; LLVM IR from UBIC-repo/core :: Network/Network.ll (ZN7Network14syncBlockchainEv)

; 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.std::map" = type { %"class.std::_Rb_tree" }
%"class.std::_Rb_tree" = type { %"struct.std::_Rb_tree<std::__cxx11::basic_string<char>, std::pair<const std::__cxx11::basic_string<char>, std::shared_ptr<PeerInterface>>, std::_Select1st<std::pair<const std::__cxx11::basic_string<char>, std::shared_ptr<PeerInterface>>>, std::less<std::__cxx11::basic_string<char>>>::_Rb_tree_impl" }
%"struct.std::_Rb_tree<std::__cxx11::basic_string<char>, std::pair<const std::__cxx11::basic_string<char>, std::shared_ptr<PeerInterface>>, std::_Select1st<std::pair<const std::__cxx11::basic_string<char>, std::shared_ptr<PeerInterface>>>, std::less<std::__cxx11::basic_string<char>>>::_Rb_tree_impl" = type { [8 x i8], %"struct.std::_Rb_tree_header" }
%"struct.std::_Rb_tree_header" = type { %"struct.std::_Rb_tree_node_base", i64 }
%"struct.std::_Rb_tree_node_base" = type { i32, ptr, ptr, ptr }
%class.Log = type { i8, i8, ptr, %"class.std::basic_filebuf" }
%"class.std::basic_filebuf" = type { %"class.std::basic_streambuf", %union.pthread_mutex_t, %"class.std::__basic_file", i32, %struct.__mbstate_t, %struct.__mbstate_t, %struct.__mbstate_t, ptr, i64, i8, i8, i8, i8, ptr, ptr, i8, ptr, ptr, i64, ptr, ptr }
%"class.std::basic_streambuf" = type { ptr, ptr, ptr, ptr, ptr, ptr, ptr, %"class.std::locale" }
%"class.std::locale" = type { ptr }
%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::__basic_file" = type <{ ptr, i8, [7 x i8] }>
%struct.__mbstate_t = type { i32, %union.anon.4 }
%union.anon.4 = type { i32 }
%"class.std::thread" = type { %"class.std::thread::id" }
%"class.std::thread::id" = type { i64 }

@_ZN7Network6syncedE = external dso_local global i8, align 1
@_ZN7Network9isSyncingE = external dso_local global i8, align 1
@_ZN7Network14lastPeerLookupE = external dso_local global i64, align 8
@.str.39 = external hidden unnamed_addr constant [26 x i8], align 1
@.str.40 = external hidden unnamed_addr constant [43 x i8], align 1
@.str.41 = external hidden unnamed_addr constant [24 x i8], align 1
@.str.42 = external hidden unnamed_addr constant [22 x i8], align 1
@.str.43 = external hidden unnamed_addr constant [15 x i8], align 1

; 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

declare i32 @__gxx_personality_v0(...)

declare void @_ZN3LogC1Eh(ptr noundef nonnull align 8 dereferenceable(256), i8 noundef zeroext) unnamed_addr #1

declare noundef nonnull align 8 dereferenceable(256) ptr @_ZN3LoglsEPKc(ptr noundef nonnull align 8 dereferenceable(256), ptr noundef) #1

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN7Network12lookForPeersEv() #3 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(48) ptr @_ZN5Peers8InstanceEv() #4 align 2

declare void @_ZNSt6thread6detachEv(ptr noundef nonnull align 8 dereferenceable(8)) #1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(32) ptr @_ZN5Chain8InstanceEv() #4 align 2

declare noundef i32 @_ZN5Chain26getCurrentBlockchainHeightEv(ptr noundef nonnull align 8 dereferenceable(32)) #1

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

declare void @_ZN5Peers8getPeersB5cxx11Ev(ptr dead_on_unwind writable sret(%"class.std::map") align 8, ptr noundef nonnull align 8 dereferenceable(48)) #1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt3mapINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt10shared_ptrI13PeerInterfaceESt4lessIS5_ESaISt4pairIKS5_S8_EEED2Ev(ptr noundef nonnull align 8 dereferenceable(48)) unnamed_addr #4 align 2

declare i32 @sleep(i32 noundef) #1

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN7Network14syncBlockchainEv(ptr noundef nonnull align 1 dereferenceable(1) %0) #3 align 2 personality ptr @__gxx_personality_v0 {
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  %4 = alloca %class.Log, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca %class.Log, align 8
  %8 = alloca i32, align 4
  %9 = alloca %"class.std::map", align 8
  %10 = alloca %class.Log, align 8
  %11 = alloca %"class.std::thread", align 8
  %12 = alloca ptr, align 8
  %13 = alloca %class.Log, align 8
  %14 = alloca ptr, align 8
  %15 = alloca i32, align 4
  %16 = alloca i16, align 2
  %17 = alloca %class.Log, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  %18 = load ptr, ptr %2, align 8
  br label %19

19:                                               ; preds = %89, %1
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #5
  %20 = call noundef nonnull align 8 dereferenceable(48) ptr @_ZN5Peers8InstanceEv()
  store ptr %20, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 256, ptr %4) #5
  call void @_ZN3LogC1Eh(ptr noundef nonnull align 8 dereferenceable(256) %4, i8 noundef zeroext 0)
  %21 = invoke noundef nonnull align 8 dereferenceable(256) ptr @_ZN3LoglsEPKc(ptr noundef nonnull align 8 dereferenceable(256) %4, ptr noundef @.str.39)
          to label %22 unwind label %28

22:                                               ; preds = %19
  call void @_ZN3LogD1Ev(ptr noundef nonnull align 8 dereferenceable(256) %4) #5
  call void @llvm.lifetime.end.p0(i64 256, ptr %4) #5
  %23 = load i8, ptr @_ZN7Network9isSyncingE, align 1, !tbaa !9, !range !11, !noundef !12
  %24 = trunc i8 %23 to i1
  br i1 %24, label %25, label %36

25:                                               ; preds = %22
  call void @llvm.lifetime.start.p0(i64 256, ptr %7) #5
  call void @_ZN3LogC1Eh(ptr noundef nonnull align 8 dereferenceable(256) %7, i8 noundef zeroext 0)
  %26 = invoke noundef nonnull align 8 dereferenceable(256) ptr @_ZN3LoglsEPKc(ptr noundef nonnull align 8 dereferenceable(256) %7, ptr noundef @.str.40)
          to label %27 unwind label %32

27:                                               ; preds = %25
  call void @_ZN3LogD1Ev(ptr noundef nonnull align 8 dereferenceable(256) %7) #5
  call void @llvm.lifetime.end.p0(i64 256, ptr %7) #5
  store i32 1, ptr %8, align 4
  br label %87

28:                                               ; preds = %19
  %29 = landingpad { ptr, i32 }
          cleanup
  %30 = extractvalue { ptr, i32 } %29, 0
  store ptr %30, ptr %5, align 8
  %31 = extractvalue { ptr, i32 } %29, 1
  store i32 %31, ptr %6, align 4
  call void @_ZN3LogD1Ev(ptr noundef nonnull align 8 dereferenceable(256) %4) #5
  call void @llvm.lifetime.end.p0(i64 256, ptr %4) #5
  br label %94

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

36:                                               ; preds = %22
  store i8 1, ptr @_ZN7Network9isSyncingE, align 1, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 48, ptr %9) #5
  %37 = load ptr, ptr %3, align 8, !tbaa !5
  call void @_ZN5Peers8getPeersB5cxx11Ev(ptr dead_on_unwind writable sret(%"class.std::map") align 8 %9, ptr noundef nonnull align 8 dereferenceable(48) %37)
  %38 = call noundef i64 @_ZNKSt3mapINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt10shared_ptrI13PeerInterfaceESt4lessIS5_ESaISt4pairIKS5_S8_EEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(48) %9) #5
  %39 = icmp ult i64 %38, 10
  br i1 %39, label %40, label %46

40:                                               ; preds = %36
  %41 = invoke noundef i64 @_ZN4Time19getCurrentTimestampEv()
          to label %42 unwind label %53

42:                                               ; preds = %40
  %43 = load i64, ptr @_ZN7Network14lastPeerLookupE, align 8, !tbaa !13
  %44 = sub i64 %41, %43
  %45 = icmp ugt i64 %44, 86400
  br label %46

46:                                               ; preds = %42, %36
  %47 = phi i1 [ false, %36 ], [ %45, %42 ]
  call void @_ZNSt3mapINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt10shared_ptrI13PeerInterfaceESt4lessIS5_ESaISt4pairIKS5_S8_EEED2Ev(ptr noundef nonnull align 8 dereferenceable(48) %9) #5
  call void @llvm.lifetime.end.p0(i64 48, ptr %9) #5
  br i1 %47, label %48, label %65

48:                                               ; preds = %46
  call void @llvm.lifetime.start.p0(i64 256, ptr %10) #5
  call void @_ZN3LogC1Eh(ptr noundef nonnull align 8 dereferenceable(256) %10, i8 noundef zeroext 0)
  %49 = invoke noundef nonnull align 8 dereferenceable(256) ptr @_ZN3LoglsEPKc(ptr noundef nonnull align 8 dereferenceable(256) %10, ptr noundef @.str.41)
          to label %50 unwind label %57

50:                                               ; preds = %48
  call void @_ZN3LogD1Ev(ptr noundef nonnull align 8 dereferenceable(256) %10) #5
  call void @llvm.lifetime.end.p0(i64 256, ptr %10) #5
  %51 = call noundef i64 @_ZN4Time19getCurrentTimestampEv()
  store i64 %51, ptr @_ZN7Network14lastPeerLookupE, align 8, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #5
  store ptr @_ZN7Network12lookForPeersEv, ptr %12, align 8, !tbaa !5
  call void @_ZNSt6threadC2IPFvvEJEvEEOT_DpOT0_(ptr noundef nonnull align 8 dereferenceable(8) %11, ptr noundef nonnull align 8 dereferenceable(8) %12)
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #5
  invoke void @_ZNSt6thread6detachEv(ptr noundef nonnull align 8 dereferenceable(8) %11)
          to label %52 unwind label %61

52:                                               ; preds = %50
  call void @_ZNSt6threadD2Ev(ptr noundef nonnull align 8 dereferenceable(8) %11) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #5
  br label %65

53:                                               ; preds = %40
  %54 = landingpad { ptr, i32 }
          cleanup
  %55 = extractvalue { ptr, i32 } %54, 0
  store ptr %55, ptr %5, align 8
  %56 = extractvalue { ptr, i32 } %54, 1
  store i32 %56, ptr %6, align 4
  call void @_ZNSt3mapINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt10shared_ptrI13PeerInterfaceESt4lessIS5_ESaISt4pairIKS5_S8_EEED2Ev(ptr noundef nonnull align 8 dereferenceable(48) %9) #5
  call void @llvm.lifetime.end.p0(i64 48, ptr %9) #5
  br label %94

57:                                               ; preds = %48
  %58 = landingpad { ptr, i32 }
          cleanup
  %59 = extractvalue { ptr, i32 } %58, 0
  store ptr %59, ptr %5, align 8
  %60 = extractvalue { ptr, i32 } %58, 1
  store i32 %60, ptr %6, align 4
  call void @_ZN3LogD1Ev(ptr noundef nonnull align 8 dereferenceable(256) %10) #5
  call void @llvm.lifetime.end.p0(i64 256, ptr %10) #5
  br label %94

61:                                               ; preds = %50
  %62 = landingpad { ptr, i32 }
          cleanup
  %63 = extractvalue { ptr, i32 } %62, 0
  store ptr %63, ptr %5, align 8
  %64 = extractvalue { ptr, i32 } %62, 1
  store i32 %64, ptr %6, align 4
  call void @_ZNSt6threadD2Ev(ptr noundef nonnull align 8 dereferenceable(8) %11) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #5
  br label %94

65:                                               ; preds = %52, %46
  call void @llvm.lifetime.start.p0(i64 256, ptr %13) #5
  call void @_ZN3LogC1Eh(ptr noundef nonnull align 8 dereferenceable(256) %13, i8 noundef zeroext 0)
  %66 = invoke noundef nonnull align 8 dereferenceable(256) ptr @_ZN3LoglsEPKc(ptr noundef nonnull align 8 dereferenceable(256) %13, ptr noundef @.str.42)
          to label %67 unwind label %79

67:                                               ; preds = %65
  call void @_ZN3LogD1Ev(ptr noundef nonnull align 8 dereferenceable(256) %13) #5
  call void @llvm.lifetime.end.p0(i64 256, ptr %13) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #5
  %68 = call noundef nonnull align 8 dereferenceable(32) ptr @_ZN5Chain8InstanceEv()
  store ptr %68, ptr %14, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #5
  call void @llvm.lifetime.start.p0(i64 2, ptr %16) #5
  store i16 1000, ptr %16, align 2, !tbaa !15
  br label %69

69:                                               ; preds = %73, %67
  %70 = load i8, ptr @_ZN7Network6syncedE, align 1, !tbaa !9, !range !11, !noundef !12
  %71 = trunc i8 %70 to i1
  %72 = xor i1 %71, true
  br i1 %72, label %73, label %83

73:                                               ; preds = %69
  %74 = load ptr, ptr %14, align 8, !tbaa !5
  %75 = call noundef i32 @_ZN5Chain26getCurrentBlockchainHeightEv(ptr noundef nonnull align 8 dereferenceable(32) %74)
  %76 = add i32 %75, 1
  store i32 %76, ptr %15, align 4, !tbaa !17
  %77 = load i32, ptr %15, align 4, !tbaa !17
  %78 = load i16, ptr %16, align 2, !tbaa !15
  call void @_ZN7Network9getBlocksEjtRb(ptr noundef nonnull align 1 dereferenceable(1) %18, i32 noundef %77, i16 noundef zeroext %78, ptr noundef nonnull align 1 dereferenceable(1) @_ZN7Network6syncedE)
  br label %69, !llvm.loop !19

79:                                               ; preds = %65
  %80 = landingpad { ptr, i32 }
          cleanup
  %81 = extractvalue { ptr, i32 } %80, 0
  store ptr %81, ptr %5, align 8
  %82 = extractvalue { ptr, i32 } %80, 1
  store i32 %82, ptr %6, align 4
  call void @_ZN3LogD1Ev(ptr noundef nonnull align 8 dereferenceable(256) %13) #5
  call void @llvm.lifetime.end.p0(i64 256, ptr %13) #5
  br label %94

83:                                               ; preds = %69
  call void @llvm.lifetime.start.p0(i64 256, ptr %17) #5
  call void @_ZN3LogC1Eh(ptr noundef nonnull align 8 dereferenceable(256) %17, i8 noundef zeroext 0)
  %84 = invoke noundef nonnull align 8 dereferenceable(256) ptr @_ZN3LoglsEPKc(ptr noundef nonnull align 8 dereferenceable(256) %17, ptr noundef @.str.43)
          to label %85 unwind label %90

85:                                               ; preds = %83
  call void @_ZN3LogD1Ev(ptr noundef nonnull align 8 dereferenceable(256) %17) #5
  call void @llvm.lifetime.end.p0(i64 256, ptr %17) #5
  store i8 0, ptr @_ZN7Network9isSyncingE, align 1, !tbaa !9
  %86 = call i32 @sleep(i32 noundef 20)
  call void @llvm.lifetime.end.p0(i64 2, ptr %16) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #5
  store i32 0, ptr %8, align 4
  br label %87

87:                                               ; preds = %85, %27
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #5
  %88 = load i32, ptr %8, align 4
  switch i32 %88, label %101 [
    i32 0, label %89
    i32 1, label %95
  ]

89:                                               ; preds = %87
  br label %19, !llvm.loop !21

90:                                               ; preds = %83
  %91 = landingpad { ptr, i32 }
          cleanup
  %92 = extractvalue { ptr, i32 } %91, 0
  store ptr %92, ptr %5, align 8
  %93 = extractvalue { ptr, i32 } %91, 1
  store i32 %93, ptr %6, align 4
  call void @_ZN3LogD1Ev(ptr noundef nonnull align 8 dereferenceable(256) %17) #5
  call void @llvm.lifetime.end.p0(i64 256, ptr %17) #5
  call void @llvm.lifetime.end.p0(i64 2, ptr %16) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #5
  br label %94

94:                                               ; preds = %90, %79, %61, %57, %53, %32, %28
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #5
  br label %96

95:                                               ; preds = %87
  ret void

96:                                               ; preds = %94
  %97 = load ptr, ptr %5, align 8
  %98 = load i32, ptr %6, align 4
  %99 = insertvalue { ptr, i32 } poison, ptr %97, 0
  %100 = insertvalue { ptr, i32 } %99, i32 %98, 1
  resume { ptr, i32 } %100

