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

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

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #0

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local { <2 x float>, <2 x float> } @_Z4vec4ffff(float noundef, float noundef, float noundef, float noundef) #1

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

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

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

; Function Attrs: nounwind
declare float @cosf(float noundef) #4

; Function Attrs: nounwind
declare float @sinf(float noundef) #4

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

attributes #0 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { inlinehint 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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #3 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { nounwind "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 #5 = { 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" }
attributes #6 = { 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 = !{i64 0, i64 16, !10}
!10 = !{!7, !7, 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: inlinehint mustprogress nounwind uwtable
declare dso_local { <2 x float>, <2 x float> } @_Z4vec4ffff(float noundef, float noundef, float noundef, float noundef) local_unnamed_addr #0

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

; Function Attrs: mustprogress nofree nounwind willreturn memory(write)
declare float @cosf(float noundef) local_unnamed_addr #2

; Function Attrs: mustprogress nofree nounwind willreturn memory(write)
declare float @sinf(float noundef) local_unnamed_addr #2

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_Z13mat4_rotationffff(ptr dead_on_unwind noalias nocapture writable writeonly sret(%union.Mat4) align 4 %0, float noundef %1, float noundef %2, float noundef %3, float noundef %4) local_unnamed_addr #3 {
  %6 = tail call float @cosf(float noundef %4) #4
  %7 = tail call float @sinf(float noundef %4) #4
  %8 = fmul float %1, %1
  %9 = fmul float %1, %2
  %10 = fmul float %1, %3
  %11 = fmul float %2, %2
  %12 = fmul float %2, %3
  %13 = fmul float %3, %3
  %14 = fsub float 1.000000e+00, %6
  %15 = tail call float @llvm.fmuladd.f32(float %8, float %14, float %6)
  %16 = fmul float %7, %3
  %17 = fneg float %16
  %18 = tail call float @llvm.fmuladd.f32(float %9, float %14, float %17)
  %19 = fmul float %7, %2
  %20 = tail call float @llvm.fmuladd.f32(float %10, float %14, float %19)
  %21 = tail call { <2 x float>, <2 x float> } @_Z4vec4ffff(float noundef %15, float noundef %18, float noundef %20, float noundef 0.000000e+00)
  %22 = extractvalue { <2 x float>, <2 x float> } %21, 0
  %23 = extractvalue { <2 x float>, <2 x float> } %21, 1
  store <2 x float> %22, ptr %0, align 4
  %.sroa.46.0..sroa_idx = getelementptr inbounds i8, ptr %0, i64 8
  store <2 x float> %23, ptr %.sroa.46.0..sroa_idx, align 4, !tbaa !5
  %24 = tail call float @llvm.fmuladd.f32(float %9, float %14, float %16)
  %25 = tail call float @llvm.fmuladd.f32(float %11, float %14, float %6)
  %26 = fmul float %7, %1
  %27 = fneg float %26
  %28 = tail call float @llvm.fmuladd.f32(float %12, float %14, float %27)
  %29 = tail call { <2 x float>, <2 x float> } @_Z4vec4ffff(float noundef %24, float noundef %25, float noundef %28, float noundef 0.000000e+00)
  %30 = extractvalue { <2 x float>, <2 x float> } %29, 0
  %31 = extractvalue { <2 x float>, <2 x float> } %29, 1
  %32 = getelementptr inbounds i8, ptr %0, i64 16
  store <2 x float> %30, ptr %32, align 4
  %.sroa.44.0..sroa_idx = getelementptr inbounds i8, ptr %0, i64 24
  store <2 x float> %31, ptr %.sroa.44.0..sroa_idx, align 4, !tbaa !5
  %33 = fneg float %19
  %34 = tail call float @llvm.fmuladd.f32(float %10, float %14, float %33)
  %35 = tail call float @llvm.fmuladd.f32(float %12, float %14, float %26)
  %36 = tail call float @llvm.fmuladd.f32(float %13, float %14, float %6)
  %37 = tail call { <2 x float>, <2 x float> } @_Z4vec4ffff(float noundef %34, float noundef %35, float noundef %36, float noundef 0.000000e+00)
  %38 = extractvalue { <2 x float>, <2 x float> } %37, 0
  %39 = extractvalue { <2 x float>, <2 x float> } %37, 1
  %40 = getelementptr inbounds i8, ptr %0, i64 32
  store <2 x float> %38, ptr %40, align 4
  %.sroa.42.0..sroa_idx = getelementptr inbounds i8, ptr %0, i64 40
  store <2 x float> %39, ptr %.sroa.42.0..sroa_idx, align 4, !tbaa !5
  %41 = tail call { <2 x float>, <2 x float> } @_Z4vec4ffff(float noundef 0.000000e+00, float noundef 0.000000e+00, float noundef 0.000000e+00, float noundef 1.000000e+00)
  %42 = extractvalue { <2 x float>, <2 x float> } %41, 0
  %43 = extractvalue { <2 x float>, <2 x float> } %41, 1
  %44 = getelementptr inbounds i8, ptr %0, i64 48
  store <2 x float> %42, ptr %44, align 4
  %.sroa.4.0..sroa_idx = getelementptr inbounds i8, ptr %0, i64 56
  store <2 x float> %43, ptr %.sroa.4.0..sroa_idx, align 4, !tbaa !5
  ret void
}

attributes #0 = { inlinehint 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 #1 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #2 = { mustprogress nofree nounwind willreturn memory(write) "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 = { 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 #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 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}


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