; LLVM IR from thuhcsi/Crystal.TTVS :: Xface/XFace/src/XMath/Quaternion.ll (ZN5XMath10QuaternionC2Efff)

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

%"class.XMath::Quaternion" = type { float, float, float, float }

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN5XMath10QuaternionC2Efff(ptr noundef nonnull align 4 dereferenceable(16) %0, float noundef %1, float noundef %2, float noundef %3) unnamed_addr #0 align 2 {
  %5 = alloca ptr, align 8
  %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 float, align 4
  %19 = alloca float, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store float %1, ptr %6, align 4, !tbaa !9
  store float %2, ptr %7, align 4, !tbaa !9
  store float %3, ptr %8, align 4, !tbaa !9
  %20 = load ptr, ptr %5, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #4
  %21 = load float, ptr %6, align 4, !tbaa !9
  %22 = fmul float %21, 0x400921FB60000000
  %23 = fdiv float %22, 1.800000e+02
  %24 = fmul float %23, 5.000000e-01
  store float %24, ptr %9, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #4
  %25 = load float, ptr %7, align 4, !tbaa !9
  %26 = fmul float %25, 0x400921FB60000000
  %27 = fdiv float %26, 1.800000e+02
  %28 = fmul float %27, 5.000000e-01
  store float %28, ptr %10, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #4
  %29 = load float, ptr %8, align 4, !tbaa !9
  %30 = fmul float %29, 0x400921FB60000000
  %31 = fdiv float %30, 1.800000e+02
  %32 = fmul float %31, 5.000000e-01
  store float %32, ptr %11, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #4
  %33 = load float, ptr %9, align 4, !tbaa !9
  %34 = call noundef float @_ZSt3sinf(float noundef %33)
  store float %34, ptr %12, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #4
  %35 = load float, ptr %9, align 4, !tbaa !9
  %36 = call noundef float @_ZSt3cosf(float noundef %35)
  store float %36, ptr %13, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #4
  %37 = load float, ptr %10, align 4, !tbaa !9
  %38 = call noundef float @_ZSt3sinf(float noundef %37)
  store float %38, ptr %14, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #4
  %39 = load float, ptr %10, align 4, !tbaa !9
  %40 = call noundef float @_ZSt3cosf(float noundef %39)
  store float %40, ptr %15, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #4
  %41 = load float, ptr %11, align 4, !tbaa !9
  %42 = call noundef float @_ZSt3sinf(float noundef %41)
  store float %42, ptr %16, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #4
  %43 = load float, ptr %11, align 4, !tbaa !9
  %44 = call noundef float @_ZSt3cosf(float noundef %43)
  store float %44, ptr %17, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %18) #4
  %45 = load float, ptr %13, align 4, !tbaa !9
  %46 = load float, ptr %15, align 4, !tbaa !9
  %47 = fmul float %45, %46
  store float %47, ptr %18, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %19) #4
  %48 = load float, ptr %12, align 4, !tbaa !9
  %49 = load float, ptr %14, align 4, !tbaa !9
  %50 = fmul float %48, %49
  store float %50, ptr %19, align 4, !tbaa !9
  %51 = load float, ptr %16, align 4, !tbaa !9
  %52 = load float, ptr %18, align 4, !tbaa !9
  %53 = load float, ptr %17, align 4, !tbaa !9
  %54 = load float, ptr %19, align 4, !tbaa !9
  %55 = fmul float %53, %54
  %56 = fneg float %55
  %57 = call float @llvm.fmuladd.f32(float %51, float %52, float %56)
  %58 = getelementptr inbounds %"class.XMath::Quaternion", ptr %20, i32 0, i32 0
  store float %57, ptr %58, align 4, !tbaa !11
  %59 = load float, ptr %17, align 4, !tbaa !9
  %60 = load float, ptr %12, align 4, !tbaa !9
  %61 = fmul float %59, %60
  %62 = load float, ptr %15, align 4, !tbaa !9
  %63 = load float, ptr %16, align 4, !tbaa !9
  %64 = load float, ptr %13, align 4, !tbaa !9
  %65 = fmul float %63, %64
  %66 = load float, ptr %14, align 4, !tbaa !9
  %67 = fmul float %65, %66
  %68 = call float @llvm.fmuladd.f32(float %61, float %62, float %67)
  %69 = getelementptr inbounds %"class.XMath::Quaternion", ptr %20, i32 0, i32 1
  store float %68, ptr %69, align 4, !tbaa !13
  %70 = load float, ptr %17, align 4, !tbaa !9
  %71 = load float, ptr %13, align 4, !tbaa !9
  %72 = fmul float %70, %71
  %73 = load float, ptr %14, align 4, !tbaa !9
  %74 = load float, ptr %16, align 4, !tbaa !9
  %75 = load float, ptr %12, align 4, !tbaa !9
  %76 = fmul float %74, %75
  %77 = load float, ptr %15, align 4, !tbaa !9
  %78 = fmul float %76, %77
  %79 = fneg float %78
  %80 = call float @llvm.fmuladd.f32(float %72, float %73, float %79)
  %81 = getelementptr inbounds %"class.XMath::Quaternion", ptr %20, i32 0, i32 2
  store float %80, ptr %81, align 4, !tbaa !14
  %82 = load float, ptr %17, align 4, !tbaa !9
  %83 = load float, ptr %18, align 4, !tbaa !9
  %84 = load float, ptr %16, align 4, !tbaa !9
  %85 = load float, ptr %19, align 4, !tbaa !9
  %86 = fmul float %84, %85
  %87 = call float @llvm.fmuladd.f32(float %82, float %83, float %86)
  %88 = getelementptr inbounds %"class.XMath::Quaternion", ptr %20, i32 0, i32 3
  store float %87, ptr %88, align 4, !tbaa !15
  call void @llvm.lifetime.end.p0(i64 4, ptr %19) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #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
  ret void
}

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef float @_ZSt3sinf(float noundef) #2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef float @_ZSt3cosf(float noundef) #2

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

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

attributes #0 = { 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 #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #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 0}
!12 = !{!"_ZTSN5XMath10QuaternionE", !10, i64 0, !10, i64 4, !10, i64 8, !10, i64 12}
!13 = !{!12, !10, i64 4}
!14 = !{!12, !10, i64 8}
!15 = !{!12, !10, i64 12}


; 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 nounwind uwtable
define dso_local void @_ZN5XMath10QuaternionC2Efff(ptr nocapture noundef nonnull writeonly align 4 dereferenceable(16) %0, float noundef %1, float noundef %2, float noundef %3) unnamed_addr #0 align 2 {
  %5 = fmul float %1, 0x400921FB60000000
  %6 = fdiv float %5, 1.800000e+02
  %7 = fmul float %6, 5.000000e-01
  %8 = fmul float %2, 0x400921FB60000000
  %9 = fdiv float %8, 1.800000e+02
  %10 = fmul float %9, 5.000000e-01
  %11 = fmul float %3, 0x400921FB60000000
  %12 = fdiv float %11, 1.800000e+02
  %13 = fmul float %12, 5.000000e-01
  %14 = tail call noundef float @_ZSt3sinf(float noundef %7)
  %15 = tail call noundef float @_ZSt3cosf(float noundef %7)
  %16 = tail call noundef float @_ZSt3sinf(float noundef %10)
  %17 = tail call noundef float @_ZSt3cosf(float noundef %10)
  %18 = tail call noundef float @_ZSt3sinf(float noundef %13)
  %19 = tail call noundef float @_ZSt3cosf(float noundef %13)
  %20 = fneg float %19
  %21 = fneg float %18
  %22 = insertelement <4 x float> poison, float %15, i64 0
  %23 = insertelement <4 x float> %22, float %14, i64 1
  %24 = shufflevector <4 x float> %23, <4 x float> poison, <4 x i32> <i32 0, i32 1, i32 0, i32 0>
  %25 = insertelement <4 x float> poison, float %17, i64 0
  %26 = insertelement <4 x float> %25, float %19, i64 1
  %27 = shufflevector <4 x float> %26, <4 x float> poison, <4 x i32> <i32 0, i32 1, i32 1, i32 0>
  %28 = fmul <4 x float> %24, %27
  %29 = shufflevector <4 x float> %23, <4 x float> poison, <4 x i32> <i32 1, i32 0, i32 1, i32 1>
  %30 = insertelement <4 x float> poison, float %16, i64 0
  %31 = insertelement <4 x float> %30, float %18, i64 1
  %32 = insertelement <4 x float> %31, float %21, i64 2
  %33 = shufflevector <4 x float> %32, <4 x float> poison, <4 x i32> <i32 0, i32 1, i32 2, i32 0>
  %34 = fmul <4 x float> %29, %33
  %35 = shufflevector <4 x float> %31, <4 x float> %25, <4 x i32> <i32 poison, i32 0, i32 4, i32 1>
  %36 = insertelement <4 x float> %35, float %20, i64 0
  %37 = fmul <4 x float> %34, %36
  %38 = shufflevector <4 x float> %35, <4 x float> %26, <4 x i32> <i32 3, i32 2, i32 1, i32 5>
  %39 = tail call <4 x float> @llvm.fmuladd.v4f32(<4 x float> %28, <4 x float> %38, <4 x float> %37)
  store <4 x float> %39, ptr %0, align 4, !tbaa !5
  ret void
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef float @_ZSt3sinf(float noundef) local_unnamed_addr #1

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef float @_ZSt3cosf(float noundef) local_unnamed_addr #1

; 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 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 = { 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) }

!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"}


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