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

; 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.EFI_MTFTP4_DATA_HEADER = type <{ i16, i16, [1 x i8] }>
%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

; Function Attrs: nounwind uwtable
define dso_local i64 @Mtftp4WrqSendBlock(ptr noundef %0, i16 noundef zeroext %1) #0 {
  %3 = alloca i64, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i16, align 2
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca i64, align 8
  %10 = alloca i16, align 2
  %11 = alloca ptr, align 8
  %12 = alloca i64, align 8
  %13 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store i16 %1, ptr %5, align 2, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #3
  call void @llvm.lifetime.start.p0(i64 2, ptr %10) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #3
  %14 = load ptr, ptr %4, align 8, !tbaa !5
  %15 = getelementptr inbounds %struct._MTFTP4_PROTOCOL, ptr %14, i32 0, i32 11
  %16 = load i16, ptr %15, align 2, !tbaa !11
  %17 = zext i16 %16 to i32
  %18 = add nsw i32 %17, 4
  %19 = call ptr @NetbufAlloc(i32 noundef %18)
  store ptr %19, ptr %8, align 8, !tbaa !5
  %20 = load ptr, ptr %8, align 8, !tbaa !5
  %21 = icmp eq ptr %20, null
  br i1 %21, label %22, label %23

22:                                               ; preds = %2
  store i64 -9223372036854775799, ptr %3, align 8
  store i32 1, ptr %13, align 4
  br label %171

23:                                               ; preds = %2
  %24 = load ptr, ptr %8, align 8, !tbaa !5
  %25 = call ptr @NetbufAllocSpace(ptr noundef %24, i32 noundef 4, i8 noundef zeroext 0)
  store ptr %25, ptr %6, align 8, !tbaa !5
  br label %26

26:                                               ; preds = %23
  %27 = call zeroext i8 @DebugAssertEnabled()
  %28 = icmp ne i8 %27, 0
  br i1 %28, label %29, label %34

29:                                               ; preds = %26
  %30 = load ptr, ptr %6, align 8, !tbaa !5
  %31 = icmp ne ptr %30, null
  br i1 %31, label %33, label %32

32:                                               ; preds = %29
  call void @DebugAssert(ptr noundef @.str, i64 noundef 55, ptr noundef @.str.1)
  br label %33

33:                                               ; preds = %32, %29
  br label %34

34:                                               ; preds = %33, %26
  br label %35

35:                                               ; preds = %34
  br label %36

36:                                               ; preds = %35
  %37 = call zeroext i16 @SwapBytes16(i16 noundef zeroext 3)
  %38 = load ptr, ptr %6, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.EFI_MTFTP4_DATA_HEADER, ptr %38, i32 0, i32 0
  store i16 %37, ptr %39, align 1, !tbaa !20
  %40 = load i16, ptr %5, align 2, !tbaa !9
  %41 = call zeroext i16 @SwapBytes16(i16 noundef zeroext %40)
  %42 = load ptr, ptr %6, align 8, !tbaa !5
  %43 = getelementptr inbounds %struct.EFI_MTFTP4_DATA_HEADER, ptr %42, i32 0, i32 1
  store i16 %41, ptr %43, align 1, !tbaa !20
  %44 = load ptr, ptr %4, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct._MTFTP4_PROTOCOL, ptr %44, i32 0, i32 8
  %46 = load ptr, ptr %45, align 8, !tbaa !21
  store ptr %46, ptr %7, align 8, !tbaa !5
  %47 = load ptr, ptr %4, align 8, !tbaa !5
  %48 = getelementptr inbounds %struct._MTFTP4_PROTOCOL, ptr %47, i32 0, i32 11
  %49 = load i16, ptr %48, align 2, !tbaa !11
  store i16 %49, ptr %10, align 2, !tbaa !9
  %50 = load ptr, ptr %7, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct._EFI_MTFTP4_TOKEN, ptr %50, i32 0, i32 8
  %52 = load ptr, ptr %51, align 8, !tbaa !22
  %53 = icmp ne ptr %52, null
  br i1 %53, label %54, label %108

54:                                               ; preds = %36
  %55 = load i16, ptr %5, align 2, !tbaa !9
  %56 = zext i16 %55 to i32
  %57 = sub nsw i32 %56, 1
  %58 = sext i32 %57 to i64
  %59 = load ptr, ptr %4, align 8, !tbaa !5
  %60 = getelementptr inbounds %struct._MTFTP4_PROTOCOL, ptr %59, i32 0, i32 11
  %61 = load i16, ptr %60, align 2, !tbaa !11
  %62 = zext i16 %61 to i32
  %63 = call i64 @MultU64x32(i64 noundef %58, i32 noundef %62)
  store i64 %63, ptr %12, align 8, !tbaa !24
  %64 = load ptr, ptr %7, align 8, !tbaa !5
  %65 = getelementptr inbounds %struct._EFI_MTFTP4_TOKEN, ptr %64, i32 0, i32 7
  %66 = load i64, ptr %65, align 8, !tbaa !25
  %67 = load i64, ptr %12, align 8, !tbaa !24
  %68 = load ptr, ptr %4, align 8, !tbaa !5
  %69 = getelementptr inbounds %struct._MTFTP4_PROTOCOL, ptr %68, i32 0, i32 11
  %70 = load i16, ptr %69, align 2, !tbaa !11
  %71 = zext i16 %70 to i64
  %72 = add i64 %67, %71
  %73 = icmp ult i64 %66, %72
  br i1 %73, label %74, label %87

74:                                               ; preds = %54
  %75 = load ptr, ptr %7, align 8, !tbaa !5
  %76 = getelementptr inbounds %struct._EFI_MTFTP4_TOKEN, ptr %75, i32 0, i32 7
  %77 = load i64, ptr %76, align 8, !tbaa !25
  %78 = load i64, ptr %12, align 8, !tbaa !24
  %79 = sub i64 %77, %78
  %80 = trunc i64 %79 to i16
  store i16 %80, ptr %10, align 2, !tbaa !9
  %81 = load i16, ptr %5, align 2, !tbaa !9
  %82 = load ptr, ptr %4, align 8, !tbaa !5
  %83 = getelementptr inbounds %struct._MTFTP4_PROTOCOL, ptr %82, i32 0, i32 12
  store i16 %81, ptr %83, align 8, !tbaa !26
  %84 = load ptr, ptr %4, align 8, !tbaa !5
  %85 = getelementptr inbounds %struct._MTFTP4_PROTOCOL, ptr %84, i32 0, i32 13
  %86 = load i16, ptr %5, align 2, !tbaa !9
  call void @Mtftp4SetLastBlockNum(ptr noundef %85, i16 noundef zeroext %86)
  br label %87

87:                                               ; preds = %74, %54
  %88 = load i16, ptr %10, align 2, !tbaa !9
  %89 = zext i16 %88 to i32
  %90 = icmp sgt i32 %89, 0
  br i1 %90, label %91, label %107

91:                                               ; preds = %87
  %92 = load ptr, ptr %8, align 8, !tbaa !5
  %93 = load i16, ptr %10, align 2, !tbaa !9
  %94 = zext i16 %93 to i32
  %95 = call ptr @NetbufAllocSpace(ptr noundef %92, i32 noundef %94, i8 noundef zeroext 0)
  %96 = load ptr, ptr %6, align 8, !tbaa !5
  %97 = getelementptr inbounds %struct.EFI_MTFTP4_DATA_HEADER, ptr %96, i32 0, i32 2
  %98 = getelementptr inbounds [1 x i8], ptr %97, i64 0, i64 0
  %99 = load ptr, ptr %7, align 8, !tbaa !5
  %100 = getelementptr inbounds %struct._EFI_MTFTP4_TOKEN, ptr %99, i32 0, i32 8
  %101 = load ptr, ptr %100, align 8, !tbaa !22
  %102 = load i64, ptr %12, align 8, !tbaa !24
  %103 = getelementptr inbounds i8, ptr %101, i64 %102
  %104 = load i16, ptr %10, align 2, !tbaa !9
  %105 = zext i16 %104 to i64
  %106 = call ptr @CopyMem(ptr noundef %98, ptr noundef %103, i64 noundef %105)
  br label %107

107:                                              ; preds = %91, %87
  br label %167

108:                                              ; preds = %36
  store ptr null, ptr %11, align 8, !tbaa !5
  %109 = load ptr, ptr %7, align 8, !tbaa !5
  %110 = getelementptr inbounds %struct._EFI_MTFTP4_TOKEN, ptr %109, i32 0, i32 12
  %111 = load ptr, ptr %110, align 8, !tbaa !27
  %112 = load ptr, ptr %4, align 8, !tbaa !5
  %113 = getelementptr inbounds %struct._MTFTP4_PROTOCOL, ptr %112, i32 0, i32 2
  %114 = load ptr, ptr %7, align 8, !tbaa !5
  %115 = call i64 %111(ptr noundef %113, ptr noundef %114, ptr noundef %10, ptr noundef %11)
  store i64 %115, ptr %9, align 8, !tbaa !24
  %116 = load i64, ptr %9, align 8, !tbaa !24
  %117 = icmp slt i64 %116, 0
  br i1 %117, label %126, label %118

118:                                              ; preds = %108
  %119 = load i16, ptr %10, align 2, !tbaa !9
  %120 = zext i16 %119 to i32
  %121 = load ptr, ptr %4, align 8, !tbaa !5
  %122 = getelementptr inbounds %struct._MTFTP4_PROTOCOL, ptr %121, i32 0, i32 11
  %123 = load i16, ptr %122, align 2, !tbaa !11
  %124 = zext i16 %123 to i32
  %125 = icmp sgt i32 %120, %124
  br i1 %125, label %126, label %134

126:                                              ; preds = %118, %108
  %127 = load ptr, ptr %11, align 8, !tbaa !5
  %128 = icmp ne ptr %127, null
  br i1 %128, label %129, label %131

129:                                              ; preds = %126
  %130 = load ptr, ptr %11, align 8, !tbaa !5
  call void @FreePool(ptr noundef %130)
  br label %131

131:                                              ; preds = %129, %126
  %132 = load ptr, ptr %4, align 8, !tbaa !5
  %133 = call i64 @Mtftp4SendError(ptr noundef %132, i16 noundef zeroext 8, ptr noundef @.str.2)
  store i64 -9223372036854775787, ptr %3, align 8
  store i32 1, ptr %13, align 4
  br label %171

134:                                              ; preds = %118
  %135 = load i16, ptr %10, align 2, !tbaa !9
  %136 = zext i16 %135 to i32
  %137 = load ptr, ptr %4, align 8, !tbaa !5
  %138 = getelementptr inbounds %struct._MTFTP4_PROTOCOL, ptr %137, i32 0, i32 11
  %139 = load i16, ptr %138, align 2, !tbaa !11
  %140 = zext i16 %139 to i32
  %141 = icmp slt i32 %136, %140
  br i1 %141, label %142, label %149

142:                                              ; preds = %134
  %143 = load i16, ptr %5, align 2, !tbaa !9
  %144 = load ptr, ptr %4, align 8, !tbaa !5
  %145 = getelementptr inbounds %struct._MTFTP4_PROTOCOL, ptr %144, i32 0, i32 12
  store i16 %143, ptr %145, align 8, !tbaa !26
  %146 = load ptr, ptr %4, align 8, !tbaa !5
  %147 = getelementptr inbounds %struct._MTFTP4_PROTOCOL, ptr %146, i32 0, i32 13
  %148 = load i16, ptr %5, align 2, !tbaa !9
  call void @Mtftp4SetLastBlockNum(ptr noundef %147, i16 noundef zeroext %148)
  br label %149

149:                                              ; preds = %142, %134
  %150 = load i16, ptr %10, align 2, !tbaa !9
  %151 = zext i16 %150 to i32
  %152 = icmp sgt i32 %151, 0
  br i1 %152, label %153, label %166

153:                                              ; preds = %149
  %154 = load ptr, ptr %8, align 8, !tbaa !5
  %155 = load i16, ptr %10, align 2, !tbaa !9
  %156 = zext i16 %155 to i32
  %157 = call ptr @NetbufAllocSpace(ptr noundef %154, i32 noundef %156, i8 noundef zeroext 0)
  %158 = load ptr, ptr %6, align 8, !tbaa !5
  %159 = getelementptr inbounds %struct.EFI_MTFTP4_DATA_HEADER, ptr %158, i32 0, i32 2
  %160 = getelementptr inbounds [1 x i8], ptr %159, i64 0, i64 0
  %161 = load ptr, ptr %11, align 8, !tbaa !5
  %162 = load i16, ptr %10, align 2, !tbaa !9
  %163 = zext i16 %162 to i64
  %164 = call ptr @CopyMem(ptr noundef %160, ptr noundef %161, i64 noundef %163)
  %165 = load ptr, ptr %11, align 8, !tbaa !5
  call void @FreePool(ptr noundef %165)
  br label %166

166:                                              ; preds = %153, %149
  br label %167

167:                                              ; preds = %166, %107
  %168 = load ptr, ptr %4, align 8, !tbaa !5
  %169 = load ptr, ptr %8, align 8, !tbaa !5
  %170 = call i64 @Mtftp4SendPacket(ptr noundef %168, ptr noundef %169)
  store i64 %170, ptr %3, align 8
  store i32 1, ptr %13, align 4
  br label %171

171:                                              ; preds = %167, %131, %22
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #3
  call void @llvm.lifetime.end.p0(i64 2, ptr %10) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #3
  %172 = load i64, ptr %3, align 8
  ret i64 %172
}

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

declare ptr @NetbufAlloc(i32 noundef) #2

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

declare zeroext i8 @DebugAssertEnabled() #2

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

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

declare i64 @MultU64x32(i64 noundef, i32 noundef) #2

declare void @Mtftp4SetLastBlockNum(ptr noundef, i16 noundef zeroext) #2

declare ptr @CopyMem(ptr noundef, ptr noundef, i64 noundef) #2

declare void @FreePool(ptr noundef) #2

declare i64 @Mtftp4SendError(ptr noundef, i16 noundef zeroext, ptr noundef) #2

declare i64 @Mtftp4SendPacket(ptr noundef, ptr noundef) #2

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

attributes #0 = { 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 #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { "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 = !{!"short", !7, i64 0}
!11 = !{!12, !10, i64 182}
!12 = !{!"_MTFTP4_PROTOCOL", !13, i64 0, !14, i64 8, !15, i64 24, !16, i64 88, !7, i64 96, !6, i64 104, !6, i64 112, !17, i64 120, !6, i64 152, !19, i64 160, !10, i64 180, !10, i64 182, !10, i64 184, !14, i64 192, !13, i64 208, !10, i64 212, !10, 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, !10, 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 = !{!"long long", !7, i64 0}
!17 = !{!"", !7, i64 0, !18, i64 1, !18, i64 5, !10, i64 10, !18, i64 12, !18, i64 16, !10, i64 20, !10, i64 22, !10, i64 24}
!18 = !{!"", !7, i64 0}
!19 = !{!"", !10, i64 0, !7, i64 2, !13, i64 4, !13, i64 8, !10, i64 12, !7, i64 14, !13, i64 16}
!20 = !{!7, !7, i64 0}
!21 = !{!12, !6, i64 152}
!22 = !{!23, !6, i64 64}
!23 = !{!"_EFI_MTFTP4_TOKEN", !16, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !13, i64 40, !6, i64 48, !16, i64 56, !6, i64 64, !6, i64 72, !6, i64 80, !6, i64 88, !6, i64 96}
!24 = !{!16, !16, i64 0}
!25 = !{!23, !16, i64 56}
!26 = !{!12, !10, i64 184}
!27 = !{!23, !6, i64 96}


; 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

; Function Attrs: nounwind uwtable
define dso_local i64 @Mtftp4WrqSendBlock(ptr noundef %0, i16 noundef zeroext %1) local_unnamed_addr #0 {
  %3 = alloca i16, align 2
  %4 = alloca ptr, align 8
  call void @llvm.lifetime.start.p0(i64 2, ptr nonnull %3) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #3
  %5 = getelementptr inbounds i8, ptr %0, i64 182
  %6 = load i16, ptr %5, align 2, !tbaa !5
  %7 = zext i16 %6 to i32
  %8 = add nuw nsw i32 %7, 4
  %9 = tail call ptr @NetbufAlloc(i32 noundef %8) #3
  %10 = icmp eq ptr %9, null
  br i1 %10, label %85, label %11

11:                                               ; preds = %2
  %12 = tail call ptr @NetbufAllocSpace(ptr noundef nonnull %9, i32 noundef 4, i8 noundef zeroext 0) #3
  %13 = tail call zeroext i8 @DebugAssertEnabled() #3
  %14 = icmp eq i8 %13, 0
  %15 = icmp ne ptr %12, null
  %or.cond = select i1 %14, i1 true, i1 %15
  br i1 %or.cond, label %17, label %16

16:                                               ; preds = %11
  tail call void @DebugAssert(ptr noundef nonnull @.str, i64 noundef 55, ptr noundef nonnull @.str.1) #3
  br label %17

17:                                               ; preds = %16, %11
  %18 = tail call zeroext i16 @SwapBytes16(i16 noundef zeroext 3) #3
  store i16 %18, ptr %12, align 1, !tbaa !18
  %19 = tail call zeroext i16 @SwapBytes16(i16 noundef zeroext %1) #3
  %20 = getelementptr inbounds i8, ptr %12, i64 2
  store i16 %19, ptr %20, align 1, !tbaa !18
  %21 = getelementptr inbounds i8, ptr %0, i64 152
  %22 = load ptr, ptr %21, align 8, !tbaa !19
  %23 = load i16, ptr %5, align 2, !tbaa !5
  store i16 %23, ptr %3, align 2, !tbaa !20
  %24 = getelementptr inbounds i8, ptr %22, i64 64
  %25 = load ptr, ptr %24, align 8, !tbaa !21
  %.not = icmp eq ptr %25, null
  br i1 %.not, label %52, label %26

26:                                               ; preds = %17
  %27 = zext i16 %1 to i64
  %28 = add nsw i64 %27, -1
  %29 = zext i16 %23 to i32
  %30 = tail call i64 @MultU64x32(i64 noundef %28, i32 noundef %29) #3
  %31 = getelementptr inbounds i8, ptr %22, i64 56
  %32 = load i64, ptr %31, align 8, !tbaa !23
  %33 = load i16, ptr %5, align 2, !tbaa !5
  %34 = zext i16 %33 to i64
  %35 = add i64 %30, %34
  %36 = icmp ult i64 %32, %35
  br i1 %36, label %37, label %42

37:                                               ; preds = %26
  %38 = sub i64 %32, %30
  %39 = trunc i64 %38 to i16
  store i16 %39, ptr %3, align 2, !tbaa !20
  %40 = getelementptr inbounds i8, ptr %0, i64 184
  store i16 %1, ptr %40, align 8, !tbaa !24
  %41 = getelementptr inbounds i8, ptr %0, i64 192
  tail call void @Mtftp4SetLastBlockNum(ptr noundef nonnull %41, i16 noundef zeroext %1) #3
  br label %42

42:                                               ; preds = %37, %26
  %43 = phi i16 [ %39, %37 ], [ %23, %26 ]
  %.not50 = icmp eq i16 %43, 0
  br i1 %.not50, label %83, label %44

44:                                               ; preds = %42
  %45 = zext i16 %43 to i32
  %46 = tail call ptr @NetbufAllocSpace(ptr noundef nonnull %9, i32 noundef %45, i8 noundef zeroext 0) #3
  %47 = getelementptr inbounds i8, ptr %12, i64 4
  %48 = load ptr, ptr %24, align 8, !tbaa !21
  %49 = getelementptr inbounds i8, ptr %48, i64 %30
  %50 = zext i16 %43 to i64
  %51 = tail call ptr @CopyMem(ptr noundef nonnull %47, ptr noundef %49, i64 noundef %50) #3
  br label %83

52:                                               ; preds = %17
  store ptr null, ptr %4, align 8, !tbaa !25
  %53 = getelementptr inbounds i8, ptr %22, i64 96
  %54 = load ptr, ptr %53, align 8, !tbaa !26
  %55 = getelementptr inbounds i8, ptr %0, i64 24
  %56 = call i64 %54(ptr noundef nonnull %55, ptr noundef nonnull %22, ptr noundef nonnull %3, ptr noundef nonnull %4) #3
  %57 = icmp slt i64 %56, 0
  br i1 %57, label %62, label %58

58:                                               ; preds = %52
  %59 = load i16, ptr %3, align 2, !tbaa !20
  %60 = load i16, ptr %5, align 2, !tbaa !5
  %61 = icmp ugt i16 %59, %60
  br i1 %61, label %62, label %67

62:                                               ; preds = %58, %52
  %63 = load ptr, ptr %4, align 8, !tbaa !25
  %.not49 = icmp eq ptr %63, null
  br i1 %.not49, label %65, label %64

64:                                               ; preds = %62
  call void @FreePool(ptr noundef nonnull %63) #3
  br label %65

65:                                               ; preds = %64, %62
  %66 = call i64 @Mtftp4SendError(ptr noundef nonnull %0, i16 noundef zeroext 8, ptr noundef nonnull @.str.2) #3
  br label %85

67:                                               ; preds = %58
  %68 = icmp ult i16 %59, %60
  br i1 %68, label %69, label %72

69:                                               ; preds = %67
  %70 = getelementptr inbounds i8, ptr %0, i64 184
  store i16 %1, ptr %70, align 8, !tbaa !24
  %71 = getelementptr inbounds i8, ptr %0, i64 192
  call void @Mtftp4SetLastBlockNum(ptr noundef nonnull %71, i16 noundef zeroext %1) #3
  %.pr = load i16, ptr %3, align 2, !tbaa !20
  br label %72

72:                                               ; preds = %69, %67
  %73 = phi i16 [ %.pr, %69 ], [ %59, %67 ]
  %.not48 = icmp eq i16 %73, 0
  br i1 %.not48, label %83, label %74

74:                                               ; preds = %72
  %75 = zext i16 %73 to i32
  %76 = call ptr @NetbufAllocSpace(ptr noundef nonnull %9, i32 noundef %75, i8 noundef zeroext 0) #3
  %77 = getelementptr inbounds i8, ptr %12, i64 4
  %78 = load ptr, ptr %4, align 8, !tbaa !25
  %79 = load i16, ptr %3, align 2, !tbaa !20
  %80 = zext i16 %79 to i64
  %81 = call ptr @CopyMem(ptr noundef nonnull %77, ptr noundef %78, i64 noundef %80) #3
  %82 = load ptr, ptr %4, align 8, !tbaa !25
  call void @FreePool(ptr noundef %82) #3
  br label %83

83:                                               ; preds = %72, %74, %42, %44
  %84 = call i64 @Mtftp4SendPacket(ptr noundef nonnull %0, ptr noundef nonnull %9) #3
  br label %85

85:                                               ; preds = %2, %83, %65
  %.0 = phi i64 [ %84, %83 ], [ -9223372036854775787, %65 ], [ -9223372036854775799, %2 ]
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #3
  call void @llvm.lifetime.end.p0(i64 2, ptr nonnull %3) #3
  ret i64 %.0
}

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

declare ptr @NetbufAlloc(i32 noundef) local_unnamed_addr #2

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

declare zeroext i8 @DebugAssertEnabled() local_unnamed_addr #2

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

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

declare i64 @MultU64x32(i64 noundef, i32 noundef) local_unnamed_addr #2

declare void @Mtftp4SetLastBlockNum(ptr noundef, i16 noundef zeroext) local_unnamed_addr #2

declare ptr @CopyMem(ptr noundef, ptr noundef, i64 noundef) local_unnamed_addr #2

declare void @FreePool(ptr noundef) local_unnamed_addr #2

declare i64 @Mtftp4SendError(ptr noundef, i16 noundef zeroext, ptr noundef) local_unnamed_addr #2

declare i64 @Mtftp4SendPacket(ptr noundef, ptr noundef) local_unnamed_addr #2

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

attributes #0 = { 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 #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { "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, !16, i64 182}
!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 = !{!6, !11, i64 152}
!20 = !{!16, !16, i64 0}
!21 = !{!22, !11, i64 64}
!22 = !{!"_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}
!23 = !{!22, !13, i64 56}
!24 = !{!6, !16, i64 184}
!25 = !{!11, !11, i64 0}
!26 = !{!22, !11, i64 96}


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