// #target: macos-x64
import std::io;
import libc;
union Baz
{
    int x;
    double y;
}
struct Bar
{
    int x;
    int y;
}


fn void test()
{
    Bar[] b = { { 1, 2 } };
    static Bar[] c = { { 1, 2 } };
    libc::printf("%d %d\n", b[0].y, c[0].y);
    b[0].y += 1;
    c[0].y += 1;

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

/* #expect: statics.ll

%Bar = type { i32, i32 }
%"Bar[]" = type { ptr, i64 }

@"$ct.statics.Baz" = linkonce global %.introspect { i8 11, i64 0, ptr null, i64 8, i64 0, i64 2, [0 x i64] zeroinitializer }, align 8
@"$ct.statics.Bar" = linkonce global %.introspect { i8 10, i64 0, ptr null, i64 8, i64 0, i64 2, [0 x i64] zeroinitializer }, align 8
@.__const = private unnamed_addr constant [1 x %Bar] [%Bar { i32 1, i32 2 }], align 4
@.__const_slice = private unnamed_addr global [1 x %Bar] [%Bar { i32 1, i32 2 }], align 4
@test.c = internal unnamed_addr global %"Bar[]" { ptr @.__const_slice, i64 1 }, align 8
@.str = private unnamed_addr constant [7 x i8] c"%d %d\0A\00", align 1

; Function Attrs:
define void @statics.test() #0 {
entry:
  %b = alloca %"Bar[]", align 8
  %literal = alloca [1 x %Bar], align 4
  call void @llvm.memcpy.p0.p0.i32(ptr align 4 %literal, ptr align 4 @.__const, i32 8, i1 false)
  %0 = insertvalue %"Bar[]" undef, ptr %literal, 0
  %1 = insertvalue %"Bar[]" %0, i64 1, 1
  store %"Bar[]" %1, ptr %b, align 8
  %2 = load ptr, ptr %b, align 8
  %ptradd = getelementptr inbounds i8, ptr %2, i64 4
  %3 = load ptr, ptr @test.c, align 8
  %ptradd1 = getelementptr inbounds i8, ptr %3, i64 4
  %4 = load i32, ptr %ptradd, align 4
  %5 = load i32, ptr %ptradd1, align 4
  %6 = call i32 (ptr, ...) @printf(ptr @.str, i32 %4, i32 %5)
  %7 = load ptr, ptr %b, align 8
  %ptradd2 = getelementptr inbounds i8, ptr %7, i64 4
  %8 = load i32, ptr %ptradd2, align 4
  %add = add i32 %8, 1
  store i32 %add, ptr %ptradd2, align 4
  %9 = load ptr, ptr @test.c, align 8
  %ptradd3 = getelementptr inbounds i8, ptr %9, i64 4
  %10 = load i32, ptr %ptradd3, align 4
  %add4 = add i32 %10, 1
  store i32 %add4, ptr %ptradd3, align 4
  ret void
}
