; LLVM IR from Derek-TH-Wang/quadruped_ctrl :: src/calculateTool.ll (ZN13CalculateTool6Quat2TEPfS0_)

; 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 willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #0

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN13CalculateTool10NormVectorEiPfS0_(ptr noundef nonnull align 8 dereferenceable(24), i32 noundef, ptr noundef, ptr noundef) #1 align 2

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

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

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 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)"}
!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 willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #0

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN13CalculateTool10NormVectorEiPfS0_(ptr noundef nonnull align 8 dereferenceable(24), i32 noundef, ptr noundef, ptr noundef) local_unnamed_addr #1 align 2

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN13CalculateTool6Quat2TEPfS0_(ptr noundef nonnull align 8 dereferenceable(24) %0, ptr noundef %1, ptr nocapture noundef writeonly %2) local_unnamed_addr #1 align 2 {
  %4 = alloca float, align 4
  %5 = load float, ptr %1, align 4, !tbaa !5
  %6 = getelementptr inbounds i8, ptr %1, i64 4
  %7 = getelementptr inbounds i8, ptr %1, i64 12
  %8 = load float, ptr %7, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %4) #4
  %9 = getelementptr inbounds i8, ptr %2, i64 4
  %10 = load <2 x float>, ptr %6, align 4, !tbaa !5
  call void @_ZN13CalculateTool10NormVectorEiPfS0_(ptr noundef nonnull align 8 dereferenceable(24) %0, i32 noundef 4, ptr noundef nonnull %1, ptr noundef nonnull %4)
  %11 = load float, ptr %4, align 4, !tbaa !5
  %12 = fdiv float %5, %11
  %13 = insertelement <2 x float> poison, float %11, i64 0
  %14 = shufflevector <2 x float> %13, <2 x float> poison, <2 x i32> zeroinitializer
  %15 = fdiv <2 x float> %10, %14
  %16 = fdiv float %8, %11
  %17 = extractelement <2 x float> %15, i64 1
  %18 = fmul float %17, %17
  %19 = extractelement <2 x float> %15, i64 0
  %20 = call float @llvm.fmuladd.f32(float %19, float %19, float %18)
  %21 = fpext float %20 to double
  %22 = call double @llvm.fmuladd.f64(double %21, double -2.000000e+00, double 1.000000e+00)
  %23 = fptrunc double %22 to float
  store float %23, ptr %2, align 4, !tbaa !5
  %24 = fmul float %16, %17
  %25 = fneg float %24
  %26 = insertelement <2 x float> poison, float %12, i64 0
  %27 = shufflevector <2 x float> %26, <2 x float> poison, <2 x i32> zeroinitializer
  %28 = call float @llvm.fmuladd.f32(float %12, float %19, float %24)
  %29 = fmul float %28, 2.000000e+00
  %30 = getelementptr inbounds i8, ptr %2, i64 12
  store float %29, ptr %30, align 4, !tbaa !5
  %31 = call float @llvm.fmuladd.f32(float %12, float %12, float %18)
  %32 = fpext float %31 to double
  %33 = call double @llvm.fmuladd.f64(double %32, double -2.000000e+00, double 1.000000e+00)
  %34 = fptrunc double %33 to float
  %35 = getelementptr inbounds i8, ptr %2, i64 16
  store float %34, ptr %35, align 4, !tbaa !5
  %36 = getelementptr inbounds i8, ptr %2, i64 20
  %37 = insertelement <2 x float> poison, float %16, i64 0
  %38 = shufflevector <2 x float> %37, <2 x float> poison, <2 x i32> zeroinitializer
  %39 = shufflevector <2 x float> %15, <2 x float> poison, <2 x i32> <i32 poison, i32 0>
  %40 = insertelement <2 x float> %39, float %12, i64 0
  %41 = fmul <2 x float> %38, %40
  %42 = insertelement <2 x float> %41, float %25, i64 0
  %43 = call <2 x float> @llvm.fmuladd.v2f32(<2 x float> %27, <2 x float> %15, <2 x float> %42)
  %44 = fmul <2 x float> %43, <float 2.000000e+00, float 2.000000e+00>
  store <2 x float> %44, ptr %9, align 4, !tbaa !5
  %45 = fneg <2 x float> %41
  %46 = insertelement <2 x float> %15, float %12, i64 1
  %47 = shufflevector <2 x float> %15, <2 x float> poison, <2 x i32> <i32 1, i32 1>
  %48 = call <2 x float> @llvm.fmuladd.v2f32(<2 x float> %46, <2 x float> %47, <2 x float> %45)
  %49 = fmul <2 x float> %48, <float 2.000000e+00, float 2.000000e+00>
  store <2 x float> %49, ptr %36, align 4, !tbaa !5
  %50 = extractelement <2 x float> %41, i64 0
  %51 = call float @llvm.fmuladd.f32(float %19, float %17, float %50)
  %52 = fmul float %51, 2.000000e+00
  %53 = getelementptr inbounds i8, ptr %2, i64 28
  store float %52, ptr %53, align 4, !tbaa !5
  %54 = fmul <2 x float> %15, %15
  %55 = extractelement <2 x float> %54, i64 0
  %56 = call float @llvm.fmuladd.f32(float %12, float %12, float %55)
  %57 = fpext float %56 to double
  %58 = call double @llvm.fmuladd.f64(double %57, double -2.000000e+00, double 1.000000e+00)
  %59 = fptrunc double %58 to float
  %60 = getelementptr inbounds i8, ptr %2, i64 32
  store float %59, ptr %60, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %4) #4
  ret void
}

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

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

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


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