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

; 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._MTFTP4_PROTOCOL = type { i32, %struct._LIST_ENTRY, %struct._EFI_MTFTP4_PROTOCOL, i64, i8, ptr, ptr, %struct.EFI_MTFTP4_CONFIG_DATA, ptr, %struct.MTFTP4_OPTION, i16, i16, i16, %struct._LIST_ENTRY, i32, i16, i16, i32, ptr, ptr, i32, i32, i32, i32, i32, i16, i8, ptr }
%struct._EFI_MTFTP4_PROTOCOL = type { ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr }
%struct.EFI_MTFTP4_CONFIG_DATA = type { i8, %struct.EFI_IPv4_ADDRESS, %struct.EFI_IPv4_ADDRESS, i16, %struct.EFI_IPv4_ADDRESS, %struct.EFI_IPv4_ADDRESS, i16, i16, i16 }
%struct.EFI_IPv4_ADDRESS = type { [4 x i8] }
%struct.MTFTP4_OPTION = type { i16, i8, i32, i32, i16, i8, i32 }
%struct._LIST_ENTRY = type { ptr, 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] }
%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_MTFTP4_TOKEN = type { i64, ptr, ptr, ptr, ptr, i32, ptr, i64, ptr, ptr, ptr, ptr, ptr }

@.str = external hidden unnamed_addr constant [154 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.7 = external hidden unnamed_addr constant [115 x i8], align 1
@.str.8 = 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 void @FreePool(ptr noundef) #1

declare i64 @Mtftp4SendError(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 @Mtftp4WrqHandleAck(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #2

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

; Function Attrs: nounwind uwtable
define dso_local void @Mtftp4WrqInput(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 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 2, ptr %14) #3
  %15 = load ptr, ptr %8, align 8, !tbaa !5
  store ptr %15, ptr %9, align 8, !tbaa !5
  br label %16

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

19:                                               ; preds = %16
  %20 = load ptr, ptr %9, align 8, !tbaa !5
  %21 = icmp ne ptr %20, null
  br i1 %21, label %22, label %27

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

27:                                               ; preds = %22, %19
  call void @DebugAssert(ptr noundef @.str, i64 noundef 355, ptr noundef @.str.7)
  br label %28

28:                                               ; preds = %27, %22
  br label %29

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

30:                                               ; preds = %29
  br label %31

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

34:                                               ; preds = %31
  %35 = load i64, ptr %7, align 8, !tbaa !9
  store i64 %35, ptr %12, align 8, !tbaa !9
  br label %179

36:                                               ; preds = %31
  br label %37

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

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

43:                                               ; preds = %40
  call void @DebugAssert(ptr noundef @.str, i64 noundef 366, ptr noundef @.str.8)
  br label %44

44:                                               ; preds = %43, %40
  br label %45

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

46:                                               ; preds = %45
  br label %47

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

52:                                               ; preds = %47
  br label %179

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

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

69:                                               ; preds = %63
  br label %179

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

76:                                               ; preds = %70
  br label %77

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

85:                                               ; preds = %77
  %86 = load i32, ptr %13, align 4, !tbaa !26
  %87 = zext i32 %86 to i64
  %88 = call ptr @AllocatePool(i64 noundef %87)
  store ptr %88, ptr %10, align 8, !tbaa !5
  %89 = load ptr, ptr %10, align 8, !tbaa !5
  %90 = icmp eq ptr %89, null
  br i1 %90, label %91, label %92

91:                                               ; preds = %85
  store i64 -9223372036854775799, ptr %12, align 8, !tbaa !9
  br label %179

92:                                               ; preds = %85
  %93 = load ptr, ptr %5, align 8, !tbaa !5
  %94 = load i32, ptr %13, align 4, !tbaa !26
  %95 = load ptr, ptr %10, align 8, !tbaa !5
  %96 = call i32 @NetbufCopy(ptr noundef %93, i32 noundef 0, i32 noundef %94, ptr noundef %95)
  br label %111

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

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

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

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

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

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

109:                                              ; preds = %108
  br label %110

110:                                              ; preds = %109
  br label %111

111:                                              ; preds = %110, %92
  %112 = load ptr, ptr %10, align 8, !tbaa !5
  %113 = load i16, ptr %112, align 1, !tbaa !20
  %114 = call zeroext i16 @SwapBytes16(i16 noundef zeroext %113)
  store i16 %114, ptr %14, align 2, !tbaa !28
  %115 = load ptr, ptr %9, align 8, !tbaa !5
  %116 = getelementptr inbounds %struct._MTFTP4_PROTOCOL, ptr %115, i32 0, i32 8
  %117 = load ptr, ptr %116, align 8, !tbaa !29
  %118 = getelementptr inbounds %struct._EFI_MTFTP4_TOKEN, ptr %117, i32 0, i32 10
  %119 = load ptr, ptr %118, align 8, !tbaa !30
  %120 = icmp ne ptr %119, null
  br i1 %120, label %121, label %155

121:                                              ; preds = %111
  %122 = load i16, ptr %14, align 2, !tbaa !28
  %123 = zext i16 %122 to i32
  %124 = icmp eq i32 %123, 6
  br i1 %124, label %129, label %125

125:                                              ; preds = %121
  %126 = load i16, ptr %14, align 2, !tbaa !28
  %127 = zext i16 %126 to i32
  %128 = icmp eq i32 %127, 5
  br i1 %128, label %129, label %155

129:                                              ; preds = %125, %121
  %130 = load ptr, ptr %9, align 8, !tbaa !5
  %131 = getelementptr inbounds %struct._MTFTP4_PROTOCOL, ptr %130, i32 0, i32 8
  %132 = load ptr, ptr %131, align 8, !tbaa !29
  %133 = getelementptr inbounds %struct._EFI_MTFTP4_TOKEN, ptr %132, i32 0, i32 10
  %134 = load ptr, ptr %133, align 8, !tbaa !30
  %135 = load ptr, ptr %9, align 8, !tbaa !5
  %136 = getelementptr inbounds %struct._MTFTP4_PROTOCOL, ptr %135, i32 0, i32 2
  %137 = load ptr, ptr %9, align 8, !tbaa !5
  %138 = getelementptr inbounds %struct._MTFTP4_PROTOCOL, ptr %137, i32 0, i32 8
  %139 = load ptr, ptr %138, align 8, !tbaa !29
  %140 = load i32, ptr %13, align 4, !tbaa !26
  %141 = trunc i32 %140 to i16
  %142 = load ptr, ptr %10, align 8, !tbaa !5
  %143 = call i64 %134(ptr noundef %136, ptr noundef %139, i16 noundef zeroext %141, ptr noundef %142)
  store i64 %143, ptr %12, align 8, !tbaa !9
  %144 = load i64, ptr %12, align 8, !tbaa !9
  %145 = icmp slt i64 %144, 0
  br i1 %145, label %146, label %154

146:                                              ; preds = %129
  %147 = load i16, ptr %14, align 2, !tbaa !28
  %148 = zext i16 %147 to i32
  %149 = icmp ne i32 %148, 5
  br i1 %149, label %150, label %153

150:                                              ; preds = %146
  %151 = load ptr, ptr %9, align 8, !tbaa !5
  %152 = call i64 @Mtftp4SendError(ptr noundef %151, i16 noundef zeroext 8, ptr noundef @.str.2)
  br label %153

153:                                              ; preds = %150, %146
  store i64 -9223372036854775787, ptr %12, align 8, !tbaa !9
  br label %179

154:                                              ; preds = %129
  br label %155

155:                                              ; preds = %154, %125, %111
  %156 = load i16, ptr %14, align 2, !tbaa !28
  %157 = zext i16 %156 to i32
  switch i32 %157, label %177 [
    i32 4, label %158
    i32 6, label %167
    i32 5, label %176
  ]

158:                                              ; preds = %155
  %159 = load i32, ptr %13, align 4, !tbaa !26
  %160 = icmp ne i32 %159, 4
  br i1 %160, label %161, label %162

161:                                              ; preds = %158
  br label %179

162:                                              ; preds = %158
  %163 = load ptr, ptr %9, align 8, !tbaa !5
  %164 = load ptr, ptr %10, align 8, !tbaa !5
  %165 = load i32, ptr %13, align 4, !tbaa !26
  %166 = call i64 @Mtftp4WrqHandleAck(ptr noundef %163, ptr noundef %164, i32 noundef %165, ptr noundef %11)
  store i64 %166, ptr %12, align 8, !tbaa !9
  br label %178

167:                                              ; preds = %155
  %168 = load i32, ptr %13, align 4, !tbaa !26
  %169 = icmp ule i32 %168, 2
  br i1 %169, label %170, label %171

170:                                              ; preds = %167
  br label %179

171:                                              ; preds = %167
  %172 = load ptr, ptr %9, align 8, !tbaa !5
  %173 = load ptr, ptr %10, align 8, !tbaa !5
  %174 = load i32, ptr %13, align 4, !tbaa !26
  %175 = call i64 @Mtftp4WrqHandleOack(ptr noundef %172, ptr noundef %173, i32 noundef %174, ptr noundef %11)
  store i64 %175, ptr %12, align 8, !tbaa !9
  br label %178

176:                                              ; preds = %155
  store i64 -9223372036854775785, ptr %12, align 8, !tbaa !9
  br label %178

177:                                              ; preds = %155
  br label %178

178:                                              ; preds = %177, %176, %171, %162
  br label %179

179:                                              ; preds = %178, %170, %161, %153, %91, %69, %52, %34
  %180 = load ptr, ptr %10, align 8, !tbaa !5
  %181 = icmp ne ptr %180, null
  br i1 %181, label %182, label %189

182:                                              ; preds = %179
  %183 = load ptr, ptr %5, align 8, !tbaa !5
  %184 = getelementptr inbounds %struct.NET_BUF, ptr %183, i32 0, i32 8
  %185 = load i32, ptr %184, align 8, !tbaa !27
  %186 = icmp ugt i32 %185, 1
  br i1 %186, label %187, label %189

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

189:                                              ; preds = %187, %182, %179
  %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 !20
  %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._MTFTP4_PROTOCOL, ptr %201, i32 0, i32 18
  %203 = load ptr, ptr %202, align 8, !tbaa !32
  %204 = load ptr, ptr %9, align 8, !tbaa !5
  %205 = call i64 @UdpIoRecvDatagram(ptr noundef %203, ptr noundef @Mtftp4WrqInput, 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 !20
  %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 @Mtftp4CleanOperation(ptr noundef %214, i64 noundef %215)
  br label %216

216:                                              ; preds = %213, %209
  call void @llvm.lifetime.end.p0(i64 2, 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 @AllocatePool(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 @NetbufFree(ptr noundef) #1

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

declare void @Mtftp4CleanOperation(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 = !{!"_MTFTP4_PROTOCOL", !13, i64 0, !14, i64 8, !15, i64 24, !10, i64 88, !7, i64 96, !6, i64 104, !6, i64 112, !16, i64 120, !6, i64 152, !19, i64 160, !18, i64 180, !18, i64 182, !18, i64 184, !14, i64 192, !13, i64 208, !18, i64 212, !18, i64 214, !13, i64 216, !6, i64 224, !6, i64 232, !13, i64 240, !13, i64 244, !13, i64 248, !13, i64 252, !13, i64 256, !18, i64 260, !7, i64 262, !6, i64 264}
!13 = !{!"int", !7, i64 0}
!14 = !{!"_LIST_ENTRY", !6, i64 0, !6, i64 8}
!15 = !{!"_EFI_MTFTP4_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 = !{!"", !7, i64 0, !17, i64 1, !17, i64 5, !18, i64 10, !17, i64 12, !17, i64 16, !18, i64 20, !18, i64 22, !18, i64 24}
!17 = !{!"", !7, i64 0}
!18 = !{!"short", !7, i64 0}
!19 = !{!"", !18, i64 0, !7, i64 2, !13, i64 4, !13, i64 8, !18, i64 12, !7, i64 14, !13, i64 16}
!20 = !{!7, !7, 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, !18, i64 36}
!24 = !{!"", !7, i64 0, !18, i64 16, !7, i64 20, !18, i64 36}
!25 = !{!12, !18, i64 214}
!26 = !{!13, !13, i64 0}
!27 = !{!22, !13, i64 128}
!28 = !{!18, !18, i64 0}
!29 = !{!12, !6, i64 152}
!30 = !{!31, !6, i64 80}
!31 = !{!"_EFI_MTFTP4_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}
!32 = !{!12, !6, i64 224}


; 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 [154 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.7 = external hidden unnamed_addr constant [115 x i8], align 1
@.str.8 = 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 void @FreePool(ptr noundef) local_unnamed_addr #1

declare i64 @Mtftp4SendError(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 @Mtftp4WrqHandleAck(ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #2

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

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

7:                                                ; preds = %4
  %.not76 = icmp eq ptr %3, null
  br i1 %.not76, label %11, label %8

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

11:                                               ; preds = %8, %7
  tail call void @DebugAssert(ptr noundef nonnull @.str, i64 noundef 355, ptr noundef nonnull @.str.7) #3
  br label %12

12:                                               ; preds = %8, %11, %4
  store i8 0, ptr %5, align 1, !tbaa !18
  %13 = icmp slt i64 %2, 0
  br i1 %13, label %75, label %14

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

18:                                               ; preds = %14
  tail call void @DebugAssert(ptr noundef nonnull @.str, i64 noundef 366, ptr noundef nonnull @.str.8) #3
  br label %19

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

23:                                               ; preds = %19
  %24 = getelementptr inbounds i8, ptr %1, i64 36
  %25 = load i16, ptr %24, align 4, !tbaa !21
  %26 = getelementptr inbounds i8, ptr %3, i64 214
  %27 = load i16, ptr %26, align 2, !tbaa !23
  %.not77 = icmp eq i16 %25, %27
  br i1 %.not77, label %30, label %28

28:                                               ; preds = %23
  %.not78 = icmp eq i16 %27, 0
  br i1 %.not78, label %29, label %.thread92

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

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

34:                                               ; preds = %30
  %35 = zext i32 %21 to i64
  %36 = tail call ptr @AllocatePool(i64 noundef %35) #3
  %37 = icmp eq ptr %36, null
  br i1 %37, label %.thread92, label %38

38:                                               ; preds = %34
  %39 = tail call i32 @NetbufCopy(ptr noundef nonnull %0, i32 noundef 0, i32 noundef %21, ptr noundef nonnull %36) #3
  br label %46

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

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

46:                                               ; preds = %40, %45, %38
  %.0 = phi ptr [ %36, %38 ], [ %41, %40 ], [ null, %45 ]
  %47 = load i16, ptr %.0, align 1, !tbaa !18
  %48 = tail call zeroext i16 @SwapBytes16(i16 noundef zeroext %47) #3
  %49 = getelementptr inbounds i8, ptr %3, i64 152
  %50 = load ptr, ptr %49, align 8, !tbaa !25
  %51 = getelementptr inbounds i8, ptr %50, i64 80
  %52 = load ptr, ptr %51, align 8, !tbaa !26
  %.not79 = icmp ne ptr %52, null
  %53 = add i16 %48, -5
  %or.cond = icmp ult i16 %53, 2
  %or.cond84 = select i1 %.not79, i1 %or.cond, i1 false
  br i1 %or.cond84, label %54, label %62

54:                                               ; preds = %46
  %55 = getelementptr inbounds i8, ptr %3, i64 24
  %56 = trunc i32 %21 to i16
  %57 = tail call i64 %52(ptr noundef nonnull %55, ptr noundef nonnull %50, i16 noundef zeroext %56, ptr noundef nonnull %.0) #3
  %58 = icmp slt i64 %57, 0
  br i1 %58, label %59, label %62

59:                                               ; preds = %54
  %.not81 = icmp eq i16 %48, 5
  br i1 %.not81, label %71, label %60

60:                                               ; preds = %59
  %61 = tail call i64 @Mtftp4SendError(ptr noundef nonnull %3, i16 noundef zeroext 8, ptr noundef nonnull @.str.2) #3
  br label %71

62:                                               ; preds = %54, %46
  %.063 = phi i64 [ %57, %54 ], [ 0, %46 ]
  switch i16 %48, label %71 [
    i16 4, label %63
    i16 6, label %66
    i16 5, label %70
  ]

63:                                               ; preds = %62
  %.not80 = icmp eq i32 %21, 4
  br i1 %.not80, label %64, label %71

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

66:                                               ; preds = %62
  %67 = icmp eq i32 %21, 2
  br i1 %67, label %71, label %68

68:                                               ; preds = %66
  %69 = call i64 @Mtftp4WrqHandleOack(ptr noundef nonnull %3, ptr noundef nonnull %.0, i32 noundef %21, ptr noundef nonnull %5)
  br label %71

70:                                               ; preds = %62
  br label %71

71:                                               ; preds = %62, %70, %66, %68, %63, %64, %60, %59
  %.164.ph = phi i64 [ -9223372036854775787, %59 ], [ -9223372036854775787, %60 ], [ %65, %64 ], [ %.063, %63 ], [ %69, %68 ], [ %.063, %66 ], [ -9223372036854775785, %70 ], [ %.063, %62 ]
  %72 = load i32, ptr %31, align 8, !tbaa !24
  %73 = icmp ugt i32 %72, 1
  br i1 %73, label %74, label %.thread92

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

75:                                               ; preds = %12
  %.not83 = icmp eq ptr %0, null
  br i1 %.not83, label %.thread100, label %.thread92

.thread92:                                        ; preds = %71, %74, %34, %28, %19, %75
  %.1648995 = phi i64 [ %2, %75 ], [ -9223372036854775799, %34 ], [ 0, %28 ], [ 0, %19 ], [ %.164.ph, %71 ], [ %.164.ph, %74 ]
  call void @NetbufFree(ptr noundef nonnull %0) #3
  %76 = icmp slt i64 %.1648995, 0
  %77 = load i8, ptr %5, align 1
  %78 = icmp ne i8 %77, 0
  %or.cond4 = select i1 %76, i1 true, i1 %78
  br i1 %or.cond4, label %83, label %79

79:                                               ; preds = %.thread92
  %80 = getelementptr inbounds i8, ptr %3, i64 224
  %81 = load ptr, ptr %80, align 8, !tbaa !28
  %82 = call i64 @UdpIoRecvDatagram(ptr noundef %81, ptr noundef nonnull @Mtftp4WrqInput, ptr noundef %3, i32 noundef 0) #3
  %.pre = load i8, ptr %5, align 1
  br label %83

83:                                               ; preds = %79, %.thread92
  %84 = phi i8 [ %77, %.thread92 ], [ %.pre, %79 ]
  %.2 = phi i64 [ %.1648995, %.thread92 ], [ %82, %79 ]
  %85 = icmp slt i64 %.2, 0
  %86 = icmp ne i8 %84, 0
  %or.cond7 = select i1 %85, i1 true, i1 %86
  br i1 %or.cond7, label %.thread100, label %87

.thread100:                                       ; preds = %75, %83
  %.2103 = phi i64 [ %.2, %83 ], [ %2, %75 ]
  call void @Mtftp4CleanOperation(ptr noundef %3, i64 noundef %.2103) #3
  br label %87

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

declare ptr @AllocatePool(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 @NetbufFree(ptr noundef) local_unnamed_addr #1

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

declare void @Mtftp4CleanOperation(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, !7, i64 0}
!6 = !{!"_MTFTP4_PROTOCOL", !7, i64 0, !10, i64 8, !12, i64 24, !13, i64 88, !8, i64 96, !11, i64 104, !11, i64 112, !14, i64 120, !11, i64 152, !17, i64 160, !16, i64 180, !16, i64 182, !16, i64 184, !10, i64 192, !7, i64 208, !16, i64 212, !16, i64 214, !7, i64 216, !11, i64 224, !11, i64 232, !7, i64 240, !7, i64 244, !7, i64 248, !7, i64 252, !7, i64 256, !16, i64 260, !8, i64 262, !11, i64 264}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"_LIST_ENTRY", !11, i64 0, !11, i64 8}
!11 = !{!"any pointer", !8, i64 0}
!12 = !{!"_EFI_MTFTP4_PROTOCOL", !11, i64 0, !11, i64 8, !11, i64 16, !11, i64 24, !11, i64 32, !11, i64 40, !11, i64 48, !11, i64 56}
!13 = !{!"long long", !8, i64 0}
!14 = !{!"", !8, i64 0, !15, i64 1, !15, i64 5, !16, i64 10, !15, i64 12, !15, i64 16, !16, i64 20, !16, i64 22, !16, i64 24}
!15 = !{!"", !8, i64 0}
!16 = !{!"short", !8, i64 0}
!17 = !{!"", !16, i64 0, !8, i64 2, !7, i64 4, !7, i64 8, !16, i64 12, !8, i64 14, !7, i64 16}
!18 = !{!8, !8, i64 0}
!19 = !{!20, !7, i64 132}
!20 = !{!"", !7, i64 0, !13, i64 8, !10, i64 16, !8, i64 32, !11, i64 40, !11, i64 48, !8, i64 56, !11, i64 120, !7, i64 128, !7, i64 132, !8, i64 136}
!21 = !{!22, !16, i64 36}
!22 = !{!"", !8, i64 0, !16, i64 16, !8, i64 20, !16, i64 36}
!23 = !{!6, !16, i64 214}
!24 = !{!20, !7, i64 128}
!25 = !{!6, !11, i64 152}
!26 = !{!27, !11, i64 80}
!27 = !{!"_EFI_MTFTP4_TOKEN", !13, i64 0, !11, i64 8, !11, i64 16, !11, i64 24, !11, i64 32, !7, i64 40, !11, i64 48, !13, i64 56, !11, i64 64, !11, i64 72, !11, i64 80, !11, i64 88, !11, i64 96}
!28 = !{!6, !11, i64 224}


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