; LLVM IR from mitdbg/deneva :: transport/message.ll (ZN16YCSBQueryMessage11copy_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.YCSBQueryMessage = type { %class.QueryMessage, %class.Array.1 }
%class.QueryMessage = type { %class.Message, i64, i64 }
%class.Message = type { ptr, i32, i64, i64, i64, i64, i64, i64, double, double, double, double, double, double, double }
%class.Array.1 = type { ptr, i64, i64 }

@.str.1 = external hidden unnamed_addr constant [69 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [18 x i8], align 1
@__PRETTY_FUNCTION__._ZN16YCSBQueryMessage11copy_to_bufEPc = external hidden unnamed_addr constant [51 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 nounwind uwtable
declare dso_local noundef i64 @_ZN12QueryMessage8get_sizeEv(ptr noundef nonnull align 8 dereferenceable(136)) unnamed_addr #3 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN12QueryMessage11copy_to_bufEPc(ptr noundef nonnull align 8 dereferenceable(136), ptr noundef) unnamed_addr #4 align 2

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

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN16YCSBQueryMessage11copy_to_bufEPc(ptr noundef nonnull align 8 dereferenceable(160) %0, ptr noundef %1) unnamed_addr #4 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 @_ZN12QueryMessage11copy_to_bufEPc(ptr noundef nonnull align 8 dereferenceable(136) %9, ptr noundef %10)
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #5
  %11 = call noundef i64 @_ZN12QueryMessage8get_sizeEv(ptr noundef nonnull align 8 dereferenceable(136) %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.YCSBQueryMessage, 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 = %35, %2
  %20 = load i64, ptr %7, align 8, !tbaa !9
  %21 = getelementptr inbounds %class.YCSBQueryMessage, 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 %38

25:                                               ; preds = %19
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #5
  %26 = getelementptr inbounds %class.YCSBQueryMessage, 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 %4, align 8, !tbaa !5
  %30 = load i64, ptr %5, align 8, !tbaa !9
  %31 = getelementptr inbounds i8, ptr %29, i64 %30
  %32 = load ptr, ptr %8, align 8, !tbaa !5
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %31, ptr align 1 %32, i64 24, i1 false)
  %33 = load i64, ptr %5, align 8, !tbaa !9
  %34 = add i64 %33, 24
  store i64 %34, ptr %5, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #5
  br label %35

35:                                               ; preds = %25
  %36 = load i64, ptr %7, align 8, !tbaa !9
  %37 = add i64 %36, 1
  store i64 %37, ptr %7, align 8, !tbaa !9
  br label %19, !llvm.loop !11

38:                                               ; preds = %24
  %39 = load i64, ptr %5, align 8, !tbaa !9
  %40 = load ptr, ptr %9, align 8, !tbaa !13
  %41 = getelementptr inbounds ptr, ptr %40, i64 2
  %42 = load ptr, ptr %41, align 8
  %43 = call noundef i64 %42(ptr noundef nonnull align 8 dereferenceable(160) %9)
  %44 = icmp eq i64 %39, %43
  br i1 %44, label %45, label %46

45:                                               ; preds = %38
  br label %48

46:                                               ; preds = %38
  call void @__assert_fail(ptr noundef @.str.9, ptr noundef @.str.1, i32 noundef 1381, ptr noundef @__PRETTY_FUNCTION__._ZN16YCSBQueryMessage11copy_to_bufEPc) #6
  unreachable

47:                                               ; No predecessors!
  br label %48

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

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 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 = { 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 #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 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = !{!14, !14, i64 0}
!14 = !{!"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
@.str.9 = external hidden unnamed_addr constant [18 x i8], align 1
@__PRETTY_FUNCTION__._ZN16YCSBQueryMessage11copy_to_bufEPc = external hidden unnamed_addr constant [51 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 nounwind uwtable
declare dso_local noundef i64 @_ZN12QueryMessage8get_sizeEv(ptr noundef nonnull align 8 dereferenceable(136)) unnamed_addr #2 align 2

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

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN16YCSBQueryMessage11copy_to_bufEPc(ptr noundef nonnull align 8 dereferenceable(160) %0, ptr noundef %1) unnamed_addr #3 align 2 {
  tail call void @_ZN12QueryMessage11copy_to_bufEPc(ptr noundef nonnull align 8 dereferenceable(136) %0, ptr noundef %1)
  %3 = tail call noundef i64 @_ZN12QueryMessage8get_sizeEv(ptr noundef nonnull align 8 dereferenceable(136) %0)
  %4 = getelementptr inbounds i8, ptr %0, i64 136
  %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 = %.lr.ph, %2
  %.0.lcssa = phi i64 [ %7, %2 ], [ %16, %.lr.ph ]
  %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(160) %0)
  %13 = icmp eq i64 %.0.lcssa, %12
  br i1 %13, label %21, label %20

.lr.ph:                                           ; preds = %2, %.lr.ph
  %.014 = phi i64 [ %16, %.lr.ph ], [ %7, %2 ]
  %.01213 = phi i64 [ %17, %.lr.ph ], [ 0, %2 ]
  %14 = tail call noundef ptr @_ZN5ArrayIP12ycsb_requestEixEm(ptr noundef nonnull align 8 dereferenceable(24) %4, i64 noundef %.01213)
  %15 = getelementptr inbounds i8, ptr %1, i64 %.014
  tail call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 1 dereferenceable(24) %15, ptr noundef nonnull align 1 dereferenceable(24) %14, i64 24, i1 false)
  %16 = add i64 %.014, 24
  %17 = add nuw i64 %.01213, 1
  %18 = tail call noundef i64 @_ZN5ArrayIP12ycsb_requestE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %4)
  %19 = icmp ult i64 %17, %18
  br i1 %19, label %.lr.ph, label %._crit_edge, !llvm.loop !8

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

21:                                               ; preds = %._crit_edge
  ret void
}

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 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 #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 = { 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 = distinct !{!8, !9}
!9 = !{!"llvm.loop.mustprogress"}


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