; LLVM IR from duc0/ContestNeko :: tasks/CodeForces/R320/TaskC.ll (Z19binarySearchMaxRealdddRKSt8functionIFbdEERd)

; 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: mustprogress uwtable
define dso_local noundef zeroext i1 @_Z19binarySearchMaxRealdddRKSt8functionIFbdEERd(double noundef %0, double noundef %1, double noundef %2, ptr noundef nonnull align 8 dereferenceable(32) %3, ptr noundef nonnull align 8 dereferenceable(8) %4) #1 {
  %6 = alloca double, align 8
  %7 = alloca double, align 8
  %8 = alloca double, align 8
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca double, align 8
  %12 = alloca double, align 8
  %13 = alloca double, align 8
  %14 = alloca double, align 8
  store double %0, ptr %6, align 8, !tbaa !5
  store double %1, ptr %7, align 8, !tbaa !5
  store double %2, ptr %8, align 8, !tbaa !5
  store ptr %3, ptr %9, align 8, !tbaa !9
  store ptr %4, ptr %10, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #2
  %15 = load double, ptr %6, align 8, !tbaa !5
  store double %15, ptr %11, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #2
  %16 = load double, ptr %7, align 8, !tbaa !5
  store double %16, ptr %12, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #2
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #2
  %17 = load double, ptr %6, align 8, !tbaa !5
  %18 = fsub double %17, 1.000000e+00
  store double %18, ptr %14, align 8, !tbaa !5
  br label %19

19:                                               ; preds = %40, %5
  %20 = load double, ptr %12, align 8, !tbaa !5
  %21 = load double, ptr %11, align 8, !tbaa !5
  %22 = fsub double %20, %21
  %23 = load double, ptr %8, align 8, !tbaa !5
  %24 = fcmp ogt double %22, %23
  br i1 %24, label %25, label %41

25:                                               ; preds = %19
  %26 = load double, ptr %11, align 8, !tbaa !5
  %27 = load double, ptr %12, align 8, !tbaa !5
  %28 = load double, ptr %11, align 8, !tbaa !5
  %29 = fsub double %27, %28
  %30 = fdiv double %29, 2.000000e+00
  %31 = fadd double %26, %30
  store double %31, ptr %13, align 8, !tbaa !5
  %32 = load ptr, ptr %9, align 8, !tbaa !9
  %33 = load double, ptr %13, align 8, !tbaa !5
  %34 = call noundef zeroext i1 @_ZNKSt8functionIFbdEEclEd(ptr noundef nonnull align 8 dereferenceable(32) %32, double noundef %33)
  br i1 %34, label %35, label %38

35:                                               ; preds = %25
  %36 = load double, ptr %13, align 8, !tbaa !5
  store double %36, ptr %14, align 8, !tbaa !5
  %37 = load double, ptr %13, align 8, !tbaa !5
  store double %37, ptr %11, align 8, !tbaa !5
  br label %40

38:                                               ; preds = %25
  %39 = load double, ptr %13, align 8, !tbaa !5
  store double %39, ptr %12, align 8, !tbaa !5
  br label %40

40:                                               ; preds = %38, %35
  br label %19, !llvm.loop !11

41:                                               ; preds = %19
  %42 = load double, ptr %14, align 8, !tbaa !5
  %43 = load ptr, ptr %10, align 8, !tbaa !9
  store double %42, ptr %43, align 8, !tbaa !5
  %44 = load double, ptr %14, align 8, !tbaa !5
  %45 = load double, ptr %6, align 8, !tbaa !5
  %46 = fsub double %45, 1.000000e+00
  %47 = fcmp une double %44, %46
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #2
  ret i1 %47
}

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZNKSt8functionIFbdEEclEd(ptr noundef nonnull align 8 dereferenceable(32), double noundef) #1 align 2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}


; 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 noundef zeroext i1 @_Z19binarySearchMaxRealdddRKSt8functionIFbdEERd(double noundef %0, double noundef %1, double noundef %2, ptr noundef nonnull align 8 dereferenceable(32) %3, ptr nocapture noundef nonnull writeonly align 8 dereferenceable(8) %4) local_unnamed_addr #0 {
  %6 = fadd double %0, -1.000000e+00
  %7 = fsub double %1, %0
  %8 = fcmp ogt double %7, %2
  br i1 %8, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %5, %.lr.ph
  %9 = phi double [ %13, %.lr.ph ], [ %7, %5 ]
  %.025 = phi double [ %..0, %.lr.ph ], [ %6, %5 ]
  %.01824 = phi double [ %..018, %.lr.ph ], [ %0, %5 ]
  %.02023 = phi double [ %.020., %.lr.ph ], [ %1, %5 ]
  %10 = fmul double %9, 5.000000e-01
  %11 = fadd double %.01824, %10
  %12 = tail call noundef zeroext i1 @_ZNKSt8functionIFbdEEclEd(ptr noundef nonnull align 8 dereferenceable(32) %3, double noundef %11)
  %.020. = select i1 %12, double %.02023, double %11
  %..018 = select i1 %12, double %11, double %.01824
  %..0 = select i1 %12, double %11, double %.025
  %13 = fsub double %.020., %..018
  %14 = fcmp ogt double %13, %2
  br i1 %14, label %.lr.ph, label %._crit_edge, !llvm.loop !5

._crit_edge:                                      ; preds = %.lr.ph, %5
  %.0.lcssa = phi double [ %6, %5 ], [ %..0, %.lr.ph ]
  store double %.0.lcssa, ptr %4, align 8, !tbaa !7
  %15 = fcmp une double %.0.lcssa, %6
  ret i1 %15
}

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZNKSt8functionIFbdEEclEd(ptr noundef nonnull align 8 dereferenceable(32), double noundef) local_unnamed_addr #0 align 2

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

!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 = !{!8, !8, i64 0}
!8 = !{!"double", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C++ TBAA"}


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