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

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

; 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
declare double @sin(double noundef) #0

; Function Attrs: nounwind uwtable
define dso_local void @RotateVectZY(ptr noundef %0, ptr noundef %1, double noundef %2) #2 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca double, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store double %2, ptr %6, align 8, !tbaa !9
  %7 = load ptr, ptr %5, align 8, !tbaa !5
  %8 = getelementptr inbounds double, ptr %7, i64 0
  %9 = load double, ptr %8, align 8, !tbaa !9
  %10 = load ptr, ptr %5, align 8, !tbaa !5
  %11 = getelementptr inbounds double, ptr %10, i64 1
  %12 = load double, ptr %11, align 8, !tbaa !9
  %13 = load ptr, ptr %5, align 8, !tbaa !5
  %14 = getelementptr inbounds double, ptr %13, i64 2
  %15 = load double, ptr %14, align 8, !tbaa !9
  call void @FillVect(ptr noundef @RotateVectZY.Temp, double noundef %9, double noundef %12, double noundef %15)
  %16 = load double, ptr %6, align 8, !tbaa !9
  %17 = call double @cos(double noundef %16) #3
  store double %17, ptr @RotateVectZY.cosAngle, align 8, !tbaa !9
  %18 = load double, ptr %6, align 8, !tbaa !9
  %19 = call double @sin(double noundef %18) #3
  store double %19, ptr @RotateVectZY.sinAngle, align 8, !tbaa !9
  %20 = load double, ptr @RotateVectZY.Temp, align 16, !tbaa !9
  %21 = load ptr, ptr %4, align 8, !tbaa !5
  %22 = getelementptr inbounds double, ptr %21, i64 0
  store double %20, ptr %22, align 8, !tbaa !9
  %23 = load double, ptr getelementptr inbounds ([3 x double], ptr @RotateVectZY.Temp, i64 0, i64 1), align 8, !tbaa !9
  %24 = load double, ptr @RotateVectZY.cosAngle, align 8, !tbaa !9
  %25 = load double, ptr getelementptr inbounds ([3 x double], ptr @RotateVectZY.Temp, i64 0, i64 2), align 16, !tbaa !9
  %26 = load double, ptr @RotateVectZY.sinAngle, align 8, !tbaa !9
  %27 = fmul double %25, %26
  %28 = fneg double %27
  %29 = call double @llvm.fmuladd.f64(double %23, double %24, double %28)
  %30 = load ptr, ptr %4, align 8, !tbaa !5
  %31 = getelementptr inbounds double, ptr %30, i64 1
  store double %29, ptr %31, align 8, !tbaa !9
  %32 = load double, ptr getelementptr inbounds ([3 x double], ptr @RotateVectZY.Temp, i64 0, i64 1), align 8, !tbaa !9
  %33 = load double, ptr @RotateVectZY.sinAngle, align 8, !tbaa !9
  %34 = load double, ptr getelementptr inbounds ([3 x double], ptr @RotateVectZY.Temp, i64 0, i64 2), align 16, !tbaa !9
  %35 = load double, ptr @RotateVectZY.cosAngle, align 8, !tbaa !9
  %36 = fmul double %34, %35
  %37 = call double @llvm.fmuladd.f64(double %32, double %33, double %36)
  %38 = load ptr, ptr %4, align 8, !tbaa !5
  %39 = getelementptr inbounds double, ptr %38, i64 2
  store double %37, ptr %39, 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"

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

; 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: mustprogress nofree nounwind willreturn memory(write)
declare double @sin(double noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local void @RotateVectZY(ptr nocapture noundef writeonly %0, ptr nocapture noundef readonly %1, double noundef %2) local_unnamed_addr #2 {
  %4 = load double, ptr %1, align 8, !tbaa !5
  %5 = getelementptr inbounds i8, ptr %1, i64 8
  %6 = load double, ptr %5, align 8, !tbaa !5
  %7 = getelementptr inbounds i8, ptr %1, i64 16
  %8 = load double, ptr %7, align 8, !tbaa !5
  tail call void @FillVect(ptr noundef nonnull @RotateVectZY.Temp, double noundef %4, double noundef %6, double noundef %8)
  %9 = tail call double @cos(double noundef %2) #3
  store double %9, ptr @RotateVectZY.cosAngle, align 8, !tbaa !5
  %10 = tail call double @sin(double noundef %2) #3
  store double %10, ptr @RotateVectZY.sinAngle, align 8, !tbaa !5
  %11 = load double, ptr @RotateVectZY.Temp, align 16, !tbaa !5
  store double %11, ptr %0, align 8, !tbaa !5
  %12 = load double, ptr getelementptr inbounds (i8, ptr @RotateVectZY.Temp, i64 8), align 8, !tbaa !5
  %13 = load double, ptr @RotateVectZY.cosAngle, align 8, !tbaa !5
  %14 = load double, ptr getelementptr inbounds (i8, ptr @RotateVectZY.Temp, i64 16), align 16, !tbaa !5
  %15 = load double, ptr @RotateVectZY.sinAngle, align 8, !tbaa !5
  %16 = fneg double %14
  %17 = fmul double %15, %16
  %18 = tail call double @llvm.fmuladd.f64(double %12, double %13, double %17)
  %19 = getelementptr inbounds i8, ptr %0, i64 8
  store double %18, ptr %19, align 8, !tbaa !5
  %20 = load double, ptr getelementptr inbounds (i8, ptr @RotateVectZY.Temp, i64 8), align 8, !tbaa !5
  %21 = load double, ptr getelementptr inbounds (i8, ptr @RotateVectZY.Temp, i64 16), align 16, !tbaa !5
  %22 = fmul double %13, %21
  %23 = tail call double @llvm.fmuladd.f64(double %20, double %15, double %22)
  %24 = getelementptr inbounds i8, ptr %0, i64 16
  store double %23, ptr %24, 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