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

; 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.EFI_UDP4_COMPLETION_TOKEN = type { ptr, i64, %union.anon.4 }
%union.anon.4 = type { ptr }
%struct.EFI_UDP4_TRANSMIT_DATA = type { ptr, ptr, i32, i32, [1 x %struct.EFI_UDP4_FRAGMENT_DATA] }
%struct.EFI_UDP4_FRAGMENT_DATA = type { i32, ptr }
%struct.EFI_BOOT_SERVICES = type { %struct.EFI_TABLE_HEADER, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr }
%struct.EFI_TABLE_HEADER = type { i64, i32, i32, i32, i32 }
%struct._EFI_UDP4_PROTOCOL = type { ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr }

@gBS = external global ptr, align 8

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

; 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 void @PxeBcCommonNotify(ptr noundef, ptr noundef) #1

; Function Attrs: nounwind uwtable
define dso_local i64 @PxeBcUdp4Write(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3, ptr noundef %4, ptr noundef %5, ptr noundef %6, ptr noundef %7) #1 {
  %9 = alloca i64, align 8
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  %13 = alloca ptr, align 8
  %14 = alloca ptr, align 8
  %15 = alloca ptr, align 8
  %16 = alloca ptr, align 8
  %17 = alloca ptr, align 8
  %18 = alloca %struct.EFI_UDP4_COMPLETION_TOKEN, align 8
  %19 = alloca ptr, align 8
  %20 = alloca i32, align 4
  %21 = alloca i32, align 4
  %22 = alloca i32, align 4
  %23 = alloca i8, align 1
  %24 = alloca i64, align 8
  %25 = alloca i32, align 4
  store ptr %0, ptr %10, align 8, !tbaa !5
  store ptr %1, ptr %11, align 8, !tbaa !5
  store ptr %2, ptr %12, align 8, !tbaa !5
  store ptr %3, ptr %13, align 8, !tbaa !5
  store ptr %4, ptr %14, align 8, !tbaa !5
  store ptr %5, ptr %15, align 8, !tbaa !5
  store ptr %6, ptr %16, align 8, !tbaa !5
  store ptr %7, ptr %17, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 24, ptr %18) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %19) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %20) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %21) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %22) #3
  call void @llvm.lifetime.start.p0(i64 1, ptr %23) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %24) #3
  %26 = load ptr, ptr %14, align 8, !tbaa !5
  %27 = icmp ne ptr %26, null
  %28 = zext i1 %27 to i64
  %29 = select i1 %27, i32 2, i32 1
  store i32 %29, ptr %21, align 4, !tbaa !9
  %30 = load i32, ptr %21, align 4, !tbaa !9
  %31 = sub i32 %30, 1
  %32 = zext i32 %31 to i64
  %33 = mul i64 %32, 16
  %34 = add i64 40, %33
  %35 = trunc i64 %34 to i32
  store i32 %35, ptr %20, align 4, !tbaa !9
  %36 = load i32, ptr %20, align 4, !tbaa !9
  %37 = zext i32 %36 to i64
  %38 = call ptr @AllocateZeroPool(i64 noundef %37)
  store ptr %38, ptr %19, align 8, !tbaa !5
  %39 = load ptr, ptr %19, align 8, !tbaa !5
  %40 = icmp eq ptr %39, null
  br i1 %40, label %41, label %42

41:                                               ; preds = %8
  store i64 -9223372036854775799, ptr %9, align 8
  store i32 1, ptr %25, align 4
  br label %168

42:                                               ; preds = %8
  %43 = load i32, ptr %21, align 4, !tbaa !9
  %44 = load ptr, ptr %19, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct.EFI_UDP4_TRANSMIT_DATA, ptr %44, i32 0, i32 3
  store i32 %43, ptr %45, align 4, !tbaa !11
  %46 = load ptr, ptr %16, align 8, !tbaa !5
  %47 = load i64, ptr %46, align 8, !tbaa !13
  %48 = trunc i64 %47 to i32
  %49 = load ptr, ptr %19, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct.EFI_UDP4_TRANSMIT_DATA, ptr %49, i32 0, i32 4
  %51 = load i32, ptr %21, align 4, !tbaa !9
  %52 = sub i32 %51, 1
  %53 = zext i32 %52 to i64
  %54 = getelementptr inbounds [1 x %struct.EFI_UDP4_FRAGMENT_DATA], ptr %50, i64 0, i64 %53
  %55 = getelementptr inbounds %struct.EFI_UDP4_FRAGMENT_DATA, ptr %54, i32 0, i32 0
  store i32 %48, ptr %55, align 8, !tbaa !15
  %56 = load ptr, ptr %17, align 8, !tbaa !5
  %57 = load ptr, ptr %19, align 8, !tbaa !5
  %58 = getelementptr inbounds %struct.EFI_UDP4_TRANSMIT_DATA, ptr %57, i32 0, i32 4
  %59 = load i32, ptr %21, align 4, !tbaa !9
  %60 = sub i32 %59, 1
  %61 = zext i32 %60 to i64
  %62 = getelementptr inbounds [1 x %struct.EFI_UDP4_FRAGMENT_DATA], ptr %58, i64 0, i64 %61
  %63 = getelementptr inbounds %struct.EFI_UDP4_FRAGMENT_DATA, ptr %62, i32 0, i32 1
  store ptr %56, ptr %63, align 8, !tbaa !17
  %64 = load ptr, ptr %16, align 8, !tbaa !5
  %65 = load i64, ptr %64, align 8, !tbaa !13
  %66 = trunc i64 %65 to i32
  store i32 %66, ptr %22, align 4, !tbaa !9
  %67 = load ptr, ptr %14, align 8, !tbaa !5
  %68 = icmp ne ptr %67, null
  br i1 %68, label %69, label %87

69:                                               ; preds = %42
  %70 = load ptr, ptr %14, align 8, !tbaa !5
  %71 = load i64, ptr %70, align 8, !tbaa !13
  %72 = trunc i64 %71 to i32
  %73 = load ptr, ptr %19, align 8, !tbaa !5
  %74 = getelementptr inbounds %struct.EFI_UDP4_TRANSMIT_DATA, ptr %73, i32 0, i32 4
  %75 = getelementptr inbounds [1 x %struct.EFI_UDP4_FRAGMENT_DATA], ptr %74, i64 0, i64 0
  %76 = getelementptr inbounds %struct.EFI_UDP4_FRAGMENT_DATA, ptr %75, i32 0, i32 0
  store i32 %72, ptr %76, align 8, !tbaa !15
  %77 = load ptr, ptr %15, align 8, !tbaa !5
  %78 = load ptr, ptr %19, align 8, !tbaa !5
  %79 = getelementptr inbounds %struct.EFI_UDP4_TRANSMIT_DATA, ptr %78, i32 0, i32 4
  %80 = getelementptr inbounds [1 x %struct.EFI_UDP4_FRAGMENT_DATA], ptr %79, i64 0, i64 0
  %81 = getelementptr inbounds %struct.EFI_UDP4_FRAGMENT_DATA, ptr %80, i32 0, i32 1
  store ptr %77, ptr %81, align 8, !tbaa !17
  %82 = load ptr, ptr %14, align 8, !tbaa !5
  %83 = load i64, ptr %82, align 8, !tbaa !13
  %84 = trunc i64 %83 to i32
  %85 = load i32, ptr %22, align 4, !tbaa !9
  %86 = add i32 %85, %84
  store i32 %86, ptr %22, align 4, !tbaa !9
  br label %87

87:                                               ; preds = %69, %42
  %88 = load ptr, ptr %13, align 8, !tbaa !5
  %89 = icmp ne ptr %88, null
  br i1 %89, label %90, label %94

