; LLVM IR from ahampriyanshu/algo-ds-101 :: Algorithms/Searching/Binary-Search/Binary_Search_CubicRoot.ll (Z9binsearchdd)

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

; Function Attrs: mustprogress uwtable
define dso_local noundef double @_Z9binsearchdd(double noundef %0, double noundef %1) #1 {
  %3 = alloca double, align 8
  %4 = alloca double, align 8
  %5 = alloca double, align 8
  %6 = alloca double, align 8
  %7 = alloca i32, align 4
  store double %0, ptr %4, align 8, !tbaa !5
  store double %1, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #4
  %8 = load double, ptr %4, align 8, !tbaa !5
  %9 = load double, ptr %5, align 8, !tbaa !5
  %10 = fadd double %8, %9
  %11 = fdiv double %10, 2.000000e+00
  store double %11, ptr %6, align 8, !tbaa !5
  %12 = load double, ptr %6, align 8, !tbaa !5
  %13 = call noundef double @_Z1fd(double noundef %12)
  %14 = call double @llvm.fabs.f64(double %13)
  %15 = fcmp olt double %14, 1.000000e-08
  br i1 %15, label %16, label %18

16:                                               ; preds = %2
  %17 = load double, ptr %6, align 8, !tbaa !5
  store double %17, ptr %3, align 8
  store i32 1, ptr %7, align 4
  br label %30

18:                                               ; preds = %2
  %19 = load double, ptr %6, align 8, !tbaa !5
  %20 = call noundef double @_Z1fd(double noundef %19)
  %21 = fcmp ogt double %20, 1.000000e-08
  br i1 %21, label %22, label %26

22:                                               ; preds = %18
  %23 = load double, ptr %4, align 8, !tbaa !5
  %24 = load double, ptr %6, align 8, !tbaa !5
  %25 = call noundef double @_Z9binsearchdd(double noundef %23, double noundef %24)
  store double %25, ptr %3, align 8
  store i32 1, ptr %7, align 4
  br label %30

26:                                               ; preds = %18
  %27 = load double, ptr %6, align 8, !tbaa !5
  %28 = load double, ptr %5, align 8, !tbaa !5
  %29 = call noundef double @_Z9binsearchdd(double noundef %27, double noundef %28)
  store double %29, ptr %3, align 8
  store i32 1, ptr %7, align 4
  br label %30

30:                                               ; preds = %26, %22, %16
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #4
  %31 = load double, ptr %3, align 8
  ret double %31
}

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

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

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

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 = { 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 #2 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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++ TBAA"}


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

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef double @_Z9binsearchdd(double noundef %0, double noundef %1) local_unnamed_addr #0 {
  %3 = fadd double %0, %1
  %4 = fmul double %3, 5.000000e-01
  %5 = tail call noundef double @_Z1fd(double noundef %4)
  %6 = tail call double @llvm.fabs.f64(double %5)
  %7 = fcmp olt double %6, 1.000000e-08
  br i1 %7, label %tailrecurse._crit_edge, label %tailrecurse

tailrecurse:                                      ; preds = %2, %tailrecurse
  %8 = phi double [ %12, %tailrecurse ], [ %4, %2 ]
  %.tr1012 = phi double [ %..tr10, %tailrecurse ], [ %1, %2 ]
  %.tr11 = phi double [ %.tr., %tailrecurse ], [ %0, %2 ]
  %9 = tail call noundef double @_Z1fd(double noundef %8)
  %10 = fcmp ogt double %9, 1.000000e-08
  %.tr. = select i1 %10, double %.tr11, double %8
  %..tr10 = select i1 %10, double %8, double %.tr1012
  %11 = fadd double %.tr., %..tr10
  %12 = fmul double %11, 5.000000e-01
  %13 = tail call noundef double @_Z1fd(double noundef %12)
  %14 = tail call double @llvm.fabs.f64(double %13)
  %15 = fcmp olt double %14, 1.000000e-08
  br i1 %15, label %tailrecurse._crit_edge, label %tailrecurse

tailrecurse._crit_edge:                           ; preds = %tailrecurse, %2
  %.lcssa = phi double [ %4, %2 ], [ %12, %tailrecurse ]
  ret double %.lcssa
}

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fabs.f64(double) #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 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }

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


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