101:                                              ; preds = %87
  unreachable
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZNKSt3mapINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt10shared_ptrI13PeerInterfaceESt4lessIS5_ESaISt4pairIKS5_S8_EEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(48)) #4 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef i64 @_ZN4Time19getCurrentTimestampEv() #3 align 2

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN7Network9getBlocksEjtRb(ptr noundef nonnull align 1 dereferenceable(1), i32 noundef, i16 noundef zeroext, ptr noundef nonnull align 1 dereferenceable(1)) #3 align 2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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" }
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 = { 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 #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 = !{!"bool", !7, i64 0}
!11 = !{i8 0, i8 2}
!12 = !{}
!13 = !{!14, !14, i64 0}
!14 = !{!"long", !7, i64 0}
!15 = !{!16, !16, i64 0}
!16 = !{!"short", !7, i64 0}
!17 = !{!18, !18, i64 0}
!18 = !{!"int", !7, i64 0}
!19 = distinct !{!19, !20}
!20 = !{!"llvm.loop.mustprogress"}
!21 = distinct !{!21, !20}


; 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.std::map" = type { %"class.std::_Rb_tree" }
%"class.std::_Rb_tree" = type { %"struct.std::_Rb_tree<std::__cxx11::basic_string<char>, std::pair<const std::__cxx11::basic_string<char>, std::shared_ptr<PeerInterface>>, std::_Select1st<std::pair<const std::__cxx11::basic_string<char>, std::shared_ptr<PeerInterface>>>, std::less<std::__cxx11::basic_string<char>>>::_Rb_tree_impl" }
%"struct.std::_Rb_tree<std::__cxx11::basic_string<char>, std::pair<const std::__cxx11::basic_string<char>, std::shared_ptr<PeerInterface>>, std::_Select1st<std::pair<const std::__cxx11::basic_string<char>, std::shared_ptr<PeerInterface>>>, std::less<std::__cxx11::basic_string<char>>>::_Rb_tree_impl" = type { [8 x i8], %"struct.std::_Rb_tree_header" }
%"struct.std::_Rb_tree_header" = type { %"struct.std::_Rb_tree_node_base", i64 }
%"struct.std::_Rb_tree_node_base" = type { i32, ptr, ptr, ptr }
%class.Log = type { i8, i8, ptr, %"class.std::basic_filebuf" }
%"class.std::basic_filebuf" = type { %"class.std::basic_streambuf", %union.pthread_mutex_t, %"class.std::__basic_file", i32, %struct.__mbstate_t, %struct.__mbstate_t, %struct.__mbstate_t, ptr, i64, i8, i8, i8, i8, ptr, ptr, i8, ptr, ptr, i64, ptr, ptr }
%"class.std::basic_streambuf" = type { ptr, ptr, ptr, ptr, ptr, ptr, ptr, %"class.std::locale" }
%"class.std::locale" = type { ptr }
%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::__basic_file" = type <{ ptr, i8, [7 x i8] }>
%struct.__mbstate_t = type { i32, %union.anon.4 }
%union.anon.4 = type { i32 }
%"class.std::thread" = type { %"class.std::thread::id" }
%"class.std::thread::id" = type { i64 }

@_ZN7Network6syncedE = external dso_local global i8, align 1
@_ZN7Network9isSyncingE = external dso_local local_unnamed_addr global i8, align 1
@_ZN7Network14lastPeerLookupE = external dso_local local_unnamed_addr global i64, align 8
@.str.39 = external hidden unnamed_addr constant [26 x i8], align 1
@.str.40 = external hidden unnamed_addr constant [43 x i8], align 1
@.str.41 = external hidden unnamed_addr constant [24 x i8], align 1
@.str.42 = external hidden unnamed_addr constant [22 x i8], align 1
@.str.43 = external hidden unnamed_addr constant [15 x i8], align 1

; 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

declare i32 @__gxx_personality_v0(...)

declare void @_ZN3LogC1Eh(ptr noundef nonnull align 8 dereferenceable(256), i8 noundef zeroext) unnamed_addr #1

declare noundef nonnull align 8 dereferenceable(256) ptr @_ZN3LoglsEPKc(ptr noundef nonnull align 8 dereferenceable(256), ptr noundef) local_unnamed_addr #1

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN7Network12lookForPeersEv() #3 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(48) ptr @_ZN5Peers8InstanceEv() local_unnamed_addr #4 align 2

declare void @_ZNSt6thread6detachEv(ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(32) ptr @_ZN5Chain8InstanceEv() local_unnamed_addr #4 align 2

declare noundef i32 @_ZN5Chain26getCurrentBlockchainHeightEv(ptr noundef nonnull align 8 dereferenceable(32)) local_unnamed_addr #1

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

declare void @_ZN5Peers8getPeersB5cxx11Ev(ptr dead_on_unwind writable sret(%"class.std::map") align 8, ptr noundef nonnull align 8 dereferenceable(48)) local_unnamed_addr #1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt3mapINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt10shared_ptrI13PeerInterfaceESt4lessIS5_ESaISt4pairIKS5_S8_EEED2Ev(ptr noundef nonnull align 8 dereferenceable(48)) unnamed_addr #4 align 2

declare i32 @sleep(i32 noundef) local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN7Network14syncBlockchainEv(ptr noundef nonnull align 1 dereferenceable(1) %0) local_unnamed_addr #3 align 2 personality ptr @__gxx_personality_v0 {
  %2 = alloca %class.Log, align 8
  %3 = alloca %class.Log, align 8
  %4 = alloca %"class.std::map", align 8
  %5 = alloca %class.Log, align 8
  %6 = alloca %"class.std::thread", align 8
  %7 = alloca ptr, align 8
  %8 = alloca %class.Log, align 8
  %9 = alloca %class.Log, align 8
  br label %10

10:                                               ; preds = %55, %1
  %11 = call noundef nonnull align 8 dereferenceable(48) ptr @_ZN5Peers8InstanceEv()
  call void @llvm.lifetime.start.p0(i64 256, ptr nonnull %2) #5
  call void @_ZN3LogC1Eh(ptr noundef nonnull align 8 dereferenceable(256) %2, i8 noundef zeroext 0)
  %12 = invoke noundef nonnull align 8 dereferenceable(256) ptr @_ZN3LoglsEPKc(ptr noundef nonnull align 8 dereferenceable(256) %2, ptr noundef nonnull @.str.39)
          to label %13 unwind label %18

13:                                               ; preds = %10
  call void @_ZN3LogD1Ev(ptr noundef nonnull align 8 dereferenceable(256) %2) #5
  call void @llvm.lifetime.end.p0(i64 256, ptr nonnull %2) #5
  %14 = load i8, ptr @_ZN7Network9isSyncingE, align 1, !tbaa !5, !range !9, !noundef !10
  %15 = trunc nuw i8 %14 to i1
  br i1 %15, label %16, label %22

16:                                               ; preds = %13
  call void @llvm.lifetime.start.p0(i64 256, ptr nonnull %3) #5
  call void @_ZN3LogC1Eh(ptr noundef nonnull align 8 dereferenceable(256) %3, i8 noundef zeroext 0)
  %17 = invoke noundef nonnull align 8 dereferenceable(256) ptr @_ZN3LoglsEPKc(ptr noundef nonnull align 8 dereferenceable(256) %3, ptr noundef nonnull @.str.40)
          to label %.loopexit unwind label %20

18:                                               ; preds = %10
  %19 = landingpad { ptr, i32 }
          cleanup
  call void @_ZN3LogD1Ev(ptr noundef nonnull align 8 dereferenceable(256) %2) #5
  call void @llvm.lifetime.end.p0(i64 256, ptr nonnull %2) #5
  br label %59

20:                                               ; preds = %16
  %21 = landingpad { ptr, i32 }
          cleanup
  call void @_ZN3LogD1Ev(ptr noundef nonnull align 8 dereferenceable(256) %3) #5
  call void @llvm.lifetime.end.p0(i64 256, ptr nonnull %3) #5
  br label %59

22:                                               ; preds = %13
  store i8 1, ptr @_ZN7Network9isSyncingE, align 1, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 48, ptr nonnull %4) #5
  call void @_ZN5Peers8getPeersB5cxx11Ev(ptr dead_on_unwind nonnull writable sret(%"class.std::map") align 8 %4, ptr noundef nonnull align 8 dereferenceable(48) %11)
  %23 = call noundef i64 @_ZNKSt3mapINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt10shared_ptrI13PeerInterfaceESt4lessIS5_ESaISt4pairIKS5_S8_EEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(48) %4) #5
  %24 = icmp ult i64 %23, 10
  br i1 %24, label %25, label %.critedge

25:                                               ; preds = %22
  %26 = invoke noundef i64 @_ZN4Time19getCurrentTimestampEv()
          to label %27 unwind label %36

27:                                               ; preds = %25
  %28 = load i64, ptr @_ZN7Network14lastPeerLookupE, align 8, !tbaa !11
  %29 = sub i64 %26, %28
  %30 = icmp ugt i64 %29, 86400
  call void @_ZNSt3mapINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt10shared_ptrI13PeerInterfaceESt4lessIS5_ESaISt4pairIKS5_S8_EEED2Ev(ptr noundef nonnull align 8 dereferenceable(48) %4) #5
  call void @llvm.lifetime.end.p0(i64 48, ptr nonnull %4) #5
  br i1 %30, label %31, label %42

31:                                               ; preds = %27
  call void @llvm.lifetime.start.p0(i64 256, ptr nonnull %5) #5
  call void @_ZN3LogC1Eh(ptr noundef nonnull align 8 dereferenceable(256) %5, i8 noundef zeroext 0)
  %32 = invoke noundef nonnull align 8 dereferenceable(256) ptr @_ZN3LoglsEPKc(ptr noundef nonnull align 8 dereferenceable(256) %5, ptr noundef nonnull @.str.41)
          to label %33 unwind label %38

33:                                               ; preds = %31
  call void @_ZN3LogD1Ev(ptr noundef nonnull align 8 dereferenceable(256) %5) #5
  call void @llvm.lifetime.end.p0(i64 256, ptr nonnull %5) #5
  %34 = call noundef i64 @_ZN4Time19getCurrentTimestampEv()
  store i64 %34, ptr @_ZN7Network14lastPeerLookupE, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %6) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %7) #5
  store ptr @_ZN7Network12lookForPeersEv, ptr %7, align 8, !tbaa !13
  call void @_ZNSt6threadC2IPFvvEJEvEEOT_DpOT0_(ptr noundef nonnull align 8 dereferenceable(8) %6, ptr noundef nonnull align 8 dereferenceable(8) %7)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %7) #5
  invoke void @_ZNSt6thread6detachEv(ptr noundef nonnull align 8 dereferenceable(8) %6)
          to label %35 unwind label %40

35:                                               ; preds = %33
  call void @_ZNSt6threadD2Ev(ptr noundef nonnull align 8 dereferenceable(8) %6) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %6) #5
  br label %42

36:                                               ; preds = %25
  %37 = landingpad { ptr, i32 }
          cleanup
  call void @_ZNSt3mapINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt10shared_ptrI13PeerInterfaceESt4lessIS5_ESaISt4pairIKS5_S8_EEED2Ev(ptr noundef nonnull align 8 dereferenceable(48) %4) #5
  call void @llvm.lifetime.end.p0(i64 48, ptr nonnull %4) #5
  br label %59

38:                                               ; preds = %31
  %39 = landingpad { ptr, i32 }
          cleanup
  call void @_ZN3LogD1Ev(ptr noundef nonnull align 8 dereferenceable(256) %5) #5
  call void @llvm.lifetime.end.p0(i64 256, ptr nonnull %5) #5
  br label %59

40:                                               ; preds = %33
  %41 = landingpad { ptr, i32 }
          cleanup
  call void @_ZNSt6threadD2Ev(ptr noundef nonnull align 8 dereferenceable(8) %6) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %6) #5
  br label %59

.critedge:                                        ; preds = %22
  call void @_ZNSt3mapINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt10shared_ptrI13PeerInterfaceESt4lessIS5_ESaISt4pairIKS5_S8_EEED2Ev(ptr noundef nonnull align 8 dereferenceable(48) %4) #5
  call void @llvm.lifetime.end.p0(i64 48, ptr nonnull %4) #5
  br label %42

42:                                               ; preds = %.critedge, %35, %27
  call void @llvm.lifetime.start.p0(i64 256, ptr nonnull %8) #5
  call void @_ZN3LogC1Eh(ptr noundef nonnull align 8 dereferenceable(256) %8, i8 noundef zeroext 0)
  %43 = invoke noundef nonnull align 8 dereferenceable(256) ptr @_ZN3LoglsEPKc(ptr noundef nonnull align 8 dereferenceable(256) %8, ptr noundef nonnull @.str.42)
          to label %44 unwind label %52

44:                                               ; preds = %42
  call void @_ZN3LogD1Ev(ptr noundef nonnull align 8 dereferenceable(256) %8) #5
  call void @llvm.lifetime.end.p0(i64 256, ptr nonnull %8) #5
  %45 = call noundef nonnull align 8 dereferenceable(32) ptr @_ZN5Chain8InstanceEv()
  %46 = load i8, ptr @_ZN7Network6syncedE, align 1, !tbaa !5, !range !9, !noundef !10
  %47 = trunc nuw i8 %46 to i1
  br i1 %47, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %44, %.lr.ph
  %48 = call noundef i32 @_ZN5Chain26getCurrentBlockchainHeightEv(ptr noundef nonnull align 8 dereferenceable(32) %45)
  %49 = add i32 %48, 1
  call void @_ZN7Network9getBlocksEjtRb(ptr noundef nonnull align 1 dereferenceable(1) %0, i32 noundef %49, i16 noundef zeroext 1000, ptr noundef nonnull align 1 dereferenceable(1) @_ZN7Network6syncedE)
  %50 = load i8, ptr @_ZN7Network6syncedE, align 1, !tbaa !5, !range !9, !noundef !10
  %51 = trunc nuw i8 %50 to i1
  br i1 %51, label %._crit_edge, label %.lr.ph, !llvm.loop !15

52:                                               ; preds = %42
  %53 = landingpad { ptr, i32 }
          cleanup
  call void @_ZN3LogD1Ev(ptr noundef nonnull align 8 dereferenceable(256) %8) #5
  call void @llvm.lifetime.end.p0(i64 256, ptr nonnull %8) #5
  br label %59

._crit_edge:                                      ; preds = %.lr.ph, %44
  call void @llvm.lifetime.start.p0(i64 256, ptr nonnull %9) #5
  call void @_ZN3LogC1Eh(ptr noundef nonnull align 8 dereferenceable(256) %9, i8 noundef zeroext 0)
  %54 = invoke noundef nonnull align 8 dereferenceable(256) ptr @_ZN3LoglsEPKc(ptr noundef nonnull align 8 dereferenceable(256) %9, ptr noundef nonnull @.str.43)
          to label %55 unwind label %57

55:                                               ; preds = %._crit_edge
  call void @_ZN3LogD1Ev(ptr noundef nonnull align 8 dereferenceable(256) %9) #5
  call void @llvm.lifetime.end.p0(i64 256, ptr nonnull %9) #5
  store i8 0, ptr @_ZN7Network9isSyncingE, align 1, !tbaa !5
  %56 = call i32 @sleep(i32 noundef 20)
  br label %10

57:                                               ; preds = %._crit_edge
  %58 = landingpad { ptr, i32 }
          cleanup
  call void @_ZN3LogD1Ev(ptr noundef nonnull align 8 dereferenceable(256) %9) #5
  call void @llvm.lifetime.end.p0(i64 256, ptr nonnull %9) #5
  br label %59

59:                                               ; preds = %57, %52, %40, %38, %36, %20, %18
  %.pn = phi { ptr, i32 } [ %21, %20 ], [ %58, %57 ], [ %53, %52 ], [ %41, %40 ], [ %39, %38 ], [ %37, %36 ], [ %19, %18 ]
  resume { ptr, i32 } %.pn

.loopexit:                                        ; preds = %16
  call void @_ZN3LogD1Ev(ptr noundef nonnull align 8 dereferenceable(256) %3) #5
  call void @llvm.lifetime.end.p0(i64 256, ptr nonnull %3) #5
  ret void
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZNKSt3mapINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt10shared_ptrI13PeerInterfaceESt4lessIS5_ESaISt4pairIKS5_S8_EEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(48)) local_unnamed_addr #4 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef i64 @_ZN4Time19getCurrentTimestampEv() local_unnamed_addr #3 align 2

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN7Network9getBlocksEjtRb(ptr noundef nonnull align 1 dereferenceable(1), i32 noundef, i16 noundef zeroext, ptr noundef nonnull align 1 dereferenceable(1)) local_unnamed_addr #3 align 2

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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" }
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 = { 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 #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 = !{!"bool", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{i8 0, i8 2}
!10 = !{}
!11 = !{!12, !12, i64 0}
!12 = !{!"long", !7, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"any pointer", !7, i64 0}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SCCPPass,SROAPass,SimplifyCFGPass