; LLVM IR from dynexcoin/Dynex :: src/P2p/P2pContext.ll (ZN7DynexCN10P2pContext11readCommandERNS_13LevinProtocol7CommandE)

; 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.System::EventLock" = type { ptr }
%"class.DynexCN::LevinProtocol" = type { ptr }
%"class.std::chrono::time_point" = type { %"class.std::chrono::duration" }
%"class.std::chrono::duration" = type { i64 }
%"class.DynexCN::P2pContext" = type <{ i8, i8, %"struct.DynexCN::NetworkAddress", [6 x i8], i64, i16, [6 x i8], ptr, %"class.System::ContextGroup", %"class.std::chrono::time_point", i8, [7 x i8], %"class.std::chrono::time_point", %"class.std::chrono::duration", ptr, %"class.System::Timer", %"class.System::Event", %"class.System::TcpConnection", %"class.System::Event", %"class.System::Event" }>
%"struct.DynexCN::NetworkAddress" = type { i32, i32 }
%"class.System::ContextGroup" = type { ptr, %"struct.System::NativeContextGroup" }
%"struct.System::NativeContextGroup" = type { ptr, ptr, ptr, ptr }
%"class.System::Timer" = type { ptr, i32, ptr }
%"class.System::TcpConnection" = type { ptr, i32, ptr, ptr }
%"class.System::Event" = type { ptr, i8, ptr, ptr }

@_ZTIN6System20InterruptedExceptionE = external dso_local constant { ptr, ptr, ptr }, align 8

; 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: nounwind
declare i64 @_ZNSt6chrono3_V212steady_clock3nowEv() #2

declare i32 @__gxx_personality_v0(...)

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZN7DynexCN10P2pContext11readCommandERNS_13LevinProtocol7CommandE(ptr noundef nonnull align 8 dereferenceable(272) %0, ptr noundef nonnull align 8 dereferenceable(32) %1) #3 align 2 personality ptr @__gxx_personality_v0 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca %"class.System::EventLock", align 8
  %6 = alloca i8, align 1
  %7 = alloca %"class.DynexCN::LevinProtocol", align 8
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  %10 = alloca %"class.std::chrono::time_point", align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  %11 = load ptr, ptr %3, align 8
  %12 = getelementptr inbounds %"class.DynexCN::P2pContext", ptr %11, i32 0, i32 10
  %13 = load i8, ptr %12, align 8, !tbaa !9, !range !23, !noundef !24
  %14 = trunc i8 %13 to i1
  br i1 %14, label %15, label %17

15:                                               ; preds = %2
  %16 = call ptr @__cxa_allocate_exception(i64 8) #7
  call void @llvm.memset.p0.i64(ptr align 16 %16, i8 0, i64 8, i1 false)
  call void @_ZN6System20InterruptedExceptionC2Ev(ptr noundef nonnull align 8 dereferenceable(8) %16) #7
  call void @__cxa_throw(ptr %16, ptr @_ZTIN6System20InterruptedExceptionE, ptr @_ZNSt9exceptionD2Ev) #8
  unreachable

17:                                               ; preds = %2
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #7
  %18 = getelementptr inbounds %"class.DynexCN::P2pContext", ptr %11, i32 0, i32 19
  call void @_ZN6System9EventLockC1ERNS_5EventE(ptr noundef nonnull align 8 dereferenceable(8) %5, ptr noundef nonnull align 8 dereferenceable(32) %18)
  call void @llvm.lifetime.start.p0(i64 1, ptr %6) #7
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #7
  %19 = getelementptr inbounds %"class.DynexCN::P2pContext", ptr %11, i32 0, i32 17
  invoke void @_ZN7DynexCN13LevinProtocolC1ERN6System13TcpConnectionE(ptr noundef nonnull align 8 dereferenceable(8) %7, ptr noundef nonnull align 8 dereferenceable(32) %19)
          to label %20 unwind label %31

20:                                               ; preds = %17
  %21 = load ptr, ptr %4, align 8, !tbaa !5
  %22 = invoke noundef zeroext i1 @_ZN7DynexCN13LevinProtocol11readCommandERNS0_7CommandE(ptr noundef nonnull align 8 dereferenceable(8) %7, ptr noundef nonnull align 8 dereferenceable(32) %21)
          to label %23 unwind label %31

23:                                               ; preds = %20
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #7
  %24 = zext i1 %22 to i8
  store i8 %24, ptr %6, align 1, !tbaa !25
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #7
  %25 = call i64 @_ZNSt6chrono3_V212steady_clock3nowEv() #7
  %26 = getelementptr inbounds %"class.std::chrono::time_point", ptr %10, i32 0, i32 0
  %27 = getelementptr inbounds %"class.std::chrono::duration", ptr %26, i32 0, i32 0
  store i64 %25, ptr %27, align 8
  %28 = getelementptr inbounds %"class.DynexCN::P2pContext", ptr %11, i32 0, i32 12
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %28, ptr align 8 %10, i64 8, i1 false), !tbaa.struct !26
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #7
  %29 = load i8, ptr %6, align 1, !tbaa !25, !range !23, !noundef !24
  %30 = trunc i8 %29 to i1
  call void @llvm.lifetime.end.p0(i64 1, ptr %6) #7
  call void @_ZN6System9EventLockD1Ev(ptr noundef nonnull align 8 dereferenceable(8) %5) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #7
  ret i1 %30

31:                                               ; preds = %20, %17
  %32 = landingpad { ptr, i32 }
          cleanup
  %33 = extractvalue { ptr, i32 } %32, 0
  store ptr %33, ptr %8, align 8
  %34 = extractvalue { ptr, i32 } %32, 1
  store i32 %34, ptr %9, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #7
  call void @llvm.lifetime.end.p0(i64 1, ptr %6) #7
  call void @_ZN6System9EventLockD1Ev(ptr noundef nonnull align 8 dereferenceable(8) %5) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #7
  br label %35

35:                                               ; preds = %31
  %36 = load ptr, ptr %8, align 8
  %37 = load i32, ptr %9, align 4
  %38 = insertvalue { ptr, i32 } poison, ptr %36, 0
  %39 = insertvalue { ptr, i32 } %38, i32 %37, 1
  resume { ptr, i32 } %39
}

declare ptr @__cxa_allocate_exception(i64)

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #4

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZN6System20InterruptedExceptionC2Ev(ptr noundef nonnull align 8 dereferenceable(8)) unnamed_addr #5 align 2

; Function Attrs: nounwind
declare void @_ZNSt9exceptionD2Ev(ptr noundef nonnull align 8 dereferenceable(8)) unnamed_addr #2

declare void @__cxa_throw(ptr, ptr, ptr)

declare void @_ZN6System9EventLockC1ERNS_5EventE(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(32)) unnamed_addr #6

declare void @_ZN7DynexCN13LevinProtocolC1ERN6System13TcpConnectionE(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(32)) unnamed_addr #6

declare noundef zeroext i1 @_ZN7DynexCN13LevinProtocol11readCommandERNS0_7CommandE(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(32)) #6

; Function Attrs: nounwind
declare void @_ZN6System9EventLockD1Ev(ptr noundef nonnull align 8 dereferenceable(8)) unnamed_addr #2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #5 = { inlinehint 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 #6 = { "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 #7 = { nounwind }
attributes #8 = { noreturn }

!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, !11, i64 88}
!10 = !{!"_ZTSN7DynexCN10P2pContextE", !7, i64 0, !11, i64 1, !12, i64 2, !14, i64 16, !15, i64 24, !6, i64 32, !16, i64 40, !18, i64 80, !11, i64 88, !18, i64 96, !19, i64 104, !6, i64 112, !20, i64 120, !21, i64 144, !22, i64 176, !21, i64 208, !21, i64 240}
!11 = !{!"bool", !7, i64 0}
!12 = !{!"_ZTSN7DynexCN14NetworkAddressE", !13, i64 0, !13, i64 4}
!13 = !{!"int", !7, i64 0}
!14 = !{!"long", !7, i64 0}
!15 = !{!"short", !7, i64 0}
!16 = !{!"_ZTSN6System12ContextGroupE", !6, i64 0, !17, i64 8}
!17 = !{!"_ZTSN6System18NativeContextGroupE", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24}
!18 = !{!"_ZTSNSt6chrono10time_pointINS_3_V212steady_clockENS_8durationIlSt5ratioILl1ELl1000000000EEEEEE", !19, i64 0}
!19 = !{!"_ZTSNSt6chrono8durationIlSt5ratioILl1ELl1000000000EEEE", !14, i64 0}
!20 = !{!"_ZTSN6System5TimerE", !6, i64 0, !13, i64 8, !6, i64 16}
!21 = !{!"_ZTSN6System5EventE", !6, i64 0, !11, i64 8, !6, i64 16, !6, i64 24}
!22 = !{!"_ZTSN6System13TcpConnectionE", !6, i64 0, !13, i64 8, !6, i64 16, !6, i64 24}
!23 = !{i8 0, i8 2}
!24 = !{}
!25 = !{!11, !11, i64 0}
!26 = !{i64 0, i64 8, !27}
!27 = !{!14, !14, 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.System::EventLock" = type { ptr }
%"class.DynexCN::LevinProtocol" = type { ptr }

@_ZTIN6System20InterruptedExceptionE = external dso_local constant { ptr, ptr, ptr }, align 8

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: nounwind
declare i64 @_ZNSt6chrono3_V212steady_clock3nowEv() local_unnamed_addr #1

declare i32 @__gxx_personality_v0(...)

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZN7DynexCN10P2pContext11readCommandERNS_13LevinProtocol7CommandE(ptr noundef nonnull align 8 dereferenceable(272) %0, ptr noundef nonnull align 8 dereferenceable(32) %1) local_unnamed_addr #2 align 2 personality ptr @__gxx_personality_v0 {
  %3 = alloca %"class.System::EventLock", align 8
  %4 = alloca %"class.DynexCN::LevinProtocol", align 8
  %5 = getelementptr inbounds i8, ptr %0, i64 88
  %6 = load i8, ptr %5, align 8, !tbaa !5, !range !22, !noundef !23
  %7 = trunc nuw i8 %6 to i1
  br i1 %7, label %8, label %10

8:                                                ; preds = %2
  %9 = tail call ptr @__cxa_allocate_exception(i64 8) #5
  store i64 0, ptr %9, align 16
  tail call void @_ZN6System20InterruptedExceptionC2Ev(ptr noundef nonnull align 8 dereferenceable(8) %9) #5
  tail call void @__cxa_throw(ptr nonnull %9, ptr nonnull @_ZTIN6System20InterruptedExceptionE, ptr nonnull @_ZNSt9exceptionD2Ev) #6
  unreachable

10:                                               ; preds = %2
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #5
  %11 = getelementptr inbounds i8, ptr %0, i64 240
  call void @_ZN6System9EventLockC1ERNS_5EventE(ptr noundef nonnull align 8 dereferenceable(8) %3, ptr noundef nonnull align 8 dereferenceable(32) %11)
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #5
  %12 = getelementptr inbounds i8, ptr %0, i64 176
  invoke void @_ZN7DynexCN13LevinProtocolC1ERN6System13TcpConnectionE(ptr noundef nonnull align 8 dereferenceable(8) %4, ptr noundef nonnull align 8 dereferenceable(32) %12)
          to label %13 unwind label %18

13:                                               ; preds = %10
  %14 = invoke noundef zeroext i1 @_ZN7DynexCN13LevinProtocol11readCommandERNS0_7CommandE(ptr noundef nonnull align 8 dereferenceable(8) %4, ptr noundef nonnull align 8 dereferenceable(32) %1)
          to label %15 unwind label %18

15:                                               ; preds = %13
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #5
  %16 = call i64 @_ZNSt6chrono3_V212steady_clock3nowEv() #5
  %17 = getelementptr inbounds i8, ptr %0, i64 96
  store i64 %16, ptr %17, align 8, !tbaa !24
  call void @_ZN6System9EventLockD1Ev(ptr noundef nonnull align 8 dereferenceable(8) %3) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #5
  ret i1 %14

18:                                               ; preds = %13, %10
  %19 = landingpad { ptr, i32 }
          cleanup
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #5
  call void @_ZN6System9EventLockD1Ev(ptr noundef nonnull align 8 dereferenceable(8) %3) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #5
  resume { ptr, i32 } %19
}

declare ptr @__cxa_allocate_exception(i64) local_unnamed_addr

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZN6System20InterruptedExceptionC2Ev(ptr noundef nonnull align 8 dereferenceable(8)) unnamed_addr #3 align 2

; Function Attrs: nounwind
declare void @_ZNSt9exceptionD2Ev(ptr noundef nonnull align 8 dereferenceable(8)) unnamed_addr #1

declare void @__cxa_throw(ptr, ptr, ptr) local_unnamed_addr

declare void @_ZN6System9EventLockC1ERNS_5EventE(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(32)) unnamed_addr #4

declare void @_ZN7DynexCN13LevinProtocolC1ERN6System13TcpConnectionE(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(32)) unnamed_addr #4

declare noundef zeroext i1 @_ZN7DynexCN13LevinProtocol11readCommandERNS0_7CommandE(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(32)) local_unnamed_addr #4

; Function Attrs: nounwind
declare void @_ZN6System9EventLockD1Ev(ptr noundef nonnull align 8 dereferenceable(8)) unnamed_addr #1

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

!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, !9, i64 88}
!6 = !{!"_ZTSN7DynexCN10P2pContextE", !7, i64 0, !9, i64 1, !10, i64 2, !12, i64 16, !13, i64 24, !14, i64 32, !15, i64 40, !17, i64 80, !9, i64 88, !17, i64 96, !18, i64 104, !14, i64 112, !19, i64 120, !20, i64 144, !21, i64 176, !20, i64 208, !20, i64 240}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!"bool", !7, i64 0}
!10 = !{!"_ZTSN7DynexCN14NetworkAddressE", !11, i64 0, !11, i64 4}
!11 = !{!"int", !7, i64 0}
!12 = !{!"long", !7, i64 0}
!13 = !{!"short", !7, i64 0}
!14 = !{!"any pointer", !7, i64 0}
!15 = !{!"_ZTSN6System12ContextGroupE", !14, i64 0, !16, i64 8}
!16 = !{!"_ZTSN6System18NativeContextGroupE", !14, i64 0, !14, i64 8, !14, i64 16, !14, i64 24}
!17 = !{!"_ZTSNSt6chrono10time_pointINS_3_V212steady_clockENS_8durationIlSt5ratioILl1ELl1000000000EEEEEE", !18, i64 0}
!18 = !{!"_ZTSNSt6chrono8durationIlSt5ratioILl1ELl1000000000EEEE", !12, i64 0}
!19 = !{!"_ZTSN6System5TimerE", !14, i64 0, !11, i64 8, !14, i64 16}
!20 = !{!"_ZTSN6System5EventE", !14, i64 0, !9, i64 8, !14, i64 16, !14, i64 24}
!21 = !{!"_ZTSN6System13TcpConnectionE", !14, i64 0, !11, i64 8, !14, i64 16, !14, i64 24}
!22 = !{i8 0, i8 2}
!23 = !{}
!24 = !{!12, !12, i64 0}


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