; LLVM IR from mitdbg/deneva :: transport/message.ll (ZN22YCSBClientQueryMessage13copy_from_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.mem_alloc = type { i8 }
%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
@mem_allocator = external global %class.mem_alloc, align 1
@g_synth_table_size = external global i64, align 8
@.str.8 = external hidden unnamed_addr constant [30 x i8], align 1
@__PRETTY_FUNCTION__._ZN22YCSBClientQueryMessage13copy_from_bufEPc = external hidden unnamed_addr constant [59 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [18 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 uwtable
define dso_local void @_ZN22YCSBClientQueryMessage13copy_from_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 @_ZN18ClientQueryMessage13copy_from_bufEPc(ptr noundef nonnull align 8 dereferenceable(176) %9, ptr noundef %10)
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #6
  %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) #6
  %12 = load ptr, ptr %4, align 8, !tbaa !5
  %13 = load i64, ptr %5, align 8, !tbaa !9
  %14 = getelementptr inbounds i8, ptr %12, i64 %13
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %6, ptr align 1 %14, i64 8, i1 false)
  %15 = load i64, ptr %5, align 8, !tbaa !9
  %16 = add i64 %15, 8
  store i64 %16, ptr %5, align 8, !tbaa !9
  %17 = getelementptr inbounds %class.YCSBClientQueryMessage, ptr %9, i32 0, i32 1
  %18 = load i64, ptr %6, align 8, !tbaa !9
  call void @_ZN5ArrayIP12ycsb_requestE4initEm(ptr noundef nonnull align 8 dereferenceable(24) %17, i64 noundef %18)
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #6
  store i64 0, ptr %7, align 8, !tbaa !9
  br label %19

19:                                               ; preds = %43, %2
  %20 = load i64, ptr %7, align 8, !tbaa !9
  %21 = load i64, ptr %6, align 8, !tbaa !9
  %22 = icmp ult i64 %20, %21
  br i1 %22, label %24, label %23

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

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

37:                                               ; preds = %24
  br label %40

38:                                               ; preds = %24
  call void @__assert_fail(ptr noundef @.str.8, ptr noundef @.str.1, i32 noundef 506, ptr noundef @__PRETTY_FUNCTION__._ZN22YCSBClientQueryMessage13copy_from_bufEPc) #7
  unreachable

39:                                               ; No predecessors!
  br label %40

40:                                               ; preds = %39, %37
  %41 = getelementptr inbounds %class.YCSBClientQueryMessage, ptr %9, i32 0, i32 1
  %42 = load ptr, ptr %8, align 8, !tbaa !5
  call void @_ZN5ArrayIP12ycsb_requestE3addES1_(ptr noundef nonnull align 8 dereferenceable(24) %41, ptr noundef %42)
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #6
  br label %43

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

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

53:                                               ; preds = %46
  br label %56

54:                                               ; preds = %46
  call void @__assert_fail(ptr noundef @.str.9, ptr noundef @.str.1, i32 noundef 509, ptr noundef @__PRETTY_FUNCTION__._ZN22YCSBClientQueryMessage13copy_from_bufEPc) #7
  unreachable

55:                                               ; No predecessors!
  br label %56

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

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

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

declare noundef ptr @_ZN9mem_alloc5allocEm(ptr noundef nonnull align 1 dereferenceable(1), i64 noundef) #4

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN5ArrayIP12ycsb_requestE3addES1_(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef) #5 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 = { "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 = { 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 #6 = { nounwind }
attributes #7 = { 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"

%class.mem_alloc = type { i8 }

@.str.1 = external hidden unnamed_addr constant [69 x i8], align 1
@mem_allocator = external global %class.mem_alloc, 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
@__PRETTY_FUNCTION__._ZN22YCSBClientQueryMessage13copy_from_bufEPc = external hidden unnamed_addr constant [59 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [18 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 uwtable
define dso_local void @_ZN22YCSBClientQueryMessage13copy_from_bufEPc(ptr noundef nonnull align 8 dereferenceable(200) %0, ptr noundef %1) unnamed_addr #2 align 2 {
  tail call void @_ZN18ClientQueryMessage13copy_from_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 %1, i64 %3
  %.0.copyload = load i64, ptr %4, align 1
  %5 = add i64 %3, 8
  %6 = getelementptr inbounds i8, ptr %0, i64 176
  tail call void @_ZN5ArrayIP12ycsb_requestE4initEm(ptr noundef nonnull align 8 dereferenceable(24) %6, i64 noundef %.0.copyload)
  %.not = icmp eq i64 %.0.copyload, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph

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

.lr.ph:                                           ; preds = %2, %19
  %.018 = phi i64 [ %20, %19 ], [ %5, %2 ]
  %.01517 = phi i64 [ %21, %19 ], [ 0, %2 ]
  %12 = tail call noundef ptr @_ZN9mem_alloc5allocEm(ptr noundef nonnull align 1 dereferenceable(1) @mem_allocator, i64 noundef 24)
  %13 = getelementptr inbounds i8, ptr %1, i64 %.018
  tail call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(24) %12, ptr noundef nonnull align 1 dereferenceable(24) %13, i64 24, i1 false)
  %14 = getelementptr inbounds i8, ptr %12, i64 8
  %15 = load i64, ptr %14, align 8, !tbaa !8
  %16 = load i64, ptr @g_synth_table_size, align 8, !tbaa !13
  %17 = icmp ult i64 %15, %16
  br i1 %17, label %19, label %18

18:                                               ; preds = %.lr.ph
  tail call void @__assert_fail(ptr noundef nonnull @.str.8, ptr noundef nonnull @.str.1, i32 noundef 506, ptr noundef nonnull @__PRETTY_FUNCTION__._ZN22YCSBClientQueryMessage13copy_from_bufEPc) #5
  unreachable

19:                                               ; preds = %.lr.ph
  %20 = add i64 %.018, 24
  tail call void @_ZN5ArrayIP12ycsb_requestE3addES1_(ptr noundef nonnull align 8 dereferenceable(24) %6, ptr noundef nonnull %12)
  %21 = add nuw i64 %.01517, 1
  %exitcond.not = icmp eq i64 %21, %.0.copyload
  br i1 %exitcond.not, label %._crit_edge, label %.lr.ph, !llvm.loop !14

22:                                               ; preds = %._crit_edge
  tail call void @__assert_fail(ptr noundef nonnull @.str.9, ptr noundef nonnull @.str.1, i32 noundef 509, ptr noundef nonnull @__PRETTY_FUNCTION__._ZN22YCSBClientQueryMessage13copy_from_bufEPc) #5
  unreachable

23:                                               ; preds = %._crit_edge
  ret void
}

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

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

declare noundef ptr @_ZN9mem_alloc5allocEm(ptr noundef nonnull align 1 dereferenceable(1), i64 noundef) local_unnamed_addr #3

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN5ArrayIP12ycsb_requestE3addES1_(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef) local_unnamed_addr #4 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 = { "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 = { 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,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass