// #target: macos-aarch64
module test;
extern fn int b(int y);

fn int foo(int x) @export
{
	switch (x) @jump
	{
		case 1:
			nextcase (b(x));
		case 0:
			x++;
			nextcase x;
		default:
			unreachable();
	}
}
/* #expect: test.ll

define i32 @test__foo(i32 %0) #0 {
entry:
  %x = alloca i32, align 4
  %switch = alloca i32, align 4
  store i32 %0, ptr %x, align 4
  %1 = load i32, ptr %x, align 4
  store i32 %1, ptr %switch, align 4
  br label %switch.entry

switch.entry:                                     ; preds = %entry
  %2 = load i32, ptr %switch, align 4
  %3 = icmp ugt i32 %2, 1
  br i1 %3, label %switch.default, label %jumpblock

jumpblock:                                        ; preds = %switch.entry
  %ptroffset = getelementptr inbounds [8 x i8], ptr @jumptable, i32 %2
  %target = load ptr, ptr %ptroffset, align 8
  indirectbr ptr %target, [label %switch.case, label %switch.case4, label %switch.default]

switch.case:                                      ; preds = %jumpblock5, %jumpblock1, %jumpblock
  %4 = load i32, ptr %x, align 4
  %5 = call i32 @b(i32 %4)
  %6 = icmp ugt i32 %5, 1
  br i1 %6, label %switch.default, label %jumpblock1

jumpblock1:                                       ; preds = %switch.case
  %ptroffset2 = getelementptr inbounds [8 x i8], ptr @jumptable, i32 %5
  %target3 = load ptr, ptr %ptroffset2, align 8
  indirectbr ptr %target3, [label %switch.case, label %switch.case4, label %switch.default]

switch.case4:                                     ; preds = %jumpblock5, %jumpblock, %jumpblock1
  %7 = load i32, ptr %x, align 4
  %add = add i32 %7, 1
  store i32 %add, ptr %x, align 4
  %8 = load i32, ptr %x, align 4
  %9 = icmp ugt i32 %8, 1
  br i1 %9, label %switch.default, label %jumpblock5

jumpblock5:                                       ; preds = %switch.case4
  %ptroffset6 = getelementptr inbounds [8 x i8], ptr @jumptable, i32 %8
  %target7 = load ptr, ptr %ptroffset6, align 8
  indirectbr ptr %target7, [label %switch.case, label %switch.case4, label %switch.default]

switch.default:                                   ; preds = %jumpblock, %jumpblock5, %switch.case4, %jumpblock1, %switch.case, %switch.entry
  unreachable
}
