; LLVM IR from dynexcoin/Dynex :: src/DynexCNProtocol (DynexCNProtocolHandler)

; 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.DynexCN::DynexCNProtocolHandler" = type { %"struct.DynexCN::i_cn_protocol", %"class.DynexCN::IDynexCNProtocolQuery", %"class.Logging::LoggerRef", ptr, ptr, ptr, %"struct.DynexCN::p2p_endpoint_stub", ptr, %"struct.std::atomic", %"struct.std::atomic", %"class.std::recursive_mutex", %"class.std::mutex", i32, %"class.std::mutex", i32, %"struct.std::atomic.4", %"class.Tools::ObserverManager" }
%"struct.DynexCN::i_cn_protocol" = type { ptr }
%"class.DynexCN::IDynexCNProtocolQuery" = type { ptr }
%"class.Logging::LoggerRef" = type { ptr, %"class.std::__cxx11::basic_string" }
%"class.std::__cxx11::basic_string" = type { %"struct.std::__cxx11::basic_string<char>::_Alloc_hider", i64, %union.anon }
%"struct.std::__cxx11::basic_string<char>::_Alloc_hider" = type { ptr }
%union.anon = type { i64, [8 x i8] }
%"struct.DynexCN::p2p_endpoint_stub" = type { %"struct.DynexCN::IP2pEndpoint" }
%"struct.DynexCN::IP2pEndpoint" = type { ptr }
%"struct.std::atomic" = type { %"struct.std::__atomic_base" }
%"struct.std::__atomic_base" = type { i8 }
%"class.std::recursive_mutex" = type { %"class.std::__recursive_mutex_base" }
%"class.std::__recursive_mutex_base" = type { %union.pthread_mutex_t }
%union.pthread_mutex_t = type { %struct.__pthread_mutex_s }
%struct.__pthread_mutex_s = type { i32, i32, i32, i32, i32, i16, i16, %struct.__pthread_internal_list }
%struct.__pthread_internal_list = type { ptr, ptr }
%"class.std::mutex" = type { %"class.std::__mutex_base" }
%"class.std::__mutex_base" = type { %union.pthread_mutex_t }
%"struct.std::atomic.4" = type { %"struct.std::__atomic_base.5" }
%"struct.std::__atomic_base.5" = type { i64 }
%"class.Tools::ObserverManager" = type { %"class.std::vector", %"class.std::mutex" }
%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<DynexCN::IDynexCNProtocolObserver *, std::allocator<DynexCN::IDynexCNProtocolObserver *>>::_Vector_impl" }
%"struct.std::_Vector_base<DynexCN::IDynexCNProtocolObserver *, std::allocator<DynexCN::IDynexCNProtocolObserver *>>::_Vector_impl" = type { %"struct.std::_Vector_base<DynexCN::IDynexCNProtocolObserver *, std::allocator<DynexCN::IDynexCNProtocolObserver *>>::_Vector_impl_data" }
%"struct.std::_Vector_base<DynexCN::IDynexCNProtocolObserver *, std::allocator<DynexCN::IDynexCNProtocolObserver *>>::_Vector_impl_data" = type { ptr, ptr, ptr }

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN7DynexCN22DynexCNProtocolHandler16set_p2p_endpointEPNS_12IP2pEndpointE(ptr noundef nonnull align 8 dereferenceable(312) %0, ptr noundef %1) #0 align 2 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  %5 = load ptr, ptr %3, align 8
  %6 = load ptr, ptr %4, align 8, !tbaa !5
  %7 = icmp ne ptr %6, null
  br i1 %7, label %8, label %11

8:                                                ; preds = %2
  %9 = load ptr, ptr %4, align 8, !tbaa !5
  %10 = getelementptr inbounds %"class.DynexCN::DynexCNProtocolHandler", ptr %5, i32 0, i32 7
  store ptr %9, ptr %10, align 8, !tbaa !9
  br label %14

