; LLVM IR from achilles288/robot-monitor-graphics :: src/base/math/euler.ll (ZN3rmg5EulerC2ERKNS_4Mat3E)

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

%"struct.rmg::Euler" = type { float, float, float }

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN3rmg5EulerC2ERKNS_4Mat3E(ptr noundef nonnull align 4 dereferenceable(12) %0, ptr noundef nonnull align 4 dereferenceable(36) %1) unnamed_addr #0 align 2 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca float, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  %6 = load ptr, ptr %3, align 8
  %7 = getelementptr inbounds %"struct.rmg::Euler", ptr %6, i32 0, i32 0
  store float 0.000000e+00, ptr %7, align 4, !tbaa !9
  %8 = getelementptr inbounds %"struct.rmg::Euler", ptr %6, i32 0, i32 1
  store float 0.000000e+00, ptr %8, align 4, !tbaa !12
  %9 = getelementptr inbounds %"struct.rmg::Euler", ptr %6, i32 0, i32 2
  store float 0.000000e+00, ptr %9, align 4, !tbaa !13
  %10 = load ptr, ptr %4, align 8, !tbaa !5
  %11 = call noundef nonnull align 4 dereferenceable(12) ptr @_ZNK3rmg4Mat3ixEh(ptr noundef nonnull align 4 dereferenceable(36) %10, i8 noundef zeroext 2)
  %12 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNK3rmg7Mat3RowixEh(ptr noundef nonnull align 4 dereferenceable(12) %11, i8 noundef zeroext 0)
  %13 = load float, ptr %12, align 4, !tbaa !14
  %14 = fpext float %13 to double
  %15 = call double @asin(double noundef %14) #5
  %16 = fneg double %15
  %17 = fptrunc double %16 to float
  %18 = getelementptr inbounds %"struct.rmg::Euler", ptr %6, i32 0, i32 1
  store float %17, ptr %18, align 4, !tbaa !12
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #5
  %19 = getelementptr inbounds %"struct.rmg::Euler", ptr %6, i32 0, i32 1
  %20 = load float, ptr %19, align 4, !tbaa !12
  %21 = fpext float %20 to double
  %22 = call double @cos(double noundef %21) #5
  %23 = fptrunc double %22 to float
  store float %23, ptr %5, align 4, !tbaa !14
  %24 = load float, ptr %5, align 4, !tbaa !14
  %25 = fpext float %24 to double
  %26 = call double @llvm.fabs.f64(double %25)
  %27 = fcmp ogt double %26, 0x3F50624DE0000000
  br i1 %27, label %28, label %63

28:                                               ; preds = %2
  %29 = load ptr, ptr %4, align 8, !tbaa !5
  %30 = call noundef nonnull align 4 dereferenceable(12) ptr @_ZNK3rmg4Mat3ixEh(ptr noundef nonnull align 4 dereferenceable(36) %29, i8 noundef zeroext 2)
  %31 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNK3rmg7Mat3RowixEh(ptr noundef nonnull align 4 dereferenceable(12) %30, i8 noundef zeroext 1)
  %32 = load float, ptr %31, align 4, !tbaa !14
  %33 = load float, ptr %5, align 4, !tbaa !14
  %34 = fdiv float %32, %33
  %35 = fpext float %34 to double
  %36 = load ptr, ptr %4, align 8, !tbaa !5
  %37 = call noundef nonnull align 4 dereferenceable(12) ptr @_ZNK3rmg4Mat3ixEh(ptr noundef nonnull align 4 dereferenceable(36) %36, i8 noundef zeroext 2)
  %38 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNK3rmg7Mat3RowixEh(ptr noundef nonnull align 4 dereferenceable(12) %37, i8 noundef zeroext 2)
  %39 = load float, ptr %38, align 4, !tbaa !14
  %40 = load float, ptr %5, align 4, !tbaa !14
  %41 = fdiv float %39, %40
  %42 = fpext float %41 to double
  %43 = call double @atan2(double noundef %35, double noundef %42) #5
  %44 = fptrunc double %43 to float
  %45 = getelementptr inbounds %"struct.rmg::Euler", ptr %6, i32 0, i32 0
  store float %44, ptr %45, align 4, !tbaa !9
  %46 = load ptr, ptr %4, align 8, !tbaa !5
  %47 = call noundef nonnull align 4 dereferenceable(12) ptr @_ZNK3rmg4Mat3ixEh(ptr noundef nonnull align 4 dereferenceable(36) %46, i8 noundef zeroext 1)
  %48 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNK3rmg7Mat3RowixEh(ptr noundef nonnull align 4 dereferenceable(12) %47, i8 noundef zeroext 0)
  %49 = load float, ptr %48, align 4, !tbaa !14
  %50 = load float, ptr %5, align 4, !tbaa !14
  %51 = fdiv float %49, %50
  %52 = fpext float %51 to double
  %53 = load ptr, ptr %4, align 8, !tbaa !5
  %54 = call noundef nonnull align 4 dereferenceable(12) ptr @_ZNK3rmg4Mat3ixEh(ptr noundef nonnull align 4 dereferenceable(36) %53, i8 noundef zeroext 0)
  %55 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNK3rmg7Mat3RowixEh(ptr noundef nonnull align 4 dereferenceable(12) %54, i8 noundef zeroext 0)
  %56 = load float, ptr %55, align 4, !tbaa !14
  %57 = load float, ptr %5, align 4, !tbaa !14
  %58 = fdiv float %56, %57
  %59 = fpext float %58 to double
  %60 = call double @atan2(double noundef %52, double noundef %59) #5
  %61 = fptrunc double %60 to float
  %62 = getelementptr inbounds %"struct.rmg::Euler", ptr %6, i32 0, i32 2
  store float %61, ptr %62, align 4, !tbaa !13
  br label %100

63:                                               ; preds = %2
  %64 = getelementptr inbounds %"struct.rmg::Euler", ptr %6, i32 0, i32 1
  %65 = load float, ptr %64, align 4, !tbaa !12
  %66 = fcmp ogt float %65, 0.000000e+00
  br i1 %66, label %67, label %82

67:                                               ; preds = %63
  %68 = load ptr, ptr %4, align 8, !tbaa !5
  %69 = call noundef nonnull align 4 dereferenceable(12) ptr @_ZNK3rmg4Mat3ixEh(ptr noundef nonnull align 4 dereferenceable(36) %68, i8 noundef zeroext 0)
  %70 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNK3rmg7Mat3RowixEh(ptr noundef nonnull align 4 dereferenceable(12) %69, i8 noundef zeroext 1)
  %71 = load float, ptr %70, align 4, !tbaa !14
  %72 = fneg float %71
  %73 = fpext float %72 to double
  %74 = load ptr, ptr %4, align 8, !tbaa !5
  %75 = call noundef nonnull align 4 dereferenceable(12) ptr @_ZNK3rmg4Mat3ixEh(ptr noundef nonnull align 4 dereferenceable(36) %74, i8 noundef zeroext 0)
  %76 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNK3rmg7Mat3RowixEh(ptr noundef nonnull align 4 dereferenceable(12) %75, i8 noundef zeroext 2)
  %77 = load float, ptr %76, align 4, !tbaa !14
  %78 = fpext float %77 to double
  %79 = call double @atan2(double noundef %73, double noundef %78) #5
  %80 = fptrunc double %79 to float
  %81 = getelementptr inbounds %"struct.rmg::Euler", ptr %6, i32 0, i32 2
  store float %80, ptr %81, align 4, !tbaa !13
  br label %98

82:                                               ; preds = %63
  %83 = load ptr, ptr %4, align 8, !tbaa !5
  %84 = call noundef nonnull align 4 dereferenceable(12) ptr @_ZNK3rmg4Mat3ixEh(ptr noundef nonnull align 4 dereferenceable(36) %83, i8 noundef zeroext 0)
  %85 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNK3rmg7Mat3RowixEh(ptr noundef nonnull align 4 dereferenceable(12) %84, i8 noundef zeroext 1)
  %86 = load float, ptr %85, align 4, !tbaa !14
  %87 = fneg float %86
  %88 = fpext float %87 to double
  %89 = load ptr, ptr %4, align 8, !tbaa !5
  %90 = call noundef nonnull align 4 dereferenceable(12) ptr @_ZNK3rmg4Mat3ixEh(ptr noundef nonnull align 4 dereferenceable(36) %89, i8 noundef zeroext 0)
  %91 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNK3rmg7Mat3RowixEh(ptr noundef nonnull align 4 dereferenceable(12) %90, i8 noundef zeroext 2)
  %92 = load float, ptr %91, align 4, !tbaa !14
  %93 = fneg float %92
  %94 = fpext float %93 to double
  %95 = call double @atan2(double noundef %88, double noundef %94) #5
  %96 = fptrunc double %95 to float
  %97 = getelementptr inbounds %"struct.rmg::Euler", ptr %6, i32 0, i32 2
  store float %96, ptr %97, align 4, !tbaa !13
  br label %98

98:                                               ; preds = %82, %67
  %99 = getelementptr inbounds %"struct.rmg::Euler", ptr %6, i32 0, i32 0
  store float 0.000000e+00, ptr %99, align 4, !tbaa !9
  br label %100

100:                                              ; preds = %98, %28
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #5
  ret void
}

; Function Attrs: nounwind
declare double @asin(double noundef) #1

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef nonnull align 4 dereferenceable(12) ptr @_ZNK3rmg4Mat3ixEh(ptr noundef nonnull align 4 dereferenceable(36), i8 noundef zeroext) #2 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZNK3rmg7Mat3RowixEh(ptr noundef nonnull align 4 dereferenceable(12), i8 noundef zeroext) #2 align 2

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

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

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

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

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

attributes #0 = { 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 #1 = { 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 #2 = { inlinehint 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 #3 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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, !11, i64 0}
!10 = !{!"_ZTSN3rmg5EulerE", !11, i64 0, !11, i64 4, !11, i64 8}
!11 = !{!"float", !7, i64 0}
!12 = !{!10, !11, i64 4}
!13 = !{!10, !11, i64 8}
!14 = !{!11, !11, 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 uwtable
define dso_local void @_ZN3rmg5EulerC2ERKNS_4Mat3E(ptr nocapture noundef nonnull align 4 dereferenceable(12) %0, ptr noundef nonnull align 4 dereferenceable(36) %1) unnamed_addr #0 align 2 {
  %3 = getelementptr inbounds i8, ptr %0, i64 4
  store <2 x float> zeroinitializer, ptr %0, align 4, !tbaa !5
  %4 = getelementptr inbounds i8, ptr %0, i64 8
  store float 0.000000e+00, ptr %4, align 4, !tbaa !9
  %5 = tail call noundef nonnull align 4 dereferenceable(12) ptr @_ZNK3rmg4Mat3ixEh(ptr noundef nonnull align 4 dereferenceable(36) %1, i8 noundef zeroext 2)
  %6 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNK3rmg7Mat3RowixEh(ptr noundef nonnull align 4 dereferenceable(12) %5, i8 noundef zeroext 0)
  %7 = load float, ptr %6, align 4, !tbaa !5
  %8 = fpext float %7 to double
  %9 = tail call double @asin(double noundef %8) #4
  %10 = fptrunc double %9 to float
  %11 = fneg float %10
  store float %11, ptr %3, align 4, !tbaa !11
  %12 = fpext float %11 to double
  %13 = tail call double @cos(double noundef %12) #4
  %14 = fptrunc double %13 to float
  %15 = tail call float @llvm.fabs.f32(float %14)
  %16 = fcmp ogt float %15, 0x3F50624DE0000000
  br i1 %16, label %17, label %42

17:                                               ; preds = %2
  %18 = tail call noundef nonnull align 4 dereferenceable(12) ptr @_ZNK3rmg4Mat3ixEh(ptr noundef nonnull align 4 dereferenceable(36) %1, i8 noundef zeroext 2)
  %19 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNK3rmg7Mat3RowixEh(ptr noundef nonnull align 4 dereferenceable(12) %18, i8 noundef zeroext 1)
  %20 = load float, ptr %19, align 4, !tbaa !5
  %21 = fdiv float %20, %14
  %22 = fpext float %21 to double
  %23 = tail call noundef nonnull align 4 dereferenceable(12) ptr @_ZNK3rmg4Mat3ixEh(ptr noundef nonnull align 4 dereferenceable(36) %1, i8 noundef zeroext 2)
  %24 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNK3rmg7Mat3RowixEh(ptr noundef nonnull align 4 dereferenceable(12) %23, i8 noundef zeroext 2)
  %25 = load float, ptr %24, align 4, !tbaa !5
  %26 = fdiv float %25, %14
  %27 = fpext float %26 to double
  %28 = tail call double @atan2(double noundef %22, double noundef %27) #4
  %29 = fptrunc double %28 to float
  store float %29, ptr %0, align 4, !tbaa !12
  %30 = tail call noundef nonnull align 4 dereferenceable(12) ptr @_ZNK3rmg4Mat3ixEh(ptr noundef nonnull align 4 dereferenceable(36) %1, i8 noundef zeroext 1)
  %31 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNK3rmg7Mat3RowixEh(ptr noundef nonnull align 4 dereferenceable(12) %30, i8 noundef zeroext 0)
  %32 = load float, ptr %31, align 4, !tbaa !5
  %33 = fdiv float %32, %14
  %34 = fpext float %33 to double
  %35 = tail call noundef nonnull align 4 dereferenceable(12) ptr @_ZNK3rmg4Mat3ixEh(ptr noundef nonnull align 4 dereferenceable(36) %1, i8 noundef zeroext 0)
  %36 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNK3rmg7Mat3RowixEh(ptr noundef nonnull align 4 dereferenceable(12) %35, i8 noundef zeroext 0)
  %37 = load float, ptr %36, align 4, !tbaa !5
  %38 = fdiv float %37, %14
  %39 = fpext float %38 to double
  %40 = tail call double @atan2(double noundef %34, double noundef %39) #4
  %41 = fptrunc double %40 to float
  store float %41, ptr %4, align 4, !tbaa !9
  br label %56

42:                                               ; preds = %2
  %43 = load float, ptr %3, align 4, !tbaa !11
  %44 = fcmp ogt float %43, 0.000000e+00
  %45 = tail call noundef nonnull align 4 dereferenceable(12) ptr @_ZNK3rmg4Mat3ixEh(ptr noundef nonnull align 4 dereferenceable(36) %1, i8 noundef zeroext 0)
  %46 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNK3rmg7Mat3RowixEh(ptr noundef nonnull align 4 dereferenceable(12) %45, i8 noundef zeroext 1)
  %47 = load float, ptr %46, align 4, !tbaa !5
  %48 = fneg float %47
  %49 = fpext float %48 to double
  %50 = tail call noundef nonnull align 4 dereferenceable(12) ptr @_ZNK3rmg4Mat3ixEh(ptr noundef nonnull align 4 dereferenceable(36) %1, i8 noundef zeroext 0)
  %51 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNK3rmg7Mat3RowixEh(ptr noundef nonnull align 4 dereferenceable(12) %50, i8 noundef zeroext 2)
  %52 = load float, ptr %51, align 4, !tbaa !5
  %53 = fneg float %52
  %.sink15 = select i1 %44, float %52, float %53
  %54 = fpext float %.sink15 to double
  %55 = tail call double @atan2(double noundef %49, double noundef %54) #4
  %storemerge = fptrunc double %55 to float
  store float %storemerge, ptr %4, align 4, !tbaa !9
  store float 0.000000e+00, ptr %0, align 4, !tbaa !12
  br label %56

56:                                               ; preds = %42, %17
  ret void
}

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef nonnull align 4 dereferenceable(12) ptr @_ZNK3rmg4Mat3ixEh(ptr noundef nonnull align 4 dereferenceable(36), i8 noundef zeroext) local_unnamed_addr #2 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZNK3rmg7Mat3RowixEh(ptr noundef nonnull align 4 dereferenceable(12), i8 noundef zeroext) local_unnamed_addr #2 align 2

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

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

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

attributes #0 = { 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 #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 = { inlinehint 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 #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"}
!9 = !{!10, !6, i64 8}
!10 = !{!"_ZTSN3rmg5EulerE", !6, i64 0, !6, i64 4, !6, i64 8}
!11 = !{!10, !6, i64 4}
!12 = !{!10, !6, i64 0}


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