; LLVM IR from mitdbg/deneva :: transport/message.ll (ZN22YCSBClientQueryMessage11copy_to_bufEPc)

; 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.YCSBClientQueryMessage = type { %class.ClientQueryMessage, %class.Array.1 }
%class.ClientQueryMessage = type { %class.Message, i64, i64, i64, i64, %class.Array.0 }
%class.Message = type { ptr, i32, i64, i64, i64, i64, i64, i64, double, double, double, double, double, double, double }
%class.Array.0 = type { ptr, i64, i64 }
%class.Array.1 = type { ptr, i64, i64 }
%class.ycsb_request = type <{ i32, [4 x i8], i64, i8, [7 x i8] }>

@.str.1 = external hidden unnamed_addr constant [69 x i8], align 1
@g_synth_table_size = external global i64, align 8
@.str.8 = external hidden unnamed_addr constant [30 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [18 x i8], align 1
@__PRETTY_FUNCTION__._ZN22YCSBClientQueryMessage11copy_to_bufEPc = external hidden unnamed_addr constant [57 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 nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #1

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #2

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef i64 @_ZN18ClientQueryMessage8get_sizeEv(ptr noundef nonnull align 8 dereferenceable(176)) unnamed_addr #3 align 2

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN22YCSBClientQueryMessage11copy_to_bufEPc(ptr noundef nonnull align 8 dereferenceable(200) %0, ptr noundef %1) unnamed_addr #3 align 2 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i64, align 8
  %6 = alloca i64, align 8
  %7 = alloca i64, align 8
  %8 = alloca ptr, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  %9 = load ptr, ptr %3, align 8
  %10 = load ptr, ptr %4, align 8, !tbaa !5
  call void @_ZN18ClientQueryMessage11copy_to_bufEPc(ptr noundef nonnull align 8 dereferenceable(176) %9, ptr noundef %10)
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #5
  %11 = call noundef i64 @_ZN18ClientQueryMessage8get_sizeEv(ptr noundef nonnull align 8 dereferenceable(176) %9)
  store i64 %11, ptr %5, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #5
  %12 = getelementptr inbounds %class.YCSBClientQueryMessage, ptr %9, i32 0, i32 1
  %13 = call noundef i64 @_ZN5ArrayIP12ycsb_requestE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %12)
  store i64 %13, ptr %6, align 8, !tbaa !9
  %14 = load ptr, ptr %4, align 8, !tbaa !5
  %15 = load i64, ptr %5, align 8, !tbaa !9
  %16 = getelementptr inbounds i8, ptr %14, i64 %15
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %16, ptr align 8 %6, i64 8, i1 false)
  %17 = load i64, ptr %5, align 8, !tbaa !9
  %18 = add i64 %17, 8
  store i64 %18, ptr %5, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #5
  store i64 0, ptr %7, align 8, !tbaa !9
  br label %19

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

24:                                               ; preds = %19
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #5
  br label %47

25:                                               ; preds = %19
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #5
  %26 = getelementptr inbounds %class.YCSBClientQueryMessage, ptr %9, i32 0, i32 1
  %27 = load i64, ptr %7, align 8, !tbaa !9
  %28 = call noundef ptr @_ZN5ArrayIP12ycsb_requestEixEm(ptr noundef nonnull align 8 dereferenceable(24) %26, i64 noundef %27)
  store ptr %28, ptr %8, align 8, !tbaa !5
  %29 = load ptr, ptr %8, align 8, !tbaa !5
  %30 = getelementptr inbounds %class.ycsb_request, ptr %29, i32 0, i32 2
  %31 = load i64, ptr %30, align 8, !tbaa !11
  %32 = load i64, ptr @g_synth_table_size, align 8, !tbaa !9
  %33 = icmp ult i64 %31, %32
  br i1 %33, label %34, label %35

34:                                               ; preds = %25
  br label %37

35:                                               ; preds = %25
  call void @__assert_fail(ptr noundef @.str.8, ptr noundef @.str.1, i32 noundef 521, ptr noundef @__PRETTY_FUNCTION__._ZN22YCSBClientQueryMessage11copy_to_bufEPc) #6
  unreachable

36:                                               ; No predecessors!
  br label %37

37:                                               ; preds = %36, %34
  %38 = load ptr, ptr %4, align 8, !tbaa !5
  %39 = load i64, ptr %5, align 8, !tbaa !9
  %40 = getelementptr inbounds i8, ptr %38, i64 %39
  %41 = load ptr, ptr %8, align 8, !tbaa !5
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %40, ptr align 1 %41, i64 24, i1 false)
  %42 = load i64, ptr %5, align 8, !tbaa !9
  %43 = add i64 %42, 24
  store i64 %43, ptr %5, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #5
  br label %44

44:                                               ; preds = %37
  %45 = load i64, ptr %7, align 8, !tbaa !9
  %46 = add i64 %45, 1
  store i64 %46, ptr %7, align 8, !tbaa !9
  br label %19, !llvm.loop !14

47:                                               ; preds = %24
  %48 = load i64, ptr %5, align 8, !tbaa !9
  %49 = load ptr, ptr %9, align 8, !tbaa !16
  %50 = getelementptr inbounds ptr, ptr %49, i64 2
  %51 = load ptr, ptr %50, align 8
  %52 = call noundef i64 %51(ptr noundef nonnull align 8 dereferenceable(200) %9)
  %53 = icmp eq i64 %48, %52
  br i1 %53, label %54, label %55

54:                                               ; preds = %47
  br label %57

55:                                               ; preds = %47
  call void @__assert_fail(ptr noundef @.str.9, ptr noundef @.str.1, i32 noundef 525, ptr noundef @__PRETTY_FUNCTION__._ZN22YCSBClientQueryMessage11copy_to_bufEPc) #6
  unreachable

56:                                               ; No predecessors!
  br label %57

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN18ClientQueryMessage11copy_to_bufEPc(ptr noundef nonnull align 8 dereferenceable(176), ptr noundef) unnamed_addr #3 align 2

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { noreturn 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 = { 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 #4 = { 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 #5 = { nounwind }
attributes #6 = { noreturn 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, !10, i64 0}
!10 = !{!"long", !7, i64 0}
!11 = !{!12, !10, i64 8}
!12 = !{!"_ZTS12ycsb_request", !13, i64 0, !10, i64 8, !7, i64 16}
!13 = !{!"_ZTS8access_t", !7, i64 0}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.mustprogress"}
!16 = !{!17, !17, i64 0}
!17 = !{!"vtable pointer", !8, i64 0}


; 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.1 = external hidden unnamed_addr constant [69 x i8], align 1
@g_synth_table_size = external local_unnamed_addr global i64, align 8
@.str.8 = external hidden unnamed_addr constant [30 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [18 x i8], align 1
@__PRETTY_FUNCTION__._ZN22YCSBClientQueryMessage11copy_to_bufEPc = external hidden unnamed_addr constant [57 x i8], align 1

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #0

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
declare dso_local noundef i64 @_ZN18ClientQueryMessage8get_sizeEv(ptr noundef nonnull align 8 dereferenceable(176)) unnamed_addr #2 align 2

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN22YCSBClientQueryMessage11copy_to_bufEPc(ptr noundef nonnull align 8 dereferenceable(200) %0, ptr noundef %1) unnamed_addr #2 align 2 {
  tail call void @_ZN18ClientQueryMessage11copy_to_bufEPc(ptr noundef nonnull align 8 dereferenceable(176) %0, ptr noundef %1)
  %3 = tail call noundef i64 @_ZN18ClientQueryMessage8get_sizeEv(ptr noundef nonnull align 8 dereferenceable(176) %0)
  %4 = getelementptr inbounds i8, ptr %0, i64 176
  %5 = tail call noundef i64 @_ZN5ArrayIP12ycsb_requestE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %4)
  %6 = getelementptr inbounds i8, ptr %1, i64 %3
  store i64 %5, ptr %6, align 1
  %7 = add i64 %3, 8
  %8 = tail call noundef i64 @_ZN5ArrayIP12ycsb_requestE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %4)
  %.not = icmp eq i64 %8, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph

._crit_edge:                                      ; preds = %20, %2
  %.0.lcssa = phi i64 [ %7, %2 ], [ %22, %20 ]
  %9 = load ptr, ptr %0, align 8, !tbaa !5
  %10 = getelementptr inbounds i8, ptr %9, i64 16
  %11 = load ptr, ptr %10, align 8
  %12 = tail call noundef i64 %11(ptr noundef nonnull align 8 dereferenceable(200) %0)
  %13 = icmp eq i64 %.0.lcssa, %12
  br i1 %13, label %27, label %26

.lr.ph:                                           ; preds = %2, %20
  %.016 = phi i64 [ %22, %20 ], [ %7, %2 ]
  %.01315 = phi i64 [ %23, %20 ], [ 0, %2 ]
  %14 = tail call noundef ptr @_ZN5ArrayIP12ycsb_requestEixEm(ptr noundef nonnull align 8 dereferenceable(24) %4, i64 noundef %.01315)
  %15 = getelementptr inbounds i8, ptr %14, i64 8
  %16 = load i64, ptr %15, align 8, !tbaa !8
  %17 = load i64, ptr @g_synth_table_size, align 8, !tbaa !13
  %18 = icmp ult i64 %16, %17
  br i1 %18, label %20, label %19

19:                                               ; preds = %.lr.ph
  tail call void @__assert_fail(ptr noundef nonnull @.str.8, ptr noundef nonnull @.str.1, i32 noundef 521, ptr noundef nonnull @__PRETTY_FUNCTION__._ZN22YCSBClientQueryMessage11copy_to_bufEPc) #4
  unreachable

20:                                               ; preds = %.lr.ph
  %21 = getelementptr inbounds i8, ptr %1, i64 %.016
  tail call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 1 dereferenceable(24) %21, ptr noundef nonnull align 1 dereferenceable(24) %14, i64 24, i1 false)
  %22 = add i64 %.016, 24
  %23 = add nuw i64 %.01315, 1
  %24 = tail call noundef i64 @_ZN5ArrayIP12ycsb_requestE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %4)
  %25 = icmp ult i64 %23, %24
  br i1 %25, label %.lr.ph, label %._crit_edge, !llvm.loop !14

26:                                               ; preds = %._crit_edge
  tail call void @__assert_fail(ptr noundef nonnull @.str.9, ptr noundef nonnull @.str.1, i32 noundef 525, ptr noundef nonnull @__PRETTY_FUNCTION__._ZN22YCSBClientQueryMessage11copy_to_bufEPc) #4
  unreachable

27:                                               ; preds = %._crit_edge
  ret void
}

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN18ClientQueryMessage11copy_to_bufEPc(ptr noundef nonnull align 8 dereferenceable(176), ptr noundef) unnamed_addr #2 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 #3 align 2

attributes #0 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { noreturn 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 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 = { 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 = { noreturn 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 = !{!"vtable pointer", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}
!8 = !{!9, !12, i64 8}
!9 = !{!"_ZTS12ycsb_request", !10, i64 0, !12, i64 8, !11, i64 16}
!10 = !{!"_ZTS8access_t", !11, i64 0}
!11 = !{!"omnipotent char", !7, i64 0}
!12 = !{!"long", !11, i64 0}
!13 = !{!12, !12, i64 0}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.mustprogress"}


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