; LLVM IR from turi-code/SFrame :: oss_src/fileio/oss_webstor (sysutils)

; 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.webstor::internal::Timeout" = type { i32, i64 }
%"struct.std::pair.17" = type { i32, i32 }
%"class.webstor::internal::SocketPool" = type { ptr, %"class.webstor::internal::EventSync" }
%"class.webstor::internal::EventSync" = type <{ %union.pthread_mutex_t, %"class.std::set", i32, [4 x i8] }>
%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::set" = type { %"class.std::_Rb_tree" }
%"class.std::_Rb_tree" = type { %"struct.std::_Rb_tree<webstor::internal::EventWaiter *, webstor::internal::EventWaiter *, std::_Identity<webstor::internal::EventWaiter *>, std::less<webstor::internal::EventWaiter *>>::_Rb_tree_impl" }
%"struct.std::_Rb_tree<webstor::internal::EventWaiter *, webstor::internal::EventWaiter *, std::_Identity<webstor::internal::EventWaiter *>, std::less<webstor::internal::EventWaiter *>>::_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 }
%"struct.webstor::internal::SocketPoolState" = type { %"class.std::vector", %"class.std::vector.4" }
%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl" }
%"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl" = type { %"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl_data" }
%"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"class.std::vector.4" = type { %"struct.std::_Vector_base.5" }
%"struct.std::_Vector_base.5" = type { %"struct.std::_Vector_base<pollfd, std::allocator<pollfd>>::_Vector_impl" }
%"struct.std::_Vector_base<pollfd, std::allocator<pollfd>>::_Vector_impl" = type { %"struct.std::_Vector_base<pollfd, std::allocator<pollfd>>::_Vector_impl_data" }
%"struct.std::_Vector_base<pollfd, std::allocator<pollfd>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%struct.pollfd = type { i32, i16, i16 }

; 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: mustprogress uwtable
declare dso_local noundef i32 @_ZN7webstor8internal7Timeout4leftEv(ptr noundef nonnull align 8 dereferenceable(16)) #1 align 2

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK7webstor8internal9EventSync9get_stateEv(ptr noundef nonnull align 8 dereferenceable(92)) #2 align 2

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

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

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

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZN7webstor8internal10SocketPool4waitEjjPSt6vectorISt4pairIijESaIS4_EE(ptr noundef nonnull align 8 dereferenceable(104) %0, i32 noundef %1, i32 noundef %2, ptr noundef %3) #1 align 2 {
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca %"class.webstor::internal::Timeout", align 8
  %12 = alloca i8, align 1
  %13 = alloca i64, align 8
  %14 = alloca i32, align 4
  %15 = alloca i32, align 4
  %16 = alloca i64, align 8
  %17 = alloca i64, align 8
  %18 = alloca %"struct.std::pair.17", align 4
  %19 = alloca i32, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store i32 %1, ptr %6, align 4, !tbaa !9
  store i32 %2, ptr %7, align 4, !tbaa !9
  store ptr %3, ptr %8, align 8, !tbaa !5
  %20 = load ptr, ptr %5, align 8
  br label %21

21:                                               ; preds = %4
  br label %22

22:                                               ; preds = %21
  %23 = load ptr, ptr %8, align 8, !tbaa !5
  call void @_ZNSt6vectorISt4pairIijESaIS1_EE5clearEv(ptr noundef nonnull align 8 dereferenceable(24) %23) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #6
  store i32 0, ptr %9, align 4, !tbaa !9
  br label %24

24:                                               ; preds = %22
  br label %25

25:                                               ; preds = %24
  br label %26

26:                                               ; preds = %25
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #6
  %27 = getelementptr inbounds %"class.webstor::internal::SocketPool", ptr %20, i32 0, i32 0
  %28 = load ptr, ptr %27, align 8, !tbaa !11
  %29 = getelementptr inbounds %"struct.webstor::internal::SocketPoolState", ptr %28, i32 0, i32 0
  %30 = call noundef i64 @_ZNKSt6vectorIiSaIiEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %29) #6
  %31 = icmp ugt i64 %30, 0
  br i1 %31, label %32, label %34

32:                                               ; preds = %26
  %33 = load i32, ptr %6, align 4, !tbaa !9
  br label %36

34:                                               ; preds = %26
  %35 = load i32, ptr %7, align 4, !tbaa !9
  br label %36

36:                                               ; preds = %34, %32
  %37 = phi i32 [ %33, %32 ], [ %35, %34 ]
  store i32 %37, ptr %10, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 16, ptr %11) #6
  %38 = load i32, ptr %10, align 4, !tbaa !9
  call void @_ZN7webstor8internal7TimeoutC1Ej(ptr noundef nonnull align 8 dereferenceable(16) %11, i32 noundef %38)
  call void @llvm.lifetime.start.p0(i64 1, ptr %12) #6
  store i8 0, ptr %12, align 1, !tbaa !23
  br label %39

39:                                               ; preds = %94, %36
  br label %40

40:                                               ; preds = %39
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #6
  store i64 0, ptr %13, align 8, !tbaa !25
  br label %41

41:                                               ; preds = %56, %40
  %42 = load i64, ptr %13, align 8, !tbaa !25
  %43 = getelementptr inbounds %"class.webstor::internal::SocketPool", ptr %20, i32 0, i32 0
  %44 = load ptr, ptr %43, align 8, !tbaa !11
  %45 = getelementptr inbounds %"struct.webstor::internal::SocketPoolState", ptr %44, i32 0, i32 1
  %46 = call noundef i64 @_ZNKSt6vectorI6pollfdSaIS0_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %45) #6
  %47 = icmp ult i64 %42, %46
  br i1 %47, label %49, label %48

48:                                               ; preds = %41
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #6
  br label %59

49:                                               ; preds = %41
  %50 = getelementptr inbounds %"class.webstor::internal::SocketPool", ptr %20, i32 0, i32 0
  %51 = load ptr, ptr %50, align 8, !tbaa !11
  %52 = getelementptr inbounds %"struct.webstor::internal::SocketPoolState", ptr %51, i32 0, i32 1
  %53 = load i64, ptr %13, align 8, !tbaa !25
  %54 = call noundef nonnull align 4 dereferenceable(8) ptr @_ZNSt6vectorI6pollfdSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %52, i64 noundef %53) #6
  %55 = getelementptr inbounds %struct.pollfd, ptr %54, i32 0, i32 2
  store i16 0, ptr %55, align 2, !tbaa !26
  br label %56

56:                                               ; preds = %49
  %57 = load i64, ptr %13, align 8, !tbaa !25
  %58 = add i64 %57, 1
  store i64 %58, ptr %13, align 8, !tbaa !25
  br label %41, !llvm.loop !29

59:                                               ; preds = %48
  %60 = getelementptr inbounds %"class.webstor::internal::SocketPool", ptr %20, i32 0, i32 0
  %61 = load ptr, ptr %60, align 8, !tbaa !11
  %62 = getelementptr inbounds %"struct.webstor::internal::SocketPoolState", ptr %61, i32 0, i32 1
  %63 = call noundef ptr @_ZNSt6vectorI6pollfdSaIS0_EE4dataEv(ptr noundef nonnull align 8 dereferenceable(24) %62) #6
  %64 = getelementptr inbounds %"class.webstor::internal::SocketPool", ptr %20, i32 0, i32 0
  %65 = load ptr, ptr %64, align 8, !tbaa !11
  %66 = getelementptr inbounds %"struct.webstor::internal::SocketPoolState", ptr %65, i32 0, i32 1
  %67 = call noundef i64 @_ZNKSt6vectorI6pollfdSaIS0_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %66) #6
  %68 = call i32 @poll(ptr noundef %63, i64 noundef %67, i32 noundef 15)
  store i32 %68, ptr %9, align 4, !tbaa !9
  %69 = getelementptr inbounds %"class.webstor::internal::SocketPool", ptr %20, i32 0, i32 1
  %70 = call noundef i32 @_ZNK7webstor8internal9EventSync9get_stateEv(ptr noundef nonnull align 8 dereferenceable(92) %69)
  %71 = icmp ne i32 %70, 0
  br i1 %71, label %72, label %73

72:                                               ; preds = %59
  store i8 1, ptr %12, align 1, !tbaa !23
  br label %73

73:                                               ; preds = %72, %59
  %74 = load i32, ptr %9, align 4, !tbaa !9
  %75 = icmp eq i32 %74, -1
  br i1 %75, label %76, label %97

76:                                               ; preds = %73
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #6
  %77 = call ptr @__errno_location() #7
  %78 = load i32, ptr %77, align 4, !tbaa !9
  store i32 %78, ptr %14, align 4, !tbaa !9
  %79 = load i32, ptr %14, align 4, !tbaa !9
  %80 = icmp eq i32 %79, 4
  br i1 %80, label %81, label %86

81:                                               ; preds = %76
  %82 = call noundef i32 @_ZN7webstor8internal7Timeout4leftEv(ptr noundef nonnull align 8 dereferenceable(16) %11)
  %83 = icmp ne i32 %82, 0
  br i1 %83, label %84, label %85

84:                                               ; preds = %81
  store i32 6, ptr %15, align 4
  br label %94, !llvm.loop !31

85:                                               ; preds = %81
  store i32 7, ptr %15, align 4
  br label %94

86:                                               ; preds = %76
  %87 = load i32, ptr %14, align 4, !tbaa !9
  %88 = icmp eq i32 %87, 12
  br i1 %88, label %89, label %90

89:                                               ; preds = %86
  call void @_ZN7webstor8internal9taskSleepEj(i32 noundef 3000)
  store i32 7, ptr %15, align 4
  br label %94

90:                                               ; preds = %86
  br label %91

91:                                               ; preds = %90
  br label %92

92:                                               ; preds = %91
  br label %93

93:                                               ; preds = %92
  store i32 0, ptr %15, align 4
  br label %94

94:                                               ; preds = %93, %89, %85, %84
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #6
  %95 = load i32, ptr %15, align 4
  switch i32 %95, label %148 [
    i32 0, label %96
    i32 6, label %39
    i32 7, label %98
  ]

96:                                               ; preds = %94
  br label %97

97:                                               ; preds = %96, %73
  br label %98

98:                                               ; preds = %97, %94
  %99 = load i8, ptr %12, align 1, !tbaa !23, !range !32, !noundef !33
  %100 = trunc i8 %99 to i1
  br i1 %100, label %101, label %103

101:                                              ; preds = %98
  %102 = getelementptr inbounds %"class.webstor::internal::SocketPool", ptr %20, i32 0, i32 1
  call void @_ZN7webstor8internal9EventSync5resetEv(ptr noundef nonnull align 8 dereferenceable(92) %102)
  br label %103

103:                                              ; preds = %101, %98
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #6
  store i64 0, ptr %16, align 8, !tbaa !25
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #6
  store i64 0, ptr %17, align 8, !tbaa !25
  br label %104

104:                                              ; preds = %142, %103
  %105 = load i64, ptr %17, align 8, !tbaa !25
  %106 = getelementptr inbounds %"class.webstor::internal::SocketPool", ptr %20, i32 0, i32 0
  %107 = load ptr, ptr %106, align 8, !tbaa !11
  %108 = getelementptr inbounds %"struct.webstor::internal::SocketPoolState", ptr %107, i32 0, i32 1
  %109 = call noundef i64 @_ZNKSt6vectorI6pollfdSaIS0_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %108) #6
  %110 = icmp ult i64 %105, %109
  br i1 %110, label %112, label %111

111:                                              ; preds = %104
  store i32 13, ptr %15, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #6
  br label %145

112:                                              ; preds = %104
  %113 = getelementptr inbounds %"class.webstor::internal::SocketPool", ptr %20, i32 0, i32 0
  %114 = load ptr, ptr %113, align 8, !tbaa !11
  %115 = getelementptr inbounds %"struct.webstor::internal::SocketPoolState", ptr %114, i32 0, i32 1
  %116 = load i64, ptr %17, align 8, !tbaa !25
  %117 = call noundef nonnull align 4 dereferenceable(8) ptr @_ZNSt6vectorI6pollfdSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %115, i64 noundef %116) #6
  %118 = getelementptr inbounds %struct.pollfd, ptr %117, i32 0, i32 2
  %119 = load i16, ptr %118, align 2, !tbaa !26
  %120 = sext i16 %119 to i32
  %121 = icmp ne i32 %120, 0
  br i1 %121, label %122, label %141

122:                                              ; preds = %112
  %123 = load ptr, ptr %8, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %18) #6
  %124 = getelementptr inbounds %"class.webstor::internal::SocketPool", ptr %20, i32 0, i32 0
  %125 = load ptr, ptr %124, align 8, !tbaa !11
  %126 = getelementptr inbounds %"struct.webstor::internal::SocketPoolState", ptr %125, i32 0, i32 1
  %127 = load i64, ptr %17, align 8, !tbaa !25
  %128 = call noundef nonnull align 4 dereferenceable(8) ptr @_ZNSt6vectorI6pollfdSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %126, i64 noundef %127) #6
  %129 = getelementptr inbounds %struct.pollfd, ptr %128, i32 0, i32 0
  call void @llvm.lifetime.start.p0(i64 4, ptr %19) #6
  %130 = getelementptr inbounds %"class.webstor::internal::SocketPool", ptr %20, i32 0, i32 0
  %131 = load ptr, ptr %130, align 8, !tbaa !11
  %132 = getelementptr inbounds %"struct.webstor::internal::SocketPoolState", ptr %131, i32 0, i32 1
  %133 = load i64, ptr %17, align 8, !tbaa !25
  %134 = call noundef nonnull align 4 dereferenceable(8) ptr @_ZNSt6vectorI6pollfdSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %132, i64 noundef %133) #6
  %135 = getelementptr inbounds %struct.pollfd, ptr %134, i32 0, i32 2
  %136 = load i16, ptr %135, align 2, !tbaa !26
  %137 = sext i16 %136 to i32
  %138 = call noundef i32 @_ZN7webstor8internalL13getActionMaskEj(i32 noundef %137)
  store i32 %138, ptr %19, align 4, !tbaa !9
  call void @_ZNSt4pairIijEC2IRijTnNSt9enable_ifIXaaclsr5_PCCPE22_MoveConstructiblePairIT_T0_EEclsr5_PCCPE30_ImplicitlyMoveConvertiblePairIS4_S5_EEEbE4typeELb1EEEOS4_OS5_(ptr noundef nonnull align 4 dereferenceable(8) %18, ptr noundef nonnull align 4 dereferenceable(4) %129, ptr noundef nonnull align 4 dereferenceable(4) %19)
  call void @_ZNSt6vectorISt4pairIijESaIS1_EE9push_backEOS1_(ptr noundef nonnull align 8 dereferenceable(24) %123, ptr noundef nonnull align 4 dereferenceable(8) %18)
  call void @llvm.lifetime.end.p0(i64 4, ptr %19) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %18) #6
  %139 = load i64, ptr %16, align 8, !tbaa !25
  %140 = add i64 %139, 1
  store i64 %140, ptr %16, align 8, !tbaa !25
  br label %141

141:                                              ; preds = %122, %112
  br label %142

142:                                              ; preds = %141
  %143 = load i64, ptr %17, align 8, !tbaa !25
  %144 = add i64 %143, 1
  store i64 %144, ptr %17, align 8, !tbaa !25
  br label %104, !llvm.loop !34

145:                                              ; preds = %111
  %146 = load i64, ptr %16, align 8, !tbaa !25
  %147 = icmp ne i64 %146, 0
  store i32 1, ptr %15, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #6
  call void @llvm.lifetime.end.p0(i64 1, ptr %12) #6
  call void @llvm.lifetime.end.p0(i64 16, ptr %11) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #6
  ret i1 %147

148:                                              ; preds = %94
  unreachable
}

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

declare i32 @poll(ptr noundef, i64 noundef, i32 noundef) #3

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

; Function Attrs: nounwind willreturn memory(none)
declare ptr @__errno_location() #4

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN7webstor8internal9taskSleepEj(i32 noundef) #1

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt6vectorISt4pairIijESaIS1_EE9push_backEOS1_(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 4 dereferenceable(8)) #1 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare hidden noundef i32 @_ZN7webstor8internalL13getActionMaskEj(i32 noundef) #5

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

declare void @_ZN7webstor8internal7TimeoutC1Ej(ptr, i32)

attributes #0 = { 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 = { 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 #3 = { "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 willreturn memory(none) "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 = { 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 = { nounwind }
attributes #7 = { nounwind willreturn memory(none) }

!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 = !{!"int", !7, i64 0}
!11 = !{!12, !6, i64 0}
!12 = !{!"_ZTSN7webstor8internal10SocketPoolE", !6, i64 0, !13, i64 8}
!13 = !{!"_ZTSN7webstor8internal9EventSyncE", !7, i64 0, !14, i64 40, !10, i64 88}
!14 = !{!"_ZTSSt3setIPN7webstor8internal11EventWaiterESt4lessIS3_ESaIS3_EE", !15, i64 0}
!15 = !{!"_ZTSSt8_Rb_treeIPN7webstor8internal11EventWaiterES3_St9_IdentityIS3_ESt4lessIS3_ESaIS3_EE", !16, i64 0}
!16 = !{!"_ZTSNSt8_Rb_treeIPN7webstor8internal11EventWaiterES3_St9_IdentityIS3_ESt4lessIS3_ESaIS3_EE13_Rb_tree_implIS7_Lb1EEE", !17, i64 0, !19, i64 8}
!17 = !{!"_ZTSSt20_Rb_tree_key_compareISt4lessIPN7webstor8internal11EventWaiterEEE", !18, i64 0}
!18 = !{!"_ZTSSt4lessIPN7webstor8internal11EventWaiterEE"}
!19 = !{!"_ZTSSt15_Rb_tree_header", !20, i64 0, !22, i64 32}
!20 = !{!"_ZTSSt18_Rb_tree_node_base", !21, i64 0, !6, i64 8, !6, i64 16, !6, i64 24}
!21 = !{!"_ZTSSt14_Rb_tree_color", !7, i64 0}
!22 = !{!"long", !7, i64 0}
!23 = !{!24, !24, i64 0}
!24 = !{!"bool", !7, i64 0}
!25 = !{!22, !22, i64 0}
!26 = !{!27, !28, i64 6}
!27 = !{!"_ZTS6pollfd", !10, i64 0, !28, i64 4, !28, i64 6}
!28 = !{!"short", !7, i64 0}
!29 = distinct !{!29, !30}
!30 = !{!"llvm.loop.mustprogress"}
!31 = distinct !{!31, !30}
!32 = !{i8 0, i8 2}
!33 = !{}
!34 = distinct !{!34, !30}


; 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.webstor::internal::Timeout" = type { i32, i64 }
%"struct.std::pair.17" = type { i32, i32 }

; 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
declare dso_local noundef i32 @_ZN7webstor8internal7Timeout4leftEv(ptr noundef nonnull align 8 dereferenceable(16)) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN7webstor8internal9EventSync5resetEv(ptr noundef nonnull align 8 dereferenceable(92)) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK7webstor8internal9EventSync9get_stateEv(ptr noundef nonnull align 8 dereferenceable(92)) local_unnamed_addr #2 align 2

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

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

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

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZN7webstor8internal10SocketPool4waitEjjPSt6vectorISt4pairIijESaIS4_EE(ptr noundef nonnull align 8 dereferenceable(104) %0, i32 noundef %1, i32 noundef %2, ptr noundef nonnull %3) local_unnamed_addr #1 align 2 {
  %5 = alloca %"class.webstor::internal::Timeout", align 8
  %6 = alloca %"struct.std::pair.17", align 4
  %7 = alloca i32, align 4
  tail call void @_ZNSt6vectorISt4pairIijESaIS1_EE5clearEv(ptr noundef nonnull align 8 dereferenceable(24) %3) #6
  %8 = load ptr, ptr %0, align 8, !tbaa !5
  %9 = tail call noundef i64 @_ZNKSt6vectorIiSaIiEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %8) #6
  %.not = icmp eq i64 %9, 0
  %10 = select i1 %.not, i32 %2, i32 %1
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %5) #6
  call void @_ZN7webstor8internal7TimeoutC1Ej(ptr noundef nonnull align 8 dereferenceable(16) %5, i32 noundef %10)
  %11 = getelementptr inbounds i8, ptr %0, i64 8
  br label %12

12:                                               ; preds = %38, %4
  %.023 = phi i1 [ false, %4 ], [ %spec.select, %38 ]
  %13 = load ptr, ptr %0, align 8, !tbaa !5
  %14 = getelementptr inbounds i8, ptr %13, i64 24
  %15 = call noundef i64 @_ZNKSt6vectorI6pollfdSaIS0_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %14) #6
  %.not41 = icmp eq i64 %15, 0
  br i1 %.not41, label %._crit_edge, label %.lr.ph

._crit_edge:                                      ; preds = %.lr.ph, %12
  %16 = load ptr, ptr %0, align 8, !tbaa !5
  %17 = getelementptr inbounds i8, ptr %16, i64 24
  %18 = call noundef ptr @_ZNSt6vectorI6pollfdSaIS0_EE4dataEv(ptr noundef nonnull align 8 dereferenceable(24) %17) #6
  %19 = load ptr, ptr %0, align 8, !tbaa !5
  %20 = getelementptr inbounds i8, ptr %19, i64 24
  %21 = call noundef i64 @_ZNKSt6vectorI6pollfdSaIS0_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %20) #6
  %22 = call i32 @poll(ptr noundef %18, i64 noundef %21, i32 noundef 15)
  %23 = call noundef i32 @_ZNK7webstor8internal9EventSync9get_stateEv(ptr noundef nonnull align 8 dereferenceable(92) %11)
  %.not26 = icmp ne i32 %23, 0
  %spec.select = select i1 %.not26, i1 true, i1 %.023
  %24 = icmp eq i32 %22, -1
  br i1 %24, label %34, label %.thread

.lr.ph:                                           ; preds = %12, %.lr.ph
  %.02235 = phi i64 [ %29, %.lr.ph ], [ 0, %12 ]
  %25 = load ptr, ptr %0, align 8, !tbaa !5
  %26 = getelementptr inbounds i8, ptr %25, i64 24
  %27 = call noundef nonnull align 4 dereferenceable(8) ptr @_ZNSt6vectorI6pollfdSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %26, i64 noundef %.02235) #6
  %28 = getelementptr inbounds i8, ptr %27, i64 6
  store i16 0, ptr %28, align 2, !tbaa !21
  %29 = add nuw i64 %.02235, 1
  %30 = load ptr, ptr %0, align 8, !tbaa !5
  %31 = getelementptr inbounds i8, ptr %30, i64 24
  %32 = call noundef i64 @_ZNKSt6vectorI6pollfdSaIS0_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %31) #6
  %33 = icmp ult i64 %29, %32
  br i1 %33, label %.lr.ph, label %._crit_edge, !llvm.loop !24

34:                                               ; preds = %._crit_edge
  %35 = tail call ptr @__errno_location() #7
  %36 = load i32, ptr %35, align 4, !tbaa !26
  switch i32 %36, label %.thread [
    i32 4, label %38
    i32 12, label %37
  ]

37:                                               ; preds = %34
  call void @_ZN7webstor8internal9taskSleepEj(i32 noundef 3000)
  br label %.thread

38:                                               ; preds = %34
  %39 = call noundef i32 @_ZN7webstor8internal7Timeout4leftEv(ptr noundef nonnull align 8 dereferenceable(16) %5)
  %.not27 = icmp eq i32 %39, 0
  br i1 %.not27, label %.thread, label %12

.thread:                                          ; preds = %34, %38, %._crit_edge, %37
  br i1 %spec.select, label %40, label %41

40:                                               ; preds = %.thread
  call void @_ZN7webstor8internal9EventSync5resetEv(ptr noundef nonnull align 8 dereferenceable(92) %11)
  br label %41

41:                                               ; preds = %40, %.thread
  %42 = load ptr, ptr %0, align 8, !tbaa !5
  %43 = getelementptr inbounds i8, ptr %42, i64 24
  %44 = call noundef i64 @_ZNKSt6vectorI6pollfdSaIS0_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %43) #6
  %.not42 = icmp eq i64 %44, 0
  br i1 %.not42, label %._crit_edge40, label %.lr.ph39

._crit_edge40.loopexit:                           ; preds = %63
  %45 = icmp ne i64 %.1, 0
  br label %._crit_edge40

._crit_edge40:                                    ; preds = %._crit_edge40.loopexit, %41
  %.020.lcssa = phi i1 [ false, %41 ], [ %45, %._crit_edge40.loopexit ]
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %5) #6
  ret i1 %.020.lcssa

.lr.ph39:                                         ; preds = %41, %63
  %.037 = phi i64 [ %64, %63 ], [ 0, %41 ]
  %.02036 = phi i64 [ %.1, %63 ], [ 0, %41 ]
  %46 = load ptr, ptr %0, align 8, !tbaa !5
  %47 = getelementptr inbounds i8, ptr %46, i64 24
  %48 = call noundef nonnull align 4 dereferenceable(8) ptr @_ZNSt6vectorI6pollfdSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %47, i64 noundef %.037) #6
  %49 = getelementptr inbounds i8, ptr %48, i64 6
  %50 = load i16, ptr %49, align 2, !tbaa !21
  %.not28 = icmp eq i16 %50, 0
  br i1 %.not28, label %63, label %51

51:                                               ; preds = %.lr.ph39
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %6) #6
  %52 = load ptr, ptr %0, align 8, !tbaa !5
  %53 = getelementptr inbounds i8, ptr %52, i64 24
  %54 = call noundef nonnull align 4 dereferenceable(8) ptr @_ZNSt6vectorI6pollfdSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %53, i64 noundef %.037) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %7) #6
  %55 = load ptr, ptr %0, align 8, !tbaa !5
  %56 = getelementptr inbounds i8, ptr %55, i64 24
  %57 = call noundef nonnull align 4 dereferenceable(8) ptr @_ZNSt6vectorI6pollfdSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %56, i64 noundef %.037) #6
  %58 = getelementptr inbounds i8, ptr %57, i64 6
  %59 = load i16, ptr %58, align 2, !tbaa !21
  %60 = sext i16 %59 to i32
  %61 = call noundef i32 @_ZN7webstor8internalL13getActionMaskEj(i32 noundef %60)
  store i32 %61, ptr %7, align 4, !tbaa !26
  call void @_ZNSt4pairIijEC2IRijTnNSt9enable_ifIXaaclsr5_PCCPE22_MoveConstructiblePairIT_T0_EEclsr5_PCCPE30_ImplicitlyMoveConvertiblePairIS4_S5_EEEbE4typeELb1EEEOS4_OS5_(ptr noundef nonnull align 4 dereferenceable(8) %6, ptr noundef nonnull align 4 dereferenceable(4) %54, ptr noundef nonnull align 4 dereferenceable(4) %7)
  call void @_ZNSt6vectorISt4pairIijESaIS1_EE9push_backEOS1_(ptr noundef nonnull align 8 dereferenceable(24) %3, ptr noundef nonnull align 4 dereferenceable(8) %6)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %7) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %6) #6
  %62 = add i64 %.02036, 1
  br label %63

63:                                               ; preds = %.lr.ph39, %51
  %.1 = phi i64 [ %62, %51 ], [ %.02036, %.lr.ph39 ]
  %64 = add nuw i64 %.037, 1
  %65 = load ptr, ptr %0, align 8, !tbaa !5
  %66 = getelementptr inbounds i8, ptr %65, i64 24
  %67 = call noundef i64 @_ZNKSt6vectorI6pollfdSaIS0_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %66) #6
  %68 = icmp ult i64 %64, %67
  br i1 %68, label %.lr.ph39, label %._crit_edge40.loopexit, !llvm.loop !27
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt6vectorISt4pairIijESaIS1_EE5clearEv(ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #2 align 2

declare i32 @poll(ptr noundef, i64 noundef, i32 noundef) local_unnamed_addr #3

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

; Function Attrs: mustprogress nofree nosync nounwind willreturn memory(none)
declare ptr @__errno_location() local_unnamed_addr #4

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN7webstor8internal9taskSleepEj(i32 noundef) local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt6vectorISt4pairIijESaIS1_EE9push_backEOS1_(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 4 dereferenceable(8)) local_unnamed_addr #1 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare hidden noundef i32 @_ZN7webstor8internalL13getActionMaskEj(i32 noundef) local_unnamed_addr #5

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

declare void @_ZN7webstor8internal7TimeoutC1Ej(ptr, i32) 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 = { 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 #3 = { "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 nofree nosync nounwind willreturn memory(none) "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 = { 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 = { nounwind }
attributes #7 = { nounwind willreturn memory(none) }

!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, !7, i64 0}
!6 = !{!"_ZTSN7webstor8internal10SocketPoolE", !7, i64 0, !10, i64 8}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"_ZTSN7webstor8internal9EventSyncE", !8, i64 0, !11, i64 40, !20, i64 88}
!11 = !{!"_ZTSSt3setIPN7webstor8internal11EventWaiterESt4lessIS3_ESaIS3_EE", !12, i64 0}
!12 = !{!"_ZTSSt8_Rb_treeIPN7webstor8internal11EventWaiterES3_St9_IdentityIS3_ESt4lessIS3_ESaIS3_EE", !13, i64 0}
!13 = !{!"_ZTSNSt8_Rb_treeIPN7webstor8internal11EventWaiterES3_St9_IdentityIS3_ESt4lessIS3_ESaIS3_EE13_Rb_tree_implIS7_Lb1EEE", !14, i64 0, !16, i64 8}
!14 = !{!"_ZTSSt20_Rb_tree_key_compareISt4lessIPN7webstor8internal11EventWaiterEEE", !15, i64 0}
!15 = !{!"_ZTSSt4lessIPN7webstor8internal11EventWaiterEE"}
!16 = !{!"_ZTSSt15_Rb_tree_header", !17, i64 0, !19, i64 32}
!17 = !{!"_ZTSSt18_Rb_tree_node_base", !18, i64 0, !7, i64 8, !7, i64 16, !7, i64 24}
!18 = !{!"_ZTSSt14_Rb_tree_color", !8, i64 0}
!19 = !{!"long", !8, i64 0}
!20 = !{!"int", !8, i64 0}
!21 = !{!22, !23, i64 6}
!22 = !{!"_ZTS6pollfd", !20, i64 0, !23, i64 4, !23, i64 6}
!23 = !{!"short", !8, i64 0}
!24 = distinct !{!24, !25}
!25 = !{!"llvm.loop.mustprogress"}
!26 = !{!20, !20, i64 0}
!27 = distinct !{!27, !25}


; Effective O3 passes: AggressiveInstCombinePass,CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass