; LLVM IR from St0wy/StowyPhysicsEngine :: StowyPhysicsEngine/src/math/Vector2.ll (ZN3stw7Vector213TripleProductERKS0_S2_S2_)

; Unoptimized IR (clang -disable-llvm-passes):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

%"struct.stw::Vector2" = type { float, float }

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare float @llvm.fmuladd.f32(float, float, float) #0

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN3stw7Vector2C2Eff(ptr noundef nonnull align 4 dereferenceable(8), float noundef, float noundef) unnamed_addr #1 align 2

; Function Attrs: mustprogress uwtable
define dso_local <2 x float> @_ZN3stw7Vector213TripleProductERKS0_S2_S2_(ptr noundef nonnull align 4 dereferenceable(8) %0, ptr noundef nonnull align 4 dereferenceable(8) %1, ptr noundef nonnull align 4 dereferenceable(8) %2) #2 align 2 {
  %4 = alloca %"struct.stw::Vector2", align 4
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store ptr %2, ptr %7, align 8, !tbaa !5
  %8 = load ptr, ptr %5, align 8, !tbaa !5
  %9 = getelementptr inbounds %"struct.stw::Vector2", ptr %8, i32 0, i32 1
  %10 = load float, ptr %9, align 4, !tbaa !9
  %11 = load ptr, ptr %6, align 8, !tbaa !5
  %12 = getelementptr inbounds %"struct.stw::Vector2", ptr %11, i32 0, i32 0
  %13 = load float, ptr %12, align 4, !tbaa !12
  %14 = load ptr, ptr %7, align 8, !tbaa !5
  %15 = getelementptr inbounds %"struct.stw::Vector2", ptr %14, i32 0, i32 1
  %16 = load float, ptr %15, align 4, !tbaa !9
  %17 = load ptr, ptr %6, align 8, !tbaa !5
  %18 = getelementptr inbounds %"struct.stw::Vector2", ptr %17, i32 0, i32 1
  %19 = load float, ptr %18, align 4, !tbaa !9
  %20 = load ptr, ptr %7, align 8, !tbaa !5
  %21 = getelementptr inbounds %"struct.stw::Vector2", ptr %20, i32 0, i32 0
  %22 = load float, ptr %21, align 4, !tbaa !12
  %23 = fmul float %19, %22
  %24 = fneg float %23
  %25 = call float @llvm.fmuladd.f32(float %13, float %16, float %24)
  %26 = fmul float %10, %25
  %27 = load ptr, ptr %5, align 8, !tbaa !5
  %28 = getelementptr inbounds %"struct.stw::Vector2", ptr %27, i32 0, i32 0
  %29 = load float, ptr %28, align 4, !tbaa !12
  %30 = load ptr, ptr %6, align 8, !tbaa !5
  %31 = getelementptr inbounds %"struct.stw::Vector2", ptr %30, i32 0, i32 1
  %32 = load float, ptr %31, align 4, !tbaa !9
  %33 = load ptr, ptr %7, align 8, !tbaa !5
  %34 = getelementptr inbounds %"struct.stw::Vector2", ptr %33, i32 0, i32 0
  %35 = load float, ptr %34, align 4, !tbaa !12
  %36 = load ptr, ptr %6, align 8, !tbaa !5
  %37 = getelementptr inbounds %"struct.stw::Vector2", ptr %36, i32 0, i32 0
  %38 = load float, ptr %37, align 4, !tbaa !12
  %39 = load ptr, ptr %7, align 8, !tbaa !5
  %40 = getelementptr inbounds %"struct.stw::Vector2", ptr %39, i32 0, i32 1
  %41 = load float, ptr %40, align 4, !tbaa !9
  %42 = fmul float %38, %41
  %43 = fneg float %42
  %44 = call float @llvm.fmuladd.f32(float %32, float %35, float %43)
  %45 = fmul float %29, %44
  call void @_ZN3stw7Vector2C2Eff(ptr noundef nonnull align 4 dereferenceable(8) %4, float noundef %26, float noundef %45)
  %46 = load <2 x float>, ptr %4, align 4
  ret <2 x float> %46
}

attributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #1 = { mustprogress nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { mustprogress uwtable "min-legal-vector-width"="64" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !11, i64 4}
!10 = !{!"_ZTSN3stw7Vector2E", !11, i64 0, !11, i64 4}
!11 = !{!"float", !7, i64 0}
!12 = !{!10, !11, i64 0}


; Optimized IR (opt -passes='default<O3>'):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

%"struct.stw::Vector2" = type { float, float }

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare float @llvm.fmuladd.f32(float, float, float) #0

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN3stw7Vector2C2Eff(ptr noundef nonnull align 4 dereferenceable(8), float noundef, float noundef) unnamed_addr #1 align 2

; Function Attrs: mustprogress nounwind uwtable
define dso_local <2 x float> @_ZN3stw7Vector213TripleProductERKS0_S2_S2_(ptr nocapture noundef nonnull readonly align 4 dereferenceable(8) %0, ptr nocapture noundef nonnull readonly align 4 dereferenceable(8) %1, ptr nocapture noundef nonnull readonly align 4 dereferenceable(8) %2) local_unnamed_addr #2 align 2 {
  %4 = alloca %"struct.stw::Vector2", align 8
  %5 = getelementptr inbounds i8, ptr %0, i64 4
  %6 = load float, ptr %5, align 4, !tbaa !5
  %7 = load float, ptr %1, align 4, !tbaa !10
  %8 = getelementptr inbounds i8, ptr %2, i64 4
  %9 = load float, ptr %8, align 4, !tbaa !5
  %10 = getelementptr inbounds i8, ptr %1, i64 4
  %11 = load float, ptr %10, align 4, !tbaa !5
  %12 = load float, ptr %2, align 4, !tbaa !10
  %13 = fneg float %11
  %14 = fmul float %12, %13
  %15 = tail call float @llvm.fmuladd.f32(float %7, float %9, float %14)
  %16 = fmul float %6, %15
  %17 = load float, ptr %0, align 4, !tbaa !10
  %18 = fneg float %7
  %19 = fmul float %9, %18
  %20 = tail call float @llvm.fmuladd.f32(float %11, float %12, float %19)
  %21 = fmul float %17, %20
  call void @_ZN3stw7Vector2C2Eff(ptr noundef nonnull align 4 dereferenceable(8) %4, float noundef %16, float noundef %21)
  %22 = load <2 x float>, ptr %4, align 8
  ret <2 x float> %22
}

attributes #0 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #1 = { mustprogress nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { mustprogress nounwind uwtable "min-legal-vector-width"="64" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !7, i64 4}
!6 = !{!"_ZTSN3stw7Vector2E", !7, i64 0, !7, i64 4}
!7 = !{!"float", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!6, !7, i64 0}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,TailCallElimPass