; LLVM IR from thalium/icebox :: third_party/virtualbox/src/VBox/Devices/EFI/Firmware/NetworkPkg/Mtftp6Dxe (Mtftp6RrqInput)

; 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._MTFTP6_INSTANCE = type { i32, ptr, %struct._LIST_ENTRY, %struct._EFI_MTFTP6_PROTOCOL, ptr, ptr, ptr, %struct.MTFTP6_EXT_OPTION_INFO, i16, i16, %struct._LIST_ENTRY, %struct.EFI_IPv6_ADDRESS, i16, i16, ptr, %struct.EFI_IPv6_ADDRESS, i16, ptr, ptr, i32, i32, i32, i32, i64, i8, i8, i8 }
%struct._EFI_MTFTP6_PROTOCOL = type { ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr }
%struct.MTFTP6_EXT_OPTION_INFO = type { i16, i8, i32, %struct.EFI_IPv6_ADDRESS, i16, i8, i32 }
%struct._LIST_ENTRY = type { ptr, ptr }
%struct.EFI_IPv6_ADDRESS = type { [16 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.UDP_END_POINT = type { %union.EFI_IP_ADDRESS, i16, %union.EFI_IP_ADDRESS, i16 }
%union.EFI_IP_ADDRESS = type { [4 x i32] }
%struct._EFI_MTFTP6_TOKEN = type { i64, ptr, ptr, ptr, ptr, i32, ptr, i64, ptr, ptr, ptr, ptr, ptr }

@.str = external hidden unnamed_addr constant [134 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [115 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [26 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [23 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [26 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

declare zeroext i8 @DebugAssertEnabled() #1

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

declare zeroext i16 @SwapBytes16(i16 noundef zeroext) #1

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

declare void @NetbufFree(ptr noundef) #1

declare i64 @Mtftp6SendError(ptr noundef, i16 noundef zeroext, ptr noundef) #1

; Function Attrs: nounwind uwtable
declare dso_local i64 @Mtftp6RrqHandleData(ptr noundef, ptr noundef, i32 noundef, ptr noundef, ptr noundef) #2

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

; Function Attrs: nounwind uwtable
declare dso_local i64 @Mtftp6RrqHandleOack(ptr noundef, ptr noundef, i32 noundef, ptr noundef, ptr noundef) #2

declare i64 @UdpIoRecvDatagram(ptr noundef, ptr noundef, ptr noundef, i32 noundef) #1

; Function Attrs: nounwind uwtable
define dso_local void @Mtftp6RrqInput(ptr noundef %0, ptr noundef %1, i64 noundef %2, ptr noundef %3) #2 {
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %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 i64, align 8
  %14 = alloca i16, align 2
  %15 = alloca i32, align 4
  %16 = alloca i32, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store i64 %2, ptr %7, align 8, !tbaa !9
  store ptr %3, ptr %8, align 8, !tbaa !5
  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 1, ptr %11) #3
  call void @llvm.lifetime.start.p0(i64 1, ptr %12) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #3
  call void @llvm.lifetime.start.p0(i64 2, ptr %14) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #3
  %17 = load ptr, ptr %8, align 8, !tbaa !5
  store ptr %17, ptr %9, align 8, !tbaa !5
  br label %18

18:                                               ; preds = %4
  %19 = call zeroext i8 @DebugAssertEnabled()
  %20 = icmp ne i8 %19, 0
  br i1 %20, label %21, label %31

21:                                               ; preds = %18
  %22 = load ptr, ptr %9, align 8, !tbaa !5
  %23 = icmp ne ptr %22, null
  br i1 %23, label %24, label %29

24:                                               ; preds = %21
  %25 = load ptr, ptr %9, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct._MTFTP6_INSTANCE, ptr %25, i32 0, i32 0
  %27 = load i32, ptr %26, align 8, !tbaa !11
  %28 = icmp eq i32 %27, 1228293709
  br i1 %28, label %30, label %29

29:                                               ; preds = %24, %21
  call void @DebugAssert(ptr noundef @.str, i64 noundef 676, ptr noundef @.str.10)
  br label %30

30:                                               ; preds = %29, %24
  br label %31

31:                                               ; preds = %30, %18
  br label %32

32:                                               ; preds = %31
  br label %33

33:                                               ; preds = %32
  store i64 0, ptr %13, align 8, !tbaa !9
  store ptr null, ptr %10, align 8, !tbaa !5
  store i8 0, ptr %11, align 1, !tbaa !19
  store i8 0, ptr %12, align 1, !tbaa !19
  store i32 0, ptr %15, align 4, !tbaa !20
  %34 = load i64, ptr %7, align 8, !tbaa !9
  %35 = icmp slt i64 %34, 0
  br i1 %35, label %36, label %38

36:                                               ; preds = %33
  %37 = load i64, ptr %7, align 8, !tbaa !9
  store i64 %37, ptr %13, align 8, !tbaa !9
  br label %204

38:                                               ; preds = %33
  br label %39

39:                                               ; preds = %38
  %40 = call zeroext i8 @DebugAssertEnabled()
  %41 = icmp ne i8 %40, 0
  br i1 %41, label %42, label %47

42:                                               ; preds = %39
  %43 = load ptr, ptr %5, align 8, !tbaa !5
  %44 = icmp ne ptr %43, null
  br i1 %44, label %46, label %45

45:                                               ; preds = %42
  call void @DebugAssert(ptr noundef @.str, i64 noundef 692, ptr noundef @.str.11)
  br label %46

46:                                               ; preds = %45, %42
  br label %47

47:                                               ; preds = %46, %39
  br label %48

48:                                               ; preds = %47
  br label %49

49:                                               ; preds = %48
  %50 = load ptr, ptr %5, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct.NET_BUF, ptr %50, i32 0, i32 9
  %52 = load i32, ptr %51, align 4, !tbaa !21
  %53 = icmp ult i32 %52, 2
  br i1 %53, label %54, label %55

54:                                               ; preds = %49
  br label %204

55:                                               ; preds = %49
  %56 = load ptr, ptr %6, align 8, !tbaa !5
  %57 = getelementptr inbounds %struct.UDP_END_POINT, ptr %56, i32 0, i32 0
  %58 = call ptr @Ip6Swap128(ptr noundef %57)
  %59 = load ptr, ptr %9, align 8, !tbaa !5
  %60 = getelementptr inbounds %struct._MTFTP6_INSTANCE, ptr %59, i32 0, i32 15
  %61 = call i64 @CompareMem(ptr noundef %58, ptr noundef %60, i64 noundef 16)
  %62 = icmp eq i64 %61, 0
  br i1 %62, label %63, label %64

63:                                               ; preds = %55
  store i8 1, ptr %12, align 1, !tbaa !19
  br label %65

64:                                               ; preds = %55
  store i8 0, ptr %12, align 1, !tbaa !19
  br label %65

65:                                               ; preds = %64, %63
  %66 = load ptr, ptr %6, align 8, !tbaa !5
  %67 = getelementptr inbounds %struct.UDP_END_POINT, ptr %66, i32 0, i32 3
  %68 = load i16, ptr %67, align 4, !tbaa !23
  %69 = zext i16 %68 to i32
  %70 = load ptr, ptr %9, align 8, !tbaa !5
  %71 = getelementptr inbounds %struct._MTFTP6_INSTANCE, ptr %70, i32 0, i32 13
  %72 = load i16, ptr %71, align 2, !tbaa !25
  %73 = zext i16 %72 to i32
  %74 = icmp ne i32 %69, %73
  br i1 %74, label %75, label %89

75:                                               ; preds = %65
  %76 = load ptr, ptr %9, align 8, !tbaa !5
  %77 = getelementptr inbounds %struct._MTFTP6_INSTANCE, ptr %76, i32 0, i32 13
  %78 = load i16, ptr %77, align 2, !tbaa !25
  %79 = zext i16 %78 to i32
  %80 = icmp ne i32 %79, 0
  br i1 %80, label %81, label %82

81:                                               ; preds = %75
  br label %204

82:                                               ; preds = %75
  %83 = load ptr, ptr %6, align 8, !tbaa !5
  %84 = getelementptr inbounds %struct.UDP_END_POINT, ptr %83, i32 0, i32 3
  %85 = load i16, ptr %84, align 4, !tbaa !23
  %86 = load ptr, ptr %9, align 8, !tbaa !5
  %87 = getelementptr inbounds %struct._MTFTP6_INSTANCE, ptr %86, i32 0, i32 13
  store i16 %85, ptr %87, align 2, !tbaa !25
  br label %88

88:                                               ; preds = %82
  br label %89

89:                                               ; preds = %88, %65
  %90 = load ptr, ptr %5, align 8, !tbaa !5
  %91 = getelementptr inbounds %struct.NET_BUF, ptr %90, i32 0, i32 9
  %92 = load i32, ptr %91, align 4, !tbaa !21
  store i32 %92, ptr %16, align 4, !tbaa !20
  %93 = load ptr, ptr %5, align 8, !tbaa !5
  %94 = getelementptr inbounds %struct.NET_BUF, ptr %93, i32 0, i32 8
  %95 = load i32, ptr %94, align 8, !tbaa !26
  store i32 %95, ptr %15, align 4, !tbaa !20
  %96 = load i32, ptr %15, align 4, !tbaa !20
  %97 = icmp ugt i32 %96, 1
  br i1 %97, label %98, label %110

98:                                               ; preds = %89
  %99 = load i32, ptr %16, align 4, !tbaa !20
  %100 = zext i32 %99 to i64
  %101 = call ptr @AllocateZeroPool(i64 noundef %100)
  store ptr %101, ptr %10, align 8, !tbaa !5
  %102 = load ptr, ptr %10, align 8, !tbaa !5
  %103 = icmp eq ptr %102, null
  br i1 %103, label %104, label %105

104:                                              ; preds = %98
  store i64 -9223372036854775799, ptr %13, align 8, !tbaa !9
  br label %204

105:                                              ; preds = %98
  %106 = load ptr, ptr %5, align 8, !tbaa !5
  %107 = load i32, ptr %16, align 4, !tbaa !20
  %108 = load ptr, ptr %10, align 8, !tbaa !5
  %109 = call i32 @NetbufCopy(ptr noundef %106, i32 noundef 0, i32 noundef %107, ptr noundef %108)
  br label %124

110:                                              ; preds = %89
  %111 = load ptr, ptr %5, align 8, !tbaa !5
  %112 = call ptr @NetbufGetByte(ptr noundef %111, i32 noundef 0, ptr noundef null)
  store ptr %112, ptr %10, align 8, !tbaa !5
  br label %113

113:                                              ; preds = %110
  %114 = call zeroext i8 @DebugAssertEnabled()
  %115 = icmp ne i8 %114, 0
  br i1 %115, label %116, label %121

116:                                              ; preds = %113
  %117 = load ptr, ptr %10, align 8, !tbaa !5
  %118 = icmp ne ptr %117, null
  br i1 %118, label %120, label %119

119:                                              ; preds = %116
  call void @DebugAssert(ptr noundef @.str, i64 noundef 749, ptr noundef @.str.12)
  br label %120

120:                                              ; preds = %119, %116
  br label %121

121:                                              ; preds = %120, %113
  br label %122

122:                                              ; preds = %121
  br label %123

123:                                              ; preds = %122
  br label %124

124:                                              ; preds = %123, %105
  %125 = load ptr, ptr %10, align 8, !tbaa !5
  %126 = load i16, ptr %125, align 1, !tbaa !19
  %127 = call zeroext i16 @SwapBytes16(i16 noundef zeroext %126)
  store i16 %127, ptr %14, align 2, !tbaa !27
  %128 = load ptr, ptr %9, align 8, !tbaa !5
  %129 = getelementptr inbounds %struct._MTFTP6_INSTANCE, ptr %128, i32 0, i32 6
  %130 = load ptr, ptr %129, align 8, !tbaa !28
  %131 = getelementptr inbounds %struct._EFI_MTFTP6_TOKEN, ptr %130, i32 0, i32 10
  %132 = load ptr, ptr %131, align 8, !tbaa !29
  %133 = icmp ne ptr %132, null
  br i1 %133, label %134, label %169

134:                                              ; preds = %124
  %135 = load i16, ptr %14, align 2, !tbaa !27
  %136 = zext i16 %135 to i32
  %137 = icmp eq i32 %136, 6
  br i1 %137, label %142, label %138

138:                                              ; preds = %134
  %139 = load i16, ptr %14, align 2, !tbaa !27
  %140 = zext i16 %139 to i32
  %141 = icmp eq i32 %140, 5
  br i1 %141, label %142, label %169

142:                                              ; preds = %138, %134
  %143 = load ptr, ptr %9, align 8, !tbaa !5
  %144 = getelementptr inbounds %struct._MTFTP6_INSTANCE, ptr %143, i32 0, i32 6
  %145 = load ptr, ptr %144, align 8, !tbaa !28
  %146 = getelementptr inbounds %struct._EFI_MTFTP6_TOKEN, ptr %145, i32 0, i32 10
  %147 = load ptr, ptr %146, align 8, !tbaa !29
  %148 = load ptr, ptr %9, align 8, !tbaa !5
  %149 = getelementptr inbounds %struct._MTFTP6_INSTANCE, ptr %148, i32 0, i32 3
  %150 = load ptr, ptr %9, align 8, !tbaa !5
  %151 = getelementptr inbounds %struct._MTFTP6_INSTANCE, ptr %150, i32 0, i32 6
  %152 = load ptr, ptr %151, align 8, !tbaa !28
  %153 = load i32, ptr %16, align 4, !tbaa !20
  %154 = trunc i32 %153 to i16
  %155 = load ptr, ptr %10, align 8, !tbaa !5
  %156 = call i64 %147(ptr noundef %149, ptr noundef %152, i16 noundef zeroext %154, ptr noundef %155)
  store i64 %156, ptr %13, align 8, !tbaa !9
  %157 = load i64, ptr %13, align 8, !tbaa !9
  %158 = icmp slt i64 %157, 0
  br i1 %158, label %159, label %168

159:                                              ; preds = %142
  %160 = load i16, ptr %14, align 2, !tbaa !27
  %161 = zext i16 %160 to i32
  %162 = icmp ne i32 %161, 5
  br i1 %162, label %163, label %167

163:                                              ; preds = %159
  %164 = load ptr, ptr %5, align 8, !tbaa !5
  call void @NetbufFree(ptr noundef %164)
  store ptr null, ptr %5, align 8, !tbaa !5
  %165 = load ptr, ptr %9, align 8, !tbaa !5
  %166 = call i64 @Mtftp6SendError(ptr noundef %165, i16 noundef zeroext 8, ptr noundef @.str.13)
  br label %167

167:                                              ; preds = %163, %159
  store i64 -9223372036854775787, ptr %13, align 8, !tbaa !9
  br label %204

168:                                              ; preds = %142
  br label %169

169:                                              ; preds = %168, %138, %124
  %170 = load i16, ptr %14, align 2, !tbaa !27
  %171 = zext i16 %170 to i32
  switch i32 %171, label %202 [
    i32 3, label %172
    i32 6, label %189
  ]

172:                                              ; preds = %169
  %173 = load i32, ptr %16, align 4, !tbaa !20
  %174 = load ptr, ptr %9, align 8, !tbaa !5
  %175 = getelementptr inbounds %struct._MTFTP6_INSTANCE, ptr %174, i32 0, i32 8
  %176 = load i16, ptr %175, align 8, !tbaa !31
  %177 = zext i16 %176 to i32
  %178 = add nsw i32 4, %177
  %179 = icmp ugt i32 %173, %178
  br i1 %179, label %183, label %180

180:                                              ; preds = %172
  %181 = load i32, ptr %16, align 4, !tbaa !20
  %182 = icmp ult i32 %181, 4
  br i1 %182, label %183, label %184

183:                                              ; preds = %180, %172
  br label %204

184:                                              ; preds = %180
  %185 = load ptr, ptr %9, align 8, !tbaa !5
  %186 = load ptr, ptr %10, align 8, !tbaa !5
  %187 = load i32, ptr %16, align 4, !tbaa !20
  %188 = call i64 @Mtftp6RrqHandleData(ptr noundef %185, ptr noundef %186, i32 noundef %187, ptr noundef %5, ptr noundef %11)
  store i64 %188, ptr %13, align 8, !tbaa !9
  br label %203

189:                                              ; preds = %169
  %190 = load i8, ptr %12, align 1, !tbaa !19
  %191 = zext i8 %190 to i32
  %192 = icmp ne i32 %191, 0
  br i1 %192, label %196, label %193

193:                                              ; preds = %189
  %194 = load i32, ptr %16, align 4, !tbaa !20
  %195 = icmp ule i32 %194, 2
  br i1 %195, label %196, label %197

196:                                              ; preds = %193, %189
  br label %204

197:                                              ; preds = %193
  %198 = load ptr, ptr %9, align 8, !tbaa !5
  %199 = load ptr, ptr %10, align 8, !tbaa !5
  %200 = load i32, ptr %16, align 4, !tbaa !20
  %201 = call i64 @Mtftp6RrqHandleOack(ptr noundef %198, ptr noundef %199, i32 noundef %200, ptr noundef %5, ptr noundef %11)
  store i64 %201, ptr %13, align 8, !tbaa !9
  br label %203

202:                                              ; preds = %169
  store i64 -9223372036854775785, ptr %13, align 8, !tbaa !9
  br label %203

203:                                              ; preds = %202, %197, %184
  br label %204

204:                                              ; preds = %203, %196, %183, %167, %104, %81, %54, %36
  %205 = load ptr, ptr %10, align 8, !tbaa !5
  %206 = icmp ne ptr %205, null
  br i1 %206, label %207, label %212

207:                                              ; preds = %204
  %208 = load i32, ptr %15, align 4, !tbaa !20
  %209 = icmp ugt i32 %208, 1
  br i1 %209, label %210, label %212

210:                                              ; preds = %207
  %211 = load ptr, ptr %10, align 8, !tbaa !5
  call void @FreePool(ptr noundef %211)
  br label %212

212:                                              ; preds = %210, %207, %204
  %213 = load ptr, ptr %5, align 8, !tbaa !5
  %214 = icmp ne ptr %213, null
  br i1 %214, label %215, label %217

215:                                              ; preds = %212
  %216 = load ptr, ptr %5, align 8, !tbaa !5
  call void @NetbufFree(ptr noundef %216)
  br label %217

217:                                              ; preds = %215, %212
  %218 = load i64, ptr %13, align 8, !tbaa !9
  %219 = icmp slt i64 %218, 0
  br i1 %219, label %239, label %220

220:                                              ; preds = %217
  %221 = load i8, ptr %11, align 1, !tbaa !19
  %222 = icmp ne i8 %221, 0
  br i1 %222, label %239, label %223

223:                                              ; preds = %220
  %224 = load i8, ptr %12, align 1, !tbaa !19
  %225 = icmp ne i8 %224, 0
  br i1 %225, label %226, label %232

226:                                              ; preds = %223
  %227 = load ptr, ptr %9, align 8, !tbaa !5
  %228 = getelementptr inbounds %struct._MTFTP6_INSTANCE, ptr %227, i32 0, i32 17
  %229 = load ptr, ptr %228, align 8, !tbaa !32
  %230 = load ptr, ptr %9, align 8, !tbaa !5
  %231 = call i64 @UdpIoRecvDatagram(ptr noundef %229, ptr noundef @Mtftp6RrqInput, ptr noundef %230, i32 noundef 0)
  store i64 %231, ptr %13, align 8, !tbaa !9
  br label %238

232:                                              ; preds = %223
  %233 = load ptr, ptr %9, align 8, !tbaa !5
  %234 = getelementptr inbounds %struct._MTFTP6_INSTANCE, ptr %233, i32 0, i32 14
  %235 = load ptr, ptr %234, align 8, !tbaa !33
  %236 = load ptr, ptr %9, align 8, !tbaa !5
  %237 = call i64 @UdpIoRecvDatagram(ptr noundef %235, ptr noundef @Mtftp6RrqInput, ptr noundef %236, i32 noundef 0)
  store i64 %237, ptr %13, align 8, !tbaa !9
  br label %238

238:                                              ; preds = %232, %226
  br label %239

239:                                              ; preds = %238, %220, %217
  %240 = load i64, ptr %13, align 8, !tbaa !9
  %241 = icmp slt i64 %240, 0
  br i1 %241, label %246, label %242

242:                                              ; preds = %239
  %243 = load i8, ptr %11, align 1, !tbaa !19
  %244 = zext i8 %243 to i32
  %245 = icmp ne i32 %244, 0
  br i1 %245, label %246, label %249

246:                                              ; preds = %242, %239
  %247 = load ptr, ptr %9, align 8, !tbaa !5
  %248 = load i64, ptr %13, align 8, !tbaa !9
  call void @Mtftp6OperationClean(ptr noundef %247, i64 noundef %248)
  br label %249

249:                                              ; preds = %246, %242
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #3
  call void @llvm.lifetime.end.p0(i64 2, ptr %14) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #3
  call void @llvm.lifetime.end.p0(i64 1, ptr %12) #3
  call void @llvm.lifetime.end.p0(i64 1, 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
  ret void
}

declare ptr @Ip6Swap128(ptr noundef) #1

declare ptr @AllocateZeroPool(i64 noundef) #1

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

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

declare void @FreePool(ptr noundef) #1

declare void @Mtftp6OperationClean(ptr noundef, i64 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 = !{!"long long", !7, i64 0}
!11 = !{!12, !13, i64 0}
!12 = !{!"_MTFTP6_INSTANCE", !13, i64 0, !6, i64 8, !14, i64 16, !15, i64 32, !6, i64 96, !6, i64 104, !6, i64 112, !16, i64 120, !17, i64 152, !17, i64 154, !14, i64 160, !18, i64 176, !17, i64 192, !17, i64 194, !6, i64 200, !18, i64 208, !17, i64 224, !6, i64 232, !6, i64 240, !13, i64 248, !13, i64 252, !13, i64 256, !13, i64 260, !10, i64 264, !7, i64 272, !7, i64 273, !7, i64 274}
!13 = !{!"int", !7, i64 0}
!14 = !{!"_LIST_ENTRY", !6, i64 0, !6, i64 8}
!15 = !{!"_EFI_MTFTP6_PROTOCOL", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !6, i64 56}
!16 = !{!"", !17, i64 0, !7, i64 2, !13, i64 4, !18, i64 8, !17, i64 24, !7, i64 26, !13, i64 28}
!17 = !{!"short", !7, i64 0}
!18 = !{!"", !7, i64 0}
!19 = !{!7, !7, i64 0}
!20 = !{!13, !13, i64 0}
!21 = !{!22, !13, i64 132}
!22 = !{!"", !13, i64 0, !10, i64 8, !14, i64 16, !7, i64 32, !6, i64 40, !6, i64 48, !7, i64 56, !6, i64 120, !13, i64 128, !13, i64 132, !7, i64 136}
!23 = !{!24, !17, i64 36}
!24 = !{!"", !7, i64 0, !17, i64 16, !7, i64 20, !17, i64 36}
!25 = !{!12, !17, i64 194}
!26 = !{!22, !13, i64 128}
!27 = !{!17, !17, i64 0}
!28 = !{!12, !6, i64 112}
!29 = !{!30, !6, i64 80}
!30 = !{!"_EFI_MTFTP6_TOKEN", !10, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !13, i64 40, !6, i64 48, !10, i64 56, !6, i64 64, !6, i64 72, !6, i64 80, !6, i64 88, !6, i64 96}
!31 = !{!12, !17, i64 152}
!32 = !{!12, !6, i64 232}
!33 = !{!12, !6, i64 200}


; 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 [134 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [115 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [26 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [23 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [26 x i8], align 1

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

declare zeroext i8 @DebugAssertEnabled() local_unnamed_addr #1

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

declare zeroext i16 @SwapBytes16(i16 noundef zeroext) local_unnamed_addr #1

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

declare void @NetbufFree(ptr noundef) local_unnamed_addr #1

declare i64 @Mtftp6SendError(ptr noundef, i16 noundef zeroext, ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare dso_local i64 @Mtftp6RrqHandleData(ptr noundef, ptr noundef, i32 noundef, ptr noundef, ptr noundef) local_unnamed_addr #2

declare i64 @CompareMem(ptr noundef, ptr noundef, i64 noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare dso_local i64 @Mtftp6RrqHandleOack(ptr noundef, ptr noundef, i32 noundef, ptr noundef, ptr noundef) local_unnamed_addr #2

declare i64 @UdpIoRecvDatagram(ptr noundef, ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local void @Mtftp6RrqInput(ptr noundef %0, ptr noundef %1, i64 noundef %2, ptr noundef %3) #2 {
  %5 = alloca ptr, align 8
  %6 = alloca i8, align 1
  store ptr %0, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 1, ptr nonnull %6) #3
  %7 = tail call zeroext i8 @DebugAssertEnabled() #3
  %.not = icmp eq i8 %7, 0
  br i1 %.not, label %13, label %8

8:                                                ; preds = %4
  %.not87 = icmp eq ptr %3, null
  br i1 %.not87, label %12, label %9

9:                                                ; preds = %8
  %10 = load i32, ptr %3, align 8, !tbaa !9
  %11 = icmp eq i32 %10, 1228293709
  br i1 %11, label %13, label %12

12:                                               ; preds = %9, %8
  tail call void @DebugAssert(ptr noundef nonnull @.str, i64 noundef 676, ptr noundef nonnull @.str.10) #3
  br label %13

13:                                               ; preds = %9, %12, %4
  store i8 0, ptr %6, align 1, !tbaa !18
  %14 = icmp slt i64 %2, 0
  br i1 %14, label %.thread, label %15

15:                                               ; preds = %13
  %16 = tail call zeroext i8 @DebugAssertEnabled() #3
  %17 = icmp eq i8 %16, 0
  %18 = icmp ne ptr %0, null
  %or.cond15 = or i1 %17, %18
  br i1 %or.cond15, label %20, label %19

19:                                               ; preds = %15
  tail call void @DebugAssert(ptr noundef nonnull @.str, i64 noundef 692, ptr noundef nonnull @.str.11) #3
  br label %20

20:                                               ; preds = %19, %15
  %21 = getelementptr inbounds i8, ptr %0, i64 132
  %22 = load i32, ptr %21, align 4, !tbaa !19
  %23 = icmp ult i32 %22, 2
  br i1 %23, label %.thread.thread, label %24

24:                                               ; preds = %20
  %25 = tail call ptr @Ip6Swap128(ptr noundef %1) #3
  %26 = getelementptr inbounds i8, ptr %3, i64 208
  %27 = tail call i64 @CompareMem(ptr noundef %25, ptr noundef nonnull %26, i64 noundef 16) #3
  %28 = icmp eq i64 %27, 0
  %29 = getelementptr inbounds i8, ptr %1, i64 36
  %30 = load i16, ptr %29, align 4, !tbaa !21
  %31 = getelementptr inbounds i8, ptr %3, i64 194
  %32 = load i16, ptr %31, align 2, !tbaa !23
  %.not88 = icmp eq i16 %30, %32
  br i1 %.not88, label %35, label %33

33:                                               ; preds = %24
  %.not89 = icmp eq i16 %32, 0
  br i1 %.not89, label %34, label %.thread

34:                                               ; preds = %33
  store i16 %30, ptr %31, align 2, !tbaa !23
  br label %35

35:                                               ; preds = %34, %24
  %36 = load i32, ptr %21, align 4, !tbaa !19
  %37 = getelementptr inbounds i8, ptr %0, i64 128
  %38 = load i32, ptr %37, align 8, !tbaa !24
  %39 = icmp ugt i32 %38, 1
  br i1 %39, label %40, label %46

40:                                               ; preds = %35
  %41 = zext i32 %36 to i64
  %42 = tail call ptr @AllocateZeroPool(i64 noundef %41) #3
  %43 = icmp eq ptr %42, null
  br i1 %43, label %.thread, label %44

44:                                               ; preds = %40
  %45 = tail call i32 @NetbufCopy(ptr noundef nonnull %0, i32 noundef 0, i32 noundef %36, ptr noundef nonnull %42) #3
  br label %52

46:                                               ; preds = %35
  %47 = tail call ptr @NetbufGetByte(ptr noundef nonnull %0, i32 noundef 0, ptr noundef null) #3
  %48 = tail call zeroext i8 @DebugAssertEnabled() #3
  %49 = icmp eq i8 %48, 0
  %50 = icmp ne ptr %47, null
  %or.cond17 = select i1 %49, i1 true, i1 %50
  br i1 %or.cond17, label %52, label %51

51:                                               ; preds = %46
  tail call void @DebugAssert(ptr noundef nonnull @.str, i64 noundef 749, ptr noundef nonnull @.str.12) #3
  br label %52

52:                                               ; preds = %46, %51, %44
  %.0 = phi ptr [ %42, %44 ], [ %47, %46 ], [ null, %51 ]
  %53 = load i16, ptr %.0, align 1, !tbaa !18
  %54 = tail call zeroext i16 @SwapBytes16(i16 noundef zeroext %53) #3
  %55 = getelementptr inbounds i8, ptr %3, i64 112
  %56 = load ptr, ptr %55, align 8, !tbaa !25
  %57 = getelementptr inbounds i8, ptr %56, i64 80
  %58 = load ptr, ptr %57, align 8, !tbaa !26
  %.not90 = icmp ne ptr %58, null
  %59 = add i16 %54, -5
  %or.cond = icmp ult i16 %59, 2
  %or.cond94 = select i1 %.not90, i1 %or.cond, i1 false
  br i1 %or.cond94, label %60, label %68

60:                                               ; preds = %52
  %61 = getelementptr inbounds i8, ptr %3, i64 32
  %62 = trunc i32 %36 to i16
  %63 = tail call i64 %58(ptr noundef nonnull %61, ptr noundef nonnull %56, i16 noundef zeroext %62, ptr noundef nonnull %.0) #3
  %64 = icmp slt i64 %63, 0
  br i1 %64, label %65, label %68

65:                                               ; preds = %60
  %.not91 = icmp eq i16 %54, 5
  br i1 %.not91, label %82, label %66

66:                                               ; preds = %65
  tail call void @NetbufFree(ptr noundef nonnull %0) #3
  store ptr null, ptr %5, align 8, !tbaa !5
  %67 = tail call i64 @Mtftp6SendError(ptr noundef nonnull %3, i16 noundef zeroext 8, ptr noundef nonnull @.str.13) #3
  br label %82

68:                                               ; preds = %60, %52
  %.073 = phi i64 [ %63, %60 ], [ 0, %52 ]
  switch i16 %54, label %82 [
    i16 3, label %69
    i16 6, label %78
  ]

69:                                               ; preds = %68
  %70 = getelementptr inbounds i8, ptr %3, i64 152
  %71 = load i16, ptr %70, align 8, !tbaa !28
  %72 = zext i16 %71 to i32
  %73 = add nuw nsw i32 %72, 4
  %74 = icmp ugt i32 %36, %73
  %75 = icmp ult i32 %36, 4
  %or.cond4 = or i1 %75, %74
  br i1 %or.cond4, label %82, label %76

76:                                               ; preds = %69
  %77 = call i64 @Mtftp6RrqHandleData(ptr noundef nonnull %3, ptr noundef nonnull %.0, i32 noundef %36, ptr noundef nonnull %5, ptr noundef nonnull %6)
  br label %82

78:                                               ; preds = %68
  %79 = icmp ult i32 %36, 3
  %or.cond6 = select i1 %28, i1 true, i1 %79
  br i1 %or.cond6, label %82, label %80

80:                                               ; preds = %78
  %81 = call i64 @Mtftp6RrqHandleOack(ptr noundef nonnull %3, ptr noundef nonnull %.0, i32 noundef %36, ptr noundef nonnull %5, ptr noundef nonnull %6)
  br label %82

82:                                               ; preds = %68, %65, %66, %76, %80, %78, %69
  %.174 = phi i64 [ %.073, %78 ], [ %81, %80 ], [ %.073, %69 ], [ %77, %76 ], [ -9223372036854775787, %66 ], [ -9223372036854775787, %65 ], [ -9223372036854775785, %68 ]
  br i1 %39, label %83, label %.thread

83:                                               ; preds = %82
  call void @FreePool(ptr noundef nonnull %.0) #3
  br label %.thread

.thread:                                          ; preds = %40, %13, %33, %83, %82
  %.172101.ph.shrunk = phi i1 [ %28, %33 ], [ false, %13 ], [ %28, %40 ], [ %28, %82 ], [ %28, %83 ]
  %.174100.ph = phi i64 [ 0, %33 ], [ %2, %13 ], [ -9223372036854775799, %40 ], [ %.174, %82 ], [ %.174, %83 ]
  %.172101.ph = zext i1 %.172101.ph.shrunk to i8
  %.pr = load ptr, ptr %5, align 8, !tbaa !5
  %.not92 = icmp eq ptr %.pr, null
  br i1 %.not92, label %85, label %.thread.thread

.thread.thread:                                   ; preds = %20, %.thread
  %.174100107 = phi i64 [ %.174100.ph, %.thread ], [ 0, %20 ]
  %.172101105 = phi i8 [ %.172101.ph, %.thread ], [ 0, %20 ]
  %84 = phi ptr [ %.pr, %.thread ], [ %0, %20 ]
  call void @NetbufFree(ptr noundef nonnull %84) #3
  br label %85

85:                                               ; preds = %.thread.thread, %.thread
  %.174100108 = phi i64 [ %.174100107, %.thread.thread ], [ %.174100.ph, %.thread ]
  %.172101106 = phi i8 [ %.172101105, %.thread.thread ], [ %.172101.ph, %.thread ]
  %86 = icmp slt i64 %.174100108, 0
  %87 = load i8, ptr %6, align 1
  %88 = icmp ne i8 %87, 0
  %or.cond10 = select i1 %86, i1 true, i1 %88
  br i1 %or.cond10, label %92, label %.sink.split

.sink.split:                                      ; preds = %85
  %.not93 = icmp eq i8 %.172101106, 0
  %. = select i1 %.not93, i64 200, i64 232
  %89 = getelementptr inbounds i8, ptr %3, i64 %.
  %90 = load ptr, ptr %89, align 8, !tbaa !5
  %91 = call i64 @UdpIoRecvDatagram(ptr noundef %90, ptr noundef nonnull @Mtftp6RrqInput, ptr noundef %3, i32 noundef 0) #3
  br label %92

92:                                               ; preds = %.sink.split, %85
  %.2 = phi i64 [ %.174100108, %85 ], [ %91, %.sink.split ]
  %93 = icmp slt i64 %.2, 0
  %94 = load i8, ptr %6, align 1
  %95 = icmp ne i8 %94, 0
  %or.cond13 = select i1 %93, i1 true, i1 %95
  br i1 %or.cond13, label %96, label %97

96:                                               ; preds = %92
  call void @Mtftp6OperationClean(ptr noundef %3, i64 noundef %.2) #3
  br label %97

97:                                               ; preds = %92, %96
  call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %6) #3
  ret void
}

declare ptr @Ip6Swap128(ptr noundef) local_unnamed_addr #1

declare ptr @AllocateZeroPool(i64 noundef) local_unnamed_addr #1

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

declare ptr @NetbufGetByte(ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #1

declare void @FreePool(ptr noundef) local_unnamed_addr #1

declare void @Mtftp6OperationClean(ptr noundef, i64 noundef) local_unnamed_addr #1

attributes #0 = { mustprogress 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, !11, i64 0}
!10 = !{!"_MTFTP6_INSTANCE", !11, i64 0, !6, i64 8, !12, i64 16, !13, i64 32, !6, i64 96, !6, i64 104, !6, i64 112, !14, i64 120, !15, i64 152, !15, i64 154, !12, i64 160, !16, i64 176, !15, i64 192, !15, i64 194, !6, i64 200, !16, i64 208, !15, i64 224, !6, i64 232, !6, i64 240, !11, i64 248, !11, i64 252, !11, i64 256, !11, i64 260, !17, i64 264, !7, i64 272, !7, i64 273, !7, i64 274}
!11 = !{!"int", !7, i64 0}
!12 = !{!"_LIST_ENTRY", !6, i64 0, !6, i64 8}
!13 = !{!"_EFI_MTFTP6_PROTOCOL", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !6, i64 56}
!14 = !{!"", !15, i64 0, !7, i64 2, !11, i64 4, !16, i64 8, !15, i64 24, !7, i64 26, !11, i64 28}
!15 = !{!"short", !7, i64 0}
!16 = !{!"", !7, i64 0}
!17 = !{!"long long", !7, i64 0}
!18 = !{!7, !7, i64 0}
!19 = !{!20, !11, i64 132}
!20 = !{!"", !11, i64 0, !17, i64 8, !12, i64 16, !7, i64 32, !6, i64 40, !6, i64 48, !7, i64 56, !6, i64 120, !11, i64 128, !11, i64 132, !7, i64 136}
!21 = !{!22, !15, i64 36}
!22 = !{!"", !7, i64 0, !15, i64 16, !7, i64 20, !15, i64 36}
!23 = !{!10, !15, i64 194}
!24 = !{!20, !11, i64 128}
!25 = !{!10, !6, i64 112}
!26 = !{!27, !6, i64 80}
!27 = !{!"_EFI_MTFTP6_TOKEN", !17, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !11, i64 40, !6, i64 48, !17, i64 56, !6, i64 64, !6, i64 72, !6, i64 80, !6, i64 88, !6, i64 96}
!28 = !{!10, !15, i64 152}


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