; LLVM IR from csviragh/robotsim :: src/utilities (math_utils)

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

@RotateVectAroundSpecificAxis.Temp = external hidden global [3 x double], align 16
@RotateVectAroundSpecificAxis.cosAngle = external hidden global double, align 8
@RotateVectAroundSpecificAxis.sinAngle = external hidden global double, align 8
@RotateVectAroundSpecificAxis.AxisUnitVect = external hidden global [3 x double], align 16

; Function Attrs: nounwind
declare double @cos(double noundef) #0

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

; Function Attrs: nounwind uwtable
declare dso_local void @FillVect(ptr noundef, double noundef, double noundef, double noundef) #2

; Function Attrs: nounwind uwtable
declare dso_local void @UnitVect(ptr noundef, ptr noundef) #2

; Function Attrs: nounwind
declare double @sin(double noundef) #0

; Function Attrs: nounwind uwtable
define dso_local void @RotateVectAroundSpecificAxis(ptr noundef %0, ptr noundef %1, ptr noundef %2, double noundef %3) #2 {
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca double, align 8
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store ptr %2, ptr %7, align 8, !tbaa !5
  store double %3, ptr %8, align 8, !tbaa !9
  %9 = load ptr, ptr %6, align 8, !tbaa !5
  %10 = getelementptr inbounds double, ptr %9, i64 0
  %11 = load double, ptr %10, align 8, !tbaa !9
  %12 = load ptr, ptr %6, align 8, !tbaa !5
  %13 = getelementptr inbounds double, ptr %12, i64 1
  %14 = load double, ptr %13, align 8, !tbaa !9
  %15 = load ptr, ptr %6, align 8, !tbaa !5
  %16 = getelementptr inbounds double, ptr %15, i64 2
  %17 = load double, ptr %16, align 8, !tbaa !9
  call void @FillVect(ptr noundef @RotateVectAroundSpecificAxis.Temp, double noundef %11, double noundef %14, double noundef %17)
  %18 = load ptr, ptr %7, align 8, !tbaa !5
  call void @UnitVect(ptr noundef @RotateVectAroundSpecificAxis.AxisUnitVect, ptr noundef %18)
  %19 = load double, ptr %8, align 8, !tbaa !9
  %20 = call double @sin(double noundef %19) #3
  store double %20, ptr @RotateVectAroundSpecificAxis.sinAngle, align 8, !tbaa !9
  %21 = load double, ptr %8, align 8, !tbaa !9
  %22 = call double @cos(double noundef %21) #3
  store double %22, ptr @RotateVectAroundSpecificAxis.cosAngle, align 8, !tbaa !9
  %23 = load double, ptr @RotateVectAroundSpecificAxis.cosAngle, align 8, !tbaa !9
  %24 = load double, ptr @RotateVectAroundSpecificAxis.AxisUnitVect, align 16, !tbaa !9
  %25 = load double, ptr @RotateVectAroundSpecificAxis.AxisUnitVect, align 16, !tbaa !9
  %26 = fmul double %24, %25
  %27 = load double, ptr @RotateVectAroundSpecificAxis.cosAngle, align 8, !tbaa !9
  %28 = fsub double 1.000000e+00, %27
  %29 = call double @llvm.fmuladd.f64(double %26, double %28, double %23)
  %30 = load double, ptr @RotateVectAroundSpecificAxis.Temp, align 16, !tbaa !9
  %31 = load double, ptr @RotateVectAroundSpecificAxis.AxisUnitVect, align 16, !tbaa !9
  %32 = load double, ptr getelementptr inbounds ([3 x double], ptr @RotateVectAroundSpecificAxis.AxisUnitVect, i64 0, i64 1), align 8, !tbaa !9
  %33 = fmul double %31, %32
  %34 = load double, ptr @RotateVectAroundSpecificAxis.cosAngle, align 8, !tbaa !9
  %35 = fsub double 1.000000e+00, %34
  %36 = load double, ptr getelementptr inbounds ([3 x double], ptr @RotateVectAroundSpecificAxis.AxisUnitVect, i64 0, i64 2), align 16, !tbaa !9
  %37 = load double, ptr @RotateVectAroundSpecificAxis.sinAngle, align 8, !tbaa !9
  %38 = fmul double %36, %37
  %39 = fneg double %38
  %40 = call double @llvm.fmuladd.f64(double %33, double %35, double %39)
  %41 = load double, ptr getelementptr inbounds ([3 x double], ptr @RotateVectAroundSpecificAxis.Temp, i64 0, i64 1), align 8, !tbaa !9
  %42 = fmul double %40, %41
  %43 = call double @llvm.fmuladd.f64(double %29, double %30, double %42)
  %44 = load double, ptr @RotateVectAroundSpecificAxis.AxisUnitVect, align 16, !tbaa !9
  %45 = load double, ptr getelementptr inbounds ([3 x double], ptr @RotateVectAroundSpecificAxis.AxisUnitVect, i64 0, i64 2), align 16, !tbaa !9
  %46 = fmul double %44, %45
  %47 = load double, ptr @RotateVectAroundSpecificAxis.cosAngle, align 8, !tbaa !9
  %48 = fsub double 1.000000e+00, %47
  %49 = load double, ptr getelementptr inbounds ([3 x double], ptr @RotateVectAroundSpecificAxis.AxisUnitVect, i64 0, i64 1), align 8, !tbaa !9
  %50 = load double, ptr @RotateVectAroundSpecificAxis.sinAngle, align 8, !tbaa !9
  %51 = fmul double %49, %50
  %52 = call double @llvm.fmuladd.f64(double %46, double %48, double %51)
  %53 = load double, ptr getelementptr inbounds ([3 x double], ptr @RotateVectAroundSpecificAxis.Temp, i64 0, i64 2), align 16, !tbaa !9
  %54 = call double @llvm.fmuladd.f64(double %52, double %53, double %43)
  %55 = load ptr, ptr %5, align 8, !tbaa !5
  %56 = getelementptr inbounds double, ptr %55, i64 0
  store double %54, ptr %56, align 8, !tbaa !9
  %57 = load double, ptr @RotateVectAroundSpecificAxis.AxisUnitVect, align 16, !tbaa !9
  %58 = load double, ptr getelementptr inbounds ([3 x double], ptr @RotateVectAroundSpecificAxis.AxisUnitVect, i64 0, i64 1), align 8, !tbaa !9
  %59 = fmul double %57, %58
  %60 = load double, ptr @RotateVectAroundSpecificAxis.cosAngle, align 8, !tbaa !9
  %61 = fsub double 1.000000e+00, %60
  %62 = load double, ptr getelementptr inbounds ([3 x double], ptr @RotateVectAroundSpecificAxis.AxisUnitVect, i64 0, i64 2), align 16, !tbaa !9
  %63 = load double, ptr @RotateVectAroundSpecificAxis.sinAngle, align 8, !tbaa !9
  %64 = fmul double %62, %63
  %65 = call double @llvm.fmuladd.f64(double %59, double %61, double %64)
  %66 = load double, ptr @RotateVectAroundSpecificAxis.Temp, align 16, !tbaa !9
  %67 = load double, ptr @RotateVectAroundSpecificAxis.cosAngle, align 8, !tbaa !9
  %68 = load double, ptr getelementptr inbounds ([3 x double], ptr @RotateVectAroundSpecificAxis.AxisUnitVect, i64 0, i64 1), align 8, !tbaa !9
  %69 = load double, ptr getelementptr inbounds ([3 x double], ptr @RotateVectAroundSpecificAxis.AxisUnitVect, i64 0, i64 1), align 8, !tbaa !9
  %70 = fmul double %68, %69
  %71 = load double, ptr @RotateVectAroundSpecificAxis.cosAngle, align 8, !tbaa !9
  %72 = fsub double 1.000000e+00, %71
  %73 = call double @llvm.fmuladd.f64(double %70, double %72, double %67)
  %74 = load double, ptr getelementptr inbounds ([3 x double], ptr @RotateVectAroundSpecificAxis.Temp, i64 0, i64 1), align 8, !tbaa !9
  %75 = fmul double %73, %74
  %76 = call double @llvm.fmuladd.f64(double %65, double %66, double %75)
  %77 = load double, ptr getelementptr inbounds ([3 x double], ptr @RotateVectAroundSpecificAxis.AxisUnitVect, i64 0, i64 1), align 8, !tbaa !9
  %78 = load double, ptr getelementptr inbounds ([3 x double], ptr @RotateVectAroundSpecificAxis.AxisUnitVect, i64 0, i64 2), align 16, !tbaa !9
  %79 = fmul double %77, %78
  %80 = load double, ptr @RotateVectAroundSpecificAxis.cosAngle, align 8, !tbaa !9
  %81 = fsub double 1.000000e+00, %80
  %82 = load double, ptr @RotateVectAroundSpecificAxis.AxisUnitVect, align 16, !tbaa !9
  %83 = load double, ptr @RotateVectAroundSpecificAxis.sinAngle, align 8, !tbaa !9
  %84 = fmul double %82, %83
  %85 = fneg double %84
  %86 = call double @llvm.fmuladd.f64(double %79, double %81, double %85)
  %87 = load double, ptr getelementptr inbounds ([3 x double], ptr @RotateVectAroundSpecificAxis.Temp, i64 0, i64 2), align 16, !tbaa !9
  %88 = call double @llvm.fmuladd.f64(double %86, double %87, double %76)
  %89 = load ptr, ptr %5, align 8, !tbaa !5
  %90 = getelementptr inbounds double, ptr %89, i64 1
  store double %88, ptr %90, align 8, !tbaa !9
  %91 = load double, ptr getelementptr inbounds ([3 x double], ptr @RotateVectAroundSpecificAxis.AxisUnitVect, i64 0, i64 2), align 16, !tbaa !9
  %92 = load double, ptr @RotateVectAroundSpecificAxis.AxisUnitVect, align 16, !tbaa !9
  %93 = fmul double %91, %92
  %94 = load double, ptr @RotateVectAroundSpecificAxis.cosAngle, align 8, !tbaa !9
  %95 = fsub double 1.000000e+00, %94
  %96 = load double, ptr getelementptr inbounds ([3 x double], ptr @RotateVectAroundSpecificAxis.AxisUnitVect, i64 0, i64 1), align 8, !tbaa !9
  %97 = load double, ptr @RotateVectAroundSpecificAxis.sinAngle, align 8, !tbaa !9
  %98 = fmul double %96, %97
  %99 = fneg double %98
  %100 = call double @llvm.fmuladd.f64(double %93, double %95, double %99)
  %101 = load double, ptr @RotateVectAroundSpecificAxis.Temp, align 16, !tbaa !9
  %102 = load double, ptr getelementptr inbounds ([3 x double], ptr @RotateVectAroundSpecificAxis.AxisUnitVect, i64 0, i64 2), align 16, !tbaa !9
  %103 = load double, ptr getelementptr inbounds ([3 x double], ptr @RotateVectAroundSpecificAxis.AxisUnitVect, i64 0, i64 1), align 8, !tbaa !9
  %104 = fmul double %102, %103
  %105 = load double, ptr @RotateVectAroundSpecificAxis.cosAngle, align 8, !tbaa !9
  %106 = fsub double 1.000000e+00, %105
  %107 = load double, ptr @RotateVectAroundSpecificAxis.AxisUnitVect, align 16, !tbaa !9
  %108 = load double, ptr @RotateVectAroundSpecificAxis.sinAngle, align 8, !tbaa !9
  %109 = fmul double %107, %108
  %110 = call double @llvm.fmuladd.f64(double %104, double %106, double %109)
  %111 = load double, ptr getelementptr inbounds ([3 x double], ptr @RotateVectAroundSpecificAxis.Temp, i64 0, i64 1), align 8, !tbaa !9
  %112 = fmul double %110, %111
  %113 = call double @llvm.fmuladd.f64(double %100, double %101, double %112)
  %114 = load double, ptr @RotateVectAroundSpecificAxis.cosAngle, align 8, !tbaa !9
  %115 = load double, ptr getelementptr inbounds ([3 x double], ptr @RotateVectAroundSpecificAxis.AxisUnitVect, i64 0, i64 2), align 16, !tbaa !9
  %116 = load double, ptr getelementptr inbounds ([3 x double], ptr @RotateVectAroundSpecificAxis.AxisUnitVect, i64 0, i64 2), align 16, !tbaa !9
  %117 = fmul double %115, %116
  %118 = load double, ptr @RotateVectAroundSpecificAxis.cosAngle, align 8, !tbaa !9
  %119 = fsub double 1.000000e+00, %118
  %120 = call double @llvm.fmuladd.f64(double %117, double %119, double %114)
  %121 = load double, ptr getelementptr inbounds ([3 x double], ptr @RotateVectAroundSpecificAxis.Temp, i64 0, i64 2), align 16, !tbaa !9
  %122 = call double @llvm.fmuladd.f64(double %120, double %121, double %113)
  %123 = load ptr, ptr %5, align 8, !tbaa !5
  %124 = getelementptr inbounds double, ptr %123, i64 2
  store double %122, ptr %124, align 8, !tbaa !9
  ret void
}

attributes #0 = { 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 #1 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #2 = { 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 = { 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/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"double", !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"

@RotateVectAroundSpecificAxis.Temp = external hidden global [3 x double], align 16
@RotateVectAroundSpecificAxis.cosAngle = external hidden local_unnamed_addr global double, align 8
@RotateVectAroundSpecificAxis.sinAngle = external hidden local_unnamed_addr global double, align 8
@RotateVectAroundSpecificAxis.AxisUnitVect = external hidden global [3 x double], align 16

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

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

; Function Attrs: nounwind uwtable
declare dso_local void @FillVect(ptr noundef, double noundef, double noundef, double noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
declare dso_local void @UnitVect(ptr noundef, ptr noundef) local_unnamed_addr #2

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

; Function Attrs: nounwind uwtable
define dso_local void @RotateVectAroundSpecificAxis(ptr nocapture noundef writeonly %0, ptr nocapture noundef readonly %1, ptr noundef %2, double noundef %3) local_unnamed_addr #2 {
  %5 = load double, ptr %1, align 8, !tbaa !5
  %6 = getelementptr inbounds i8, ptr %1, i64 8
  %7 = load double, ptr %6, align 8, !tbaa !5
  %8 = getelementptr inbounds i8, ptr %1, i64 16
  %9 = load double, ptr %8, align 8, !tbaa !5
  tail call void @FillVect(ptr noundef nonnull @RotateVectAroundSpecificAxis.Temp, double noundef %5, double noundef %7, double noundef %9)
  tail call void @UnitVect(ptr noundef nonnull @RotateVectAroundSpecificAxis.AxisUnitVect, ptr noundef %2)
  %10 = tail call double @sin(double noundef %3) #3
  store double %10, ptr @RotateVectAroundSpecificAxis.sinAngle, align 8, !tbaa !5
  %11 = tail call double @cos(double noundef %3) #3
  store double %11, ptr @RotateVectAroundSpecificAxis.cosAngle, align 8, !tbaa !5
  %12 = load double, ptr @RotateVectAroundSpecificAxis.AxisUnitVect, align 16, !tbaa !5
  %13 = fmul double %12, %12
  %14 = fsub double 1.000000e+00, %11
  %15 = tail call double @llvm.fmuladd.f64(double %13, double %14, double %11)
  %16 = load double, ptr @RotateVectAroundSpecificAxis.Temp, align 16, !tbaa !5
  %17 = load double, ptr getelementptr inbounds (i8, ptr @RotateVectAroundSpecificAxis.AxisUnitVect, i64 8), align 8, !tbaa !5
  %18 = fmul double %12, %17
  %19 = load double, ptr getelementptr inbounds (i8, ptr @RotateVectAroundSpecificAxis.AxisUnitVect, i64 16), align 16, !tbaa !5
  %20 = load double, ptr @RotateVectAroundSpecificAxis.sinAngle, align 8, !tbaa !5
  %21 = fneg double %19
  %22 = fmul double %20, %21
  %23 = tail call double @llvm.fmuladd.f64(double %18, double %14, double %22)
  %24 = load double, ptr getelementptr inbounds (i8, ptr @RotateVectAroundSpecificAxis.Temp, i64 8), align 8, !tbaa !5
  %25 = fmul double %24, %23
  %26 = tail call double @llvm.fmuladd.f64(double %15, double %16, double %25)
  %27 = fmul double %12, %19
  %28 = fmul double %17, %20
  %29 = tail call double @llvm.fmuladd.f64(double %27, double %14, double %28)
  %30 = load double, ptr getelementptr inbounds (i8, ptr @RotateVectAroundSpecificAxis.Temp, i64 16), align 16, !tbaa !5
  %31 = tail call double @llvm.fmuladd.f64(double %29, double %30, double %26)
  store double %31, ptr %0, align 8, !tbaa !5
  %32 = load double, ptr @RotateVectAroundSpecificAxis.AxisUnitVect, align 16, !tbaa !5
  %33 = load double, ptr getelementptr inbounds (i8, ptr @RotateVectAroundSpecificAxis.AxisUnitVect, i64 8), align 8, !tbaa !5
  %34 = fmul double %32, %33
  %35 = load double, ptr @RotateVectAroundSpecificAxis.cosAngle, align 8, !tbaa !5
  %36 = fsub double 1.000000e+00, %35
  %37 = load double, ptr getelementptr inbounds (i8, ptr @RotateVectAroundSpecificAxis.AxisUnitVect, i64 16), align 16, !tbaa !5
  %38 = load double, ptr @RotateVectAroundSpecificAxis.sinAngle, align 8, !tbaa !5
  %39 = fmul double %37, %38
  %40 = tail call double @llvm.fmuladd.f64(double %34, double %36, double %39)
  %41 = load double, ptr @RotateVectAroundSpecificAxis.Temp, align 16, !tbaa !5
  %42 = fmul double %33, %33
  %43 = tail call double @llvm.fmuladd.f64(double %42, double %36, double %35)
  %44 = load double, ptr getelementptr inbounds (i8, ptr @RotateVectAroundSpecificAxis.Temp, i64 8), align 8, !tbaa !5
  %45 = fmul double %43, %44
  %46 = tail call double @llvm.fmuladd.f64(double %40, double %41, double %45)
  %47 = fmul double %33, %37
  %48 = fneg double %32
  %49 = fmul double %38, %48
  %50 = tail call double @llvm.fmuladd.f64(double %47, double %36, double %49)
  %51 = load double, ptr getelementptr inbounds (i8, ptr @RotateVectAroundSpecificAxis.Temp, i64 16), align 16, !tbaa !5
  %52 = tail call double @llvm.fmuladd.f64(double %50, double %51, double %46)
  %53 = getelementptr inbounds i8, ptr %0, i64 8
  store double %52, ptr %53, align 8, !tbaa !5
  %54 = load double, ptr getelementptr inbounds (i8, ptr @RotateVectAroundSpecificAxis.AxisUnitVect, i64 16), align 16, !tbaa !5
  %55 = fmul double %32, %54
  %56 = load double, ptr getelementptr inbounds (i8, ptr @RotateVectAroundSpecificAxis.AxisUnitVect, i64 8), align 8, !tbaa !5
  %57 = fneg double %56
  %58 = fmul double %38, %57
  %59 = tail call double @llvm.fmuladd.f64(double %55, double %36, double %58)
  %60 = fmul double %54, %56
  %61 = fmul double %32, %38
  %62 = tail call double @llvm.fmuladd.f64(double %60, double %36, double %61)
  %63 = load double, ptr getelementptr inbounds (i8, ptr @RotateVectAroundSpecificAxis.Temp, i64 8), align 8, !tbaa !5
  %64 = fmul double %63, %62
  %65 = tail call double @llvm.fmuladd.f64(double %59, double %41, double %64)
  %66 = fmul double %54, %54
  %67 = tail call double @llvm.fmuladd.f64(double %66, double %36, double %35)
  %68 = load double, ptr getelementptr inbounds (i8, ptr @RotateVectAroundSpecificAxis.Temp, i64 16), align 16, !tbaa !5
  %69 = tail call double @llvm.fmuladd.f64(double %67, double %68, double %65)
  %70 = getelementptr inbounds i8, ptr %0, i64 16
  store double %69, ptr %70, align 8, !tbaa !5
  ret void
}

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


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