; LLVM IR from dynexcoin/Dynex :: src/P2p/P2pNodeConfig.ll (ZNK7DynexCN13P2pNodeConfig12getNetworkIdEv)

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

%"struct.Crypto::Uuid" = type { [16 x i8] }
%"class.DynexCN::P2pNodeConfig" = type { %"class.DynexCN::NetNodeConfig.base", %"class.std::chrono::duration", %"class.std::chrono::duration", %"class.std::chrono::duration", %"class.std::chrono::duration", %"struct.Crypto::Uuid", i64, i64, i64, i64 }
%"class.DynexCN::NetNodeConfig.base" = type <{ %"class.std::__cxx11::basic_string", i16, i16, i8, [3 x i8], %"class.std::vector", %"class.std::vector.3", %"class.std::vector.3", %"class.std::vector.3", i8, [7 x i8], %"class.std::__cxx11::basic_string", %"class.std::__cxx11::basic_string", i8 }>
%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<DynexCN::PeerlistEntry, std::allocator<DynexCN::PeerlistEntry>>::_Vector_impl" }
%"struct.std::_Vector_base<DynexCN::PeerlistEntry, std::allocator<DynexCN::PeerlistEntry>>::_Vector_impl" = type { %"struct.std::_Vector_base<DynexCN::PeerlistEntry, std::allocator<DynexCN::PeerlistEntry>>::_Vector_impl_data" }
%"struct.std::_Vector_base<DynexCN::PeerlistEntry, std::allocator<DynexCN::PeerlistEntry>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"class.std::vector.3" = type { %"struct.std::_Vector_base.4" }
%"struct.std::_Vector_base.4" = type { %"struct.std::_Vector_base<DynexCN::NetworkAddress, std::allocator<DynexCN::NetworkAddress>>::_Vector_impl" }
%"struct.std::_Vector_base<DynexCN::NetworkAddress, std::allocator<DynexCN::NetworkAddress>>::_Vector_impl" = type { %"struct.std::_Vector_base<DynexCN::NetworkAddress, std::allocator<DynexCN::NetworkAddress>>::_Vector_impl_data" }
%"struct.std::_Vector_base<DynexCN::NetworkAddress, std::allocator<DynexCN::NetworkAddress>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"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] }
%"class.std::chrono::duration" = type { i64 }

; 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) #0

; Function Attrs: mustprogress uwtable
define dso_local { i64, i64 } @_ZNK7DynexCN13P2pNodeConfig12getNetworkIdEv(ptr noundef nonnull align 8 dereferenceable(296) %0) #1 align 2 {
  %2 = alloca %"struct.Crypto::Uuid", align 1
  %3 = alloca ptr, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  %4 = load ptr, ptr %3, align 8
  %5 = call noundef zeroext i1 @_ZNK7DynexCN13NetNodeConfig10getTestnetEv(ptr noundef nonnull align 8 dereferenceable(209) %4)
  br i1 %5, label %6, label %14

6:                                                ; preds = %1
  %7 = getelementptr inbounds %"class.DynexCN::P2pNodeConfig", ptr %4, i32 0, i32 5
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %2, ptr align 8 %7, i64 16, i1 false), !tbaa.struct !9
  %8 = getelementptr inbounds %"struct.Crypto::Uuid", ptr %2, i32 0, i32 0
  %9 = getelementptr inbounds [16 x i8], ptr %8, i64 0, i64 0
  %10 = load i8, ptr %9, align 1, !tbaa !10
  %11 = zext i8 %10 to i32
  %12 = add nsw i32 %11, 1
  %13 = trunc i32 %12 to i8
  store i8 %13, ptr %9, align 1, !tbaa !10
  br label %16

14:                                               ; preds = %1
  %15 = getelementptr inbounds %"class.DynexCN::P2pNodeConfig", ptr %4, i32 0, i32 5
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %2, ptr align 8 %15, i64 16, i1 false), !tbaa.struct !9
  br label %16

16:                                               ; preds = %14, %6
  %17 = getelementptr inbounds %"struct.Crypto::Uuid", ptr %2, i32 0, i32 0
  %18 = load { i64, i64 }, ptr %17, align 1
  ret { i64, i64 } %18
}

declare noundef zeroext i1 @_ZNK7DynexCN13NetNodeConfig10getTestnetEv(ptr noundef nonnull align 8 dereferenceable(209)) #2

attributes #0 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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 = { "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 = !{i64 0, i64 16, !10}
!10 = !{!7, !7, 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"

; Function Attrs: mustprogress uwtable
define dso_local { i64, i64 } @_ZNK7DynexCN13P2pNodeConfig12getNetworkIdEv(ptr noundef nonnull align 8 dereferenceable(296) %0) local_unnamed_addr #0 align 2 {
  %2 = tail call noundef zeroext i1 @_ZNK7DynexCN13NetNodeConfig10getTestnetEv(ptr noundef nonnull align 8 dereferenceable(209) %0)
  %3 = getelementptr inbounds i8, ptr %0, i64 248
  %.sroa.0.0.copyload = load i64, ptr %3, align 8
  %4 = zext i1 %2 to i64
  %.sroa.0.sroa.0.0 = add i64 %.sroa.0.0.copyload, %4
  %.sroa.0.sroa.5.sroa.0.0.in = and i64 %.sroa.0.0.copyload, -256
  %.sroa.5.0.in = getelementptr inbounds i8, ptr %0, i64 256
  %.sroa.5.0 = load i64, ptr %.sroa.5.0.in, align 8, !tbaa !5
  %.sroa.0.sroa.0.0.insert.ext = and i64 %.sroa.0.sroa.0.0, 255
  %.sroa.0.sroa.0.0.insert.insert = or disjoint i64 %.sroa.0.sroa.0.0.insert.ext, %.sroa.0.sroa.5.sroa.0.0.in
  %.fca.0.insert = insertvalue { i64, i64 } poison, i64 %.sroa.0.sroa.0.0.insert.insert, 0
  %.fca.1.insert = insertvalue { i64, i64 } %.fca.0.insert, i64 %.sroa.5.0, 1
  ret { i64, i64 } %.fca.1.insert
}

declare noundef zeroext i1 @_ZNK7DynexCN13NetNodeConfig10getTestnetEv(ptr noundef nonnull align 8 dereferenceable(209)) 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 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}


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