; LLVM IR from HRI-EU/Rcs :: src/RcsCore (Rcs_Mat3d)

; 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: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #1

; Function Attrs: nounwind
declare double @atan2(double noundef, double noundef) #2

; Function Attrs: nounwind uwtable
define dso_local void @Mat3d_toEulerAngles(ptr noundef %0, ptr noundef %1) #3 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca double, align 8
  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) #4
  %6 = load ptr, ptr %4, align 8, !tbaa !5
  %7 = getelementptr inbounds [3 x double], ptr %6, i64 0
  %8 = getelementptr inbounds [3 x double], ptr %7, i64 0, i64 0
  %9 = load double, ptr %8, align 8, !tbaa !9
  %10 = load ptr, ptr %4, align 8, !tbaa !5
  %11 = getelementptr inbounds [3 x double], ptr %10, i64 0
  %12 = getelementptr inbounds [3 x double], ptr %11, i64 0, i64 0
  %13 = load double, ptr %12, align 8, !tbaa !9
  %14 = load ptr, ptr %4, align 8, !tbaa !5
  %15 = getelementptr inbounds [3 x double], ptr %14, i64 1
  %16 = getelementptr inbounds [3 x double], ptr %15, i64 0, i64 0
  %17 = load double, ptr %16, align 8, !tbaa !9
  %18 = load ptr, ptr %4, align 8, !tbaa !5
  %19 = getelementptr inbounds [3 x double], ptr %18, i64 1
  %20 = getelementptr inbounds [3 x double], ptr %19, i64 0, i64 0
  %21 = load double, ptr %20, align 8, !tbaa !9
  %22 = fmul double %17, %21
  %23 = call double @llvm.fmuladd.f64(double %9, double %13, double %22)
  %24 = call double @sqrt(double noundef %23) #4
  store double %24, ptr %5, align 8, !tbaa !9
  %25 = load double, ptr %5, align 8, !tbaa !9
  %26 = fcmp ogt double %25, 0x3EC0000000000000
  br i1 %26, label %27, label %62

27:                                               ; preds = %2
  %28 = load ptr, ptr %4, align 8, !tbaa !5
  %29 = getelementptr inbounds [3 x double], ptr %28, i64 2
  %30 = getelementptr inbounds [3 x double], ptr %29, i64 0, i64 1
  %31 = load double, ptr %30, align 8, !tbaa !9
  %32 = load ptr, ptr %4, align 8, !tbaa !5
  %33 = getelementptr inbounds [3 x double], ptr %32, i64 2
  %34 = getelementptr inbounds [3 x double], ptr %33, i64 0, i64 2
  %35 = load double, ptr %34, align 8, !tbaa !9
  %36 = call double @atan2(double noundef %31, double noundef %35) #4
  %37 = fneg double %36
  %38 = load ptr, ptr %3, align 8, !tbaa !5
  %39 = getelementptr inbounds double, ptr %38, i64 0
  store double %37, ptr %39, align 8, !tbaa !9
  %40 = load ptr, ptr %4, align 8, !tbaa !5
  %41 = getelementptr inbounds [3 x double], ptr %40, i64 2
  %42 = getelementptr inbounds [3 x double], ptr %41, i64 0, i64 0
  %43 = load double, ptr %42, align 8, !tbaa !9
  %44 = fneg double %43
  %45 = load double, ptr %5, align 8, !tbaa !9
  %46 = call double @atan2(double noundef %44, double noundef %45) #4
  %47 = fneg double %46
  %48 = load ptr, ptr %3, align 8, !tbaa !5
  %49 = getelementptr inbounds double, ptr %48, i64 1
  store double %47, ptr %49, align 8, !tbaa !9
  %50 = load ptr, ptr %4, align 8, !tbaa !5
  %51 = getelementptr inbounds [3 x double], ptr %50, i64 1
  %52 = getelementptr inbounds [3 x double], ptr %51, i64 0, i64 0
  %53 = load double, ptr %52, align 8, !tbaa !9
  %54 = load ptr, ptr %4, align 8, !tbaa !5
  %55 = getelementptr inbounds [3 x double], ptr %54, i64 0
  %56 = getelementptr inbounds [3 x double], ptr %55, i64 0, i64 0
  %57 = load double, ptr %56, align 8, !tbaa !9
  %58 = call double @atan2(double noundef %53, double noundef %57) #4
  %59 = fneg double %58
  %60 = load ptr, ptr %3, align 8, !tbaa !5
  %61 = getelementptr inbounds double, ptr %60, i64 2
  store double %59, ptr %61, align 8, !tbaa !9
  br label %88

62:                                               ; preds = %2
  %63 = load ptr, ptr %4, align 8, !tbaa !5
  %64 = getelementptr inbounds [3 x double], ptr %63, i64 1
  %65 = getelementptr inbounds [3 x double], ptr %64, i64 0, i64 2
  %66 = load double, ptr %65, align 8, !tbaa !9
  %67 = fneg double %66
  %68 = load ptr, ptr %4, align 8, !tbaa !5
  %69 = getelementptr inbounds [3 x double], ptr %68, i64 1
  %70 = getelementptr inbounds [3 x double], ptr %69, i64 0, i64 1
  %71 = load double, ptr %70, align 8, !tbaa !9
  %72 = call double @atan2(double noundef %67, double noundef %71) #4
  %73 = fneg double %72
  %74 = load ptr, ptr %3, align 8, !tbaa !5
  %75 = getelementptr inbounds double, ptr %74, i64 0
  store double %73, ptr %75, align 8, !tbaa !9
  %76 = load ptr, ptr %4, align 8, !tbaa !5
  %77 = getelementptr inbounds [3 x double], ptr %76, i64 2
  %78 = getelementptr inbounds [3 x double], ptr %77, i64 0, i64 0
  %79 = load double, ptr %78, align 8, !tbaa !9
  %80 = fneg double %79
  %81 = load double, ptr %5, align 8, !tbaa !9
  %82 = call double @atan2(double noundef %80, double noundef %81) #4
  %83 = fneg double %82
  %84 = load ptr, ptr %3, align 8, !tbaa !5
  %85 = getelementptr inbounds double, ptr %84, i64 1
  store double %83, ptr %85, align 8, !tbaa !9
  %86 = load ptr, ptr %3, align 8, !tbaa !5
  %87 = getelementptr inbounds double, ptr %86, i64 2
  store double 0.000000e+00, ptr %87, align 8, !tbaa !9
  br label %88

88:                                               ; preds = %62, %27
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #4
  ret void
}

; Function Attrs: nounwind
declare double @sqrt(double noundef) #2

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

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

; Function Attrs: mustprogress nofree nounwind willreturn memory(write)
declare double @atan2(double noundef, double noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nofree nounwind willreturn memory(write, argmem: readwrite) uwtable
define dso_local void @Mat3d_toEulerAngles(ptr nocapture noundef writeonly %0, ptr nocapture noundef readonly %1) local_unnamed_addr #2 {
  %3 = load double, ptr %1, align 8, !tbaa !5
  %4 = getelementptr inbounds i8, ptr %1, i64 24
  %5 = load double, ptr %4, align 8, !tbaa !5
  %6 = fmul double %5, %5
  %7 = tail call double @llvm.fmuladd.f64(double %3, double %3, double %6)
  %sqrt = tail call double @llvm.sqrt.f64(double %7)
  %8 = fcmp ogt double %sqrt, 0x3EC0000000000000
  br i1 %8, label %9, label %26

9:                                                ; preds = %2
  %10 = getelementptr inbounds i8, ptr %1, i64 48
  %11 = getelementptr inbounds i8, ptr %1, i64 56
  %12 = load double, ptr %11, align 8, !tbaa !5
  %13 = getelementptr inbounds i8, ptr %1, i64 64
  %14 = load double, ptr %13, align 8, !tbaa !5
  %15 = tail call double @atan2(double noundef %12, double noundef %14) #4
  %16 = fneg double %15
  store double %16, ptr %0, align 8, !tbaa !5
  %17 = load double, ptr %10, align 8, !tbaa !5
  %18 = fneg double %17
  %19 = tail call double @atan2(double noundef %18, double noundef %sqrt) #4
  %20 = fneg double %19
  %21 = getelementptr inbounds i8, ptr %0, i64 8
  store double %20, ptr %21, align 8, !tbaa !5
  %22 = load double, ptr %4, align 8, !tbaa !5
  %23 = load double, ptr %1, align 8, !tbaa !5
  %24 = tail call double @atan2(double noundef %22, double noundef %23) #4
  %25 = fneg double %24
  br label %40

26:                                               ; preds = %2
  %27 = getelementptr inbounds i8, ptr %1, i64 40
  %28 = load double, ptr %27, align 8, !tbaa !5
  %29 = fneg double %28
  %30 = getelementptr inbounds i8, ptr %1, i64 32
  %31 = load double, ptr %30, align 8, !tbaa !5
  %32 = tail call double @atan2(double noundef %29, double noundef %31) #4
  %33 = fneg double %32
  store double %33, ptr %0, align 8, !tbaa !5
  %34 = getelementptr inbounds i8, ptr %1, i64 48
  %35 = load double, ptr %34, align 8, !tbaa !5
  %36 = fneg double %35
  %37 = tail call double @atan2(double noundef %36, double noundef %sqrt) #4
  %38 = fneg double %37
  %39 = getelementptr inbounds i8, ptr %0, i64 8
  store double %38, ptr %39, align 8, !tbaa !5
  br label %40

40:                                               ; preds = %26, %9
  %.sink = phi double [ %25, %9 ], [ 0.000000e+00, %26 ]
  %41 = getelementptr inbounds i8, ptr %0, i64 16
  store double %.sink, ptr %41, align 8
  ret void
}

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

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


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