// #target: macos-x64
module test;

fn void? test()
{
	int? n;
	for (n += 1; n! < 10; n += 1);
}
fn int main()
{
	(void)test();
	int? n;
	for (n += 1; n!! < 10; n += 1);
	return 0;
}

/* #expect: test.ll

define i64 @test.test() #0 {
entry:
  %n = alloca i32, align 4
  %n.f = alloca i64, align 8
  %error_var = alloca i64, align 8
  store i64 0, ptr %n.f, align 8
  store i32 0, ptr %n, align 4
  %optval = load i64, ptr %n.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 %voiderr
after_check:                                      ; preds = %entry
  %1 = load i32, ptr %n, align 4
  %add = add i32 %1, 1
  store i32 %add, ptr %n, align 4
  br label %voiderr
voiderr:                                          ; preds = %after_check, %entry
  br label %loop.cond
loop.cond:                                        ; preds = %voiderr8, %voiderr
  %optval1 = load i64, ptr %n.f, align 8
  %not_err2 = icmp eq i64 %optval1, 0
  %2 = call i1 @llvm.expect.i1(i1 %not_err2, i1 true)
  br i1 %2, label %after_check3, label %assign_optional
assign_optional:                                  ; preds = %loop.cond
  store i64 %optval1, ptr %error_var, align 8
  br label %guard_block
after_check3:                                     ; preds = %loop.cond
  br label %noerr_block
guard_block:                                      ; preds = %assign_optional
  %3 = load i64, ptr %error_var, align 8
  ret i64 %3
noerr_block:                                      ; preds = %after_check3
  %4 = load i32, ptr %n, align 4
  %lt = icmp slt i32 %4, 10
  br i1 %lt, label %loop.body, label %loop.exit
loop.body:                                        ; preds = %noerr_block
  %optval4 = load i64, ptr %n.f, align 8
  %not_err5 = icmp eq i64 %optval4, 0
  %5 = call i1 @llvm.expect.i1(i1 %not_err5, i1 true)
  br i1 %5, label %after_check6, label %voiderr8
after_check6:                                     ; preds = %loop.body
  %6 = load i32, ptr %n, align 4
  %add7 = add i32 %6, 1
  store i32 %add7, ptr %n, align 4
  br label %voiderr8
voiderr8:                                         ; preds = %after_check6, %loop.body
  br label %loop.cond
loop.exit:                                        ; preds = %noerr_block
  ret i64 0
}

define i32 @main() #0 {
entry:
  %n = alloca i32, align 4
  %n.f = alloca i64, align 8
  %error_var = alloca i64, align 8
  %varargslots = alloca [1 x %any], align 16
  %indirectarg = alloca %"any[]", align 8
  %0 = call i64 @test.test()
  store i64 0, ptr %n.f, align 8
  store i32 0, ptr %n, align 4
  %optval = load i64, ptr %n.f, align 8
  %not_err = icmp eq i64 %optval, 0
  %1 = call i1 @llvm.expect.i1(i1 %not_err, i1 true)
  br i1 %1, label %after_check, label %voiderr
after_check:                                      ; preds = %entry
  %2 = load i32, ptr %n, align 4
  %add = add i32 %2, 1
  store i32 %add, ptr %n, align 4
  br label %voiderr
voiderr:                                          ; preds = %after_check, %entry
  br label %loop.cond
loop.cond:                                        ; preds = %voiderr8, %voiderr
  %optval1 = load i64, ptr %n.f, align 8
  %not_err2 = icmp eq i64 %optval1, 0
  %3 = call i1 @llvm.expect.i1(i1 %not_err2, i1 true)
  br i1 %3, label %after_check3, label %assign_optional
assign_optional:                                  ; preds = %loop.cond
  store i64 %optval1, ptr %error_var, align 8
  br label %panic_block
after_check3:                                     ; preds = %loop.cond
  br label %noerr_block
panic_block:                                      ; preds = %assign_optional
  %4 = insertvalue %any undef, ptr %error_var, 0
  %5 = insertvalue %any %4, i64 ptrtoint (ptr @"$ct.fault" to i64), 1
  store %any %5, ptr %varargslots, align 16
  %6 = insertvalue %"any[]" undef, ptr %varargslots, 0
  %"$$temp" = insertvalue %"any[]" %6, i64 1, 1
  store %"any[]" %"$$temp", ptr %indirectarg, align 8
  call void @std.core.builtin.panicf(
  unreachable
noerr_block:                                      ; preds = %after_check3
  %7 = load i32, ptr %n, align 4
  %lt = icmp slt i32 %7, 10
  br i1 %lt, label %loop.body, label %loop.exit
loop.body:                                        ; preds = %noerr_block
  %optval4 = load i64, ptr %n.f, align 8
  %not_err5 = icmp eq i64 %optval4, 0
  %8 = call i1 @llvm.expect.i1(i1 %not_err5, i1 true)
  br i1 %8, label %after_check6, label %voiderr8
after_check6:                                     ; preds = %loop.body
  %9 = load i32, ptr %n, align 4
  %add7 = add i32 %9, 1
  store i32 %add7, ptr %n, align 4
  br label %voiderr8
voiderr8:                                         ; preds = %after_check6, %loop.body
  br label %loop.cond
loop.exit:                                        ; preds = %noerr_block
  ret i32 0
}
