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

; 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.Array.0 = type { ptr, i64, i64 }
%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.BaseQuery = type { ptr, i64, %class.Array.0, %class.Array.0, %class.Array.0, %class.Array.0 }
%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 }

; 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) #0

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN7Message12mcopy_to_txnEP10TxnManager(ptr noundef nonnull align 8 dereferenceable(120), ptr noundef) #1 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN18ClientQueryMessage11copy_to_txnEP10TxnManager(ptr noundef nonnull align 8 dereferenceable(176) %0, ptr noundef %1) unnamed_addr #2 align 2 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca %class.Array.0, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  %6 = load ptr, ptr %3, align 8
  %7 = load ptr, ptr %4, align 8, !tbaa !5
  call void @_ZN7Message12mcopy_to_txnEP10TxnManager(ptr noundef nonnull align 8 dereferenceable(120) %6, ptr noundef %7)
  %8 = load ptr, ptr %4, align 8, !tbaa !5
  %9 = getelementptr inbounds %class.TxnManager, ptr %8, i32 0, i32 21
  %10 = load ptr, ptr %9, align 8, !tbaa !9
  %11 = getelementptr inbounds %class.BaseQuery, ptr %10, i32 0, i32 2
  call void @_ZN5ArrayImE5clearEv(ptr noundef nonnull align 8 dereferenceable(24) %11)
  %12 = load ptr, ptr %4, align 8, !tbaa !5
  %13 = getelementptr inbounds %class.TxnManager, ptr %12, i32 0, i32 21
  %14 = load ptr, ptr %13, align 8, !tbaa !9
  %15 = getelementptr inbounds %class.BaseQuery, ptr %14, i32 0, i32 2
  %16 = getelementptr inbounds %class.ClientQueryMessage, ptr %6, i32 0, i32 5
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %5, ptr align 8 %16, i64 24, i1 false), !tbaa.struct !19
  call void @_ZN5ArrayImE6appendES0_(ptr noundef nonnull align 8 dereferenceable(24) %15, ptr noundef byval(%class.Array.0) align 8 %5)
  %17 = getelementptr inbounds %class.ClientQueryMessage, ptr %6, i32 0, i32 3
  %18 = load i64, ptr %17, align 8, !tbaa !21
  %19 = load ptr, ptr %4, align 8, !tbaa !5
  %20 = getelementptr inbounds %class.TxnManager, ptr %19, i32 0, i32 22
  store i64 %18, ptr %20, align 8, !tbaa !26
  %21 = getelementptr inbounds %class.Message, ptr %6, i32 0, i32 4
  %22 = load i64, ptr %21, align 8, !tbaa !27
  %23 = load ptr, ptr %4, align 8, !tbaa !5
  %24 = getelementptr inbounds %class.TxnManager, ptr %23, i32 0, i32 23
  store i64 %22, ptr %24, align 8, !tbaa !28
  ret void
}

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN5ArrayImE6appendES0_(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef byval(%class.Array.0) align 8) #2 align 2

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

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

!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 = !{i64 0, i64 8, !5, i64 8, i64 8, !20, i64 16, i64 8, !20}
!20 = !{!13, !13, i64 0}
!21 = !{!22, !13, i64 136}
!22 = !{!"_ZTS18ClientQueryMessage", !23, i64 0, !13, i64 120, !13, i64 128, !13, i64 136, !13, i64 144, !25, i64 152}
!23 = !{!"_ZTS7Message", !24, i64 8, !13, i64 16, !13, i64 24, !13, i64 32, !13, i64 40, !13, i64 48, !13, i64 56, !15, i64 64, !15, i64 72, !15, i64 80, !15, i64 88, !15, i64 96, !15, i64 104, !15, i64 112}
!24 = !{!"_ZTS10RemReqType", !7, i64 0}
!25 = !{!"_ZTS5ArrayImE", !6, i64 0, !13, i64 8, !13, i64 16}
!26 = !{!10, !13, i64 152}
!27 = !{!23, !13, i64 32}
!28 = !{!10, !13, i64 160}


; 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.Array.0 = type { ptr, i64, i64 }

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN18ClientQueryMessage11copy_to_txnEP10TxnManager(ptr noundef nonnull align 8 dereferenceable(176) %0, ptr noundef %1) unnamed_addr #1 align 2 {
  tail call void @_ZN7Message12mcopy_to_txnEP10TxnManager(ptr noundef nonnull align 8 dereferenceable(120) %0, ptr noundef %1)
  %3 = getelementptr inbounds i8, ptr %1, i64 144
  %4 = load ptr, ptr %3, align 8, !tbaa !5
  %5 = getelementptr inbounds i8, ptr %4, i64 16
  tail call void @_ZN5ArrayImE5clearEv(ptr noundef nonnull align 8 dereferenceable(24) %5)
  %6 = load ptr, ptr %3, align 8, !tbaa !5
  %7 = getelementptr inbounds i8, ptr %6, i64 16
  %8 = getelementptr inbounds i8, ptr %0, i64 152
  tail call void @_ZN5ArrayImE6appendES0_(ptr noundef nonnull align 8 dereferenceable(24) %7, ptr noundef nonnull byval(%class.Array.0) align 8 %8)
  %9 = getelementptr inbounds i8, ptr %0, i64 136
  %10 = load i64, ptr %9, align 8, !tbaa !18
  %11 = getelementptr inbounds i8, ptr %1, i64 152
  store i64 %10, ptr %11, align 8, !tbaa !23
  %12 = getelementptr inbounds i8, ptr %0, i64 32
  %13 = load i64, ptr %12, align 8, !tbaa !24
  %14 = getelementptr inbounds i8, ptr %1, i64 160
  store i64 %13, ptr %14, align 8, !tbaa !25
  ret void
}

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN5ArrayImE6appendES0_(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef byval(%class.Array.0) align 8) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN5ArrayImE5clearEv(ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #0 align 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" }

!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 136}
!19 = !{!"_ZTS18ClientQueryMessage", !20, i64 0, !12, i64 120, !12, i64 128, !12, i64 136, !12, i64 144, !22, i64 152}
!20 = !{!"_ZTS7Message", !21, i64 8, !12, i64 16, !12, i64 24, !12, i64 32, !12, i64 40, !12, i64 48, !12, i64 56, !14, i64 64, !14, i64 72, !14, i64 80, !14, i64 88, !14, i64 96, !14, i64 104, !14, i64 112}
!21 = !{!"_ZTS10RemReqType", !8, i64 0}
!22 = !{!"_ZTS5ArrayImE", !7, i64 0, !12, i64 8, !12, i64 16}
!23 = !{!6, !12, i64 152}
!24 = !{!20, !12, i64 32}
!25 = !{!6, !12, i64 160}


; Effective O3 passes: DSEPass,EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,MemCpyOptPass,SROAPass,TailCallElimPass