// #target: macos-x64
module test;
import std::io;
// Issue 1982
fn int main()
{
	defer
	{
		int? x = 1;
		if (catch err = x) unreachable();
		int y = x;
	}
	return 0;
}
/* #expect: test.ll

define i32 @main() #0 {
entry:
  %x = alloca i32, align 4
  %x.f = alloca i64, align 8
  %err = alloca i64, align 8
  %y = alloca i32, align 4
  store i32 1, ptr %x, align 4
  store i64 0, ptr %x.f, align 8
  br label %testblock

testblock:                                        ; preds = %entry
  %optval = load i64, ptr %x.f, align 8
  %not_err = icmp eq i64 %optval, 0
  %0 = call i1 @llvm.expect.i1(i1 %not_err, i1 true)
  br i1 %0, label %after_check, label %assign_optional

assign_optional:                                  ; preds = %testblock
  store i64 %optval, ptr %err, align 8
  br label %end_block

after_check:                                      ; preds = %testblock
  store i64 0, ptr %err, align 8
  br label %end_block

end_block:                                        ; preds = %after_check, %assign_optional
  %1 = load i64, ptr %err, align 8
  %i2b = icmp ne i64 %1, 0
  br i1 %i2b, label %if.then, label %if.exit

if.then:                                          ; preds = %end_block
  unreachable

if.exit:                                          ; preds = %end_block
  %2 = load i32, ptr %x, align 4
  store i32 %2, ptr %y, align 4
  ret i32 0
}
