; LLVM IR from mitdbg/deneva :: benchmarks/ycsb_txn.ll (ZN14YCSBTxnManager20copy_remote_requestsEP16YCSBQueryMessage)

; 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.TxnManager = type { ptr, ptr, ptr, i8, ptr, i32, i8, i32, i32, i8, i64, i64, i64, i64, ptr, ptr, ptr, i64, i8, i8, ptr, ptr, i64, i64, i64, %class.TxnStats, i32, i32, i32, i8, i32, %class.Array, i32, ptr, ptr, i32, %union.sem_t }
%class.TxnStats = type { i64, i64, i64, i64, i64, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, i64, i64, double, double, double, double, double, double, double, double }
%class.Array = type { ptr, i64, i64 }
%union.sem_t = type { i64, [24 x i8] }
%class.YCSBQuery = type { %class.BaseQuery, %class.Array.7 }
%class.BaseQuery = type { ptr, i64, %class.Array.6, %class.Array.6, %class.Array.6, %class.Array.6 }
%class.Array.6 = type { ptr, i64, i64 }
%class.Array.7 = type { ptr, i64, i64 }
%class.YCSBTxnManager = type { %class.TxnManager, ptr, ptr, i32, i64 }
%class.ycsb_request = type <{ i32, [4 x i8], i64, i8, [7 x i8] }>

@g_node_cnt = external global i32, align 4

; 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: mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZN5ArrayIP12ycsb_requestE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24)) #1 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZN14YCSBTxnManager16is_local_requestEm(ptr noundef nonnull align 8 dereferenceable(576), i64 noundef) #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZN5ArrayIP12ycsb_requestEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) #1 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN14YCSBTxnManager20copy_remote_requestsEP16YCSBQueryMessage(ptr noundef nonnull align 8 dereferenceable(576) %0, ptr noundef %1) #2 align 2 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i64, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  %7 = load ptr, ptr %3, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #4
  %8 = getelementptr inbounds %class.TxnManager, ptr %7, i32 0, i32 21
  %9 = load ptr, ptr %8, align 8, !tbaa !9
  store ptr %9, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #4
  %10 = load ptr, ptr %5, align 8, !tbaa !5
  %11 = getelementptr inbounds %class.YCSBQuery, ptr %10, i32 0, i32 1
  %12 = getelementptr inbounds %class.YCSBTxnManager, ptr %7, i32 0, i32 4
  %13 = load i64, ptr %12, align 8, !tbaa !19
  %14 = call noundef ptr @_ZN5ArrayIP12ycsb_requestEixEm(ptr noundef nonnull align 8 dereferenceable(24) %11, i64 noundef %13)
  %15 = getelementptr inbounds %class.ycsb_request, ptr %14, i32 0, i32 2
  %16 = load i64, ptr %15, align 8, !tbaa !22
  %17 = load i32, ptr @g_node_cnt, align 4, !tbaa !24
  %18 = zext i32 %17 to i64
  %19 = urem i64 %16, %18
  store i64 %19, ptr %6, align 8, !tbaa !25
  br label %20

20:                                               ; preds = %46, %2
  %21 = getelementptr inbounds %class.YCSBTxnManager, ptr %7, i32 0, i32 4
  %22 = load i64, ptr %21, align 8, !tbaa !19
  %23 = load ptr, ptr %5, align 8, !tbaa !5
  %24 = getelementptr inbounds %class.YCSBQuery, ptr %23, i32 0, i32 1
  %25 = call noundef i64 @_ZN5ArrayIP12ycsb_requestE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %24)
  %26 = icmp ult i64 %22, %25
  br i1 %26, label %27, label %44

27:                                               ; preds = %20
  %28 = getelementptr inbounds %class.YCSBTxnManager, ptr %7, i32 0, i32 4
  %29 = load i64, ptr %28, align 8, !tbaa !19
  %30 = call noundef zeroext i1 @_ZN14YCSBTxnManager16is_local_requestEm(ptr noundef nonnull align 8 dereferenceable(576) %7, i64 noundef %29)
  br i1 %30, label %44, label %31

31:                                               ; preds = %27
  %32 = load ptr, ptr %5, align 8, !tbaa !5
  %33 = getelementptr inbounds %class.YCSBQuery, ptr %32, i32 0, i32 1
  %34 = getelementptr inbounds %class.YCSBTxnManager, ptr %7, i32 0, i32 4
  %35 = load i64, ptr %34, align 8, !tbaa !19
  %36 = call noundef ptr @_ZN5ArrayIP12ycsb_requestEixEm(ptr noundef nonnull align 8 dereferenceable(24) %33, i64 noundef %35)
  %37 = getelementptr inbounds %class.ycsb_request, ptr %36, i32 0, i32 2
  %38 = load i64, ptr %37, align 8, !tbaa !22
  %39 = load i32, ptr @g_node_cnt, align 4, !tbaa !24
  %40 = zext i32 %39 to i64
  %41 = urem i64 %38, %40
  %42 = load i64, ptr %6, align 8, !tbaa !25
  %43 = icmp eq i64 %41, %42
  br label %44

44:                                               ; preds = %31, %27, %20
  %45 = phi i1 [ false, %27 ], [ false, %20 ], [ %43, %31 ]
  br i1 %45, label %46, label %52

46:                                               ; preds = %44
  %47 = load ptr, ptr %5, align 8, !tbaa !5
  %48 = load ptr, ptr %4, align 8, !tbaa !5
  %49 = getelementptr inbounds %class.YCSBTxnManager, ptr %7, i32 0, i32 4
  %50 = load i64, ptr %49, align 8, !tbaa !19
  %51 = add i64 %50, 1
  store i64 %51, ptr %49, align 8, !tbaa !19
  call void @_ZN9YCSBQuery19copy_request_to_msgEPS_P16YCSBQueryMessagem(ptr noundef %47, ptr noundef %48, i64 noundef %50)
  br label %20, !llvm.loop !26

52:                                               ; preds = %44
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #4
  ret void
}

declare void @_ZN9YCSBQuery19copy_request_to_msgEPS_P16YCSBQueryMessagem(ptr noundef, ptr noundef, i64 noundef) #3

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { 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 #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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !6, i64 144}
!10 = !{!"_ZTS10TxnManager", !6, i64 8, !6, i64 16, !11, i64 24, !6, i64 32, !12, i64 40, !11, i64 44, !12, i64 48, !12, i64 52, !11, i64 56, !13, i64 64, !13, i64 72, !13, i64 80, !13, i64 88, !6, i64 96, !6, i64 104, !6, i64 112, !13, i64 120, !11, i64 128, !11, i64 129, !6, i64 136, !6, i64 144, !13, i64 152, !13, i64 160, !13, i64 168, !14, i64 176, !12, i64 432, !12, i64 436, !12, i64 440, !11, i64 444, !16, i64 448, !17, i64 456, !12, i64 480, !6, i64 488, !6, i64 496, !18, i64 504, !7, i64 512}
!11 = !{!"bool", !7, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!"long", !7, i64 0}
!14 = !{!"_ZTS8TxnStats", !13, i64 0, !13, i64 8, !13, i64 16, !13, i64 24, !13, i64 32, !15, i64 40, !15, i64 48, !15, i64 56, !15, i64 64, !15, i64 72, !15, i64 80, !15, i64 88, !15, i64 96, !15, i64 104, !15, i64 112, !15, i64 120, !15, i64 128, !15, i64 136, !15, i64 144, !15, i64 152, !15, i64 160, !15, i64 168, !13, i64 176, !13, i64 184, !15, i64 192, !15, i64 200, !15, i64 208, !15, i64 216, !15, i64 224, !15, i64 232, !15, i64 240, !15, i64 248}
!15 = !{!"double", !7, i64 0}
!16 = !{!"_ZTS12CALVIN_PHASE", !7, i64 0}
!17 = !{!"_ZTS5ArrayIP5row_tE", !6, i64 0, !13, i64 8, !13, i64 16}
!18 = !{!"_ZTS8access_t", !7, i64 0}
!19 = !{!20, !13, i64 568}
!20 = !{!"_ZTS14YCSBTxnManager", !10, i64 0, !6, i64 544, !6, i64 552, !21, i64 560, !13, i64 568}
!21 = !{!"_ZTS14YCSBRemTxnType", !7, i64 0}
!22 = !{!23, !13, i64 8}
!23 = !{!"_ZTS12ycsb_request", !18, i64 0, !13, i64 8, !7, i64 16}
!24 = !{!12, !12, i64 0}
!25 = !{!13, !13, i64 0}
!26 = distinct !{!26, !27}
!27 = !{!"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"

@g_node_cnt = external local_unnamed_addr global i32, align 4

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZN5ArrayIP12ycsb_requestE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZN14YCSBTxnManager16is_local_requestEm(ptr noundef nonnull align 8 dereferenceable(576), i64 noundef) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZN5ArrayIP12ycsb_requestEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN14YCSBTxnManager20copy_remote_requestsEP16YCSBQueryMessage(ptr noundef nonnull align 8 dereferenceable(576) %0, ptr noundef %1) local_unnamed_addr #1 align 2 {
  %3 = getelementptr inbounds i8, ptr %0, i64 144
  %4 = load ptr, ptr %3, align 8, !tbaa !5
  %5 = getelementptr inbounds i8, ptr %4, i64 112
  %6 = getelementptr inbounds i8, ptr %0, i64 568
  %7 = load i64, ptr %6, align 8, !tbaa !18
  %8 = tail call noundef ptr @_ZN5ArrayIP12ycsb_requestEixEm(ptr noundef nonnull align 8 dereferenceable(24) %5, i64 noundef %7)
  %9 = getelementptr inbounds i8, ptr %8, i64 8
  %10 = load i64, ptr %9, align 8, !tbaa !21
  %11 = load i32, ptr @g_node_cnt, align 4, !tbaa !23
  %12 = zext i32 %11 to i64
  %13 = urem i64 %10, %12
  %14 = load i64, ptr %6, align 8, !tbaa !18
  %15 = tail call noundef i64 @_ZN5ArrayIP12ycsb_requestE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %5)
  %16 = icmp ult i64 %14, %15
  br i1 %16, label %.lr.ph, label %.critedge

.lr.ph:                                           ; preds = %2, %28
  %17 = load i64, ptr %6, align 8, !tbaa !18
  %18 = tail call noundef zeroext i1 @_ZN14YCSBTxnManager16is_local_requestEm(ptr noundef nonnull align 8 dereferenceable(576) %0, i64 noundef %17)
  br i1 %18, label %.critedge, label %19

19:                                               ; preds = %.lr.ph
  %20 = load i64, ptr %6, align 8, !tbaa !18
  %21 = tail call noundef ptr @_ZN5ArrayIP12ycsb_requestEixEm(ptr noundef nonnull align 8 dereferenceable(24) %5, i64 noundef %20)
  %22 = getelementptr inbounds i8, ptr %21, i64 8
  %23 = load i64, ptr %22, align 8, !tbaa !21
  %24 = load i32, ptr @g_node_cnt, align 4, !tbaa !23
  %25 = zext i32 %24 to i64
  %26 = urem i64 %23, %25
  %27 = icmp eq i64 %26, %13
  br i1 %27, label %28, label %.critedge

28:                                               ; preds = %19
  %29 = load i64, ptr %6, align 8, !tbaa !18
  %30 = add i64 %29, 1
  store i64 %30, ptr %6, align 8, !tbaa !18
  tail call void @_ZN9YCSBQuery19copy_request_to_msgEPS_P16YCSBQueryMessagem(ptr noundef %4, ptr noundef %1, i64 noundef %29)
  %31 = load i64, ptr %6, align 8, !tbaa !18
  %32 = tail call noundef i64 @_ZN5ArrayIP12ycsb_requestE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %5)
  %33 = icmp ult i64 %31, %32
  br i1 %33, label %.lr.ph, label %.critedge, !llvm.loop !24

.critedge:                                        ; preds = %19, %28, %.lr.ph, %2
  ret void
}

declare void @_ZN9YCSBQuery19copy_request_to_msgEPS_P16YCSBQueryMessagem(ptr noundef, ptr noundef, i64 noundef) local_unnamed_addr #2

attributes #0 = { 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 #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 = { "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" }

!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, !7, i64 144}
!6 = !{!"_ZTS10TxnManager", !7, i64 8, !7, i64 16, !10, i64 24, !7, i64 32, !11, i64 40, !10, i64 44, !11, i64 48, !11, i64 52, !10, i64 56, !12, i64 64, !12, i64 72, !12, i64 80, !12, i64 88, !7, i64 96, !7, i64 104, !7, i64 112, !12, i64 120, !10, i64 128, !10, i64 129, !7, i64 136, !7, i64 144, !12, i64 152, !12, i64 160, !12, i64 168, !13, i64 176, !11, i64 432, !11, i64 436, !11, i64 440, !10, i64 444, !15, i64 448, !16, i64 456, !11, i64 480, !7, i64 488, !7, i64 496, !17, i64 504, !8, i64 512}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"bool", !8, i64 0}
!11 = !{!"int", !8, i64 0}
!12 = !{!"long", !8, i64 0}
!13 = !{!"_ZTS8TxnStats", !12, i64 0, !12, i64 8, !12, i64 16, !12, i64 24, !12, i64 32, !14, i64 40, !14, i64 48, !14, i64 56, !14, i64 64, !14, i64 72, !14, i64 80, !14, i64 88, !14, i64 96, !14, i64 104, !14, i64 112, !14, i64 120, !14, i64 128, !14, i64 136, !14, i64 144, !14, i64 152, !14, i64 160, !14, i64 168, !12, i64 176, !12, i64 184, !14, i64 192, !14, i64 200, !14, i64 208, !14, i64 216, !14, i64 224, !14, i64 232, !14, i64 240, !14, i64 248}
!14 = !{!"double", !8, i64 0}
!15 = !{!"_ZTS12CALVIN_PHASE", !8, i64 0}
!16 = !{!"_ZTS5ArrayIP5row_tE", !7, i64 0, !12, i64 8, !12, i64 16}
!17 = !{!"_ZTS8access_t", !8, i64 0}
!18 = !{!19, !12, i64 568}
!19 = !{!"_ZTS14YCSBTxnManager", !6, i64 0, !7, i64 544, !7, i64 552, !20, i64 560, !12, i64 568}
!20 = !{!"_ZTS14YCSBRemTxnType", !8, i64 0}
!21 = !{!22, !12, i64 8}
!22 = !{!"_ZTS12ycsb_request", !17, i64 0, !12, i64 8, !8, i64 16}
!23 = !{!11, !11, i64 0}
!24 = distinct !{!24, !25}
!25 = !{!"llvm.loop.mustprogress"}


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