// #target: macos-x64
module abi;

struct Vector2 {
  float x;
  float y;
}
fn Vector2 vector2_zero() @extern("vector2_zero") { return {}; }
fn Vector2 vector2_one() @extern("vector2_one") { return {}; }
fn Vector2 vector2_add(Vector2 v1, Vector2 v2) @extern("vector2_add") { return {}; }
fn Vector2 vector2_add_value(Vector2 v, float add) @extern("vector2_add_value") { return {}; }
fn Vector2 vector2_subtract(Vector2 v1, Vector2 v2) @extern("vector2_subtract") { return {}; }
fn Vector2 vector2_subtract_value(Vector2 v, float sub) @extern("vector2_subtract_value")  { return {}; }

/* #expect: abi.ll

%Vector2 = type { float, float }

define <2 x float> @vector2_zero() #0 {
entry:
  %literal = alloca %Vector2, align 4
  store float 0.000000e+00, ptr %literal, align 4
  %ptradd = getelementptr inbounds i8, ptr %literal, i64 4
  store float 0.000000e+00, ptr %ptradd, align 4
  %0 = load <2 x float>, ptr %literal, align 4
  ret <2 x float> %0
}

; Function Attrs:
define <2 x float> @vector2_one() #0 {
entry:
  %literal = alloca %Vector2, align 4
  store float 0.000000e+00, ptr %literal, align 4
  %ptradd = getelementptr inbounds i8, ptr %literal, i64 4
  store float 0.000000e+00, ptr %ptradd, align 4
  %0 = load <2 x float>, ptr %literal, align 4
  ret <2 x float> %0
}

; Function Attrs:
define <2 x float> @vector2_add(<2 x float> %0, <2 x float> %1) #0 {
entry:
  %v1 = alloca %Vector2, align 4
  %v2 = alloca %Vector2, align 4
  %literal = alloca %Vector2, align 4
  store <2 x float> %0, ptr %v1, align 4
  store <2 x float> %1, ptr %v2, align 4
  store float 0.000000e+00, ptr %literal, align 4
  %ptradd = getelementptr inbounds i8, ptr %literal, i64 4
  store float 0.000000e+00, ptr %ptradd, align 4
  %2 = load <2 x float>, ptr %literal, align 4
  ret <2 x float> %2
}

; Function Attrs:
define <2 x float> @vector2_add_value(<2 x float> %0, float %1) #0 {
entry:
  %v = alloca %Vector2, align 4
  %literal = alloca %Vector2, align 4
  store <2 x float> %0, ptr %v, align 4
  store float 0.000000e+00, ptr %literal, align 4
  %ptradd = getelementptr inbounds i8, ptr %literal, i64 4
  store float 0.000000e+00, ptr %ptradd, align 4
  %2 = load <2 x float>, ptr %literal, align 4
  ret <2 x float> %2
}

; Function Attrs:
define <2 x float> @vector2_subtract(<2 x float> %0, <2 x float> %1) #0 {
entry:
  %v1 = alloca %Vector2, align 4
  %v2 = alloca %Vector2, align 4
  %literal = alloca %Vector2, align 4
  store <2 x float> %0, ptr %v1, align 4
  store <2 x float> %1, ptr %v2, align 4
  store float 0.000000e+00, ptr %literal, align 4
  %ptradd = getelementptr inbounds i8, ptr %literal, i64 4
  store float 0.000000e+00, ptr %ptradd, align 4
  %2 = load <2 x float>, ptr %literal, align 4
  ret <2 x float> %2
}

; Function Attrs:
define <2 x float> @vector2_subtract_value(<2 x float> %0, float %1) #0 {
entry:
  %v = alloca %Vector2, align 4
  %literal = alloca %Vector2, align 4
  store <2 x float> %0, ptr %v, align 4
  store float 0.000000e+00, ptr %literal, align 4
  %ptradd = getelementptr inbounds i8, ptr %literal, i64 4
  store float 0.000000e+00, ptr %ptradd, align 4
  %2 = load <2 x float>, ptr %literal, align 4
  ret <2 x float> %2
}
