; LLVM IR from mitdbg/deneva :: transport/message.ll (ZN21PPSClientQueryMessage11copy_to_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.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 }
%class.Array.0 = type { ptr, i64, i64 }

@.str.1 = external hidden unnamed_addr constant [69 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [18 x i8], align 1
@__PRETTY_FUNCTION__._ZN21PPSClientQueryMessage11copy_to_bufEPc = external hidden unnamed_addr constant [56 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
declare dso_local void @_ZN18ClientQueryMessage11copy_to_bufEPc(ptr noundef nonnull align 8 dereferenceable(176), ptr noundef) unnamed_addr #3 align 2

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN21PPSClientQueryMessage11copy_to_bufEPc(ptr noundef nonnull align 8 dereferenceable(233) %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 i64, 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 @_ZN18ClientQueryMessage11copy_to_bufEPc(ptr noundef nonnull align 8 dereferenceable(176) %9, ptr noundef %10)
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #5
  %11 = call noundef i64 @_ZN18ClientQueryMessage8get_sizeEv(ptr noundef nonnull align 8 dereferenceable(176) %9)
  store i64 %11, ptr %5, align 8, !tbaa !9
  %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
  %15 = getelementptr inbounds %class.PPSClientQueryMessage, ptr %9, i32 0, i32 1
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %14, ptr align 8 %15, i64 8, i1 false)
  %16 = load i64, ptr %5, align 8, !tbaa !9
  %17 = add i64 %16, 8
  store i64 %17, ptr %5, align 8, !tbaa !9
  %18 = load ptr, ptr %4, align 8, !tbaa !5
  %19 = load i64, ptr %5, align 8, !tbaa !9
  %20 = getelementptr inbounds i8, ptr %18, i64 %19
  %21 = getelementptr inbounds %class.PPSClientQueryMessage, ptr %9, i32 0, i32 2
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %20, ptr align 8 %21, i64 8, i1 false)
  %22 = load i64, ptr %5, align 8, !tbaa !9
  %23 = add i64 %22, 8
  store i64 %23, ptr %5, align 8, !tbaa !9
  %24 = load ptr, ptr %4, align 8, !tbaa !5
  %25 = load i64, ptr %5, align 8, !tbaa !9
  %26 = getelementptr inbounds i8, ptr %24, i64 %25
  %27 = getelementptr inbounds %class.PPSClientQueryMessage, ptr %9, i32 0, i32 3
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %26, ptr align 8 %27, i64 8, i1 false)
  %28 = load i64, ptr %5, align 8, !tbaa !9
  %29 = add i64 %28, 8
  store i64 %29, ptr %5, align 8, !tbaa !9
  %30 = load ptr, ptr %4, align 8, !tbaa !5
  %31 = load i64, ptr %5, align 8, !tbaa !9
  %32 = getelementptr inbounds i8, ptr %30, i64 %31
  %33 = getelementptr inbounds %class.PPSClientQueryMessage, ptr %9, i32 0, i32 4
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %32, ptr align 8 %33, i64 8, i1 false)
  %34 = load i64, ptr %5, align 8, !tbaa !9
  %35 = add i64 %34, 8
  store i64 %35, ptr %5, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #5
  %36 = getelementptr inbounds %class.PPSClientQueryMessage, ptr %9, i32 0, i32 5
  %37 = call noundef i64 @_ZN5ArrayImE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %36)
  store i64 %37, ptr %6, align 8, !tbaa !9
  %38 = load ptr, ptr %4, align 8, !tbaa !5
  %39 = load i64, ptr %5, align 8, !tbaa !9
  %40 = getelementptr inbounds i8, ptr %38, i64 %39
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %40, ptr align 8 %6, i64 8, i1 false)
  %41 = load i64, ptr %5, align 8, !tbaa !9
  %42 = add i64 %41, 8
  store i64 %42, ptr %5, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #5
  store i64 0, ptr %7, align 8, !tbaa !9
  br label %43

43:                                               ; preds = %58, %2
  %44 = load i64, ptr %7, align 8, !tbaa !9
  %45 = getelementptr inbounds %class.PPSClientQueryMessage, ptr %9, i32 0, i32 5
  %46 = call noundef i64 @_ZN5ArrayImE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %45)
  %47 = icmp ult i64 %44, %46
  br i1 %47, label %49, label %48

48:                                               ; preds = %43
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #5
  br label %61

49:                                               ; preds = %43
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #5
  %50 = getelementptr inbounds %class.PPSClientQueryMessage, ptr %9, i32 0, i32 5
  %51 = load i64, ptr %7, align 8, !tbaa !9
  %52 = call noundef i64 @_ZN5ArrayImEixEm(ptr noundef nonnull align 8 dereferenceable(24) %50, i64 noundef %51)
  store i64 %52, ptr %8, align 8, !tbaa !9
  %53 = load ptr, ptr %4, align 8, !tbaa !5
  %54 = load i64, ptr %5, align 8, !tbaa !9
  %55 = getelementptr inbounds i8, ptr %53, i64 %54
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %55, ptr align 8 %8, i64 8, i1 false)
  %56 = load i64, ptr %5, align 8, !tbaa !9
  %57 = add i64 %56, 8
  store i64 %57, ptr %5, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #5
  br label %58

58:                                               ; preds = %49
  %59 = load i64, ptr %7, align 8, !tbaa !9
  %60 = add i64 %59, 1
  store i64 %60, ptr %7, align 8, !tbaa !9
  br label %43, !llvm.loop !11

61:                                               ; preds = %48
  %62 = load i64, ptr %5, align 8, !tbaa !9
  %63 = load ptr, ptr %9, align 8, !tbaa !13
  %64 = getelementptr inbounds ptr, ptr %63, i64 2
  %65 = load ptr, ptr %64, align 8
  %66 = call noundef i64 %65(ptr noundef nonnull align 8 dereferenceable(233) %9)
  %67 = icmp eq i64 %62, %66
  br i1 %67, label %68, label %69

68:                                               ; preds = %61
  br label %71

69:                                               ; preds = %61
  call void @__assert_fail(ptr noundef @.str.9, ptr noundef @.str.1, i32 noundef 833, ptr noundef @__PRETTY_FUNCTION__._ZN21PPSClientQueryMessage11copy_to_bufEPc) #6
  unreachable

70:                                               ; No predecessors!
  br label %71

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZN5ArrayImEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) #4 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 = { 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 = { nounwind }
attributes #6 = { 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 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = !{!14, !14, i64 0}
!14 = !{!"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"

@.str.1 = external hidden unnamed_addr constant [69 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [18 x i8], align 1
@__PRETTY_FUNCTION__._ZN21PPSClientQueryMessage11copy_to_bufEPc = external hidden unnamed_addr constant [56 x i8], align 1

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
declare dso_local noundef i64 @_ZN18ClientQueryMessage8get_sizeEv(ptr noundef nonnull align 8 dereferenceable(176)) unnamed_addr #1 align 2

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

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN21PPSClientQueryMessage11copy_to_bufEPc(ptr noundef nonnull align 8 dereferenceable(233) %0, ptr noundef %1) unnamed_addr #1 align 2 {
  tail call void @_ZN18ClientQueryMessage11copy_to_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
  %5 = getelementptr inbounds i8, ptr %0, i64 176
  %6 = load i64, ptr %5, align 8
  store i64 %6, ptr %4, align 1
  %7 = getelementptr i8, ptr %4, i64 8
  %8 = getelementptr inbounds i8, ptr %0, i64 184
  %9 = load i64, ptr %8, align 8
  store i64 %9, ptr %7, align 1
  %10 = getelementptr i8, ptr %4, i64 16
  %11 = getelementptr inbounds i8, ptr %0, i64 192
  %12 = load i64, ptr %11, align 8
  store i64 %12, ptr %10, align 1
  %13 = getelementptr i8, ptr %4, i64 24
  %14 = getelementptr inbounds i8, ptr %0, i64 200
  %15 = load i64, ptr %14, align 8
  store i64 %15, ptr %13, align 1
  %16 = getelementptr inbounds i8, ptr %0, i64 208
  %17 = tail call noundef i64 @_ZN5ArrayImE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %16)
  %18 = getelementptr i8, ptr %4, i64 32
  store i64 %17, ptr %18, align 1
  %19 = add i64 %3, 40
  %20 = tail call noundef i64 @_ZN5ArrayImE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %16)
  %.not = icmp eq i64 %20, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph

._crit_edge:                                      ; preds = %.lr.ph, %2
  %.0.lcssa = phi i64 [ %19, %2 ], [ %28, %.lr.ph ]
  %21 = load ptr, ptr %0, align 8, !tbaa !5
  %22 = getelementptr inbounds i8, ptr %21, i64 16
  %23 = load ptr, ptr %22, align 8
  %24 = tail call noundef i64 %23(ptr noundef nonnull align 8 dereferenceable(233) %0)
  %25 = icmp eq i64 %.0.lcssa, %24
  br i1 %25, label %33, label %32

.lr.ph:                                           ; preds = %2, %.lr.ph
  %.026 = phi i64 [ %28, %.lr.ph ], [ %19, %2 ]
  %.02425 = phi i64 [ %29, %.lr.ph ], [ 0, %2 ]
  %26 = tail call noundef i64 @_ZN5ArrayImEixEm(ptr noundef nonnull align 8 dereferenceable(24) %16, i64 noundef %.02425)
  %27 = getelementptr inbounds i8, ptr %1, i64 %.026
  store i64 %26, ptr %27, align 1
  %28 = add i64 %.026, 8
  %29 = add nuw i64 %.02425, 1
  %30 = tail call noundef i64 @_ZN5ArrayImE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %16)
  %31 = icmp ult i64 %29, %30
  br i1 %31, label %.lr.ph, label %._crit_edge, !llvm.loop !8

32:                                               ; preds = %._crit_edge
  tail call void @__assert_fail(ptr noundef nonnull @.str.9, ptr noundef nonnull @.str.1, i32 noundef 833, ptr noundef nonnull @__PRETTY_FUNCTION__._ZN21PPSClientQueryMessage11copy_to_bufEPc) #3
  unreachable

33:                                               ; preds = %._crit_edge
  ret void
}

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

attributes #0 = { 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 #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" }
attributes #3 = { 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 = distinct !{!8, !9}
!9 = !{!"llvm.loop.mustprogress"}


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