; LLVM IR from mitdbg/deneva :: transport/message.ll (ZN7Message12mcopy_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.Message = type { ptr, i32, i64, i64, i64, i64, i64, i64, double, double, double, double, double, double, double }

@g_node_id = external global i32, align 4
@g_node_cnt = external global i32, align 4

; 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

declare noundef i64 @_Z13get_sys_clockv() #2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN7Message12mcopy_to_bufEPc(ptr noundef nonnull align 8 dereferenceable(120) %0, ptr noundef %1) #3 align 2 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i64, 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
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #4
  store i64 0, ptr %5, align 8, !tbaa !9
  %7 = load ptr, ptr %4, align 8, !tbaa !5
  %8 = load i64, ptr %5, align 8, !tbaa !9
  %9 = getelementptr inbounds i8, ptr %7, i64 %8
  %10 = getelementptr inbounds %class.Message, ptr %6, i32 0, i32 1
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %9, ptr align 8 %10, i64 4, i1 false)
  %11 = load i64, ptr %5, align 8, !tbaa !9
  %12 = add i64 %11, 4
  store i64 %12, ptr %5, align 8, !tbaa !9
  %13 = load ptr, ptr %4, align 8, !tbaa !5
  %14 = load i64, ptr %5, align 8, !tbaa !9
  %15 = getelementptr inbounds i8, ptr %13, i64 %14
  %16 = getelementptr inbounds %class.Message, ptr %6, i32 0, i32 2
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %15, ptr align 8 %16, i64 8, i1 false)
  %17 = load i64, ptr %5, align 8, !tbaa !9
  %18 = add i64 %17, 8
  store i64 %18, ptr %5, align 8, !tbaa !9
  %19 = load ptr, ptr %4, align 8, !tbaa !5
  %20 = load i64, ptr %5, align 8, !tbaa !9
  %21 = getelementptr inbounds i8, ptr %19, i64 %20
  %22 = getelementptr inbounds %class.Message, ptr %6, i32 0, i32 6
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %21, ptr align 8 %22, i64 8, i1 false)
  %23 = load i64, ptr %5, align 8, !tbaa !9
  %24 = add i64 %23, 8
  store i64 %24, ptr %5, align 8, !tbaa !9
  %25 = load ptr, ptr %4, align 8, !tbaa !5
  %26 = load i64, ptr %5, align 8, !tbaa !9
  %27 = getelementptr inbounds i8, ptr %25, i64 %26
  %28 = getelementptr inbounds %class.Message, ptr %6, i32 0, i32 8
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %27, ptr align 8 %28, i64 8, i1 false)
  %29 = load i64, ptr %5, align 8, !tbaa !9
  %30 = add i64 %29, 8
  store i64 %30, ptr %5, align 8, !tbaa !9
  %31 = load ptr, ptr %4, align 8, !tbaa !5
  %32 = load i64, ptr %5, align 8, !tbaa !9
  %33 = getelementptr inbounds i8, ptr %31, i64 %32
  %34 = getelementptr inbounds %class.Message, ptr %6, i32 0, i32 9
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %33, ptr align 8 %34, i64 8, i1 false)
  %35 = load i64, ptr %5, align 8, !tbaa !9
  %36 = add i64 %35, 8
  store i64 %36, ptr %5, align 8, !tbaa !9
  %37 = load ptr, ptr %4, align 8, !tbaa !5
  %38 = load i64, ptr %5, align 8, !tbaa !9
  %39 = getelementptr inbounds i8, ptr %37, i64 %38
  %40 = getelementptr inbounds %class.Message, ptr %6, i32 0, i32 10
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %39, ptr align 8 %40, 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
  %43 = load ptr, ptr %4, align 8, !tbaa !5
  %44 = load i64, ptr %5, align 8, !tbaa !9
  %45 = getelementptr inbounds i8, ptr %43, i64 %44
  %46 = getelementptr inbounds %class.Message, ptr %6, i32 0, i32 11
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %45, ptr align 8 %46, i64 8, i1 false)
  %47 = load i64, ptr %5, align 8, !tbaa !9
  %48 = add i64 %47, 8
  store i64 %48, ptr %5, align 8, !tbaa !9
  %49 = load ptr, ptr %4, align 8, !tbaa !5
  %50 = load i64, ptr %5, align 8, !tbaa !9
  %51 = getelementptr inbounds i8, ptr %49, i64 %50
  %52 = getelementptr inbounds %class.Message, ptr %6, i32 0, i32 12
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %51, ptr align 8 %52, i64 8, i1 false)
  %53 = load i64, ptr %5, align 8, !tbaa !9
  %54 = add i64 %53, 8
  store i64 %54, ptr %5, align 8, !tbaa !9
  %55 = getelementptr inbounds %class.Message, ptr %6, i32 0, i32 2
  %56 = load i64, ptr %55, align 8, !tbaa !11
  %57 = load i32, ptr @g_node_cnt, align 4, !tbaa !15
  %58 = zext i32 %57 to i64
  %59 = urem i64 %56, %58
  %60 = load i32, ptr @g_node_id, align 4, !tbaa !15
  %61 = zext i32 %60 to i64
  %62 = icmp eq i64 %59, %61
  br i1 %62, label %63, label %67

63:                                               ; preds = %2
  %64 = call noundef i64 @_Z13get_sys_clockv()
  %65 = uitofp i64 %64 to double
  %66 = getelementptr inbounds %class.Message, ptr %6, i32 0, i32 13
  store double %65, ptr %66, align 8, !tbaa !17
  br label %74

67:                                               ; preds = %2
  %68 = call noundef i64 @_Z13get_sys_clockv()
  %69 = uitofp i64 %68 to double
  %70 = getelementptr inbounds %class.Message, ptr %6, i32 0, i32 14
  %71 = load double, ptr %70, align 8, !tbaa !18
  %72 = fsub double %69, %71
  %73 = getelementptr inbounds %class.Message, ptr %6, i32 0, i32 14
  store double %72, ptr %73, align 8, !tbaa !18
  br label %74

74:                                               ; preds = %67, %63
  %75 = load ptr, ptr %4, align 8, !tbaa !5
  %76 = load i64, ptr %5, align 8, !tbaa !9
  %77 = getelementptr inbounds i8, ptr %75, i64 %76
  %78 = getelementptr inbounds %class.Message, ptr %6, i32 0, i32 13
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %77, ptr align 8 %78, i64 8, i1 false)
  %79 = load i64, ptr %5, align 8, !tbaa !9
  %80 = add i64 %79, 8
  store i64 %80, ptr %5, align 8, !tbaa !9
  %81 = load ptr, ptr %4, align 8, !tbaa !5
  %82 = load i64, ptr %5, align 8, !tbaa !9
  %83 = getelementptr inbounds i8, ptr %81, i64 %82
  %84 = getelementptr inbounds %class.Message, ptr %6, i32 0, i32 14
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %83, ptr align 8 %84, i64 8, i1 false)
  %85 = load i64, ptr %5, align 8, !tbaa !9
  %86 = add i64 %85, 8
  store i64 %86, ptr %5, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #4
  ret void
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { "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 = { 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, !10, i64 16}
!12 = !{!"_ZTS7Message", !13, i64 8, !10, i64 16, !10, i64 24, !10, i64 32, !10, i64 40, !10, i64 48, !10, i64 56, !14, i64 64, !14, i64 72, !14, i64 80, !14, i64 88, !14, i64 96, !14, i64 104, !14, i64 112}
!13 = !{!"_ZTS10RemReqType", !7, i64 0}
!14 = !{!"double", !7, i64 0}
!15 = !{!16, !16, i64 0}
!16 = !{!"int", !7, i64 0}
!17 = !{!12, !14, i64 104}
!18 = !{!12, !14, i64 112}


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

@g_node_id = external local_unnamed_addr global i32, align 4
@g_node_cnt = external local_unnamed_addr global i32, align 4

declare noundef i64 @_Z13get_sys_clockv() local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN7Message12mcopy_to_bufEPc(ptr nocapture noundef nonnull align 8 dereferenceable(120) %0, ptr nocapture noundef writeonly %1) local_unnamed_addr #1 align 2 {
  %3 = getelementptr inbounds i8, ptr %0, i64 8
  %4 = load i32, ptr %3, align 8
  store i32 %4, ptr %1, align 1
  %5 = getelementptr inbounds i8, ptr %1, i64 4
  %6 = getelementptr inbounds i8, ptr %0, i64 16
  %7 = load i64, ptr %6, align 8
  store i64 %7, ptr %5, align 1
  %8 = getelementptr inbounds i8, ptr %1, i64 12
  %9 = getelementptr inbounds i8, ptr %0, i64 48
  %10 = load i64, ptr %9, align 8
  store i64 %10, ptr %8, align 1
  %11 = getelementptr inbounds i8, ptr %1, i64 20
  %12 = getelementptr inbounds i8, ptr %0, i64 64
  %13 = load i64, ptr %12, align 8
  store i64 %13, ptr %11, align 1
  %14 = getelementptr inbounds i8, ptr %1, i64 28
  %15 = getelementptr inbounds i8, ptr %0, i64 72
  %16 = load i64, ptr %15, align 8
  store i64 %16, ptr %14, align 1
  %17 = getelementptr inbounds i8, ptr %1, i64 36
  %18 = getelementptr inbounds i8, ptr %0, i64 80
  %19 = load i64, ptr %18, align 8
  store i64 %19, ptr %17, align 1
  %20 = getelementptr inbounds i8, ptr %1, i64 44
  %21 = getelementptr inbounds i8, ptr %0, i64 88
  %22 = load i64, ptr %21, align 8
  store i64 %22, ptr %20, align 1
  %23 = getelementptr inbounds i8, ptr %1, i64 52
  %24 = getelementptr inbounds i8, ptr %0, i64 96
  %25 = load i64, ptr %24, align 8
  store i64 %25, ptr %23, align 1
  %26 = load i64, ptr %6, align 8, !tbaa !5
  %27 = load i32, ptr @g_node_cnt, align 4, !tbaa !12
  %28 = zext i32 %27 to i64
  %29 = urem i64 %26, %28
  %30 = load i32, ptr @g_node_id, align 4, !tbaa !12
  %31 = zext i32 %30 to i64
  %32 = icmp eq i64 %29, %31
  %33 = tail call noundef i64 @_Z13get_sys_clockv()
  %34 = uitofp i64 %33 to double
  br i1 %32, label %35, label %38

35:                                               ; preds = %2
  %36 = getelementptr inbounds i8, ptr %0, i64 104
  store double %34, ptr %36, align 8, !tbaa !14
  %37 = bitcast double %34 to i64
  br label %42

38:                                               ; preds = %2
  %39 = getelementptr inbounds i8, ptr %0, i64 112
  %40 = load double, ptr %39, align 8, !tbaa !15
  %41 = fsub double %34, %40
  store double %41, ptr %39, align 8, !tbaa !15
  %.phi.trans.insert = getelementptr inbounds i8, ptr %0, i64 104
  %.pre = load i64, ptr %.phi.trans.insert, align 8
  br label %42

42:                                               ; preds = %38, %35
  %43 = phi i64 [ %.pre, %38 ], [ %37, %35 ]
  %44 = getelementptr inbounds i8, ptr %1, i64 60
  store i64 %43, ptr %44, align 1
  %45 = getelementptr inbounds i8, ptr %1, i64 68
  %46 = getelementptr inbounds i8, ptr %0, i64 112
  %47 = load i64, ptr %46, align 8
  store i64 %47, ptr %45, align 1
  ret void
}

attributes #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, !10, i64 16}
!6 = !{!"_ZTS7Message", !7, i64 8, !10, i64 16, !10, i64 24, !10, i64 32, !10, i64 40, !10, i64 48, !10, i64 56, !11, i64 64, !11, i64 72, !11, i64 80, !11, i64 88, !11, i64 96, !11, i64 104, !11, i64 112}
!7 = !{!"_ZTS10RemReqType", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"long", !8, i64 0}
!11 = !{!"double", !8, i64 0}
!12 = !{!13, !13, i64 0}
!13 = !{!"int", !8, i64 0}
!14 = !{!6, !11, i64 104}
!15 = !{!6, !11, i64 112}


; Effective O3 passes: BDCEPass,EarlyCSEPass,GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass