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

; 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.1 = external hidden unnamed_addr constant [23 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [26 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [115 x i8], align 1
@.str.9 = 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

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

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

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

declare void @NetbufFree(ptr noundef) #1

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

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

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

20:                                               ; preds = %17
  %21 = load ptr, ptr %9, align 8, !tbaa !5
  %22 = icmp ne ptr %21, null
  br i1 %22, label %23, label %28

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

28:                                               ; preds = %23, %20
  call void @DebugAssert(ptr noundef @.str, i64 noundef 401, ptr noundef @.str.8)
  br label %29

29:                                               ; preds = %28, %23
  br label %30

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

31:                                               ; preds = %30
  br label %32

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

35:                                               ; preds = %32
  %36 = load i64, ptr %7, align 8, !tbaa !9
  store i64 %36, ptr %12, align 8, !tbaa !9
  br label %181

37:                                               ; preds = %32
  br label %38

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

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

44:                                               ; preds = %41
  call void @DebugAssert(ptr noundef @.str, i64 noundef 416, ptr noundef @.str.9)
  br label %45

45:                                               ; preds = %44, %41
  br label %46

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

47:                                               ; preds = %46
  br label %48

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

53:                                               ; preds = %48
  br label %181

54:                                               ; preds = %48
  %55 = load ptr, ptr %6, align 8, !tbaa !5
  %56 = getelementptr inbounds %struct.UDP_END_POINT, ptr %55, i32 0, i32 3
  %57 = load i16, ptr %56, align 4, !tbaa !23
  %58 = zext i16 %57 to i32
  %59 = load ptr, ptr %9, align 8, !tbaa !5
  %60 = getelementptr inbounds %struct._MTFTP6_INSTANCE, ptr %59, i32 0, i32 13
  %61 = load i16, ptr %60, align 2, !tbaa !25
  %62 = zext i16 %61 to i32
  %63 = icmp ne i32 %58, %62
  br i1 %63, label %64, label %78

64:                                               ; preds = %54
  %65 = load ptr, ptr %9, align 8, !tbaa !5
  %66 = getelementptr inbounds %struct._MTFTP6_INSTANCE, ptr %65, i32 0, i32 13
  %67 = load i16, ptr %66, align 2, !tbaa !25
  %68 = zext i16 %67 to i32
  %69 = icmp ne i32 %68, 0
  br i1 %69, label %70, label %71

70:                                               ; preds = %64
  br label %181

71:                                               ; preds = %64
  %72 = load ptr, ptr %6, align 8, !tbaa !5
  %73 = getelementptr inbounds %struct.UDP_END_POINT, ptr %72, i32 0, i32 3
  %74 = load i16, ptr %73, align 4, !tbaa !23
  %75 = load ptr, ptr %9, align 8, !tbaa !5
  %76 = getelementptr inbounds %struct._MTFTP6_INSTANCE, ptr %75, i32 0, i32 13
  store i16 %74, ptr %76, align 2, !tbaa !25
  br label %77

77:                                               ; preds = %71
  br label %78

78:                                               ; preds = %77, %54
  %79 = load ptr, ptr %5, align 8, !tbaa !5
  %80 = getelementptr inbounds %struct.NET_BUF, ptr %79, i32 0, i32 9
  %81 = load i32, ptr %80, align 4, !tbaa !21
  store i32 %81, ptr %14, align 4, !tbaa !20
  %82 = load ptr, ptr %5, align 8, !tbaa !5
  %83 = getelementptr inbounds %struct.NET_BUF, ptr %82, i32 0, i32 8
  %84 = load i32, ptr %83, align 8, !tbaa !26
  store i32 %84, ptr %13, align 4, !tbaa !20
  %85 = load i32, ptr %13, align 4, !tbaa !20
  %86 = icmp ugt i32 %85, 1
  br i1 %86, label %87, label %99

87:                                               ; preds = %78
  %88 = load i32, ptr %14, align 4, !tbaa !20
  %89 = zext i32 %88 to i64
  %90 = call ptr @AllocateZeroPool(i64 noundef %89)
  store ptr %90, ptr %10, align 8, !tbaa !5
  %91 = load ptr, ptr %10, align 8, !tbaa !5
  %92 = icmp eq ptr %91, null
  br i1 %92, label %93, label %94

93:                                               ; preds = %87
  store i64 -9223372036854775799, ptr %12, align 8, !tbaa !9
  br label %181

94:                                               ; preds = %87
  %95 = load ptr, ptr %5, align 8, !tbaa !5
  %96 = load i32, ptr %14, align 4, !tbaa !20
  %97 = load ptr, ptr %10, align 8, !tbaa !5
  %98 = call i32 @NetbufCopy(ptr noundef %95, i32 noundef 0, i32 noundef %96, ptr noundef %97)
  br label %113

99:                                               ; preds = %78
  %100 = load ptr, ptr %5, align 8, !tbaa !5
  %101 = call ptr @NetbufGetByte(ptr noundef %100, i32 noundef 0, ptr noundef null)
  store ptr %101, ptr %10, align 8, !tbaa !5
  br label %102

102:                                              ; preds = %99
  %103 = call zeroext i8 @DebugAssertEnabled()
  %104 = icmp ne i8 %103, 0
  br i1 %104, label %105, label %110

105:                                              ; preds = %102
  %106 = load ptr, ptr %10, align 8, !tbaa !5
  %107 = icmp ne ptr %106, null
  br i1 %107, label %109, label %108

108:                                              ; preds = %105
  call void @DebugAssert(ptr noundef @.str, i64 noundef 452, ptr noundef @.str.1)
  br label %109

109:                                              ; preds = %108, %105
  br label %110

110:                                              ; preds = %109, %102
  br label %111

111:                                              ; preds = %110
  br label %112

112:                                              ; preds = %111
  br label %113

113:                                              ; preds = %112, %94
  %114 = load ptr, ptr %10, align 8, !tbaa !5
  %115 = load i16, ptr %114, align 1, !tbaa !19
  %116 = call zeroext i16 @SwapBytes16(i16 noundef zeroext %115)
  store i16 %116, ptr %15, align 2, !tbaa !27
  %117 = load ptr, ptr %9, align 8, !tbaa !5
  %118 = getelementptr inbounds %struct._MTFTP6_INSTANCE, ptr %117, i32 0, i32 6
  %119 = load ptr, ptr %118, align 8, !tbaa !28
  %120 = getelementptr inbounds %struct._EFI_MTFTP6_TOKEN, ptr %119, i32 0, i32 10
  %121 = load ptr, ptr %120, align 8, !tbaa !29
  %122 = icmp ne ptr %121, null
  br i1 %122, label %123, label %158

123:                                              ; preds = %113
  %124 = load i16, ptr %15, align 2, !tbaa !27
  %125 = zext i16 %124 to i32
  %126 = icmp eq i32 %125, 6
  br i1 %126, label %131, label %127

127:                                              ; preds = %123
  %128 = load i16, ptr %15, align 2, !tbaa !27
  %129 = zext i16 %128 to i32
  %130 = icmp eq i32 %129, 5
  br i1 %130, label %131, label %158

131:                                              ; preds = %127, %123
  %132 = load ptr, ptr %9, align 8, !tbaa !5
  %133 = getelementptr inbounds %struct._MTFTP6_INSTANCE, ptr %132, i32 0, i32 6
  %134 = load ptr, ptr %133, align 8, !tbaa !28
  %135 = getelementptr inbounds %struct._EFI_MTFTP6_TOKEN, ptr %134, i32 0, i32 10
  %136 = load ptr, ptr %135, align 8, !tbaa !29
  %137 = load ptr, ptr %9, align 8, !tbaa !5
  %138 = getelementptr inbounds %struct._MTFTP6_INSTANCE, ptr %137, i32 0, i32 3
  %139 = load ptr, ptr %9, align 8, !tbaa !5
  %140 = getelementptr inbounds %struct._MTFTP6_INSTANCE, ptr %139, i32 0, i32 6
  %141 = load ptr, ptr %140, align 8, !tbaa !28
  %142 = load i32, ptr %14, align 4, !tbaa !20
  %143 = trunc i32 %142 to i16
  %144 = load ptr, ptr %10, align 8, !tbaa !5
  %145 = call i64 %136(ptr noundef %138, ptr noundef %141, i16 noundef zeroext %143, ptr noundef %144)
  store i64 %145, ptr %12, align 8, !tbaa !9
  %146 = load i64, ptr %12, align 8, !tbaa !9
  %147 = icmp slt i64 %146, 0
  br i1 %147, label %148, label %157

148:                                              ; preds = %131
  %149 = load i16, ptr %15, align 2, !tbaa !27
  %150 = zext i16 %149 to i32
  %151 = icmp ne i32 %150, 5
  br i1 %151, label %152, label %156

152:                                              ; preds = %148
  %153 = load ptr, ptr %5, align 8, !tbaa !5
  call void @NetbufFree(ptr noundef %153)
  store ptr null, ptr %5, align 8, !tbaa !5
  %154 = load ptr, ptr %9, align 8, !tbaa !5
  %155 = call i64 @Mtftp6SendError(ptr noundef %154, i16 noundef zeroext 8, ptr noundef @.str.2)
  br label %156

156:                                              ; preds = %152, %148
  store i64 -9223372036854775787, ptr %12, align 8, !tbaa !9
  br label %181

157:                                              ; preds = %131
  br label %158

158:                                              ; preds = %157, %127, %113
  %159 = load i16, ptr %15, align 2, !tbaa !27
  %160 = zext i16 %159 to i32
  switch i32 %160, label %179 [
    i32 4, label %161
    i32 6, label %170
  ]

161:                                              ; preds = %158
  %162 = load i32, ptr %14, align 4, !tbaa !20
  %163 = icmp ne i32 %162, 4
  br i1 %163, label %164, label %165

164:                                              ; preds = %161
  br label %181

165:                                              ; preds = %161
  %166 = load ptr, ptr %9, align 8, !tbaa !5
  %167 = load ptr, ptr %10, align 8, !tbaa !5
  %168 = load i32, ptr %14, align 4, !tbaa !20
  %169 = call i64 @Mtftp6WrqHandleAck(ptr noundef %166, ptr noundef %167, i32 noundef %168, ptr noundef %5, ptr noundef %11)
  store i64 %169, ptr %12, align 8, !tbaa !9
  br label %180

170:                                              ; preds = %158
  %171 = load i32, ptr %14, align 4, !tbaa !20
  %172 = icmp ule i32 %171, 2
  br i1 %172, label %173, label %174

173:                                              ; preds = %170
  br label %181

174:                                              ; preds = %170
  %175 = load ptr, ptr %9, align 8, !tbaa !5
  %176 = load ptr, ptr %10, align 8, !tbaa !5
  %177 = load i32, ptr %14, align 4, !tbaa !20
  %178 = call i64 @Mtftp6WrqHandleOack(ptr noundef %175, ptr noundef %176, i32 noundef %177, ptr noundef %5, ptr noundef %11)
  store i64 %178, ptr %12, align 8, !tbaa !9
  br label %180

179:                                              ; preds = %158
  store i64 -9223372036854775785, ptr %12, align 8, !tbaa !9
  br label %180

180:                                              ; preds = %179, %174, %165
  br label %181

181:                                              ; preds = %180, %173, %164, %156, %93, %70, %53, %35
  %182 = load ptr, ptr %10, align 8, !tbaa !5
  %183 = icmp ne ptr %182, null
  br i1 %183, label %184, label %189

184:                                              ; preds = %181
  %185 = load i32, ptr %13, align 4, !tbaa !20
  %186 = icmp ugt i32 %185, 1
  br i1 %186, label %187, label %189

187:                                              ; preds = %184
  %188 = load ptr, ptr %10, align 8, !tbaa !5
  call void @FreePool(ptr noundef %188)
  br label %189

189:                                              ; preds = %187, %184, %181
  %190 = load ptr, ptr %5, align 8, !tbaa !5
  %191 = icmp ne ptr %190, null
  br i1 %191, label %192, label %194

192:                                              ; preds = %189
  %193 = load ptr, ptr %5, align 8, !tbaa !5
  call void @NetbufFree(ptr noundef %193)
  br label %194

194:                                              ; preds = %192, %189
  %195 = load i64, ptr %12, align 8, !tbaa !9
  %196 = icmp slt i64 %195, 0
  br i1 %196, label %206, label %197

197:                                              ; preds = %194
  %198 = load i8, ptr %11, align 1, !tbaa !19
  %199 = icmp ne i8 %198, 0
  br i1 %199, label %206, label %200

200:                                              ; preds = %197
  %201 = load ptr, ptr %9, align 8, !tbaa !5
  %202 = getelementptr inbounds %struct._MTFTP6_INSTANCE, ptr %201, i32 0, i32 14
  %203 = load ptr, ptr %202, align 8, !tbaa !31
  %204 = load ptr, ptr %9, align 8, !tbaa !5
  %205 = call i64 @UdpIoRecvDatagram(ptr noundef %203, ptr noundef @Mtftp6WrqInput, ptr noundef %204, i32 noundef 0)
  store i64 %205, ptr %12, align 8, !tbaa !9
  br label %206

206:                                              ; preds = %200, %197, %194
  %207 = load i64, ptr %12, align 8, !tbaa !9
  %208 = icmp slt i64 %207, 0
  br i1 %208, label %213, label %209

209:                                              ; preds = %206
  %210 = load i8, ptr %11, align 1, !tbaa !19
  %211 = zext i8 %210 to i32
  %212 = icmp ne i32 %211, 0
  br i1 %212, label %213, label %216

213:                                              ; preds = %209, %206
  %214 = load ptr, ptr %9, align 8, !tbaa !5
  %215 = load i64, ptr %12, align 8, !tbaa !9
  call void @Mtftp6OperationClean(ptr noundef %214, i64 noundef %215)
  br label %216

216:                                              ; preds = %213, %209
  call void @llvm.lifetime.end.p0(i64 2, ptr %15) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #3
  call void @llvm.lifetime.end.p0(i64 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 @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 i64 @UdpIoRecvDatagram(ptr noundef, ptr noundef, ptr noundef, i32 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, !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.1 = external hidden unnamed_addr constant [23 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [26 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [115 x i8], align 1
@.str.9 = 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

declare i64 @Mtftp6SendError(ptr noundef, i16 noundef zeroext, ptr noundef) 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

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

declare void @NetbufFree(ptr noundef) local_unnamed_addr #1

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

; Function Attrs: nounwind uwtable
define dso_local void @Mtftp6WrqInput(ptr noundef %0, ptr nocapture noundef readonly %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
  %.not73 = icmp eq ptr %3, null
  br i1 %.not73, 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 401, ptr noundef nonnull @.str.8) #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.cond11 = or i1 %17, %18
  br i1 %or.cond11, label %20, label %19

19:                                               ; preds = %15
  tail call void @DebugAssert(ptr noundef nonnull @.str, i64 noundef 416, ptr noundef nonnull @.str.9) #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 = getelementptr inbounds i8, ptr %1, i64 36
  %26 = load i16, ptr %25, align 4, !tbaa !21
  %27 = getelementptr inbounds i8, ptr %3, i64 194
  %28 = load i16, ptr %27, align 2, !tbaa !23
  %.not74 = icmp eq i16 %26, %28
  br i1 %.not74, label %31, label %29

29:                                               ; preds = %24
  %.not75 = icmp eq i16 %28, 0
  br i1 %.not75, label %30, label %.thread

30:                                               ; preds = %29
  store i16 %26, ptr %27, align 2, !tbaa !23
  br label %31

31:                                               ; preds = %30, %24
  %32 = getelementptr inbounds i8, ptr %0, i64 128
  %33 = load i32, ptr %32, align 8, !tbaa !24
  %34 = icmp ugt i32 %33, 1
  br i1 %34, label %35, label %41

35:                                               ; preds = %31
  %36 = zext i32 %22 to i64
  %37 = tail call ptr @AllocateZeroPool(i64 noundef %36) #3
  %38 = icmp eq ptr %37, null
  br i1 %38, label %.thread, label %39

39:                                               ; preds = %35
  %40 = tail call i32 @NetbufCopy(ptr noundef nonnull %0, i32 noundef 0, i32 noundef %22, ptr noundef nonnull %37) #3
  br label %47

41:                                               ; preds = %31
  %42 = tail call ptr @NetbufGetByte(ptr noundef nonnull %0, i32 noundef 0, ptr noundef null) #3
  %43 = tail call zeroext i8 @DebugAssertEnabled() #3
  %44 = icmp eq i8 %43, 0
  %45 = icmp ne ptr %42, null
  %or.cond13 = select i1 %44, i1 true, i1 %45
  br i1 %or.cond13, label %47, label %46

46:                                               ; preds = %41
  tail call void @DebugAssert(ptr noundef nonnull @.str, i64 noundef 452, ptr noundef nonnull @.str.1) #3
  br label %47

47:                                               ; preds = %41, %46, %39
  %.0 = phi ptr [ %37, %39 ], [ %42, %41 ], [ null, %46 ]
  %48 = load i16, ptr %.0, align 1, !tbaa !18
  %49 = tail call zeroext i16 @SwapBytes16(i16 noundef zeroext %48) #3
  %50 = getelementptr inbounds i8, ptr %3, i64 112
  %51 = load ptr, ptr %50, align 8, !tbaa !25
  %52 = getelementptr inbounds i8, ptr %51, i64 80
  %53 = load ptr, ptr %52, align 8, !tbaa !26
  %.not76 = icmp ne ptr %53, null
  %54 = add i16 %49, -5
  %or.cond = icmp ult i16 %54, 2
  %or.cond80 = select i1 %.not76, i1 %or.cond, i1 false
  br i1 %or.cond80, label %55, label %63

55:                                               ; preds = %47
  %56 = getelementptr inbounds i8, ptr %3, i64 32
  %57 = trunc i32 %22 to i16
  %58 = tail call i64 %53(ptr noundef nonnull %56, ptr noundef nonnull %51, i16 noundef zeroext %57, ptr noundef nonnull %.0) #3
  %59 = icmp slt i64 %58, 0
  br i1 %59, label %60, label %63

60:                                               ; preds = %55
  %.not78 = icmp eq i16 %49, 5
  br i1 %.not78, label %71, label %61

61:                                               ; preds = %60
  tail call void @NetbufFree(ptr noundef nonnull %0) #3
  store ptr null, ptr %5, align 8, !tbaa !5
  %62 = tail call i64 @Mtftp6SendError(ptr noundef nonnull %3, i16 noundef zeroext 8, ptr noundef nonnull @.str.2) #3
  br label %71

63:                                               ; preds = %55, %47
  %.058 = phi i64 [ %58, %55 ], [ 0, %47 ]
  switch i16 %49, label %71 [
    i16 4, label %64
    i16 6, label %67
  ]

64:                                               ; preds = %63
  %.not77 = icmp eq i32 %22, 4
  br i1 %.not77, label %65, label %71

65:                                               ; preds = %64
  %66 = call i64 @Mtftp6WrqHandleAck(ptr noundef nonnull %3, ptr noundef nonnull %.0, i32 noundef 4, ptr noundef nonnull %5, ptr noundef nonnull %6)
  br label %71

67:                                               ; preds = %63
  %68 = icmp eq i32 %22, 2
  br i1 %68, label %71, label %69

69:                                               ; preds = %67
  %70 = call i64 @Mtftp6WrqHandleOack(ptr noundef nonnull %3, ptr noundef nonnull %.0, i32 noundef %22, ptr noundef nonnull %5, ptr noundef nonnull %6)
  br label %71

71:                                               ; preds = %63, %60, %61, %65, %69, %67, %64
  %.159 = phi i64 [ %.058, %67 ], [ %70, %69 ], [ %.058, %64 ], [ %66, %65 ], [ -9223372036854775787, %61 ], [ -9223372036854775787, %60 ], [ -9223372036854775785, %63 ]
  br i1 %34, label %72, label %.thread

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

.thread:                                          ; preds = %35, %13, %29, %72, %71
  %.15985.ph = phi i64 [ 0, %29 ], [ %2, %13 ], [ -9223372036854775799, %35 ], [ %.159, %71 ], [ %.159, %72 ]
  %.pr = load ptr, ptr %5, align 8, !tbaa !5
  %.not79 = icmp eq ptr %.pr, null
  br i1 %.not79, label %74, label %.thread.thread

.thread.thread:                                   ; preds = %20, %.thread
  %.1598588 = phi i64 [ %.15985.ph, %.thread ], [ 0, %20 ]
  %73 = phi ptr [ %.pr, %.thread ], [ %0, %20 ]
  call void @NetbufFree(ptr noundef nonnull %73) #3
  br label %74

74:                                               ; preds = %.thread.thread, %.thread
  %.1598589 = phi i64 [ %.1598588, %.thread.thread ], [ %.15985.ph, %.thread ]
  %75 = icmp slt i64 %.1598589, 0
  %76 = load i8, ptr %6, align 1
  %77 = icmp ne i8 %76, 0
  %or.cond6 = select i1 %75, i1 true, i1 %77
  br i1 %or.cond6, label %82, label %78

78:                                               ; preds = %74
  %79 = getelementptr inbounds i8, ptr %3, i64 200
  %80 = load ptr, ptr %79, align 8, !tbaa !28
  %81 = call i64 @UdpIoRecvDatagram(ptr noundef %80, ptr noundef nonnull @Mtftp6WrqInput, ptr noundef %3, i32 noundef 0) #3
  %.pre = load i8, ptr %6, align 1
  br label %82

82:                                               ; preds = %78, %74
  %83 = phi i8 [ %76, %74 ], [ %.pre, %78 ]
  %.2 = phi i64 [ %.1598589, %74 ], [ %81, %78 ]
  %84 = icmp slt i64 %.2, 0
  %85 = icmp ne i8 %83, 0
  %or.cond9 = select i1 %84, i1 true, i1 %85
  br i1 %or.cond9, label %86, label %87

86:                                               ; preds = %82
  call void @Mtftp6OperationClean(ptr noundef %3, i64 noundef %.2) #3
  br label %87

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

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 i64 @UdpIoRecvDatagram(ptr noundef, ptr noundef, ptr noundef, i32 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, !6, i64 200}


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