; LLVM IR from whoiswelliton/Computer_Engineering_UTFPR-PB :: Embedded_Systems/TIVA Connected TM4C1294XL Projects/01 - lwIP_HTTPServer_on_TIVA (accept)

; 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.lwip_sock = type { ptr, %union.lwip_sock_lastdata, i16, i16, i16, i8 }
%union.lwip_sock_lastdata = type { ptr }
%struct.ip4_addr = type { i32 }
%union.sockaddr_aligned = type { %struct.sockaddr_in }
%struct.sockaddr_in = type { i8, i8, i16, %struct.in_addr, [8 x i8] }
%struct.in_addr = type { i32 }
%struct.netconn = type { i32, i32, %union.anon, i8, ptr, ptr, ptr, i32, i32, i32, i8, ptr, ptr }
%union.anon = type { ptr }
%struct.sockaddr = type { i8, i8, [14 x i8] }

@errno = external global i32, align 4
@.str = external hidden unnamed_addr constant [40 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [16 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [181 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [21 x i8], align 1
@sockets = external hidden global [16 x %struct.lwip_sock], align 16
@lock_tcpip_core = external global ptr, align 8

; Function Attrs: nounwind uwtable
define dso_local i32 @lwip_accept(i32 noundef %0, ptr noundef %1, ptr noundef %2) #0 {
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca %struct.ip4_addr, align 4
  %12 = alloca i16, align 2
  %13 = alloca i32, align 4
  %14 = alloca i8, align 1
  %15 = alloca i32, align 4
  %16 = alloca i32, align 4
  %17 = alloca i32, align 4
  %18 = alloca i32, align 4
  %19 = alloca i32, align 4
  %20 = alloca i32, align 4
  %21 = alloca i32, align 4
  %22 = alloca %union.sockaddr_aligned, align 4
  %23 = alloca i32, align 4
  %24 = alloca i32, align 4
  store i32 %0, ptr %5, align 4, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !9
  store ptr %2, ptr %7, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #5
  call void @llvm.lifetime.start.p0(i64 2, ptr %12) #5
  store i16 0, ptr %12, align 2, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #5
  call void @llvm.lifetime.start.p0(i64 1, ptr %14) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #5
  %25 = load i32, ptr %5, align 4, !tbaa !5
  %26 = call ptr @get_socket(i32 noundef %25)
  store ptr %26, ptr %8, align 8, !tbaa !9
  %27 = load ptr, ptr %8, align 8, !tbaa !9
  %28 = icmp ne ptr %27, null
  br i1 %28, label %30, label %29

29:                                               ; preds = %3
  store i32 -1, ptr %4, align 4
  store i32 1, ptr %17, align 4
  br label %223

30:                                               ; preds = %3
  %31 = load ptr, ptr %8, align 8, !tbaa !9
  %32 = getelementptr inbounds %struct.lwip_sock, ptr %31, i32 0, i32 0
  %33 = load ptr, ptr %32, align 8, !tbaa !13
  %34 = call signext i8 @netconn_accept(ptr noundef %33, ptr noundef %10)
  store i8 %34, ptr %14, align 1, !tbaa !15
  %35 = load i8, ptr %14, align 1, !tbaa !15
  %36 = sext i8 %35 to i32
  %37 = icmp ne i32 %36, 0
  br i1 %37, label %38, label %80

38:                                               ; preds = %30
  %39 = load ptr, ptr %8, align 8, !tbaa !9
  %40 = getelementptr inbounds %struct.lwip_sock, ptr %39, i32 0, i32 0
  %41 = load ptr, ptr %40, align 8, !tbaa !13
  %42 = getelementptr inbounds %struct.netconn, ptr %41, i32 0, i32 0
  %43 = load i32, ptr %42, align 8, !tbaa !16
  %44 = and i32 %43, 240
  %45 = icmp ne i32 %44, 16
  br i1 %45, label %46, label %53

46:                                               ; preds = %38
  br label %47

47:                                               ; preds = %46
  call void @llvm.lifetime.start.p0(i64 4, ptr %18) #5
  store i32 95, ptr %18, align 4, !tbaa !5
  br label %48

48:                                               ; preds = %47
  store i32 95, ptr @errno, align 4, !tbaa !5
  br label %49

49:                                               ; preds = %48
  br label %50

50:                                               ; preds = %49
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #5
  br label %51

51:                                               ; preds = %50
  br label %52

52:                                               ; preds = %51
  br label %79

53:                                               ; preds = %38
  %54 = load i8, ptr %14, align 1, !tbaa !15
  %55 = sext i8 %54 to i32
  %56 = icmp eq i32 %55, -15
  br i1 %56, label %57, label %64

57:                                               ; preds = %53
  br label %58

58:                                               ; preds = %57
  call void @llvm.lifetime.start.p0(i64 4, ptr %19) #5
  store i32 22, ptr %19, align 4, !tbaa !5
  br label %59

59:                                               ; preds = %58
  store i32 22, ptr @errno, align 4, !tbaa !5
  br label %60

60:                                               ; preds = %59
  br label %61

61:                                               ; preds = %60
  call void @llvm.lifetime.end.p0(i64 4, ptr %19) #5
  br label %62

62:                                               ; preds = %61
  br label %63

63:                                               ; preds = %62
  br label %78

64:                                               ; preds = %53
  br label %65

65:                                               ; preds = %64
  call void @llvm.lifetime.start.p0(i64 4, ptr %20) #5
  %66 = load i8, ptr %14, align 1, !tbaa !15
  %67 = call i32 @err_to_errno(i8 noundef signext %66)
  store i32 %67, ptr %20, align 4, !tbaa !5
  br label %68

68:                                               ; preds = %65
  %69 = load i32, ptr %20, align 4, !tbaa !5
  %70 = icmp ne i32 %69, 0
  br i1 %70, label %71, label %73

71:                                               ; preds = %68
  %72 = load i32, ptr %20, align 4, !tbaa !5
  store i32 %72, ptr @errno, align 4, !tbaa !5
  br label %73

73:                                               ; preds = %71, %68
  br label %74

74:                                               ; preds = %73
  br label %75

75:                                               ; preds = %74
  call void @llvm.lifetime.end.p0(i64 4, ptr %20) #5
  br label %76

76:                                               ; preds = %75
  br label %77

77:                                               ; preds = %76
  br label %78

78:                                               ; preds = %77, %63
  br label %79

79:                                               ; preds = %78, %52
  store i32 -1, ptr %4, align 4
  store i32 1, ptr %17, align 4
  br label %223

80:                                               ; preds = %30
  br label %81

81:                                               ; preds = %80
  %82 = load ptr, ptr %10, align 8, !tbaa !9
  %83 = icmp ne ptr %82, null
  br i1 %83, label %89, label %84

84:                                               ; preds = %81
  br label %85

85:                                               ; preds = %84
  %86 = call i32 (ptr, ...) @printf(ptr noundef @.str, ptr noundef @.str.1, i32 noundef 651, ptr noundef @.str.2)
  br label %87

87:                                               ; preds = %85
  br label %88

88:                                               ; preds = %87
  br label %89

89:                                               ; preds = %88, %81
  br label %90

90:                                               ; preds = %89
  br label %91

91:                                               ; preds = %90
  %92 = load ptr, ptr %10, align 8, !tbaa !9
  %93 = call i32 @alloc_socket(ptr noundef %92, i32 noundef 1)
  store i32 %93, ptr %13, align 4, !tbaa !5
  %94 = load i32, ptr %13, align 4, !tbaa !5
  %95 = icmp eq i32 %94, -1
  br i1 %95, label %96, label %105

96:                                               ; preds = %91
  %97 = load ptr, ptr %10, align 8, !tbaa !9
  %98 = call signext i8 @netconn_delete(ptr noundef %97)
  br label %99

99:                                               ; preds = %96
  call void @llvm.lifetime.start.p0(i64 4, ptr %21) #5
  store i32 23, ptr %21, align 4, !tbaa !5
  br label %100

100:                                              ; preds = %99
  store i32 23, ptr @errno, align 4, !tbaa !5
  br label %101

101:                                              ; preds = %100
  br label %102

102:                                              ; preds = %101
  call void @llvm.lifetime.end.p0(i64 4, ptr %21) #5
  br label %103

103:                                              ; preds = %102
  br label %104

104:                                              ; preds = %103
  store i32 -1, ptr %4, align 4
  store i32 1, ptr %17, align 4
  br label %223

105:                                              ; preds = %91
  br label %106

106:                                              ; preds = %105
  %107 = load i32, ptr %13, align 4, !tbaa !5
  %108 = icmp sge i32 %107, 0
  br i1 %108, label %109, label %112

109:                                              ; preds = %106
  %110 = load i32, ptr %13, align 4, !tbaa !5
  %111 = icmp slt i32 %110, 16
  br i1 %111, label %117, label %112

112:                                              ; preds = %109, %106
  br label %113

113:                                              ; preds = %112
  %114 = call i32 (ptr, ...) @printf(ptr noundef @.str, ptr noundef @.str.3, i32 noundef 660, ptr noundef @.str.2)
  br label %115

115:                                              ; preds = %113
  br label %116

116:                                              ; preds = %115
  br label %117

117:                                              ; preds = %116, %109
  br label %118

118:                                              ; preds = %117
  br label %119

119:                                              ; preds = %118
  %120 = load i32, ptr %13, align 4, !tbaa !5
  %121 = sub nsw i32 %120, 0
  %122 = sext i32 %121 to i64
  %123 = getelementptr inbounds [16 x %struct.lwip_sock], ptr @sockets, i64 0, i64 %122
  store ptr %123, ptr %9, align 8, !tbaa !9
  %124 = call i32 @sys_arch_protect()
  store i32 %124, ptr %16, align 4, !tbaa !5
  %125 = load ptr, ptr %10, align 8, !tbaa !9
  %126 = getelementptr inbounds %struct.netconn, ptr %125, i32 0, i32 7
  %127 = load i32, ptr %126, align 8, !tbaa !18
  %128 = sub nsw i32 -1, %127
  %129 = trunc i32 %128 to i16
  %130 = sext i16 %129 to i32
  store i32 %130, ptr %15, align 4, !tbaa !5
  %131 = load i32, ptr %13, align 4, !tbaa !5
  %132 = load ptr, ptr %10, align 8, !tbaa !9
  %133 = getelementptr inbounds %struct.netconn, ptr %132, i32 0, i32 7
  store i32 %131, ptr %133, align 8, !tbaa !18
  %134 = load i32, ptr %16, align 4, !tbaa !5
  call void @sys_arch_unprotect(i32 noundef %134)
  %135 = load ptr, ptr %10, align 8, !tbaa !9
  %136 = getelementptr inbounds %struct.netconn, ptr %135, i32 0, i32 12
  %137 = load ptr, ptr %136, align 8, !tbaa !19
  %138 = icmp ne ptr %137, null
  br i1 %138, label %139, label %151

139:                                              ; preds = %119
  call void @sys_mutex_lock(ptr noundef @lock_tcpip_core)
  br label %140

140:                                              ; preds = %143, %139
  %141 = load i32, ptr %15, align 4, !tbaa !5
  %142 = icmp sgt i32 %141, 0
  br i1 %142, label %143, label %150

143:                                              ; preds = %140
  %144 = load i32, ptr %15, align 4, !tbaa !5
  %145 = add nsw i32 %144, -1
  store i32 %145, ptr %15, align 4, !tbaa !5
  %146 = load ptr, ptr %10, align 8, !tbaa !9
  %147 = getelementptr inbounds %struct.netconn, ptr %146, i32 0, i32 12
  %148 = load ptr, ptr %147, align 8, !tbaa !19
  %149 = load ptr, ptr %10, align 8, !tbaa !9
  call void %148(ptr noundef %149, i32 noundef 0, i16 noundef zeroext 0)
  br label %140, !llvm.loop !20

150:                                              ; preds = %140
  call void @sys_mutex_unlock(ptr noundef @lock_tcpip_core)
  br label %151

151:                                              ; preds = %150, %119
  %152 = load ptr, ptr %6, align 8, !tbaa !9
  %153 = icmp ne ptr %152, null
  br i1 %153, label %154, label %214

154:                                              ; preds = %151
  %155 = load ptr, ptr %7, align 8, !tbaa !9
  %156 = icmp ne ptr %155, null
  br i1 %156, label %157, label %214

157:                                              ; preds = %154
  call void @llvm.lifetime.start.p0(i64 16, ptr %22) #5
  %158 = load ptr, ptr %10, align 8, !tbaa !9
  %159 = call signext i8 @netconn_getaddr(ptr noundef %158, ptr noundef %11, ptr noundef %12, i8 noundef zeroext 0)
  store i8 %159, ptr %14, align 1, !tbaa !15
  %160 = load i8, ptr %14, align 1, !tbaa !15
  %161 = sext i8 %160 to i32
  %162 = icmp ne i32 %161, 0
  br i1 %162, label %163, label %180

163:                                              ; preds = %157
  %164 = load ptr, ptr %10, align 8, !tbaa !9
  %165 = call signext i8 @netconn_delete(ptr noundef %164)
  %166 = load ptr, ptr %9, align 8, !tbaa !9
  call void @free_socket(ptr noundef %166, i32 noundef 1)
  br label %167

167:                                              ; preds = %163
  call void @llvm.lifetime.start.p0(i64 4, ptr %23) #5
  %168 = load i8, ptr %14, align 1, !tbaa !15
  %169 = call i32 @err_to_errno(i8 noundef signext %168)
  store i32 %169, ptr %23, align 4, !tbaa !5
  br label %170

170:                                              ; preds = %167
  %171 = load i32, ptr %23, align 4, !tbaa !5
  %172 = icmp ne i32 %171, 0
  br i1 %172, label %173, label %175

173:                                              ; preds = %170
  %174 = load i32, ptr %23, align 4, !tbaa !5
  store i32 %174, ptr @errno, align 4, !tbaa !5
  br label %175

175:                                              ; preds = %173, %170
  br label %176

176:                                              ; preds = %175
  br label %177

177:                                              ; preds = %176
  call void @llvm.lifetime.end.p0(i64 4, ptr %23) #5
  br label %178

178:                                              ; preds = %177
  br label %179

179:                                              ; preds = %178
  store i32 -1, ptr %4, align 4
  store i32 1, ptr %17, align 4
  br label %211

180:                                              ; preds = %157
  br label %181

181:                                              ; preds = %180
  %182 = getelementptr inbounds %struct.sockaddr_in, ptr %22, i32 0, i32 0
  store i8 16, ptr %182, align 4, !tbaa !22
  %183 = getelementptr inbounds %struct.sockaddr_in, ptr %22, i32 0, i32 1
  store i8 2, ptr %183, align 1, !tbaa !25
  %184 = load i16, ptr %12, align 2, !tbaa !11
  %185 = call zeroext i16 @lwip_htons(i16 noundef zeroext %184)
  %186 = getelementptr inbounds %struct.sockaddr_in, ptr %22, i32 0, i32 2
  store i16 %185, ptr %186, align 2, !tbaa !26
  %187 = getelementptr inbounds %struct.ip4_addr, ptr %11, i32 0, i32 0
  %188 = load i32, ptr %187, align 4, !tbaa !27
  %189 = getelementptr inbounds %struct.sockaddr_in, ptr %22, i32 0, i32 3
  %190 = getelementptr inbounds %struct.in_addr, ptr %189, i32 0, i32 0
  store i32 %188, ptr %190, align 4, !tbaa !29
  %191 = getelementptr inbounds %struct.sockaddr_in, ptr %22, i32 0, i32 4
  %192 = getelementptr inbounds [8 x i8], ptr %191, i64 0, i64 0
  call void @llvm.memset.p0.i64(ptr align 4 %192, i8 0, i64 8, i1 false)
  br label %193

193:                                              ; preds = %181
  br label %194

194:                                              ; preds = %193
  %195 = load ptr, ptr %7, align 8, !tbaa !9
  %196 = load i32, ptr %195, align 4, !tbaa !5
  %197 = getelementptr inbounds %struct.sockaddr, ptr %22, i32 0, i32 0
  %198 = load i8, ptr %197, align 4, !tbaa !15
  %199 = zext i8 %198 to i32
  %200 = icmp ugt i32 %196, %199
  br i1 %200, label %201, label %206

201:                                              ; preds = %194
  %202 = getelementptr inbounds %struct.sockaddr, ptr %22, i32 0, i32 0
  %203 = load i8, ptr %202, align 4, !tbaa !15
  %204 = zext i8 %203 to i32
  %205 = load ptr, ptr %7, align 8, !tbaa !9
  store i32 %204, ptr %205, align 4, !tbaa !5
  br label %206

206:                                              ; preds = %201, %194
  %207 = load ptr, ptr %6, align 8, !tbaa !9
  %208 = load ptr, ptr %7, align 8, !tbaa !9
  %209 = load i32, ptr %208, align 4, !tbaa !5
  %210 = zext i32 %209 to i64
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %207, ptr align 4 %22, i64 %210, i1 false)
  store i32 0, ptr %17, align 4
  br label %211

211:                                              ; preds = %206, %179
  call void @llvm.lifetime.end.p0(i64 16, ptr %22) #5
  %212 = load i32, ptr %17, align 4
  switch i32 %212, label %223 [
    i32 0, label %213
  ]

213:                                              ; preds = %211
  br label %215

214:                                              ; preds = %154, %151
  br label %215

215:                                              ; preds = %214, %213
  br label %216

216:                                              ; preds = %215
  call void @llvm.lifetime.start.p0(i64 4, ptr %24) #5
  store i32 0, ptr %24, align 4, !tbaa !5
  br label %217

217:                                              ; preds = %216
  br label %218

218:                                              ; preds = %217
  br label %219

219:                                              ; preds = %218
  call void @llvm.lifetime.end.p0(i64 4, ptr %24) #5
  br label %220

220:                                              ; preds = %219
  br label %221

221:                                              ; preds = %220
  %222 = load i32, ptr %13, align 4, !tbaa !5
  store i32 %222, ptr %4, align 4
  store i32 1, ptr %17, align 4
  br label %223

223:                                              ; preds = %221, %211, %104, %79, %29
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #5
  call void @llvm.lifetime.end.p0(i64 1, ptr %14) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #5
  call void @llvm.lifetime.end.p0(i64 2, ptr %12) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #5
  %224 = load i32, ptr %4, align 4
  ret i32 %224
}

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

; Function Attrs: nounwind uwtable
declare hidden ptr @get_socket(i32 noundef) #0

declare signext i8 @netconn_accept(ptr noundef, ptr noundef) #2

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

declare i32 @err_to_errno(i8 noundef signext) #2

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

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

declare signext i8 @netconn_delete(ptr noundef) #2

declare i32 @sys_arch_protect() #2

declare void @sys_arch_unprotect(i32 noundef) #2

declare void @sys_mutex_lock(ptr noundef) #2

declare void @sys_mutex_unlock(ptr noundef) #2

declare signext i8 @netconn_getaddr(ptr noundef, ptr noundef, ptr noundef, i8 noundef zeroext) #2

; Function Attrs: nounwind uwtable
declare hidden void @free_socket(ptr noundef, i32 noundef) #0

declare zeroext i16 @lwip_htons(i16 noundef zeroext) #2

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

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #4

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 = { "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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #4 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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, !12, i64 0}
!12 = !{!"short", !7, i64 0}
!13 = !{!14, !10, i64 0}
!14 = !{!"lwip_sock", !10, i64 0, !7, i64 8, !12, i64 16, !12, i64 18, !12, i64 20, !7, i64 22}
!15 = !{!7, !7, i64 0}
!16 = !{!17, !6, i64 0}
!17 = !{!"netconn", !6, i64 0, !6, i64 4, !7, i64 8, !7, i64 16, !10, i64 24, !10, i64 32, !10, i64 40, !6, i64 48, !6, i64 52, !6, i64 56, !7, i64 60, !10, i64 64, !10, i64 72}
!18 = !{!17, !6, i64 48}
!19 = !{!17, !10, i64 72}
!20 = distinct !{!20, !21}
!21 = !{!"llvm.loop.mustprogress"}
!22 = !{!23, !7, i64 0}
!23 = !{!"sockaddr_in", !7, i64 0, !7, i64 1, !12, i64 2, !24, i64 4, !7, i64 8}
!24 = !{!"in_addr", !6, i64 0}
!25 = !{!23, !7, i64 1}
!26 = !{!23, !12, i64 2}
!27 = !{!28, !6, i64 0}
!28 = !{!"ip4_addr", !6, i64 0}
!29 = !{!23, !6, i64 4}


; 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.lwip_sock = type { ptr, %union.lwip_sock_lastdata, i16, i16, i16, i8 }
%union.lwip_sock_lastdata = type { ptr }
%struct.ip4_addr = type { i32 }
%struct.sockaddr_in = type { i8, i8, i16, %struct.in_addr, [8 x i8] }
%struct.in_addr = type { i32 }

@errno = external local_unnamed_addr global i32, align 4
@.str = external hidden unnamed_addr constant [40 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [16 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [181 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [21 x i8], align 1
@sockets = external hidden global [16 x %struct.lwip_sock], align 16
@lock_tcpip_core = external global ptr, align 8

; Function Attrs: nounwind uwtable
define dso_local i32 @lwip_accept(i32 noundef %0, ptr noundef writeonly %1, ptr noundef %2) local_unnamed_addr #0 {
  %4 = alloca ptr, align 8
  %5 = alloca %struct.ip4_addr, align 4
  %6 = alloca i16, align 2
  %.sroa.0 = alloca %struct.sockaddr_in, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %5) #5
  call void @llvm.lifetime.start.p0(i64 2, ptr nonnull %6) #5
  store i16 0, ptr %6, align 2, !tbaa !5
  %7 = tail call ptr @get_socket(i32 noundef %0)
  %.not = icmp eq ptr %7, null
  br i1 %.not, label %76, label %8

8:                                                ; preds = %3
  %9 = load ptr, ptr %7, align 8, !tbaa !9
  %10 = call signext i8 @netconn_accept(ptr noundef %9, ptr noundef nonnull %4) #5
  %.not47 = icmp eq i8 %10, 0
  br i1 %.not47, label %22, label %11

11:                                               ; preds = %8
  %12 = load ptr, ptr %7, align 8, !tbaa !9
  %13 = load i32, ptr %12, align 8, !tbaa !12
  %14 = and i32 %13, 240
  %.not52 = icmp eq i32 %14, 16
  br i1 %.not52, label %16, label %15

15:                                               ; preds = %11
  store i32 95, ptr @errno, align 4, !tbaa !15
  br label %76

16:                                               ; preds = %11
  %17 = icmp eq i8 %10, -15
  br i1 %17, label %18, label %19

18:                                               ; preds = %16
  store i32 22, ptr @errno, align 4, !tbaa !15
  br label %76

19:                                               ; preds = %16
  %20 = call i32 @err_to_errno(i8 noundef signext %10) #5
  %.not53 = icmp eq i32 %20, 0
  br i1 %.not53, label %76, label %21

21:                                               ; preds = %19
  store i32 %20, ptr @errno, align 4, !tbaa !15
  br label %76

22:                                               ; preds = %8
  %23 = load ptr, ptr %4, align 8, !tbaa !16
  %.not48 = icmp eq ptr %23, null
  br i1 %.not48, label %24, label %26

24:                                               ; preds = %22
  %25 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, ptr noundef nonnull @.str.1, i32 noundef 651, ptr noundef nonnull @.str.2)
  %.pre = load ptr, ptr %4, align 8, !tbaa !16
  br label %26

26:                                               ; preds = %24, %22
  %27 = phi ptr [ %.pre, %24 ], [ %23, %22 ]
  %28 = call i32 @alloc_socket(ptr noundef %27, i32 noundef 1)
  %29 = icmp eq i32 %28, -1
  br i1 %29, label %30, label %33

30:                                               ; preds = %26
  %31 = load ptr, ptr %4, align 8, !tbaa !16
  %32 = call signext i8 @netconn_delete(ptr noundef %31) #5
  store i32 23, ptr @errno, align 4, !tbaa !15
  br label %76

33:                                               ; preds = %26
  %or.cond = icmp ult i32 %28, 16
  br i1 %or.cond, label %36, label %34

34:                                               ; preds = %33
  %35 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, ptr noundef nonnull @.str.3, i32 noundef 660, ptr noundef nonnull @.str.2)
  br label %36

36:                                               ; preds = %33, %34
  %37 = sext i32 %28 to i64
  %38 = getelementptr inbounds [16 x %struct.lwip_sock], ptr @sockets, i64 0, i64 %37
  %39 = call i32 @sys_arch_protect() #5
  %40 = load ptr, ptr %4, align 8, !tbaa !16
  %41 = getelementptr inbounds i8, ptr %40, i64 48
  %42 = load i32, ptr %41, align 8, !tbaa !17
  store i32 %28, ptr %41, align 8, !tbaa !17
  call void @sys_arch_unprotect(i32 noundef %39) #5
  %43 = load ptr, ptr %4, align 8, !tbaa !16
  %44 = getelementptr inbounds i8, ptr %43, i64 72
  %45 = load ptr, ptr %44, align 8, !tbaa !18
  %.not49 = icmp eq ptr %45, null
  br i1 %.not49, label %55, label %46

46:                                               ; preds = %36
  %47 = xor i32 %42, -1
  %sext = shl i32 %47, 16
  %48 = ashr exact i32 %sext, 16
  call void @sys_mutex_lock(ptr noundef nonnull @lock_tcpip_core) #5
  %49 = icmp sgt i32 %48, 0
  br i1 %49, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %46, %.lr.ph
  %.03854 = phi i32 [ %50, %.lr.ph ], [ %48, %46 ]
  %50 = add nsw i32 %.03854, -1
  %51 = load ptr, ptr %4, align 8, !tbaa !16
  %52 = getelementptr inbounds i8, ptr %51, i64 72
  %53 = load ptr, ptr %52, align 8, !tbaa !18
  call void %53(ptr noundef %51, i32 noundef 0, i16 noundef zeroext 0) #5
  %54 = icmp ugt i32 %.03854, 1
  br i1 %54, label %.lr.ph, label %._crit_edge, !llvm.loop !19

._crit_edge:                                      ; preds = %.lr.ph, %46
  call void @sys_mutex_unlock(ptr noundef nonnull @lock_tcpip_core) #5
  br label %55

55:                                               ; preds = %._crit_edge, %36
  %56 = icmp ne ptr %1, null
  %57 = icmp ne ptr %2, null
  %or.cond3 = and i1 %56, %57
  br i1 %or.cond3, label %58, label %76

58:                                               ; preds = %55
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %.sroa.0)
  %59 = load ptr, ptr %4, align 8, !tbaa !16
  %60 = call signext i8 @netconn_getaddr(ptr noundef %59, ptr noundef nonnull %5, ptr noundef nonnull %6, i8 noundef zeroext 0) #5
  %.not50 = icmp eq i8 %60, 0
  br i1 %.not50, label %66, label %61

61:                                               ; preds = %58
  %62 = load ptr, ptr %4, align 8, !tbaa !16
  %63 = call signext i8 @netconn_delete(ptr noundef %62) #5
  call void @free_socket(ptr noundef nonnull %38, i32 noundef 1)
  %64 = call i32 @err_to_errno(i8 noundef signext %60) #5
  %.not51 = icmp eq i32 %64, 0
  br i1 %.not51, label %.thread, label %65

65:                                               ; preds = %61
  store i32 %64, ptr @errno, align 4, !tbaa !15
  br label %.thread

66:                                               ; preds = %58
  store i8 16, ptr %.sroa.0, align 8, !tbaa !21
  %.sroa.0.1.sroa_idx = getelementptr inbounds i8, ptr %.sroa.0, i64 1
  store i8 2, ptr %.sroa.0.1.sroa_idx, align 1, !tbaa !24
  %67 = load i16, ptr %6, align 2, !tbaa !5
  %68 = call zeroext i16 @lwip_htons(i16 noundef zeroext %67) #5
  %.sroa.0.2.sroa_idx = getelementptr inbounds i8, ptr %.sroa.0, i64 2
  store i16 %68, ptr %.sroa.0.2.sroa_idx, align 2, !tbaa !25
  %69 = load i32, ptr %5, align 4, !tbaa !26
  %.sroa.0.4.sroa_idx = getelementptr inbounds i8, ptr %.sroa.0, i64 4
  store i32 %69, ptr %.sroa.0.4.sroa_idx, align 4, !tbaa !28
  %.sroa.0.8.sroa_idx = getelementptr inbounds i8, ptr %.sroa.0, i64 8
  store i64 0, ptr %.sroa.0.8.sroa_idx, align 8
  %70 = load i32, ptr %2, align 4, !tbaa !15
  %71 = icmp ugt i32 %70, 16
  br i1 %71, label %72, label %73

72:                                               ; preds = %66
  store i32 16, ptr %2, align 4, !tbaa !15
  br label %73

.thread:                                          ; preds = %61, %65
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %.sroa.0)
  br label %76

