; LLVM IR from thalium/icebox :: third_party/virtualbox/src/VBox/Devices/EFI/Firmware/MdeModulePkg/Universal (TcpGetSegmentSndQue)

; 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._TCP_CB = type { %struct._LIST_ENTRY, ptr, ptr, %struct._TCP_PEER, %struct._TCP_PEER, %struct._LIST_ENTRY, %struct._LIST_ENTRY, i32, i32, i8, i8, i16, i32, i32, i32, i32, i32, i32, i32, i32, i32, i16, i32, i32, i32, i32, i32, i16, i16, [6 x i32], i32, i32, i32, i8, i8, i8, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i16, i8, i8, i32, i32, i32, i8, i8, i16, i32, i32, i32, i8, i8, i8, %struct.EFI_IPv4_ADDRESS, ptr }
%struct._TCP_PEER = type { i32, i16 }
%struct._LIST_ENTRY = type { ptr, ptr }
%struct.EFI_IPv4_ADDRESS = type { [4 x i8] }
%struct.NET_BUF = type { i32, i64, %struct._LIST_ENTRY, %union.NET_IP_HEAD, ptr, ptr, [64 x i8], ptr, i32, i32, [1 x %struct.NET_BLOCK_OP] }
%union.NET_IP_HEAD = type { ptr }
%struct.NET_BLOCK_OP = type { ptr, ptr, ptr, ptr, i32 }
%struct._TCP_SEG = type { i32, i32, i32, i8, i16, i32 }
%struct.NET_VECTOR = type { i32, i64, ptr, ptr, i32, i32, i32, [1 x %struct.NET_BLOCK] }
%struct.NET_BLOCK = type { i32, ptr }

@.str = external hidden unnamed_addr constant [153 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [77 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [12 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [21 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [20 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [13 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [21 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 zeroext i8 @DebugAssertEnabled() #1

declare void @DebugAssert(ptr noundef, i64 noundef, ptr noundef) #1

declare ptr @NetbufAllocSpace(ptr noundef, i32 noundef, i8 noundef zeroext) #1

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

19:                                               ; preds = %3
  %20 = call zeroext i8 @DebugAssertEnabled()
  %21 = icmp ne i8 %20, 0
  br i1 %21, label %22, label %37

22:                                               ; preds = %19
  %23 = load ptr, ptr %5, align 8, !tbaa !5
  %24 = icmp ne ptr %23, null
  br i1 %24, label %25, label %35

25:                                               ; preds = %22
  %26 = load i32, ptr %6, align 4, !tbaa !9
  %27 = load ptr, ptr %5, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct._TCP_CB, ptr %27, i32 0, i32 14
  %29 = load i32, ptr %28, align 4, !tbaa !11
  %30 = sub i32 %26, %29
  %31 = icmp sle i32 %30, 0
  br i1 %31, label %32, label %35

32:                                               ; preds = %25
  %33 = load i32, ptr %7, align 4, !tbaa !9
  %34 = icmp ugt i32 %33, 0
  br i1 %34, label %36, label %35

35:                                               ; preds = %32, %25, %22
  call void @DebugAssert(ptr noundef @.str, i64 noundef 430, ptr noundef @.str.7)
  br label %36

36:                                               ; preds = %35, %32
  br label %37

37:                                               ; preds = %36, %19
  br label %38

38:                                               ; preds = %37
  br label %39

39:                                               ; preds = %38
  %40 = load ptr, ptr %5, align 8, !tbaa !5
  %41 = getelementptr inbounds %struct._TCP_CB, ptr %40, i32 0, i32 5
  store ptr %41, ptr %8, align 8, !tbaa !5
  store ptr null, ptr %10, align 8, !tbaa !5
  store ptr null, ptr %11, align 8, !tbaa !5
  %42 = load ptr, ptr %8, align 8, !tbaa !5
  %43 = getelementptr inbounds %struct._LIST_ENTRY, ptr %42, i32 0, i32 0
  %44 = load ptr, ptr %43, align 8, !tbaa !17
  store ptr %44, ptr %9, align 8, !tbaa !5
  br label %45

45:                                               ; preds = %72, %39
  %46 = load ptr, ptr %9, align 8, !tbaa !5
  %47 = load ptr, ptr %8, align 8, !tbaa !5
  %48 = icmp ne ptr %46, %47
  br i1 %48, label %49, label %76

49:                                               ; preds = %45
  %50 = load ptr, ptr %9, align 8, !tbaa !5
  %51 = ptrtoint ptr %50 to i64
  %52 = sub i64 %51, ptrtoint (ptr getelementptr inbounds (%struct.NET_BUF, ptr null, i32 0, i32 2) to i64)
  %53 = inttoptr i64 %52 to ptr
  store ptr %53, ptr %10, align 8, !tbaa !5
  %54 = load ptr, ptr %10, align 8, !tbaa !5
  %55 = getelementptr inbounds %struct.NET_BUF, ptr %54, i32 0, i32 6
  %56 = getelementptr inbounds [64 x i8], ptr %55, i64 0, i64 0
  store ptr %56, ptr %11, align 8, !tbaa !5
  %57 = load i32, ptr %6, align 4, !tbaa !9
  %58 = load ptr, ptr %11, align 8, !tbaa !5
  %59 = getelementptr inbounds %struct._TCP_SEG, ptr %58, i32 0, i32 1
  %60 = load i32, ptr %59, align 4, !tbaa !18
  %61 = sub i32 %57, %60
  %62 = icmp slt i32 %61, 0
  br i1 %62, label %63, label %71

63:                                               ; preds = %49
  %64 = load ptr, ptr %11, align 8, !tbaa !5
  %65 = getelementptr inbounds %struct._TCP_SEG, ptr %64, i32 0, i32 0
  %66 = load i32, ptr %65, align 4, !tbaa !20
  %67 = load i32, ptr %6, align 4, !tbaa !9
  %68 = sub i32 %66, %67
  %69 = icmp sle i32 %68, 0
  br i1 %69, label %70, label %71

70:                                               ; preds = %63
  br label %76

71:                                               ; preds = %63, %49
  br label %72

72:                                               ; preds = %71
  %73 = load ptr, ptr %9, align 8, !tbaa !5
  %74 = getelementptr inbounds %struct._LIST_ENTRY, ptr %73, i32 0, i32 0
  %75 = load ptr, ptr %74, align 8, !tbaa !17
  store ptr %75, ptr %9, align 8, !tbaa !5
  br label %45, !llvm.loop !21

76:                                               ; preds = %70, %45
  br label %77

77:                                               ; preds = %76
  %78 = call zeroext i8 @DebugAssertEnabled()
  %79 = icmp ne i8 %78, 0
  br i1 %79, label %80, label %86

80:                                               ; preds = %77
  %81 = load ptr, ptr %9, align 8, !tbaa !5
  %82 = load ptr, ptr %8, align 8, !tbaa !5
  %83 = icmp ne ptr %81, %82
  br i1 %83, label %85, label %84

84:                                               ; preds = %80
  call void @DebugAssert(ptr noundef @.str, i64 noundef 450, ptr noundef @.str.8)
  br label %85

85:                                               ; preds = %84, %80
  br label %86

86:                                               ; preds = %85, %77
  br label %87

87:                                               ; preds = %86
  br label %88

88:                                               ; preds = %87
  br label %89

89:                                               ; preds = %88
  %90 = call zeroext i8 @DebugAssertEnabled()
  %91 = icmp ne i8 %90, 0
  br i1 %91, label %92, label %97

92:                                               ; preds = %89
  %93 = load ptr, ptr %10, align 8, !tbaa !5
  %94 = icmp ne ptr %93, null
  br i1 %94, label %96, label %95

95:                                               ; preds = %92
  call void @DebugAssert(ptr noundef @.str, i64 noundef 451, ptr noundef @.str.9)
  br label %96

96:                                               ; preds = %95, %92
  br label %97

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

98:                                               ; preds = %97
  br label %99

99:                                               ; preds = %98
  br label %100

100:                                              ; preds = %99
  %101 = call zeroext i8 @DebugAssertEnabled()
  %102 = icmp ne i8 %101, 0
  br i1 %102, label %103, label %108

103:                                              ; preds = %100
  %104 = load ptr, ptr %11, align 8, !tbaa !5
  %105 = icmp ne ptr %104, null
  br i1 %105, label %107, label %106

106:                                              ; preds = %103
  call void @DebugAssert(ptr noundef @.str, i64 noundef 452, ptr noundef @.str.10)
  br label %107

107:                                              ; preds = %106, %103
  br label %108

108:                                              ; preds = %107, %100
  br label %109

109:                                              ; preds = %108
  br label %110

110:                                              ; preds = %109
  %111 = load ptr, ptr %11, align 8, !tbaa !5
  %112 = getelementptr inbounds %struct._TCP_SEG, ptr %111, i32 0, i32 0
  %113 = load i32, ptr %112, align 4, !tbaa !20
  %114 = load i32, ptr %6, align 4, !tbaa !9
  %115 = icmp eq i32 %113, %114
  br i1 %115, label %116, label %145

116:                                              ; preds = %110
  %117 = load ptr, ptr %11, align 8, !tbaa !5
  %118 = getelementptr inbounds %struct._TCP_SEG, ptr %117, i32 0, i32 1
  %119 = load i32, ptr %118, align 4, !tbaa !18
  %120 = load ptr, ptr %11, align 8, !tbaa !5
  %121 = getelementptr inbounds %struct._TCP_SEG, ptr %120, i32 0, i32 0
  %122 = load i32, ptr %121, align 4, !tbaa !20
  %123 = load i32, ptr %7, align 4, !tbaa !9
  %124 = add i32 %122, %123
  %125 = sub i32 %119, %124
  %126 = icmp sle i32 %125, 0
  br i1 %126, label %127, label %145

127:                                              ; preds = %116
  %128 = load ptr, ptr %10, align 8, !tbaa !5
  %129 = getelementptr inbounds %struct.NET_BUF, ptr %128, i32 0, i32 1
  %130 = load i64, ptr %129, align 8, !tbaa !23
  %131 = icmp sgt i64 %130, 1
  br i1 %131, label %145, label %132

132:                                              ; preds = %127
  %133 = load ptr, ptr %10, align 8, !tbaa !5
  %134 = getelementptr inbounds %struct.NET_BUF, ptr %133, i32 0, i32 7
  %135 = load ptr, ptr %134, align 8, !tbaa !26
  %136 = getelementptr inbounds %struct.NET_VECTOR, ptr %135, i32 0, i32 1
  %137 = load i64, ptr %136, align 8, !tbaa !27
  %138 = icmp sgt i64 %137, 1
  br i1 %138, label %145, label %139

139:                                              ; preds = %132
  %140 = load ptr, ptr %10, align 8, !tbaa !5
  %141 = getelementptr inbounds %struct.NET_BUF, ptr %140, i32 0, i32 1
  %142 = load i64, ptr %141, align 8, !tbaa !23
  %143 = add nsw i64 %142, 1
  store i64 %143, ptr %141, align 8, !tbaa !23
  %144 = load ptr, ptr %10, align 8, !tbaa !5
  store ptr %144, ptr %4, align 8
  store i32 1, ptr %18, align 4
  br label %295

145:                                              ; preds = %132, %127, %116, %110
  %146 = load i32, ptr %7, align 4, !tbaa !9
  %147 = add i32 %146, 192
  %148 = call ptr @NetbufAlloc(i32 noundef %147)
  store ptr %148, ptr %12, align 8, !tbaa !5
  %149 = load ptr, ptr %12, align 8, !tbaa !5
  %150 = icmp eq ptr %149, null
  br i1 %150, label %151, label %152

151:                                              ; preds = %145
  store ptr null, ptr %4, align 8
  store i32 1, ptr %18, align 4
  br label %295

152:                                              ; preds = %145
  %153 = load ptr, ptr %12, align 8, !tbaa !5
  call void @NetbufReserve(ptr noundef %153, i32 noundef 192)
  %154 = load ptr, ptr %11, align 8, !tbaa !5
  %155 = getelementptr inbounds %struct._TCP_SEG, ptr %154, i32 0, i32 3
  %156 = load i8, ptr %155, align 4, !tbaa !29
  store i8 %156, ptr %15, align 1, !tbaa !30
  %157 = load ptr, ptr %11, align 8, !tbaa !5
  %158 = getelementptr inbounds %struct._TCP_SEG, ptr %157, i32 0, i32 1
  %159 = load i32, ptr %158, align 4, !tbaa !18
  store i32 %159, ptr %13, align 4, !tbaa !9
  %160 = load i32, ptr %6, align 4, !tbaa !9
  %161 = load i32, ptr %7, align 4, !tbaa !9
  %162 = add i32 %160, %161
  %163 = load ptr, ptr %11, align 8, !tbaa !5
  %164 = getelementptr inbounds %struct._TCP_SEG, ptr %163, i32 0, i32 1
  %165 = load i32, ptr %164, align 4, !tbaa !18
  %166 = sub i32 %162, %165
  %167 = icmp slt i32 %166, 0
  br i1 %167, label %168, label %172

168:                                              ; preds = %152
  %169 = load i32, ptr %6, align 4, !tbaa !9
  %170 = load i32, ptr %7, align 4, !tbaa !9
  %171 = add i32 %169, %170
  store i32 %171, ptr %13, align 4, !tbaa !9
  br label %172

172:                                              ; preds = %168, %152
  %173 = load i32, ptr %13, align 4, !tbaa !9
  %174 = load i32, ptr %6, align 4, !tbaa !9
  %175 = sub i32 %173, %174
  store i32 %175, ptr %17, align 4, !tbaa !9
  %176 = load i32, ptr %6, align 4, !tbaa !9
  %177 = load ptr, ptr %11, align 8, !tbaa !5
  %178 = getelementptr inbounds %struct._TCP_SEG, ptr %177, i32 0, i32 0
  %179 = load i32, ptr %178, align 4, !tbaa !20
  %180 = sub i32 %176, %179
  store i32 %180, ptr %16, align 4, !tbaa !9
  %181 = load ptr, ptr %11, align 8, !tbaa !5
  %182 = getelementptr inbounds %struct._TCP_SEG, ptr %181, i32 0, i32 3
  %183 = load i8, ptr %182, align 4, !tbaa !29
  %184 = zext i8 %183 to i32
  %185 = and i32 %184, 2
  %186 = icmp ne i32 %185, 0
  %187 = zext i1 %186 to i32
  %188 = trunc i32 %187 to i8
  %189 = icmp ne i8 %188, 0
  br i1 %189, label %190, label %208

190:                                              ; preds = %172
  %191 = load ptr, ptr %11, align 8, !tbaa !5
  %192 = getelementptr inbounds %struct._TCP_SEG, ptr %191, i32 0, i32 0
  %193 = load i32, ptr %192, align 4, !tbaa !20
  %194 = load i32, ptr %6, align 4, !tbaa !9
  %195 = sub i32 %193, %194
  %196 = icmp slt i32 %195, 0
  br i1 %196, label %197, label %204

197:                                              ; preds = %190
  %198 = load i8, ptr %15, align 1, !tbaa !30
  %199 = zext i8 %198 to i32
  %200 = and i32 %199, -3
  %201 = trunc i32 %200 to i8
  store i8 %201, ptr %15, align 1, !tbaa !30
  %202 = load i32, ptr %16, align 4, !tbaa !9
  %203 = add nsw i32 %202, -1
  store i32 %203, ptr %16, align 4, !tbaa !9
  br label %207

204:                                              ; preds = %190
  %205 = load i32, ptr %17, align 4, !tbaa !9
  %206 = add nsw i32 %205, -1
  store i32 %206, ptr %17, align 4, !tbaa !9
  br label %207

207:                                              ; preds = %204, %197
  br label %208

208:                                              ; preds = %207, %172
  %209 = load ptr, ptr %11, align 8, !tbaa !5
  %210 = getelementptr inbounds %struct._TCP_SEG, ptr %209, i32 0, i32 3
  %211 = load i8, ptr %210, align 4, !tbaa !29
  %212 = zext i8 %211 to i32
  %213 = and i32 %212, 1
  %214 = icmp ne i32 %213, 0
  %215 = zext i1 %214 to i32
  %216 = trunc i32 %215 to i8
  %217 = icmp ne i8 %216, 0
  br i1 %217, label %218, label %233

218:                                              ; preds = %208
  %219 = load ptr, ptr %11, align 8, !tbaa !5
  %220 = getelementptr inbounds %struct._TCP_SEG, ptr %219, i32 0, i32 1
  %221 = load i32, ptr %220, align 4, !tbaa !18
  %222 = load i32, ptr %13, align 4, !tbaa !9
  %223 = icmp eq i32 %221, %222
  br i1 %223, label %224, label %227

224:                                              ; preds = %218
  %225 = load i32, ptr %17, align 4, !tbaa !9
  %226 = add nsw i32 %225, -1
  store i32 %226, ptr %17, align 4, !tbaa !9
  br label %232

227:                                              ; preds = %218
  %228 = load i8, ptr %15, align 1, !tbaa !30
  %229 = zext i8 %228 to i32
  %230 = and i32 %229, -2
  %231 = trunc i32 %230 to i8
  store i8 %231, ptr %15, align 1, !tbaa !30
  br label %232

232:                                              ; preds = %227, %224
  br label %233

233:                                              ; preds = %232, %208
  br label %234

234:                                              ; preds = %233
  %235 = call zeroext i8 @DebugAssertEnabled()
  %236 = icmp ne i8 %235, 0
  br i1 %236, label %237, label %242

237:                                              ; preds = %234
  %238 = load i32, ptr %17, align 4, !tbaa !9
  %239 = icmp sge i32 %238, 0
  br i1 %239, label %241, label %240

240:                                              ; preds = %237
  call void @DebugAssert(ptr noundef @.str, i64 noundef 520, ptr noundef @.str.11)
  br label %241

241:                                              ; preds = %240, %237
  br label %242

242:                                              ; preds = %241, %234
  br label %243

243:                                              ; preds = %242
  br label %244

244:                                              ; preds = %243
  %245 = load i32, ptr %17, align 4, !tbaa !9
  %246 = icmp ne i32 %245, 0
  br i1 %246, label %247, label %271

247:                                              ; preds = %244
  %248 = load ptr, ptr %12, align 8, !tbaa !5
  %249 = load i32, ptr %17, align 4, !tbaa !9
  %250 = call ptr @NetbufAllocSpace(ptr noundef %248, i32 noundef %249, i8 noundef zeroext 0)
  store ptr %250, ptr %14, align 8, !tbaa !5
  br label %251

251:                                              ; preds = %247
  %252 = call zeroext i8 @DebugAssertEnabled()
  %253 = icmp ne i8 %252, 0
  br i1 %253, label %254, label %259

254:                                              ; preds = %251
  %255 = load ptr, ptr %14, align 8, !tbaa !5
  %256 = icmp ne ptr %255, null
  br i1 %256, label %258, label %257

257:                                              ; preds = %254
  call void @DebugAssert(ptr noundef @.str, i64 noundef 527, ptr noundef @.str.12)
  br label %258

258:                                              ; preds = %257, %254
  br label %259

259:                                              ; preds = %258, %251
  br label %260

260:                                              ; preds = %259
  br label %261

261:                                              ; preds = %260
  %262 = load ptr, ptr %10, align 8, !tbaa !5
  %263 = load i32, ptr %16, align 4, !tbaa !9
  %264 = load i32, ptr %17, align 4, !tbaa !9
  %265 = load ptr, ptr %14, align 8, !tbaa !5
  %266 = call i32 @NetbufCopy(ptr noundef %262, i32 noundef %263, i32 noundef %264, ptr noundef %265)
  %267 = load i32, ptr %17, align 4, !tbaa !9
  %268 = icmp ne i32 %266, %267
  br i1 %268, label %269, label %270

269:                                              ; preds = %261
  br label %293

270:                                              ; preds = %261
  br label %271

271:                                              ; preds = %270, %244
  %272 = load ptr, ptr %12, align 8, !tbaa !5
  %273 = getelementptr inbounds %struct.NET_BUF, ptr %272, i32 0, i32 6
  %274 = getelementptr inbounds [64 x i8], ptr %273, i64 0, i64 0
  %275 = load ptr, ptr %11, align 8, !tbaa !5
  %276 = call ptr @CopyMem(ptr noundef %274, ptr noundef %275, i64 noundef 20)
  %277 = load i32, ptr %6, align 4, !tbaa !9
  %278 = load ptr, ptr %12, align 8, !tbaa !5
  %279 = getelementptr inbounds %struct.NET_BUF, ptr %278, i32 0, i32 6
  %280 = getelementptr inbounds [64 x i8], ptr %279, i64 0, i64 0
  %281 = getelementptr inbounds %struct._TCP_SEG, ptr %280, i32 0, i32 0
  store i32 %277, ptr %281, align 8, !tbaa !20
  %282 = load i32, ptr %13, align 4, !tbaa !9
  %283 = load ptr, ptr %12, align 8, !tbaa !5
  %284 = getelementptr inbounds %struct.NET_BUF, ptr %283, i32 0, i32 6
  %285 = getelementptr inbounds [64 x i8], ptr %284, i64 0, i64 0
  %286 = getelementptr inbounds %struct._TCP_SEG, ptr %285, i32 0, i32 1
  store i32 %282, ptr %286, align 4, !tbaa !18
  %287 = load i8, ptr %15, align 1, !tbaa !30
  %288 = load ptr, ptr %12, align 8, !tbaa !5
  %289 = getelementptr inbounds %struct.NET_BUF, ptr %288, i32 0, i32 6
  %290 = getelementptr inbounds [64 x i8], ptr %289, i64 0, i64 0
  %291 = getelementptr inbounds %struct._TCP_SEG, ptr %290, i32 0, i32 3
  store i8 %287, ptr %291, align 4, !tbaa !29
  %292 = load ptr, ptr %12, align 8, !tbaa !5
  store ptr %292, ptr %4, align 8
  store i32 1, ptr %18, align 4
  br label %295

293:                                              ; preds = %269
  %294 = load ptr, ptr %12, align 8, !tbaa !5
  call void @NetbufFree(ptr noundef %294)
  store ptr null, ptr %4, align 8
  store i32 1, ptr %18, align 4
  br label %295

295:                                              ; preds = %293, %271, %151, %139
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #3
  call void @llvm.lifetime.end.p0(i64 1, ptr %15) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #3
  %296 = load ptr, ptr %4, align 8
  ret ptr %296
}

declare ptr @NetbufAlloc(i32 noundef) #1

declare void @NetbufReserve(ptr noundef, i32 noundef) #1

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

declare ptr @CopyMem(ptr noundef, ptr noundef, i64 noundef) #1

declare void @NetbufFree(ptr 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 = { nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { 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 = !{!12, !10, i64 100}
!12 = !{!"_TCP_CB", !13, i64 0, !6, i64 16, !6, i64 24, !14, i64 32, !14, i64 40, !13, i64 48, !13, i64 64, !10, i64 80, !10, i64 84, !7, i64 88, !7, i64 89, !15, i64 90, !10, i64 92, !10, i64 96, !10, i64 100, !10, i64 104, !10, i64 108, !10, i64 112, !10, i64 116, !10, i64 120, !10, i64 124, !15, i64 128, !10, i64 132, !10, i64 136, !10, i64 140, !10, i64 144, !10, i64 148, !15, i64 152, !15, i64 154, !7, i64 156, !10, i64 180, !10, i64 184, !10, i64 188, !7, i64 192, !7, i64 193, !7, i64 194, !10, i64 196, !10, i64 200, !10, i64 204, !10, i64 208, !10, i64 212, !10, i64 216, !10, i64 220, !10, i64 224, !10, i64 228, !10, i64 232, !15, i64 236, !7, i64 238, !7, i64 239, !10, i64 240, !10, i64 244, !10, i64 248, !7, i64 252, !7, i64 253, !15, i64 254, !10, i64 256, !10, i64 260, !10, i64 264, !7, i64 268, !7, i64 269, !7, i64 270, !16, i64 271, !6, i64 280}
!13 = !{!"_LIST_ENTRY", !6, i64 0, !6, i64 8}
!14 = !{!"_TCP_PEER", !10, i64 0, !15, i64 4}
!15 = !{!"short", !7, i64 0}
!16 = !{!"", !7, i64 0}
!17 = !{!13, !6, i64 0}
!18 = !{!19, !10, i64 4}
!19 = !{!"_TCP_SEG", !10, i64 0, !10, i64 4, !10, i64 8, !7, i64 12, !15, i64 14, !10, i64 16}
!20 = !{!19, !10, i64 0}
!21 = distinct !{!21, !22}
!22 = !{!"llvm.loop.mustprogress"}
!23 = !{!24, !25, i64 8}
!24 = !{!"", !10, i64 0, !25, i64 8, !13, i64 16, !7, i64 32, !6, i64 40, !6, i64 48, !7, i64 56, !6, i64 120, !10, i64 128, !10, i64 132, !7, i64 136}
!25 = !{!"long long", !7, i64 0}
!26 = !{!24, !6, i64 120}
!27 = !{!28, !25, i64 8}
!28 = !{!"", !10, i64 0, !25, i64 8, !6, i64 16, !6, i64 24, !10, i64 32, !10, i64 36, !10, i64 40, !7, i64 48}
!29 = !{!19, !7, i64 12}
!30 = !{!7, !7, i64 0}


; 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"

@.str = external hidden unnamed_addr constant [153 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [77 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [12 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [21 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [20 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [13 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [21 x i8], align 1

declare zeroext i8 @DebugAssertEnabled() local_unnamed_addr #0

declare void @DebugAssert(ptr noundef, i64 noundef, ptr noundef) local_unnamed_addr #0

declare ptr @NetbufAllocSpace(ptr noundef, i32 noundef, i8 noundef zeroext) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local ptr @TcpGetSegmentSndQue(ptr noundef readonly %0, i32 noundef %1, i32 noundef %2) local_unnamed_addr #1 {
  %4 = tail call zeroext i8 @DebugAssertEnabled() #2
  %.not = icmp eq i8 %4, 0
  br i1 %.not, label %13, label %5

5:                                                ; preds = %3
  %.not96 = icmp eq ptr %0, null
  br i1 %.not96, label %12, label %6

6:                                                ; preds = %5
  %7 = getelementptr inbounds i8, ptr %0, i64 100
  %8 = load i32, ptr %7, align 4, !tbaa !5
  %9 = sub i32 %1, %8
  %10 = icmp slt i32 %9, 1
  %11 = icmp ne i32 %2, 0
  %or.cond = and i1 %11, %10
  br i1 %or.cond, label %13, label %12

12:                                               ; preds = %6, %5
  tail call void @DebugAssert(ptr noundef nonnull @.str, i64 noundef 430, ptr noundef nonnull @.str.7) #2
  br label %13

13:                                               ; preds = %12, %6, %3
  %14 = getelementptr inbounds i8, ptr %0, i64 48
  %.087106 = load ptr, ptr %14, align 8, !tbaa !15
  %.not97107.not = icmp eq ptr %.087106, %14
  br i1 %.not97107.not, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %13, %28
  %.087108 = phi ptr [ %.087, %28 ], [ %.087106, %13 ]
  %15 = ptrtoint ptr %.087108 to i64
  %16 = add i64 %15, -16
  %17 = inttoptr i64 %16 to ptr
  %18 = getelementptr inbounds i8, ptr %17, i64 56
  %19 = getelementptr inbounds i8, ptr %17, i64 60
  %20 = load i32, ptr %19, align 4, !tbaa !16
  %21 = sub i32 %1, %20
  %22 = icmp slt i32 %21, 0
  br i1 %22, label %23, label %28

23:                                               ; preds = %.lr.ph
  %24 = load i32, ptr %18, align 4, !tbaa !18
  %25 = sub i32 %24, %1
  %26 = icmp slt i32 %25, 1
  br i1 %26, label %._crit_edge.thread, label %28

._crit_edge.thread:                               ; preds = %23
  %27 = tail call zeroext i8 @DebugAssertEnabled() #2
  br label %31

28:                                               ; preds = %.lr.ph, %23
  %.087 = load ptr, ptr %.087108, align 8, !tbaa !15
  %.not97.not = icmp eq ptr %.087, %14
  br i1 %.not97.not, label %._crit_edge, label %.lr.ph, !llvm.loop !19

._crit_edge:                                      ; preds = %28, %13
  %.191 = phi ptr [ null, %13 ], [ %17, %28 ]
  %.189 = phi ptr [ null, %13 ], [ %18, %28 ]
  %29 = tail call zeroext i8 @DebugAssertEnabled() #2
  %.not98 = icmp eq i8 %29, 0
  br i1 %.not98, label %31, label %30

30:                                               ; preds = %._crit_edge
  tail call void @DebugAssert(ptr noundef nonnull @.str, i64 noundef 450, ptr noundef nonnull @.str.8) #2
  br label %31

31:                                               ; preds = %._crit_edge.thread, %._crit_edge, %30
  %.189123 = phi ptr [ %18, %._crit_edge.thread ], [ %.189, %._crit_edge ], [ %.189, %30 ]
  %.191122 = phi ptr [ %17, %._crit_edge.thread ], [ %.191, %._crit_edge ], [ %.191, %30 ]
  %32 = tail call zeroext i8 @DebugAssertEnabled() #2
  %33 = icmp eq i8 %32, 0
  %34 = icmp ne ptr %.191122, null
  %or.cond3 = or i1 %34, %33
  br i1 %or.cond3, label %36, label %35

35:                                               ; preds = %31
  tail call void @DebugAssert(ptr noundef nonnull @.str, i64 noundef 451, ptr noundef nonnull @.str.9) #2
  br label %36

36:                                               ; preds = %31, %35
  %37 = tail call zeroext i8 @DebugAssertEnabled() #2
  %38 = icmp eq i8 %37, 0
  %39 = icmp ne ptr %.189123, null
  %or.cond5 = select i1 %38, i1 true, i1 %39
  br i1 %or.cond5, label %41, label %40

40:                                               ; preds = %36
  tail call void @DebugAssert(ptr noundef nonnull @.str, i64 noundef 452, ptr noundef nonnull @.str.10) #2
  br label %41

41:                                               ; preds = %40, %36
  %42 = load i32, ptr %.189123, align 4, !tbaa !18
  %43 = icmp eq i32 %42, %1
  br i1 %43, label %44, label %62

44:                                               ; preds = %41
  %45 = getelementptr inbounds i8, ptr %.189123, i64 4
  %46 = load i32, ptr %45, align 4, !tbaa !16
  %47 = add i32 %1, %2
  %48 = sub i32 %46, %47
  %49 = icmp slt i32 %48, 1
  br i1 %49, label %50, label %62

50:                                               ; preds = %44
  %51 = getelementptr inbounds i8, ptr %.191122, i64 8
  %52 = load i64, ptr %51, align 8, !tbaa !21
  %53 = icmp sgt i64 %52, 1
  br i1 %53, label %62, label %54

54:                                               ; preds = %50
  %55 = getelementptr inbounds i8, ptr %.191122, i64 120
  %56 = load ptr, ptr %55, align 8, !tbaa !24
  %57 = getelementptr inbounds i8, ptr %56, i64 8
  %58 = load i64, ptr %57, align 8, !tbaa !25
  %59 = icmp sgt i64 %58, 1
  br i1 %59, label %62, label %60

60:                                               ; preds = %54
  %61 = add nsw i64 %52, 1
  store i64 %61, ptr %51, align 8, !tbaa !21
  br label %113

62:                                               ; preds = %54, %50, %44, %41
  %63 = add i32 %2, 192
  %64 = tail call ptr @NetbufAlloc(i32 noundef %63) #2
  %65 = icmp eq ptr %64, null
  br i1 %65, label %113, label %66

66:                                               ; preds = %62
  tail call void @NetbufReserve(ptr noundef nonnull %64, i32 noundef 192) #2
  %67 = getelementptr inbounds i8, ptr %.189123, i64 12
  %68 = load i8, ptr %67, align 4, !tbaa !27
  %69 = getelementptr inbounds i8, ptr %.189123, i64 4
  %70 = load i32, ptr %69, align 4, !tbaa !16
  %71 = add i32 %2, %1
  %72 = sub i32 %71, %70
  %73 = icmp slt i32 %72, 0
  %spec.select = select i1 %73, i32 %71, i32 %70
  %74 = sub i32 %spec.select, %1
  %75 = load i32, ptr %.189123, align 4, !tbaa !18
  %76 = sub i32 %1, %75
  %77 = and i8 %68, 2
  %.not99 = icmp eq i8 %77, 0
  br i1 %.not99, label %86, label %78

78:                                               ; preds = %66
  %79 = sub i32 %75, %1
  %80 = icmp slt i32 %79, 0
  br i1 %80, label %81, label %84

81:                                               ; preds = %78
  %82 = and i8 %68, -3
  %83 = add nsw i32 %76, -1
  br label %86

84:                                               ; preds = %78
  %85 = add nsw i32 %74, -1
  br label %86

86:                                               ; preds = %81, %84, %66
  %.083 = phi i8 [ %82, %81 ], [ %68, %84 ], [ %68, %66 ]
  %.082 = phi i32 [ %83, %81 ], [ %76, %84 ], [ %76, %66 ]
  %.0 = phi i32 [ %74, %81 ], [ %85, %84 ], [ %74, %66 ]
  %87 = and i8 %68, 1
  %.not100 = icmp eq i8 %87, 0
  br i1 %.not100, label %94, label %88

88:                                               ; preds = %86
  %89 = icmp eq i32 %70, %spec.select
  br i1 %89, label %90, label %92

90:                                               ; preds = %88
  %91 = add nsw i32 %.0, -1
  br label %94

92:                                               ; preds = %88
  %93 = and i8 %.083, -2
  br label %94

94:                                               ; preds = %86, %92, %90
  %.184 = phi i8 [ %.083, %90 ], [ %93, %92 ], [ %.083, %86 ]
  %.1 = phi i32 [ %91, %90 ], [ %.0, %92 ], [ %.0, %86 ]
  %95 = tail call zeroext i8 @DebugAssertEnabled() #2
  %96 = icmp eq i8 %95, 0
  %97 = icmp sgt i32 %.1, -1
  %or.cond7 = select i1 %96, i1 true, i1 %97
  br i1 %or.cond7, label %98, label %.thread

.thread:                                          ; preds = %94
  tail call void @DebugAssert(ptr noundef nonnull @.str, i64 noundef 520, ptr noundef nonnull @.str.11) #2
  br label %99

98:                                               ; preds = %94
  %.not101 = icmp eq i32 %.1, 0
  br i1 %.not101, label %107, label %99

99:                                               ; preds = %.thread, %98
  %100 = tail call ptr @NetbufAllocSpace(ptr noundef nonnull %64, i32 noundef %.1, i8 noundef zeroext 0) #2
  %101 = tail call zeroext i8 @DebugAssertEnabled() #2
  %102 = icmp eq i8 %101, 0
  %103 = icmp ne ptr %100, null
  %or.cond9 = select i1 %102, i1 true, i1 %103
  br i1 %or.cond9, label %105, label %104

104:                                              ; preds = %99
  tail call void @DebugAssert(ptr noundef nonnull @.str, i64 noundef 527, ptr noundef nonnull @.str.12) #2
  br label %105

105:                                              ; preds = %104, %99
  %106 = tail call i32 @NetbufCopy(ptr noundef %.191122, i32 noundef %.082, i32 noundef %.1, ptr noundef %100) #2
  %.not102 = icmp eq i32 %106, %.1
  br i1 %.not102, label %107, label %112

107:                                              ; preds = %105, %98
  %108 = getelementptr inbounds i8, ptr %64, i64 56
  %109 = tail call ptr @CopyMem(ptr noundef nonnull %108, ptr noundef nonnull %.189123, i64 noundef 20) #2
  store i32 %1, ptr %108, align 8, !tbaa !18
  %110 = getelementptr inbounds i8, ptr %64, i64 60
  store i32 %spec.select, ptr %110, align 4, !tbaa !16
  %111 = getelementptr inbounds i8, ptr %64, i64 68
  store i8 %.184, ptr %111, align 4, !tbaa !27
  br label %113

112:                                              ; preds = %105
  tail call void @NetbufFree(ptr noundef nonnull %64) #2
  br label %113

113:                                              ; preds = %62, %112, %107, %60
  %.085 = phi ptr [ null, %112 ], [ %64, %107 ], [ %.191122, %60 ], [ null, %62 ]
  ret ptr %.085
}

declare ptr @NetbufAlloc(i32 noundef) local_unnamed_addr #0

declare void @NetbufReserve(ptr noundef, i32 noundef) local_unnamed_addr #0

declare i32 @NetbufCopy(ptr noundef, i32 noundef, i32 noundef, ptr noundef) local_unnamed_addr #0

declare ptr @CopyMem(ptr noundef, ptr noundef, i64 noundef) local_unnamed_addr #0

declare void @NetbufFree(ptr noundef) local_unnamed_addr #0

attributes #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 = { 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 #2 = { 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, !12, i64 100}
!6 = !{!"_TCP_CB", !7, i64 0, !8, i64 16, !8, i64 24, !11, i64 32, !11, i64 40, !7, i64 48, !7, i64 64, !12, i64 80, !12, i64 84, !9, i64 88, !9, i64 89, !13, i64 90, !12, i64 92, !12, i64 96, !12, i64 100, !12, i64 104, !12, i64 108, !12, i64 112, !12, i64 116, !12, i64 120, !12, i64 124, !13, i64 128, !12, i64 132, !12, i64 136, !12, i64 140, !12, i64 144, !12, i64 148, !13, i64 152, !13, i64 154, !9, i64 156, !12, i64 180, !12, i64 184, !12, i64 188, !9, i64 192, !9, i64 193, !9, i64 194, !12, i64 196, !12, i64 200, !12, i64 204, !12, i64 208, !12, i64 212, !12, i64 216, !12, i64 220, !12, i64 224, !12, i64 228, !12, i64 232, !13, i64 236, !9, i64 238, !9, i64 239, !12, i64 240, !12, i64 244, !12, i64 248, !9, i64 252, !9, i64 253, !13, i64 254, !12, i64 256, !12, i64 260, !12, i64 264, !9, i64 268, !9, i64 269, !9, i64 270, !14, i64 271, !8, i64 280}
!7 = !{!"_LIST_ENTRY", !8, i64 0, !8, i64 8}
!8 = !{!"any pointer", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C/C++ TBAA"}
!11 = !{!"_TCP_PEER", !12, i64 0, !13, i64 4}
!12 = !{!"int", !9, i64 0}
!13 = !{!"short", !9, i64 0}
!14 = !{!"", !9, i64 0}
!15 = !{!7, !8, i64 0}
!16 = !{!17, !12, i64 4}
!17 = !{!"_TCP_SEG", !12, i64 0, !12, i64 4, !12, i64 8, !9, i64 12, !13, i64 14, !12, i64 16}
!18 = !{!17, !12, i64 0}
!19 = distinct !{!19, !20}
!20 = !{!"llvm.loop.mustprogress"}
!21 = !{!22, !23, i64 8}
!22 = !{!"", !12, i64 0, !23, i64 8, !7, i64 16, !9, i64 32, !8, i64 40, !8, i64 48, !9, i64 56, !8, i64 120, !12, i64 128, !12, i64 132, !9, i64 136}
!23 = !{!"long long", !9, i64 0}
!24 = !{!22, !8, i64 120}
!25 = !{!26, !23, i64 8}
!26 = !{!"", !12, i64 0, !23, i64 8, !8, i64 16, !8, i64 24, !12, i64 32, !12, i64 36, !12, i64 40, !9, i64 48}
!27 = !{!17, !9, i64 12}


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