; LLVM IR from Slingshot-Physics/slingshot-community :: common/math/src/attitudeutils.ll (Z20attitudeToQuaternionRK7Vector3R10Quaternion)

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

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

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

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

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

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZN10QuaternionixEj(ptr noundef nonnull align 4 dereferenceable(16), i32 noundef) #3 align 2

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

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


; 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 nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare float @llvm.fmuladd.f32(float, float, float) #0

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_Z20attitudeToQuaternionRK7Vector3R10Quaternion(ptr noundef nonnull align 4 dereferenceable(12) %0, ptr noundef nonnull align 4 dereferenceable(16) %1) local_unnamed_addr #1 {
  %3 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNK7Vector3ixEj(ptr noundef nonnull align 4 dereferenceable(12) %0, i32 noundef 0)
  %4 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNK7Vector3ixEj(ptr noundef nonnull align 4 dereferenceable(12) %0, i32 noundef 1)
  %5 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNK7Vector3ixEj(ptr noundef nonnull align 4 dereferenceable(12) %0, i32 noundef 2)
  %6 = load float, ptr %3, align 4, !tbaa !5
  %7 = fmul float %6, 5.000000e-01
  %8 = tail call noundef float @_ZSt3sinf(float noundef %7)
  %9 = load float, ptr %3, align 4, !tbaa !5
  %10 = fmul float %9, 5.000000e-01
  %11 = tail call noundef float @_ZSt3cosf(float noundef %10)
  %12 = load float, ptr %4, align 4, !tbaa !5
  %13 = fmul float %12, 5.000000e-01
  %14 = tail call noundef float @_ZSt3sinf(float noundef %13)
  %15 = load float, ptr %4, align 4, !tbaa !5
  %16 = fmul float %15, 5.000000e-01
  %17 = tail call noundef float @_ZSt3cosf(float noundef %16)
  %18 = load float, ptr %5, align 4, !tbaa !5
  %19 = fmul float %18, 5.000000e-01
  %20 = tail call noundef float @_ZSt3sinf(float noundef %19)
  %21 = load float, ptr %5, align 4, !tbaa !5
  %22 = fmul float %21, 5.000000e-01
  %23 = tail call noundef float @_ZSt3cosf(float noundef %22)
  %24 = fmul float %11, %17
  %25 = fmul float %8, %14
  %26 = fmul float %25, %20
  %27 = tail call float @llvm.fmuladd.f32(float %24, float %23, float %26)
  %28 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZN10QuaternionixEj(ptr noundef nonnull align 4 dereferenceable(16) %1, i32 noundef 0)
  store float %27, ptr %28, align 4, !tbaa !5
  %29 = fmul float %8, %17
  %30 = fmul float %11, %14
  %31 = fneg float %30
  %32 = fmul float %20, %31
  %33 = tail call float @llvm.fmuladd.f32(float %29, float %23, float %32)
  %34 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZN10QuaternionixEj(ptr noundef nonnull align 4 dereferenceable(16) %1, i32 noundef 1)
  store float %33, ptr %34, align 4, !tbaa !5
  %35 = fmul float %29, %20
  %36 = tail call float @llvm.fmuladd.f32(float %30, float %23, float %35)
  %37 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZN10QuaternionixEj(ptr noundef nonnull align 4 dereferenceable(16) %1, i32 noundef 2)
  store float %36, ptr %37, align 4, !tbaa !5
  %38 = fneg float %25
  %39 = fmul float %23, %38
  %40 = tail call float @llvm.fmuladd.f32(float %24, float %20, float %39)
  %41 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZN10QuaternionixEj(ptr noundef nonnull align 4 dereferenceable(16) %1, i32 noundef 3)
  store float %40, ptr %41, align 4, !tbaa !5
  ret void
}

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

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

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

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

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

!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,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,TailCallElimPass