// #target: macos-x64
module test;

fn int? foo() => 1;

fn int main()
{
	int[*]? x = { 1, 2 };
	int[*]? y = { foo(), foo() };
	int[<*>]? x2 = { 1, 2 };
	int[<*>]? y2 = { foo(), foo() };
	return 1;
}

/* #expect: test.ll


define i32 @main() #0 {
entry:
  %x = alloca [2 x i32], align 4
  %x.f = alloca i64, align 8
  %y = alloca [2 x i32], align 4
  %y.f = alloca i64, align 8
  %retparam = alloca i32, align 4
  %retparam1 = alloca i32, align 4
  %x2 = alloca <2 x i32>, align 8
  %x2.f = alloca i64, align 8
  %y2 = alloca <2 x i32>, align 8
  %y2.f = alloca i64, align 8
  %retparam5 = alloca i32, align 4
  %retparam9 = alloca i32, align 4
  call void @llvm.memcpy.p0.p0.i32(ptr align 4 %x, ptr align 4 @.__const, i32 8, i1 false)
  store i64 0, ptr %x.f, align 8
  %0 = call i64 @test.foo(ptr %retparam)
  %not_err = icmp eq i64 %0, 0
  %1 = call i1 @llvm.expect.i1(i1 %not_err, i1 true)
  br i1 %1, label %after_check, label %assign_optional

assign_optional:                                  ; preds = %entry
  store i64 %0, ptr %y.f, align 8
  br label %after_assign

after_check:                                      ; preds = %entry
  %2 = load i32, ptr %retparam, align 4
  store i32 %2, ptr %y, align 4
  %ptradd = getelementptr inbounds i8, ptr %y, i64 4
  %3 = call i64 @test.foo(ptr %retparam1)
  %not_err2 = icmp eq i64 %3, 0
  %4 = call i1 @llvm.expect.i1(i1 %not_err2, i1 true)
  br i1 %4, label %after_check4, label %assign_optional3

assign_optional3:                                 ; preds = %after_check
  store i64 %3, ptr %y.f, align 8
  br label %after_assign

after_check4:                                     ; preds = %after_check
  %5 = load i32, ptr %retparam1, align 4
  store i32 %5, ptr %ptradd, align 4
  store i64 0, ptr %y.f, align 8
  br label %after_assign

after_assign:                                     ; preds = %after_check4, %assign_optional3, %assign_optional
  store <2 x i32> <i32 1, i32 2>, ptr %x2, align 8
  store i64 0, ptr %x2.f, align 8
  %6 = call i64 @test.foo(ptr %retparam5)
  %not_err6 = icmp eq i64 %6, 0
  %7 = call i1 @llvm.expect.i1(i1 %not_err6, i1 true)
  br i1 %7, label %after_check8, label %assign_optional7

assign_optional7:                                 ; preds = %after_assign
  store i64 %6, ptr %y2.f, align 8
  br label %after_assign13

after_check8:                                     ; preds = %after_assign
  %8 = load i32, ptr %retparam5, align 4
  %9 = insertelement <2 x i32> undef, i32 %8, i64 0
  %10 = call i64 @test.foo(ptr %retparam9)
  %not_err10 = icmp eq i64 %10, 0
  %11 = call i1 @llvm.expect.i1(i1 %not_err10, i1 true)
  br i1 %11, label %after_check12, label %assign_optional11

assign_optional11:                                ; preds = %after_check8
  store i64 %10, ptr %y2.f, align 8
  br label %after_assign13

after_check12:                                    ; preds = %after_check8
  %12 = load i32, ptr %retparam9, align 4
  %13 = insertelement <2 x i32> %9, i32 %12, i64 1
  store <2 x i32> %13, ptr %y2, align 8
  store i64 0, ptr %y2.f, align 8
  br label %after_assign13
