; LLVM IR from lelegard/cryptobench :: src/bench.ll (ZN5bench3runEv)

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

%class.bench = type { ptr, %"class.std::__cxx11::basic_string", i64, i64, i64, i64 }
%"class.std::__cxx11::basic_string" = type { %"struct.std::__cxx11::basic_string<char>::_Alloc_hider", i64, %union.anon }
%"struct.std::__cxx11::basic_string<char>::_Alloc_hider" = type { ptr }
%union.anon = type { i64, [8 x i8] }

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN5bench3runEv(ptr noundef nonnull align 8 dereferenceable(72) %0) #0 align 2 {
  %2 = alloca ptr, align 8
  %3 = alloca i64, align 8
  %4 = alloca i64, align 8
  %5 = alloca i64, align 8
  %6 = alloca i64, align 8
  %7 = alloca i64, align 8
  %8 = alloca i64, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  %9 = load ptr, ptr %2, align 8
  %10 = getelementptr inbounds %class.bench, ptr %9, i32 0, i32 4
  store i64 0, ptr %10, align 8, !tbaa !9
  %11 = getelementptr inbounds %class.bench, ptr %9, i32 0, i32 5
  store i64 0, ptr %11, align 8, !tbaa !14
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #4
  %12 = call noundef i64 @_ZN3sys8cpu_timeEv()
  store i64 %12, ptr %3, align 8, !tbaa !15
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #4
  %13 = getelementptr inbounds %class.bench, ptr %9, i32 0, i32 3
  %14 = load i64, ptr %13, align 8, !tbaa !16
  store i64 %14, ptr %4, align 8, !tbaa !15
  br label %15

15:                                               ; preds = %47, %1
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #4
  store i64 0, ptr %5, align 8, !tbaa !15
  br label %16

16:                                               ; preds = %25, %15
  %17 = load i64, ptr %5, align 8, !tbaa !15
  %18 = load i64, ptr %4, align 8, !tbaa !15
  %19 = icmp slt i64 %17, %18
  br i1 %19, label %21, label %20

20:                                               ; preds = %16
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #4
  br label %28

21:                                               ; preds = %16
  %22 = load ptr, ptr %9, align 8, !tbaa !17
  %23 = getelementptr inbounds ptr, ptr %22, i64 0
  %24 = load ptr, ptr %23, align 8
  call void %24(ptr noundef nonnull align 8 dereferenceable(72) %9)
  br label %25

25:                                               ; preds = %21
  %26 = load i64, ptr %5, align 8, !tbaa !15
  %27 = add nsw i64 %26, 1
  store i64 %27, ptr %5, align 8, !tbaa !15
  br label %16, !llvm.loop !19

28:                                               ; preds = %20
  %29 = load i64, ptr %4, align 8, !tbaa !15
  %30 = getelementptr inbounds %class.bench, ptr %9, i32 0, i32 4
  %31 = load i64, ptr %30, align 8, !tbaa !9
  %32 = add nsw i64 %31, %29
  store i64 %32, ptr %30, align 8, !tbaa !9
  %33 = call noundef i64 @_ZN3sys8cpu_timeEv()
  %34 = load i64, ptr %3, align 8, !tbaa !15
  %35 = sub nsw i64 %33, %34
  %36 = getelementptr inbounds %class.bench, ptr %9, i32 0, i32 5
  store i64 %35, ptr %36, align 8, !tbaa !14
  %37 = getelementptr inbounds %class.bench, ptr %9, i32 0, i32 5
  %38 = load i64, ptr %37, align 8, !tbaa !14
  %39 = getelementptr inbounds %class.bench, ptr %9, i32 0, i32 2
  %40 = load i64, ptr %39, align 8, !tbaa !21
  %41 = icmp sge i64 %38, %40
  br i1 %41, label %46, label %42

42:                                               ; preds = %28
  %43 = getelementptr inbounds %class.bench, ptr %9, i32 0, i32 5
  %44 = load i64, ptr %43, align 8, !tbaa !14
  %45 = icmp sle i64 %44, 0
  br i1 %45, label %46, label %47

46:                                               ; preds = %42, %28
  br label %60

47:                                               ; preds = %42
  %48 = getelementptr inbounds %class.bench, ptr %9, i32 0, i32 4
  %49 = load i64, ptr %48, align 8, !tbaa !9
  %50 = getelementptr inbounds %class.bench, ptr %9, i32 0, i32 2
  %51 = load i64, ptr %50, align 8, !tbaa !21
  %52 = getelementptr inbounds %class.bench, ptr %9, i32 0, i32 5
  %53 = load i64, ptr %52, align 8, !tbaa !14
  %54 = sub nsw i64 %51, %53
  %55 = mul nsw i64 %49, %54
  %56 = getelementptr inbounds %class.bench, ptr %9, i32 0, i32 5
  %57 = load i64, ptr %56, align 8, !tbaa !14
  %58 = call noundef i64 @_ZN3sys5div64Ell(i64 noundef %55, i64 noundef %57)
  %59 = add nsw i64 2, %58
  store i64 %59, ptr %4, align 8, !tbaa !15
  br label %15, !llvm.loop !22

