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

; 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.PPSQuery = type { %class.BaseQuery, i32, i64, i64, i64, i64, %class.Array.0 }
%class.BaseQuery = type { ptr, i64, %class.Array.0, %class.Array.0, %class.Array.0, %class.Array.0 }
%class.PPSClientQueryMessage = type <{ %class.ClientQueryMessage, i64, i64, i64, i64, %class.Array.0, i8, [7 x i8] }>
%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 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: 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 void @_ZN18ClientQueryMessage15copy_from_queryEP9BaseQuery(ptr noundef nonnull align 8 dereferenceable(176), ptr noundef) #2 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN21PPSClientQueryMessage15copy_from_queryEP9BaseQuery(ptr noundef nonnull align 8 dereferenceable(233) %0, ptr noundef %1) #2 align 2 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca %class.Array.0, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  %7 = load ptr, ptr %3, align 8
  %8 = load ptr, ptr %4, align 8, !tbaa !5
  call void @_ZN18ClientQueryMessage15copy_from_queryEP9BaseQuery(ptr noundef nonnull align 8 dereferenceable(176) %7, ptr noundef %8)
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #3
  %9 = load ptr, ptr %4, align 8, !tbaa !5
  store ptr %9, ptr %5, align 8, !tbaa !5
  %10 = load ptr, ptr %5, align 8, !tbaa !5
  %11 = getelementptr inbounds %class.PPSQuery, ptr %10, i32 0, i32 1
  %12 = load i32, ptr %11, align 8, !tbaa !9
  %13 = zext i32 %12 to i64
  %14 = getelementptr inbounds %class.PPSClientQueryMessage, ptr %7, i32 0, i32 1
  store i64 %13, ptr %14, align 8, !tbaa !15
  %15 = load ptr, ptr %5, align 8, !tbaa !5
  %16 = getelementptr inbounds %class.PPSQuery, ptr %15, i32 0, i32 3
  %17 = load i64, ptr %16, align 8, !tbaa !22
  %18 = getelementptr inbounds %class.PPSClientQueryMessage, ptr %7, i32 0, i32 2
  store i64 %17, ptr %18, align 8, !tbaa !23
  %19 = load ptr, ptr %5, align 8, !tbaa !5
  %20 = getelementptr inbounds %class.PPSQuery, ptr %19, i32 0, i32 5
  %21 = load i64, ptr %20, align 8, !tbaa !24
  %22 = getelementptr inbounds %class.PPSClientQueryMessage, ptr %7, i32 0, i32 3
  store i64 %21, ptr %22, align 8, !tbaa !25
  %23 = load ptr, ptr %5, align 8, !tbaa !5
  %24 = getelementptr inbounds %class.PPSQuery, ptr %23, i32 0, i32 4
  %25 = load i64, ptr %24, align 8, !tbaa !26
  %26 = getelementptr inbounds %class.PPSClientQueryMessage, ptr %7, i32 0, i32 4
  store i64 %25, ptr %26, align 8, !tbaa !27
  %27 = getelementptr inbounds %class.PPSClientQueryMessage, ptr %7, i32 0, i32 5
  %28 = load ptr, ptr %5, align 8, !tbaa !5
  %29 = getelementptr inbounds %class.PPSQuery, ptr %28, i32 0, i32 6
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %6, ptr align 8 %29, i64 24, i1 false), !tbaa.struct !28
  call void @_ZN5ArrayImE4copyES0_(ptr noundef nonnull align 8 dereferenceable(24) %27, ptr noundef byval(%class.Array.0) align 8 %6)
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #3
  ret void
}

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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 = { 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, !14, i64 112}
!10 = !{!"_ZTS8PPSQuery", !11, i64 0, !14, i64 112, !12, i64 120, !12, i64 128, !12, i64 136, !12, i64 144, !13, i64 152}
!11 = !{!"_ZTS9BaseQuery", !12, i64 8, !13, i64 16, !13, i64 40, !13, i64 64, !13, i64 88}
!12 = !{!"long", !7, i64 0}
!13 = !{!"_ZTS5ArrayImE", !6, i64 0, !12, i64 8, !12, i64 16}
!14 = !{!"_ZTS10PPSTxnType", !7, i64 0}
!15 = !{!16, !12, i64 176}
!16 = !{!"_ZTS21PPSClientQueryMessage", !17, i64 0, !12, i64 176, !12, i64 184, !12, i64 192, !12, i64 200, !13, i64 208, !21, i64 232}
!17 = !{!"_ZTS18ClientQueryMessage", !18, i64 0, !12, i64 120, !12, i64 128, !12, i64 136, !12, i64 144, !13, i64 152}
!18 = !{!"_ZTS7Message", !19, i64 8, !12, i64 16, !12, i64 24, !12, i64 32, !12, i64 40, !12, i64 48, !12, i64 56, !20, i64 64, !20, i64 72, !20, i64 80, !20, i64 88, !20, i64 96, !20, i64 104, !20, i64 112}
!19 = !{!"_ZTS10RemReqType", !7, i64 0}
!20 = !{!"double", !7, i64 0}
!21 = !{!"bool", !7, i64 0}
!22 = !{!10, !12, i64 128}
!23 = !{!16, !12, i64 184}
!24 = !{!10, !12, i64 144}
!25 = !{!16, !12, i64 192}
!26 = !{!10, !12, i64 136}
!27 = !{!16, !12, i64 200}
!28 = !{i64 0, i64 8, !5, i64 8, i64 8, !29, i64 16, i64 8, !29}
!29 = !{!12, !12, 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.Array.0 = type { ptr, i64, i64 }

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN21PPSClientQueryMessage15copy_from_queryEP9BaseQuery(ptr noundef nonnull align 8 dereferenceable(233) %0, ptr noundef %1) local_unnamed_addr #0 align 2 {
  tail call void @_ZN18ClientQueryMessage15copy_from_queryEP9BaseQuery(ptr noundef nonnull align 8 dereferenceable(176) %0, ptr noundef %1)
  %3 = getelementptr inbounds i8, ptr %1, i64 112
  %4 = load i32, ptr %3, align 8, !tbaa !5
  %5 = zext i32 %4 to i64
  %6 = getelementptr inbounds i8, ptr %0, i64 176
  store i64 %5, ptr %6, align 8, !tbaa !14
  %7 = getelementptr inbounds i8, ptr %1, i64 128
  %8 = load i64, ptr %7, align 8, !tbaa !21
  %9 = getelementptr inbounds i8, ptr %0, i64 184
  store i64 %8, ptr %9, align 8, !tbaa !22
  %10 = getelementptr inbounds i8, ptr %0, i64 192
  %11 = getelementptr inbounds i8, ptr %1, i64 136
  %12 = load <2 x i64>, ptr %11, align 8, !tbaa !23
  %13 = shufflevector <2 x i64> %12, <2 x i64> poison, <2 x i32> <i32 1, i32 0>
  store <2 x i64> %13, ptr %10, align 8, !tbaa !23
  %14 = getelementptr inbounds i8, ptr %0, i64 208
  %15 = getelementptr inbounds i8, ptr %1, i64 152
  tail call void @_ZN5ArrayImE4copyES0_(ptr noundef nonnull align 8 dereferenceable(24) %14, ptr noundef nonnull byval(%class.Array.0) align 8 %15)
  ret void
}

; 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

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" }

!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, !13, i64 112}
!6 = !{!"_ZTS8PPSQuery", !7, i64 0, !13, i64 112, !8, i64 120, !8, i64 128, !8, i64 136, !8, i64 144, !11, i64 152}
!7 = !{!"_ZTS9BaseQuery", !8, i64 8, !11, i64 16, !11, i64 40, !11, i64 64, !11, i64 88}
!8 = !{!"long", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C++ TBAA"}
!11 = !{!"_ZTS5ArrayImE", !12, i64 0, !8, i64 8, !8, i64 16}
!12 = !{!"any pointer", !9, i64 0}
!13 = !{!"_ZTS10PPSTxnType", !9, i64 0}
!14 = !{!15, !8, i64 176}
!15 = !{!"_ZTS21PPSClientQueryMessage", !16, i64 0, !8, i64 176, !8, i64 184, !8, i64 192, !8, i64 200, !11, i64 208, !20, i64 232}
!16 = !{!"_ZTS18ClientQueryMessage", !17, i64 0, !8, i64 120, !8, i64 128, !8, i64 136, !8, i64 144, !11, i64 152}
!17 = !{!"_ZTS7Message", !18, i64 8, !8, i64 16, !8, i64 24, !8, i64 32, !8, i64 40, !8, i64 48, !8, i64 56, !19, i64 64, !19, i64 72, !19, i64 80, !19, i64 88, !19, i64 96, !19, i64 104, !19, i64 112}
!18 = !{!"_ZTS10RemReqType", !9, i64 0}
!19 = !{!"double", !9, i64 0}
!20 = !{!"bool", !9, i64 0}
!21 = !{!6, !8, i64 128}
!22 = !{!15, !8, i64 184}
!23 = !{!8, !8, i64 0}


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