; LLVM IR from EntityFX/anybench :: src/benchmarks/generic/whetstone (whets)

; 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 [44 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [43 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [10 x i8], align 1
@timeday = external global [30 x i8], align 16
@.str.4 = external hidden unnamed_addr constant [11 x i8], align 1
@TimeUsed = external hidden global float, align 4
@.str.5 = external hidden unnamed_addr constant [41 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [25 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [50 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [80 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [19 x i8], align 1
@mwips = external hidden global float, align 4
@.str.11 = external hidden unnamed_addr constant [15 x i8], align 1
@Check = external hidden global float, align 4
@.str.12 = external hidden unnamed_addr constant [15 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local i32 @main(i32 noundef %0, ptr noundef %1) #0 {
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i64, align 8
  %9 = alloca i32, align 4
  %10 = alloca i64, align 8
  %11 = alloca i32, align 4
  %12 = alloca ptr, align 8
  %13 = alloca [80 x i8], align 16
  %14 = alloca [256 x i8], align 16
  %15 = alloca [10 x [80 x i8]], align 16
  %16 = alloca [80 x i8], align 16
  %17 = alloca i32, align 4
  store i32 0, ptr %3, align 4
  store i32 %0, ptr %4, align 4, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #4
  store i32 10, ptr %6, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #4
  store i32 1, ptr %7, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #4
  store i64 1, ptr %8, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #4
  store i64 100, ptr %10, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #4
  store i32 10, ptr %11, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #4
  call void @llvm.lifetime.start.p0(i64 80, ptr %13) #4
  call void @llvm.lifetime.start.p0(i64 256, ptr %14) #4
  call void @llvm.lifetime.start.p0(i64 800, ptr %15) #4
  call void @llvm.memset.p0.i64(ptr align 16 %15, i8 0, i64 800, i1 false)
  %18 = getelementptr inbounds <{ [80 x i8], [9 x [80 x i8]] }>, ptr %15, i32 0, i32 0
  %19 = getelementptr inbounds [80 x i8], ptr %18, i32 0, i32 0
  store i8 32, ptr %19, align 16
  call void @llvm.lifetime.start.p0(i64 80, ptr %16) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #4
  call void (...) @local_time()
  %20 = call i32 (ptr, ...) @printf(ptr noundef @.str)
  %21 = call i32 (ptr, ...) @printf(ptr noundef @.str.1, ptr noundef @.str.2, ptr noundef @.str.3, ptr noundef @timeday)
  %22 = call i32 (ptr, ...) @printf(ptr noundef @.str.4)
  br label %23

23:                                               ; preds = %45, %2
  store float 0.000000e+00, ptr @TimeUsed, align 4, !tbaa !13
  %24 = load i64, ptr %8, align 8, !tbaa !11
  %25 = load i64, ptr %10, align 8, !tbaa !11
  %26 = load i32, ptr %7, align 4, !tbaa !5
  call void @whetstones(i64 noundef %24, i64 noundef %25, i32 noundef %26)
  %27 = load float, ptr @TimeUsed, align 4, !tbaa !13
  %28 = fpext float %27 to double
  %29 = load i64, ptr %8, align 8, !tbaa !11
  %30 = sitofp i64 %29 to float
  %31 = fpext float %30 to double
  %32 = call i32 (ptr, ...) @printf(ptr noundef @.str.5, double noundef %28, double noundef %31)
  %33 = load i32, ptr %7, align 4, !tbaa !5
  %34 = add nsw i32 %33, 1
  store i32 %34, ptr %7, align 4, !tbaa !5
  %35 = load i32, ptr %6, align 4, !tbaa !5
  %36 = add nsw i32 %35, -1
  store i32 %36, ptr %6, align 4, !tbaa !5
  %37 = load float, ptr @TimeUsed, align 4, !tbaa !13
  %38 = fpext float %37 to double
  %39 = fcmp ogt double %38, 2.000000e+00
  br i1 %39, label %40, label %41

40:                                               ; preds = %23
  store i32 0, ptr %6, align 4, !tbaa !5
  br label %44

41:                                               ; preds = %23
  %42 = load i64, ptr %8, align 8, !tbaa !11
  %43 = mul nsw i64 %42, 5
  store i64 %43, ptr %8, align 8, !tbaa !11
  br label %44

44:                                               ; preds = %41, %40
  br label %45

45:                                               ; preds = %44
  %46 = load i32, ptr %6, align 4, !tbaa !5
  %47 = icmp sgt i32 %46, 0
  br i1 %47, label %23, label %48, !llvm.loop !15

48:                                               ; preds = %45
  %49 = load float, ptr @TimeUsed, align 4, !tbaa !13
  %50 = fcmp ogt float %49, 0.000000e+00
  br i1 %50, label %51, label %60

51:                                               ; preds = %48
  %52 = load i32, ptr %11, align 4, !tbaa !5
  %53 = sext i32 %52 to i64
  %54 = load i64, ptr %8, align 8, !tbaa !11
  %55 = mul nsw i64 %53, %54
  %56 = sitofp i64 %55 to float
  %57 = load float, ptr @TimeUsed, align 4, !tbaa !13
  %58 = fdiv float %56, %57
  %59 = fptosi float %58 to i64
  store i64 %59, ptr %8, align 8, !tbaa !11
  br label %60

60:                                               ; preds = %51, %48
  %61 = load i64, ptr %8, align 8, !tbaa !11
  %62 = icmp slt i64 %61, 1
  br i1 %62, label %63, label %64

63:                                               ; preds = %60
  store i64 1, ptr %8, align 8, !tbaa !11
  br label %64

64:                                               ; preds = %63, %60
  store i32 0, ptr %7, align 4, !tbaa !5
  %65 = load i64, ptr %8, align 8, !tbaa !11
  %66 = trunc i64 %65 to i32
  %67 = call i32 (ptr, ...) @printf(ptr noundef @.str.6, i32 noundef %66)
  %68 = call i32 (ptr, ...) @printf(ptr noundef @.str.7, ptr noundef @.str.2)
  %69 = call i32 (ptr, ...) @printf(ptr noundef @.str.8)
  %70 = call i32 (ptr, ...) @printf(ptr noundef @.str.9)
  store float 0.000000e+00, ptr @TimeUsed, align 4, !tbaa !13
  %71 = load i64, ptr %8, align 8, !tbaa !11
  %72 = load i64, ptr %10, align 8, !tbaa !11
  %73 = load i32, ptr %7, align 4, !tbaa !5
  call void @whetstones(i64 noundef %71, i64 noundef %72, i32 noundef %73)
  %74 = call i32 (ptr, ...) @printf(ptr noundef @.str.10)
  %75 = load float, ptr @TimeUsed, align 4, !tbaa !13
  %76 = fcmp ogt float %75, 0.000000e+00
  br i1 %76, label %77, label %86

77:                                               ; preds = %64
  %78 = load i64, ptr %8, align 8, !tbaa !11
  %79 = sitofp i64 %78 to float
  %80 = load i64, ptr %10, align 8, !tbaa !11
  %81 = sitofp i64 %80 to float
  %82 = fmul float %79, %81
  %83 = load float, ptr @TimeUsed, align 4, !tbaa !13
  %84 = fmul float 1.000000e+01, %83
  %85 = fdiv float %82, %84
  store float %85, ptr @mwips, align 4, !tbaa !13
  br label %87

86:                                               ; preds = %64
  store float 0.000000e+00, ptr @mwips, align 4, !tbaa !13
  br label %87

87:                                               ; preds = %86, %77
  %88 = load float, ptr @mwips, align 4, !tbaa !13
  %89 = fpext float %88 to double
  %90 = load float, ptr @TimeUsed, align 4, !tbaa !13
  %91 = fpext float %90 to double
  %92 = call i32 (ptr, ...) @printf(ptr noundef @.str.11, double noundef %89, double noundef %91)
  %93 = load float, ptr @Check, align 4, !tbaa !13
  %94 = fcmp oeq float %93, 0.000000e+00
  br i1 %94, label %95, label %97

95:                                               ; preds = %87
  %96 = call i32 (ptr, ...) @printf(ptr noundef @.str.12)
  br label %97

97:                                               ; preds = %95, %87
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #4
  call void @llvm.lifetime.end.p0(i64 80, ptr %16) #4
  call void @llvm.lifetime.end.p0(i64 800, ptr %15) #4
  call void @llvm.lifetime.end.p0(i64 256, ptr %14) #4
  call void @llvm.lifetime.end.p0(i64 80, ptr %13) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #4
  ret i32 0
}

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

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #2

declare void @local_time(...) #3

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

; Function Attrs: nounwind uwtable
declare dso_local void @whetstones(i64 noundef, i64 noundef, i32 noundef) #0

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

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 willreturn memory(argmem: readwrite) }
attributes #2 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #3 = { "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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"long", !7, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"float", !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"

@.str = external hidden unnamed_addr constant [44 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [43 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [10 x i8], align 1
@timeday = external global [30 x i8], align 16
@.str.4 = external hidden unnamed_addr constant [11 x i8], align 1
@TimeUsed = external hidden local_unnamed_addr global float, align 4
@.str.5 = external hidden unnamed_addr constant [41 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [25 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [50 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [80 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [19 x i8], align 1
@mwips = external hidden local_unnamed_addr global float, align 4
@.str.11 = external hidden unnamed_addr constant [15 x i8], align 1
@Check = external hidden local_unnamed_addr global float, align 4
@.str.12 = external hidden unnamed_addr constant [15 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @main(i32 noundef %0, ptr nocapture noundef readnone %1) local_unnamed_addr #0 {
  tail call void (...) @local_time() #4
  %3 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str)
  %4 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, ptr noundef nonnull @.str.2, ptr noundef nonnull @.str.3, ptr noundef nonnull @timeday)
  %5 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.4)
  br label %6

6:                                                ; preds = %6, %2
  %.018 = phi i64 [ 1, %2 ], [ %.119, %6 ]
  %.017 = phi i32 [ 1, %2 ], [ %12, %6 ]
  %.0 = phi i32 [ 10, %2 ], [ %15, %6 ]
  store float 0.000000e+00, ptr @TimeUsed, align 4, !tbaa !5
  tail call void @whetstones(i64 noundef %.018, i64 noundef 100, i32 noundef %.017)
  %7 = load float, ptr @TimeUsed, align 4, !tbaa !5
  %8 = fpext float %7 to double
  %9 = sitofp i64 %.018 to float
  %10 = fpext float %9 to double
  %11 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.5, double noundef %8, double noundef %10)
  %12 = add nuw nsw i32 %.017, 1
  %13 = load float, ptr @TimeUsed, align 4, !tbaa !5
  %14 = fcmp ogt float %13, 2.000000e+00
  %15 = add nsw i32 %.0, -1
  %16 = mul nsw i64 %.018, 5
  %.119 = select i1 %14, i64 %.018, i64 %16
  %.not22 = icmp eq i32 %15, 0
  %.not = select i1 %14, i1 true, i1 %.not22
  br i1 %.not, label %17, label %6, !llvm.loop !9

17:                                               ; preds = %6
  %18 = fcmp ogt float %13, 0.000000e+00
  br i1 %18, label %19, label %24

19:                                               ; preds = %17
  %20 = mul nsw i64 %.119, 10
  %21 = sitofp i64 %20 to float
  %22 = fdiv float %21, %13
  %23 = fptosi float %22 to i64
  br label %24

24:                                               ; preds = %19, %17
  %.2 = phi i64 [ %23, %19 ], [ %.119, %17 ]
  %spec.store.select = tail call i64 @llvm.smax.i64(i64 %.2, i64 1)
  %25 = trunc i64 %spec.store.select to i32
  %26 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.6, i32 noundef %25)
  %27 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.7, ptr noundef nonnull @.str.2)
  %28 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.8)
  %29 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.9)
  store float 0.000000e+00, ptr @TimeUsed, align 4, !tbaa !5
  tail call void @whetstones(i64 noundef %spec.store.select, i64 noundef 100, i32 noundef 0)
  %30 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.10)
  %31 = load float, ptr @TimeUsed, align 4, !tbaa !5
  %32 = fcmp ogt float %31, 0.000000e+00
  %33 = uitofp nneg i64 %spec.store.select to float
  %34 = fmul float %33, 1.000000e+02
  %35 = fmul float %31, 1.000000e+01
  %36 = fdiv float %34, %35
  %storemerge = select i1 %32, float %36, float 0.000000e+00
  store float %storemerge, ptr @mwips, align 4, !tbaa !5
  %37 = fpext float %storemerge to double
  %38 = fpext float %31 to double
  %39 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.11, double noundef %37, double noundef %38)
  %40 = load float, ptr @Check, align 4, !tbaa !5
  %41 = fcmp oeq float %40, 0.000000e+00
  br i1 %41, label %42, label %44

42:                                               ; preds = %24
  %43 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.12)
  br label %44

44:                                               ; preds = %42, %24
  ret i32 0
}

declare void @local_time(...) local_unnamed_addr #1

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

; Function Attrs: nounwind uwtable
declare dso_local void @whetstones(i64 noundef, i64 noundef, i32 noundef) local_unnamed_addr #0

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

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 = { "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 = { 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 = { 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 = !{!"float", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,LCSSAPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass