; LLVM IR from mitdbg/deneva :: transport/message.ll (ZN16YCSBQueryMessage13copy_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.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 }
%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
@.str.9 = external hidden unnamed_addr constant [18 x i8], align 1
@g_req_per_query = external global i32, align 4
@.str.10 = external hidden unnamed_addr constant [22 x i8], align 1
@__PRETTY_FUNCTION__._ZN16YCSBQueryMessage13copy_from_bufEPc = external hidden unnamed_addr constant [53 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 @_ZN12QueryMessage13copy_from_bufEPc(ptr noundef nonnull align 8 dereferenceable(136), ptr noundef) unnamed_addr #4 align 2

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

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

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN16YCSBQueryMessage13copy_from_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 @_ZN12QueryMessage13copy_from_bufEPc(ptr noundef nonnull align 8 dereferenceable(136) %9, ptr noundef %10)
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #6
  %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) #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 = load i64, ptr %6, align 8, !tbaa !9
  %18 = load i32, ptr @g_req_per_query, align 4, !tbaa !11
  %19 = zext i32 %18 to i64
  %20 = icmp ule i64 %17, %19
  br i1 %20, label %21, label %22

21:                                               ; preds = %2
  br label %24

22:                                               ; preds = %2
  call void @__assert_fail(ptr noundef @.str.10, ptr noundef @.str.1, i32 noundef 1360, ptr noundef @__PRETTY_FUNCTION__._ZN16YCSBQueryMessage13copy_from_bufEPc) #7
  unreachable

23:                                               ; No predecessors!
  br label %24

24:                                               ; preds = %23, %21
  %25 = getelementptr inbounds %class.YCSBQueryMessage, ptr %9, i32 0, i32 1
  %26 = load i64, ptr %6, align 8, !tbaa !9
  call void @_ZN5ArrayIP12ycsb_requestE4initEm(ptr noundef nonnull align 8 dereferenceable(24) %25, i64 noundef %26)
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #6
  store i64 0, ptr %7, align 8, !tbaa !9
  br label %27

27:                                               ; preds = %51, %24
  %28 = load i64, ptr %7, align 8, !tbaa !9
  %29 = load i64, ptr %6, align 8, !tbaa !9
  %30 = icmp ult i64 %28, %29
  br i1 %30, label %32, label %31

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

32:                                               ; preds = %27
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #6
  %33 = call noundef ptr @_ZN9mem_alloc5allocEm(ptr noundef nonnull align 1 dereferenceable(1) @mem_allocator, i64 noundef 24)
  store ptr %33, ptr %8, align 8, !tbaa !5
  %34 = load ptr, ptr %8, align 8, !tbaa !5
  %35 = load ptr, ptr %4, align 8, !tbaa !5
  %36 = load i64, ptr %5, align 8, !tbaa !9
  %37 = getelementptr inbounds i8, ptr %35, i64 %36
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %34, ptr align 1 %37, i64 24, i1 false)
  %38 = load i64, ptr %5, align 8, !tbaa !9
  %39 = add i64 %38, 24
  store i64 %39, ptr %5, align 8, !tbaa !9
  %40 = load ptr, ptr %8, align 8, !tbaa !5
  %41 = getelementptr inbounds %class.ycsb_request, ptr %40, i32 0, i32 2
  %42 = load i64, ptr %41, align 8, !tbaa !13
  %43 = load i64, ptr @g_synth_table_size, align 8, !tbaa !9
  %44 = icmp ult i64 %42, %43
  br i1 %44, label %45, label %46

45:                                               ; preds = %32
  br label %48

46:                                               ; preds = %32
  call void @__assert_fail(ptr noundef @.str.8, ptr noundef @.str.1, i32 noundef 1366, ptr noundef @__PRETTY_FUNCTION__._ZN16YCSBQueryMessage13copy_from_bufEPc) #7
  unreachable

47:                                               ; No predecessors!
  br label %48

48:                                               ; preds = %47, %45
  %49 = getelementptr inbounds %class.YCSBQueryMessage, ptr %9, i32 0, i32 1
  %50 = load ptr, ptr %8, align 8, !tbaa !5
  call void @_ZN5ArrayIP12ycsb_requestE3addES1_(ptr noundef nonnull align 8 dereferenceable(24) %49, ptr noundef %50)
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #6
  br label %51

51:                                               ; preds = %48
  %52 = load i64, ptr %7, align 8, !tbaa !9
  %53 = add i64 %52, 1
  store i64 %53, ptr %7, align 8, !tbaa !9
  br label %27, !llvm.loop !16

54:                                               ; preds = %31
  %55 = load i64, ptr %5, align 8, !tbaa !9
  %56 = load ptr, ptr %9, align 8, !tbaa !18
  %57 = getelementptr inbounds ptr, ptr %56, i64 2
  %58 = load ptr, ptr %57, align 8
  %59 = call noundef i64 %58(ptr noundef nonnull align 8 dereferenceable(160) %9)
  %60 = icmp eq i64 %55, %59
  br i1 %60, label %61, label %62

61:                                               ; preds = %54
  br label %64

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

63:                                               ; No predecessors!
  br label %64

64:                                               ; preds = %63, %61
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #6
  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 = { "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, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!14, !10, i64 8}
!14 = !{!"_ZTS12ycsb_request", !15, i64 0, !10, i64 8, !7, i64 16}
!15 = !{!"_ZTS8access_t", !7, i64 0}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}
!18 = !{!19, !19, i64 0}
!19 = !{!"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
@.str.9 = external hidden unnamed_addr constant [18 x i8], align 1
@g_req_per_query = external local_unnamed_addr global i32, align 4
@.str.10 = external hidden unnamed_addr constant [22 x i8], align 1
@__PRETTY_FUNCTION__._ZN16YCSBQueryMessage13copy_from_bufEPc = external hidden unnamed_addr constant [53 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 @_ZN12QueryMessage13copy_from_bufEPc(ptr noundef nonnull align 8 dereferenceable(136), 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) local_unnamed_addr #3 align 2

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

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN16YCSBQueryMessage13copy_from_bufEPc(ptr noundef nonnull align 8 dereferenceable(160) %0, ptr noundef %1) unnamed_addr #3 align 2 {
  tail call void @_ZN12QueryMessage13copy_from_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 %1, i64 %3
  %.0.copyload = load i64, ptr %4, align 1
  %5 = load i32, ptr @g_req_per_query, align 4, !tbaa !5
  %6 = zext i32 %5 to i64
  %.not = icmp ugt i64 %.0.copyload, %6
  br i1 %.not, label %7, label %8

7:                                                ; preds = %2
  tail call void @__assert_fail(ptr noundef nonnull @.str.10, ptr noundef nonnull @.str.1, i32 noundef 1360, ptr noundef nonnull @__PRETTY_FUNCTION__._ZN16YCSBQueryMessage13copy_from_bufEPc) #5
  unreachable

8:                                                ; preds = %2
  %9 = add i64 %3, 8
  %10 = getelementptr inbounds i8, ptr %0, i64 136
  tail call void @_ZN5ArrayIP12ycsb_requestE4initEm(ptr noundef nonnull align 8 dereferenceable(24) %10, i64 noundef %.0.copyload)
  %.not20 = icmp eq i64 %.0.copyload, 0
  br i1 %.not20, label %._crit_edge, label %.lr.ph

._crit_edge:                                      ; preds = %23, %8
  %.0.lcssa = phi i64 [ %9, %8 ], [ %24, %23 ]
  %11 = load ptr, ptr %0, align 8, !tbaa !9
  %12 = getelementptr inbounds i8, ptr %11, i64 16
  %13 = load ptr, ptr %12, align 8
  %14 = tail call noundef i64 %13(ptr noundef nonnull align 8 dereferenceable(160) %0)
  %15 = icmp eq i64 %.0.lcssa, %14
  br i1 %15, label %27, label %26

.lr.ph:                                           ; preds = %8, %23
  %.019 = phi i64 [ %24, %23 ], [ %9, %8 ]
  %.01618 = phi i64 [ %25, %23 ], [ 0, %8 ]
  %16 = tail call noundef ptr @_ZN9mem_alloc5allocEm(ptr noundef nonnull align 1 dereferenceable(1) @mem_allocator, i64 noundef 24)
  %17 = getelementptr inbounds i8, ptr %1, i64 %.019
  tail call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(24) %16, ptr noundef nonnull align 1 dereferenceable(24) %17, i64 24, i1 false)
  %18 = getelementptr inbounds i8, ptr %16, i64 8
  %19 = load i64, ptr %18, align 8, !tbaa !11
  %20 = load i64, ptr @g_synth_table_size, align 8, !tbaa !15
  %21 = icmp ult i64 %19, %20
  br i1 %21, label %23, label %22

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

23:                                               ; preds = %.lr.ph
  %24 = add i64 %.019, 24
  tail call void @_ZN5ArrayIP12ycsb_requestE3addES1_(ptr noundef nonnull align 8 dereferenceable(24) %10, ptr noundef nonnull %16)
  %25 = add nuw i64 %.01618, 1
  %exitcond.not = icmp eq i64 %25, %.0.copyload
  br i1 %exitcond.not, label %._crit_edge, label %.lr.ph, !llvm.loop !16

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

27:                                               ; 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 = { "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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"vtable pointer", !8, i64 0}
!11 = !{!12, !14, i64 8}
!12 = !{!"_ZTS12ycsb_request", !13, i64 0, !14, i64 8, !7, i64 16}
!13 = !{!"_ZTS8access_t", !7, i64 0}
!14 = !{!"long", !7, i64 0}
!15 = !{!14, !14, i64 0}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}


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