; LLVM IR from ashishzero/karma :: src/modules/core/lin_maths.ll (Z13quat_get_mat44Quat)

; 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"

%union.Mat4 = type { [4 x %union.Vec4] }
%union.Vec4 = type { %struct.anon.3 }
%struct.anon.3 = type { float, float, float, float }
%union.Quat = type { [4 x float] }
%struct.anon.18 = type { float, float, float, float }

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

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

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

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_Z13quat_get_mat44Quat(ptr dead_on_unwind noalias writable sret(%union.Mat4) align 4 %0, <2 x float> %1, <2 x float> %2) #2 {
  %4 = alloca %union.Quat, align 4
  %5 = alloca float, align 4
  %6 = alloca float, align 4
  %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 float, align 4
  %16 = alloca float, align 4
  %17 = alloca float, align 4
  %18 = getelementptr inbounds { <2 x float>, <2 x float> }, ptr %4, i32 0, i32 0
  store <2 x float> %1, ptr %18, align 4
  %19 = getelementptr inbounds { <2 x float>, <2 x float> }, ptr %4, i32 0, i32 1
  store <2 x float> %2, ptr %19, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #3
  %20 = getelementptr inbounds %struct.anon.18, ptr %4, i32 0, i32 0
  %21 = load float, ptr %20, align 4, !tbaa !5
  store float %21, ptr %5, align 4, !tbaa !8
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #3
  %22 = getelementptr inbounds %struct.anon.18, ptr %4, i32 0, i32 1
  %23 = load float, ptr %22, align 4, !tbaa !5
  store float %23, ptr %6, align 4, !tbaa !8
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #3
  %24 = getelementptr inbounds %struct.anon.18, ptr %4, i32 0, i32 2
  %25 = load float, ptr %24, align 4, !tbaa !5
  store float %25, ptr %7, align 4, !tbaa !8
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #3
  %26 = getelementptr inbounds %struct.anon.18, ptr %4, i32 0, i32 3
  %27 = load float, ptr %26, align 4, !tbaa !5
  store float %27, ptr %8, align 4, !tbaa !8
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #3
  %28 = load float, ptr %5, align 4, !tbaa !8
  %29 = load float, ptr %5, align 4, !tbaa !8
  %30 = fmul float %28, %29
  store float %30, ptr %9, align 4, !tbaa !8
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #3
  %31 = load float, ptr %6, align 4, !tbaa !8
  %32 = load float, ptr %6, align 4, !tbaa !8
  %33 = fmul float %31, %32
  store float %33, ptr %10, align 4, !tbaa !8
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #3
  %34 = load float, ptr %7, align 4, !tbaa !8
  %35 = load float, ptr %7, align 4, !tbaa !8
  %36 = fmul float %34, %35
  store float %36, ptr %11, align 4, !tbaa !8
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #3
  %37 = load float, ptr %5, align 4, !tbaa !8
  %38 = load float, ptr %6, align 4, !tbaa !8
  %39 = fmul float %37, %38
  store float %39, ptr %12, align 4, !tbaa !8
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #3
  %40 = load float, ptr %6, align 4, !tbaa !8
  %41 = load float, ptr %7, align 4, !tbaa !8
  %42 = fmul float %40, %41
  store float %42, ptr %13, align 4, !tbaa !8
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #3
  %43 = load float, ptr %7, align 4, !tbaa !8
  %44 = load float, ptr %8, align 4, !tbaa !8
  %45 = fmul float %43, %44
  store float %45, ptr %14, align 4, !tbaa !8
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #3
  %46 = load float, ptr %6, align 4, !tbaa !8
  %47 = load float, ptr %8, align 4, !tbaa !8
  %48 = fmul float %46, %47
  store float %48, ptr %15, align 4, !tbaa !8
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #3
  %49 = load float, ptr %5, align 4, !tbaa !8
  %50 = load float, ptr %8, align 4, !tbaa !8
  %51 = fmul float %49, %50
  store float %51, ptr %16, align 4, !tbaa !8
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #3
  %52 = load float, ptr %5, align 4, !tbaa !8
  %53 = load float, ptr %7, align 4, !tbaa !8
  %54 = fmul float %52, %53
  store float %54, ptr %17, align 4, !tbaa !8
  %55 = load float, ptr %10, align 4, !tbaa !8
  %56 = load float, ptr %11, align 4, !tbaa !8
  %57 = fadd float %55, %56
  %58 = call float @llvm.fmuladd.f32(float -2.000000e+00, float %57, float 1.000000e+00)
  %59 = getelementptr inbounds [4 x [4 x float]], ptr %0, i64 0, i64 0
  %60 = getelementptr inbounds [4 x float], ptr %59, i64 0, i64 0
  store float %58, ptr %60, align 4, !tbaa !5
  %61 = load float, ptr %12, align 4, !tbaa !8
  %62 = load float, ptr %14, align 4, !tbaa !8
  %63 = fsub float %61, %62
  %64 = fmul float 2.000000e+00, %63
  %65 = getelementptr inbounds [4 x [4 x float]], ptr %0, i64 0, i64 0
  %66 = getelementptr inbounds [4 x float], ptr %65, i64 0, i64 1
  store float %64, ptr %66, align 4, !tbaa !5
  %67 = load float, ptr %17, align 4, !tbaa !8
  %68 = load float, ptr %15, align 4, !tbaa !8
  %69 = fadd float %67, %68
  %70 = fmul float 2.000000e+00, %69
  %71 = getelementptr inbounds [4 x [4 x float]], ptr %0, i64 0, i64 0
  %72 = getelementptr inbounds [4 x float], ptr %71, i64 0, i64 2
  store float %70, ptr %72, align 4, !tbaa !5
  %73 = getelementptr inbounds [4 x [4 x float]], ptr %0, i64 0, i64 0
  %74 = getelementptr inbounds [4 x float], ptr %73, i64 0, i64 3
  store float 0.000000e+00, ptr %74, align 4, !tbaa !5
  %75 = load float, ptr %12, align 4, !tbaa !8
  %76 = load float, ptr %14, align 4, !tbaa !8
  %77 = fadd float %75, %76
  %78 = fmul float 2.000000e+00, %77
  %79 = getelementptr inbounds [4 x [4 x float]], ptr %0, i64 0, i64 1
  %80 = getelementptr inbounds [4 x float], ptr %79, i64 0, i64 0
  store float %78, ptr %80, align 4, !tbaa !5
  %81 = load float, ptr %9, align 4, !tbaa !8
  %82 = load float, ptr %11, align 4, !tbaa !8
  %83 = fadd float %81, %82
  %84 = call float @llvm.fmuladd.f32(float -2.000000e+00, float %83, float 1.000000e+00)
  %85 = getelementptr inbounds [4 x [4 x float]], ptr %0, i64 0, i64 1
  %86 = getelementptr inbounds [4 x float], ptr %85, i64 0, i64 1
  store float %84, ptr %86, align 4, !tbaa !5
  %87 = load float, ptr %13, align 4, !tbaa !8
  %88 = load float, ptr %16, align 4, !tbaa !8
  %89 = fsub float %87, %88
  %90 = fmul float 2.000000e+00, %89
  %91 = getelementptr inbounds [4 x [4 x float]], ptr %0, i64 0, i64 1
  %92 = getelementptr inbounds [4 x float], ptr %91, i64 0, i64 2
  store float %90, ptr %92, align 4, !tbaa !5
  %93 = getelementptr inbounds [4 x [4 x float]], ptr %0, i64 0, i64 1
  %94 = getelementptr inbounds [4 x float], ptr %93, i64 0, i64 3
  store float 0.000000e+00, ptr %94, align 4, !tbaa !5
  %95 = load float, ptr %17, align 4, !tbaa !8
  %96 = load float, ptr %15, align 4, !tbaa !8
  %97 = fsub float %95, %96
  %98 = fmul float 2.000000e+00, %97
  %99 = getelementptr inbounds [4 x [4 x float]], ptr %0, i64 0, i64 2
  %100 = getelementptr inbounds [4 x float], ptr %99, i64 0, i64 0
  store float %98, ptr %100, align 4, !tbaa !5
  %101 = load float, ptr %13, align 4, !tbaa !8
  %102 = load float, ptr %16, align 4, !tbaa !8
  %103 = fadd float %101, %102
  %104 = fmul float 2.000000e+00, %103
  %105 = getelementptr inbounds [4 x [4 x float]], ptr %0, i64 0, i64 2
  %106 = getelementptr inbounds [4 x float], ptr %105, i64 0, i64 1
  store float %104, ptr %106, align 4, !tbaa !5
  %107 = load float, ptr %9, align 4, !tbaa !8
  %108 = load float, ptr %10, align 4, !tbaa !8
  %109 = fadd float %107, %108
  %110 = call float @llvm.fmuladd.f32(float -2.000000e+00, float %109, float 1.000000e+00)
  %111 = getelementptr inbounds [4 x [4 x float]], ptr %0, i64 0, i64 2
  %112 = getelementptr inbounds [4 x float], ptr %111, i64 0, i64 2
  store float %110, ptr %112, align 4, !tbaa !5
  %113 = getelementptr inbounds [4 x [4 x float]], ptr %0, i64 0, i64 2
  %114 = getelementptr inbounds [4 x float], ptr %113, i64 0, i64 3
  store float 0.000000e+00, ptr %114, align 4, !tbaa !5
  %115 = getelementptr inbounds [4 x [4 x float]], ptr %0, i64 0, i64 3
  %116 = getelementptr inbounds [4 x float], ptr %115, i64 0, i64 0
  store float 0.000000e+00, ptr %116, align 4, !tbaa !5
  %117 = getelementptr inbounds [4 x [4 x float]], ptr %0, i64 0, i64 3
  %118 = getelementptr inbounds [4 x float], ptr %117, i64 0, i64 1
  store float 0.000000e+00, ptr %118, align 4, !tbaa !5
  %119 = getelementptr inbounds [4 x [4 x float]], ptr %0, i64 0, i64 3
  %120 = getelementptr inbounds [4 x float], ptr %119, i64 0, i64 2
  store float 0.000000e+00, ptr %120, align 4, !tbaa !5
  %121 = getelementptr inbounds [4 x [4 x float]], ptr %0, i64 0, i64 3
  %122 = getelementptr inbounds [4 x float], ptr %121, i64 0, i64 3
  store float 1.000000e+00, ptr %122, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #3
  ret void
}

attributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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" }
attributes #3 = { 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 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}
!8 = !{!9, !9, i64 0}
!9 = !{!"float", !6, 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"

%union.Mat4 = type { [4 x %union.Vec4] }
%union.Vec4 = type { %struct.anon.3 }
%struct.anon.3 = type { float, float, 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 nofree norecurse nosync nounwind willreturn memory(argmem: write) uwtable
define dso_local void @_Z13quat_get_mat44Quat(ptr dead_on_unwind noalias nocapture writable writeonly sret(%union.Mat4) align 4 %0, <2 x float> %1, <2 x float> %2) local_unnamed_addr #1 {
  %.sroa.0.0.vec.extract = extractelement <2 x float> %1, i64 0
  %.sroa.0.4.vec.extract = extractelement <2 x float> %1, i64 1
  %.sroa.3.8.vec.extract = extractelement <2 x float> %2, i64 0
  %.sroa.3.12.vec.extract = extractelement <2 x float> %2, i64 1
  %4 = fmul <2 x float> %1, %1
  %5 = extractelement <2 x float> %4, i64 0
  %6 = fmul float %.sroa.0.4.vec.extract, %.sroa.0.4.vec.extract
  %7 = fmul <2 x float> %2, %2
  %8 = extractelement <2 x float> %7, i64 0
  %9 = fmul float %.sroa.0.0.vec.extract, %.sroa.0.4.vec.extract
  %10 = fmul float %.sroa.0.4.vec.extract, %.sroa.3.8.vec.extract
  %11 = fmul float %.sroa.3.8.vec.extract, %.sroa.3.12.vec.extract
  %12 = fmul float %.sroa.0.4.vec.extract, %.sroa.3.12.vec.extract
  %13 = fmul float %.sroa.0.0.vec.extract, %.sroa.3.12.vec.extract
  %14 = fmul <2 x float> %1, %2
  %15 = extractelement <2 x float> %14, i64 0
  %16 = fadd float %6, %8
  %17 = tail call float @llvm.fmuladd.f32(float %16, float -2.000000e+00, float 1.000000e+00)
  store float %17, ptr %0, align 4, !tbaa !5
  %18 = fsub float %9, %11
  %19 = fmul float %18, 2.000000e+00
  %20 = getelementptr inbounds i8, ptr %0, i64 4
  store float %19, ptr %20, align 4, !tbaa !5
  %21 = fadd float %15, %12
  %22 = fmul float %21, 2.000000e+00
  %23 = getelementptr inbounds i8, ptr %0, i64 8
  store float %22, ptr %23, align 4, !tbaa !5
  %24 = getelementptr inbounds i8, ptr %0, i64 12
  store float 0.000000e+00, ptr %24, align 4, !tbaa !5
  %25 = fadd float %9, %11
  %26 = fmul float %25, 2.000000e+00
  %27 = getelementptr inbounds i8, ptr %0, i64 16
  store float %26, ptr %27, align 4, !tbaa !5
  %28 = fadd <2 x float> %4, %7
  %29 = extractelement <2 x float> %28, i64 0
  %30 = tail call float @llvm.fmuladd.f32(float %29, float -2.000000e+00, float 1.000000e+00)
  %31 = getelementptr inbounds i8, ptr %0, i64 20
  store float %30, ptr %31, align 4, !tbaa !5
  %32 = fsub float %10, %13
  %33 = fmul float %32, 2.000000e+00
  %34 = getelementptr inbounds i8, ptr %0, i64 24
  store float %33, ptr %34, align 4, !tbaa !5
  %35 = getelementptr inbounds i8, ptr %0, i64 28
  store float 0.000000e+00, ptr %35, align 4, !tbaa !5
  %36 = fsub float %15, %12
  %37 = fmul float %36, 2.000000e+00
  %38 = getelementptr inbounds i8, ptr %0, i64 32
  store float %37, ptr %38, align 4, !tbaa !5
  %39 = fadd float %10, %13
  %40 = fmul float %39, 2.000000e+00
  %41 = getelementptr inbounds i8, ptr %0, i64 36
  store float %40, ptr %41, align 4, !tbaa !5
  %42 = fadd float %5, %6
  %43 = tail call float @llvm.fmuladd.f32(float %42, float -2.000000e+00, float 1.000000e+00)
  %44 = getelementptr inbounds i8, ptr %0, i64 40
  store float %43, ptr %44, align 4, !tbaa !5
  %45 = getelementptr inbounds i8, ptr %0, i64 44
  %46 = getelementptr inbounds i8, ptr %0, i64 60
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 4 dereferenceable(16) %45, i8 0, i64 16, i1 false)
  store float 1.000000e+00, ptr %46, align 4, !tbaa !5
  ret void
}

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #2

attributes #0 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #1 = { mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: write) 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" }
attributes #2 = { nocallback nofree nounwind willreturn memory(argmem: write) }

!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 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,MemCpyOptPass,PostOrderFunctionAttrsPass,SROAPass,TailCallElimPass,VectorCombinePass