; LLVM IR from szxp/3d-soft-engine :: src/Quaternion.ll (ZN2g3mlERKNS_10QuaternionES2_)

; 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.g3::Quaternion" = type { %"class.g3::Vec", float }
%"class.g3::Vec" = type { [3 x float] }
%"class.std::initializer_list" = type { ptr, i64 }

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #0

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

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN2g3mlERKNS_10QuaternionES2_(ptr dead_on_unwind noalias writable sret(%"struct.g3::Quaternion") align 4 %0, ptr noundef nonnull align 4 dereferenceable(16) %1, ptr noundef nonnull align 4 dereferenceable(16) %2) #2 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca float, align 4
  %8 = alloca float, align 4
  %9 = alloca float, align 4
  %10 = alloca float, align 4
  %11 = alloca float, align 4
  %12 = alloca float, align 4
  %13 = alloca float, align 4
  %14 = alloca float, align 4
  %15 = alloca %"class.std::initializer_list", align 8
  %16 = alloca [3 x float], align 4
  store ptr %0, ptr %4, align 8
  store ptr %1, ptr %5, align 8, !tbaa !5
  store ptr %2, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #4
  %17 = load ptr, ptr %5, align 8, !tbaa !5
  %18 = getelementptr inbounds %"struct.g3::Quaternion", ptr %17, i32 0, i32 0
  %19 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNK2g33VecILm3EEixEi(ptr noundef nonnull align 4 dereferenceable(12) %18, i32 noundef 0)
  %20 = load float, ptr %19, align 4, !tbaa !9
  store float %20, ptr %7, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #4
  %21 = load ptr, ptr %5, align 8, !tbaa !5
  %22 = getelementptr inbounds %"struct.g3::Quaternion", ptr %21, i32 0, i32 0
  %23 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNK2g33VecILm3EEixEi(ptr noundef nonnull align 4 dereferenceable(12) %22, i32 noundef 1)
  %24 = load float, ptr %23, align 4, !tbaa !9
  store float %24, ptr %8, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #4
  %25 = load ptr, ptr %5, align 8, !tbaa !5
  %26 = getelementptr inbounds %"struct.g3::Quaternion", ptr %25, i32 0, i32 0
  %27 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNK2g33VecILm3EEixEi(ptr noundef nonnull align 4 dereferenceable(12) %26, i32 noundef 2)
  %28 = load float, ptr %27, align 4, !tbaa !9
  store float %28, ptr %9, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #4
  %29 = load ptr, ptr %5, align 8, !tbaa !5
  %30 = getelementptr inbounds %"struct.g3::Quaternion", ptr %29, i32 0, i32 1
  %31 = load float, ptr %30, align 4, !tbaa !11
  store float %31, ptr %10, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #4
  %32 = load ptr, ptr %6, align 8, !tbaa !5
  %33 = getelementptr inbounds %"struct.g3::Quaternion", ptr %32, i32 0, i32 0
  %34 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNK2g33VecILm3EEixEi(ptr noundef nonnull align 4 dereferenceable(12) %33, i32 noundef 0)
  %35 = load float, ptr %34, align 4, !tbaa !9
  store float %35, ptr %11, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #4
  %36 = load ptr, ptr %6, align 8, !tbaa !5
  %37 = getelementptr inbounds %"struct.g3::Quaternion", ptr %36, i32 0, i32 0
  %38 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNK2g33VecILm3EEixEi(ptr noundef nonnull align 4 dereferenceable(12) %37, i32 noundef 1)
  %39 = load float, ptr %38, align 4, !tbaa !9
  store float %39, ptr %12, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #4
  %40 = load ptr, ptr %6, align 8, !tbaa !5
  %41 = getelementptr inbounds %"struct.g3::Quaternion", ptr %40, i32 0, i32 0
  %42 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNK2g33VecILm3EEixEi(ptr noundef nonnull align 4 dereferenceable(12) %41, i32 noundef 2)
  %43 = load float, ptr %42, align 4, !tbaa !9
  store float %43, ptr %13, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #4
  %44 = load ptr, ptr %6, align 8, !tbaa !5
  %45 = getelementptr inbounds %"struct.g3::Quaternion", ptr %44, i32 0, i32 1
  %46 = load float, ptr %45, align 4, !tbaa !11
  store float %46, ptr %14, align 4, !tbaa !9
  %47 = getelementptr inbounds %"struct.g3::Quaternion", ptr %0, i32 0, i32 0
  call void @llvm.lifetime.start.p0(i64 12, ptr %16) #4
  %48 = load float, ptr %10, align 4, !tbaa !9
  %49 = load float, ptr %11, align 4, !tbaa !9
  %50 = load float, ptr %7, align 4, !tbaa !9
  %51 = load float, ptr %14, align 4, !tbaa !9
  %52 = fmul float %50, %51
  %53 = call float @llvm.fmuladd.f32(float %48, float %49, float %52)
  %54 = load float, ptr %8, align 4, !tbaa !9
  %55 = load float, ptr %13, align 4, !tbaa !9
  %56 = call float @llvm.fmuladd.f32(float %54, float %55, float %53)
  %57 = load float, ptr %9, align 4, !tbaa !9
  %58 = load float, ptr %12, align 4, !tbaa !9
  %59 = fneg float %57
  %60 = call float @llvm.fmuladd.f32(float %59, float %58, float %56)
  store float %60, ptr %16, align 4, !tbaa !9
  %61 = getelementptr inbounds float, ptr %16, i64 1
  %62 = load float, ptr %10, align 4, !tbaa !9
  %63 = load float, ptr %12, align 4, !tbaa !9
  %64 = load float, ptr %7, align 4, !tbaa !9
  %65 = load float, ptr %13, align 4, !tbaa !9
  %66 = fmul float %64, %65
  %67 = fneg float %66
  %68 = call float @llvm.fmuladd.f32(float %62, float %63, float %67)
  %69 = load float, ptr %8, align 4, !tbaa !9
  %70 = load float, ptr %14, align 4, !tbaa !9
  %71 = call float @llvm.fmuladd.f32(float %69, float %70, float %68)
  %72 = load float, ptr %9, align 4, !tbaa !9
  %73 = load float, ptr %11, align 4, !tbaa !9
  %74 = call float @llvm.fmuladd.f32(float %72, float %73, float %71)
  store float %74, ptr %61, align 4, !tbaa !9
  %75 = getelementptr inbounds float, ptr %16, i64 2
  %76 = load float, ptr %10, align 4, !tbaa !9
  %77 = load float, ptr %13, align 4, !tbaa !9
  %78 = load float, ptr %7, align 4, !tbaa !9
  %79 = load float, ptr %12, align 4, !tbaa !9
  %80 = fmul float %78, %79
  %81 = call float @llvm.fmuladd.f32(float %76, float %77, float %80)
  %82 = load float, ptr %8, align 4, !tbaa !9
  %83 = load float, ptr %11, align 4, !tbaa !9
  %84 = fneg float %82
  %85 = call float @llvm.fmuladd.f32(float %84, float %83, float %81)
  %86 = load float, ptr %9, align 4, !tbaa !9
  %87 = load float, ptr %14, align 4, !tbaa !9
  %88 = call float @llvm.fmuladd.f32(float %86, float %87, float %85)
  store float %88, ptr %75, align 4, !tbaa !9
  %89 = getelementptr inbounds %"class.std::initializer_list", ptr %15, i32 0, i32 0
  store ptr %16, ptr %89, align 8, !tbaa !14
  %90 = getelementptr inbounds %"class.std::initializer_list", ptr %15, i32 0, i32 1
  store i64 3, ptr %90, align 8, !tbaa !17
  %91 = getelementptr inbounds { ptr, i64 }, ptr %15, i32 0, i32 0
  %92 = load ptr, ptr %91, align 8
  %93 = getelementptr inbounds { ptr, i64 }, ptr %15, i32 0, i32 1
  %94 = load i64, ptr %93, align 8
  call void @_ZN2g33VecILm3EEC2ESt16initializer_listIfE(ptr noundef nonnull align 4 dereferenceable(12) %47, ptr %92, i64 %94)
  %95 = getelementptr inbounds %"struct.g3::Quaternion", ptr %0, i32 0, i32 1
  %96 = load float, ptr %10, align 4, !tbaa !9
  %97 = load float, ptr %14, align 4, !tbaa !9
  %98 = load float, ptr %7, align 4, !tbaa !9
  %99 = load float, ptr %11, align 4, !tbaa !9
  %100 = fmul float %98, %99
  %101 = fneg float %100
  %102 = call float @llvm.fmuladd.f32(float %96, float %97, float %101)
  %103 = load float, ptr %8, align 4, !tbaa !9
  %104 = load float, ptr %12, align 4, !tbaa !9
  %105 = fneg float %103
  %106 = call float @llvm.fmuladd.f32(float %105, float %104, float %102)
  %107 = load float, ptr %9, align 4, !tbaa !9
  %108 = load float, ptr %13, align 4, !tbaa !9
  %109 = fneg float %107
  %110 = call float @llvm.fmuladd.f32(float %109, float %108, float %106)
  store float %110, ptr %95, align 4, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 12, ptr %16) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  ret void
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZNK2g33VecILm3EEixEi(ptr noundef nonnull align 4 dereferenceable(12), i32 noundef) #1 align 2

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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"="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 #3 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #4 = { nounwind }

!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, !10, i64 0}
!10 = !{!"float", !7, i64 0}
!11 = !{!12, !10, i64 12}
!12 = !{!"_ZTSN2g310QuaternionE", !13, i64 0, !10, i64 12}
!13 = !{!"_ZTSN2g33VecILm3EEE", !7, i64 0}
!14 = !{!15, !6, i64 0}
!15 = !{!"_ZTSSt16initializer_listIfE", !6, i64 0, !16, i64 8}
!16 = !{!"long", !7, i64 0}
!17 = !{!15, !16, i64 8}


; 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.g3::Quaternion" = type { %"class.g3::Vec", float }
%"class.g3::Vec" = type { [3 x float] }

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #0

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

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN2g3mlERKNS_10QuaternionES2_(ptr dead_on_unwind noalias writable sret(%"struct.g3::Quaternion") align 4 %0, ptr noundef nonnull align 4 dereferenceable(16) %1, ptr noundef nonnull align 4 dereferenceable(16) %2) local_unnamed_addr #1 {
  %4 = alloca [3 x float], align 8
  %5 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNK2g33VecILm3EEixEi(ptr noundef nonnull align 4 dereferenceable(12) %1, i32 noundef 0)
  %6 = load float, ptr %5, align 4, !tbaa !5
  %7 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNK2g33VecILm3EEixEi(ptr noundef nonnull align 4 dereferenceable(12) %1, i32 noundef 1)
  %8 = load float, ptr %7, align 4, !tbaa !5
  %9 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNK2g33VecILm3EEixEi(ptr noundef nonnull align 4 dereferenceable(12) %1, i32 noundef 2)
  %10 = load float, ptr %9, align 4, !tbaa !5
  %11 = getelementptr inbounds i8, ptr %1, i64 12
  %12 = load float, ptr %11, align 4, !tbaa !9
  %13 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNK2g33VecILm3EEixEi(ptr noundef nonnull align 4 dereferenceable(12) %2, i32 noundef 0)
  %14 = load float, ptr %13, align 4, !tbaa !5
  %15 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNK2g33VecILm3EEixEi(ptr noundef nonnull align 4 dereferenceable(12) %2, i32 noundef 1)
  %16 = load float, ptr %15, align 4, !tbaa !5
  %17 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNK2g33VecILm3EEixEi(ptr noundef nonnull align 4 dereferenceable(12) %2, i32 noundef 2)
  %18 = load float, ptr %17, align 4, !tbaa !5
  %19 = getelementptr inbounds i8, ptr %2, i64 12
  %20 = load float, ptr %19, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 12, ptr nonnull %4) #4
  %21 = fneg float %10
  %22 = fneg float %6
  %23 = insertelement <2 x float> poison, float %6, i64 0
  %24 = insertelement <2 x float> %23, float %18, i64 1
  %25 = insertelement <2 x float> poison, float %20, i64 0
  %26 = insertelement <2 x float> %25, float %22, i64 1
  %27 = fmul <2 x float> %24, %26
  %28 = insertelement <2 x float> poison, float %12, i64 0
  %29 = shufflevector <2 x float> %28, <2 x float> poison, <2 x i32> zeroinitializer
  %30 = insertelement <2 x float> poison, float %14, i64 0
  %31 = insertelement <2 x float> %30, float %16, i64 1
  %32 = tail call <2 x float> @llvm.fmuladd.v2f32(<2 x float> %29, <2 x float> %31, <2 x float> %27)
  %33 = insertelement <2 x float> poison, float %8, i64 0
  %34 = shufflevector <2 x float> %33, <2 x float> poison, <2 x i32> zeroinitializer
  %35 = insertelement <2 x float> poison, float %18, i64 0
  %36 = insertelement <2 x float> %35, float %20, i64 1
  %37 = tail call <2 x float> @llvm.fmuladd.v2f32(<2 x float> %34, <2 x float> %36, <2 x float> %32)
  %38 = insertelement <2 x float> poison, float %21, i64 0
  %39 = insertelement <2 x float> %38, float %10, i64 1
  %40 = insertelement <2 x float> poison, float %16, i64 0
  %41 = insertelement <2 x float> %40, float %14, i64 1
  %42 = tail call <2 x float> @llvm.fmuladd.v2f32(<2 x float> %39, <2 x float> %41, <2 x float> %37)
  store <2 x float> %42, ptr %4, align 8, !tbaa !5
  %43 = getelementptr inbounds i8, ptr %4, i64 8
  %44 = fmul float %6, %16
  %45 = tail call float @llvm.fmuladd.f32(float %12, float %18, float %44)
  %46 = fneg float %8
  %47 = tail call float @llvm.fmuladd.f32(float %46, float %14, float %45)
  %48 = tail call float @llvm.fmuladd.f32(float %10, float %20, float %47)
  store float %48, ptr %43, align 8, !tbaa !5
  call void @_ZN2g33VecILm3EEC2ESt16initializer_listIfE(ptr noundef nonnull align 4 dereferenceable(12) %0, ptr nonnull %4, i64 3)
  %49 = getelementptr inbounds i8, ptr %0, i64 12
  %50 = fmul float %14, %22
  %51 = call float @llvm.fmuladd.f32(float %12, float %20, float %50)
  %52 = call float @llvm.fmuladd.f32(float %46, float %16, float %51)
  %53 = call float @llvm.fmuladd.f32(float %21, float %18, float %52)
  store float %53, ptr %49, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 12, ptr nonnull %4) #4
  ret void
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZNK2g33VecILm3EEixEi(ptr noundef nonnull align 4 dereferenceable(12), i32 noundef) local_unnamed_addr #1 align 2

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

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare <2 x float> @llvm.fmuladd.v2f32(<2 x float>, <2 x float>, <2 x float>) #3

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #3 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #4 = { nounwind }

!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 = !{!"float", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !6, i64 12}
!10 = !{!"_ZTSN2g310QuaternionE", !11, i64 0, !6, i64 12}
!11 = !{!"_ZTSN2g33VecILm3EEE", !7, i64 0}


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