; LLVM IR from 0r-gh0/NUMERICAL_ANALYSIS :: CODES (rf)

; 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 = external hidden unnamed_addr constant [60 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [47 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [49 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [53 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local double @function(double noundef) #0

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

; Function Attrs: nounwind uwtable
define dso_local double @regulaFalsi(double noundef %0, double noundef %1, double noundef %2, i32 noundef %3, i32 noundef %4, ptr noundef %5) #0 {
  %7 = alloca double, align 8
  %8 = alloca double, align 8
  %9 = alloca double, align 8
  %10 = alloca double, align 8
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca ptr, align 8
  %14 = alloca double, align 8
  %15 = alloca i32, align 4
  store double %0, ptr %8, align 8, !tbaa !5
  store double %1, ptr %9, align 8, !tbaa !5
  store double %2, ptr %10, align 8, !tbaa !5
  store i32 %3, ptr %11, align 4, !tbaa !9
  store i32 %4, ptr %12, align 4, !tbaa !9
  store ptr %5, ptr %13, align 8, !tbaa !11
  %16 = load i32, ptr %11, align 4, !tbaa !9
  %17 = add nsw i32 %16, 1
  store i32 %17, ptr %11, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #5
  %18 = load double, ptr %8, align 8, !tbaa !5
  %19 = load double, ptr %9, align 8, !tbaa !5
  %20 = call double @function(double noundef %19)
  %21 = load double, ptr %9, align 8, !tbaa !5
  %22 = load double, ptr %8, align 8, !tbaa !5
  %23 = call double @function(double noundef %22)
  %24 = fmul double %21, %23
  %25 = fneg double %24
  %26 = call double @llvm.fmuladd.f64(double %18, double %20, double %25)
  %27 = load double, ptr %9, align 8, !tbaa !5
  %28 = call double @function(double noundef %27)
  %29 = load double, ptr %8, align 8, !tbaa !5
  %30 = call double @function(double noundef %29)
  %31 = fsub double %28, %30
  %32 = fdiv double %26, %31
  store double %32, ptr %14, align 8, !tbaa !5
  %33 = load ptr, ptr %13, align 8, !tbaa !11
  %34 = load i32, ptr %11, align 4, !tbaa !9
  %35 = load double, ptr %8, align 8, !tbaa !5
  %36 = load double, ptr %9, align 8, !tbaa !5
  %37 = load double, ptr %14, align 8, !tbaa !5
  %38 = load double, ptr %14, align 8, !tbaa !5
  %39 = call double @function(double noundef %38)
  %40 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %33, ptr noundef @.str, i32 noundef %34, double noundef %35, double noundef %36, double noundef %37, double noundef %39) #5
  %41 = load double, ptr %14, align 8, !tbaa !5
  %42 = call double @function(double noundef %41)
  %43 = call double @llvm.fabs.f64(double %42)
  %44 = load double, ptr %10, align 8, !tbaa !5
  %45 = fcmp oge double %43, %44
  br i1 %45, label %46, label %74

46:                                               ; preds = %6
  %47 = load i32, ptr %11, align 4, !tbaa !9
  %48 = load i32, ptr %12, align 4, !tbaa !9
  %49 = icmp slt i32 %47, %48
  br i1 %49, label %50, label %74

50:                                               ; preds = %46
  %51 = load double, ptr %8, align 8, !tbaa !5
  %52 = call double @function(double noundef %51)
  %53 = load double, ptr %14, align 8, !tbaa !5
  %54 = call double @function(double noundef %53)
  %55 = fmul double %52, %54
  %56 = fcmp olt double %55, 0.000000e+00
  br i1 %56, label %57, label %65

57:                                               ; preds = %50
  %58 = load double, ptr %8, align 8, !tbaa !5
  %59 = load double, ptr %14, align 8, !tbaa !5
  %60 = load double, ptr %10, align 8, !tbaa !5
  %61 = load i32, ptr %11, align 4, !tbaa !9
  %62 = load i32, ptr %12, align 4, !tbaa !9
  %63 = load ptr, ptr %13, align 8, !tbaa !11
  %64 = call double @regulaFalsi(double noundef %58, double noundef %59, double noundef %60, i32 noundef %61, i32 noundef %62, ptr noundef %63)
  br label %73

65:                                               ; preds = %50
  %66 = load double, ptr %14, align 8, !tbaa !5
  %67 = load double, ptr %9, align 8, !tbaa !5
  %68 = load double, ptr %10, align 8, !tbaa !5
  %69 = load i32, ptr %11, align 4, !tbaa !9
  %70 = load i32, ptr %12, align 4, !tbaa !9
  %71 = load ptr, ptr %13, align 8, !tbaa !11
  %72 = call double @regulaFalsi(double noundef %66, double noundef %67, double noundef %68, i32 noundef %69, i32 noundef %70, ptr noundef %71)
  br label %73

73:                                               ; preds = %65, %57
  br label %85

74:                                               ; preds = %46, %6
  %75 = load ptr, ptr %13, align 8, !tbaa !11
  %76 = load i32, ptr %11, align 4, !tbaa !9
  %77 = load double, ptr %14, align 8, !tbaa !5
  %78 = load double, ptr %14, align 8, !tbaa !5
  %79 = call double @function(double noundef %78)
  %80 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %75, ptr noundef @.str.1, i32 noundef %76, double noundef %77, double noundef %79) #5
  %81 = load ptr, ptr %13, align 8, !tbaa !11
  %82 = call i32 @fclose(ptr noundef %81)
  %83 = call i32 (ptr, ...) @printf(ptr noundef @.str.2)
  %84 = call i32 (ptr, ...) @printf(ptr noundef @.str.3)
  store double 0.000000e+00, ptr %7, align 8
  store i32 1, ptr %15, align 4
  br label %86

85:                                               ; preds = %73
  store i32 0, ptr %15, align 4
  br label %86

86:                                               ; preds = %85, %74
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #5
  %87 = load i32, ptr %15, align 4
  switch i32 %87, label %90 [
    i32 0, label %88
    i32 1, label %88
  ]

88:                                               ; preds = %86, %86
  %89 = load double, ptr %7, align 8
  ret double %89

90:                                               ; preds = %86
  unreachable
}

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

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

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

declare i32 @fclose(ptr noundef) #4

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

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

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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #2 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { 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 #4 = { "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 #5 = { 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}
!11 = !{!12, !12, i64 0}
!12 = !{!"any pointer", !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 = external hidden unnamed_addr constant [60 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [47 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [49 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [53 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local double @function(double noundef) 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: nounwind uwtable
define dso_local noundef double @regulaFalsi(double noundef %0, double noundef %1, double noundef %2, i32 noundef %3, i32 noundef %4, ptr nocapture noundef %5) local_unnamed_addr #0 {
  br label %tailrecurse.outer.outer

tailrecurse.outer.outer:                          ; preds = %44, %6
  %.tr.ph.ph = phi double [ %0, %6 ], [ %37, %44 ]
  %.tr38.ph.ph = phi double [ %1, %6 ], [ %.tr38, %44 ]
  %.tr40.ph.ph = phi i32 [ %3, %6 ], [ %28, %44 ]
  br label %tailrecurse.outer

tailrecurse.outer:                                ; preds = %tailrecurse.outer.outer, %23
  %.tr.ph = phi double [ %16, %23 ], [ %.tr.ph.ph, %tailrecurse.outer.outer ]
  %.tr40.ph = phi i32 [ %7, %23 ], [ %.tr40.ph.ph, %tailrecurse.outer.outer ]
  %7 = add nsw i32 %.tr40.ph, 1
  %8 = tail call double @function(double noundef %.tr38.ph.ph)
  %9 = tail call double @function(double noundef %.tr.ph)
  %10 = fneg double %9
  %11 = fmul double %.tr38.ph.ph, %10
  %12 = tail call double @llvm.fmuladd.f64(double %.tr.ph, double %8, double %11)
  %13 = tail call double @function(double noundef %.tr38.ph.ph)
  %14 = tail call double @function(double noundef %.tr.ph)
  %15 = fsub double %13, %14
  %16 = fdiv double %12, %15
  %17 = tail call double @function(double noundef %16)
  %18 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %5, ptr noundef nonnull @.str, i32 noundef %7, double noundef %.tr.ph, double noundef %.tr38.ph.ph, double noundef %16, double noundef %17) #3
  %19 = tail call double @function(double noundef %16)
  %20 = tail call double @llvm.fabs.f64(double %19)
  %21 = fcmp oge double %20, %2
  %22 = icmp slt i32 %7, %4
  %or.cond.peel = select i1 %21, i1 %22, i1 false
  br i1 %or.cond.peel, label %23, label %.loopexit

23:                                               ; preds = %tailrecurse.outer
  %24 = tail call double @function(double noundef %.tr.ph)
  %25 = tail call double @function(double noundef %16)
  %26 = fmul double %24, %25
  %27 = fcmp olt double %26, 0.000000e+00
  br i1 %27, label %tailrecurse, label %tailrecurse.outer

tailrecurse:                                      ; preds = %23, %44
  %.tr38 = phi double [ %37, %44 ], [ %16, %23 ]
  %.tr40 = phi i32 [ %28, %44 ], [ %7, %23 ]
  %28 = add nsw i32 %.tr40, 1
  %29 = tail call double @function(double noundef %.tr38)
  %30 = tail call double @function(double noundef %.tr.ph)
  %31 = fneg double %30
  %32 = fmul double %.tr38, %31
  %33 = tail call double @llvm.fmuladd.f64(double %.tr.ph, double %29, double %32)
  %34 = tail call double @function(double noundef %.tr38)
  %35 = tail call double @function(double noundef %.tr.ph)
  %36 = fsub double %34, %35
  %37 = fdiv double %33, %36
  %38 = tail call double @function(double noundef %37)
  %39 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %5, ptr noundef nonnull @.str, i32 noundef %28, double noundef %.tr.ph, double noundef %.tr38, double noundef %37, double noundef %38) #3
  %40 = tail call double @function(double noundef %37)
  %41 = tail call double @llvm.fabs.f64(double %40)
  %42 = fcmp oge double %41, %2
  %43 = icmp slt i32 %28, %4
  %or.cond = select i1 %42, i1 %43, i1 false
  br i1 %or.cond, label %44, label %.loopexit

44:                                               ; preds = %tailrecurse
  %45 = tail call double @function(double noundef %.tr.ph)
  %46 = tail call double @function(double noundef %37)
  %47 = fmul double %45, %46
  %48 = fcmp olt double %47, 0.000000e+00
  br i1 %48, label %tailrecurse, label %tailrecurse.outer.outer, !llvm.loop !5

.loopexit:                                        ; preds = %tailrecurse.outer, %tailrecurse
  %.lcssa52 = phi i32 [ %28, %tailrecurse ], [ %7, %tailrecurse.outer ]
  %.lcssa = phi double [ %37, %tailrecurse ], [ %16, %tailrecurse.outer ]
  %49 = tail call double @function(double noundef %.lcssa)
  %50 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %5, ptr noundef nonnull @.str.1, i32 noundef %.lcssa52, double noundef %.lcssa, double noundef %49) #3
  %51 = tail call i32 @fclose(ptr noundef %5)
  %52 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2)
  %53 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.3)
  ret double 0.000000e+00
}

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

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

; Function Attrs: nofree nounwind
declare noundef i32 @fclose(ptr nocapture noundef) local_unnamed_addr #2

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

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 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #2 = { 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 #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 = distinct !{!5, !6}
!6 = !{!"llvm.loop.peeled.count", i32 1}


; Effective O3 passes: BDCEPass,GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LoopFullUnrollPass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,ReassociatePass,SCCPPass,SROAPass,SimplifyCFGPass,TailCallElimPass