60:                                               ; preds = %46
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #4
  %61 = call noundef i64 @_ZN3sys8cpu_timeEv()
  store i64 %61, ptr %6, align 8, !tbaa !15
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #4
  store i64 0, ptr %7, align 8, !tbaa !15
  br label %62

62:                                               ; preds = %72, %60
  %63 = load i64, ptr %7, align 8, !tbaa !15
  %64 = getelementptr inbounds %class.bench, ptr %9, i32 0, i32 4
  %65 = load i64, ptr %64, align 8, !tbaa !9
  %66 = icmp slt i64 %63, %65
  br i1 %66, label %68, label %67

67:                                               ; preds = %62
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #4
  br label %75

68:                                               ; preds = %62
  %69 = load ptr, ptr %9, align 8, !tbaa !17
  %70 = getelementptr inbounds ptr, ptr %69, i64 2
  %71 = load ptr, ptr %70, align 8
  call void %71(ptr noundef nonnull align 8 dereferenceable(72) %9)
  br label %72

72:                                               ; preds = %68
  %73 = load i64, ptr %7, align 8, !tbaa !15
  %74 = add nsw i64 %73, 1
  store i64 %74, ptr %7, align 8, !tbaa !15
  br label %62, !llvm.loop !23

75:                                               ; preds = %67
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #4
  %76 = call noundef i64 @_ZN3sys8cpu_timeEv()
  %77 = load i64, ptr %6, align 8, !tbaa !15
  %78 = sub nsw i64 %76, %77
  store i64 %78, ptr %8, align 8, !tbaa !15
  %79 = getelementptr inbounds %class.bench, ptr %9, i32 0, i32 5
  %80 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3minIlERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %79, ptr noundef nonnull align 8 dereferenceable(8) %8)
  %81 = load i64, ptr %80, align 8, !tbaa !15
  %82 = getelementptr inbounds %class.bench, ptr %9, i32 0, i32 5
  %83 = load i64, ptr %82, align 8, !tbaa !14
  %84 = sub nsw i64 %83, %81
  store i64 %84, ptr %82, align 8, !tbaa !14
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #4
  ret void
}

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

declare noundef i64 @_ZN3sys8cpu_timeEv() #2

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

declare noundef i64 @_ZN3sys5div64Ell(i64 noundef, i64 noundef) #2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3minIlERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(8)) #3

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 = { 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 = { inlinehint 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 #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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !13, i64 56}
!10 = !{!"_ZTS5bench", !11, i64 8, !13, i64 40, !13, i64 48, !13, i64 56, !13, i64 64}
!11 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE", !12, i64 0, !13, i64 8, !7, i64 16}
!12 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_Alloc_hiderE", !6, i64 0}
!13 = !{!"long", !7, i64 0}
!14 = !{!10, !13, i64 64}
!15 = !{!13, !13, i64 0}
!16 = !{!10, !13, i64 48}
!17 = !{!18, !18, i64 0}
!18 = !{!"vtable pointer", !8, i64 0}
!19 = distinct !{!19, !20}
!20 = !{!"llvm.loop.mustprogress"}
!21 = !{!10, !13, i64 40}
!22 = distinct !{!22, !20}
!23 = distinct !{!23, !20}


; 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
define dso_local void @_ZN5bench3runEv(ptr noundef nonnull align 8 dereferenceable(72) %0) local_unnamed_addr #0 align 2 {
  %2 = alloca i64, align 8
  %3 = getelementptr inbounds i8, ptr %0, i64 56
  %4 = getelementptr inbounds i8, ptr %0, i64 64
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %3, i8 0, i64 16, i1 false)
  %5 = tail call noundef i64 @_ZN3sys8cpu_timeEv()
  %6 = getelementptr inbounds i8, ptr %0, i64 48
  %7 = load i64, ptr %6, align 8, !tbaa !5
  %8 = getelementptr inbounds i8, ptr %0, i64 40
  br label %9

9:                                                ; preds = %20, %1
  %.08 = phi i64 [ %7, %1 ], [ %25, %20 ]
  %10 = icmp sgt i64 %.08, 0
  br i1 %10, label %.lr.ph, label %._crit_edge

._crit_edge:                                      ; preds = %.lr.ph, %9
  %11 = load i64, ptr %3, align 8, !tbaa !13
  %12 = add nsw i64 %11, %.08
  store i64 %12, ptr %3, align 8, !tbaa !13
  %13 = tail call noundef i64 @_ZN3sys8cpu_timeEv()
  %14 = sub nsw i64 %13, %5
  store i64 %14, ptr %4, align 8, !tbaa !14
  %15 = load i64, ptr %8, align 8, !tbaa !15
  %.not = icmp sge i64 %14, %15
  %16 = icmp slt i64 %14, 1
  %or.cond = or i1 %16, %.not
  br i1 %or.cond, label %26, label %20

.lr.ph:                                           ; preds = %9, %.lr.ph
  %.0912 = phi i64 [ %19, %.lr.ph ], [ 0, %9 ]
  %17 = load ptr, ptr %0, align 8, !tbaa !16
  %18 = load ptr, ptr %17, align 8
  tail call void %18(ptr noundef nonnull align 8 dereferenceable(72) %0)
  %19 = add nuw nsw i64 %.0912, 1
  %exitcond.not = icmp eq i64 %19, %.08
  br i1 %exitcond.not, label %._crit_edge, label %.lr.ph, !llvm.loop !18

20:                                               ; preds = %._crit_edge
  %21 = load i64, ptr %3, align 8, !tbaa !13
  %22 = sub nsw i64 %15, %14
  %23 = mul nsw i64 %21, %22
  %24 = tail call noundef i64 @_ZN3sys5div64Ell(i64 noundef %23, i64 noundef %14)
  %25 = add nsw i64 %24, 2
  br label %9, !llvm.loop !20

26:                                               ; preds = %._crit_edge
  %27 = tail call noundef i64 @_ZN3sys8cpu_timeEv()
  %28 = load i64, ptr %3, align 8, !tbaa !13
  %29 = icmp sgt i64 %28, 0
  br i1 %29, label %.lr.ph15, label %._crit_edge16

._crit_edge16:                                    ; preds = %.lr.ph15, %26
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %2) #5
  %30 = tail call noundef i64 @_ZN3sys8cpu_timeEv()
  %31 = sub nsw i64 %30, %27
  store i64 %31, ptr %2, align 8, !tbaa !21
  %32 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3minIlERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %4, ptr noundef nonnull align 8 dereferenceable(8) %2)
  %33 = load i64, ptr %32, align 8, !tbaa !21
  %34 = load i64, ptr %4, align 8, !tbaa !14
  %35 = sub nsw i64 %34, %33
  store i64 %35, ptr %4, align 8, !tbaa !14
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #5
  ret void

.lr.ph15:                                         ; preds = %26, %.lr.ph15
  %.013 = phi i64 [ %39, %.lr.ph15 ], [ 0, %26 ]
  %36 = load ptr, ptr %0, align 8, !tbaa !16
  %37 = getelementptr inbounds i8, ptr %36, i64 16
  %38 = load ptr, ptr %37, align 8
  tail call void %38(ptr noundef nonnull align 8 dereferenceable(72) %0)
  %39 = add nuw nsw i64 %.013, 1
  %40 = load i64, ptr %3, align 8, !tbaa !13
  %41 = icmp slt i64 %39, %40
  br i1 %41, label %.lr.ph15, label %._crit_edge16, !llvm.loop !22
}

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

declare noundef i64 @_ZN3sys8cpu_timeEv() local_unnamed_addr #2

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

declare noundef i64 @_ZN3sys5div64Ell(i64 noundef, i64 noundef) local_unnamed_addr #2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3minIlERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #3

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

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 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 = { inlinehint 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 #4 = { nocallback nofree nounwind willreturn memory(argmem: write) }
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, !12, i64 48}
!6 = !{!"_ZTS5bench", !7, i64 8, !12, i64 40, !12, i64 48, !12, i64 56, !12, i64 64}
!7 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE", !8, i64 0, !12, i64 8, !10, i64 16}
!8 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_Alloc_hiderE", !9, i64 0}
!9 = !{!"any pointer", !10, i64 0}
!10 = !{!"omnipotent char", !11, i64 0}
!11 = !{!"Simple C++ TBAA"}
!12 = !{!"long", !10, i64 0}
!13 = !{!6, !12, i64 56}
!14 = !{!6, !12, i64 64}
!15 = !{!6, !12, i64 40}
!16 = !{!17, !17, i64 0}
!17 = !{!"vtable pointer", !11, i64 0}
!18 = distinct !{!18, !19}
!19 = !{!"llvm.loop.mustprogress"}
!20 = distinct !{!20, !19}
!21 = !{!12, !12, i64 0}
!22 = distinct !{!22, !19}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,MemCpyOptPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass