; LLVM IR from mitdbg/deneva :: transport/message.ll (ZN18ClientQueryMessage13copy_from_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.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.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 }

; 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 uwtable
declare dso_local void @_ZN7Message14mcopy_from_txnEP10TxnManager(ptr noundef nonnull align 8 dereferenceable(120), ptr noundef) #1 align 2

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

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN18ClientQueryMessage13copy_from_txnEP10TxnManager(ptr noundef nonnull align 8 dereferenceable(176) %0, ptr noundef %1) unnamed_addr #1 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 @_ZN7Message14mcopy_from_txnEP10TxnManager(ptr noundef nonnull align 8 dereferenceable(120) %6, ptr noundef %7)
  %8 = getelementptr inbounds %class.ClientQueryMessage, ptr %6, i32 0, i32 5
  call void @_ZN5ArrayImE5clearEv(ptr noundef nonnull align 8 dereferenceable(24) %8)
  %9 = getelementptr inbounds %class.ClientQueryMessage, ptr %6, i32 0, i32 5
  %10 = load ptr, ptr %4, align 8, !tbaa !5
  %11 = getelementptr inbounds %class.TxnManager, ptr %10, i32 0, i32 21
  %12 = load ptr, ptr %11, align 8, !tbaa !9
  %13 = getelementptr inbounds %class.BaseQuery, ptr %12, i32 0, i32 2
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %5, ptr align 8 %13, i64 24, i1 false), !tbaa.struct !19
  call void @_ZN5ArrayImE4copyES0_(ptr noundef nonnull align 8 dereferenceable(24) %9, ptr noundef byval(%class.Array.0) align 8 %5)
  %14 = load ptr, ptr %4, align 8, !tbaa !5
  %15 = getelementptr inbounds %class.TxnManager, ptr %14, i32 0, i32 22
  %16 = load i64, ptr %15, align 8, !tbaa !21
  %17 = getelementptr inbounds %class.ClientQueryMessage, ptr %6, i32 0, i32 3
  store i64 %16, ptr %17, align 8, !tbaa !22
  ret void
}

attributes #0 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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" }
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" }

!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 = !{!10, !13, i64 152}
!22 = !{!23, !13, i64 136}
!23 = !{!"_ZTS18ClientQueryMessage", !24, i64 0, !13, i64 120, !13, i64 128, !13, i64 136, !13, i64 144, !26, i64 152}
!24 = !{!"_ZTS7Message", !25, 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}
!25 = !{!"_ZTS10RemReqType", !7, i64 0}
!26 = !{!"_ZTS5ArrayImE", !6, i64 0, !13, i64 8, !13, i64 16}


; 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 uwtable
declare dso_local void @_ZN7Message14mcopy_from_txnEP10TxnManager(ptr noundef nonnull align 8 dereferenceable(120), ptr noundef) local_unnamed_addr #0 align 2

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

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN18ClientQueryMessage13copy_from_txnEP10TxnManager(ptr noundef nonnull align 8 dereferenceable(176) %0, ptr noundef %1) unnamed_addr #0 align 2 {
  tail call void @_ZN7Message14mcopy_from_txnEP10TxnManager(ptr noundef nonnull align 8 dereferenceable(120) %0, ptr noundef %1)
  %3 = getelementptr inbounds i8, ptr %0, i64 152
  tail call void @_ZN5ArrayImE5clearEv(ptr noundef nonnull align 8 dereferenceable(24) %3)
  %4 = getelementptr inbounds i8, ptr %1, i64 144
  %5 = load ptr, ptr %4, align 8, !tbaa !5
  %6 = getelementptr inbounds i8, ptr %5, i64 16
  tail call void @_ZN5ArrayImE4copyES0_(ptr noundef nonnull align 8 dereferenceable(24) %3, ptr noundef nonnull byval(%class.Array.0) align 8 %6)
  %7 = getelementptr inbounds i8, ptr %1, i64 152
  %8 = load i64, ptr %7, align 8, !tbaa !18
  %9 = getelementptr inbounds i8, ptr %0, i64 136
  store i64 %8, ptr %9, align 8, !tbaa !19
  ret void
}

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

!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 = !{!6, !12, i64 152}
!19 = !{!20, !12, i64 136}
!20 = !{!"_ZTS18ClientQueryMessage", !21, i64 0, !12, i64 120, !12, i64 128, !12, i64 136, !12, i64 144, !23, i64 152}
!21 = !{!"_ZTS7Message", !22, 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}
!22 = !{!"_ZTS10RemReqType", !8, i64 0}
!23 = !{!"_ZTS5ArrayImE", !7, i64 0, !12, i64 8, !12, i64 16}


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