11:                                               ; preds = %2
  %12 = getelementptr inbounds %"class.DynexCN::DynexCNProtocolHandler", ptr %5, i32 0, i32 6
  %13 = getelementptr inbounds %"class.DynexCN::DynexCNProtocolHandler", ptr %5, i32 0, i32 7
  store ptr %12, ptr %13, align 8, !tbaa !9
  br label %14

14:                                               ; preds = %11, %8
  ret void
}

attributes #0 = { 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" }

!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, !6, i64 88}
!10 = !{!"_ZTSN7DynexCN22DynexCNProtocolHandlerE", !11, i64 0, !12, i64 8, !13, i64 16, !6, i64 56, !6, i64 64, !6, i64 72, !17, i64 80, !6, i64 88, !19, i64 96, !19, i64 97, !22, i64 104, !24, i64 144, !26, i64 184, !24, i64 192, !26, i64 232, !27, i64 240, !29, i64 248}
!11 = !{!"_ZTSN7DynexCN13i_cn_protocolE"}
!12 = !{!"_ZTSN7DynexCN21IDynexCNProtocolQueryE"}
!13 = !{!"_ZTSN7Logging9LoggerRefE", !6, i64 0, !14, i64 8}
!14 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE", !15, i64 0, !16, i64 8, !7, i64 16}
!15 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_Alloc_hiderE", !6, i64 0}
!16 = !{!"long", !7, i64 0}
!17 = !{!"_ZTSN7DynexCN17p2p_endpoint_stubE", !18, i64 0}
!18 = !{!"_ZTSN7DynexCN12IP2pEndpointE"}
!19 = !{!"_ZTSSt6atomicIbE", !20, i64 0}
!20 = !{!"_ZTSSt13__atomic_baseIbE", !21, i64 0}
!21 = !{!"bool", !7, i64 0}
!22 = !{!"_ZTSSt15recursive_mutex", !23, i64 0}
!23 = !{!"_ZTSSt22__recursive_mutex_base", !7, i64 0}
!24 = !{!"_ZTSSt5mutex", !25, i64 0}
!25 = !{!"_ZTSSt12__mutex_base", !7, i64 0}
!26 = !{!"int", !7, i64 0}
!27 = !{!"_ZTSSt6atomicImE", !28, i64 0}
!28 = !{!"_ZTSSt13__atomic_baseImE", !16, i64 0}
!29 = !{!"_ZTSN5Tools15ObserverManagerIN7DynexCN24IDynexCNProtocolObserverEEE", !30, i64 0, !24, i64 24}
!30 = !{!"_ZTSSt6vectorIPN7DynexCN24IDynexCNProtocolObserverESaIS2_EE", !31, i64 0}
!31 = !{!"_ZTSSt12_Vector_baseIPN7DynexCN24IDynexCNProtocolObserverESaIS2_EE", !32, i64 0}
!32 = !{!"_ZTSNSt12_Vector_baseIPN7DynexCN24IDynexCNProtocolObserverESaIS2_EE12_Vector_implE", !33, i64 0}
!33 = !{!"_ZTSNSt12_Vector_baseIPN7DynexCN24IDynexCNProtocolObserverESaIS2_EE17_Vector_impl_dataE", !6, i64 0, !6, i64 8, !6, i64 16}


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

; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: write) uwtable
define dso_local void @_ZN7DynexCN22DynexCNProtocolHandler16set_p2p_endpointEPNS_12IP2pEndpointE(ptr noundef nonnull align 8 dereferenceable(312) %0, ptr noundef %1) local_unnamed_addr #0 align 2 {
  %.not = icmp eq ptr %1, null
  %3 = getelementptr inbounds i8, ptr %0, i64 80
  %spec.select = select i1 %.not, ptr %3, ptr %1
  %4 = getelementptr inbounds i8, ptr %0, i64 88
  store ptr %spec.select, ptr %4, align 8
  ret void
}

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: write) 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)"}


; Effective O3 passes: GlobalOptPass,InstCombinePass,JumpThreadingPass,MergedLoadStoreMotionPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass