; LLVM IR from tezc/sc :: socket (sock_test)

; 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.sc_sock = type { %struct.sc_sock_fd, i8, i32, [128 x i8] }
%struct.sc_sock_fd = type { i32, i32, i32 }
%struct.sc_sock_poll = type { i32, ptr }

@.str = external hidden unnamed_addr constant [10 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [60 x i8], align 1
@.str.15 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.80 = external hidden unnamed_addr constant [27 x i8], align 1
@__PRETTY_FUNCTION__.server = external hidden unnamed_addr constant [21 x i8], align 1
@.str.81 = external hidden unnamed_addr constant [30 x i8], align 1
@.str.82 = external hidden unnamed_addr constant [27 x i8], align 1
@.str.83 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.84 = external hidden unnamed_addr constant [12 x i8], align 1
@.str.85 = external hidden unnamed_addr constant [11 x i8], align 1
@.str.86 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.87 = external hidden unnamed_addr constant [9 x i8], align 1
@.str.88 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.89 = external hidden unnamed_addr constant [24 x i8], align 1
@.str.90 = external hidden unnamed_addr constant [15 x i8], align 1
@.str.91 = external hidden unnamed_addr constant [18 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 void @sc_sock_init(ptr noundef, i32 noundef, i1 noundef zeroext, i32 noundef) #1

declare i32 @sc_sock_listen(ptr noundef, ptr noundef, ptr noundef) #1

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #2

declare i32 @sc_sock_accept(ptr noundef, ptr noundef) #1

declare i32 @sc_sock_recv(ptr noundef, ptr noundef, i32 noundef, i32 noundef) #1

declare i32 @sc_sock_term(ptr noundef) #1

declare i32 @printf(ptr noundef, ...) #1

declare i32 @sc_sock_poll_init(ptr noundef) #1

declare i32 @sc_sock_poll_add(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #1

declare i32 @sc_sock_poll_del(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #1

declare i32 @sc_sock_poll_term(ptr noundef) #1

; Function Attrs: nounwind uwtable
define dso_local ptr @server(ptr noundef %0) #3 {
  %2 = alloca ptr, align 8
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca %struct.sc_sock, align 4
  %8 = alloca %struct.sc_sock, align 4
  %9 = alloca ptr, align 8
  %10 = alloca %struct.sc_sock_poll, align 8
  %11 = alloca i8, align 1
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  %15 = alloca i8, align 1
  %16 = alloca i32, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  %17 = load ptr, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #4
  store i32 2, ptr %4, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #4
  store i32 0, ptr %6, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 148, ptr %7) #4
  call void @llvm.lifetime.start.p0(i64 148, ptr %8) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #4
  call void @llvm.lifetime.start.p0(i64 16, ptr %10) #4
  %18 = call i32 @sc_sock_poll_init(ptr noundef %10)
  %19 = icmp eq i32 %18, 0
  br i1 %19, label %20, label %21

20:                                               ; preds = %1
  br label %22

21:                                               ; preds = %1
  call void @__assert_fail(ptr noundef @.str.80, ptr noundef @.str.3, i32 noundef 1296, ptr noundef @__PRETTY_FUNCTION__.server) #5
  unreachable

22:                                               ; preds = %20
  %23 = call ptr @sc_sock_poll_err(ptr noundef %10)
  %24 = load i8, ptr %23, align 1, !tbaa !11
  %25 = sext i8 %24 to i32
  %26 = icmp eq i32 %25, 0
  br i1 %26, label %27, label %28

27:                                               ; preds = %22
  br label %29

28:                                               ; preds = %22
  call void @__assert_fail(ptr noundef @.str.81, ptr noundef @.str.3, i32 noundef 1297, ptr noundef @__PRETTY_FUNCTION__.server) #5
  unreachable

29:                                               ; preds = %27
  %30 = call i32 @sc_sock_poll_term(ptr noundef %10)
  %31 = icmp eq i32 %30, 0
  br i1 %31, label %32, label %33

32:                                               ; preds = %29
  br label %34

33:                                               ; preds = %29
  call void @__assert_fail(ptr noundef @.str.82, ptr noundef @.str.3, i32 noundef 1298, ptr noundef @__PRETTY_FUNCTION__.server) #5
  unreachable

34:                                               ; preds = %32
  %35 = call i32 @sc_sock_poll_init(ptr noundef %10)
  %36 = icmp eq i32 %35, 0
  br i1 %36, label %37, label %38

37:                                               ; preds = %34
  br label %39

38:                                               ; preds = %34
  call void @__assert_fail(ptr noundef @.str.80, ptr noundef @.str.3, i32 noundef 1299, ptr noundef @__PRETTY_FUNCTION__.server) #5
  unreachable

39:                                               ; preds = %37
  call void @sc_sock_init(ptr noundef %7, i32 noundef 0, i1 noundef zeroext true, i32 noundef 2)
  %40 = call i32 @sc_sock_listen(ptr noundef %7, ptr noundef @.str, ptr noundef @.str.83)
  store i32 %40, ptr %5, align 4, !tbaa !9
  %41 = load i32, ptr %5, align 4, !tbaa !9
  %42 = icmp eq i32 %41, 0
  br i1 %42, label %43, label %44

43:                                               ; preds = %39
  br label %45

44:                                               ; preds = %39
  call void @__assert_fail(ptr noundef @.str.15, ptr noundef @.str.3, i32 noundef 1303, ptr noundef @__PRETTY_FUNCTION__.server) #5
  unreachable

45:                                               ; preds = %43
  %46 = getelementptr inbounds %struct.sc_sock, ptr %7, i32 0, i32 0
  %47 = call i32 @sc_sock_poll_add(ptr noundef %10, ptr noundef %46, i32 noundef 1, ptr noundef %7)
  store i32 %47, ptr %5, align 4, !tbaa !9
  %48 = load i32, ptr %5, align 4, !tbaa !9
  %49 = icmp eq i32 %48, 0
  br i1 %49, label %50, label %51

50:                                               ; preds = %45
  br label %52

51:                                               ; preds = %45
  call void @__assert_fail(ptr noundef @.str.15, ptr noundef @.str.3, i32 noundef 1306, ptr noundef @__PRETTY_FUNCTION__.server) #5
  unreachable

52:                                               ; preds = %50
  call void @llvm.lifetime.start.p0(i64 1, ptr %11) #4
  store i8 0, ptr %11, align 1, !tbaa !12
  br label %53

53:                                               ; preds = %174, %52
  %54 = load i8, ptr %11, align 1, !tbaa !12, !range !14, !noundef !15
  %55 = trunc i8 %54 to i1
  %56 = xor i1 %55, true
  br i1 %56, label %57, label %175

57:                                               ; preds = %53
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #4
  %58 = call i32 @sc_sock_poll_wait(ptr noundef %10, i32 noundef -1)
  store i32 %58, ptr %12, align 4, !tbaa !9
  %59 = load i32, ptr %12, align 4, !tbaa !9
  %60 = icmp ne i32 %59, -1
  br i1 %60, label %61, label %62

61:                                               ; preds = %57
  br label %63

62:                                               ; preds = %57
  call void @__assert_fail(ptr noundef @.str.84, ptr noundef @.str.3, i32 noundef 1311, ptr noundef @__PRETTY_FUNCTION__.server) #5
  unreachable

63:                                               ; preds = %61
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #4
  store i32 0, ptr %13, align 4, !tbaa !9
  br label %64

64:                                               ; preds = %170, %63
  %65 = load i32, ptr %13, align 4, !tbaa !9
  %66 = load i32, ptr %12, align 4, !tbaa !9
  %67 = icmp slt i32 %65, %66
  br i1 %67, label %69, label %68

68:                                               ; preds = %64
  store i32 4, ptr %14, align 4
  br label %173

69:                                               ; preds = %64
  %70 = load i32, ptr %13, align 4, !tbaa !9
  %71 = call i32 @sc_sock_poll_event(ptr noundef %10, i32 noundef %70)
  store i32 %71, ptr %3, align 4, !tbaa !9
  %72 = load i32, ptr %13, align 4, !tbaa !9
  %73 = call ptr @sc_sock_poll_data(ptr noundef %10, i32 noundef %72)
  store ptr %73, ptr %9, align 8, !tbaa !5
  %74 = load i32, ptr %3, align 4, !tbaa !9
  %75 = icmp eq i32 %74, 0
  br i1 %75, label %76, label %77

76:                                               ; preds = %69
  br label %170

77:                                               ; preds = %69
  %78 = load ptr, ptr %9, align 8, !tbaa !5
  %79 = icmp eq ptr %78, %7
  br i1 %79, label %80, label %105

80:                                               ; preds = %77
  %81 = load i32, ptr %3, align 4, !tbaa !9
  %82 = and i32 %81, 1
  %83 = icmp ne i32 %82, 0
  br i1 %83, label %84, label %99

84:                                               ; preds = %80
  %85 = call i32 @sc_sock_accept(ptr noundef %7, ptr noundef %8)
  store i32 %85, ptr %5, align 4, !tbaa !9
  %86 = load i32, ptr %5, align 4, !tbaa !9
  %87 = icmp eq i32 %86, 0
  br i1 %87, label %88, label %89

88:                                               ; preds = %84
  br label %90

89:                                               ; preds = %84
  call void @__assert_fail(ptr noundef @.str.15, ptr noundef @.str.3, i32 noundef 1324, ptr noundef @__PRETTY_FUNCTION__.server) #5
  unreachable

90:                                               ; preds = %88
  %91 = call i32 (ptr, ...) @printf(ptr noundef @.str.85)
  %92 = getelementptr inbounds %struct.sc_sock, ptr %8, i32 0, i32 0
  %93 = call i32 @sc_sock_poll_add(ptr noundef %10, ptr noundef %92, i32 noundef 2, ptr noundef %8)
  store i32 %93, ptr %5, align 4, !tbaa !9
  %94 = load i32, ptr %5, align 4, !tbaa !9
  %95 = icmp eq i32 %94, 0
  br i1 %95, label %96, label %97

96:                                               ; preds = %90
  br label %98

97:                                               ; preds = %90
  call void @__assert_fail(ptr noundef @.str.15, ptr noundef @.str.3, i32 noundef 1330, ptr noundef @__PRETTY_FUNCTION__.server) #5
  unreachable

98:                                               ; preds = %96
  br label %99

99:                                               ; preds = %98, %80
  %100 = load i32, ptr %3, align 4, !tbaa !9
  %101 = and i32 %100, 2
  %102 = icmp ne i32 %101, 0
  br i1 %102, label %103, label %104

103:                                              ; preds = %99
  call void @__assert_fail(ptr noundef @.str.86, ptr noundef @.str.3, i32 noundef 1334, ptr noundef @__PRETTY_FUNCTION__.server) #5
  unreachable

104:                                              ; preds = %99
  br label %169

105:                                              ; preds = %77
  %106 = load i32, ptr %3, align 4, !tbaa !9
  %107 = and i32 %106, 1
  %108 = icmp ne i32 %107, 0
  br i1 %108, label %109, label %148

109:                                              ; preds = %105
  call void @llvm.lifetime.start.p0(i64 1, ptr %15) #4
  %110 = call i32 @sc_sock_recv(ptr noundef %8, ptr noundef %15, i32 noundef 1, i32 noundef 0)
  store i32 %110, ptr %5, align 4, !tbaa !9
  %111 = load i32, ptr %5, align 4, !tbaa !9
  %112 = icmp eq i32 %111, 1
  br i1 %112, label %113, label %122

113:                                              ; preds = %109
  %114 = load i8, ptr %15, align 1, !tbaa !11
  %115 = sext i8 %114 to i32
  %116 = icmp eq i32 %115, 100
  br i1 %116, label %117, label %118

117:                                              ; preds = %113
  br label %119

118:                                              ; preds = %113
  call void @__assert_fail(ptr noundef @.str.87, ptr noundef @.str.3, i32 noundef 1342, ptr noundef @__PRETTY_FUNCTION__.server) #5
  unreachable

119:                                              ; preds = %117
  %120 = load i32, ptr %6, align 4, !tbaa !9
  %121 = add nsw i32 %120, 1
  store i32 %121, ptr %6, align 4, !tbaa !9
  br label %144

122:                                              ; preds = %109
  %123 = load i32, ptr %5, align 4, !tbaa !9
  %124 = icmp eq i32 %123, 0
  br i1 %124, label %128, label %125

125:                                              ; preds = %122
  %126 = load i32, ptr %5, align 4, !tbaa !9
  %127 = icmp slt i32 %126, 0
  br i1 %127, label %128, label %143

128:                                              ; preds = %125, %122
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #4
  store i32 3, ptr %16, align 4, !tbaa !9
  %129 = getelementptr inbounds %struct.sc_sock, ptr %8, i32 0, i32 0
  %130 = load i32, ptr %16, align 4, !tbaa !9
  %131 = call i32 @sc_sock_poll_del(ptr noundef %10, ptr noundef %129, i32 noundef %130, ptr noundef %8)
  store i32 %131, ptr %5, align 4, !tbaa !9
  %132 = load i32, ptr %5, align 4, !tbaa !9
  %133 = icmp eq i32 %132, 0
  br i1 %133, label %134, label %135

134:                                              ; preds = %128
  br label %136

135:                                              ; preds = %128
  call void @__assert_fail(ptr noundef @.str.15, ptr noundef @.str.3, i32 noundef 1350, ptr noundef @__PRETTY_FUNCTION__.server) #5
  unreachable

136:                                              ; preds = %134
  %137 = call i32 @sc_sock_term(ptr noundef %8)
  store i32 %137, ptr %5, align 4, !tbaa !9
  %138 = load i32, ptr %5, align 4, !tbaa !9
  %139 = icmp eq i32 %138, 0
  br i1 %139, label %140, label %141

140:                                              ; preds = %136
  br label %142

141:                                              ; preds = %136
  call void @__assert_fail(ptr noundef @.str.15, ptr noundef @.str.3, i32 noundef 1353, ptr noundef @__PRETTY_FUNCTION__.server) #5
  unreachable

142:                                              ; preds = %140
  store i8 1, ptr %11, align 1, !tbaa !12
  store i32 4, ptr %14, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #4
  br label %145

143:                                              ; preds = %125
  br label %144

144:                                              ; preds = %143, %119
  store i32 0, ptr %14, align 4
  br label %145

145:                                              ; preds = %144, %142
  call void @llvm.lifetime.end.p0(i64 1, ptr %15) #4
  %146 = load i32, ptr %14, align 4
  switch i32 %146, label %173 [
    i32 0, label %147
  ]

147:                                              ; preds = %145
  br label %148

148:                                              ; preds = %147, %105
  %149 = load i32, ptr %4, align 4, !tbaa !9
  %150 = icmp sgt i32 %149, 0
  br i1 %150, label %151, label %168

151:                                              ; preds = %148
  %152 = load i32, ptr %4, align 4, !tbaa !9
  %153 = add nsw i32 %152, -1
  store i32 %153, ptr %4, align 4, !tbaa !9
  %154 = load i32, ptr %4, align 4, !tbaa !9
  %155 = icmp eq i32 %154, 0
  br i1 %155, label %156, label %164

156:                                              ; preds = %151
  %157 = getelementptr inbounds %struct.sc_sock, ptr %8, i32 0, i32 0
  %158 = call i32 @sc_sock_poll_del(ptr noundef %10, ptr noundef %157, i32 noundef 2, ptr noundef %8)
  store i32 %158, ptr %5, align 4, !tbaa !9
  %159 = load i32, ptr %5, align 4, !tbaa !9
  %160 = icmp eq i32 %159, 0
  br i1 %160, label %161, label %162

161:                                              ; preds = %156
  br label %163

162:                                              ; preds = %156
  call void @__assert_fail(ptr noundef @.str.15, ptr noundef @.str.3, i32 noundef 1366, ptr noundef @__PRETTY_FUNCTION__.server) #5
  unreachable

163:                                              ; preds = %161
  br label %167

164:                                              ; preds = %151
  %165 = getelementptr inbounds %struct.sc_sock, ptr %8, i32 0, i32 0
  %166 = call i32 @sc_sock_poll_add(ptr noundef %10, ptr noundef %165, i32 noundef 1, ptr noundef %8)
  store i32 %166, ptr %5, align 4, !tbaa !9
  br label %167

167:                                              ; preds = %164, %163
  br label %168

168:                                              ; preds = %167, %148
  br label %169

169:                                              ; preds = %168, %104
  br label %170

170:                                              ; preds = %169, %76
  %171 = load i32, ptr %13, align 4, !tbaa !9
  %172 = add nsw i32 %171, 1
  store i32 %172, ptr %13, align 4, !tbaa !9
  br label %64, !llvm.loop !16

173:                                              ; preds = %145, %68
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #4
  br label %174

174:                                              ; preds = %173
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #4
  br label %53, !llvm.loop !18

175:                                              ; preds = %53
  %176 = load i32, ptr %4, align 4, !tbaa !9
  %177 = icmp eq i32 %176, 0
  br i1 %177, label %178, label %179

178:                                              ; preds = %175
  br label %180

179:                                              ; preds = %175
  call void @__assert_fail(ptr noundef @.str.88, ptr noundef @.str.3, i32 noundef 1377, ptr noundef @__PRETTY_FUNCTION__.server) #5
  unreachable

180:                                              ; preds = %178
  %181 = call i32 @sc_sock_term(ptr noundef %7)
  %182 = icmp eq i32 %181, 0
  br i1 %182, label %183, label %184

183:                                              ; preds = %180
  br label %185

184:                                              ; preds = %180
  call void @__assert_fail(ptr noundef @.str.89, ptr noundef @.str.3, i32 noundef 1378, ptr noundef @__PRETTY_FUNCTION__.server) #5
  unreachable

185:                                              ; preds = %183
  %186 = call i32 @sc_sock_poll_term(ptr noundef %10)
  %187 = icmp eq i32 %186, 0
  br i1 %187, label %188, label %189

188:                                              ; preds = %185
  br label %190

189:                                              ; preds = %185
  call void @__assert_fail(ptr noundef @.str.82, ptr noundef @.str.3, i32 noundef 1379, ptr noundef @__PRETTY_FUNCTION__.server) #5
  unreachable

190:                                              ; preds = %188
  %191 = load i32, ptr %6, align 4, !tbaa !9
  %192 = call i32 (ptr, ...) @printf(ptr noundef @.str.90, i32 noundef %191)
  %193 = load i32, ptr %6, align 4, !tbaa !9
  %194 = icmp eq i32 %193, 10000
  br i1 %194, label %195, label %196

195:                                              ; preds = %190
  br label %197

196:                                              ; preds = %190
  call void @__assert_fail(ptr noundef @.str.91, ptr noundef @.str.3, i32 noundef 1382, ptr noundef @__PRETTY_FUNCTION__.server) #5
  unreachable

197:                                              ; preds = %195
  store i32 1, ptr %14, align 4
  call void @llvm.lifetime.end.p0(i64 1, ptr %11) #4
  call void @llvm.lifetime.end.p0(i64 16, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 148, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 148, ptr %7) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #4
  ret ptr null
}

declare ptr @sc_sock_poll_err(ptr noundef) #1

declare i32 @sc_sock_poll_wait(ptr noundef, i32 noundef) #1

declare i32 @sc_sock_poll_event(ptr noundef, i32 noundef) #1

declare ptr @sc_sock_poll_data(ptr noundef, i32 noundef) #1

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 = { noreturn 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 = { 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 #4 = { nounwind }
attributes #5 = { noreturn 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/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!7, !7, i64 0}
!12 = !{!13, !13, i64 0}
!13 = !{!"_Bool", !7, i64 0}
!14 = !{i8 0, i8 2}
!15 = !{}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}
!18 = distinct !{!18, !17}


; 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.sc_sock = type { %struct.sc_sock_fd, i8, i32, [128 x i8] }
%struct.sc_sock_fd = type { i32, i32, i32 }
%struct.sc_sock_poll = type { i32, ptr }

@.str = external hidden unnamed_addr constant [10 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [60 x i8], align 1
@.str.15 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.80 = external hidden unnamed_addr constant [27 x i8], align 1
@__PRETTY_FUNCTION__.server = external hidden unnamed_addr constant [21 x i8], align 1
@.str.81 = external hidden unnamed_addr constant [30 x i8], align 1
@.str.82 = external hidden unnamed_addr constant [27 x i8], align 1
@.str.83 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.84 = external hidden unnamed_addr constant [12 x i8], align 1
@.str.85 = external hidden unnamed_addr constant [11 x i8], align 1
@.str.86 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.87 = external hidden unnamed_addr constant [9 x i8], align 1
@.str.88 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.89 = external hidden unnamed_addr constant [24 x i8], align 1
@.str.90 = external hidden unnamed_addr constant [15 x i8], align 1
@.str.91 = external hidden unnamed_addr constant [18 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 void @sc_sock_init(ptr noundef, i32 noundef, i1 noundef zeroext, i32 noundef) local_unnamed_addr #1

declare i32 @sc_sock_listen(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #2

declare i32 @sc_sock_accept(ptr noundef, ptr noundef) local_unnamed_addr #1

declare i32 @sc_sock_recv(ptr noundef, ptr noundef, i32 noundef, i32 noundef) local_unnamed_addr #1

declare i32 @sc_sock_term(ptr noundef) local_unnamed_addr #1

; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #3

declare i32 @sc_sock_poll_init(ptr noundef) local_unnamed_addr #1

declare i32 @sc_sock_poll_add(ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #1

declare i32 @sc_sock_poll_del(ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #1

declare i32 @sc_sock_poll_term(ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local noalias noundef ptr @server(ptr nocapture noundef readnone %0) local_unnamed_addr #4 {
  %2 = alloca %struct.sc_sock, align 4
  %3 = alloca %struct.sc_sock, align 4
  %4 = alloca %struct.sc_sock_poll, align 8
  %5 = alloca i8, align 1
  call void @llvm.lifetime.start.p0(i64 148, ptr nonnull %2) #5
  call void @llvm.lifetime.start.p0(i64 148, ptr nonnull %3) #5
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %4) #5
  %6 = call i32 @sc_sock_poll_init(ptr noundef nonnull %4) #5
  %7 = icmp eq i32 %6, 0
  br i1 %7, label %9, label %8

8:                                                ; preds = %1
  call void @__assert_fail(ptr noundef nonnull @.str.80, ptr noundef nonnull @.str.3, i32 noundef 1296, ptr noundef nonnull @__PRETTY_FUNCTION__.server) #6
  unreachable

9:                                                ; preds = %1
  %10 = call ptr @sc_sock_poll_err(ptr noundef nonnull %4) #5
  %11 = load i8, ptr %10, align 1, !tbaa !5
  %12 = icmp eq i8 %11, 0
  br i1 %12, label %14, label %13

13:                                               ; preds = %9
  call void @__assert_fail(ptr noundef nonnull @.str.81, ptr noundef nonnull @.str.3, i32 noundef 1297, ptr noundef nonnull @__PRETTY_FUNCTION__.server) #6
  unreachable

14:                                               ; preds = %9
  %15 = call i32 @sc_sock_poll_term(ptr noundef nonnull %4) #5
  %16 = icmp eq i32 %15, 0
  br i1 %16, label %18, label %17

17:                                               ; preds = %14
  call void @__assert_fail(ptr noundef nonnull @.str.82, ptr noundef nonnull @.str.3, i32 noundef 1298, ptr noundef nonnull @__PRETTY_FUNCTION__.server) #6
  unreachable

18:                                               ; preds = %14
  %19 = call i32 @sc_sock_poll_init(ptr noundef nonnull %4) #5
  %20 = icmp eq i32 %19, 0
  br i1 %20, label %22, label %21

21:                                               ; preds = %18
  call void @__assert_fail(ptr noundef nonnull @.str.80, ptr noundef nonnull @.str.3, i32 noundef 1299, ptr noundef nonnull @__PRETTY_FUNCTION__.server) #6
  unreachable

22:                                               ; preds = %18
  call void @sc_sock_init(ptr noundef nonnull %2, i32 noundef 0, i1 noundef zeroext true, i32 noundef 2) #5
  %23 = call i32 @sc_sock_listen(ptr noundef nonnull %2, ptr noundef nonnull @.str, ptr noundef nonnull @.str.83) #5
  %24 = icmp eq i32 %23, 0
  br i1 %24, label %26, label %25

25:                                               ; preds = %22
  call void @__assert_fail(ptr noundef nonnull @.str.15, ptr noundef nonnull @.str.3, i32 noundef 1303, ptr noundef nonnull @__PRETTY_FUNCTION__.server) #6
  unreachable

26:                                               ; preds = %22
  %27 = call i32 @sc_sock_poll_add(ptr noundef nonnull %4, ptr noundef nonnull %2, i32 noundef 1, ptr noundef nonnull %2) #5
  %28 = icmp eq i32 %27, 0
  br i1 %28, label %.preheader55.preheader, label %30

.preheader55.preheader:                           ; preds = %26
  %29 = call i32 @sc_sock_poll_wait(ptr noundef nonnull %4, i32 noundef -1) #5
  %.not135 = icmp eq i32 %29, -1
  br i1 %.not135, label %.preheader55._crit_edge, label %.preheader

30:                                               ; preds = %26
  call void @__assert_fail(ptr noundef nonnull @.str.15, ptr noundef nonnull @.str.3, i32 noundef 1306, ptr noundef nonnull @__PRETTY_FUNCTION__.server) #6
  unreachable

.preheader:                                       ; preds = %.preheader55.preheader, %.loopexit
  %31 = phi i32 [ %84, %.loopexit ], [ %29, %.preheader55.preheader ]
  %.03791137 = phi i32 [ %.13869, %.loopexit ], [ 0, %.preheader55.preheader ]
  %.093136 = phi i32 [ %.162, %.loopexit ], [ 2, %.preheader55.preheader ]
  %32 = icmp sgt i32 %31, 0
  br i1 %32, label %.lr.ph, label %.loopexit

.preheader55._crit_edge:                          ; preds = %.loopexit, %.preheader55.preheader
  call void @__assert_fail(ptr noundef nonnull @.str.84, ptr noundef nonnull @.str.3, i32 noundef 1311, ptr noundef nonnull @__PRETTY_FUNCTION__.server) #6
  unreachable

.lr.ph:                                           ; preds = %.preheader, %82
  %.188 = phi i32 [ %.2, %82 ], [ %.093136, %.preheader ]
  %.03387 = phi i32 [ %83, %82 ], [ 0, %.preheader ]
  %.13886 = phi i32 [ %.542, %82 ], [ %.03791137, %.preheader ]
  %33 = call i32 @sc_sock_poll_event(ptr noundef nonnull %4, i32 noundef %.03387) #5
  %34 = call ptr @sc_sock_poll_data(ptr noundef nonnull %4, i32 noundef %.03387) #5
  %35 = icmp eq i32 %33, 0
  br i1 %35, label %82, label %36

36:                                               ; preds = %.lr.ph
  %37 = icmp eq ptr %34, %2
  %38 = and i32 %33, 1
  %.not50 = icmp eq i32 %38, 0
  br i1 %37, label %39, label %52

39:                                               ; preds = %36
  br i1 %.not50, label %49, label %40

40:                                               ; preds = %39
  %41 = call i32 @sc_sock_accept(ptr noundef nonnull %2, ptr noundef nonnull %3) #5
  %42 = icmp eq i32 %41, 0
  br i1 %42, label %44, label %43

43:                                               ; preds = %40
  call void @__assert_fail(ptr noundef nonnull @.str.15, ptr noundef nonnull @.str.3, i32 noundef 1324, ptr noundef nonnull @__PRETTY_FUNCTION__.server) #6
  unreachable

44:                                               ; preds = %40
  %45 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.85)
  %46 = call i32 @sc_sock_poll_add(ptr noundef nonnull %4, ptr noundef nonnull %3, i32 noundef 2, ptr noundef nonnull %3) #5
  %47 = icmp eq i32 %46, 0
  br i1 %47, label %49, label %48

48:                                               ; preds = %44
  call void @__assert_fail(ptr noundef nonnull @.str.15, ptr noundef nonnull @.str.3, i32 noundef 1330, ptr noundef nonnull @__PRETTY_FUNCTION__.server) #6
  unreachable

49:                                               ; preds = %44, %39
  %50 = and i32 %33, 2
  %.not51 = icmp eq i32 %50, 0
  br i1 %.not51, label %82, label %51

51:                                               ; preds = %49
  call void @__assert_fail(ptr noundef nonnull @.str.86, ptr noundef nonnull @.str.3, i32 noundef 1334, ptr noundef nonnull @__PRETTY_FUNCTION__.server) #6
  unreachable

52:                                               ; preds = %36
  br i1 %.not50, label %71, label %53

53:                                               ; preds = %52
  call void @llvm.lifetime.start.p0(i64 1, ptr nonnull %5) #5
  %54 = call i32 @sc_sock_recv(ptr noundef nonnull %3, ptr noundef nonnull %5, i32 noundef 1, i32 noundef 0) #5
  %55 = icmp eq i32 %54, 1
  br i1 %55, label %56, label %62

56:                                               ; preds = %53
  %57 = load i8, ptr %5, align 1, !tbaa !5
  %58 = icmp eq i8 %57, 100
  br i1 %58, label %60, label %59

59:                                               ; preds = %56
  call void @__assert_fail(ptr noundef nonnull @.str.87, ptr noundef nonnull @.str.3, i32 noundef 1342, ptr noundef nonnull @__PRETTY_FUNCTION__.server) #6
  unreachable

60:                                               ; preds = %56
  %61 = add nsw i32 %.13886, 1
  br label %.thread

62:                                               ; preds = %53
  %or.cond = icmp slt i32 %54, 1
  br i1 %or.cond, label %63, label %.thread

63:                                               ; preds = %62
  %64 = call i32 @sc_sock_poll_del(ptr noundef nonnull %4, ptr noundef nonnull %3, i32 noundef 3, ptr noundef nonnull %3) #5
  %65 = icmp eq i32 %64, 0
  br i1 %65, label %67, label %66

66:                                               ; preds = %63
  call void @__assert_fail(ptr noundef nonnull @.str.15, ptr noundef nonnull @.str.3, i32 noundef 1350, ptr noundef nonnull @__PRETTY_FUNCTION__.server) #6
  unreachable

67:                                               ; preds = %63
  %68 = call i32 @sc_sock_term(ptr noundef nonnull %3) #5
  %69 = icmp eq i32 %68, 0
  br i1 %69, label %85, label %70

70:                                               ; preds = %67
  call void @__assert_fail(ptr noundef nonnull @.str.15, ptr noundef nonnull @.str.3, i32 noundef 1353, ptr noundef nonnull @__PRETTY_FUNCTION__.server) #6
  unreachable

.thread:                                          ; preds = %62, %60
  %.340.ph = phi i32 [ %.13886, %62 ], [ %61, %60 ]
  call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %5) #5
  br label %71

71:                                               ; preds = %.thread, %52
  %.441 = phi i32 [ %.13886, %52 ], [ %.340.ph, %.thread ]
  %72 = icmp sgt i32 %.188, 0
  br i1 %72, label %73, label %82

73:                                               ; preds = %71
  %74 = add nsw i32 %.188, -1
  %75 = icmp eq i32 %74, 0
  br i1 %75, label %76, label %80

76:                                               ; preds = %73
  %77 = call i32 @sc_sock_poll_del(ptr noundef nonnull %4, ptr noundef nonnull %3, i32 noundef 2, ptr noundef nonnull %3) #5
  %78 = icmp eq i32 %77, 0
  br i1 %78, label %82, label %79

79:                                               ; preds = %76
  call void @__assert_fail(ptr noundef nonnull @.str.15, ptr noundef nonnull @.str.3, i32 noundef 1366, ptr noundef nonnull @__PRETTY_FUNCTION__.server) #6
  unreachable

80:                                               ; preds = %73
  %81 = call i32 @sc_sock_poll_add(ptr noundef nonnull %4, ptr noundef nonnull %3, i32 noundef 1, ptr noundef nonnull %3) #5
  br label %82

82:                                               ; preds = %49, %80, %76, %71, %.lr.ph
  %.542 = phi i32 [ %.13886, %.lr.ph ], [ %.13886, %49 ], [ %.441, %76 ], [ %.441, %80 ], [ %.441, %71 ]
  %.2 = phi i32 [ %.188, %.lr.ph ], [ %.188, %49 ], [ 0, %76 ], [ %74, %80 ], [ %.188, %71 ]
  %83 = add nuw nsw i32 %.03387, 1
  %exitcond.not = icmp eq i32 %83, %31
  br i1 %exitcond.not, label %.loopexit, label %.lr.ph, !llvm.loop !8

.loopexit:                                        ; preds = %82, %.preheader
  %.13869 = phi i32 [ %.03791137, %.preheader ], [ %.542, %82 ]
  %.162 = phi i32 [ %.093136, %.preheader ], [ %.2, %82 ]
  %84 = call i32 @sc_sock_poll_wait(ptr noundef nonnull %4, i32 noundef -1) #5
  %.not = icmp eq i32 %84, -1
  br i1 %.not, label %.preheader55._crit_edge, label %.preheader, !llvm.loop !10

85:                                               ; preds = %67
  call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %5) #5
  %86 = icmp eq i32 %.188, 0
  br i1 %86, label %88, label %87

87:                                               ; preds = %85
  call void @__assert_fail(ptr noundef nonnull @.str.88, ptr noundef nonnull @.str.3, i32 noundef 1377, ptr noundef nonnull @__PRETTY_FUNCTION__.server) #6
  unreachable

88:                                               ; preds = %85
  %89 = call i32 @sc_sock_term(ptr noundef nonnull %2) #5
  %90 = icmp eq i32 %89, 0
  br i1 %90, label %92, label %91

91:                                               ; preds = %88
  call void @__assert_fail(ptr noundef nonnull @.str.89, ptr noundef nonnull @.str.3, i32 noundef 1378, ptr noundef nonnull @__PRETTY_FUNCTION__.server) #6
  unreachable

92:                                               ; preds = %88
  %93 = call i32 @sc_sock_poll_term(ptr noundef nonnull %4) #5
  %94 = icmp eq i32 %93, 0
  br i1 %94, label %96, label %95

95:                                               ; preds = %92
  call void @__assert_fail(ptr noundef nonnull @.str.82, ptr noundef nonnull @.str.3, i32 noundef 1379, ptr noundef nonnull @__PRETTY_FUNCTION__.server) #6
  unreachable

96:                                               ; preds = %92
  %97 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.90, i32 noundef %.13886)
  %98 = icmp eq i32 %.13886, 10000
  br i1 %98, label %100, label %99

99:                                               ; preds = %96
  call void @__assert_fail(ptr noundef nonnull @.str.91, ptr noundef nonnull @.str.3, i32 noundef 1382, ptr noundef nonnull @__PRETTY_FUNCTION__.server) #6
  unreachable

100:                                              ; preds = %96
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %4) #5
  call void @llvm.lifetime.end.p0(i64 148, ptr nonnull %3) #5
  call void @llvm.lifetime.end.p0(i64 148, ptr nonnull %2) #5
  ret ptr null
}

declare ptr @sc_sock_poll_err(ptr noundef) local_unnamed_addr #1

declare i32 @sc_sock_poll_wait(ptr noundef, i32 noundef) local_unnamed_addr #1

declare i32 @sc_sock_poll_event(ptr noundef, i32 noundef) local_unnamed_addr #1

declare ptr @sc_sock_poll_data(ptr noundef, i32 noundef) local_unnamed_addr #1

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 = { noreturn 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 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 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 }
attributes #6 = { noreturn 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 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C/C++ TBAA"}
!8 = distinct !{!8, !9}
!9 = !{!"llvm.loop.mustprogress"}
!10 = distinct !{!10, !9}


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