; LLVM IR from radualexandrub/Optimization-Algorithms-Find-local-minimum :: 1D_DerivativeFree_Algorithms (interpolare_parab)

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

@logfile_interpolare_parab = external dso_local global ptr, align 8
@.str.9 = external hidden unnamed_addr constant [17 x i8], align 1

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

; Function Attrs: nounwind uwtable
define dso_local double @interpolare_parab(ptr noundef %0, double noundef %1, double noundef %2, double noundef %3) #1 {
  %5 = alloca ptr, align 8
  %6 = alloca double, align 8
  %7 = alloca double, align 8
  %8 = alloca double, align 8
  %9 = alloca double, align 8
  %10 = alloca double, align 8
  %11 = alloca double, align 8
  %12 = alloca float, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store double %1, ptr %6, align 8, !tbaa !9
  store double %2, ptr %7, align 8, !tbaa !9
  store double %3, ptr %8, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #4
  %13 = call double @sqrt(double noundef 5.000000e+00) #4
  %14 = fadd double 1.000000e+00, %13
  %15 = fdiv double %14, 2.000000e+00
  store double %15, ptr %9, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #4
  br label %16

16:                                               ; preds = %58, %4
  %17 = load double, ptr %6, align 8, !tbaa !9
  %18 = load double, ptr %7, align 8, !tbaa !9
  %19 = fsub double %17, %18
  %20 = call double @llvm.fabs.f64(double %19)
  %21 = fdiv double %20, 2.000000e+00
  %22 = load double, ptr %8, align 8, !tbaa !9
  %23 = fcmp ogt double %21, %22
  br i1 %23, label %24, label %69

24:                                               ; preds = %16
  %25 = load double, ptr %6, align 8, !tbaa !9
  %26 = load double, ptr %7, align 8, !tbaa !9
  %27 = load double, ptr %6, align 8, !tbaa !9
  %28 = fsub double %26, %27
  %29 = load double, ptr %9, align 8, !tbaa !9
  %30 = fdiv double %28, %29
  %31 = fadd double %25, %30
  store double %31, ptr %10, align 8, !tbaa !9
  %32 = load ptr, ptr %5, align 8, !tbaa !5
  %33 = load double, ptr %6, align 8, !tbaa !9
  %34 = load double, ptr %10, align 8, !tbaa !9
  %35 = load double, ptr %7, align 8, !tbaa !9
  %36 = call double @sectionare(ptr noundef %32, double noundef %33, double noundef %34, double noundef %35)
  store double %36, ptr %11, align 8, !tbaa !9
  %37 = load double, ptr %11, align 8, !tbaa !9
  %38 = load double, ptr %10, align 8, !tbaa !9
  %39 = fcmp ogt double %37, %38
  br i1 %39, label %40, label %46

40:                                               ; preds = %24
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #4
  %41 = load double, ptr %10, align 8, !tbaa !9
  %42 = fptrunc double %41 to float
  store float %42, ptr %12, align 4, !tbaa !11
  %43 = load double, ptr %11, align 8, !tbaa !9
  store double %43, ptr %10, align 8, !tbaa !9
  %44 = load float, ptr %12, align 4, !tbaa !11
  %45 = fpext float %44 to double
  store double %45, ptr %11, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #4
  br label %46

46:                                               ; preds = %40, %24
  %47 = load ptr, ptr %5, align 8, !tbaa !5
  %48 = load double, ptr %10, align 8, !tbaa !9
  %49 = call double %47(double noundef %48)
  %50 = load ptr, ptr %5, align 8, !tbaa !5
  %51 = load double, ptr %11, align 8, !tbaa !9
  %52 = call double %50(double noundef %51)
  %53 = fcmp olt double %49, %52
  br i1 %53, label %54, label %56

54:                                               ; preds = %46
  %55 = load double, ptr %11, align 8, !tbaa !9
  store double %55, ptr %6, align 8, !tbaa !9
  br label %58

56:                                               ; preds = %46
  %57 = load double, ptr %10, align 8, !tbaa !9
  store double %57, ptr %7, align 8, !tbaa !9
  br label %58

58:                                               ; preds = %56, %54
  %59 = load ptr, ptr @logfile_interpolare_parab, align 8, !tbaa !5
  %60 = load double, ptr %6, align 8, !tbaa !9
  %61 = load ptr, ptr %5, align 8, !tbaa !5
  %62 = load double, ptr %6, align 8, !tbaa !9
  %63 = call double %61(double noundef %62)
  %64 = load double, ptr %7, align 8, !tbaa !9
  %65 = load ptr, ptr %5, align 8, !tbaa !5
  %66 = load double, ptr %7, align 8, !tbaa !9
  %67 = call double %65(double noundef %66)
  %68 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %59, ptr noundef @.str.9, double noundef %60, double noundef %63, double noundef %64, double noundef %67) #4
  br label %16, !llvm.loop !13

69:                                               ; preds = %16
  %70 = load double, ptr %6, align 8, !tbaa !9
  %71 = load double, ptr %7, align 8, !tbaa !9
  %72 = fadd double %70, %71
  %73 = fdiv double %72, 2.000000e+00
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #4
  ret double %73
}

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

; Function Attrs: nounwind
declare i32 @fprintf(ptr noundef, ptr noundef, ...) #2

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

; Function Attrs: nounwind
declare double @sqrt(double noundef) #2

; Function Attrs: nounwind uwtable
declare dso_local double @sectionare(ptr noundef, double noundef, double noundef, double noundef) #1

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { 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 #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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"double", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"float", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"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"

@logfile_interpolare_parab = external dso_local local_unnamed_addr global ptr, align 8
@.str.9 = external hidden unnamed_addr constant [17 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local double @interpolare_parab(ptr noundef %0, double noundef %1, double noundef %2, double noundef %3) local_unnamed_addr #0 {
  %5 = fsub double %1, %2
  %6 = tail call double @llvm.fabs.f64(double %5)
  %7 = fmul double %6, 5.000000e-01
  %8 = fcmp ogt double %7, %3
  br i1 %8, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %4, %.lr.ph
  %.039 = phi double [ %.1, %.lr.ph ], [ %1, %4 ]
  %.03238 = phi double [ %.133, %.lr.ph ], [ %2, %4 ]
  %9 = fsub double %.03238, %.039
  %10 = fdiv double %9, 0x3FF9E3779B97F4A8
  %11 = fadd double %.039, %10
  %12 = tail call double @sectionare(ptr noundef %0, double noundef %.039, double noundef %11, double noundef %.03238)
  %13 = fcmp ogt double %12, %11
  %14 = fptrunc double %11 to float
  %15 = fpext float %14 to double
  %.031 = select i1 %13, double %12, double %11
  %.030 = select i1 %13, double %15, double %12
  %16 = tail call double %0(double noundef %.031) #3
  %17 = tail call double %0(double noundef %.030) #3
  %18 = fcmp olt double %16, %17
  %.133 = select i1 %18, double %.03238, double %.031
  %.1 = select i1 %18, double %.030, double %.039
  %19 = load ptr, ptr @logfile_interpolare_parab, align 8, !tbaa !5
  %20 = tail call double %0(double noundef %.1) #3
  %21 = tail call double %0(double noundef %.133) #3
  %22 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %19, ptr noundef nonnull @.str.9, double noundef %.1, double noundef %20, double noundef %.133, double noundef %21) #3
  %23 = fsub double %.1, %.133
  %24 = tail call double @llvm.fabs.f64(double %23)
  %25 = fmul double %24, 5.000000e-01
  %26 = fcmp ogt double %25, %3
  br i1 %26, label %.lr.ph, label %._crit_edge, !llvm.loop !9

._crit_edge:                                      ; preds = %.lr.ph, %4
  %.032.lcssa = phi double [ %2, %4 ], [ %.133, %.lr.ph ]
  %.0.lcssa = phi double [ %1, %4 ], [ %.1, %.lr.ph ]
  %27 = fadd double %.032.lcssa, %.0.lcssa
  %28 = fmul double %27, 5.000000e-01
  ret double %28
}

; Function Attrs: nofree nounwind
declare noundef i32 @fprintf(ptr nocapture noundef, ptr nocapture noundef readonly, ...) local_unnamed_addr #1

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

; Function Attrs: nounwind uwtable
declare dso_local double @sectionare(ptr noundef, double noundef, double noundef, double noundef) local_unnamed_addr #0

attributes #0 = { 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 = { nofree 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 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #3 = { 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/C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}


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