// #target: macos-x64
// #safe: yes
module test;

fn int main()
{
	int a;
	test(&a, 1);
	return 0;
}

<*
 @ensure *a < b
*>
fn void test(int* a, int b)
{
	*a = b + 1;
}

/* #expect: test.ll

define void @test.test(ptr %0, i32 %1) #0 {
entry:
  %taddr = alloca i64, align 8
  %taddr2 = alloca i64, align 8
  %varargslots = alloca [2 x %any], align 16
  %indirectarg = alloca %"any[]", align 8
  %taddr8 = alloca i64, align 8
  %taddr9 = alloca i64, align 8
  %varargslots10 = alloca [2 x %any], align 16
  %indirectarg13 = alloca %"any[]", align 8
  %add = add i32 %1, 1
  %checknull = icmp eq ptr %0, null
  %2 = call i1 @llvm.expect.i1(i1 %checknull, i1 false)
  br i1 %2, label %panic, label %checkok

checkok:                                          ; preds = %entry
  %3 = ptrtoint ptr %0 to i64
  %4 = urem i64 %3, 4
  %5 = icmp ne i64 %4, 0
  %6 = call i1 @llvm.expect.i1(i1 %5, i1 false)
  br i1 %6, label %panic1, label %checkok3

checkok3:                                         ; preds = %checkok
  store i32 %add, ptr %0, align 4
  %checknull4 = icmp eq ptr %0, null
  %7 = call i1 @llvm.expect.i1(i1 %checknull4, i1 false)
  br i1 %7, label %panic5, label %checkok6

checkok6:                                         ; preds = %checkok3
  %8 = ptrtoint ptr %0 to i64
  %9 = urem i64 %8, 4
  %10 = icmp ne i64 %9, 0
  %11 = call i1 @llvm.expect.i1(i1 %10, i1 false)
  br i1 %11, label %panic7, label %checkok14

checkok14:                                        ; preds = %checkok6
  %12 = load i32, ptr %0, align 4
  %lt = icmp slt i32 %12, %1
  br i1 %lt, label %assert_ok, label %assert_fail

assert_fail:                                      ; preds = %checkok14
  %13 = load ptr, ptr @std.core.builtin.panic, align 8
  call void %13(ptr @.panic_msg.2, i64 26, ptr @.file, i64 24, ptr @.func, i64 4, i32 14) #2
  unreachable

assert_ok:                                        ; preds = %checkok14
  ret void

panic:                                            ; preds = %entry
  %14 = load ptr, ptr @std.core.builtin.panic, align 8
  call void %14(ptr @.panic_msg, i64 42, ptr @.file, i64 24, ptr @.func, i64 4, i32 15) #2
  unreachable

panic1:                                           ; preds = %checkok
  store i64 4, ptr %taddr, align 8
  %15 = insertvalue %any undef, ptr %taddr, 0
  %16 = insertvalue %any %15, i64 ptrtoint (ptr @"$ct.ulong" to i64), 1
  store i64 %4, ptr %taddr2, align 8
  %17 = insertvalue %any undef, ptr %taddr2, 0
  %18 = insertvalue %any %17, i64 ptrtoint (ptr @"$ct.ulong" to i64), 1
  store %any %16, ptr %varargslots, align 16
  %ptradd = getelementptr inbounds i8, ptr %varargslots, i64 16
  store %any %18, ptr %ptradd, align 16
  %19 = insertvalue %"any[]" undef, ptr %varargslots, 0
  %"$$temp" = insertvalue %"any[]" %19, i64 2, 1
  store %"any[]" %"$$temp", ptr %indirectarg, align 8
  call void @std.core.builtin.panicf(ptr @.panic_msg.1, i64 94, ptr @.file, i64 24, ptr @.func, i64 4, i32 15, ptr byval(%"any[]") align 8 %indirectarg) #2
  unreachable

panic5:                                           ; preds = %checkok3
  %20 = load ptr, ptr @std.core.builtin.panic, align 8
  call void %20(ptr @.panic_msg, i64 42, ptr @.file, i64 24, ptr @.func, i64 4, i32 11) #2
  unreachable

panic7:                                           ; preds = %checkok6
  store i64 4, ptr %taddr8, align 8
  %21 = insertvalue %any undef, ptr %taddr8, 0
  %22 = insertvalue %any %21, i64 ptrtoint (ptr @"$ct.ulong" to i64), 1
  store i64 %9, ptr %taddr9, align 8
  %23 = insertvalue %any undef, ptr %taddr9, 0
  %24 = insertvalue %any %23, i64 ptrtoint (ptr @"$ct.ulong" to i64), 1
  store %any %22, ptr %varargslots10, align 16
  %ptradd11 = getelementptr inbounds i8, ptr %varargslots10, i64 16
  store %any %24, ptr %ptradd11, align 16
  %25 = insertvalue %"any[]" undef, ptr %varargslots10, 0
  %"$$temp12" = insertvalue %"any[]" %25, i64 2, 1
  store %"any[]" %"$$temp12", ptr %indirectarg13, align 8
  call void @std.core.builtin.panicf(ptr @.panic_msg.1, i64 94, ptr @.file, i64 24, ptr @.func, i64 4, i32 11, ptr byval(%"any[]") align 8 %indirectarg13) #2
  unreachable
}
