// #target: macos-x64
// #debuginfo: yes
module test;
extern fn void printf(char*,...);

fn void test(int x)
{
	defer
	{
		do
		{
			defer {
				x = 0;
				printf("Hello\n");
				defer x = 1;
			}
			if (x < 100) break;
		};
	}
}

fn int main()
{
	test(0);
	return 0;
}

/* #expect: test.ll

  %x = alloca i32, align 4
  store i32 %0, ptr %x, align 4
  %1 = load i32, ptr %x, align 4, !dbg !15
  %lt = icmp slt i32 %1, 100, !dbg !15
  br i1 %lt, label %if.then, label %if.exit, !dbg !15
if.then:                                          ; preds = %entry
  store i32 0, ptr %x, align 4, !dbg !19
  call void (ptr, ...) @printf(ptr @.str), !dbg !21
  store i32 1, ptr %x, align 4, !dbg !22
  br label %loop.exit, !dbg !22
if.exit:                                          ; preds = %entry
  store i32 0, ptr %x, align 4, !dbg !24
  call void (ptr, ...) @printf(ptr @.str.1), !dbg !26
  store i32 1, ptr %x, align 4, !dbg !27
  br label %loop.exit, !dbg !27
loop.exit:                                        ; preds = %if.exit, %if.then
  ret void, !dbg !27