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

; 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_UDP6_COMPLETION_TOKEN = type { ptr, i64, %union.anon.5 }
%union.anon.5 = type { ptr }
%struct.EFI_UDP6_TRANSMIT_DATA = type { ptr, i32, i32, [1 x %struct.EFI_UDP6_FRAGMENT_DATA] }
%struct.EFI_UDP6_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_UDP6_PROTOCOL = type { 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

declare ptr @AllocateZeroPool(i64 noundef) #2

declare void @FreePool(ptr noundef) #2

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

39:                                               ; preds = %7
  store i64 -9223372036854775799, ptr %8, align 8
  store i32 1, ptr %23, align 4
  br label %159

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

67:                                               ; preds = %40
  %68 = load ptr, ptr %12, align 8, !tbaa !5
  %69 = load i64, ptr %68, align 8, !tbaa !13
  %70 = trunc i64 %69 to i32
  %71 = load ptr, ptr %17, align 8, !tbaa !5
  %72 = getelementptr inbounds %struct.EFI_UDP6_TRANSMIT_DATA, ptr %71, i32 0, i32 3
  %73 = getelementptr inbounds [1 x %struct.EFI_UDP6_FRAGMENT_DATA], ptr %72, i64 0, i64 0
  %74 = getelementptr inbounds %struct.EFI_UDP6_FRAGMENT_DATA, ptr %73, i32 0, i32 0
  store i32 %70, ptr %74, align 8, !tbaa !15
  %75 = load ptr, ptr %13, align 8, !tbaa !5
  %76 = load ptr, ptr %17, align 8, !tbaa !5
  %77 = getelementptr inbounds %struct.EFI_UDP6_TRANSMIT_DATA, ptr %76, i32 0, i32 3
  %78 = getelementptr inbounds [1 x %struct.EFI_UDP6_FRAGMENT_DATA], ptr %77, i64 0, i64 0
  %79 = getelementptr inbounds %struct.EFI_UDP6_FRAGMENT_DATA, ptr %78, i32 0, i32 1
  store ptr %75, ptr %79, align 8, !tbaa !17
  %80 = load ptr, ptr %12, align 8, !tbaa !5
  %81 = load i64, ptr %80, align 8, !tbaa !13
  %82 = trunc i64 %81 to i32
  %83 = load i32, ptr %20, align 4, !tbaa !9
  %84 = add i32 %83, %82
  store i32 %84, ptr %20, align 4, !tbaa !9
  br label %85

85:                                               ; preds = %67, %40
  %86 = load ptr, ptr %10, align 8, !tbaa !5
  %87 = load ptr, ptr %17, align 8, !tbaa !5
  %88 = getelementptr inbounds %struct.EFI_UDP6_TRANSMIT_DATA, ptr %87, i32 0, i32 0
  store ptr %86, ptr %88, align 8, !tbaa !18
  %89 = load i32, ptr %20, align 4, !tbaa !9
  %90 = load ptr, ptr %17, align 8, !tbaa !5
  %91 = getelementptr inbounds %struct.EFI_UDP6_TRANSMIT_DATA, ptr %90, i32 0, i32 1
  store i32 %89, ptr %91, align 8, !tbaa !19
  %92 = load ptr, ptr %17, align 8, !tbaa !5
  %93 = getelementptr inbounds %struct.EFI_UDP6_COMPLETION_TOKEN, ptr %16, i32 0, i32 2
  store ptr %92, ptr %93, align 8, !tbaa !20
  %94 = getelementptr inbounds %struct.EFI_UDP6_COMPLETION_TOKEN, ptr %16, i32 0, i32 1
  store i64 -9223372036854775802, ptr %94, align 8, !tbaa !21
  store i8 0, ptr %21, align 1, !tbaa !20
  %95 = load ptr, ptr @gBS, align 8, !tbaa !5
  %96 = getelementptr inbounds %struct.EFI_BOOT_SERVICES, ptr %95, i32 0, i32 8
  %97 = load ptr, ptr %96, align 8, !tbaa !23
  %98 = getelementptr inbounds %struct.EFI_UDP6_COMPLETION_TOKEN, ptr %16, i32 0, i32 0
  %99 = call i64 %97(i32 noundef 512, i64 noundef 16, ptr noundef @PxeBcCommonNotify, ptr noundef %21, ptr noundef %98)
  store i64 %99, ptr %22, align 8, !tbaa !13
  %100 = load i64, ptr %22, align 8, !tbaa !13
  %101 = icmp slt i64 %100, 0
  br i1 %101, label %102, label %103

102:                                              ; preds = %85
  br label %145

103:                                              ; preds = %85
  %104 = load ptr, ptr %9, align 8, !tbaa !5
  %105 = getelementptr inbounds %struct._EFI_UDP6_PROTOCOL, ptr %104, i32 0, i32 3
  %106 = load ptr, ptr %105, align 8, !tbaa !26
  %107 = load ptr, ptr %9, align 8, !tbaa !5
  %108 = call i64 %106(ptr noundef %107, ptr noundef %16)
  store i64 %108, ptr %22, align 8, !tbaa !13
  %109 = load i64, ptr %22, align 8, !tbaa !13
  %110 = icmp slt i64 %109, 0
  br i1 %110, label %111, label %112

111:                                              ; preds = %103
  br label %145

112:                                              ; preds = %103
  br label %113

113:                                              ; preds = %129, %112
  %114 = load i8, ptr %21, align 1, !tbaa !20
  %115 = icmp ne i8 %114, 0
  br i1 %115, label %127, label %116

116:                                              ; preds = %113
  %117 = getelementptr inbounds %struct.EFI_UDP6_COMPLETION_TOKEN, ptr %16, i32 0, i32 1
  %118 = load i64, ptr %117, align 8, !tbaa !21
  %119 = icmp eq i64 %118, -9223372036854775802
  br i1 %119, label %120, label %127

120:                                              ; preds = %116
  %121 = load ptr, ptr @gBS, align 8, !tbaa !5
  %122 = getelementptr inbounds %struct.EFI_BOOT_SERVICES, ptr %121, i32 0, i32 13
  %123 = load ptr, ptr %122, align 8, !tbaa !28
  %124 = load ptr, ptr %11, align 8, !tbaa !5
  %125 = call i64 %123(ptr noundef %124)
  %126 = icmp slt i64 %125, 0
  br label %127

127:                                              ; preds = %120, %116, %113
  %128 = phi i1 [ false, %116 ], [ false, %113 ], [ %126, %120 ]
  br i1 %128, label %129, label %135

129:                                              ; preds = %127
  %130 = load ptr, ptr %9, align 8, !tbaa !5
  %131 = getelementptr inbounds %struct._EFI_UDP6_PROTOCOL, ptr %130, i32 0, i32 6
  %132 = load ptr, ptr %131, align 8, !tbaa !29
  %133 = load ptr, ptr %9, align 8, !tbaa !5
  %134 = call i64 %132(ptr noundef %133)
  br label %113, !llvm.loop !30

135:                                              ; preds = %127
  %136 = getelementptr inbounds %struct.EFI_UDP6_COMPLETION_TOKEN, ptr %16, i32 0, i32 1
  %137 = load i64, ptr %136, align 8, !tbaa !21
  %138 = icmp eq i64 %137, -9223372036854775802
  br i1 %138, label %139, label %140

139:                                              ; preds = %135
  br label %143

140:                                              ; preds = %135
  %141 = getelementptr inbounds %struct.EFI_UDP6_COMPLETION_TOKEN, ptr %16, i32 0, i32 1
  %142 = load i64, ptr %141, align 8, !tbaa !21
  br label %143

143:                                              ; preds = %140, %139
  %144 = phi i64 [ -9223372036854775790, %139 ], [ %142, %140 ]
  store i64 %144, ptr %22, align 8, !tbaa !13
  br label %145

145:                                              ; preds = %143, %111, %102
  %146 = getelementptr inbounds %struct.EFI_UDP6_COMPLETION_TOKEN, ptr %16, i32 0, i32 0
  %147 = load ptr, ptr %146, align 8, !tbaa !32
  %148 = icmp ne ptr %147, null
  br i1 %148, label %149, label %156

149:                                              ; preds = %145
  %150 = load ptr, ptr @gBS, align 8, !tbaa !5
  %151 = getelementptr inbounds %struct.EFI_BOOT_SERVICES, ptr %150, i32 0, i32 12
  %152 = load ptr, ptr %151, align 8, !tbaa !33
  %153 = getelementptr inbounds %struct.EFI_UDP6_COMPLETION_TOKEN, ptr %16, i32 0, i32 0
  %154 = load ptr, ptr %153, align 8, !tbaa !32
  %155 = call i64 %152(ptr noundef %154)
  br label %156

156:                                              ; preds = %149, %145
  %157 = load ptr, ptr %17, align 8, !tbaa !5
  call void @FreePool(ptr noundef %157)
  %158 = load i64, ptr %22, align 8, !tbaa !13
  store i64 %158, ptr %8, align 8
  store i32 1, ptr %23, align 4
  br label %159

159:                                              ; preds = %156, %39
  call void @llvm.lifetime.end.p0(i64 8, ptr %22) #3
  call void @llvm.lifetime.end.p0(i64 1, ptr %21) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %20) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %19) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #3
  call void @llvm.lifetime.end.p0(i64 24, ptr %16) #3
  %160 = load i64, ptr %8, align 8
  ret i64 %160
}

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 12}
!12 = !{!"", !6, i64 0, !10, i64 8, !10, i64 12, !7, i64 16}
!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 0}
!19 = !{!12, !10, i64 8}
!20 = !{!7, !7, i64 0}
!21 = !{!22, !14, i64 8}
!22 = !{!"", !6, i64 0, !14, i64 8, !7, i64 16}
!23 = !{!24, !6, i64 80}
!24 = !{!"", !25, 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}
!25 = !{!"", !14, i64 0, !10, i64 8, !10, i64 12, !10, i64 16, !10, i64 20}
!26 = !{!27, !6, i64 24}
!27 = !{!"_EFI_UDP6_PROTOCOL", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48}
!28 = !{!24, !6, i64 120}
!29 = !{!27, !6, i64 48}
!30 = distinct !{!30, !31}
!31 = !{!"llvm.loop.mustprogress"}
!32 = !{!22, !6, i64 0}
!33 = !{!24, !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_UDP6_COMPLETION_TOKEN = type { ptr, i64, %union.anon.5 }
%union.anon.5 = type { ptr }
%struct.EFI_UDP6_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

declare ptr @AllocateZeroPool(i64 noundef) local_unnamed_addr #2

declare void @FreePool(ptr noundef) local_unnamed_addr #2

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

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

25:                                               ; preds = %17
  %26 = load i64, ptr %3, align 8, !tbaa !11
  %27 = trunc i64 %26 to i32
  store i32 %27, ptr %22, align 8, !tbaa !13
  %28 = getelementptr inbounds i8, ptr %15, i64 24
  store ptr %4, ptr %28, align 8, !tbaa !15
  %29 = add i32 %27, %21
  br label %30

30:                                               ; preds = %25, %17
  %.036 = phi i32 [ %29, %25 ], [ %21, %17 ]
  store ptr %1, ptr %15, align 8, !tbaa !16
  %31 = getelementptr inbounds i8, ptr %15, i64 8
  store i32 %.036, ptr %31, align 8, !tbaa !17
  %32 = getelementptr inbounds i8, ptr %8, i64 16
  store ptr %15, ptr %32, align 8, !tbaa !18
  %33 = getelementptr inbounds i8, ptr %8, i64 8
  store i64 -9223372036854775802, ptr %33, align 8, !tbaa !19
  store i8 0, ptr %9, align 1, !tbaa !18
  %34 = load ptr, ptr @gBS, align 8, !tbaa !21
  %35 = getelementptr inbounds i8, ptr %34, i64 80
  %36 = load ptr, ptr %35, align 8, !tbaa !22
  %37 = call i64 %36(i32 noundef 512, i64 noundef 16, ptr noundef nonnull @PxeBcCommonNotify, ptr noundef nonnull %9, ptr noundef nonnull %8) #3
  %38 = icmp slt i64 %37, 0
  br i1 %38, label %65, label %39

39:                                               ; preds = %30
  %40 = getelementptr inbounds i8, ptr %0, i64 24
  %41 = load ptr, ptr %40, align 8, !tbaa !25
  %42 = call i64 %41(ptr noundef %0, ptr noundef nonnull %8) #3
  %43 = icmp slt i64 %42, 0
  br i1 %43, label %65, label %.preheader

.preheader:                                       ; preds = %39
  %44 = load i8, ptr %9, align 1, !tbaa !18
  %45 = icmp eq i8 %44, 0
  %46 = load i64, ptr %33, align 8
  %47 = icmp eq i64 %46, -9223372036854775802
  %or.cond44 = select i1 %45, i1 %47, i1 false
  br i1 %or.cond44, label %.lr.ph, label %.critedge

.lr.ph:                                           ; preds = %.preheader
  %48 = getelementptr inbounds i8, ptr %0, i64 48
  br label %49

49:                                               ; preds = %.lr.ph, %55
  %50 = load ptr, ptr @gBS, align 8, !tbaa !21
  %51 = getelementptr inbounds i8, ptr %50, i64 120
  %52 = load ptr, ptr %51, align 8, !tbaa !27
  %53 = call i64 %52(ptr noundef %2) #3
  %54 = icmp slt i64 %53, 0
  br i1 %54, label %55, label %..critedge.loopexit_crit_edge

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

55:                                               ; preds = %49
  %56 = load ptr, ptr %48, align 8, !tbaa !28
  %57 = call i64 %56(ptr noundef nonnull %0) #3
  %58 = load i8, ptr %9, align 1, !tbaa !18
  %59 = icmp eq i8 %58, 0
  %60 = load i64, ptr %33, align 8
  %61 = icmp eq i64 %60, -9223372036854775802
  %or.cond = select i1 %59, i1 %61, i1 false
  br i1 %or.cond, label %49, label %.critedge, !llvm.loop !29

.critedge:                                        ; preds = %55, %..critedge.loopexit_crit_edge, %.preheader
  %62 = phi i64 [ %46, %.preheader ], [ %.pre.pre, %..critedge.loopexit_crit_edge ], [ %60, %55 ]
  %63 = icmp eq i64 %62, -9223372036854775802
  %64 = select i1 %63, i64 -9223372036854775790, i64 %62
  br label %65

65:                                               ; preds = %39, %30, %.critedge
  %.0 = phi i64 [ %37, %30 ], [ %42, %39 ], [ %64, %.critedge ]
  %66 = load ptr, ptr %8, align 8, !tbaa !31
  %.not43 = icmp eq ptr %66, null
  br i1 %.not43, label %72, label %67

67:                                               ; preds = %65
  %68 = load ptr, ptr @gBS, align 8, !tbaa !21
  %69 = getelementptr inbounds i8, ptr %68, i64 112
  %70 = load ptr, ptr %69, align 8, !tbaa !32
  %71 = call i64 %70(ptr noundef nonnull %66) #3
  br label %72

72:                                               ; preds = %67, %65
  call void @FreePool(ptr noundef nonnull %15) #3
  br label %73

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

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 12}
!6 = !{!"", !7, i64 0, !10, i64 8, !10, i64 12, !8, i64 16}
!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 0}
!17 = !{!6, !10, i64 8}
!18 = !{!8, !8, i64 0}
!19 = !{!20, !12, i64 8}
!20 = !{!"", !7, i64 0, !12, i64 8, !8, i64 16}
!21 = !{!7, !7, i64 0}
!22 = !{!23, !7, i64 80}
!23 = !{!"", !24, 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}
!24 = !{!"", !12, i64 0, !10, i64 8, !10, i64 12, !10, i64 16, !10, i64 20}
!25 = !{!26, !7, i64 24}
!26 = !{!"_EFI_UDP6_PROTOCOL", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !7, i64 32, !7, i64 40, !7, i64 48}
!27 = !{!23, !7, i64 120}
!28 = !{!26, !7, i64 48}
!29 = distinct !{!29, !30}
!30 = !{!"llvm.loop.mustprogress"}
!31 = !{!20, !7, i64 0}
!32 = !{!23, !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