// #target: macos-x64
module test;
struct Foo
{
    char a;
    char b;
    char c;
}

fn int testing()
{
    Foo y = getFoo((Foo) { 4, 5, 6 });
    return y.a + y.c;
}

fn Foo getFoo(Foo f)
{
    return (Foo) { 1, 2, 3 };
}

/* #expect: test.ll

%.introspect = type { i8, i64, ptr, i64, i64, i64, [0 x i64] }
%Foo = type { i8, i8, i8 }

@"$ct.test.Foo" = linkonce global %.introspect { i8 10, i64 0, ptr null, i64 3, i64 0, i64 3, [0 x i64] zeroinitializer }, align 8

define i32 @test.testing() #0 {
entry:
  %y = alloca %Foo, align 1
  %literal = alloca %Foo, align 1
  %tempcoerce = alloca i24, align 4
  %result = alloca %Foo, align 1
  %tempcoerce1 = alloca i24, align 4
  call void @llvm.memcpy.p0.p0.i32(ptr align 1 %literal, ptr align 1 @.__const, i32 3, i1 false)
  call void @llvm.memcpy.p0.p0.i32(ptr align 4 %tempcoerce, ptr align 1 %literal, i32 3, i1 false)
  %0 = load i24, ptr %tempcoerce, align 4
  %1 = call i24 @test.getFoo(i24 %0)
  store i24 %1, ptr %tempcoerce1, align 4
  call void @llvm.memcpy.p0.p0.i32(ptr align 1 %result, ptr align 4 %tempcoerce1, i32 3, i1 false)
  call void @llvm.memcpy.p0.p0.i32(ptr align 1 %y, ptr align 1 %result, i32 3, i1 false)
  %2 = load i8, ptr %y, align 1
  %zext = zext i8 %2 to i32
  %ptradd = getelementptr inbounds i8, ptr %y, i64 2
  %3 = load i8, ptr %ptradd, align 1
  %zext2 = zext i8 %3 to i32
  %add = add i32 %zext, %zext2
  ret i32 %add
}

; Function Attrs:
define i24 @test.getFoo(i24 %0) #0 {
entry:
  %f = alloca %Foo, align 1
  %tempcoerce = alloca i24, align 4
  %literal = alloca %Foo, align 1
  %tempcoerce1 = alloca i24, align 4
  store i24 %0, ptr %tempcoerce, align 4
  call void @llvm.memcpy.p0.p0.i32(ptr align 1 %f, ptr align 4 %tempcoerce, i32 3, i1 false)
  call void @llvm.memcpy.p0.p0.i32(ptr align 1 %literal, ptr align 1 @.__const.1, i32 3, i1 false)
  call void @llvm.memcpy.p0.p0.i32(ptr align 4 %tempcoerce1, ptr align 1 %literal, i32 3, i1 false)
  %1 = load i24, ptr %tempcoerce1, align 4
  ret i24 %1
}