73:                                               ; preds = %66, %72
  %74 = phi i32 [ %70, %66 ], [ 16, %72 ]
  %75 = zext nneg i32 %74 to i64
  call void @llvm.memcpy.p0.p0.i64(ptr nonnull align 1 %1, ptr nonnull align 8 %.sroa.0, i64 %75, i1 false)
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %.sroa.0)
  br label %76

76:                                               ; preds = %55, %73, %.thread, %15, %18, %21, %19, %3, %30
  %.1 = phi i32 [ -1, %30 ], [ -1, %3 ], [ -1, %19 ], [ -1, %21 ], [ -1, %18 ], [ -1, %15 ], [ -1, %.thread ], [ %28, %73 ], [ %28, %55 ]
  call void @llvm.lifetime.end.p0(i64 2, ptr nonnull %6) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %5) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #5
  ret i32 %.1
}

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

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

declare signext i8 @netconn_accept(ptr noundef, ptr noundef) local_unnamed_addr #2

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

declare i32 @err_to_errno(i8 noundef signext) local_unnamed_addr #2

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

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

declare signext i8 @netconn_delete(ptr noundef) local_unnamed_addr #2

declare i32 @sys_arch_protect() local_unnamed_addr #2

declare void @sys_arch_unprotect(i32 noundef) local_unnamed_addr #2

declare void @sys_mutex_lock(ptr noundef) local_unnamed_addr #2

declare void @sys_mutex_unlock(ptr noundef) local_unnamed_addr #2

declare signext i8 @netconn_getaddr(ptr noundef, ptr noundef, ptr noundef, i8 noundef zeroext) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
declare hidden void @free_socket(ptr noundef, i32 noundef) local_unnamed_addr #0

declare zeroext i16 @lwip_htons(i16 noundef zeroext) local_unnamed_addr #2

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #4

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 = { "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 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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 = !{!"short", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !11, i64 0}
!10 = !{!"lwip_sock", !11, i64 0, !7, i64 8, !6, i64 16, !6, i64 18, !6, i64 20, !7, i64 22}
!11 = !{!"any pointer", !7, i64 0}
!12 = !{!13, !14, i64 0}
!13 = !{!"netconn", !14, i64 0, !14, i64 4, !7, i64 8, !7, i64 16, !11, i64 24, !11, i64 32, !11, i64 40, !14, i64 48, !14, i64 52, !14, i64 56, !7, i64 60, !11, i64 64, !11, i64 72}
!14 = !{!"int", !7, i64 0}
!15 = !{!14, !14, i64 0}
!16 = !{!11, !11, i64 0}
!17 = !{!13, !14, i64 48}
!18 = !{!13, !11, i64 72}
!19 = distinct !{!19, !20}
!20 = !{!"llvm.loop.mustprogress"}
!21 = !{!22, !7, i64 0}
!22 = !{!"sockaddr_in", !7, i64 0, !7, i64 1, !6, i64 2, !23, i64 4, !7, i64 8}
!23 = !{!"in_addr", !14, i64 0}
!24 = !{!22, !7, i64 1}
!25 = !{!22, !6, i64 2}
!26 = !{!27, !14, i64 0}
!27 = !{!"ip4_addr", !14, i64 0}
!28 = !{!22, !14, i64 4}


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