; LLVM IR from eXascaleInfolab/daoc :: export/shared/fileio.ll (ZN4daoc16estimateCnlNodesEmf)

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

@stderr = external global ptr, align 8
@.str.7 = external hidden unnamed_addr constant [77 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: 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, ...) #1

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef i64 @_ZN4daoc16estimateCnlNodesEmf(i64 noundef %0, float noundef %1) #2 {
  %3 = alloca i64, align 8
  %4 = alloca float, align 4
  %5 = alloca i64, align 8
  %6 = alloca i64, align 8
  %7 = alloca i32, align 4
  %8 = alloca i64, align 8
  store i64 %0, ptr %3, align 8, !tbaa !5
  store float %1, ptr %4, align 4, !tbaa !9
  %9 = load float, ptr %4, align 4, !tbaa !9
  %10 = fcmp ole float %9, 0.000000e+00
  br i1 %10, label %11, label %16

11:                                               ; preds = %2
  %12 = load ptr, ptr @stderr, align 8, !tbaa !11
  %13 = load float, ptr %4, align 4, !tbaa !9
  %14 = fpext float %13 to double
  %15 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %12, ptr noundef @.str.7, double noundef %14) #3
  store float 1.000000e+00, ptr %4, align 4, !tbaa !9
  br label %16

16:                                               ; preds = %11, %2
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #3
  store i64 0, ptr %5, align 8, !tbaa !5
  %17 = load i64, ptr %3, align 8, !tbaa !5
  %18 = icmp ne i64 %17, 0
  br i1 %18, label %19, label %50

19:                                               ; preds = %16
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #3
  store i64 10, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #3
  store i32 1, ptr %7, align 4, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #3
  %20 = load i64, ptr %3, align 8, !tbaa !5
  %21 = load i64, ptr %6, align 8, !tbaa !5
  %22 = urem i64 %20, %21
  store i64 %22, ptr %8, align 8, !tbaa !5
  %23 = load i64, ptr %8, align 8, !tbaa !5
  %24 = load i32, ptr %7, align 4, !tbaa !13
  %25 = add i32 %24, 1
  store i32 %25, ptr %7, align 4, !tbaa !13
  %26 = zext i32 %25 to i64
  %27 = udiv i64 %23, %26
  store i64 %27, ptr %5, align 8, !tbaa !5
  br label %28

28:                                               ; preds = %32, %19
  %29 = load i64, ptr %3, align 8, !tbaa !5
  %30 = load i64, ptr %6, align 8, !tbaa !5
  %31 = icmp uge i64 %29, %30
  br i1 %31, label %32, label %49

32:                                               ; preds = %28
  %33 = load i64, ptr %6, align 8, !tbaa !5
  %34 = mul i64 %33, 10
  store i64 %34, ptr %6, align 8, !tbaa !5
  %35 = load i64, ptr %3, align 8, !tbaa !5
  %36 = load i64, ptr %8, align 8, !tbaa !5
  %37 = sub i64 %35, %36
  %38 = load i64, ptr %6, align 8, !tbaa !5
  %39 = urem i64 %37, %38
  %40 = load i32, ptr %7, align 4, !tbaa !13
  %41 = add i32 %40, 1
  store i32 %41, ptr %7, align 4, !tbaa !13
  %42 = zext i32 %41 to i64
  %43 = udiv i64 %39, %42
  %44 = load i64, ptr %5, align 8, !tbaa !5
  %45 = add i64 %44, %43
  store i64 %45, ptr %5, align 8, !tbaa !5
  %46 = load i64, ptr %3, align 8, !tbaa !5
  %47 = load i64, ptr %6, align 8, !tbaa !5
  %48 = urem i64 %46, %47
  store i64 %48, ptr %8, align 8, !tbaa !5
  br label %28, !llvm.loop !15

49:                                               ; preds = %28
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #3
  br label %50

50:                                               ; preds = %49, %16
  %51 = load i64, ptr %5, align 8, !tbaa !5
  %52 = uitofp i64 %51 to float
  %53 = load float, ptr %4, align 4, !tbaa !9
  %54 = fdiv float %52, %53
  %55 = fptoui float %54 to i64
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #3
  ret i64 %55
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 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 = { 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 = !{!"long", !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 = !{!"any pointer", !7, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"int", !7, i64 0}
!15 = distinct !{!15, !16}
!16 = !{!"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"

@stderr = external local_unnamed_addr global ptr, align 8
@.str.7 = external hidden unnamed_addr constant [77 x i8], align 1

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

; Function Attrs: mustprogress nofree nounwind uwtable
define dso_local noundef i64 @_ZN4daoc16estimateCnlNodesEmf(i64 noundef %0, float noundef %1) local_unnamed_addr #1 {
  %3 = fcmp ugt float %1, 0.000000e+00
  br i1 %3, label %8, label %4

4:                                                ; preds = %2
  %5 = load ptr, ptr @stderr, align 8, !tbaa !5
  %6 = fpext float %1 to double
  %7 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %5, ptr noundef nonnull @.str.7, double noundef %6) #2
  br label %8

8:                                                ; preds = %4, %2
  %.021 = phi float [ 1.000000e+00, %4 ], [ %1, %2 ]
  %.not = icmp eq i64 %0, 0
  br i1 %.not, label %21, label %9

9:                                                ; preds = %8
  %10 = urem i64 %0, 10
  %11 = lshr i64 %10, 1
  %.not2526 = icmp ult i64 %0, 10
  br i1 %.not2526, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %9, %.lr.ph
  %.030 = phi i64 [ %19, %.lr.ph ], [ %10, %9 ]
  %.01829 = phi i32 [ %15, %.lr.ph ], [ 2, %9 ]
  %.01928 = phi i64 [ %12, %.lr.ph ], [ 10, %9 ]
  %.02027 = phi i64 [ %18, %.lr.ph ], [ %11, %9 ]
  %12 = mul i64 %.01928, 10
  %13 = sub i64 %0, %.030
  %14 = urem i64 %13, %12
  %15 = add i32 %.01829, 1
  %16 = zext i32 %15 to i64
  %17 = udiv i64 %14, %16
  %18 = add i64 %17, %.02027
  %19 = urem i64 %0, %12
  %.not25 = icmp ugt i64 %12, %0
  br i1 %.not25, label %._crit_edge, label %.lr.ph, !llvm.loop !9

._crit_edge:                                      ; preds = %.lr.ph, %9
  %.020.lcssa = phi i64 [ %11, %9 ], [ %18, %.lr.ph ]
  %20 = uitofp i64 %.020.lcssa to float
  br label %21

21:                                               ; preds = %._crit_edge, %8
  %.1 = phi float [ %20, %._crit_edge ], [ 0.000000e+00, %8 ]
  %22 = fdiv float %.1, %.021
  %23 = fptoui float %22 to i64
  ret i64 %23
}

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 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 = { cold 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 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}


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