; LLVM IR from atlantis13579/Riemann :: Src/Solver/NewtonRaphsonIteration.ll (ZN13NewtonRaphson8FindRootERKSt8functionIFffEES4_fi)

; 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: mustprogress uwtable
declare dso_local noundef float @_ZNKSt8functionIFffEEclEf(ptr noundef nonnull align 8 dereferenceable(32), float noundef) #1 align 2

; 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 float @_ZN13NewtonRaphson8FindRootERKSt8functionIFffEES4_fi(ptr noundef nonnull align 8 dereferenceable(32) %0, ptr noundef nonnull align 8 dereferenceable(32) %1, float noundef %2, i32 noundef %3) #1 align 2 {
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca float, align 4
  %8 = alloca i32, align 4
  %9 = alloca float, align 4
  %10 = alloca i32, align 4
  %11 = alloca float, align 4
  %12 = alloca float, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store float %2, ptr %7, align 4, !tbaa !9
  store i32 %3, ptr %8, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #3
  %13 = load float, ptr %7, align 4, !tbaa !9
  store float %13, ptr %9, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #3
  store i32 0, ptr %10, align 4, !tbaa !11
  br label %14

14:                                               ; preds = %27, %4
  %15 = load i32, ptr %10, align 4, !tbaa !11
  %16 = add nsw i32 %15, 1
  store i32 %16, ptr %10, align 4, !tbaa !11
  %17 = load i32, ptr %8, align 4, !tbaa !11
  %18 = icmp slt i32 %15, %17
  br i1 %18, label %19, label %25

19:                                               ; preds = %14
  %20 = load ptr, ptr %5, align 8, !tbaa !5
  %21 = load float, ptr %9, align 4, !tbaa !9
  %22 = call noundef float @_ZNKSt8functionIFffEEclEf(ptr noundef nonnull align 8 dereferenceable(32) %20, float noundef %21)
  %23 = call float @llvm.fabs.f32(float %22)
  %24 = fcmp ogt float %23, 0x3F50624DE0000000
  br label %25

25:                                               ; preds = %19, %14
  %26 = phi i1 [ false, %14 ], [ %24, %19 ]
  br i1 %26, label %27, label %39

27:                                               ; preds = %25
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #3
  %28 = load ptr, ptr %5, align 8, !tbaa !5
  %29 = load float, ptr %9, align 4, !tbaa !9
  %30 = call noundef float @_ZNKSt8functionIFffEEclEf(ptr noundef nonnull align 8 dereferenceable(32) %28, float noundef %29)
  store float %30, ptr %11, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #3
  %31 = load ptr, ptr %6, align 8, !tbaa !5
  %32 = load float, ptr %9, align 4, !tbaa !9
  %33 = call noundef float @_ZNKSt8functionIFffEEclEf(ptr noundef nonnull align 8 dereferenceable(32) %31, float noundef %32)
  store float %33, ptr %12, align 4, !tbaa !9
  %34 = load float, ptr %9, align 4, !tbaa !9
  %35 = load float, ptr %11, align 4, !tbaa !9
  %36 = load float, ptr %12, align 4, !tbaa !9
  %37 = fdiv float %35, %36
  %38 = fsub float %34, %37
  store float %38, ptr %9, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #3
  br label %14, !llvm.loop !13

39:                                               ; preds = %25
  %40 = load float, ptr %9, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #3
  ret float %40
}

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare float @llvm.fabs.f32(float) #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 = { 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++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"float", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !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"

; Function Attrs: mustprogress uwtable
declare dso_local noundef float @_ZNKSt8functionIFffEEclEf(ptr noundef nonnull align 8 dereferenceable(32), float noundef) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef float @_ZN13NewtonRaphson8FindRootERKSt8functionIFffEES4_fi(ptr noundef nonnull align 8 dereferenceable(32) %0, ptr noundef nonnull align 8 dereferenceable(32) %1, float noundef %2, i32 noundef %3) local_unnamed_addr #0 align 2 {
  %5 = icmp sgt i32 %3, 0
  br i1 %5, label %.lr.ph, label %.critedge

.lr.ph:                                           ; preds = %4, %10
  %6 = phi i32 [ %15, %10 ], [ 1, %4 ]
  %.013 = phi float [ %14, %10 ], [ %2, %4 ]
  %7 = tail call noundef float @_ZNKSt8functionIFffEEclEf(ptr noundef nonnull align 8 dereferenceable(32) %0, float noundef %.013)
  %8 = tail call float @llvm.fabs.f32(float %7)
  %9 = fcmp ogt float %8, 0x3F50624DE0000000
  br i1 %9, label %10, label %.critedge

10:                                               ; preds = %.lr.ph
  %11 = tail call noundef float @_ZNKSt8functionIFffEEclEf(ptr noundef nonnull align 8 dereferenceable(32) %0, float noundef %.013)
  %12 = tail call noundef float @_ZNKSt8functionIFffEEclEf(ptr noundef nonnull align 8 dereferenceable(32) %1, float noundef %.013)
  %13 = fdiv float %11, %12
  %14 = fsub float %.013, %13
  %15 = add nuw i32 %6, 1
  %exitcond.not = icmp eq i32 %6, %3
  br i1 %exitcond.not, label %.critedge, label %.lr.ph, !llvm.loop !5

.critedge:                                        ; preds = %.lr.ph, %10, %4
  %.0.lcssa = phi float [ %2, %4 ], [ %14, %10 ], [ %.013, %.lr.ph ]
  ret float %.0.lcssa
}

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

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" }
attributes #1 = { mustprogress 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)"}
!5 = distinct !{!5, !6}
!6 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LCSSAPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass