// #target: mingw-x64

module rethrow;

fn void? test()
{
    int? i;
    i!;
}

/* #expect: rethrow.ll

define i64 @rethrow.test() #0 {
entry:
  %i = alloca i32, align 4
  %i.f = alloca i64, align 8
  %error_var = alloca i64, align 8
  store i64 0, ptr %i.f, align 8
  store i32 0, ptr %i, align 4
  %optval = load i64, ptr %i.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 = %entry
  store i64 %optval, ptr %error_var, align 8
  br label %guard_block

after_check:                                      ; preds = %entry
  br label %noerr_block

guard_block:                                      ; preds = %assign_optional
  %1 = load i64, ptr %error_var, align 8
  ret i64 %1

noerr_block:                                      ; preds = %after_check
  ret i64 0
}


