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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN7Message14mcopy_from_bufEPc(ptr noundef nonnull align 8 dereferenceable(120) %0, ptr noundef %1) #2 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 = getelementptr inbounds %class.Message, ptr %6, i32 0, i32 1
  %8 = load ptr, ptr %4, align 8, !tbaa !5
  %9 = load i64, ptr %5, align 8, !tbaa !9
  %10 = getelementptr inbounds i8, ptr %8, i64 %9
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %7, ptr align 1 %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 = getelementptr inbounds %class.Message, ptr %6, i32 0, i32 2
  %14 = load ptr, ptr %4, align 8, !tbaa !5
  %15 = load i64, ptr %5, align 8, !tbaa !9
  %16 = getelementptr inbounds i8, ptr %14, i64 %15
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %13, ptr align 1 %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 = getelementptr inbounds %class.Message, ptr %6, i32 0, i32 6
  %20 = load ptr, ptr %4, align 8, !tbaa !5
  %21 = load i64, ptr %5, align 8, !tbaa !9
  %22 = getelementptr inbounds i8, ptr %20, i64 %21
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %19, ptr align 1 %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 = getelementptr inbounds %class.Message, ptr %6, i32 0, i32 8
  %26 = load ptr, ptr %4, align 8, !tbaa !5
  %27 = load i64, ptr %5, align 8, !tbaa !9
  %28 = getelementptr inbounds i8, ptr %26, i64 %27
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %25, ptr align 1 %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 = getelementptr inbounds %class.Message, ptr %6, i32 0, i32 9
  %32 = load ptr, ptr %4, align 8, !tbaa !5
  %33 = load i64, ptr %5, align 8, !tbaa !9
  %34 = getelementptr inbounds i8, ptr %32, i64 %33
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %31, ptr align 1 %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 = getelementptr inbounds %class.Message, ptr %6, i32 0, i32 10
  %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 8 %37, ptr align 1 %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 = getelementptr inbounds %class.Message, ptr %6, i32 0, i32 11
  %44 = load ptr, ptr %4, align 8, !tbaa !5
  %45 = load i64, ptr %5, align 8, !tbaa !9
  %46 = getelementptr inbounds i8, ptr %44, i64 %45
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %43, ptr align 1 %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 = getelementptr inbounds %class.Message, ptr %6, i32 0, i32 12
  %50 = load ptr, ptr %4, align 8, !tbaa !5
  %51 = load i64, ptr %5, align 8, !tbaa !9
  %52 = getelementptr inbounds i8, ptr %50, i64 %51
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %49, ptr align 1 %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 13
  %56 = load ptr, ptr %4, align 8, !tbaa !5
  %57 = load i64, ptr %5, align 8, !tbaa !9
  %58 = getelementptr inbounds i8, ptr %56, i64 %57
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %55, ptr align 1 %58, i64 8, i1 false)
  %59 = load i64, ptr %5, align 8, !tbaa !9
  %60 = add i64 %59, 8
  store i64 %60, ptr %5, align 8, !tbaa !9
  %61 = getelementptr inbounds %class.Message, ptr %6, i32 0, i32 14
  %62 = load ptr, ptr %4, align 8, !tbaa !5
  %63 = load i64, ptr %5, align 8, !tbaa !9
  %64 = getelementptr inbounds i8, ptr %62, i64 %63
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %61, ptr align 1 %64, i64 8, i1 false)
  %65 = load i64, ptr %5, align 8, !tbaa !9
  %66 = add i64 %65, 8
  store i64 %66, ptr %5, align 8, !tbaa !9
  %67 = getelementptr inbounds %class.Message, ptr %6, i32 0, i32 2
  %68 = load i64, ptr %67, align 8, !tbaa !11
  %69 = load i32, ptr @g_node_cnt, align 4, !tbaa !15
  %70 = zext i32 %69 to i64
  %71 = urem i64 %68, %70
  %72 = load i32, ptr @g_node_id, align 4, !tbaa !15
  %73 = zext i32 %72 to i64
  %74 = icmp eq i64 %71, %73
  br i1 %74, label %75, label %85

75:                                               ; preds = %2
  %76 = call noundef i64 @_Z13get_sys_clockv()
  %77 = uitofp i64 %76 to double
  %78 = getelementptr inbounds %class.Message, ptr %6, i32 0, i32 13
  %79 = load double, ptr %78, align 8, !tbaa !17
  %80 = fsub double %77, %79
  %81 = getelementptr inbounds %class.Message, ptr %6, i32 0, i32 14
  %82 = load double, ptr %81, align 8, !tbaa !18
  %83 = fsub double %80, %82
  %84 = getelementptr inbounds %class.Message, ptr %6, i32 0, i32 13
  store double %83, ptr %84, align 8, !tbaa !17
  br label %89

85:                                               ; preds = %2
  %86 = call noundef i64 @_Z13get_sys_clockv()
  %87 = uitofp i64 %86 to double
  %88 = getelementptr inbounds %class.Message, ptr %6, i32 0, i32 14
  store double %87, ptr %88, align 8, !tbaa !18
  br label %89

89:                                               ; preds = %85, %75
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #4
  ret void
}

declare noundef i64 @_Z13get_sys_clockv() #3

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 = { "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

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

40:                                               ; preds = %2
  %41 = load double, ptr %26, align 8, !tbaa !9
  %42 = fsub double %39, %41
  %43 = load double, ptr %29, align 8, !tbaa !14
  %44 = fsub double %42, %43
  store double %44, ptr %26, align 8, !tbaa !9
  br label %46

45:                                               ; preds = %2
  store double %39, ptr %29, align 8, !tbaa !14
  br label %46

46:                                               ; preds = %45, %40
  ret void
}

declare noundef i64 @_Z13get_sys_clockv() local_unnamed_addr #1

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


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