90:                                               ; preds = %87
  %91 = load ptr, ptr %13, align 8, !tbaa !5
  %92 = load ptr, ptr %19, align 8, !tbaa !5
  %93 = getelementptr inbounds %struct.EFI_UDP4_TRANSMIT_DATA, ptr %92, i32 0, i32 1
  store ptr %91, ptr %93, align 8, !tbaa !18
  br label %94

94:                                               ; preds = %90, %87
  %95 = load ptr, ptr %11, align 8, !tbaa !5
  %96 = load ptr, ptr %19, align 8, !tbaa !5
  %97 = getelementptr inbounds %struct.EFI_UDP4_TRANSMIT_DATA, ptr %96, i32 0, i32 0
  store ptr %95, ptr %97, align 8, !tbaa !19
  %98 = load i32, ptr %22, align 4, !tbaa !9
  %99 = load ptr, ptr %19, align 8, !tbaa !5
  %100 = getelementptr inbounds %struct.EFI_UDP4_TRANSMIT_DATA, ptr %99, i32 0, i32 2
  store i32 %98, ptr %100, align 8, !tbaa !20
  %101 = load ptr, ptr %19, align 8, !tbaa !5
  %102 = getelementptr inbounds %struct.EFI_UDP4_COMPLETION_TOKEN, ptr %18, i32 0, i32 2
  store ptr %101, ptr %102, align 8, !tbaa !21
  %103 = getelementptr inbounds %struct.EFI_UDP4_COMPLETION_TOKEN, ptr %18, i32 0, i32 1
  store i64 -9223372036854775802, ptr %103, align 8, !tbaa !22
  store i8 0, ptr %23, align 1, !tbaa !21
  %104 = load ptr, ptr @gBS, align 8, !tbaa !5
  %105 = getelementptr inbounds %struct.EFI_BOOT_SERVICES, ptr %104, i32 0, i32 8
  %106 = load ptr, ptr %105, align 8, !tbaa !24
  %107 = getelementptr inbounds %struct.EFI_UDP4_COMPLETION_TOKEN, ptr %18, i32 0, i32 0
  %108 = call i64 %106(i32 noundef 512, i64 noundef 16, ptr noundef @PxeBcCommonNotify, ptr noundef %23, ptr noundef %107)
  store i64 %108, ptr %24, align 8, !tbaa !13
  %109 = load i64, ptr %24, align 8, !tbaa !13
  %110 = icmp slt i64 %109, 0
  br i1 %110, label %111, label %112

111:                                              ; preds = %94
  br label %154

112:                                              ; preds = %94
  %113 = load ptr, ptr %10, align 8, !tbaa !5
  %114 = getelementptr inbounds %struct._EFI_UDP4_PROTOCOL, ptr %113, i32 0, i32 4
  %115 = load ptr, ptr %114, align 8, !tbaa !27
  %116 = load ptr, ptr %10, align 8, !tbaa !5
  %117 = call i64 %115(ptr noundef %116, ptr noundef %18)
  store i64 %117, ptr %24, align 8, !tbaa !13
  %118 = load i64, ptr %24, align 8, !tbaa !13
  %119 = icmp slt i64 %118, 0
  br i1 %119, label %120, label %121

120:                                              ; preds = %112
  br label %154

121:                                              ; preds = %112
  br label %122

122:                                              ; preds = %138, %121
  %123 = load i8, ptr %23, align 1, !tbaa !21
  %124 = icmp ne i8 %123, 0
  br i1 %124, label %136, label %125

125:                                              ; preds = %122
  %126 = getelementptr inbounds %struct.EFI_UDP4_COMPLETION_TOKEN, ptr %18, i32 0, i32 1
  %127 = load i64, ptr %126, align 8, !tbaa !22
  %128 = icmp eq i64 %127, -9223372036854775802
  br i1 %128, label %129, label %136

129:                                              ; preds = %125
  %130 = load ptr, ptr @gBS, align 8, !tbaa !5
  %131 = getelementptr inbounds %struct.EFI_BOOT_SERVICES, ptr %130, i32 0, i32 13
  %132 = load ptr, ptr %131, align 8, !tbaa !29
  %133 = load ptr, ptr %12, align 8, !tbaa !5
  %134 = call i64 %132(ptr noundef %133)
  %135 = icmp slt i64 %134, 0
  br label %136

136:                                              ; preds = %129, %125, %122
  %137 = phi i1 [ false, %125 ], [ false, %122 ], [ %135, %129 ]
  br i1 %137, label %138, label %144

138:                                              ; preds = %136
  %139 = load ptr, ptr %10, align 8, !tbaa !5
  %140 = getelementptr inbounds %struct._EFI_UDP4_PROTOCOL, ptr %139, i32 0, i32 7
  %141 = load ptr, ptr %140, align 8, !tbaa !30
  %142 = load ptr, ptr %10, align 8, !tbaa !5
  %143 = call i64 %141(ptr noundef %142)
  br label %122, !llvm.loop !31

144:                                              ; preds = %136
  %145 = getelementptr inbounds %struct.EFI_UDP4_COMPLETION_TOKEN, ptr %18, i32 0, i32 1
  %146 = load i64, ptr %145, align 8, !tbaa !22
  %147 = icmp eq i64 %146, -9223372036854775802
  br i1 %147, label %148, label %149

148:                                              ; preds = %144
  br label %152

149:                                              ; preds = %144
  %150 = getelementptr inbounds %struct.EFI_UDP4_COMPLETION_TOKEN, ptr %18, i32 0, i32 1
  %151 = load i64, ptr %150, align 8, !tbaa !22
  br label %152

152:                                              ; preds = %149, %148
  %153 = phi i64 [ -9223372036854775790, %148 ], [ %151, %149 ]
  store i64 %153, ptr %24, align 8, !tbaa !13
  br label %154

154:                                              ; preds = %152, %120, %111
  %155 = getelementptr inbounds %struct.EFI_UDP4_COMPLETION_TOKEN, ptr %18, i32 0, i32 0
  %156 = load ptr, ptr %155, align 8, !tbaa !33
  %157 = icmp ne ptr %156, null
  br i1 %157, label %158, label %165

158:                                              ; preds = %154
  %159 = load ptr, ptr @gBS, align 8, !tbaa !5
  %160 = getelementptr inbounds %struct.EFI_BOOT_SERVICES, ptr %159, i32 0, i32 12
  %161 = load ptr, ptr %160, align 8, !tbaa !34
  %162 = getelementptr inbounds %struct.EFI_UDP4_COMPLETION_TOKEN, ptr %18, i32 0, i32 0
  %163 = load ptr, ptr %162, align 8, !tbaa !33
  %164 = call i64 %161(ptr noundef %163)
  br label %165

165:                                              ; preds = %158, %154
  %166 = load ptr, ptr %19, align 8, !tbaa !5
  call void @FreePool(ptr noundef %166)
  %167 = load i64, ptr %24, align 8, !tbaa !13
  store i64 %167, ptr %9, align 8
  store i32 1, ptr %25, align 4
  br label %168

168:                                              ; preds = %165, %41
  call void @llvm.lifetime.end.p0(i64 8, ptr %24) #3
  call void @llvm.lifetime.end.p0(i64 1, ptr %23) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %22) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %21) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %20) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %19) #3
  call void @llvm.lifetime.end.p0(i64 24, ptr %18) #3
  %169 = load i64, ptr %9, align 8
  ret i64 %169
}

declare ptr @AllocateZeroPool(i64 noundef) #2

declare void @FreePool(ptr noundef) #2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #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 = !{!"int", !7, i64 0}
!11 = !{!12, !10, i64 20}
!12 = !{!"", !6, i64 0, !6, i64 8, !10, i64 16, !10, i64 20, !7, i64 24}
!13 = !{!14, !14, i64 0}
!14 = !{!"long long", !7, i64 0}
!15 = !{!16, !10, i64 0}
!16 = !{!"", !10, i64 0, !6, i64 8}
!17 = !{!16, !6, i64 8}
!18 = !{!12, !6, i64 8}
!19 = !{!12, !6, i64 0}
!20 = !{!12, !10, i64 16}
!21 = !{!7, !7, i64 0}
!22 = !{!23, !14, i64 8}
!23 = !{!"", !6, i64 0, !14, i64 8, !7, i64 16}
!24 = !{!25, !6, i64 80}
!25 = !{!"", !26, i64 0, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !6, i64 56, !6, i64 64, !6, i64 72, !6, i64 80, !6, i64 88, !6, i64 96, !6, i64 104, !6, i64 112, !6, i64 120, !6, i64 128, !6, i64 136, !6, i64 144, !6, i64 152, !6, i64 160, !6, i64 168, !6, i64 176, !6, i64 184, !6, i64 192, !6, i64 200, !6, i64 208, !6, i64 216, !6, i64 224, !6, i64 232, !6, i64 240, !6, i64 248, !6, i64 256, !6, i64 264, !6, i64 272, !6, i64 280, !6, i64 288, !6, i64 296, !6, i64 304, !6, i64 312, !6, i64 320, !6, i64 328, !6, i64 336, !6, i64 344, !6, i64 352, !6, i64 360, !6, i64 368}
!26 = !{!"", !14, i64 0, !10, i64 8, !10, i64 12, !10, i64 16, !10, i64 20}
!27 = !{!28, !6, i64 32}
!28 = !{!"_EFI_UDP4_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}
!29 = !{!25, !6, i64 120}
!30 = !{!28, !6, i64 56}
!31 = distinct !{!31, !32}
!32 = !{!"llvm.loop.mustprogress"}
!33 = !{!23, !6, i64 0}
!34 = !{!25, !6, i64 112}


; Optimized IR (opt -passes='default<O3>'):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

%struct.EFI_UDP4_COMPLETION_TOKEN = type { ptr, i64, %union.anon.4 }
%union.anon.4 = type { ptr }
%struct.EFI_UDP4_FRAGMENT_DATA = type { i32, ptr }

@gBS = external local_unnamed_addr global ptr, align 8

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

; 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 void @PxeBcCommonNotify(ptr noundef, ptr noundef) #1

; Function Attrs: nounwind uwtable
define dso_local i64 @PxeBcUdp4Write(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3, ptr noundef readonly %4, ptr noundef %5, ptr nocapture noundef readonly %6, ptr noundef %7) local_unnamed_addr #1 {
  %9 = alloca %struct.EFI_UDP4_COMPLETION_TOKEN, align 8
  %10 = alloca i8, align 1
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %9) #3
  call void @llvm.lifetime.start.p0(i64 1, ptr nonnull %10) #3
  %.not = icmp eq ptr %4, null
  %11 = select i1 %.not, i32 1, i32 2
  %12 = add nsw i32 %11, -1
  %13 = shl nuw nsw i32 %12, 4
  %14 = add nuw nsw i32 %13, 40
  %15 = zext nneg i32 %14 to i64
  %16 = tail call ptr @AllocateZeroPool(i64 noundef %15) #3
  %17 = icmp eq ptr %16, null
  br i1 %17, label %77, label %18

18:                                               ; preds = %8
  %19 = zext nneg i32 %12 to i64
  %20 = getelementptr inbounds i8, ptr %16, i64 20
  store i32 %11, ptr %20, align 4, !tbaa !5
  %21 = load i64, ptr %6, align 8, !tbaa !11
  %22 = trunc i64 %21 to i32
  %23 = getelementptr inbounds i8, ptr %16, i64 24
  %24 = getelementptr inbounds [1 x %struct.EFI_UDP4_FRAGMENT_DATA], ptr %23, i64 0, i64 %19
  store i32 %22, ptr %24, align 8, !tbaa !13
  %25 = getelementptr inbounds i8, ptr %24, i64 8
  store ptr %7, ptr %25, align 8, !tbaa !15
  br i1 %.not, label %31, label %26

26:                                               ; preds = %18
  %27 = load i64, ptr %4, align 8, !tbaa !11
  %28 = trunc i64 %27 to i32
  store i32 %28, ptr %23, align 8, !tbaa !13
  %29 = getelementptr inbounds i8, ptr %16, i64 32
  store ptr %5, ptr %29, align 8, !tbaa !15
  %30 = add i32 %28, %22
  br label %31

31:                                               ; preds = %26, %18
  %.039 = phi i32 [ %30, %26 ], [ %22, %18 ]
  %.not47 = icmp eq ptr %3, null
  br i1 %.not47, label %34, label %32

32:                                               ; preds = %31
  %33 = getelementptr inbounds i8, ptr %16, i64 8
  store ptr %3, ptr %33, align 8, !tbaa !16
  br label %34

34:                                               ; preds = %32, %31
  store ptr %1, ptr %16, align 8, !tbaa !17
  %35 = getelementptr inbounds i8, ptr %16, i64 16
  store i32 %.039, ptr %35, align 8, !tbaa !18
  %36 = getelementptr inbounds i8, ptr %9, i64 16
  store ptr %16, ptr %36, align 8, !tbaa !19
  %37 = getelementptr inbounds i8, ptr %9, i64 8
  store i64 -9223372036854775802, ptr %37, align 8, !tbaa !20
  store i8 0, ptr %10, align 1, !tbaa !19
  %38 = load ptr, ptr @gBS, align 8, !tbaa !22
  %39 = getelementptr inbounds i8, ptr %38, i64 80
  %40 = load ptr, ptr %39, align 8, !tbaa !23
  %41 = call i64 %40(i32 noundef 512, i64 noundef 16, ptr noundef nonnull @PxeBcCommonNotify, ptr noundef nonnull %10, ptr noundef nonnull %9) #3
  %42 = icmp slt i64 %41, 0
  br i1 %42, label %69, label %43

43:                                               ; preds = %34
  %44 = getelementptr inbounds i8, ptr %0, i64 32
  %45 = load ptr, ptr %44, align 8, !tbaa !26
  %46 = call i64 %45(ptr noundef %0, ptr noundef nonnull %9) #3
  %47 = icmp slt i64 %46, 0
  br i1 %47, label %69, label %.preheader

.preheader:                                       ; preds = %43
  %48 = load i8, ptr %10, align 1, !tbaa !19
  %49 = icmp eq i8 %48, 0
  %50 = load i64, ptr %37, align 8
  %51 = icmp eq i64 %50, -9223372036854775802
  %or.cond49 = select i1 %49, i1 %51, i1 false
  br i1 %or.cond49, label %.lr.ph, label %.critedge

.lr.ph:                                           ; preds = %.preheader
  %52 = getelementptr inbounds i8, ptr %0, i64 56
  br label %53

53:                                               ; preds = %.lr.ph, %59
  %54 = load ptr, ptr @gBS, align 8, !tbaa !22
  %55 = getelementptr inbounds i8, ptr %54, i64 120
  %56 = load ptr, ptr %55, align 8, !tbaa !28
  %57 = call i64 %56(ptr noundef %2) #3
  %58 = icmp slt i64 %57, 0
  br i1 %58, label %59, label %..critedge.loopexit_crit_edge

..critedge.loopexit_crit_edge:                    ; preds = %53
  %.pre.pre = load i64, ptr %37, align 8
  br label %.critedge

59:                                               ; preds = %53
  %60 = load ptr, ptr %52, align 8, !tbaa !29
  %61 = call i64 %60(ptr noundef nonnull %0) #3
  %62 = load i8, ptr %10, align 1, !tbaa !19
  %63 = icmp eq i8 %62, 0
  %64 = load i64, ptr %37, align 8
  %65 = icmp eq i64 %64, -9223372036854775802
  %or.cond = select i1 %63, i1 %65, i1 false
  br i1 %or.cond, label %53, label %.critedge, !llvm.loop !30

.critedge:                                        ; preds = %59, %..critedge.loopexit_crit_edge, %.preheader
  %66 = phi i64 [ %50, %.preheader ], [ %.pre.pre, %..critedge.loopexit_crit_edge ], [ %64, %59 ]
  %67 = icmp eq i64 %66, -9223372036854775802
  %68 = select i1 %67, i64 -9223372036854775790, i64 %66
  br label %69

69:                                               ; preds = %43, %34, %.critedge
  %.0 = phi i64 [ %41, %34 ], [ %46, %43 ], [ %68, %.critedge ]
  %70 = load ptr, ptr %9, align 8, !tbaa !32
  %.not48 = icmp eq ptr %70, null
  br i1 %.not48, label %76, label %71

71:                                               ; preds = %69
  %72 = load ptr, ptr @gBS, align 8, !tbaa !22
  %73 = getelementptr inbounds i8, ptr %72, i64 112
  %74 = load ptr, ptr %73, align 8, !tbaa !33
  %75 = call i64 %74(ptr noundef nonnull %70) #3
  br label %76

76:                                               ; preds = %71, %69
  call void @FreePool(ptr noundef nonnull %16) #3
  br label %77

77:                                               ; preds = %8, %76
  %.040 = phi i64 [ %.0, %76 ], [ -9223372036854775799, %8 ]
  call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %10) #3
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %9) #3
  ret i64 %.040
}

declare ptr @AllocateZeroPool(i64 noundef) local_unnamed_addr #2

declare void @FreePool(ptr noundef) local_unnamed_addr #2

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #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, !10, i64 20}
!6 = !{!"", !7, i64 0, !7, i64 8, !10, i64 16, !10, i64 20, !8, i64 24}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"long long", !8, i64 0}
!13 = !{!14, !10, i64 0}
!14 = !{!"", !10, i64 0, !7, i64 8}
!15 = !{!14, !7, i64 8}
!16 = !{!6, !7, i64 8}
!17 = !{!6, !7, i64 0}
!18 = !{!6, !10, i64 16}
!19 = !{!8, !8, i64 0}
!20 = !{!21, !12, i64 8}
!21 = !{!"", !7, i64 0, !12, i64 8, !8, i64 16}
!22 = !{!7, !7, i64 0}
!23 = !{!24, !7, i64 80}
!24 = !{!"", !25, i64 0, !7, i64 24, !7, i64 32, !7, i64 40, !7, i64 48, !7, i64 56, !7, i64 64, !7, i64 72, !7, i64 80, !7, i64 88, !7, i64 96, !7, i64 104, !7, i64 112, !7, i64 120, !7, i64 128, !7, i64 136, !7, i64 144, !7, i64 152, !7, i64 160, !7, i64 168, !7, i64 176, !7, i64 184, !7, i64 192, !7, i64 200, !7, i64 208, !7, i64 216, !7, i64 224, !7, i64 232, !7, i64 240, !7, i64 248, !7, i64 256, !7, i64 264, !7, i64 272, !7, i64 280, !7, i64 288, !7, i64 296, !7, i64 304, !7, i64 312, !7, i64 320, !7, i64 328, !7, i64 336, !7, i64 344, !7, i64 352, !7, i64 360, !7, i64 368}
!25 = !{!"", !12, i64 0, !10, i64 8, !10, i64 12, !10, i64 16, !10, i64 20}
!26 = !{!27, !7, i64 32}
!27 = !{!"_EFI_UDP4_PROTOCOL", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !7, i64 32, !7, i64 40, !7, i64 48, !7, i64 56}
!28 = !{!24, !7, i64 120}
!29 = !{!27, !7, i64 56}
!30 = distinct !{!30, !31}
!31 = !{!"llvm.loop.mustprogress"}
!32 = !{!21, !7, i64 0}
!33 = !{!24, !7, i64 112}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass