; 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: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #2

; Function Attrs: nounwind uwtable
define dso_local double @FalsePosition() #3 {
  %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 %114

24:                                               ; preds = %0
  br label %25

25:                                               ; preds = %112, %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 = load double, ptr %3, align 8, !tbaa !5
  %32 = fmul double %30, %31
  %33 = load double, ptr %3, align 8, !tbaa !5
  %34 = load double, ptr %3, align 8, !tbaa !5
  %35 = fneg double %34
  %36 = call double @llvm.fmuladd.f64(double %32, double %33, double %35)
  %37 = fsub double %36, 2.000000e+00
  %38 = load double, ptr %3, align 8, !tbaa !5
  %39 = load double, ptr %2, align 8, !tbaa !5
  %40 = load double, ptr %2, align 8, !tbaa !5
  %41 = fmul double %39, %40
  %42 = load double, ptr %2, align 8, !tbaa !5
  %43 = load double, ptr %2, align 8, !tbaa !5
  %44 = fneg double %43
  %45 = call double @llvm.fmuladd.f64(double %41, double %42, double %44)
  %46 = fsub double %45, 2.000000e+00
  %47 = fmul double %38, %46
  %48 = fneg double %47
  %49 = call double @llvm.fmuladd.f64(double %29, double %37, double %48)
  %50 = load double, ptr %3, align 8, !tbaa !5
  %51 = load double, ptr %3, align 8, !tbaa !5
  %52 = fmul double %50, %51
  %53 = load double, ptr %3, align 8, !tbaa !5
  %54 = load double, ptr %3, align 8, !tbaa !5
  %55 = fneg double %54
  %56 = call double @llvm.fmuladd.f64(double %52, double %53, double %55)
  %57 = fsub double %56, 2.000000e+00
  %58 = load double, ptr %2, align 8, !tbaa !5
  %59 = load double, ptr %2, align 8, !tbaa !5
  %60 = fmul double %58, %59
  %61 = load double, ptr %2, align 8, !tbaa !5
  %62 = load double, ptr %2, align 8, !tbaa !5
  %63 = fneg double %62
  %64 = call double @llvm.fmuladd.f64(double %60, double %61, double %63)
  %65 = fsub double %64, 2.000000e+00
  %66 = fsub double %57, %65
  %67 = fdiv double %49, %66
  store double %67, ptr %4, align 8, !tbaa !5
  %68 = load double, ptr %4, align 8, !tbaa !5
  %69 = load double, ptr %4, align 8, !tbaa !5
  %70 = fmul double %68, %69
  %71 = load double, ptr %4, align 8, !tbaa !5
  %72 = load double, ptr %4, align 8, !tbaa !5
  %73 = fneg double %72
  %74 = call double @llvm.fmuladd.f64(double %70, double %71, double %73)
  %75 = fsub double %74, 2.000000e+00
  %76 = fcmp olt double %75, 1.000000e-05
  br i1 %76, label %77, label %89

77:                                               ; preds = %26
  %78 = load double, ptr %4, align 8, !tbaa !5
  %79 = load double, ptr %4, align 8, !tbaa !5
  %80 = fmul double %78, %79
  %81 = load double, ptr %4, align 8, !tbaa !5
  %82 = load double, ptr %4, align 8, !tbaa !5
  %83 = fneg double %82
  %84 = call double @llvm.fmuladd.f64(double %80, double %81, double %83)
  %85 = fsub double %84, 2.000000e+00
  %86 = fcmp ogt double %85, -1.000000e-05
  br i1 %86, label %87, label %89

87:                                               ; preds = %77
  %88 = load double, ptr %4, align 8, !tbaa !5
  store double %88, ptr %1, align 8, !tbaa !5
  br label %113

89:                                               ; preds = %77, %26
  %90 = load double, ptr %2, align 8, !tbaa !5
  %91 = load double, ptr %2, align 8, !tbaa !5
  %92 = fmul double %90, %91
  %93 = load double, ptr %2, align 8, !tbaa !5
  %94 = load double, ptr %2, align 8, !tbaa !5
  %95 = fneg double %94
  %96 = call double @llvm.fmuladd.f64(double %92, double %93, double %95)
  %97 = fsub double %96, 2.000000e+00
  %98 = load double, ptr %4, align 8, !tbaa !5
  %99 = load double, ptr %4, align 8, !tbaa !5
  %100 = fmul double %98, %99
  %101 = load double, ptr %4, align 8, !tbaa !5
  %102 = load double, ptr %4, align 8, !tbaa !5
  %103 = fneg double %102
  %104 = call double @llvm.fmuladd.f64(double %100, double %101, double %103)
  %105 = fsub double %104, 2.000000e+00
  %106 = fmul double %97, %105
  %107 = fcmp olt double %106, 0.000000e+00
  br i1 %107, label %108, label %110

108:                                              ; preds = %89
  %109 = load double, ptr %4, align 8, !tbaa !5
  store double %109, ptr %3, align 8, !tbaa !5
  br label %112

110:                                              ; preds = %89
  %111 = load double, ptr %4, align 8, !tbaa !5
  store double %111, ptr %2, align 8, !tbaa !5
  br label %112

112:                                              ; preds = %110, %108
  br label %25

113:                                              ; preds = %87
  br label %114

114:                                              ; preds = %113, %0
  %115 = load i32, ptr %5, align 4, !tbaa !9
  %116 = call i32 (ptr, ...) @printf(ptr noundef @.str.5, i32 noundef %115)
  %117 = 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 %117
}

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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #3 = { 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 #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: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #1

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

1:                                                ; preds = %0, %21
  %.0 = phi i32 [ 0, %0 ], [ %3, %21 ]
  %2 = phi <2 x double> [ <double 2.000000e+00, double 1.000000e+00>, %0 ], [ %28, %21 ]
  %3 = add nuw nsw i32 %.0, 1
  %4 = fmul <2 x double> %2, %2
  %5 = fneg <2 x double> %2
  %6 = tail call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %4, <2 x double> %2, <2 x double> %5)
  %7 = fadd <2 x double> %6, <double -2.000000e+00, double -2.000000e+00>
  %8 = extractelement <2 x double> %7, i64 1
  %9 = extractelement <2 x double> %5, i64 0
  %10 = fmul double %8, %9
  %11 = extractelement <2 x double> %7, i64 0
  %12 = extractelement <2 x double> %2, i64 1
  %13 = tail call double @llvm.fmuladd.f64(double %12, double %11, double %10)
  %14 = fsub double %11, %8
  %15 = fdiv double %13, %14
  %16 = fmul double %15, %15
  %17 = fneg double %15
  %18 = tail call double @llvm.fmuladd.f64(double %16, double %15, double %17)
  %19 = fadd double %18, -2.000000e+00
  %20 = tail call double @llvm.fabs.f64(double %19)
  %or.cond = fcmp olt double %20, 1.000000e-05
  br i1 %or.cond, label %29, label %21

21:                                               ; preds = %1
  %22 = fmul double %8, %19
  %23 = fcmp olt double %22, 0.000000e+00
  %24 = insertelement <2 x i1> poison, i1 %23, i64 0
  %25 = shufflevector <2 x i1> %24, <2 x i1> poison, <2 x i32> zeroinitializer
  %26 = insertelement <2 x double> %2, double %15, i64 0
  %27 = insertelement <2 x double> %2, double %15, i64 1
  %28 = select <2 x i1> %25, <2 x double> %26, <2 x double> %27
  br label %1

29:                                               ; preds = %1
  %30 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.5, i32 noundef %3)
  ret double %15
}

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

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare <2 x double> @llvm.fmuladd.v2f64(<2 x double>, <2 x double>, <2 x 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 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #2 = { 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 #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,LoopUnrollPass,PostOrderFunctionAttrsPass,ReassociatePass,SLPVectorizerPass,SROAPass,SimplifyCFGPass,TailCallElimPass