; LLVM IR from openanolis/openssl :: doc/designs/ddd (ddd-04-fd-nonblocking)

; 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.addrinfo = type { i32, i32, i32, i32, i32, ptr, ptr, ptr }
%struct.pollfd = type { i32, i16, i16 }

@main.tx_msg = external hidden global [300 x i8], align 16
@stderr = external global ptr, align 8
@.str = external hidden unnamed_addr constant [21 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [29 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [27 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [16 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [22 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [16 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [32 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [29 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [10 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [12 x i8], align 1
@stdout = external global ptr, align 8
@.str.10 = external hidden unnamed_addr constant [12 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local ptr @create_ssl_ctx() #0

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: nounwind uwtable
declare dso_local ptr @new_conn(ptr noundef, i32 noundef, ptr noundef) #0

; Function Attrs: nounwind uwtable
declare dso_local i32 @tx(ptr noundef, ptr noundef, i32 noundef) #0

; Function Attrs: nounwind uwtable
declare dso_local i32 @rx(ptr noundef, ptr noundef, i32 noundef) #0

; Function Attrs: nounwind uwtable
declare dso_local i32 @get_conn_fd(ptr noundef) #0

; Function Attrs: nounwind uwtable
declare dso_local i32 @get_conn_pending_tx(ptr noundef) #0

; Function Attrs: nounwind uwtable
declare dso_local i32 @get_conn_pending_rx(ptr noundef) #0

; Function Attrs: nounwind uwtable
declare dso_local void @teardown(ptr noundef) #0

; Function Attrs: nounwind uwtable
declare dso_local void @teardown_ctx(ptr noundef) #0

; Function Attrs: nounwind uwtable
define dso_local i32 @main(i32 noundef %0, ptr noundef %1) #0 {
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca ptr, align 8
  %10 = alloca [2048 x i8], align 16
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca ptr, align 8
  %15 = alloca %struct.addrinfo, align 8
  %16 = alloca ptr, align 8
  %17 = alloca ptr, align 8
  %18 = alloca %struct.pollfd, align 4
  %19 = alloca i32, align 4
  %20 = alloca %struct.pollfd, align 4
  store i32 0, ptr %3, align 4
  store i32 %0, ptr %4, align 4, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #5
  store i32 -1, ptr %7, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #5
  store i32 1, ptr %8, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #5
  store ptr @main.tx_msg, ptr %9, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 2048, ptr %10) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #5
  store i32 299, ptr %12, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #5
  store i32 2000, ptr %13, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #5
  store ptr null, ptr %14, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 48, ptr %15) #5
  call void @llvm.memset.p0.i64(ptr align 8 %15, i8 0, i64 48, i1 false)
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #5
  store ptr null, ptr %16, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #5
  store ptr null, ptr %17, align 8, !tbaa !9
  %21 = load i32, ptr %4, align 4, !tbaa !5
  %22 = icmp slt i32 %21, 3
  br i1 %22, label %23, label %29

23:                                               ; preds = %2
  %24 = load ptr, ptr @stderr, align 8, !tbaa !9
  %25 = load ptr, ptr %5, align 8, !tbaa !9
  %26 = getelementptr inbounds ptr, ptr %25, i64 0
  %27 = load ptr, ptr %26, align 8, !tbaa !9
  %28 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %24, ptr noundef @.str, ptr noundef %27) #5
  br label %189

29:                                               ; preds = %2
  %30 = load ptr, ptr %5, align 8, !tbaa !9
  %31 = getelementptr inbounds ptr, ptr %30, i64 1
  %32 = load ptr, ptr %31, align 8, !tbaa !9
  %33 = call i32 (ptr, i64, ptr, ...) @snprintf(ptr noundef @main.tx_msg, i64 noundef 300, ptr noundef @.str.1, ptr noundef %32) #5
  %34 = call ptr @create_ssl_ctx()
  store ptr %34, ptr %17, align 8, !tbaa !9
  %35 = load ptr, ptr %17, align 8, !tbaa !9
  %36 = icmp eq ptr %35, null
  br i1 %36, label %37, label %40

37:                                               ; preds = %29
  %38 = load ptr, ptr @stderr, align 8, !tbaa !9
  %39 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %38, ptr noundef @.str.2) #5
  br label %189

40:                                               ; preds = %29
  %41 = getelementptr inbounds %struct.addrinfo, ptr %15, i32 0, i32 1
  store i32 2, ptr %41, align 4, !tbaa !11
  %42 = getelementptr inbounds %struct.addrinfo, ptr %15, i32 0, i32 2
  store i32 1, ptr %42, align 8, !tbaa !13
  %43 = getelementptr inbounds %struct.addrinfo, ptr %15, i32 0, i32 0
  store i32 1, ptr %43, align 8, !tbaa !14
  %44 = load ptr, ptr %5, align 8, !tbaa !9
  %45 = getelementptr inbounds ptr, ptr %44, i64 1
  %46 = load ptr, ptr %45, align 8, !tbaa !9
  %47 = load ptr, ptr %5, align 8, !tbaa !9
  %48 = getelementptr inbounds ptr, ptr %47, i64 2
  %49 = load ptr, ptr %48, align 8, !tbaa !9
  %50 = call i32 @getaddrinfo(ptr noundef %46, ptr noundef %49, ptr noundef %15, ptr noundef %16)
  store i32 %50, ptr %6, align 4, !tbaa !5
  %51 = load i32, ptr %6, align 4, !tbaa !5
  %52 = icmp slt i32 %51, 0
  br i1 %52, label %53, label %56

53:                                               ; preds = %40
  %54 = load ptr, ptr @stderr, align 8, !tbaa !9
  %55 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %54, ptr noundef @.str.3) #5
  br label %189

56:                                               ; preds = %40
  %57 = call ptr @signal(i32 noundef 13, ptr noundef inttoptr (i64 1 to ptr)) #5
  %58 = call i32 @socket(i32 noundef 2, i32 noundef 1, i32 noundef 6) #5
  store i32 %58, ptr %7, align 4, !tbaa !5
  %59 = load i32, ptr %7, align 4, !tbaa !5
  %60 = icmp slt i32 %59, 0
  br i1 %60, label %61, label %64

61:                                               ; preds = %56
  %62 = load ptr, ptr @stderr, align 8, !tbaa !9
  %63 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %62, ptr noundef @.str.4) #5
  br label %189

64:                                               ; preds = %56
  %65 = load i32, ptr %7, align 4, !tbaa !5
  %66 = load ptr, ptr %16, align 8, !tbaa !9
  %67 = getelementptr inbounds %struct.addrinfo, ptr %66, i32 0, i32 5
  %68 = load ptr, ptr %67, align 8, !tbaa !15
  %69 = load ptr, ptr %16, align 8, !tbaa !9
  %70 = getelementptr inbounds %struct.addrinfo, ptr %69, i32 0, i32 4
  %71 = load i32, ptr %70, align 8, !tbaa !16
  %72 = call i32 @connect(i32 noundef %65, ptr noundef %68, i32 noundef %71)
  store i32 %72, ptr %6, align 4, !tbaa !5
  %73 = load i32, ptr %6, align 4, !tbaa !5
  %74 = icmp slt i32 %73, 0
  br i1 %74, label %75, label %78

75:                                               ; preds = %64
  %76 = load ptr, ptr @stderr, align 8, !tbaa !9
  %77 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %76, ptr noundef @.str.5) #5
  br label %189

78:                                               ; preds = %64
  %79 = load i32, ptr %7, align 4, !tbaa !5
  %80 = call i32 (i32, i32, ...) @fcntl(i32 noundef %79, i32 noundef 4, i32 noundef 2048)
  store i32 %80, ptr %6, align 4, !tbaa !5
  %81 = load i32, ptr %6, align 4, !tbaa !5
  %82 = icmp slt i32 %81, 0
  br i1 %82, label %83, label %86

83:                                               ; preds = %78
  %84 = load ptr, ptr @stderr, align 8, !tbaa !9
  %85 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %84, ptr noundef @.str.6) #5
  br label %189

86:                                               ; preds = %78
  %87 = load ptr, ptr %17, align 8, !tbaa !9
  %88 = load i32, ptr %7, align 4, !tbaa !5
  %89 = load ptr, ptr %5, align 8, !tbaa !9
  %90 = getelementptr inbounds ptr, ptr %89, i64 1
  %91 = load ptr, ptr %90, align 8, !tbaa !9
  %92 = call ptr @new_conn(ptr noundef %87, i32 noundef %88, ptr noundef %91)
  store ptr %92, ptr %14, align 8, !tbaa !9
  %93 = load ptr, ptr %14, align 8, !tbaa !9
  %94 = icmp eq ptr %93, null
  br i1 %94, label %95, label %98

95:                                               ; preds = %86
  %96 = load ptr, ptr @stderr, align 8, !tbaa !9
  %97 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %96, ptr noundef @.str.7) #5
  br label %189

98:                                               ; preds = %86
  br label %99

99:                                               ; preds = %146, %98
  %100 = load i32, ptr %12, align 4, !tbaa !5
  %101 = icmp ne i32 %100, 0
  br i1 %101, label %102, label %147

102:                                              ; preds = %99
  %103 = load ptr, ptr %14, align 8, !tbaa !9
  %104 = load ptr, ptr %9, align 8, !tbaa !9
  %105 = load i32, ptr %12, align 4, !tbaa !5
  %106 = call i32 @tx(ptr noundef %103, ptr noundef %104, i32 noundef %105)
  store i32 %106, ptr %11, align 4, !tbaa !5
  %107 = load i32, ptr %11, align 4, !tbaa !5
  %108 = icmp sgt i32 %107, 0
  br i1 %108, label %109, label %117

109:                                              ; preds = %102
  %110 = load i32, ptr %11, align 4, !tbaa !5
  %111 = load ptr, ptr %9, align 8, !tbaa !9
  %112 = sext i32 %110 to i64
  %113 = getelementptr inbounds i8, ptr %111, i64 %112
  store ptr %113, ptr %9, align 8, !tbaa !9
  %114 = load i32, ptr %11, align 4, !tbaa !5
  %115 = load i32, ptr %12, align 4, !tbaa !5
  %116 = sub nsw i32 %115, %114
  store i32 %116, ptr %12, align 4, !tbaa !5
  br label %146

117:                                              ; preds = %102
  %118 = load i32, ptr %11, align 4, !tbaa !5
  %119 = icmp eq i32 %118, -1
  br i1 %119, label %120, label %123

120:                                              ; preds = %117
  %121 = load ptr, ptr @stderr, align 8, !tbaa !9
  %122 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %121, ptr noundef @.str.8) #5
  br label %189

123:                                              ; preds = %117
  %124 = load i32, ptr %11, align 4, !tbaa !5
  %125 = icmp eq i32 %124, -2
  br i1 %125, label %126, label %144

126:                                              ; preds = %123
  call void @llvm.lifetime.start.p0(i64 8, ptr %18) #5
  call void @llvm.memset.p0.i64(ptr align 4 %18, i8 0, i64 8, i1 false)
  %127 = load ptr, ptr %14, align 8, !tbaa !9
  %128 = call i32 @get_conn_fd(ptr noundef %127)
  %129 = getelementptr inbounds %struct.pollfd, ptr %18, i32 0, i32 0
  store i32 %128, ptr %129, align 4, !tbaa !17
  %130 = load ptr, ptr %14, align 8, !tbaa !9
  %131 = call i32 @get_conn_pending_tx(ptr noundef %130)
  %132 = trunc i32 %131 to i16
  %133 = getelementptr inbounds %struct.pollfd, ptr %18, i32 0, i32 1
  store i16 %132, ptr %133, align 4, !tbaa !20
  %134 = load i32, ptr %13, align 4, !tbaa !5
  %135 = call i32 @poll(ptr noundef %18, i64 noundef 1, i32 noundef %134)
  %136 = icmp eq i32 %135, 0
  br i1 %136, label %137, label %140

137:                                              ; preds = %126
  %138 = load ptr, ptr @stderr, align 8, !tbaa !9
  %139 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %138, ptr noundef @.str.9) #5
  store i32 2, ptr %19, align 4
  br label %141

140:                                              ; preds = %126
  store i32 0, ptr %19, align 4
  br label %141

141:                                              ; preds = %140, %137
  call void @llvm.lifetime.end.p0(i64 8, ptr %18) #5
  %142 = load i32, ptr %19, align 4
  switch i32 %142, label %206 [
    i32 0, label %143
    i32 2, label %189
  ]

143:                                              ; preds = %141
  br label %144

144:                                              ; preds = %143, %123
  br label %145

145:                                              ; preds = %144
  br label %146

146:                                              ; preds = %145, %109
  br label %99, !llvm.loop !21

147:                                              ; preds = %99
  br label %148

148:                                              ; preds = %187, %147
  %149 = load ptr, ptr %14, align 8, !tbaa !9
  %150 = getelementptr inbounds [2048 x i8], ptr %10, i64 0, i64 0
  %151 = call i32 @rx(ptr noundef %149, ptr noundef %150, i32 noundef 2048)
  store i32 %151, ptr %11, align 4, !tbaa !5
  %152 = load i32, ptr %11, align 4, !tbaa !5
  %153 = icmp sgt i32 %152, 0
  br i1 %153, label %154, label %160

154:                                              ; preds = %148
  %155 = getelementptr inbounds [2048 x i8], ptr %10, i64 0, i64 0
  %156 = load i32, ptr %11, align 4, !tbaa !5
  %157 = sext i32 %156 to i64
  %158 = load ptr, ptr @stdout, align 8, !tbaa !9
  %159 = call i64 @fwrite(ptr noundef %155, i64 noundef 1, i64 noundef %157, ptr noundef %158)
  br label %187

160:                                              ; preds = %148
  %161 = load i32, ptr %11, align 4, !tbaa !5
  %162 = icmp eq i32 %161, -1
  br i1 %162, label %163, label %164

163:                                              ; preds = %160
  br label %188

164:                                              ; preds = %160
  %165 = load i32, ptr %11, align 4, !tbaa !5
  %166 = icmp eq i32 %165, -2
  br i1 %166, label %167, label %185

167:                                              ; preds = %164
  call void @llvm.lifetime.start.p0(i64 8, ptr %20) #5
  call void @llvm.memset.p0.i64(ptr align 4 %20, i8 0, i64 8, i1 false)
  %168 = load ptr, ptr %14, align 8, !tbaa !9
  %169 = call i32 @get_conn_fd(ptr noundef %168)
  %170 = getelementptr inbounds %struct.pollfd, ptr %20, i32 0, i32 0
  store i32 %169, ptr %170, align 4, !tbaa !17
  %171 = load ptr, ptr %14, align 8, !tbaa !9
  %172 = call i32 @get_conn_pending_rx(ptr noundef %171)
  %173 = trunc i32 %172 to i16
  %174 = getelementptr inbounds %struct.pollfd, ptr %20, i32 0, i32 1
  store i16 %173, ptr %174, align 4, !tbaa !20
  %175 = load i32, ptr %13, align 4, !tbaa !5
  %176 = call i32 @poll(ptr noundef %20, i64 noundef 1, i32 noundef %175)
  %177 = icmp eq i32 %176, 0
  br i1 %177, label %178, label %181

178:                                              ; preds = %167
  %179 = load ptr, ptr @stderr, align 8, !tbaa !9
  %180 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %179, ptr noundef @.str.10) #5
  store i32 2, ptr %19, align 4
  br label %182

181:                                              ; preds = %167
  store i32 0, ptr %19, align 4
  br label %182

182:                                              ; preds = %181, %178
  call void @llvm.lifetime.end.p0(i64 8, ptr %20) #5
  %183 = load i32, ptr %19, align 4
  switch i32 %183, label %206 [
    i32 0, label %184
    i32 2, label %189
  ]

184:                                              ; preds = %182
  br label %185

185:                                              ; preds = %184, %164
  br label %186

186:                                              ; preds = %185
  br label %187

187:                                              ; preds = %186, %154
  br label %148

188:                                              ; preds = %163
  store i32 0, ptr %8, align 4, !tbaa !5
  br label %189

189:                                              ; preds = %188, %182, %141, %120, %95, %83, %75, %61, %53, %37, %23
  %190 = load ptr, ptr %14, align 8, !tbaa !9
  %191 = icmp ne ptr %190, null
  br i1 %191, label %192, label %194

192:                                              ; preds = %189
  %193 = load ptr, ptr %14, align 8, !tbaa !9
  call void @teardown(ptr noundef %193)
  br label %194

194:                                              ; preds = %192, %189
  %195 = load ptr, ptr %17, align 8, !tbaa !9
  %196 = icmp ne ptr %195, null
  br i1 %196, label %197, label %199

197:                                              ; preds = %194
  %198 = load ptr, ptr %17, align 8, !tbaa !9
  call void @teardown_ctx(ptr noundef %198)
  br label %199

199:                                              ; preds = %197, %194
  %200 = load ptr, ptr %16, align 8, !tbaa !9
  %201 = icmp ne ptr %200, null
  br i1 %201, label %202, label %204

202:                                              ; preds = %199
  %203 = load ptr, ptr %16, align 8, !tbaa !9
  call void @freeaddrinfo(ptr noundef %203) #5
  br label %204

204:                                              ; preds = %202, %199
  %205 = load i32, ptr %8, align 4, !tbaa !5
  store i32 %205, ptr %3, align 4
  store i32 1, ptr %19, align 4
  br label %206

206:                                              ; preds = %204, %182, %141
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #5
  call void @llvm.lifetime.end.p0(i64 48, ptr %15) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #5
  call void @llvm.lifetime.end.p0(i64 2048, ptr %10) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #5
  %207 = load i32, ptr %3, align 4
  ret i32 %207
}

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #2

; Function Attrs: nounwind
declare i32 @fprintf(ptr noundef, ptr noundef, ...) #3

; Function Attrs: nounwind
declare i32 @snprintf(ptr noundef, i64 noundef, ptr noundef, ...) #3

declare i32 @getaddrinfo(ptr noundef, ptr noundef, ptr noundef, ptr noundef) #4

; Function Attrs: nounwind
declare ptr @signal(i32 noundef, ptr noundef) #3

; Function Attrs: nounwind
declare i32 @socket(i32 noundef, i32 noundef, i32 noundef) #3

declare i32 @connect(i32 noundef, ptr noundef, i32 noundef) #4

declare i32 @fcntl(i32 noundef, i32 noundef, ...) #4

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

declare i64 @fwrite(ptr noundef, i64 noundef, i64 noundef, ptr noundef) #4

; Function Attrs: nounwind
declare void @freeaddrinfo(ptr noundef) #3

attributes #0 = { 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 #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #3 = { nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { "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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!12, !6, i64 4}
!12 = !{!"addrinfo", !6, i64 0, !6, i64 4, !6, i64 8, !6, i64 12, !6, i64 16, !10, i64 24, !10, i64 32, !10, i64 40}
!13 = !{!12, !6, i64 8}
!14 = !{!12, !6, i64 0}
!15 = !{!12, !10, i64 24}
!16 = !{!12, !6, i64 16}
!17 = !{!18, !6, i64 0}
!18 = !{!"pollfd", !6, i64 0, !19, i64 4, !19, i64 6}
!19 = !{!"short", !7, i64 0}
!20 = !{!18, !19, i64 4}
!21 = distinct !{!21, !22}
!22 = !{!"llvm.loop.mustprogress"}


; 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.addrinfo = type { i32, i32, i32, i32, i32, ptr, ptr, ptr }
%struct.pollfd = type { i32, i16, i16 }

@main.tx_msg = external hidden global [300 x i8], align 16
@stderr = external local_unnamed_addr global ptr, align 8
@.str = external hidden unnamed_addr constant [21 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [29 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [27 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [16 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [22 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [16 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [32 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [29 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [10 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [12 x i8], align 1
@stdout = external local_unnamed_addr global ptr, align 8
@.str.10 = external hidden unnamed_addr constant [12 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local ptr @create_ssl_ctx() local_unnamed_addr #0

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: nounwind uwtable
declare dso_local ptr @new_conn(ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local i32 @tx(ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local i32 @rx(ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local i32 @get_conn_fd(ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local i32 @get_conn_pending_tx(ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local i32 @get_conn_pending_rx(ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local void @teardown(ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local void @teardown_ctx(ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local range(i32 0, 2) i32 @main(i32 noundef %0, ptr nocapture noundef readonly %1) local_unnamed_addr #0 {
  %3 = alloca [2048 x i8], align 16
  %4 = alloca %struct.addrinfo, align 8
  %5 = alloca ptr, align 8
  %6 = alloca %struct.pollfd, align 8
  %7 = alloca %struct.pollfd, align 8
  call void @llvm.lifetime.start.p0(i64 2048, ptr nonnull %3) #6
  call void @llvm.lifetime.start.p0(i64 48, ptr nonnull %4) #6
  %8 = getelementptr inbounds i8, ptr %4, i64 8
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(48) %8, i8 0, i64 40, i1 false)
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %5) #6
  store ptr null, ptr %5, align 8, !tbaa !5
  %9 = icmp slt i32 %0, 3
  br i1 %9, label %10, label %14

10:                                               ; preds = %2
  %11 = load ptr, ptr @stderr, align 8, !tbaa !5
  %12 = load ptr, ptr %1, align 8, !tbaa !5
  %13 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %11, ptr noundef nonnull @.str, ptr noundef %12) #7
  br label %.thread74.thread88.thread

14:                                               ; preds = %2
  %15 = getelementptr inbounds i8, ptr %1, i64 8
  %16 = load ptr, ptr %15, align 8, !tbaa !5
  %17 = tail call i32 (ptr, i64, ptr, ...) @snprintf(ptr noundef nonnull dereferenceable(1) @main.tx_msg, i64 noundef 300, ptr noundef nonnull @.str.1, ptr noundef %16) #6
  %18 = tail call ptr @create_ssl_ctx()
  %19 = icmp eq ptr %18, null
  br i1 %19, label %20, label %23

20:                                               ; preds = %14
  %21 = load ptr, ptr @stderr, align 8, !tbaa !5
  %22 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %21, ptr noundef nonnull @.str.2) #7
  br label %.thread74.thread88.thread

23:                                               ; preds = %14
  %24 = getelementptr inbounds i8, ptr %4, i64 4
  store i32 2, ptr %24, align 4, !tbaa !9
  %25 = getelementptr inbounds i8, ptr %4, i64 8
  store i32 1, ptr %25, align 8, !tbaa !12
  store i32 1, ptr %4, align 8, !tbaa !13
  %26 = load ptr, ptr %15, align 8, !tbaa !5
  %27 = getelementptr inbounds i8, ptr %1, i64 16
  %28 = load ptr, ptr %27, align 8, !tbaa !5
  %29 = call i32 @getaddrinfo(ptr noundef %26, ptr noundef %28, ptr noundef nonnull %4, ptr noundef nonnull %5) #6
  %30 = icmp slt i32 %29, 0
  br i1 %30, label %31, label %34

31:                                               ; preds = %23
  %32 = load ptr, ptr @stderr, align 8, !tbaa !5
  %33 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %32, ptr noundef nonnull @.str.3) #7
  br label %.thread74.thread88

34:                                               ; preds = %23
  %35 = call ptr @signal(i32 noundef 13, ptr noundef nonnull inttoptr (i64 1 to ptr)) #6
  %36 = call i32 @socket(i32 noundef 2, i32 noundef 1, i32 noundef 6) #6
  %37 = icmp slt i32 %36, 0
  br i1 %37, label %38, label %41

38:                                               ; preds = %34
  %39 = load ptr, ptr @stderr, align 8, !tbaa !5
  %40 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %39, ptr noundef nonnull @.str.4) #7
  br label %.thread74.thread88

41:                                               ; preds = %34
  %42 = load ptr, ptr %5, align 8, !tbaa !5
  %43 = getelementptr inbounds i8, ptr %42, i64 24
  %44 = load ptr, ptr %43, align 8, !tbaa !14
  %45 = getelementptr inbounds i8, ptr %42, i64 16
  %46 = load i32, ptr %45, align 8, !tbaa !15
  %47 = call i32 @connect(i32 noundef %36, ptr noundef %44, i32 noundef %46) #6
  %48 = icmp slt i32 %47, 0
  br i1 %48, label %49, label %52

49:                                               ; preds = %41
  %50 = load ptr, ptr @stderr, align 8, !tbaa !5
  %51 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %50, ptr noundef nonnull @.str.5) #7
  br label %.thread74.thread88

52:                                               ; preds = %41
  %53 = call i32 (i32, i32, ...) @fcntl(i32 noundef %36, i32 noundef 4, i32 noundef 2048) #6
  %54 = icmp slt i32 %53, 0
  br i1 %54, label %55, label %58

55:                                               ; preds = %52
  %56 = load ptr, ptr @stderr, align 8, !tbaa !5
  %57 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %56, ptr noundef nonnull @.str.6) #7
  br label %.thread74.thread88

58:                                               ; preds = %52
  %59 = load ptr, ptr %15, align 8, !tbaa !5
  %60 = call ptr @new_conn(ptr noundef nonnull %18, i32 noundef %36, ptr noundef %59)
  %61 = icmp eq ptr %60, null
  br i1 %61, label %63, label %.preheader92

.preheader92:                                     ; preds = %58
  %62 = getelementptr inbounds i8, ptr %6, i64 4
  br label %67

63:                                               ; preds = %58
  %64 = load ptr, ptr @stderr, align 8, !tbaa !5
  %65 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %64, ptr noundef nonnull @.str.7) #7
  br label %.thread74.thread88

.preheader:                                       ; preds = %87
  %66 = getelementptr inbounds i8, ptr %7, i64 4
  br label %88

67:                                               ; preds = %.preheader92, %87
  %.04894 = phi i32 [ 299, %.preheader92 ], [ %.149, %87 ]
  %.05093 = phi ptr [ @main.tx_msg, %.preheader92 ], [ %.151, %87 ]
  %68 = call i32 @tx(ptr noundef nonnull %60, ptr noundef %.05093, i32 noundef %.04894)
  %69 = icmp sgt i32 %68, 0
  br i1 %69, label %70, label %74

70:                                               ; preds = %67
  %71 = zext nneg i32 %68 to i64
  %72 = getelementptr inbounds i8, ptr %.05093, i64 %71
  %73 = sub nsw i32 %.04894, %68
  br label %87

74:                                               ; preds = %67
  switch i32 %68, label %87 [
    i32 -1, label %75
    i32 -2, label %78
  ]

75:                                               ; preds = %74
  %76 = load ptr, ptr @stderr, align 8, !tbaa !5
  %77 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %76, ptr noundef nonnull @.str.8) #7
  br label %.thread74

78:                                               ; preds = %74
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %6) #6
  store i64 0, ptr %6, align 8
  %79 = call i32 @get_conn_fd(ptr noundef nonnull %60)
  store i32 %79, ptr %6, align 8, !tbaa !16
  %80 = call i32 @get_conn_pending_tx(ptr noundef nonnull %60)
  %81 = trunc i32 %80 to i16
  store i16 %81, ptr %62, align 4, !tbaa !19
  %82 = call i32 @poll(ptr noundef nonnull %6, i64 noundef 1, i32 noundef 2000) #6
  %83 = icmp eq i32 %82, 0
  br i1 %83, label %84, label %.thread

.thread:                                          ; preds = %78
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %6) #6
  br label %87

84:                                               ; preds = %78
  %85 = load ptr, ptr @stderr, align 8, !tbaa !5
  %86 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %85, ptr noundef nonnull @.str.9) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %6) #6
  br label %.thread74

87:                                               ; preds = %.thread, %74, %70
  %.151 = phi ptr [ %72, %70 ], [ %.05093, %74 ], [ %.05093, %.thread ]
  %.149 = phi i32 [ %73, %70 ], [ %.04894, %74 ], [ %.04894, %.thread ]
  %.not = icmp eq i32 %.149, 0
  br i1 %.not, label %.preheader, label %67, !llvm.loop !20

88:                                               ; preds = %.backedge, %.preheader
  %89 = call i32 @rx(ptr noundef nonnull %60, ptr noundef nonnull %3, i32 noundef 2048)
  %90 = icmp sgt i32 %89, 0
  br i1 %90, label %91, label %95

91:                                               ; preds = %88
  %92 = zext nneg i32 %89 to i64
  %93 = load ptr, ptr @stdout, align 8, !tbaa !5
  %94 = call i64 @fwrite(ptr noundef nonnull %3, i64 noundef 1, i64 noundef %92, ptr noundef %93)
  br label %.backedge

95:                                               ; preds = %88
  switch i32 %89, label %.backedge [
    i32 -1, label %.thread74
    i32 -2, label %96
  ]

96:                                               ; preds = %95
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %7) #6
  store i64 0, ptr %7, align 8
  %97 = call i32 @get_conn_fd(ptr noundef nonnull %60)
  store i32 %97, ptr %7, align 8, !tbaa !16
  %98 = call i32 @get_conn_pending_rx(ptr noundef nonnull %60)
  %99 = trunc i32 %98 to i16
  store i16 %99, ptr %66, align 4, !tbaa !19
  %100 = call i32 @poll(ptr noundef nonnull %7, i64 noundef 1, i32 noundef 2000) #6
  %101 = icmp eq i32 %100, 0
  br i1 %101, label %102, label %.thread71

.thread71:                                        ; preds = %96
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %7) #6
  br label %.backedge

.backedge:                                        ; preds = %.thread71, %95, %91
  br label %88

102:                                              ; preds = %96
  %103 = load ptr, ptr @stderr, align 8, !tbaa !5
  %104 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %103, ptr noundef nonnull @.str.10) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %7) #6
  br label %.thread74

.thread74:                                        ; preds = %95, %75, %84, %102
  %.052 = phi i32 [ 1, %75 ], [ 1, %84 ], [ 1, %102 ], [ 0, %95 ]
  call void @teardown(ptr noundef nonnull %60)
  br label %.thread74.thread88

.thread74.thread88:                               ; preds = %63, %55, %49, %38, %31, %.thread74
  %.0527985 = phi i32 [ %.052, %.thread74 ], [ 1, %63 ], [ 1, %55 ], [ 1, %49 ], [ 1, %38 ], [ 1, %31 ]
  call void @teardown_ctx(ptr noundef nonnull %18)
  %.pre = load ptr, ptr %5, align 8, !tbaa !5
  %.not64 = icmp eq ptr %.pre, null
  br i1 %.not64, label %.thread74.thread88.thread, label %105

105:                                              ; preds = %.thread74.thread88
  call void @freeaddrinfo(ptr noundef nonnull %.pre) #6
  br label %.thread74.thread88.thread

.thread74.thread88.thread:                        ; preds = %10, %20, %.thread74.thread88, %105
  %.052798697 = phi i32 [ %.0527985, %.thread74.thread88 ], [ %.0527985, %105 ], [ 1, %20 ], [ 1, %10 ]
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #6
  call void @llvm.lifetime.end.p0(i64 48, ptr nonnull %4) #6
  call void @llvm.lifetime.end.p0(i64 2048, ptr nonnull %3) #6
  ret i32 %.052798697
}

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #2

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

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

declare i32 @getaddrinfo(ptr noundef, ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #4

; Function Attrs: nounwind
declare ptr @signal(i32 noundef, ptr noundef) local_unnamed_addr #5

; Function Attrs: nounwind
declare i32 @socket(i32 noundef, i32 noundef, i32 noundef) local_unnamed_addr #5

declare i32 @connect(i32 noundef, ptr noundef, i32 noundef) local_unnamed_addr #4

declare i32 @fcntl(i32 noundef, i32 noundef, ...) local_unnamed_addr #4

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

; Function Attrs: nofree nounwind
declare noundef i64 @fwrite(ptr nocapture noundef, i64 noundef, i64 noundef, ptr nocapture noundef) local_unnamed_addr #3

; Function Attrs: nounwind
declare void @freeaddrinfo(ptr noundef) local_unnamed_addr #5

attributes #0 = { 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 #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
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 = { "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 "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 = { cold 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, !11, i64 4}
!10 = !{!"addrinfo", !11, i64 0, !11, i64 4, !11, i64 8, !11, i64 12, !11, i64 16, !6, i64 24, !6, i64 32, !6, i64 40}
!11 = !{!"int", !7, i64 0}
!12 = !{!10, !11, i64 8}
!13 = !{!10, !11, i64 0}
!14 = !{!10, !6, i64 24}
!15 = !{!10, !11, i64 16}
!16 = !{!17, !11, i64 0}
!17 = !{!"pollfd", !11, i64 0, !18, i64 4, !18, i64 6}
!18 = !{!"short", !7, i64 0}
!19 = !{!17, !18, i64 4}
!20 = distinct !{!20, !21}
!21 = !{!"llvm.loop.mustprogress"}


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