; LLVM IR from Forrest-Z/cpp_robotics :: slam/ukf_slam/src/tools.ll (ZN5Tools15normalize_angleEf)

; 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: mustprogress nounwind uwtable
define dso_local noundef float @_ZN5Tools15normalize_angleEf(ptr noundef nonnull align 8 dereferenceable(8) %0, float noundef %1) #0 align 2 {
  %3 = alloca ptr, align 8
  %4 = alloca float, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store float %1, ptr %4, align 4, !tbaa !9
  %5 = load ptr, ptr %3, align 8
  br label %6

6:                                                ; preds = %10, %2
  %7 = load float, ptr %4, align 4, !tbaa !9
  %8 = fpext float %7 to double
  %9 = fcmp ogt double %8, 0x400921FB54442D18
  br i1 %9, label %10, label %15

10:                                               ; preds = %6
  %11 = load float, ptr %4, align 4, !tbaa !9
  %12 = fpext float %11 to double
  %13 = fsub double %12, 0x401921FB54442D18
  %14 = fptrunc double %13 to float
  store float %14, ptr %4, align 4, !tbaa !9
  br label %6, !llvm.loop !11

15:                                               ; preds = %6
  br label %16

16:                                               ; preds = %20, %15
  %17 = load float, ptr %4, align 4, !tbaa !9
  %18 = fpext float %17 to double
  %19 = fcmp olt double %18, 0xC00921FB54442D18
  br i1 %19, label %20, label %25

20:                                               ; preds = %16
  %21 = load float, ptr %4, align 4, !tbaa !9
  %22 = fpext float %21 to double
  %23 = fadd double %22, 0x401921FB54442D18
  %24 = fptrunc double %23 to float
  store float %24, ptr %4, align 4, !tbaa !9
  br label %16, !llvm.loop !13

25:                                               ; preds = %16
  %26 = load float, ptr %4, align 4, !tbaa !9
  ret float %26
}

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

!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 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}


; 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 nofree norecurse nosync nounwind willreturn memory(none) uwtable
define dso_local noundef float @_ZN5Tools15normalize_angleEf(ptr nocapture noundef nonnull readnone align 8 dereferenceable(8) %0, float noundef %1) local_unnamed_addr #0 align 2 {
  %3 = fpext float %1 to double
  %4 = fcmp ogt double %3, 0x400921FB54442D18
  br i1 %4, label %.lr.ph, label %.preheader

.preheader:                                       ; preds = %.lr.ph, %2
  %.pre-phi = phi double [ %3, %2 ], [ %9, %.lr.ph ]
  %.0.lcssa = phi float [ %1, %2 ], [ %8, %.lr.ph ]
  %5 = fcmp olt double %.pre-phi, 0xC00921FB54442D18
  br i1 %5, label %.lr.ph8, label %._crit_edge

.lr.ph:                                           ; preds = %2, %.lr.ph
  %6 = phi double [ %9, %.lr.ph ], [ %3, %2 ]
  %7 = fadd double %6, 0xC01921FB54442D18
  %8 = fptrunc double %7 to float
  %9 = fpext float %8 to double
  %10 = fcmp ogt double %9, 0x400921FB54442D18
  br i1 %10, label %.lr.ph, label %.preheader, !llvm.loop !5

.lr.ph8:                                          ; preds = %.preheader, %.lr.ph8
  %11 = phi double [ %14, %.lr.ph8 ], [ %.pre-phi, %.preheader ]
  %12 = fadd double %11, 0x401921FB54442D18
  %13 = fptrunc double %12 to float
  %14 = fpext float %13 to double
  %15 = fcmp olt double %14, 0xC00921FB54442D18
  br i1 %15, label %.lr.ph8, label %._crit_edge, !llvm.loop !7

._crit_edge:                                      ; preds = %.lr.ph8, %.preheader
  %.1.lcssa = phi float [ %.0.lcssa, %.preheader ], [ %13, %.lr.ph8 ]
  ret float %.1.lcssa
}

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(none) 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 = distinct !{!5, !6}
!6 = !{!"llvm.loop.mustprogress"}
!7 = distinct !{!7, !6}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass