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

; 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 @_ZN3rmg5EulerC2EfffNS_9AngleUnitE(ptr noundef nonnull align 4 dereferenceable(12) %0, float noundef %1, float noundef %2, float noundef %3, i32 noundef %4) unnamed_addr #0 align 2 {
  %6 = alloca ptr, align 8
  %7 = alloca float, align 4
  %8 = alloca float, align 4
  %9 = alloca float, align 4
  %10 = alloca i32, align 4
  store ptr %0, ptr %6, align 8, !tbaa !5
  store float %1, ptr %7, align 4, !tbaa !9
  store float %2, ptr %8, align 4, !tbaa !9
  store float %3, ptr %9, align 4, !tbaa !9
  store i32 %4, ptr %10, align 4, !tbaa !11
  %11 = load ptr, ptr %6, align 8
  %12 = getelementptr inbounds %"struct.rmg::Euler", ptr %11, i32 0, i32 0
  store float 0.000000e+00, ptr %12, align 4, !tbaa !13
  %13 = getelementptr inbounds %"struct.rmg::Euler", ptr %11, i32 0, i32 1
  store float 0.000000e+00, ptr %13, align 4, !tbaa !15
  %14 = getelementptr inbounds %"struct.rmg::Euler", ptr %11, i32 0, i32 2
  store float 0.000000e+00, ptr %14, align 4, !tbaa !16
  %15 = load i32, ptr %10, align 4, !tbaa !11
  %16 = icmp eq i32 %15, 1
  br i1 %16, label %17, label %24

17:                                               ; preds = %5
  %18 = load float, ptr %7, align 4, !tbaa !9
  %19 = getelementptr inbounds %"struct.rmg::Euler", ptr %11, i32 0, i32 0
  store float %18, ptr %19, align 4, !tbaa !13
  %20 = load float, ptr %8, align 4, !tbaa !9
  %21 = getelementptr inbounds %"struct.rmg::Euler", ptr %11, i32 0, i32 1
  store float %20, ptr %21, align 4, !tbaa !15
  %22 = load float, ptr %9, align 4, !tbaa !9
  %23 = getelementptr inbounds %"struct.rmg::Euler", ptr %11, i32 0, i32 2
  store float %22, ptr %23, align 4, !tbaa !16
  br label %34

24:                                               ; preds = %5
  %25 = load float, ptr %7, align 4, !tbaa !9
  %26 = call noundef float @_ZN3rmg6radianEf(float noundef %25)
  %27 = getelementptr inbounds %"struct.rmg::Euler", ptr %11, i32 0, i32 0
  store float %26, ptr %27, align 4, !tbaa !13
  %28 = load float, ptr %8, align 4, !tbaa !9
  %29 = call noundef float @_ZN3rmg6radianEf(float noundef %28)
  %30 = getelementptr inbounds %"struct.rmg::Euler", ptr %11, i32 0, i32 1
  store float %29, ptr %30, align 4, !tbaa !15
  %31 = load float, ptr %9, align 4, !tbaa !9
  %32 = call noundef float @_ZN3rmg6radianEf(float noundef %31)
  %33 = getelementptr inbounds %"struct.rmg::Euler", ptr %11, i32 0, i32 2
  store float %32, ptr %33, align 4, !tbaa !16
  br label %34

34:                                               ; preds = %24, %17
  ret void
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef float @_ZN3rmg6radianEf(float noundef) #1

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 = { inlinehint mustprogress 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" }

!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}
!11 = !{!12, !12, i64 0}
!12 = !{!"_ZTSN3rmg9AngleUnitE", !7, i64 0}
!13 = !{!14, !10, i64 0}
!14 = !{!"_ZTSN3rmg5EulerE", !10, i64 0, !10, i64 4, !10, i64 8}
!15 = !{!14, !10, i64 4}
!16 = !{!14, !10, i64 8}


; 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 nounwind uwtable
define dso_local void @_ZN3rmg5EulerC2EfffNS_9AngleUnitE(ptr nocapture noundef nonnull writeonly align 4 dereferenceable(12) %0, float noundef %1, float noundef %2, float noundef %3, i32 noundef %4) unnamed_addr #0 align 2 {
  %6 = getelementptr inbounds i8, ptr %0, i64 4
  store <2 x float> zeroinitializer, ptr %0, align 4, !tbaa !5
  %7 = getelementptr inbounds i8, ptr %0, i64 8
  store float 0.000000e+00, ptr %7, align 4, !tbaa !9
  %8 = icmp eq i32 %4, 1
  br i1 %8, label %9, label %10

9:                                                ; preds = %5
  store float %1, ptr %0, align 4, !tbaa !11
  store float %2, ptr %6, align 4, !tbaa !12
  br label %14

10:                                               ; preds = %5
  %11 = tail call noundef float @_ZN3rmg6radianEf(float noundef %1)
  store float %11, ptr %0, align 4, !tbaa !11
  %12 = tail call noundef float @_ZN3rmg6radianEf(float noundef %2)
  store float %12, ptr %6, align 4, !tbaa !12
  %13 = tail call noundef float @_ZN3rmg6radianEf(float noundef %3)
  br label %14

14:                                               ; preds = %10, %9
  %storemerge = phi float [ %13, %10 ], [ %3, %9 ]
  store float %storemerge, ptr %7, align 4, !tbaa !9
  ret void
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef float @_ZN3rmg6radianEf(float noundef) local_unnamed_addr #1

attributes #0 = { mustprogress 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 #1 = { inlinehint mustprogress 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" }

!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 0}
!12 = !{!10, !6, i64 4}


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