; LLVM IR from glaretechnologies/substrata :: secp256k1-master/src (bench_ecdh)

; 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.2 = external hidden unnamed_addr constant [9 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [10 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [10 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [4 x i8], align 1

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

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

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

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

; Function Attrs: nounwind uwtable
define dso_local void @run_benchmark(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3, ptr noundef %4, i32 noundef %5, i32 noundef %6) #0 {
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  %15 = alloca i32, align 4
  %16 = alloca i64, align 8
  %17 = alloca i64, align 8
  %18 = alloca i64, align 8
  %19 = alloca i64, align 8
  %20 = alloca i64, align 8
  store ptr %0, ptr %8, align 8, !tbaa !5
  store ptr %1, ptr %9, align 8, !tbaa !5
  store ptr %2, ptr %10, align 8, !tbaa !5
  store ptr %3, ptr %11, align 8, !tbaa !5
  store ptr %4, ptr %12, align 8, !tbaa !5
  store i32 %5, ptr %13, align 4, !tbaa !9
  store i32 %6, ptr %14, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #3
  store i64 9223372036854775807, ptr %16, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #3
  store i64 0, ptr %17, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %18) #3
  store i64 0, ptr %18, align 8, !tbaa !11
  store i32 0, ptr %15, align 4, !tbaa !9
  br label %21

21:                                               ; preds = %61, %7
  %22 = load i32, ptr %15, align 4, !tbaa !9
  %23 = load i32, ptr %13, align 4, !tbaa !9
  %24 = icmp slt i32 %22, %23
  br i1 %24, label %25, label %64

25:                                               ; preds = %21
  call void @llvm.lifetime.start.p0(i64 8, ptr %19) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %20) #3
  %26 = load ptr, ptr %10, align 8, !tbaa !5
  %27 = icmp ne ptr %26, null
  br i1 %27, label %28, label %31

28:                                               ; preds = %25
  %29 = load ptr, ptr %10, align 8, !tbaa !5
  %30 = load ptr, ptr %12, align 8, !tbaa !5
  call void %29(ptr noundef %30)
  br label %31

31:                                               ; preds = %28, %25
  %32 = call i64 @gettime_i64()
  store i64 %32, ptr %19, align 8, !tbaa !11
  %33 = load ptr, ptr %9, align 8, !tbaa !5
  %34 = load ptr, ptr %12, align 8, !tbaa !5
  %35 = load i32, ptr %14, align 4, !tbaa !9
  call void %33(ptr noundef %34, i32 noundef %35)
  %36 = call i64 @gettime_i64()
  %37 = load i64, ptr %19, align 8, !tbaa !11
  %38 = sub nsw i64 %36, %37
  store i64 %38, ptr %20, align 8, !tbaa !11
  %39 = load ptr, ptr %11, align 8, !tbaa !5
  %40 = icmp ne ptr %39, null
  br i1 %40, label %41, label %45

41:                                               ; preds = %31
  %42 = load ptr, ptr %11, align 8, !tbaa !5
  %43 = load ptr, ptr %12, align 8, !tbaa !5
  %44 = load i32, ptr %14, align 4, !tbaa !9
  call void %42(ptr noundef %43, i32 noundef %44)
  br label %45

45:                                               ; preds = %41, %31
  %46 = load i64, ptr %20, align 8, !tbaa !11
  %47 = load i64, ptr %16, align 8, !tbaa !11
  %48 = icmp slt i64 %46, %47
  br i1 %48, label %49, label %51

49:                                               ; preds = %45
  %50 = load i64, ptr %20, align 8, !tbaa !11
  store i64 %50, ptr %16, align 8, !tbaa !11
  br label %51

51:                                               ; preds = %49, %45
  %52 = load i64, ptr %20, align 8, !tbaa !11
  %53 = load i64, ptr %18, align 8, !tbaa !11
  %54 = icmp sgt i64 %52, %53
  br i1 %54, label %55, label %57

55:                                               ; preds = %51
  %56 = load i64, ptr %20, align 8, !tbaa !11
  store i64 %56, ptr %18, align 8, !tbaa !11
  br label %57

57:                                               ; preds = %55, %51
  %58 = load i64, ptr %20, align 8, !tbaa !11
  %59 = load i64, ptr %17, align 8, !tbaa !11
  %60 = add nsw i64 %59, %58
  store i64 %60, ptr %17, align 8, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 8, ptr %20) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %19) #3
  br label %61

61:                                               ; preds = %57
  %62 = load i32, ptr %15, align 4, !tbaa !9
  %63 = add nsw i32 %62, 1
  store i32 %63, ptr %15, align 4, !tbaa !9
  br label %21, !llvm.loop !13

64:                                               ; preds = %21
  %65 = load ptr, ptr %8, align 8, !tbaa !5
  %66 = call i32 (ptr, ...) @printf(ptr noundef @.str.2, ptr noundef %65)
  %67 = load i64, ptr %16, align 8, !tbaa !11
  %68 = mul nsw i64 %67, 1000000
  %69 = load i32, ptr %14, align 4, !tbaa !9
  %70 = sext i32 %69 to i64
  %71 = sdiv i64 %68, %70
  call void @print_number(i64 noundef %71)
  %72 = call i32 (ptr, ...) @printf(ptr noundef @.str.3)
  %73 = load i64, ptr %17, align 8, !tbaa !11
  %74 = mul nsw i64 %73, 1000000
  %75 = load i32, ptr %13, align 4, !tbaa !9
  %76 = sext i32 %75 to i64
  %77 = sdiv i64 %74, %76
  %78 = load i32, ptr %14, align 4, !tbaa !9
  %79 = sext i32 %78 to i64
  %80 = sdiv i64 %77, %79
  call void @print_number(i64 noundef %80)
  %81 = call i32 (ptr, ...) @printf(ptr noundef @.str.4)
  %82 = load i64, ptr %18, align 8, !tbaa !11
  %83 = mul nsw i64 %82, 1000000
  %84 = load i32, ptr %14, align 4, !tbaa !9
  %85 = sext i32 %84 to i64
  %86 = sdiv i64 %83, %85
  call void @print_number(i64 noundef %86)
  %87 = call i32 (ptr, ...) @printf(ptr noundef @.str.5)
  call void @llvm.lifetime.end.p0(i64 8, ptr %18) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #3
  ret void
}

; Function Attrs: nounwind uwtable
declare hidden i64 @gettime_i64() #0

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 = { "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 = !{!"any pointer", !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 = !{!"long", !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"

@.str.2 = external hidden unnamed_addr constant [9 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [10 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [10 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [4 x i8], align 1

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

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

; Function Attrs: nounwind uwtable
define dso_local void @run_benchmark(ptr noundef %0, ptr nocapture noundef readonly %1, ptr noundef readonly %2, ptr noundef readonly %3, ptr noundef %4, i32 noundef %5, i32 noundef %6) local_unnamed_addr #0 {
  %8 = icmp sgt i32 %5, 0
  br i1 %8, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %7
  %.not = icmp eq ptr %2, null
  %.not38 = icmp eq ptr %3, null
  br i1 %.not38, label %.lr.ph.split.us, label %.lr.ph.split

.lr.ph.split.us:                                  ; preds = %.lr.ph
  br i1 %.not, label %.lr.ph.split.us.split.us, label %.lr.ph.split.us.split

.lr.ph.split.us.split.us:                         ; preds = %.lr.ph.split.us, %.lr.ph.split.us.split.us
  %.042.us.us = phi i32 [ %13, %.lr.ph.split.us.split.us ], [ 0, %.lr.ph.split.us ]
  %.02941.us.us = phi i64 [ %spec.select.us.us, %.lr.ph.split.us.split.us ], [ 9223372036854775807, %.lr.ph.split.us ]
  %.03040.us.us = phi i64 [ %.131.us.us, %.lr.ph.split.us.split.us ], [ 0, %.lr.ph.split.us ]
  %.03239.us.us = phi i64 [ %12, %.lr.ph.split.us.split.us ], [ 0, %.lr.ph.split.us ]
  %9 = tail call i64 @gettime_i64()
  tail call void %1(ptr noundef %4, i32 noundef %6) #3
  %10 = tail call i64 @gettime_i64()
  %11 = sub nsw i64 %10, %9
  %spec.select.us.us = tail call i64 @llvm.smin.i64(i64 %11, i64 %.02941.us.us)
  %.131.us.us = tail call i64 @llvm.smax.i64(i64 %11, i64 %.03040.us.us)
  %12 = add nsw i64 %11, %.03239.us.us
  %13 = add nuw nsw i32 %.042.us.us, 1
  %exitcond70.not = icmp eq i32 %13, %5
  br i1 %exitcond70.not, label %._crit_edge, label %.lr.ph.split.us.split.us, !llvm.loop !5

.lr.ph.split.us.split:                            ; preds = %.lr.ph.split.us, %.lr.ph.split.us.split
  %.042.us = phi i32 [ %18, %.lr.ph.split.us.split ], [ 0, %.lr.ph.split.us ]
  %.02941.us = phi i64 [ %spec.select.us, %.lr.ph.split.us.split ], [ 9223372036854775807, %.lr.ph.split.us ]
  %.03040.us = phi i64 [ %.131.us, %.lr.ph.split.us.split ], [ 0, %.lr.ph.split.us ]
  %.03239.us = phi i64 [ %17, %.lr.ph.split.us.split ], [ 0, %.lr.ph.split.us ]
  tail call void %2(ptr noundef %4) #3
  %14 = tail call i64 @gettime_i64()
  tail call void %1(ptr noundef %4, i32 noundef %6) #3
  %15 = tail call i64 @gettime_i64()
  %16 = sub nsw i64 %15, %14
  %spec.select.us = tail call i64 @llvm.smin.i64(i64 %16, i64 %.02941.us)
  %.131.us = tail call i64 @llvm.smax.i64(i64 %16, i64 %.03040.us)
  %17 = add nsw i64 %16, %.03239.us
  %18 = add nuw nsw i32 %.042.us, 1
  %exitcond69.not = icmp eq i32 %18, %5
  br i1 %exitcond69.not, label %._crit_edge, label %.lr.ph.split.us.split, !llvm.loop !5

.lr.ph.split:                                     ; preds = %.lr.ph
  br i1 %.not, label %.lr.ph.split.split.us, label %.lr.ph.split.split

.lr.ph.split.split.us:                            ; preds = %.lr.ph.split, %.lr.ph.split.split.us
  %.042.us47 = phi i32 [ %23, %.lr.ph.split.split.us ], [ 0, %.lr.ph.split ]
  %.02941.us48 = phi i64 [ %spec.select.us51, %.lr.ph.split.split.us ], [ 9223372036854775807, %.lr.ph.split ]
  %.03040.us49 = phi i64 [ %.131.us52, %.lr.ph.split.split.us ], [ 0, %.lr.ph.split ]
  %.03239.us50 = phi i64 [ %22, %.lr.ph.split.split.us ], [ 0, %.lr.ph.split ]
  %19 = tail call i64 @gettime_i64()
  tail call void %1(ptr noundef %4, i32 noundef %6) #3
  %20 = tail call i64 @gettime_i64()
  %21 = sub nsw i64 %20, %19
  tail call void %3(ptr noundef %4, i32 noundef %6) #3
  %spec.select.us51 = tail call i64 @llvm.smin.i64(i64 %21, i64 %.02941.us48)
  %.131.us52 = tail call i64 @llvm.smax.i64(i64 %21, i64 %.03040.us49)
  %22 = add nsw i64 %21, %.03239.us50
  %23 = add nuw nsw i32 %.042.us47, 1
  %exitcond68.not = icmp eq i32 %23, %5
  br i1 %exitcond68.not, label %._crit_edge, label %.lr.ph.split.split.us, !llvm.loop !5

.lr.ph.split.split:                               ; preds = %.lr.ph.split, %.lr.ph.split.split
  %.042 = phi i32 [ %28, %.lr.ph.split.split ], [ 0, %.lr.ph.split ]
  %.02941 = phi i64 [ %spec.select, %.lr.ph.split.split ], [ 9223372036854775807, %.lr.ph.split ]
  %.03040 = phi i64 [ %.131, %.lr.ph.split.split ], [ 0, %.lr.ph.split ]
  %.03239 = phi i64 [ %27, %.lr.ph.split.split ], [ 0, %.lr.ph.split ]
  tail call void %2(ptr noundef %4) #3
  %24 = tail call i64 @gettime_i64()
  tail call void %1(ptr noundef %4, i32 noundef %6) #3
  %25 = tail call i64 @gettime_i64()
  %26 = sub nsw i64 %25, %24
  tail call void %3(ptr noundef %4, i32 noundef %6) #3
  %spec.select = tail call i64 @llvm.smin.i64(i64 %26, i64 %.02941)
  %.131 = tail call i64 @llvm.smax.i64(i64 %26, i64 %.03040)
  %27 = add nsw i64 %26, %.03239
  %28 = add nuw nsw i32 %.042, 1
  %exitcond.not = icmp eq i32 %28, %5
  br i1 %exitcond.not, label %._crit_edge, label %.lr.ph.split.split, !llvm.loop !5

._crit_edge:                                      ; preds = %.lr.ph.split.split, %.lr.ph.split.split.us, %.lr.ph.split.us.split, %.lr.ph.split.us.split.us, %7
  %.032.lcssa = phi i64 [ 0, %7 ], [ %12, %.lr.ph.split.us.split.us ], [ %17, %.lr.ph.split.us.split ], [ %22, %.lr.ph.split.split.us ], [ %27, %.lr.ph.split.split ]
  %.030.lcssa = phi i64 [ 0, %7 ], [ %.131.us.us, %.lr.ph.split.us.split.us ], [ %.131.us, %.lr.ph.split.us.split ], [ %.131.us52, %.lr.ph.split.split.us ], [ %.131, %.lr.ph.split.split ]
  %.029.lcssa = phi i64 [ 9223372036854775807, %7 ], [ %spec.select.us.us, %.lr.ph.split.us.split.us ], [ %spec.select.us, %.lr.ph.split.us.split ], [ %spec.select.us51, %.lr.ph.split.split.us ], [ %spec.select, %.lr.ph.split.split ]
  %29 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, ptr noundef %0)
  %30 = mul nsw i64 %.029.lcssa, 1000000
  %31 = sext i32 %6 to i64
  %32 = sdiv i64 %30, %31
  tail call void @print_number(i64 noundef %32)
  %33 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.3)
  %34 = mul nsw i64 %.032.lcssa, 1000000
  %35 = sext i32 %5 to i64
  %36 = sdiv i64 %34, %35
  %37 = sdiv i64 %36, %31
  tail call void @print_number(i64 noundef %37)
  %38 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.4)
  %39 = mul nsw i64 %.030.lcssa, 1000000
  %40 = sdiv i64 %39, %31
  tail call void @print_number(i64 noundef %40)
  %41 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.5)
  ret void
}

; Function Attrs: nounwind uwtable
declare hidden i64 @gettime_i64() local_unnamed_addr #0

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

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i64 @llvm.smax.i64(i64, i64) #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 = { 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 #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 = distinct !{!5, !6}
!6 = !{!"llvm.loop.mustprogress"}


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