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

; 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.Quat = type { [4 x float] }
%struct.anon.17 = 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: nounwind
declare float @cosf(float noundef) #2

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

; Function Attrs: mustprogress nounwind uwtable
define dso_local { <2 x float>, <2 x float> } @_Z17quat_euler_anglesfff(float noundef %0, float noundef %1, float noundef %2) #3 {
  %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
  store float %0, ptr %5, align 4, !tbaa !5
  store float %1, ptr %6, align 4, !tbaa !5
  store float %2, ptr %7, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #4
  %14 = load float, ptr %7, align 4, !tbaa !5
  %15 = fmul float %14, 5.000000e-01
  %16 = call float @cosf(float noundef %15) #4
  store float %16, ptr %8, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #4
  %17 = load float, ptr %7, align 4, !tbaa !5
  %18 = fmul float %17, 5.000000e-01
  %19 = call float @sinf(float noundef %18) #4
  store float %19, ptr %9, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #4
  %20 = load float, ptr %6, align 4, !tbaa !5
  %21 = fmul float %20, 5.000000e-01
  %22 = call float @cosf(float noundef %21) #4
  store float %22, ptr %10, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #4
  %23 = load float, ptr %6, align 4, !tbaa !5
  %24 = fmul float %23, 5.000000e-01
  %25 = call float @sinf(float noundef %24) #4
  store float %25, ptr %11, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #4
  %26 = load float, ptr %5, align 4, !tbaa !5
  %27 = fmul float %26, 5.000000e-01
  %28 = call float @cosf(float noundef %27) #4
  store float %28, ptr %12, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #4
  %29 = load float, ptr %5, align 4, !tbaa !5
  %30 = fmul float %29, 5.000000e-01
  %31 = call float @sinf(float noundef %30) #4
  store float %31, ptr %13, align 4, !tbaa !5
  %32 = load float, ptr %8, align 4, !tbaa !5
  %33 = load float, ptr %10, align 4, !tbaa !5
  %34 = fmul float %32, %33
  %35 = load float, ptr %12, align 4, !tbaa !5
  %36 = load float, ptr %9, align 4, !tbaa !5
  %37 = load float, ptr %11, align 4, !tbaa !5
  %38 = fmul float %36, %37
  %39 = load float, ptr %13, align 4, !tbaa !5
  %40 = fmul float %38, %39
  %41 = call float @llvm.fmuladd.f32(float %34, float %35, float %40)
  %42 = getelementptr inbounds %struct.anon.17, ptr %4, i32 0, i32 3
  store float %41, ptr %42, align 4, !tbaa !9
  %43 = load float, ptr %8, align 4, !tbaa !5
  %44 = load float, ptr %10, align 4, !tbaa !5
  %45 = fmul float %43, %44
  %46 = load float, ptr %13, align 4, !tbaa !5
  %47 = load float, ptr %9, align 4, !tbaa !5
  %48 = load float, ptr %11, align 4, !tbaa !5
  %49 = fmul float %47, %48
  %50 = load float, ptr %12, align 4, !tbaa !5
  %51 = fmul float %49, %50
  %52 = fneg float %51
  %53 = call float @llvm.fmuladd.f32(float %45, float %46, float %52)
  %54 = getelementptr inbounds %struct.anon.17, ptr %4, i32 0, i32 0
  store float %53, ptr %54, align 4, !tbaa !9
  %55 = load float, ptr %9, align 4, !tbaa !5
  %56 = load float, ptr %10, align 4, !tbaa !5
  %57 = fmul float %55, %56
  %58 = load float, ptr %13, align 4, !tbaa !5
  %59 = load float, ptr %8, align 4, !tbaa !5
  %60 = load float, ptr %11, align 4, !tbaa !5
  %61 = fmul float %59, %60
  %62 = load float, ptr %12, align 4, !tbaa !5
  %63 = fmul float %61, %62
  %64 = call float @llvm.fmuladd.f32(float %57, float %58, float %63)
  %65 = getelementptr inbounds %struct.anon.17, ptr %4, i32 0, i32 1
  store float %64, ptr %65, align 4, !tbaa !9
  %66 = load float, ptr %9, align 4, !tbaa !5
  %67 = load float, ptr %10, align 4, !tbaa !5
  %68 = fmul float %66, %67
  %69 = load float, ptr %12, align 4, !tbaa !5
  %70 = load float, ptr %8, align 4, !tbaa !5
  %71 = load float, ptr %11, align 4, !tbaa !5
  %72 = fmul float %70, %71
  %73 = load float, ptr %13, align 4, !tbaa !5
  %74 = fmul float %72, %73
  %75 = fneg float %74
  %76 = call float @llvm.fmuladd.f32(float %68, float %69, float %75)
  %77 = getelementptr inbounds %struct.anon.17, ptr %4, i32 0, i32 2
  store float %76, ptr %77, align 4, !tbaa !9
  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
  %78 = getelementptr inbounds %union.Quat, ptr %4, i32 0, i32 0
  %79 = load { <2 x float>, <2 x float> }, ptr %78, align 4
  ret { <2 x float>, <2 x float> } %79
}

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

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

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

; Function Attrs: mustprogress nofree nounwind willreturn memory(write) uwtable
define dso_local { <2 x float>, <2 x float> } @_Z17quat_euler_anglesfff(float noundef %0, float noundef %1, float noundef %2) local_unnamed_addr #1 {
  %4 = fmul float %2, 5.000000e-01
  %5 = tail call float @cosf(float noundef %4) #3
  %6 = tail call float @sinf(float noundef %4) #3
  %7 = fmul float %1, 5.000000e-01
  %8 = tail call float @cosf(float noundef %7) #3
  %9 = tail call float @sinf(float noundef %7) #3
  %10 = fmul float %0, 5.000000e-01
  %11 = tail call float @cosf(float noundef %10) #3
  %12 = tail call float @sinf(float noundef %10) #3
  %13 = fmul float %6, %9
  %14 = fneg float %13
  %15 = fmul float %5, %9
  %16 = fneg float %15
  %17 = insertelement <2 x float> poison, float %5, i64 0
  %18 = insertelement <2 x float> %17, float %6, i64 1
  %19 = insertelement <2 x float> poison, float %8, i64 0
  %20 = shufflevector <2 x float> %19, <2 x float> poison, <2 x i32> zeroinitializer
  %21 = fmul <2 x float> %18, %20
  %22 = shufflevector <2 x float> %21, <2 x float> poison, <4 x i32> <i32 0, i32 1, i32 0, i32 1>
  %23 = insertelement <4 x float> poison, float %14, i64 0
  %24 = insertelement <4 x float> %23, float %15, i64 1
  %25 = insertelement <4 x float> %24, float %12, i64 2
  %26 = shufflevector <4 x float> %25, <4 x float> poison, <4 x i32> <i32 0, i32 1, i32 2, i32 2>
  %27 = insertelement <4 x float> poison, float %11, i64 0
  %28 = insertelement <4 x float> %27, float %13, i64 2
  %29 = insertelement <4 x float> %28, float %16, i64 3
  %30 = shufflevector <4 x float> %29, <4 x float> poison, <4 x i32> <i32 0, i32 0, i32 2, i32 3>
  %31 = fmul <4 x float> %26, %30
  %32 = shufflevector <4 x float> %25, <4 x float> %27, <4 x i32> <i32 2, i32 2, i32 4, i32 4>
  %33 = tail call <4 x float> @llvm.fmuladd.v4f32(<4 x float> %22, <4 x float> %32, <4 x float> %31)
  %34 = shufflevector <4 x float> %33, <4 x float> poison, <2 x i32> <i32 0, i32 1>
  %35 = shufflevector <4 x float> %33, <4 x float> poison, <2 x i32> <i32 3, i32 2>
  %.fca.0.insert = insertvalue { <2 x float>, <2 x float> } poison, <2 x float> %34, 0
  %.fca.1.insert = insertvalue { <2 x float>, <2 x float> } %.fca.0.insert, <2 x float> %35, 1
  ret { <2 x float>, <2 x float> } %.fca.1.insert
}

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

attributes #0 = { 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 #1 = { mustprogress nofree nounwind willreturn memory(write) 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 = { 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)"}


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