; LLVM IR from thalium/icebox :: third_party/virtualbox/src/VBox/Devices/EFI/Firmware/NetworkPkg/IScsiDxe (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, i8, i16, i32, %struct.NET_BUF_QUEUE, i8, %struct.TCP_IO, i32, i32, i32 }
%struct.NET_BUF_QUEUE = type { i32, i64, %struct._LIST_ENTRY, %struct._LIST_ENTRY, i32, i32 }
%struct.TCP_IO = type { i8, ptr, ptr, ptr, %union.TCP_IO_PROTOCOL, %union.TCP_IO_PROTOCOL, %union.TCP_IO_CONNECTION_TOKEN, %union.TCP_IO_IO_TOKEN, %union.TCP_IO_IO_TOKEN, %union.TCP_IO_CLOSE_TOKEN, %union.TCP_IO_LISTEN_TOKEN, i8, i8, i8, i8, i8 }
%union.TCP_IO_PROTOCOL = type { ptr }
%union.TCP_IO_CONNECTION_TOKEN = type { %struct.EFI_TCP4_CONNECTION_TOKEN }
%struct.EFI_TCP4_CONNECTION_TOKEN = type { %struct.EFI_TCP4_COMPLETION_TOKEN }
%struct.EFI_TCP4_COMPLETION_TOKEN = type { ptr, i64 }
%union.TCP_IO_IO_TOKEN = type { %struct.EFI_TCP4_IO_TOKEN }
%struct.EFI_TCP4_IO_TOKEN = type { %struct.EFI_TCP4_COMPLETION_TOKEN, %union.anon.0 }
%union.anon.0 = type { ptr }
%union.TCP_IO_CLOSE_TOKEN = type { %struct.EFI_TCP4_CLOSE_TOKEN }
%struct.EFI_TCP4_CLOSE_TOKEN = type { %struct.EFI_TCP4_COMPLETION_TOKEN, i8 }
%union.TCP_IO_LISTEN_TOKEN = type { %struct.EFI_TCP4_LISTEN_TOKEN }
%struct.EFI_TCP4_LISTEN_TOKEN = type { %struct.EFI_TCP4_COMPLETION_TOKEN, ptr }
%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.1 = external hidden unnamed_addr constant [134 x i8], align 1
@.str.7 = 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 zeroext i8 @DebugAssertEnabled() #0

declare void @DebugAssert(ptr noundef, i64 noundef, 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 %240

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 %45

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

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

49:                                               ; preds = %45
  %50 = call zeroext i8 @DebugAssertEnabled()
  %51 = icmp ne i8 %50, 0
  br i1 %51, label %52, label %57

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

55:                                               ; preds = %52
  call void @DebugAssert(ptr noundef @.str.1, i64 noundef 1248, ptr noundef @.str.7)
  br label %56

56:                                               ; preds = %55, %52
  br label %57

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

58:                                               ; preds = %57
  br label %59

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

71:                                               ; preds = %59
  br label %233

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

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

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

100:                                              ; preds = %78
  br label %223

101:                                              ; preds = %78
  %102 = load i32, ptr %15, align 4, !tbaa !10
  %103 = xor i32 %102, -1
  %104 = add i32 %103, 1
  %105 = and i32 %104, 3
  store i32 %105, ptr %19, align 4, !tbaa !10
  %106 = load ptr, ptr %17, align 8, !tbaa !5
  %107 = getelementptr inbounds %struct._ISCSI_BASIC_HEADER, ptr %106, i32 0, i32 0
  %108 = load i8, ptr %107, align 4, !tbaa !14
  %109 = zext i8 %108 to i32
  %110 = and i32 %109, 63
  switch i32 %110, label %195 [
    i32 37, label %111
    i32 33, label %173
    i32 32, label %173
    i32 35, label %173
    i32 36, label %173
    i32 50, label %173
    i32 63, label %173
    i32 60, label %173
    i32 61, label %173
    i32 62, label %173
  ]

111:                                              ; preds = %101
  %112 = load ptr, ptr %17, align 8, !tbaa !5
  %113 = getelementptr inbounds %struct._ISCSI_SCSI_DATA_IN, ptr %112, i32 0, i32 13
  %114 = load i32, ptr %113, align 4, !tbaa !17
  %115 = call i32 @SwapBytes32(i32 noundef %114)
  store i32 %115, ptr %20, align 4, !tbaa !10
  %116 = load ptr, ptr %10, align 8, !tbaa !5
  %117 = icmp eq ptr %116, null
  br i1 %117, label %126, label %118

118:                                              ; preds = %111
  %119 = load i32, ptr %20, align 4, !tbaa !10
  %120 = load i32, ptr %15, align 4, !tbaa !10
  %121 = add i32 %119, %120
  %122 = load ptr, ptr %10, align 8, !tbaa !5
  %123 = getelementptr inbounds %struct._ISCSI_IN_BUFFER_CONTEXT, ptr %122, i32 0, i32 1
  %124 = load i32, ptr %123, align 8, !tbaa !19
  %125 = icmp ugt i32 %121, %124
  br i1 %125, label %126, label %127

126:                                              ; preds = %118, %111
  store i64 -9223372036854775784, ptr %18, align 8, !tbaa !12
  br label %233

127:                                              ; preds = %118
  %128 = load i32, ptr %15, align 4, !tbaa !10
  %129 = getelementptr inbounds [2 x %struct.NET_FRAGMENT], ptr %21, i64 0, i64 0
  %130 = getelementptr inbounds %struct.NET_FRAGMENT, ptr %129, i32 0, i32 0
  store i32 %128, ptr %130, align 16, !tbaa !21
  %131 = load ptr, ptr %10, align 8, !tbaa !5
  %132 = getelementptr inbounds %struct._ISCSI_IN_BUFFER_CONTEXT, ptr %131, i32 0, i32 0
  %133 = load ptr, ptr %132, align 8, !tbaa !23
  %134 = load i32, ptr %20, align 4, !tbaa !10
  %135 = zext i32 %134 to i64
  %136 = getelementptr inbounds i8, ptr %133, i64 %135
  %137 = getelementptr inbounds [2 x %struct.NET_FRAGMENT], ptr %21, i64 0, i64 0
  %138 = getelementptr inbounds %struct.NET_FRAGMENT, ptr %137, i32 0, i32 1
  store ptr %136, ptr %138, align 8, !tbaa !24
  %139 = load i8, ptr %12, align 1, !tbaa !9
  %140 = zext i8 %139 to i32
  %141 = icmp ne i32 %140, 0
  br i1 %141, label %145, label %142

142:                                              ; preds = %127
  %143 = load i32, ptr %19, align 4, !tbaa !10
  %144 = icmp ne i32 %143, 0
  br i1 %144, label %145, label %164

145:                                              ; preds = %142, %127
  %146 = load i32, ptr %19, align 4, !tbaa !10
  %147 = zext i32 %146 to i64
  %148 = load i8, ptr %12, align 1, !tbaa !9
  %149 = zext i8 %148 to i32
  %150 = icmp ne i32 %149, 0
  %151 = zext i1 %150 to i64
  %152 = select i1 %150, i64 4, i64 0
  %153 = add i64 %147, %152
  %154 = trunc i64 %153 to i32
  %155 = getelementptr inbounds [2 x %struct.NET_FRAGMENT], ptr %21, i64 0, i64 1
  %156 = getelementptr inbounds %struct.NET_FRAGMENT, ptr %155, i32 0, i32 0
  store i32 %154, ptr %156, align 16, !tbaa !21
  %157 = getelementptr inbounds [2 x i32], ptr %24, i64 0, i64 0
  %158 = load i32, ptr %19, align 4, !tbaa !10
  %159 = sub i32 4, %158
  %160 = zext i32 %159 to i64
  %161 = getelementptr inbounds i8, ptr %157, i64 %160
  %162 = getelementptr inbounds [2 x %struct.NET_FRAGMENT], ptr %21, i64 0, i64 1
  %163 = getelementptr inbounds %struct.NET_FRAGMENT, ptr %162, i32 0, i32 1
  store ptr %161, ptr %163, align 8, !tbaa !24
  store i32 2, ptr %22, align 4, !tbaa !10
  br label %165

164:                                              ; preds = %142
  store i32 1, ptr %22, align 4, !tbaa !10
  br label %165

165:                                              ; preds = %164, %145
  %166 = getelementptr inbounds [2 x %struct.NET_FRAGMENT], ptr %21, i64 0, i64 0
  %167 = load i32, ptr %22, align 4, !tbaa !10
  %168 = call ptr @NetbufFromExt(ptr noundef %166, i32 noundef %167, i32 noundef 0, i32 noundef 0, ptr noundef @IScsiNbufExtFree, ptr noundef null)
  store ptr %168, ptr %23, align 8, !tbaa !5
  %169 = load ptr, ptr %23, align 8, !tbaa !5
  %170 = icmp eq ptr %169, null
  br i1 %170, label %171, label %172

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

172:                                              ; preds = %165
  br label %196

173:                                              ; preds = %101, %101, %101, %101, %101, %101, %101, %101, %101
  %174 = load i32, ptr %19, align 4, !tbaa !10
  %175 = zext i32 %174 to i64
  %176 = load i8, ptr %12, align 1, !tbaa !9
  %177 = zext i8 %176 to i32
  %178 = icmp ne i32 %177, 0
  %179 = zext i1 %178 to i64
  %180 = select i1 %178, i64 4, i64 0
  %181 = add i64 %175, %180
  %182 = load i32, ptr %15, align 4, !tbaa !10
  %183 = zext i32 %182 to i64
  %184 = add i64 %183, %181
  %185 = trunc i64 %184 to i32
  store i32 %185, ptr %15, align 4, !tbaa !10
  %186 = load i32, ptr %15, align 4, !tbaa !10
  %187 = call ptr @NetbufAlloc(i32 noundef %186)
  store ptr %187, ptr %23, align 8, !tbaa !5
  %188 = load ptr, ptr %23, align 8, !tbaa !5
  %189 = icmp eq ptr %188, null
  br i1 %189, label %190, label %191

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

191:                                              ; preds = %173
  %192 = load ptr, ptr %23, align 8, !tbaa !5
  %193 = load i32, ptr %15, align 4, !tbaa !10
  %194 = call ptr @NetbufAllocSpace(ptr noundef %192, i32 noundef %193, i8 noundef zeroext 0)
  br label %196

195:                                              ; preds = %101
  store i64 -9223372036854775784, ptr %18, align 8, !tbaa !12
  br label %233

196:                                              ; preds = %191, %172
  %197 = load ptr, ptr %14, align 8, !tbaa !5
  %198 = load ptr, ptr %23, align 8, !tbaa !5
  %199 = getelementptr inbounds %struct.NET_BUF, ptr %198, i32 0, i32 2
  %200 = call ptr @InsertTailList(ptr noundef %197, ptr noundef %199)
  %201 = load ptr, ptr %8, align 8, !tbaa !5
  %202 = getelementptr inbounds %struct._ISCSI_CONNECTION, ptr %201, i32 0, i32 16
  %203 = load ptr, ptr %23, align 8, !tbaa !5
  %204 = load ptr, ptr %13, align 8, !tbaa !5
  %205 = call i64 @TcpIoReceive(ptr noundef %202, ptr noundef %203, i8 noundef zeroext 0, ptr noundef %204)
  store i64 %205, ptr %18, align 8, !tbaa !12
  %206 = load i64, ptr %18, align 8, !tbaa !12
  %207 = icmp slt i64 %206, 0
  br i1 %207, label %208, label %209

208:                                              ; preds = %196
  br label %233

209:                                              ; preds = %196
  %210 = load i8, ptr %12, align 1, !tbaa !9
  %211 = icmp ne i8 %210, 0
  br i1 %211, label %212, label %215

212:                                              ; preds = %209
  %213 = load ptr, ptr %23, align 8, !tbaa !5
  %214 = call i32 @NetbufTrim(ptr noundef %213, i32 noundef 4, i8 noundef zeroext 0)
  br label %215

215:                                              ; preds = %212, %209
  %216 = load i32, ptr %19, align 4, !tbaa !10
  %217 = icmp ne i32 %216, 0
  br i1 %217, label %218, label %222

218:                                              ; preds = %215
  %219 = load ptr, ptr %23, align 8, !tbaa !5
  %220 = load i32, ptr %19, align 4, !tbaa !10
  %221 = call i32 @NetbufTrim(ptr noundef %219, i32 noundef %220, i8 noundef zeroext 0)
  br label %222

222:                                              ; preds = %218, %215
  br label %223

223:                                              ; preds = %222, %100
  %224 = load ptr, ptr %14, align 8, !tbaa !5
  %225 = load ptr, ptr %14, align 8, !tbaa !5
  %226 = call ptr @NetbufFromBufList(ptr noundef %224, i32 noundef 0, i32 noundef 0, ptr noundef @IScsiFreeNbufList, ptr noundef %225)
  %227 = load ptr, ptr %9, align 8, !tbaa !5
  store ptr %226, ptr %227, align 8, !tbaa !5
  %228 = load ptr, ptr %9, align 8, !tbaa !5
  %229 = load ptr, ptr %228, align 8, !tbaa !5
  %230 = icmp eq ptr %229, null
  br i1 %230, label %231, label %232

231:                                              ; preds = %223
  store i64 -9223372036854775799, ptr %18, align 8, !tbaa !12
  br label %232

232:                                              ; preds = %231, %223
  br label %233

233:                                              ; preds = %232, %208, %195, %190, %171, %126, %71, %44
  %234 = load i64, ptr %18, align 8, !tbaa !12
  %235 = icmp slt i64 %234, 0
  br i1 %235, label %236, label %238

236:                                              ; preds = %233
  %237 = load ptr, ptr %14, align 8, !tbaa !5
  call void @IScsiFreeNbufList(ptr noundef %237)
  br label %238

238:                                              ; preds = %236, %233
  %239 = load i64, ptr %18, align 8, !tbaa !12
  store i64 %239, ptr %7, align 8
  store i32 1, ptr %25, align 4
  br label %240

240:                                              ; preds = %238, %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
  %241 = load i64, ptr %7, align 8
  ret i64 %241
}

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 @AllocatePool(i64 noundef) #0

declare ptr @InitializeListHead(ptr noundef) #0

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

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

declare ptr @NetbufFromBufList(ptr 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.1 = external hidden unnamed_addr constant [134 x i8], align 1
@.str.7 = 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 zeroext i8 @DebugAssertEnabled() local_unnamed_addr #0

declare void @DebugAssert(ptr noundef, i64 noundef, 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 %101, 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 %select.unfold, label %16

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

21:                                               ; preds = %16
  tail call void @DebugAssert(ptr noundef nonnull @.str.1, i64 noundef 1248, ptr noundef nonnull @.str.7) #3
  br label %22

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

28:                                               ; preds = %22
  br i1 %.not, label %31, label %29

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

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

46:                                               ; preds = %31
  %47 = sub nsw i32 0, %43
  %48 = and i32 %47, 3
  %49 = load i8, ptr %17, align 4, !tbaa !8
  %50 = and i8 %49, 63
  switch i8 %50, label %select.unfold [
    i8 37, label %51
    i8 33, label %79
    i8 32, label %79
    i8 35, label %79
    i8 36, label %79
    i8 50, label %79
    i8 63, label %79
    i8 60, label %79
    i8 61, label %79
    i8 62, label %79
  ]

51:                                               ; preds = %46
  %52 = getelementptr inbounds i8, ptr %17, i64 40
  %53 = load i32, ptr %52, align 4, !tbaa !12
  %54 = tail call i32 @SwapBytes32(i32 noundef %53) #3
  %55 = icmp eq ptr %2, null
  br i1 %55, label %select.unfold, label %56

56:                                               ; preds = %51
  %57 = add i32 %54, %44
  %58 = getelementptr inbounds i8, ptr %2, i64 8
  %59 = load i32, ptr %58, align 8, !tbaa !14
  %60 = icmp ugt i32 %57, %59
  br i1 %60, label %select.unfold, label %61

61:                                               ; preds = %56
  store i32 %44, ptr %7, align 16, !tbaa !17
  %62 = load ptr, ptr %2, align 8, !tbaa !19
  %63 = zext i32 %54 to i64
  %64 = getelementptr inbounds i8, ptr %62, i64 %63
  %65 = getelementptr inbounds i8, ptr %7, i64 8
  store ptr %64, ptr %65, align 8, !tbaa !20
  %66 = icmp ne i8 %4, 0
  %67 = icmp ne i32 %48, 0
  %or.cond = select i1 %66, i1 true, i1 %67
  br i1 %or.cond, label %68, label %76

68:                                               ; preds = %61
  %69 = select i1 %66, i32 4, i32 0
  %70 = or disjoint i32 %48, %69
  %71 = getelementptr inbounds i8, ptr %7, i64 16
  store i32 %70, ptr %71, align 16, !tbaa !17
  %72 = sub nuw nsw i32 4, %48
  %73 = zext nneg i32 %72 to i64
  %74 = getelementptr inbounds i8, ptr %8, i64 %73
  %75 = getelementptr inbounds i8, ptr %7, i64 24
  store ptr %74, ptr %75, align 8, !tbaa !20
  br label %76

76:                                               ; preds = %61, %68
  %.065 = phi i32 [ 2, %68 ], [ 1, %61 ]
  %77 = call ptr @NetbufFromExt(ptr noundef nonnull %7, i32 noundef %.065, i32 noundef 0, i32 noundef 0, ptr noundef nonnull @IScsiNbufExtFree, ptr noundef null) #3
  %78 = icmp eq ptr %77, null
  br i1 %78, label %select.unfold, label %87

79:                                               ; preds = %46, %46, %46, %46, %46, %46, %46, %46, %46
  %.not80 = icmp eq i8 %4, 0
  %80 = select i1 %.not80, i32 0, i32 4
  %81 = or disjoint i32 %48, %80
  %82 = add nuw nsw i32 %81, %44
  %83 = tail call ptr @NetbufAlloc(i32 noundef %82) #3
  %84 = icmp eq ptr %83, null
  br i1 %84, label %select.unfold, label %85

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

87:                                               ; preds = %76, %85
  %.0 = phi ptr [ %83, %85 ], [ %77, %76 ]
  %88 = getelementptr inbounds i8, ptr %.0, i64 16
  %89 = call ptr @InsertTailList(ptr noundef nonnull %9, ptr noundef nonnull %88) #3
  %90 = call i64 @TcpIoReceive(ptr noundef nonnull %25, ptr noundef nonnull %.0, i8 noundef zeroext 0, ptr noundef %5) #3
  %91 = icmp slt i64 %90, 0
  br i1 %91, label %select.unfold, label %92

92:                                               ; preds = %87
  %.not81 = icmp eq i8 %4, 0
  br i1 %.not81, label %95, label %93

93:                                               ; preds = %92
  %94 = call i32 @NetbufTrim(ptr noundef nonnull %.0, i32 noundef 4, i8 noundef zeroext 0) #3
  br label %95

95:                                               ; preds = %93, %92
  %.not82 = icmp eq i32 %48, 0
  br i1 %.not82, label %98, label %96

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

98:                                               ; preds = %95, %96, %31
  %.067 = phi i64 [ %26, %31 ], [ %90, %96 ], [ %90, %95 ]
  %99 = call ptr @NetbufFromBufList(ptr noundef nonnull %9, i32 noundef 0, i32 noundef 0, ptr noundef nonnull @IScsiFreeNbufList, ptr noundef nonnull %9) #3
  store ptr %99, ptr %1, align 8, !tbaa !21
  %100 = icmp eq ptr %99, null
  br i1 %100, label %select.unfold, label %101

select.unfold:                                    ; preds = %98, %22, %87, %11, %56, %51, %76, %79, %46
  %.1.ph = phi i64 [ -9223372036854775784, %46 ], [ -9223372036854775799, %79 ], [ -9223372036854775799, %76 ], [ -9223372036854775784, %51 ], [ -9223372036854775784, %56 ], [ -9223372036854775799, %11 ], [ %90, %87 ], [ %26, %22 ], [ -9223372036854775799, %98 ]
  call void @IScsiFreeNbufList(ptr noundef nonnull %9)
  br label %101

101:                                              ; preds = %98, %select.unfold, %6
  %.066 = phi i64 [ -9223372036854775799, %6 ], [ %.1.ph, %select.unfold ], [ %.067, %98 ]
  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 %.066
}

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 @AllocatePool(i64 noundef) local_unnamed_addr #0

declare ptr @InitializeListHead(ptr noundef) local_unnamed_addr #0

declare i64 @TcpIoReceive(ptr noundef, ptr noundef, i8 noundef zeroext, 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

declare ptr @NetbufFromBufList(ptr 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, !6, i64 0}
!9 = !{!"_ISCSI_BASIC_HEADER", !6, i64 0, !6, i64 1, !10, i64 2, !6, i64 4, !6, i64 5, !6, i64 8, !11, i64 16, !6, i64 20}
!10 = !{!"short", !6, i64 0}
!11 = !{!"int", !6, i64 0}
!12 = !{!13, !11, i64 40}
!13 = !{!"_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, !11, i64 16, !11, i64 20, !11, i64 24, !11, i64 28, !11, i64 32, !11, i64 36, !11, i64 40, !11, i64 44}
!14 = !{!15, !11, i64 8}
!15 = !{!"_ISCSI_IN_BUFFER_CONTEXT", !16, i64 0, !11, i64 8}
!16 = !{!"any pointer", !6, i64 0}
!17 = !{!18, !11, i64 0}
!18 = !{!"", !11, i64 0, !16, i64 8}
!19 = !{!15, !16, i64 0}
!20 = !{!18, !16, i64 8}
!21 = !{!16, !16, i64 0}


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