; LLVM IR from dynexcoin/Dynex :: src/P2p (PeerListManager)

; 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.DynexCN::PeerlistEntry" = type { %"struct.DynexCN::NetworkAddress", i64, i64 }
%"struct.DynexCN::NetworkAddress" = type { i32, i32 }

@_ZTISt9exception = external constant ptr

declare i32 @__gxx_personality_v0(...)

; 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 nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.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: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZN7DynexCN15PeerlistManager18set_peer_just_seenEmRKNS_14NetworkAddressE(ptr noundef nonnull align 8 dereferenceable(136) %0, i64 noundef %1, ptr noundef nonnull align 1 dereferenceable(8) %2) #2 align 2 personality ptr @__gxx_personality_v0 {
  %4 = alloca i1, align 1
  %5 = alloca ptr, align 8
  %6 = alloca i64, align 8
  %7 = alloca ptr, align 8
  %8 = alloca %"struct.DynexCN::PeerlistEntry", align 1
  %9 = alloca ptr, align 8
  %10 = alloca i32, align 4
  %11 = alloca ptr, align 8
  store ptr %0, ptr %5, align 8, !tbaa !5
  store i64 %1, ptr %6, align 8, !tbaa !9
  store ptr %2, ptr %7, align 8, !tbaa !5
  %12 = load ptr, ptr %5, align 8
  call void @llvm.lifetime.start.p0(i64 24, ptr %8) #5
  %13 = load ptr, ptr %7, align 8, !tbaa !5
  %14 = getelementptr inbounds %"struct.DynexCN::PeerlistEntry", ptr %8, i32 0, i32 0
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %14, ptr align 1 %13, i64 8, i1 false), !tbaa.struct !11
  %15 = load i64, ptr %6, align 8, !tbaa !9
  %16 = getelementptr inbounds %"struct.DynexCN::PeerlistEntry", ptr %8, i32 0, i32 1
  store i64 %15, ptr %16, align 1, !tbaa !14
  %17 = call i64 @time(ptr noundef null) #5
  %18 = getelementptr inbounds %"struct.DynexCN::PeerlistEntry", ptr %8, i32 0, i32 2
  store i64 %17, ptr %18, align 1, !tbaa !17
  %19 = invoke noundef zeroext i1 @_ZN7DynexCN15PeerlistManager22append_with_peer_whiteERKNS_13PeerlistEntryE(ptr noundef nonnull align 8 dereferenceable(136) %12, ptr noundef nonnull align 1 dereferenceable(24) %8)
          to label %20 unwind label %21

20:                                               ; preds = %3
  store i1 %19, ptr %4, align 1
  call void @llvm.lifetime.end.p0(i64 24, ptr %8) #5
  br label %33

21:                                               ; preds = %3
  %22 = landingpad { ptr, i32 }
          cleanup
          catch ptr @_ZTISt9exception
  %23 = extractvalue { ptr, i32 } %22, 0
  store ptr %23, ptr %9, align 8
  %24 = extractvalue { ptr, i32 } %22, 1
  store i32 %24, ptr %10, align 4
  call void @llvm.lifetime.end.p0(i64 24, ptr %8) #5
  br label %25

25:                                               ; preds = %21
  %26 = load i32, ptr %10, align 4
  %27 = call i32 @llvm.eh.typeid.for.p0(ptr @_ZTISt9exception) #5
  %28 = icmp eq i32 %26, %27
  br i1 %28, label %29, label %35

29:                                               ; preds = %25
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #5
  %30 = load ptr, ptr %9, align 8
  %31 = call ptr @__cxa_begin_catch(ptr %30) #5
  store ptr %31, ptr %11, align 8
  call void @__cxa_end_catch()
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #5
  br label %32

32:                                               ; preds = %29
  store i1 false, ptr %4, align 1
  br label %33

33:                                               ; preds = %32, %20
  %34 = load i1, ptr %4, align 1
  ret i1 %34

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

; Function Attrs: nounwind
declare i64 @time(ptr noundef) #3

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZN7DynexCN15PeerlistManager22append_with_peer_whiteERKNS_13PeerlistEntryE(ptr noundef nonnull align 8 dereferenceable(136), ptr noundef nonnull align 1 dereferenceable(24)) #2 align 2

; Function Attrs: nounwind memory(none)
declare i32 @llvm.eh.typeid.for.p0(ptr) #4

declare ptr @__cxa_begin_catch(ptr)

declare void @__cxa_end_catch()

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 = { 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 #4 = { nounwind memory(none) }
attributes #5 = { 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 = !{i64 0, i64 4, !12, i64 4, i64 4, !12}
!12 = !{!13, !13, i64 0}
!13 = !{!"int", !7, i64 0}
!14 = !{!15, !10, i64 8}
!15 = !{!"_ZTSN7DynexCN13PeerlistEntryE", !16, i64 0, !10, i64 8, !10, i64 16}
!16 = !{!"_ZTSN7DynexCN14NetworkAddressE", !13, i64 0, !13, i64 4}
!17 = !{!15, !10, 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"

%"struct.DynexCN::PeerlistEntry" = type { %"struct.DynexCN::NetworkAddress", i64, i64 }
%"struct.DynexCN::NetworkAddress" = type { i32, i32 }

@_ZTISt9exception = external constant ptr

declare i32 @__gxx_personality_v0(...)

; 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: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZN7DynexCN15PeerlistManager18set_peer_just_seenEmRKNS_14NetworkAddressE(ptr noundef nonnull align 8 dereferenceable(136) %0, i64 noundef %1, ptr nocapture noundef nonnull readonly align 1 dereferenceable(8) %2) local_unnamed_addr #1 align 2 personality ptr @__gxx_personality_v0 {
  %4 = alloca %"struct.DynexCN::PeerlistEntry", align 8
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %4) #4
  %5 = load i64, ptr %2, align 1
  store i64 %5, ptr %4, align 8
  %6 = getelementptr inbounds i8, ptr %4, i64 8
  store i64 %1, ptr %6, align 8, !tbaa !5
  %7 = tail call i64 @time(ptr noundef null) #4
  %8 = getelementptr inbounds i8, ptr %4, i64 16
  store i64 %7, ptr %8, align 8, !tbaa !12
  %9 = invoke noundef zeroext i1 @_ZN7DynexCN15PeerlistManager22append_with_peer_whiteERKNS_13PeerlistEntryE(ptr noundef nonnull align 8 dereferenceable(136) %0, ptr noundef nonnull align 1 dereferenceable(24) %4)
          to label %10 unwind label %11

10:                                               ; preds = %3
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %4) #4
  br label %19

11:                                               ; preds = %3
  %12 = landingpad { ptr, i32 }
          cleanup
          catch ptr @_ZTISt9exception
  %13 = extractvalue { ptr, i32 } %12, 1
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %4) #4
  %14 = call i32 @llvm.eh.typeid.for.p0(ptr nonnull @_ZTISt9exception) #4
  %15 = icmp eq i32 %13, %14
  br i1 %15, label %16, label %20

16:                                               ; preds = %11
  %17 = extractvalue { ptr, i32 } %12, 0
  %18 = call ptr @__cxa_begin_catch(ptr %17) #4
  call void @__cxa_end_catch()
  br label %19

19:                                               ; preds = %16, %10
  %.0 = phi i1 [ %9, %10 ], [ false, %16 ]
  ret i1 %.0

20:                                               ; preds = %11
  resume { ptr, i32 } %12
}

; Function Attrs: nounwind
declare i64 @time(ptr noundef) local_unnamed_addr #2

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZN7DynexCN15PeerlistManager22append_with_peer_whiteERKNS_13PeerlistEntryE(ptr noundef nonnull align 8 dereferenceable(136), ptr noundef nonnull align 1 dereferenceable(24)) local_unnamed_addr #1 align 2

; Function Attrs: nofree nosync nounwind memory(none)
declare i32 @llvm.eh.typeid.for.p0(ptr) #3

declare ptr @__cxa_begin_catch(ptr) local_unnamed_addr

declare void @__cxa_end_catch() local_unnamed_addr

attributes #0 = { mustprogress nocallback nofree nosync 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 = { 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 = { nofree nosync nounwind memory(none) }
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, !11, i64 8}
!6 = !{!"_ZTSN7DynexCN13PeerlistEntryE", !7, i64 0, !11, i64 8, !11, i64 16}
!7 = !{!"_ZTSN7DynexCN14NetworkAddressE", !8, i64 0, !8, i64 4}
!8 = !{!"int", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C++ TBAA"}
!11 = !{!"long", !9, i64 0}
!12 = !{!6, !11, i64 16}


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