; LLVM IR from MinhasKamal/AlgorithmImplementations :: numericalMethods/equationSolving (NonLinearEquationSolvingProcess)

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

@.str.5 = external hidden unnamed_addr constant [19 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

declare i32 @printf(ptr noundef, ...) #1

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

; Function Attrs: nounwind uwtable
define dso_local double @BisectionMethod() #2 {
  %1 = alloca double, align 8
  %2 = alloca double, align 8
  %3 = alloca double, align 8
  %4 = alloca double, align 8
  %5 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 8, ptr %1) #4
  store double 0.000000e+00, ptr %1, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %2) #4
  store double 1.000000e+00, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #4
  store double 2.000000e+00, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #4
  store double 0.000000e+00, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #4
  store i32 0, ptr %5, align 4, !tbaa !9
  %6 = load double, ptr %2, align 8, !tbaa !5
  %7 = load double, ptr %2, align 8, !tbaa !5
  %8 = fmul double %6, %7
  %9 = load double, ptr %2, align 8, !tbaa !5
  %10 = load double, ptr %2, align 8, !tbaa !5
  %11 = fneg double %10
  %12 = call double @llvm.fmuladd.f64(double %8, double %9, double %11)
  %13 = fsub double %12, 2.000000e+00
  %14 = load double, ptr %3, align 8, !tbaa !5
  %15 = load double, ptr %3, align 8, !tbaa !5
  %16 = fmul double %14, %15
  %17 = load double, ptr %3, align 8, !tbaa !5
  %18 = load double, ptr %3, align 8, !tbaa !5
  %19 = fneg double %18
  %20 = call double @llvm.fmuladd.f64(double %16, double %17, double %19)
  %21 = fsub double %20, 2.000000e+00
  %22 = fmul double %13, %21
  %23 = fcmp olt double %22, 0.000000e+00
  br i1 %23, label %24, label %79

24:                                               ; preds = %0
  br label %25

25:                                               ; preds = %77, %24
  br label %26

26:                                               ; preds = %25
  %27 = load i32, ptr %5, align 4, !tbaa !9
  %28 = add nsw i32 %27, 1
  store i32 %28, ptr %5, align 4, !tbaa !9
  %29 = load double, ptr %2, align 8, !tbaa !5
  %30 = load double, ptr %3, align 8, !tbaa !5
  %31 = fadd double %29, %30
  %32 = fdiv double %31, 2.000000e+00
  store double %32, ptr %4, align 8, !tbaa !5
  %33 = load double, ptr %4, align 8, !tbaa !5
  %34 = load double, ptr %4, align 8, !tbaa !5
  %35 = fmul double %33, %34
  %36 = load double, ptr %4, align 8, !tbaa !5
  %37 = load double, ptr %4, align 8, !tbaa !5
  %38 = fneg double %37
  %39 = call double @llvm.fmuladd.f64(double %35, double %36, double %38)
  %40 = fsub double %39, 2.000000e+00
  %41 = fcmp olt double %40, 1.000000e-05
  br i1 %41, label %42, label %54

42:                                               ; preds = %26
  %43 = load double, ptr %4, align 8, !tbaa !5
  %44 = load double, ptr %4, align 8, !tbaa !5
  %45 = fmul double %43, %44
  %46 = load double, ptr %4, align 8, !tbaa !5
  %47 = load double, ptr %4, align 8, !tbaa !5
  %48 = fneg double %47
  %49 = call double @llvm.fmuladd.f64(double %45, double %46, double %48)
  %50 = fsub double %49, 2.000000e+00
  %51 = fcmp ogt double %50, -1.000000e-05
  br i1 %51, label %52, label %54

52:                                               ; preds = %42
  %53 = load double, ptr %4, align 8, !tbaa !5
  store double %53, ptr %1, align 8, !tbaa !5
  br label %78

54:                                               ; preds = %42, %26
  %55 = load double, ptr %2, align 8, !tbaa !5
  %56 = load double, ptr %2, align 8, !tbaa !5
  %57 = fmul double %55, %56
  %58 = load double, ptr %2, align 8, !tbaa !5
  %59 = load double, ptr %2, align 8, !tbaa !5
  %60 = fneg double %59
  %61 = call double @llvm.fmuladd.f64(double %57, double %58, double %60)
  %62 = fsub double %61, 2.000000e+00
  %63 = load double, ptr %4, align 8, !tbaa !5
  %64 = load double, ptr %4, align 8, !tbaa !5
  %65 = fmul double %63, %64
  %66 = load double, ptr %4, align 8, !tbaa !5
  %67 = load double, ptr %4, align 8, !tbaa !5
  %68 = fneg double %67
  %69 = call double @llvm.fmuladd.f64(double %65, double %66, double %68)
  %70 = fsub double %69, 2.000000e+00
  %71 = fmul double %62, %70
  %72 = fcmp olt double %71, 0.000000e+00
  br i1 %72, label %73, label %75

73:                                               ; preds = %54
  %74 = load double, ptr %4, align 8, !tbaa !5
  store double %74, ptr %3, align 8, !tbaa !5
  br label %77

75:                                               ; preds = %54
  %76 = load double, ptr %4, align 8, !tbaa !5
  store double %76, ptr %2, align 8, !tbaa !5
  br label %77

77:                                               ; preds = %75, %73
  br label %25

78:                                               ; preds = %52
  br label %79

79:                                               ; preds = %78, %0
  %80 = load i32, ptr %5, align 4, !tbaa !9
  %81 = call i32 (ptr, ...) @printf(ptr noundef @.str.5, i32 noundef %80)
  %82 = load double, ptr %1, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %2) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %1) #4
  ret double %82
}

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { "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 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 #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/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}


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

@.str.5 = external hidden unnamed_addr constant [19 x i8], align 1

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

; Function Attrs: nofree nounwind uwtable
define dso_local double @BisectionMethod() local_unnamed_addr #1 {
  br label %1

1:                                                ; preds = %0, %1
  %2 = phi double [ -1.250000e-01, %0 ], [ %17, %1 ]
  %3 = phi double [ 1.500000e+00, %0 ], [ %13, %1 ]
  %4 = phi i32 [ 1, %0 ], [ %11, %1 ]
  %.03139 = phi double [ 2.000000e+00, %0 ], [ %..031, %1 ]
  %.03338 = phi double [ 1.000000e+00, %0 ], [ %.033., %1 ]
  %5 = fmul double %.03338, %.03338
  %6 = fneg double %.03338
  %7 = tail call double @llvm.fmuladd.f64(double %5, double %.03338, double %6)
  %8 = fadd double %7, -2.000000e+00
  %9 = fmul double %8, %2
  %10 = fcmp olt double %9, 0.000000e+00
  %.033. = select i1 %10, double %.03338, double %3
  %..031 = select i1 %10, double %3, double %.03139
  %11 = add nuw nsw i32 %4, 1
  %12 = fadd double %.033., %..031
  %13 = fmul double %12, 5.000000e-01
  %14 = fmul double %13, %13
  %15 = fneg double %13
  %16 = tail call double @llvm.fmuladd.f64(double %14, double %13, double %15)
  %17 = fadd double %16, -2.000000e+00
  %18 = tail call double @llvm.fabs.f64(double %17)
  %or.cond = fcmp olt double %18, 1.000000e-05
  br i1 %or.cond, label %19, label %1

19:                                               ; preds = %1
  %20 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.5, i32 noundef %11)
  ret double %13
}

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

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

attributes #0 = { 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 #1 = { nofree 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 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #3 = { 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: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,LCSSAPass,LoopRotatePass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass