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

; 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.NET_FRAGMENT = type { i32, ptr }
%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] }
%struct._LIST_ENTRY = type { ptr, ptr }
%union.NET_IP_HEAD = type { ptr }
%struct.NET_BLOCK_OP = type { ptr, ptr, ptr, ptr, i32 }
%struct._ISCSI_CONNECTION = type { i32, %struct._LIST_ENTRY, ptr, ptr, i8, i8, i8, i8, i8, i8, i8, i16, i32, %struct.NET_BUF_QUEUE, %struct._TCP4_IO, i32, i32, i32 }
%struct.NET_BUF_QUEUE = type { i32, i64, %struct._LIST_ENTRY, %struct._LIST_ENTRY, i32, i32 }
%struct._TCP4_IO = type { ptr, ptr, ptr, ptr, %struct.EFI_TCP4_CONNECTION_TOKEN, %struct.EFI_TCP4_IO_TOKEN, %struct.EFI_TCP4_IO_TOKEN, %struct.EFI_TCP4_CLOSE_TOKEN, i8, i8, i8, i8 }
%struct.EFI_TCP4_CONNECTION_TOKEN = type { %struct.EFI_TCP4_COMPLETION_TOKEN }
%struct.EFI_TCP4_COMPLETION_TOKEN = type { ptr, i64 }
%struct.EFI_TCP4_IO_TOKEN = type { %struct.EFI_TCP4_COMPLETION_TOKEN, %union.anon }
%union.anon = type { ptr }
%struct.EFI_TCP4_CLOSE_TOKEN = type { %struct.EFI_TCP4_COMPLETION_TOKEN, i8 }
%struct._ISCSI_BASIC_HEADER = type { i8, i8, i16, i8, [3 x i8], [8 x i8], i32, [7 x i32] }
%struct._ISCSI_SCSI_DATA_IN = type { i8, i8, i8, i8, i8, [3 x i8], [8 x i8], i32, i32, i32, i32, i32, i32, i32, i32 }
%struct._ISCSI_IN_BUFFER_CONTEXT = type { ptr, i32 }

@.str = external hidden unnamed_addr constant [154 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [23 x i8], align 1

declare ptr @InsertTailList(ptr noundef, ptr noundef) #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

declare ptr @AllocatePool(i64 noundef) #0

declare void @FreePool(ptr noundef) #0

; Function Attrs: nounwind uwtable
define dso_local i64 @IScsiReceivePdu(ptr noundef %0, ptr noundef %1, ptr noundef %2, i8 noundef zeroext %3, i8 noundef zeroext %4, ptr noundef %5) #2 {
  %7 = alloca i64, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca i8, align 1
  %12 = alloca i8, align 1
  %13 = alloca ptr, align 8
  %14 = alloca ptr, align 8
  %15 = alloca i32, align 4
  %16 = alloca ptr, align 8
  %17 = alloca ptr, align 8
  %18 = alloca i64, align 8
  %19 = alloca i32, align 4
  %20 = alloca i32, align 4
  %21 = alloca [2 x %struct.NET_FRAGMENT], align 16
  %22 = alloca i32, align 4
  %23 = alloca ptr, align 8
  %24 = alloca [2 x i32], align 4
  %25 = alloca i32, align 4
  store ptr %0, ptr %8, align 8, !tbaa !5
  store ptr %1, ptr %9, align 8, !tbaa !5
  store ptr %2, ptr %10, align 8, !tbaa !5
  store i8 %3, ptr %11, align 1, !tbaa !9
  store i8 %4, ptr %12, align 1, !tbaa !9
  store ptr %5, ptr %13, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %18) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %19) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %20) #3
  call void @llvm.lifetime.start.p0(i64 32, ptr %21) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %22) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %23) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %24) #3
  %26 = call ptr @AllocatePool(i64 noundef 16)
  store ptr %26, ptr %14, align 8, !tbaa !5
  %27 = load ptr, ptr %14, align 8, !tbaa !5
  %28 = icmp eq ptr %27, null
  br i1 %28, label %29, label %30

29:                                               ; preds = %6
  store i64 -9223372036854775799, ptr %7, align 8
  store i32 1, ptr %25, align 4
  br label %250

30:                                               ; preds = %6
  %31 = load ptr, ptr %14, align 8, !tbaa !5
  %32 = call ptr @InitializeListHead(ptr noundef %31)
  %33 = load i8, ptr %11, align 1, !tbaa !9
  %34 = zext i8 %33 to i32
  %35 = icmp ne i32 %34, 0
  %36 = zext i1 %35 to i64
  %37 = select i1 %35, i64 4, i64 0
  %38 = add i64 48, %37
  %39 = trunc i64 %38 to i32
  store i32 %39, ptr %15, align 4, !tbaa !10
  %40 = load i32, ptr %15, align 4, !tbaa !10
  %41 = call ptr @NetbufAlloc(i32 noundef %40)
  store ptr %41, ptr %16, align 8, !tbaa !5
  %42 = load ptr, ptr %16, align 8, !tbaa !5
  %43 = icmp eq ptr %42, null
  br i1 %43, label %44, label %46

44:                                               ; preds = %30
  %45 = load ptr, ptr %14, align 8, !tbaa !5
  call void @FreePool(ptr noundef %45)
  store i64 -9223372036854775799, ptr %7, align 8
  store i32 1, ptr %25, align 4
  br label %250

46:                                               ; preds = %30
  %47 = load ptr, ptr %16, align 8, !tbaa !5
  %48 = load i32, ptr %15, align 4, !tbaa !10
  %49 = call ptr @NetbufAllocSpace(ptr noundef %47, i32 noundef %48, i8 noundef zeroext 0)
  store ptr %49, ptr %17, align 8, !tbaa !5
  br label %50

50:                                               ; preds = %46
  %51 = call zeroext i8 @DebugAssertEnabled()
  %52 = icmp ne i8 %51, 0
  br i1 %52, label %53, label %58

53:                                               ; preds = %50
  %54 = load ptr, ptr %17, align 8, !tbaa !5
  %55 = icmp ne ptr %54, null
  br i1 %55, label %57, label %56

56:                                               ; preds = %53
  call void @DebugAssert(ptr noundef @.str, i64 noundef 988, ptr noundef @.str.5)
  br label %57

57:                                               ; preds = %56, %53
  br label %58

58:                                               ; preds = %57, %50
  br label %59

59:                                               ; preds = %58
  br label %60

60:                                               ; preds = %59
  %61 = load ptr, ptr %14, align 8, !tbaa !5
  %62 = load ptr, ptr %16, align 8, !tbaa !5
  %63 = getelementptr inbounds %struct.NET_BUF, ptr %62, i32 0, i32 2
  %64 = call ptr @InsertTailList(ptr noundef %61, ptr noundef %63)
  %65 = load ptr, ptr %8, align 8, !tbaa !5
  %66 = getelementptr inbounds %struct._ISCSI_CONNECTION, ptr %65, i32 0, i32 14
  %67 = load ptr, ptr %16, align 8, !tbaa !5
  %68 = load ptr, ptr %13, align 8, !tbaa !5
  %69 = call i64 @Tcp4IoReceive(ptr noundef %66, ptr noundef %67, i8 noundef zeroext 0, ptr noundef %68)
  store i64 %69, ptr %18, align 8, !tbaa !12
  %70 = load i64, ptr %18, align 8, !tbaa !12
  %71 = icmp slt i64 %70, 0
  br i1 %71, label %72, label %73

72:                                               ; preds = %60
  br label %243

73:                                               ; preds = %60
  %74 = load i8, ptr %11, align 1, !tbaa !9
  %75 = icmp ne i8 %74, 0
  br i1 %75, label %76, label %79

76:                                               ; preds = %73
  %77 = load ptr, ptr %16, align 8, !tbaa !5
  %78 = call i32 @NetbufTrim(ptr noundef %77, i32 noundef 4, i8 noundef zeroext 0)
  br label %79

79:                                               ; preds = %76, %73
  %80 = load ptr, ptr %17, align 8, !tbaa !5
  %81 = getelementptr inbounds %struct._ISCSI_BASIC_HEADER, ptr %80, i32 0, i32 4
  %82 = getelementptr inbounds [3 x i8], ptr %81, i64 0, i64 0
  %83 = load i8, ptr %82, align 1, !tbaa !9
  %84 = zext i8 %83 to i32
  %85 = shl i32 %84, 16
  %86 = load ptr, ptr %17, align 8, !tbaa !5
  %87 = getelementptr inbounds %struct._ISCSI_BASIC_HEADER, ptr %86, i32 0, i32 4
  %88 = getelementptr inbounds [3 x i8], ptr %87, i64 0, i64 1
  %89 = load i8, ptr %88, align 1, !tbaa !9
  %90 = zext i8 %89 to i32
  %91 = shl i32 %90, 8
  %92 = or i32 %85, %91
  %93 = load ptr, ptr %17, align 8, !tbaa !5
  %94 = getelementptr inbounds %struct._ISCSI_BASIC_HEADER, ptr %93, i32 0, i32 4
  %95 = getelementptr inbounds [3 x i8], ptr %94, i64 0, i64 2
  %96 = load i8, ptr %95, align 1, !tbaa !9
  %97 = zext i8 %96 to i32
  %98 = or i32 %92, %97
  store i32 %98, ptr %15, align 4, !tbaa !10
  %99 = load i32, ptr %15, align 4, !tbaa !10
  %100 = icmp eq i32 %99, 0
  br i1 %100, label %101, label %112

101:                                              ; preds = %79
  %102 = load ptr, ptr %14, align 8, !tbaa !5
  %103 = load ptr, ptr %14, align 8, !tbaa !5
  %104 = call ptr @NetbufFromBufList(ptr noundef %102, i32 noundef 0, i32 noundef 0, ptr noundef @IScsiFreeNbufList, ptr noundef %103)
  %105 = load ptr, ptr %9, align 8, !tbaa !5
  store ptr %104, ptr %105, align 8, !tbaa !5
  %106 = load ptr, ptr %9, align 8, !tbaa !5
  %107 = load ptr, ptr %106, align 8, !tbaa !5
  %108 = icmp eq ptr %107, null
  br i1 %108, label %109, label %110

109:                                              ; preds = %101
  store i64 -9223372036854775799, ptr %18, align 8, !tbaa !12
  br label %243

110:                                              ; preds = %101
  %111 = load i64, ptr %18, align 8, !tbaa !12
  store i64 %111, ptr %7, align 8
  store i32 1, ptr %25, align 4
  br label %250

112:                                              ; preds = %79
  %113 = load i32, ptr %15, align 4, !tbaa !10
  %114 = xor i32 %113, -1
  %115 = add i32 %114, 1
  %116 = and i32 %115, 3
  store i32 %116, ptr %19, align 4, !tbaa !10
  %117 = load ptr, ptr %17, align 8, !tbaa !5
  %118 = getelementptr inbounds %struct._ISCSI_BASIC_HEADER, ptr %117, i32 0, i32 0
  %119 = load i8, ptr %118, align 4, !tbaa !14
  %120 = zext i8 %119 to i32
  %121 = and i32 %120, 63
  switch i32 %121, label %206 [
    i32 37, label %122
    i32 33, label %184
    i32 32, label %184
    i32 35, label %184
    i32 36, label %184
    i32 50, label %184
    i32 63, label %184
    i32 60, label %184
    i32 61, label %184
    i32 62, label %184
  ]

122:                                              ; preds = %112
  %123 = load ptr, ptr %17, align 8, !tbaa !5
  %124 = getelementptr inbounds %struct._ISCSI_SCSI_DATA_IN, ptr %123, i32 0, i32 13
  %125 = load i32, ptr %124, align 4, !tbaa !17
  %126 = call i32 @SwapBytes32(i32 noundef %125)
  store i32 %126, ptr %20, align 4, !tbaa !10
  %127 = load ptr, ptr %10, align 8, !tbaa !5
  %128 = icmp eq ptr %127, null
  br i1 %128, label %137, label %129

129:                                              ; preds = %122
  %130 = load i32, ptr %20, align 4, !tbaa !10
  %131 = load i32, ptr %15, align 4, !tbaa !10
  %132 = add i32 %130, %131
  %133 = load ptr, ptr %10, align 8, !tbaa !5
  %134 = getelementptr inbounds %struct._ISCSI_IN_BUFFER_CONTEXT, ptr %133, i32 0, i32 1
  %135 = load i32, ptr %134, align 8, !tbaa !19
  %136 = icmp ugt i32 %132, %135
  br i1 %136, label %137, label %138

137:                                              ; preds = %129, %122
  store i64 -9223372036854775784, ptr %18, align 8, !tbaa !12
  br label %243

138:                                              ; preds = %129
  %139 = load i32, ptr %15, align 4, !tbaa !10
  %140 = getelementptr inbounds [2 x %struct.NET_FRAGMENT], ptr %21, i64 0, i64 0
  %141 = getelementptr inbounds %struct.NET_FRAGMENT, ptr %140, i32 0, i32 0
  store i32 %139, ptr %141, align 16, !tbaa !21
  %142 = load ptr, ptr %10, align 8, !tbaa !5
  %143 = getelementptr inbounds %struct._ISCSI_IN_BUFFER_CONTEXT, ptr %142, i32 0, i32 0
  %144 = load ptr, ptr %143, align 8, !tbaa !23
  %145 = load i32, ptr %20, align 4, !tbaa !10
  %146 = zext i32 %145 to i64
  %147 = getelementptr inbounds i8, ptr %144, i64 %146
  %148 = getelementptr inbounds [2 x %struct.NET_FRAGMENT], ptr %21, i64 0, i64 0
  %149 = getelementptr inbounds %struct.NET_FRAGMENT, ptr %148, i32 0, i32 1
  store ptr %147, ptr %149, align 8, !tbaa !24
  %150 = load i8, ptr %12, align 1, !tbaa !9
  %151 = zext i8 %150 to i32
  %152 = icmp ne i32 %151, 0
  br i1 %152, label %156, label %153

153:                                              ; preds = %138
  %154 = load i32, ptr %19, align 4, !tbaa !10
  %155 = icmp ne i32 %154, 0
  br i1 %155, label %156, label %175

156:                                              ; preds = %153, %138
  %157 = load i32, ptr %19, align 4, !tbaa !10
  %158 = zext i32 %157 to i64
  %159 = load i8, ptr %12, align 1, !tbaa !9
  %160 = zext i8 %159 to i32
  %161 = icmp ne i32 %160, 0
  %162 = zext i1 %161 to i64
  %163 = select i1 %161, i64 4, i64 0
  %164 = add i64 %158, %163
  %165 = trunc i64 %164 to i32
  %166 = getelementptr inbounds [2 x %struct.NET_FRAGMENT], ptr %21, i64 0, i64 1
  %167 = getelementptr inbounds %struct.NET_FRAGMENT, ptr %166, i32 0, i32 0
  store i32 %165, ptr %167, align 16, !tbaa !21
  %168 = getelementptr inbounds [2 x i32], ptr %24, i64 0, i64 0
  %169 = load i32, ptr %19, align 4, !tbaa !10
  %170 = sub i32 4, %169
  %171 = zext i32 %170 to i64
  %172 = getelementptr inbounds i8, ptr %168, i64 %171
  %173 = getelementptr inbounds [2 x %struct.NET_FRAGMENT], ptr %21, i64 0, i64 1
  %174 = getelementptr inbounds %struct.NET_FRAGMENT, ptr %173, i32 0, i32 1
  store ptr %172, ptr %174, align 8, !tbaa !24
  store i32 2, ptr %22, align 4, !tbaa !10
  br label %176

175:                                              ; preds = %153
  store i32 1, ptr %22, align 4, !tbaa !10
  br label %176

176:                                              ; preds = %175, %156
  %177 = getelementptr inbounds [2 x %struct.NET_FRAGMENT], ptr %21, i64 0, i64 0
  %178 = load i32, ptr %22, align 4, !tbaa !10
  %179 = call ptr @NetbufFromExt(ptr noundef %177, i32 noundef %178, i32 noundef 0, i32 noundef 0, ptr noundef @IScsiNbufExtFree, ptr noundef null)
  store ptr %179, ptr %23, align 8, !tbaa !5
  %180 = load ptr, ptr %23, align 8, !tbaa !5
  %181 = icmp eq ptr %180, null
  br i1 %181, label %182, label %183

182:                                              ; preds = %176
  store i64 -9223372036854775799, ptr %18, align 8, !tbaa !12
  br label %243

183:                                              ; preds = %176
  br label %207

184:                                              ; preds = %112, %112, %112, %112, %112, %112, %112, %112, %112
  %185 = load i32, ptr %19, align 4, !tbaa !10
  %186 = zext i32 %185 to i64
  %187 = load i8, ptr %12, align 1, !tbaa !9
  %188 = zext i8 %187 to i32
  %189 = icmp ne i32 %188, 0
  %190 = zext i1 %189 to i64
  %191 = select i1 %189, i64 4, i64 0
  %192 = add i64 %186, %191
  %193 = load i32, ptr %15, align 4, !tbaa !10
  %194 = zext i32 %193 to i64
  %195 = add i64 %194, %192
  %196 = trunc i64 %195 to i32
  store i32 %196, ptr %15, align 4, !tbaa !10
  %197 = load i32, ptr %15, align 4, !tbaa !10
  %198 = call ptr @NetbufAlloc(i32 noundef %197)
  store ptr %198, ptr %23, align 8, !tbaa !5
  %199 = load ptr, ptr %23, align 8, !tbaa !5
  %200 = icmp eq ptr %199, null
  br i1 %200, label %201, label %202

201:                                              ; preds = %184
  store i64 -9223372036854775799, ptr %18, align 8, !tbaa !12
  br label %243

202:                                              ; preds = %184
  %203 = load ptr, ptr %23, align 8, !tbaa !5
  %204 = load i32, ptr %15, align 4, !tbaa !10
  %205 = call ptr @NetbufAllocSpace(ptr noundef %203, i32 noundef %204, i8 noundef zeroext 0)
  br label %207

206:                                              ; preds = %112
  store i64 -9223372036854775784, ptr %18, align 8, !tbaa !12
  br label %243

207:                                              ; preds = %202, %183
  %208 = load ptr, ptr %14, align 8, !tbaa !5
  %209 = load ptr, ptr %23, align 8, !tbaa !5
  %210 = getelementptr inbounds %struct.NET_BUF, ptr %209, i32 0, i32 2
  %211 = call ptr @InsertTailList(ptr noundef %208, ptr noundef %210)
  %212 = load ptr, ptr %8, align 8, !tbaa !5
  %213 = getelementptr inbounds %struct._ISCSI_CONNECTION, ptr %212, i32 0, i32 14
  %214 = load ptr, ptr %23, align 8, !tbaa !5
  %215 = load ptr, ptr %13, align 8, !tbaa !5
  %216 = call i64 @Tcp4IoReceive(ptr noundef %213, ptr noundef %214, i8 noundef zeroext 0, ptr noundef %215)
  store i64 %216, ptr %18, align 8, !tbaa !12
  %217 = load i64, ptr %18, align 8, !tbaa !12
  %218 = icmp slt i64 %217, 0
  br i1 %218, label %219, label %220

219:                                              ; preds = %207
  br label %243

220:                                              ; preds = %207
  %221 = load i8, ptr %12, align 1, !tbaa !9
  %222 = icmp ne i8 %221, 0
  br i1 %222, label %223, label %226

223:                                              ; preds = %220
  %224 = load ptr, ptr %23, align 8, !tbaa !5
  %225 = call i32 @NetbufTrim(ptr noundef %224, i32 noundef 4, i8 noundef zeroext 0)
  br label %226

226:                                              ; preds = %223, %220
  %227 = load i32, ptr %19, align 4, !tbaa !10
  %228 = icmp ne i32 %227, 0
  br i1 %228, label %229, label %233

229:                                              ; preds = %226
  %230 = load ptr, ptr %23, align 8, !tbaa !5
  %231 = load i32, ptr %19, align 4, !tbaa !10
  %232 = call i32 @NetbufTrim(ptr noundef %230, i32 noundef %231, i8 noundef zeroext 0)
  br label %233

233:                                              ; preds = %229, %226
  %234 = load ptr, ptr %14, align 8, !tbaa !5
  %235 = load ptr, ptr %14, align 8, !tbaa !5
  %236 = call ptr @NetbufFromBufList(ptr noundef %234, i32 noundef 0, i32 noundef 0, ptr noundef @IScsiFreeNbufList, ptr noundef %235)
  %237 = load ptr, ptr %9, align 8, !tbaa !5
  store ptr %236, ptr %237, align 8, !tbaa !5
  %238 = load ptr, ptr %9, align 8, !tbaa !5
  %239 = load ptr, ptr %238, align 8, !tbaa !5
  %240 = icmp eq ptr %239, null
  br i1 %240, label %241, label %242

241:                                              ; preds = %233
  store i64 -9223372036854775799, ptr %18, align 8, !tbaa !12
  br label %242

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

243:                                              ; preds = %242, %219, %206, %201, %182, %137, %109, %72
  %244 = load i64, ptr %18, align 8, !tbaa !12
  %245 = icmp slt i64 %244, 0
  br i1 %245, label %246, label %248

246:                                              ; preds = %243
  %247 = load ptr, ptr %14, align 8, !tbaa !5
  call void @IScsiFreeNbufList(ptr noundef %247)
  br label %248

248:                                              ; preds = %246, %243
  %249 = load i64, ptr %18, align 8, !tbaa !12
  store i64 %249, ptr %7, align 8
  store i32 1, ptr %25, align 4
  br label %250

250:                                              ; preds = %248, %110, %44, %29
  call void @llvm.lifetime.end.p0(i64 8, ptr %24) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %23) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %22) #3
  call void @llvm.lifetime.end.p0(i64 32, ptr %21) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %20) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %19) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %18) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #3
  %251 = load i64, ptr %7, align 8
  ret i64 %251
}

declare zeroext i8 @DebugAssertEnabled() #0

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

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

declare ptr @NetbufAlloc(i32 noundef) #0

declare i32 @SwapBytes32(i32 noundef) #0

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

; Function Attrs: nounwind uwtable
declare dso_local void @IScsiFreeNbufList(ptr noundef) #2

; Function Attrs: nounwind uwtable
declare dso_local void @IScsiNbufExtFree(ptr noundef) #2

declare ptr @InitializeListHead(ptr noundef) #0

declare i64 @Tcp4IoReceive(ptr noundef, ptr noundef, i8 noundef zeroext, ptr noundef) #0

declare ptr @NetbufFromBufList(ptr noundef, i32 noundef, i32 noundef, ptr noundef, ptr noundef) #0

declare ptr @NetbufFromExt(ptr noundef, i32 noundef, i32 noundef, i32 noundef, ptr noundef, ptr noundef) #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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = !{!7, !7, i64 0}
!10 = !{!11, !11, i64 0}
!11 = !{!"int", !7, i64 0}
!12 = !{!13, !13, i64 0}
!13 = !{!"long long", !7, i64 0}
!14 = !{!15, !7, i64 0}
!15 = !{!"_ISCSI_BASIC_HEADER", !7, i64 0, !7, i64 1, !16, i64 2, !7, i64 4, !7, i64 5, !7, i64 8, !11, i64 16, !7, i64 20}
!16 = !{!"short", !7, i64 0}
!17 = !{!18, !11, i64 40}
!18 = !{!"_ISCSI_SCSI_DATA_IN", !7, i64 0, !7, i64 1, !7, i64 2, !7, i64 3, !7, i64 4, !7, i64 5, !7, i64 8, !11, i64 16, !11, i64 20, !11, i64 24, !11, i64 28, !11, i64 32, !11, i64 36, !11, i64 40, !11, i64 44}
!19 = !{!20, !11, i64 8}
!20 = !{!"_ISCSI_IN_BUFFER_CONTEXT", !6, i64 0, !11, i64 8}
!21 = !{!22, !11, i64 0}
!22 = !{!"", !11, i64 0, !6, i64 8}
!23 = !{!20, !6, i64 0}
!24 = !{!22, !6, i64 8}


; 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.NET_FRAGMENT = type { i32, ptr }

@.str = external hidden unnamed_addr constant [154 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [23 x i8], align 1

declare ptr @InsertTailList(ptr noundef, ptr noundef) 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

declare ptr @AllocatePool(i64 noundef) local_unnamed_addr #0

declare void @FreePool(ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local i64 @IScsiReceivePdu(ptr noundef %0, ptr nocapture noundef writeonly %1, ptr noundef readonly %2, i8 noundef zeroext %3, i8 noundef zeroext %4, ptr noundef %5) local_unnamed_addr #2 {
  %7 = alloca [2 x %struct.NET_FRAGMENT], align 16
  %8 = alloca [2 x i32], align 4
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %7) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %8) #3
  %9 = tail call ptr @AllocatePool(i64 noundef 16) #3
  %10 = icmp eq ptr %9, null
  br i1 %10, label %105, label %11

11:                                               ; preds = %6
  %12 = tail call ptr @InitializeListHead(ptr noundef nonnull %9) #3
  %.not = icmp eq i8 %3, 0
  %13 = select i1 %.not, i32 48, i32 52
  %14 = tail call ptr @NetbufAlloc(i32 noundef %13) #3
  %15 = icmp eq ptr %14, null
  br i1 %15, label %16, label %17

16:                                               ; preds = %11
  tail call void @FreePool(ptr noundef nonnull %9) #3
  br label %105

17:                                               ; preds = %11
  %18 = tail call ptr @NetbufAllocSpace(ptr noundef nonnull %14, i32 noundef %13, i8 noundef zeroext 0) #3
  %19 = tail call zeroext i8 @DebugAssertEnabled() #3
  %20 = icmp eq i8 %19, 0
  %21 = icmp ne ptr %18, null
  %or.cond3 = select i1 %20, i1 true, i1 %21
  br i1 %or.cond3, label %23, label %22

22:                                               ; preds = %17
  tail call void @DebugAssert(ptr noundef nonnull @.str, i64 noundef 988, ptr noundef nonnull @.str.5) #3
  br label %23

23:                                               ; preds = %22, %17
  %24 = getelementptr inbounds i8, ptr %14, i64 16
  %25 = tail call ptr @InsertTailList(ptr noundef nonnull %9, ptr noundef nonnull %24) #3
  %26 = getelementptr inbounds i8, ptr %0, i64 112
  %27 = tail call i64 @Tcp4IoReceive(ptr noundef nonnull %26, ptr noundef nonnull %14, i8 noundef zeroext 0, ptr noundef %5) #3
  %28 = icmp slt i64 %27, 0
  br i1 %28, label %select.unfold, label %29

29:                                               ; preds = %23
  br i1 %.not, label %32, label %30

30:                                               ; preds = %29
  %31 = tail call i32 @NetbufTrim(ptr noundef nonnull %14, i32 noundef 4, i8 noundef zeroext 0) #3
  br label %32

32:                                               ; preds = %30, %29
  %33 = getelementptr inbounds i8, ptr %18, i64 5
  %34 = load i8, ptr %33, align 1, !tbaa !5
  %35 = zext i8 %34 to i32
  %36 = shl nuw nsw i32 %35, 16
  %37 = getelementptr inbounds i8, ptr %18, i64 6
  %38 = load i8, ptr %37, align 1, !tbaa !5
  %39 = zext i8 %38 to i32
  %40 = shl nuw nsw i32 %39, 8
  %41 = or disjoint i32 %40, %36
  %42 = getelementptr inbounds i8, ptr %18, i64 7
  %43 = load i8, ptr %42, align 1, !tbaa !5
  %44 = zext i8 %43 to i32
  %45 = or disjoint i32 %41, %44
  %46 = icmp eq i32 %45, 0
  br i1 %46, label %47, label %50

47:                                               ; preds = %32
  %48 = tail call ptr @NetbufFromBufList(ptr noundef nonnull %9, i32 noundef 0, i32 noundef 0, ptr noundef nonnull @IScsiFreeNbufList, ptr noundef nonnull %9) #3
  store ptr %48, ptr %1, align 8, !tbaa !8
  %49 = icmp eq ptr %48, null
  br i1 %49, label %select.unfold, label %105

50:                                               ; preds = %32
  %51 = sub nsw i32 0, %44
  %52 = and i32 %51, 3
  %53 = load i8, ptr %18, align 4, !tbaa !10
  %54 = and i8 %53, 63
  switch i8 %54, label %select.unfold [
    i8 37, label %55
    i8 33, label %83
    i8 32, label %83
    i8 35, label %83
    i8 36, label %83
    i8 50, label %83
    i8 63, label %83
    i8 60, label %83
    i8 61, label %83
    i8 62, label %83
  ]

55:                                               ; preds = %50
  %56 = getelementptr inbounds i8, ptr %18, i64 40
  %57 = load i32, ptr %56, align 4, !tbaa !14
  %58 = tail call i32 @SwapBytes32(i32 noundef %57) #3
  %59 = icmp eq ptr %2, null
  br i1 %59, label %select.unfold, label %60

60:                                               ; preds = %55
  %61 = add i32 %58, %45
  %62 = getelementptr inbounds i8, ptr %2, i64 8
  %63 = load i32, ptr %62, align 8, !tbaa !16
  %64 = icmp ugt i32 %61, %63
  br i1 %64, label %select.unfold, label %65

65:                                               ; preds = %60
  store i32 %45, ptr %7, align 16, !tbaa !18
  %66 = load ptr, ptr %2, align 8, !tbaa !20
  %67 = zext i32 %58 to i64
  %68 = getelementptr inbounds i8, ptr %66, i64 %67
  %69 = getelementptr inbounds i8, ptr %7, i64 8
  store ptr %68, ptr %69, align 8, !tbaa !21
  %70 = icmp ne i8 %4, 0
  %71 = icmp ne i32 %52, 0
  %or.cond = select i1 %70, i1 true, i1 %71
  br i1 %or.cond, label %72, label %80

72:                                               ; preds = %65
  %73 = select i1 %70, i32 4, i32 0
  %74 = or disjoint i32 %52, %73
  %75 = getelementptr inbounds i8, ptr %7, i64 16
  store i32 %74, ptr %75, align 16, !tbaa !18
  %76 = sub nuw nsw i32 4, %52
  %77 = zext nneg i32 %76 to i64
  %78 = getelementptr inbounds i8, ptr %8, i64 %77
  %79 = getelementptr inbounds i8, ptr %7, i64 24
  store ptr %78, ptr %79, align 8, !tbaa !21
  br label %80

80:                                               ; preds = %65, %72
  %.071 = phi i32 [ 2, %72 ], [ 1, %65 ]
  %81 = call ptr @NetbufFromExt(ptr noundef nonnull %7, i32 noundef %.071, i32 noundef 0, i32 noundef 0, ptr noundef nonnull @IScsiNbufExtFree, ptr noundef null) #3
  %82 = icmp eq ptr %81, null
  br i1 %82, label %select.unfold, label %91

83:                                               ; preds = %50, %50, %50, %50, %50, %50, %50, %50, %50
  %.not85 = icmp eq i8 %4, 0
  %84 = select i1 %.not85, i32 0, i32 4
  %85 = or disjoint i32 %52, %84
  %86 = add nuw nsw i32 %85, %45
  %87 = tail call ptr @NetbufAlloc(i32 noundef %86) #3
  %88 = icmp eq ptr %87, null
  br i1 %88, label %select.unfold, label %89

89:                                               ; preds = %83
  %90 = tail call ptr @NetbufAllocSpace(ptr noundef nonnull %87, i32 noundef %86, i8 noundef zeroext 0) #3
  br label %91

91:                                               ; preds = %80, %89
  %.0 = phi ptr [ %87, %89 ], [ %81, %80 ]
  %92 = getelementptr inbounds i8, ptr %.0, i64 16
  %93 = call ptr @InsertTailList(ptr noundef nonnull %9, ptr noundef nonnull %92) #3
  %94 = call i64 @Tcp4IoReceive(ptr noundef nonnull %26, ptr noundef nonnull %.0, i8 noundef zeroext 0, ptr noundef %5) #3
  %95 = icmp slt i64 %94, 0
  br i1 %95, label %select.unfold, label %96

96:                                               ; preds = %91
  %.not86 = icmp eq i8 %4, 0
  br i1 %.not86, label %99, label %97

97:                                               ; preds = %96
  %98 = call i32 @NetbufTrim(ptr noundef nonnull %.0, i32 noundef 4, i8 noundef zeroext 0) #3
  br label %99

99:                                               ; preds = %97, %96
  %.not87 = icmp eq i32 %52, 0
  br i1 %.not87, label %102, label %100

100:                                              ; preds = %99
  %101 = call i32 @NetbufTrim(ptr noundef nonnull %.0, i32 noundef %52, i8 noundef zeroext 0) #3
  br label %102

102:                                              ; preds = %100, %99
  %103 = call ptr @NetbufFromBufList(ptr noundef nonnull %9, i32 noundef 0, i32 noundef 0, ptr noundef nonnull @IScsiFreeNbufList, ptr noundef nonnull %9) #3
  store ptr %103, ptr %1, align 8, !tbaa !8
  %104 = icmp eq ptr %103, null
  br i1 %104, label %select.unfold, label %105

select.unfold:                                    ; preds = %102, %23, %91, %47, %60, %55, %80, %83, %50
  %.073.ph = phi i64 [ -9223372036854775784, %50 ], [ -9223372036854775799, %83 ], [ -9223372036854775799, %80 ], [ -9223372036854775784, %55 ], [ -9223372036854775784, %60 ], [ -9223372036854775799, %47 ], [ %94, %91 ], [ %27, %23 ], [ -9223372036854775799, %102 ]
  call void @IScsiFreeNbufList(ptr noundef nonnull %9)
  br label %105

105:                                              ; preds = %102, %select.unfold, %47, %6, %16
  %.072 = phi i64 [ -9223372036854775799, %16 ], [ -9223372036854775799, %6 ], [ %27, %47 ], [ %.073.ph, %select.unfold ], [ %94, %102 ]
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %8) #3
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %7) #3
  ret i64 %.072
}

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

declare ptr @NetbufAlloc(i32 noundef) local_unnamed_addr #0

declare i32 @SwapBytes32(i32 noundef) local_unnamed_addr #0

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

; Function Attrs: nounwind uwtable
declare dso_local void @IScsiFreeNbufList(ptr noundef) #2

; Function Attrs: nounwind uwtable
declare dso_local void @IScsiNbufExtFree(ptr noundef) #2

declare ptr @InitializeListHead(ptr noundef) local_unnamed_addr #0

declare i64 @Tcp4IoReceive(ptr noundef, ptr noundef, i8 noundef zeroext, ptr noundef) local_unnamed_addr #0

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

declare ptr @NetbufFromExt(ptr noundef, i32 noundef, i32 noundef, i32 noundef, ptr noundef, 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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C/C++ TBAA"}
!8 = !{!9, !9, i64 0}
!9 = !{!"any pointer", !6, i64 0}
!10 = !{!11, !6, i64 0}
!11 = !{!"_ISCSI_BASIC_HEADER", !6, i64 0, !6, i64 1, !12, i64 2, !6, i64 4, !6, i64 5, !6, i64 8, !13, i64 16, !6, i64 20}
!12 = !{!"short", !6, i64 0}
!13 = !{!"int", !6, i64 0}
!14 = !{!15, !13, i64 40}
!15 = !{!"_ISCSI_SCSI_DATA_IN", !6, i64 0, !6, i64 1, !6, i64 2, !6, i64 3, !6, i64 4, !6, i64 5, !6, i64 8, !13, i64 16, !13, i64 20, !13, i64 24, !13, i64 28, !13, i64 32, !13, i64 36, !13, i64 40, !13, i64 44}
!16 = !{!17, !13, i64 8}
!17 = !{!"_ISCSI_IN_BUFFER_CONTEXT", !9, i64 0, !13, i64 8}
!18 = !{!19, !13, i64 0}
!19 = !{!"", !13, i64 0, !9, i64 8}
!20 = !{!17, !9, i64 0}
!21 = !{!19, !9, i64 8}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass