; LLVM IR from thalium/icebox :: third_party/virtualbox/src/VBox/Devices/EFI/Firmware/IntelFrameworkModulePkg (BiosBlockIoDriverBindingStart)

; 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_LOCK = type { i64, i64, i32 }
%struct.GUID = type { i32, i16, i16, [8 x i8] }
%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_DRIVER_BINDING_PROTOCOL = type { ptr, ptr, ptr, i32, ptr, ptr }
%struct._EFI_PCI_IO_PROTOCOL = type { ptr, ptr, %struct.EFI_PCI_IO_PROTOCOL_ACCESS, %struct.EFI_PCI_IO_PROTOCOL_ACCESS, %struct.EFI_PCI_IO_PROTOCOL_CONFIG_ACCESS, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, i64, ptr }
%struct.EFI_PCI_IO_PROTOCOL_ACCESS = type { ptr, ptr }
%struct.EFI_PCI_IO_PROTOCOL_CONFIG_ACCESS = type { ptr, ptr }
%struct._EFI_LEGACY_BIOS_PROTOCOL = type { ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr }
%struct.BIOS_BLOCK_IO_DEV = type { i64, ptr, ptr, %struct._EFI_BLOCK_IO_PROTOCOL, %struct.EFI_BLOCK_IO_MEDIA, ptr, ptr, ptr, %struct.BIOS_LEGACY_DRIVE }
%struct._EFI_BLOCK_IO_PROTOCOL = type { i64, ptr, ptr, ptr, ptr, ptr }
%struct.EFI_BLOCK_IO_MEDIA = type { i32, i8, i8, i8, i8, i8, i32, i32, i64, i64, i32, i32 }
%struct.BIOS_LEGACY_DRIVE = type { i8, i8, i8, i8, i8, i8, i8, i8, i8, ptr, i8, i8, i8, i8, i16, i16, %struct.EDD_DRIVE_PARAMETERS }
%struct.EDD_DRIVE_PARAMETERS = type <{ i16, i16, i32, i32, i32, i64, i16, i32, i16, i8, i8, i16, [4 x i8], [8 x i8], %union.EDD_INTERFACE_PATH, %union.EDD_DEVICE_PATH, i8, i8 }>
%union.EDD_INTERFACE_PATH = type { %struct.EDD_PCI }
%struct.EDD_PCI = type { i8, i8, i8, i8, i32 }
%union.EDD_DEVICE_PATH = type { %struct.EDD_USB }
%struct.EDD_USB = type { i64, i64 }

@mGlobalDataLock = external dso_local global %struct.EFI_LOCK, align 8
@mActiveInstances = external dso_local global i64, align 8
@mBufferUnder1Mb = external dso_local global i64, align 8
@gBS = external global ptr, align 8
@gEfiLegacyBiosProtocolGuid = external global %struct.GUID, align 4
@gEfiDevicePathProtocolGuid = external global %struct.GUID, align 4
@gEfiPciIoProtocolGuid = external global %struct.GUID, align 4
@.str = external hidden unnamed_addr constant [162 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [22 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [33 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [20 x i8], align 1
@mEdd11Buffer = external dso_local global ptr, align 8
@mLegacyDriverUnder1Mb = external dso_local global ptr, align 8
@mEddBufferUnder1Mb = external dso_local global ptr, align 8
@gEfiBlockIoProtocolGuid = external global %struct.GUID, align 4

; Function Attrs: nounwind uwtable
define dso_local i64 @BiosBlockIoDriverBindingStart(ptr noundef %0, ptr noundef %1, ptr noundef %2) #0 {
  %4 = alloca ptr, align 8
  %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 i8, align 1
  %11 = alloca i8, align 1
  %12 = alloca ptr, align 8
  %13 = alloca ptr, align 8
  %14 = alloca i64, align 8
  %15 = alloca i64, align 8
  %16 = alloca i64, align 8
  %17 = alloca i8, align 1
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store ptr %2, ptr %6, align 8, !tbaa !5
  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 1, 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 8, ptr %13) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #3
  call void @llvm.lifetime.start.p0(i64 1, ptr %17) #3
  store ptr null, ptr %9, align 8, !tbaa !5
  store ptr null, ptr %13, align 8, !tbaa !5
  store i8 0, ptr %17, align 1, !tbaa !9
  %18 = load ptr, ptr @gBS, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct.EFI_BOOT_SERVICES, ptr %18, i32 0, i32 38
  %20 = load ptr, ptr %19, align 8, !tbaa !10
  %21 = call i64 %20(ptr noundef @gEfiLegacyBiosProtocolGuid, ptr noundef null, ptr noundef %8)
  store i64 %21, ptr %7, align 8, !tbaa !15
  %22 = load i64, ptr %7, align 8, !tbaa !15
  %23 = icmp slt i64 %22, 0
  br i1 %23, label %24, label %25

24:                                               ; preds = %3
  br label %255

25:                                               ; preds = %3
  %26 = load ptr, ptr @gBS, align 8, !tbaa !5
  %27 = getelementptr inbounds %struct.EFI_BOOT_SERVICES, ptr %26, i32 0, i32 33
  %28 = load ptr, ptr %27, align 8, !tbaa !16
  %29 = load ptr, ptr %5, align 8, !tbaa !5
  %30 = load ptr, ptr %4, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct._EFI_DRIVER_BINDING_PROTOCOL, ptr %30, i32 0, i32 5
  %32 = load ptr, ptr %31, align 8, !tbaa !17
  %33 = load ptr, ptr %5, align 8, !tbaa !5
  %34 = call i64 %28(ptr noundef %29, ptr noundef @gEfiPciIoProtocolGuid, ptr noundef %9, ptr noundef %32, ptr noundef %33, i32 noundef 16)
  store i64 %34, ptr %7, align 8, !tbaa !15
  %35 = load i64, ptr %7, align 8, !tbaa !15
  %36 = icmp slt i64 %35, 0
  br i1 %36, label %37, label %38

37:                                               ; preds = %25
  br label %255

38:                                               ; preds = %25
  %39 = load ptr, ptr @gBS, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.EFI_BOOT_SERVICES, ptr %39, i32 0, i32 33
  %41 = load ptr, ptr %40, align 8, !tbaa !16
  %42 = load ptr, ptr %5, align 8, !tbaa !5
  %43 = load ptr, ptr %4, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct._EFI_DRIVER_BINDING_PROTOCOL, ptr %43, i32 0, i32 5
  %45 = load ptr, ptr %44, align 8, !tbaa !17
  %46 = load ptr, ptr %5, align 8, !tbaa !5
  %47 = call i64 %41(ptr noundef %42, ptr noundef @gEfiDevicePathProtocolGuid, ptr noundef %13, ptr noundef %45, ptr noundef %46, i32 noundef 16)
  store i64 %47, ptr %7, align 8, !tbaa !15
  %48 = load i64, ptr %7, align 8, !tbaa !15
  %49 = icmp slt i64 %48, 0
  br i1 %49, label %50, label %51

50:                                               ; preds = %38
  br label %255

51:                                               ; preds = %38
  %52 = load ptr, ptr %9, align 8, !tbaa !5
  %53 = getelementptr inbounds %struct._EFI_PCI_IO_PROTOCOL, ptr %52, i32 0, i32 12
  %54 = load ptr, ptr %53, align 8, !tbaa !19
  %55 = load ptr, ptr %9, align 8, !tbaa !5
  %56 = call i64 %54(ptr noundef %55, i32 noundef 2, i64 noundef 1792, ptr noundef null)
  store i64 %56, ptr %7, align 8, !tbaa !15
  %57 = load i64, ptr %7, align 8, !tbaa !15
  %58 = icmp slt i64 %57, 0
  br i1 %58, label %59, label %60

59:                                               ; preds = %51
  br label %255

60:                                               ; preds = %51
  store i8 1, ptr %17, align 1, !tbaa !9
  %61 = load ptr, ptr %8, align 8, !tbaa !5
  %62 = getelementptr inbounds %struct._EFI_LEGACY_BIOS_PROTOCOL, ptr %61, i32 0, i32 2
  %63 = load ptr, ptr %62, align 8, !tbaa !22
  %64 = load ptr, ptr %8, align 8, !tbaa !5
  %65 = load ptr, ptr %5, align 8, !tbaa !5
  %66 = call i64 %63(ptr noundef %64, ptr noundef %65, ptr noundef null, ptr noundef null, ptr noundef %15)
  store i64 %66, ptr %7, align 8, !tbaa !15
  %67 = load i64, ptr %7, align 8, !tbaa !15
  %68 = icmp slt i64 %67, 0
  br i1 %68, label %69, label %70

69:                                               ; preds = %60
  br label %255

70:                                               ; preds = %60
  %71 = load ptr, ptr %8, align 8, !tbaa !5
  %72 = getelementptr inbounds %struct._EFI_LEGACY_BIOS_PROTOCOL, ptr %71, i32 0, i32 3
  %73 = load ptr, ptr %72, align 8, !tbaa !24
  %74 = load ptr, ptr %8, align 8, !tbaa !5
  %75 = load ptr, ptr %5, align 8, !tbaa !5
  %76 = call i64 %73(ptr noundef %74, ptr noundef %75, ptr noundef null, ptr noundef %15, ptr noundef %10, ptr noundef %11, ptr noundef null, ptr noundef null)
  store i64 %76, ptr %7, align 8, !tbaa !15
  %77 = load i64, ptr %7, align 8, !tbaa !15
  %78 = icmp slt i64 %77, 0
  br i1 %78, label %79, label %80

79:                                               ; preds = %70
  br label %255

80:                                               ; preds = %70
  %81 = load i64, ptr @mBufferUnder1Mb, align 8, !tbaa !15
  %82 = icmp eq i64 %81, 0
  br i1 %82, label %83, label %154

83:                                               ; preds = %80
  br label %84

84:                                               ; preds = %83
  %85 = call zeroext i8 @DebugAssertEnabled()
  %86 = icmp ne i8 %85, 0
  br i1 %86, label %87, label %92

87:                                               ; preds = %84
  %88 = load i64, ptr @mActiveInstances, align 8, !tbaa !15
  %89 = icmp eq i64 %88, 0
  br i1 %89, label %91, label %90

90:                                               ; preds = %87
  call void @DebugAssert(ptr noundef @.str, i64 noundef 335, ptr noundef @.str.1)
  br label %91

91:                                               ; preds = %90, %87
  br label %92

92:                                               ; preds = %91, %84
  br label %93

93:                                               ; preds = %92
  br label %94

94:                                               ; preds = %93
  call void @EfiAcquireLock(ptr noundef @mGlobalDataLock)
  store i64 1048575, ptr @mBufferUnder1Mb, align 8, !tbaa !15
  %95 = load ptr, ptr @gBS, align 8, !tbaa !5
  %96 = getelementptr inbounds %struct.EFI_BOOT_SERVICES, ptr %95, i32 0, i32 3
  %97 = load ptr, ptr %96, align 8, !tbaa !25
  %98 = call i64 %97(i32 noundef 1, i32 noundef 4, i64 noundef 16, ptr noundef @mBufferUnder1Mb)
  store i64 %98, ptr %7, align 8, !tbaa !15
  call void @EfiReleaseLock(ptr noundef @mGlobalDataLock)
  %99 = load i64, ptr %7, align 8, !tbaa !15
  %100 = icmp slt i64 %99, 0
  br i1 %100, label %101, label %128

101:                                              ; preds = %94
  br label %102

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

105:                                              ; preds = %102
  %106 = load i64, ptr %7, align 8, !tbaa !15
  %107 = icmp slt i64 %106, 0
  br i1 %107, label %108, label %124

108:                                              ; preds = %105
  br label %109

109:                                              ; preds = %108
  %110 = call zeroext i8 @DebugPrintEnabled()
  %111 = icmp ne i8 %110, 0
  br i1 %111, label %112, label %121

112:                                              ; preds = %109
  br label %113

113:                                              ; preds = %112
  %114 = call zeroext i8 @DebugPrintLevelEnabled(i64 noundef 2147483648)
  %115 = icmp ne i8 %114, 0
  br i1 %115, label %116, label %118

116:                                              ; preds = %113
  %117 = load i64, ptr %7, align 8, !tbaa !15
  call void (i64, ptr, ...) @DebugPrint(i64 noundef 2147483648, ptr noundef @.str.2, i64 noundef %117)
  br label %118

118:                                              ; preds = %116, %113
  br label %119

119:                                              ; preds = %118
  br label %120

120:                                              ; preds = %119
  br label %121

121:                                              ; preds = %120, %109
  br label %122

122:                                              ; preds = %121
  br label %123

123:                                              ; preds = %122
  call void @DebugAssert(ptr noundef @.str, i64 noundef 360, ptr noundef @.str.3)
  br label %124

124:                                              ; preds = %123, %105
  br label %125

125:                                              ; preds = %124, %102
  br label %126

126:                                              ; preds = %125
  br label %127

127:                                              ; preds = %126
  store i64 -9223372036854775799, ptr %7, align 8, !tbaa !15
  store i64 0, ptr @mBufferUnder1Mb, align 8, !tbaa !15
  br label %255

128:                                              ; preds = %94
  %129 = load i64, ptr @mBufferUnder1Mb, align 8, !tbaa !15
  store i64 %129, ptr %16, align 8, !tbaa !15
  %130 = load i64, ptr %16, align 8, !tbaa !15
  %131 = load i64, ptr %16, align 8, !tbaa !15
  %132 = sub i64 8, %131
  %133 = and i64 %132, 7
  %134 = add i64 %130, %133
  %135 = inttoptr i64 %134 to ptr
  store ptr %135, ptr @mEdd11Buffer, align 8, !tbaa !5
  %136 = load ptr, ptr @mEdd11Buffer, align 8, !tbaa !5
  %137 = ptrtoint ptr %136 to i64
  %138 = add i64 %137, 65024
  store i64 %138, ptr %16, align 8, !tbaa !15
  %139 = load i64, ptr %16, align 8, !tbaa !15
  %140 = load i64, ptr %16, align 8, !tbaa !15
  %141 = sub i64 8, %140
  %142 = and i64 %141, 7
  %143 = add i64 %139, %142
  %144 = inttoptr i64 %143 to ptr
  store ptr %144, ptr @mLegacyDriverUnder1Mb, align 8, !tbaa !5
  %145 = load ptr, ptr @mLegacyDriverUnder1Mb, align 8, !tbaa !5
  %146 = ptrtoint ptr %145 to i64
  %147 = add i64 %146, 112
  store i64 %147, ptr %16, align 8, !tbaa !15
  %148 = load i64, ptr %16, align 8, !tbaa !15
  %149 = load i64, ptr %16, align 8, !tbaa !15
  %150 = sub i64 8, %149
  %151 = and i64 %150, 7
  %152 = add i64 %148, %151
  %153 = inttoptr i64 %152 to ptr
  store ptr %153, ptr @mEddBufferUnder1Mb, align 8, !tbaa !5
  br label %154

154:                                              ; preds = %128, %80
  %155 = load i8, ptr %10, align 1, !tbaa !9
  %156 = zext i8 %155 to i64
  store i64 %156, ptr %14, align 8, !tbaa !15
  br label %157

157:                                              ; preds = %251, %154
  %158 = load i64, ptr %14, align 8, !tbaa !15
  %159 = load i8, ptr %11, align 1, !tbaa !9
  %160 = zext i8 %159 to i64
  %161 = icmp ult i64 %158, %160
  br i1 %161, label %162, label %254

162:                                              ; preds = %157
  %163 = load ptr, ptr @gBS, align 8, !tbaa !5
  %164 = getelementptr inbounds %struct.EFI_BOOT_SERVICES, ptr %163, i32 0, i32 6
  %165 = load ptr, ptr %164, align 8, !tbaa !26
  %166 = call i64 %165(i32 noundef 4, i64 noundef 256, ptr noundef %12)
  store i64 %166, ptr %7, align 8, !tbaa !15
  %167 = load i64, ptr %7, align 8, !tbaa !15
  %168 = icmp slt i64 %167, 0
  br i1 %168, label %169, label %170

169:                                              ; preds = %162
  br label %255

170:                                              ; preds = %162
  %171 = load ptr, ptr %12, align 8, !tbaa !5
  %172 = call ptr @ZeroMem(ptr noundef %171, i64 noundef 256)
  %173 = load ptr, ptr %12, align 8, !tbaa !5
  %174 = getelementptr inbounds %struct.BIOS_BLOCK_IO_DEV, ptr %173, i32 0, i32 0
  store i64 1869177442, ptr %174, align 8, !tbaa !27
  %175 = load ptr, ptr %5, align 8, !tbaa !5
  %176 = load ptr, ptr %12, align 8, !tbaa !5
  %177 = getelementptr inbounds %struct.BIOS_BLOCK_IO_DEV, ptr %176, i32 0, i32 2
  store ptr %175, ptr %177, align 8, !tbaa !34
  %178 = load ptr, ptr %8, align 8, !tbaa !5
  %179 = load ptr, ptr %12, align 8, !tbaa !5
  %180 = getelementptr inbounds %struct.BIOS_BLOCK_IO_DEV, ptr %179, i32 0, i32 7
  store ptr %178, ptr %180, align 8, !tbaa !35
  %181 = load ptr, ptr %9, align 8, !tbaa !5
  %182 = load ptr, ptr %12, align 8, !tbaa !5
  %183 = getelementptr inbounds %struct.BIOS_BLOCK_IO_DEV, ptr %182, i32 0, i32 6
  store ptr %181, ptr %183, align 8, !tbaa !36
  %184 = load ptr, ptr %12, align 8, !tbaa !5
  %185 = getelementptr inbounds %struct.BIOS_BLOCK_IO_DEV, ptr %184, i32 0, i32 8
  %186 = getelementptr inbounds %struct.BIOS_LEGACY_DRIVE, ptr %185, i32 0, i32 10
  store i8 0, ptr %186, align 8, !tbaa !37
  %187 = load i64, ptr %14, align 8, !tbaa !15
  %188 = trunc i64 %187 to i8
  %189 = load ptr, ptr %12, align 8, !tbaa !5
  %190 = getelementptr inbounds %struct.BIOS_BLOCK_IO_DEV, ptr %189, i32 0, i32 8
  %191 = getelementptr inbounds %struct.BIOS_LEGACY_DRIVE, ptr %190, i32 0, i32 1
  store i8 %188, ptr %191, align 1, !tbaa !38
  %192 = load i64, ptr %14, align 8, !tbaa !15
  %193 = sub i64 %192, 128
  %194 = add i64 %193, 67
  %195 = trunc i64 %194 to i8
  %196 = load ptr, ptr %12, align 8, !tbaa !5
  %197 = getelementptr inbounds %struct.BIOS_BLOCK_IO_DEV, ptr %196, i32 0, i32 8
  %198 = getelementptr inbounds %struct.BIOS_LEGACY_DRIVE, ptr %197, i32 0, i32 0
  store i8 %195, ptr %198, align 8, !tbaa !39
  %199 = load ptr, ptr %12, align 8, !tbaa !5
  %200 = getelementptr inbounds %struct.BIOS_BLOCK_IO_DEV, ptr %199, i32 0, i32 4
  %201 = getelementptr inbounds %struct.EFI_BLOCK_IO_MEDIA, ptr %200, i32 0, i32 1
  store i8 0, ptr %201, align 4, !tbaa !40
  %202 = load ptr, ptr %12, align 8, !tbaa !5
  %203 = call zeroext i8 @BiosInitBlockIo(ptr noundef %202)
  %204 = icmp ne i8 %203, 0
  br i1 %204, label %205, label %244

205:                                              ; preds = %170
  %206 = load ptr, ptr %13, align 8, !tbaa !5
  %207 = load ptr, ptr %12, align 8, !tbaa !5
  %208 = getelementptr inbounds %struct.BIOS_BLOCK_IO_DEV, ptr %207, i32 0, i32 8
  %209 = load ptr, ptr %12, align 8, !tbaa !5
  %210 = getelementptr inbounds %struct.BIOS_BLOCK_IO_DEV, ptr %209, i32 0, i32 5
  call void @SetBiosInitBlockIoDevicePath(ptr noundef %206, ptr noundef %208, ptr noundef %210)
  %211 = load ptr, ptr @gBS, align 8, !tbaa !5
  %212 = getelementptr inbounds %struct.EFI_BOOT_SERVICES, ptr %211, i32 0, i32 39
  %213 = load ptr, ptr %212, align 8, !tbaa !41
  %214 = load ptr, ptr %12, align 8, !tbaa !5
  %215 = getelementptr inbounds %struct.BIOS_BLOCK_IO_DEV, ptr %214, i32 0, i32 1
  %216 = load ptr, ptr %12, align 8, !tbaa !5
  %217 = getelementptr inbounds %struct.BIOS_BLOCK_IO_DEV, ptr %216, i32 0, i32 3
  %218 = load ptr, ptr %12, align 8, !tbaa !5
  %219 = getelementptr inbounds %struct.BIOS_BLOCK_IO_DEV, ptr %218, i32 0, i32 5
  %220 = load ptr, ptr %219, align 8, !tbaa !42
  %221 = call i64 (ptr, ...) %213(ptr noundef %215, ptr noundef @gEfiBlockIoProtocolGuid, ptr noundef %217, ptr noundef @gEfiDevicePathProtocolGuid, ptr noundef %220, ptr noundef null)
  store i64 %221, ptr %7, align 8, !tbaa !15
  %222 = load i64, ptr %7, align 8, !tbaa !15
  %223 = icmp slt i64 %222, 0
  br i1 %223, label %224, label %230

224:                                              ; preds = %205
  %225 = load ptr, ptr @gBS, align 8, !tbaa !5
  %226 = getelementptr inbounds %struct.EFI_BOOT_SERVICES, ptr %225, i32 0, i32 7
  %227 = load ptr, ptr %226, align 8, !tbaa !43
  %228 = load ptr, ptr %12, align 8, !tbaa !5
  %229 = call i64 %227(ptr noundef %228)
  br label %230

230:                                              ; preds = %224, %205
  %231 = load ptr, ptr @gBS, align 8, !tbaa !5
  %232 = getelementptr inbounds %struct.EFI_BOOT_SERVICES, ptr %231, i32 0, i32 33
  %233 = load ptr, ptr %232, align 8, !tbaa !16
  %234 = load ptr, ptr %5, align 8, !tbaa !5
  %235 = load ptr, ptr %12, align 8, !tbaa !5
  %236 = getelementptr inbounds %struct.BIOS_BLOCK_IO_DEV, ptr %235, i32 0, i32 6
  %237 = load ptr, ptr %4, align 8, !tbaa !5
  %238 = getelementptr inbounds %struct._EFI_DRIVER_BINDING_PROTOCOL, ptr %237, i32 0, i32 5
  %239 = load ptr, ptr %238, align 8, !tbaa !17
  %240 = load ptr, ptr %12, align 8, !tbaa !5
  %241 = getelementptr inbounds %struct.BIOS_BLOCK_IO_DEV, ptr %240, i32 0, i32 1
  %242 = load ptr, ptr %241, align 8, !tbaa !44
  %243 = call i64 %233(ptr noundef %234, ptr noundef @gEfiPciIoProtocolGuid, ptr noundef %236, ptr noundef %239, ptr noundef %242, i32 noundef 8)
  store i64 %243, ptr %7, align 8, !tbaa !15
  br label %250

244:                                              ; preds = %170
  %245 = load ptr, ptr @gBS, align 8, !tbaa !5
  %246 = getelementptr inbounds %struct.EFI_BOOT_SERVICES, ptr %245, i32 0, i32 7
  %247 = load ptr, ptr %246, align 8, !tbaa !43
  %248 = load ptr, ptr %12, align 8, !tbaa !5
  %249 = call i64 %247(ptr noundef %248)
  br label %250

250:                                              ; preds = %244, %230
  br label %251

251:                                              ; preds = %250
  %252 = load i64, ptr %14, align 8, !tbaa !15
  %253 = add i64 %252, 1
  store i64 %253, ptr %14, align 8, !tbaa !15
  br label %157, !llvm.loop !45

254:                                              ; preds = %157
  br label %255

255:                                              ; preds = %254, %169, %127, %79, %69, %59, %50, %37, %24
  %256 = load i64, ptr %7, align 8, !tbaa !15
  %257 = icmp slt i64 %256, 0
  br i1 %257, label %258, label %306

258:                                              ; preds = %255
  %259 = load ptr, ptr %9, align 8, !tbaa !5
  %260 = icmp ne ptr %259, null
  br i1 %260, label %261, label %305

261:                                              ; preds = %258
  %262 = load i8, ptr %17, align 1, !tbaa !9
  %263 = icmp ne i8 %262, 0
  br i1 %263, label %264, label %270

264:                                              ; preds = %261
  %265 = load ptr, ptr %9, align 8, !tbaa !5
  %266 = getelementptr inbounds %struct._EFI_PCI_IO_PROTOCOL, ptr %265, i32 0, i32 12
  %267 = load ptr, ptr %266, align 8, !tbaa !19
  %268 = load ptr, ptr %9, align 8, !tbaa !5
  %269 = call i64 %267(ptr noundef %268, i32 noundef 3, i64 noundef 1792, ptr noundef null)
  br label %270

270:                                              ; preds = %264, %261
  %271 = load ptr, ptr @gBS, align 8, !tbaa !5
  %272 = getelementptr inbounds %struct.EFI_BOOT_SERVICES, ptr %271, i32 0, i32 34
  %273 = load ptr, ptr %272, align 8, !tbaa !47
  %274 = load ptr, ptr %5, align 8, !tbaa !5
  %275 = load ptr, ptr %4, align 8, !tbaa !5
  %276 = getelementptr inbounds %struct._EFI_DRIVER_BINDING_PROTOCOL, ptr %275, i32 0, i32 5
  %277 = load ptr, ptr %276, align 8, !tbaa !17
  %278 = load ptr, ptr %5, align 8, !tbaa !5
  %279 = call i64 %273(ptr noundef %274, ptr noundef @gEfiPciIoProtocolGuid, ptr noundef %277, ptr noundef %278)
  %280 = load ptr, ptr %13, align 8, !tbaa !5
  %281 = icmp ne ptr %280, null
  br i1 %281, label %282, label %292

282:                                              ; preds = %270
  %283 = load ptr, ptr @gBS, align 8, !tbaa !5
  %284 = getelementptr inbounds %struct.EFI_BOOT_SERVICES, ptr %283, i32 0, i32 34
  %285 = load ptr, ptr %284, align 8, !tbaa !47
  %286 = load ptr, ptr %5, align 8, !tbaa !5
  %287 = load ptr, ptr %4, align 8, !tbaa !5
  %288 = getelementptr inbounds %struct._EFI_DRIVER_BINDING_PROTOCOL, ptr %287, i32 0, i32 5
  %289 = load ptr, ptr %288, align 8, !tbaa !17
  %290 = load ptr, ptr %5, align 8, !tbaa !5
  %291 = call i64 %285(ptr noundef %286, ptr noundef @gEfiDevicePathProtocolGuid, ptr noundef %289, ptr noundef %290)
  br label %292

292:                                              ; preds = %282, %270
  %293 = load i64, ptr @mBufferUnder1Mb, align 8, !tbaa !15
  %294 = icmp ne i64 %293, 0
  br i1 %294, label %295, label %304

295:                                              ; preds = %292
  %296 = load i64, ptr @mActiveInstances, align 8, !tbaa !15
  %297 = icmp eq i64 %296, 0
  br i1 %297, label %298, label %304

298:                                              ; preds = %295
  %299 = load ptr, ptr @gBS, align 8, !tbaa !5
  %300 = getelementptr inbounds %struct.EFI_BOOT_SERVICES, ptr %299, i32 0, i32 4
  %301 = load ptr, ptr %300, align 8, !tbaa !48
  %302 = load i64, ptr @mBufferUnder1Mb, align 8, !tbaa !15
  %303 = call i64 %301(i64 noundef %302, i64 noundef 16)
  call void @EfiAcquireLock(ptr noundef @mGlobalDataLock)
  store i64 0, ptr @mBufferUnder1Mb, align 8, !tbaa !15
  call void @EfiReleaseLock(ptr noundef @mGlobalDataLock)
  br label %304

304:                                              ; preds = %298, %295, %292
  br label %305

305:                                              ; preds = %304, %258
  br label %309

306:                                              ; preds = %255
  call void @EfiAcquireLock(ptr noundef @mGlobalDataLock)
  %307 = load i64, ptr @mActiveInstances, align 8, !tbaa !15
  %308 = add i64 %307, 1
  store i64 %308, ptr @mActiveInstances, align 8, !tbaa !15
  call void @EfiReleaseLock(ptr noundef @mGlobalDataLock)
  br label %309

309:                                              ; preds = %306, %305
  %310 = load i64, ptr %7, align 8, !tbaa !15
  call void @llvm.lifetime.end.p0(i64 1, ptr %17) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #3
  call void @llvm.lifetime.end.p0(i64 8, 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 1, 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
  ret i64 %310
}

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

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

declare zeroext i8 @DebugAssertEnabled() #2

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

declare void @EfiAcquireLock(ptr noundef) #2

declare void @EfiReleaseLock(ptr noundef) #2

declare zeroext i8 @DebugPrintEnabled() #2

declare zeroext i8 @DebugPrintLevelEnabled(i64 noundef) #2

declare void @DebugPrint(i64 noundef, ptr noundef, ...) #2

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

declare zeroext i8 @BiosInitBlockIo(ptr noundef) #2

; Function Attrs: nounwind uwtable
declare dso_local void @SetBiosInitBlockIoDevicePath(ptr noundef, ptr noundef, ptr noundef) #0

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 = !{!7, !7, i64 0}
!10 = !{!11, !6, i64 320}
!11 = !{!"", !12, 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}
!12 = !{!"", !13, i64 0, !14, i64 8, !14, i64 12, !14, i64 16, !14, i64 20}
!13 = !{!"long long", !7, i64 0}
!14 = !{!"int", !7, i64 0}
!15 = !{!13, !13, i64 0}
!16 = !{!11, !6, i64 280}
!17 = !{!18, !6, i64 40}
!18 = !{!"_EFI_DRIVER_BINDING_PROTOCOL", !6, i64 0, !6, i64 8, !6, i64 16, !14, i64 24, !6, i64 32, !6, i64 40}
!19 = !{!20, !6, i64 120}
!20 = !{!"_EFI_PCI_IO_PROTOCOL", !6, i64 0, !6, i64 8, !21, i64 16, !21, i64 32, !21, i64 48, !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, !13, i64 144, !6, i64 152}
!21 = !{!"", !6, i64 0, !6, i64 8}
!22 = !{!23, !6, i64 16}
!23 = !{!"_EFI_LEGACY_BIOS_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, !6, i64 64, !6, i64 72, !6, i64 80, !6, i64 88}
!24 = !{!23, !6, i64 24}
!25 = !{!11, !6, i64 40}
!26 = !{!11, !6, i64 64}
!27 = !{!28, !13, i64 0}
!28 = !{!"", !13, i64 0, !6, i64 8, !6, i64 16, !29, i64 24, !30, i64 72, !6, i64 120, !6, i64 128, !6, i64 136, !31, i64 144}
!29 = !{!"_EFI_BLOCK_IO_PROTOCOL", !13, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40}
!30 = !{!"", !14, i64 0, !7, i64 4, !7, i64 5, !7, i64 6, !7, i64 7, !7, i64 8, !14, i64 12, !14, i64 16, !13, i64 24, !13, i64 32, !14, i64 40, !14, i64 44}
!31 = !{!"", !7, i64 0, !7, i64 1, !7, i64 2, !7, i64 3, !7, i64 4, !7, i64 5, !7, i64 6, !7, i64 7, !7, i64 8, !6, i64 16, !7, i64 24, !7, i64 25, !7, i64 26, !7, i64 27, !32, i64 28, !32, i64 30, !33, i64 32}
!32 = !{!"short", !7, i64 0}
!33 = !{!"", !32, i64 0, !32, i64 2, !14, i64 4, !14, i64 8, !14, i64 12, !13, i64 16, !32, i64 24, !14, i64 26, !32, i64 30, !7, i64 32, !7, i64 33, !32, i64 34, !7, i64 36, !7, i64 40, !7, i64 48, !7, i64 56, !7, i64 72, !7, i64 73}
!34 = !{!28, !6, i64 16}
!35 = !{!28, !6, i64 136}
!36 = !{!28, !6, i64 128}
!37 = !{!28, !7, i64 168}
!38 = !{!28, !7, i64 145}
!39 = !{!28, !7, i64 144}
!40 = !{!28, !7, i64 76}
!41 = !{!11, !6, i64 328}
!42 = !{!28, !6, i64 120}
!43 = !{!11, !6, i64 72}
!44 = !{!28, !6, i64 8}
!45 = distinct !{!45, !46}
!46 = !{!"llvm.loop.mustprogress"}
!47 = !{!11, !6, i64 288}
!48 = !{!11, !6, i64 48}


; 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_LOCK = type { i64, i64, i32 }
%struct.GUID = type { i32, i16, i16, [8 x i8] }

@mGlobalDataLock = external dso_local global %struct.EFI_LOCK, align 8
@mActiveInstances = external dso_local local_unnamed_addr global i64, align 8
@mBufferUnder1Mb = external dso_local global i64, align 8
@gBS = external local_unnamed_addr global ptr, align 8
@gEfiLegacyBiosProtocolGuid = external global %struct.GUID, align 4
@gEfiDevicePathProtocolGuid = external global %struct.GUID, align 4
@gEfiPciIoProtocolGuid = external global %struct.GUID, align 4
@.str = external hidden unnamed_addr constant [162 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [22 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [33 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [20 x i8], align 1
@mEdd11Buffer = external dso_local local_unnamed_addr global ptr, align 8
@mLegacyDriverUnder1Mb = external dso_local local_unnamed_addr global ptr, align 8
@mEddBufferUnder1Mb = external dso_local local_unnamed_addr global ptr, align 8
@gEfiBlockIoProtocolGuid = external global %struct.GUID, align 4

; Function Attrs: nounwind uwtable
define dso_local i64 @BiosBlockIoDriverBindingStart(ptr nocapture noundef readonly %0, ptr noundef %1, ptr nocapture noundef readnone %2) local_unnamed_addr #0 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i8, align 1
  %7 = alloca i8, align 1
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca i64, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %5) #3
  call void @llvm.lifetime.start.p0(i64 1, ptr nonnull %6) #3
  call void @llvm.lifetime.start.p0(i64 1, ptr nonnull %7) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %8) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %9) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %10) #3
  store ptr null, ptr %5, align 8, !tbaa !5
  store ptr null, ptr %9, align 8, !tbaa !5
  %11 = load ptr, ptr @gBS, align 8, !tbaa !5
  %12 = getelementptr inbounds i8, ptr %11, i64 320
  %13 = load ptr, ptr %12, align 8, !tbaa !9
  %14 = call i64 %13(ptr noundef nonnull @gEfiLegacyBiosProtocolGuid, ptr noundef null, ptr noundef nonnull %4) #3
  %15 = icmp slt i64 %14, 0
  br i1 %15, label %.thread, label %16

16:                                               ; preds = %3
  %17 = load ptr, ptr @gBS, align 8, !tbaa !5
  %18 = getelementptr inbounds i8, ptr %17, i64 280
  %19 = load ptr, ptr %18, align 8, !tbaa !14
  %20 = getelementptr inbounds i8, ptr %0, i64 40
  %21 = load ptr, ptr %20, align 8, !tbaa !15
  %22 = call i64 %19(ptr noundef %1, ptr noundef nonnull @gEfiPciIoProtocolGuid, ptr noundef nonnull %5, ptr noundef %21, ptr noundef %1, i32 noundef 16) #3
  %23 = icmp slt i64 %22, 0
  br i1 %23, label %.thread, label %24

24:                                               ; preds = %16
  %25 = load ptr, ptr @gBS, align 8, !tbaa !5
  %26 = getelementptr inbounds i8, ptr %25, i64 280
  %27 = load ptr, ptr %26, align 8, !tbaa !14
  %28 = load ptr, ptr %20, align 8, !tbaa !15
  %29 = call i64 %27(ptr noundef %1, ptr noundef nonnull @gEfiDevicePathProtocolGuid, ptr noundef nonnull %9, ptr noundef %28, ptr noundef %1, i32 noundef 16) #3
  %30 = icmp slt i64 %29, 0
  br i1 %30, label %.thread, label %31

31:                                               ; preds = %24
  %32 = load ptr, ptr %5, align 8, !tbaa !5
  %33 = getelementptr inbounds i8, ptr %32, i64 120
  %34 = load ptr, ptr %33, align 8, !tbaa !17
  %35 = call i64 %34(ptr noundef %32, i32 noundef 2, i64 noundef 1792, ptr noundef null) #3
  %36 = icmp slt i64 %35, 0
  br i1 %36, label %.thread, label %37

37:                                               ; preds = %31
  %38 = load ptr, ptr %4, align 8, !tbaa !5
  %39 = getelementptr inbounds i8, ptr %38, i64 16
  %40 = load ptr, ptr %39, align 8, !tbaa !20
  %41 = call i64 %40(ptr noundef %38, ptr noundef %1, ptr noundef null, ptr noundef null, ptr noundef nonnull %10) #3
  %42 = icmp slt i64 %41, 0
  br i1 %42, label %.thread, label %43

43:                                               ; preds = %37
  %44 = load ptr, ptr %4, align 8, !tbaa !5
  %45 = getelementptr inbounds i8, ptr %44, i64 24
  %46 = load ptr, ptr %45, align 8, !tbaa !22
  %47 = call i64 %46(ptr noundef %44, ptr noundef %1, ptr noundef null, ptr noundef nonnull %10, ptr noundef nonnull %6, ptr noundef nonnull %7, ptr noundef null, ptr noundef null) #3
  %48 = icmp slt i64 %47, 0
  br i1 %48, label %.thread, label %49

49:                                               ; preds = %43
  %50 = load i64, ptr @mBufferUnder1Mb, align 8, !tbaa !23
  %51 = icmp eq i64 %50, 0
  br i1 %51, label %52, label %89

52:                                               ; preds = %49
  %53 = call zeroext i8 @DebugAssertEnabled() #3
  %54 = icmp eq i8 %53, 0
  %55 = load i64, ptr @mActiveInstances, align 8
  %56 = icmp eq i64 %55, 0
  %or.cond3 = select i1 %54, i1 true, i1 %56
  br i1 %or.cond3, label %58, label %57

57:                                               ; preds = %52
  call void @DebugAssert(ptr noundef nonnull @.str, i64 noundef 335, ptr noundef nonnull @.str.1) #3
  br label %58

58:                                               ; preds = %57, %52
  call void @EfiAcquireLock(ptr noundef nonnull @mGlobalDataLock) #3
  store i64 1048575, ptr @mBufferUnder1Mb, align 8, !tbaa !23
  %59 = load ptr, ptr @gBS, align 8, !tbaa !5
  %60 = getelementptr inbounds i8, ptr %59, i64 40
  %61 = load ptr, ptr %60, align 8, !tbaa !24
  %62 = call i64 %61(i32 noundef 1, i32 noundef 4, i64 noundef 16, ptr noundef nonnull @mBufferUnder1Mb) #3
  call void @EfiReleaseLock(ptr noundef nonnull @mGlobalDataLock) #3
  %63 = icmp slt i64 %62, 0
  br i1 %63, label %64, label %73

64:                                               ; preds = %58
  %65 = call zeroext i8 @DebugAssertEnabled() #3
  %.not60 = icmp eq i8 %65, 0
  br i1 %.not60, label %72, label %66

66:                                               ; preds = %64
  %67 = call zeroext i8 @DebugPrintEnabled() #3
  %.not61 = icmp eq i8 %67, 0
  br i1 %.not61, label %71, label %68

68:                                               ; preds = %66
  %69 = call zeroext i8 @DebugPrintLevelEnabled(i64 noundef 2147483648) #3
  %.not62 = icmp eq i8 %69, 0
  br i1 %.not62, label %71, label %70

70:                                               ; preds = %68
  call void (i64, ptr, ...) @DebugPrint(i64 noundef 2147483648, ptr noundef nonnull @.str.2, i64 noundef %62) #3
  br label %71

71:                                               ; preds = %68, %70, %66
  call void @DebugAssert(ptr noundef nonnull @.str, i64 noundef 360, ptr noundef nonnull @.str.3) #3
  br label %72

72:                                               ; preds = %71, %64
  store i64 0, ptr @mBufferUnder1Mb, align 8, !tbaa !23
  br label %.thread

73:                                               ; preds = %58
  %74 = load i64, ptr @mBufferUnder1Mb, align 8, !tbaa !23
  %75 = sub i64 0, %74
  %76 = and i64 %75, 7
  %77 = add i64 %76, %74
  %78 = inttoptr i64 %77 to ptr
  store ptr %78, ptr @mEdd11Buffer, align 8, !tbaa !5
  %79 = add i64 %77, 65024
  %80 = sub i64 0, %77
  %81 = and i64 %80, 7
  %82 = add i64 %79, %81
  %83 = inttoptr i64 %82 to ptr
  store ptr %83, ptr @mLegacyDriverUnder1Mb, align 8, !tbaa !5
  %84 = add i64 %82, 112
  %85 = sub i64 0, %82
  %86 = and i64 %85, 7
  %87 = add i64 %84, %86
  %88 = inttoptr i64 %87 to ptr
  store ptr %88, ptr @mEddBufferUnder1Mb, align 8, !tbaa !5
  br label %89

89:                                               ; preds = %73, %49
  %.045 = phi i64 [ %62, %73 ], [ %47, %49 ]
  %90 = load i8, ptr %6, align 1, !tbaa !25
  %91 = load i8, ptr %7, align 1, !tbaa !25
  %92 = icmp ult i8 %90, %91
  br i1 %92, label %.lr.ph.preheader, label %._crit_edge.thread

.lr.ph.preheader:                                 ; preds = %89
  %93 = zext i8 %90 to i64
  br label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph.preheader, %152
  %.04672 = phi i64 [ %153, %152 ], [ %93, %.lr.ph.preheader ]
  %94 = load ptr, ptr @gBS, align 8, !tbaa !5
  %95 = getelementptr inbounds i8, ptr %94, i64 64
  %96 = load ptr, ptr %95, align 8, !tbaa !26
  %97 = call i64 %96(i32 noundef 4, i64 noundef 256, ptr noundef nonnull %8) #3
  %98 = icmp slt i64 %97, 0
  br i1 %98, label %.thread, label %99

99:                                               ; preds = %.lr.ph
  %100 = load ptr, ptr %8, align 8, !tbaa !5
  %101 = call ptr @ZeroMem(ptr noundef %100, i64 noundef 256) #3
  %102 = load ptr, ptr %8, align 8, !tbaa !5
  store i64 1869177442, ptr %102, align 8, !tbaa !27
  %103 = getelementptr inbounds i8, ptr %102, i64 16
  store ptr %1, ptr %103, align 8, !tbaa !34
  %104 = load ptr, ptr %4, align 8, !tbaa !5
  %105 = getelementptr inbounds i8, ptr %102, i64 136
  store ptr %104, ptr %105, align 8, !tbaa !35
  %106 = load ptr, ptr %5, align 8, !tbaa !5
  %107 = getelementptr inbounds i8, ptr %102, i64 128
  store ptr %106, ptr %107, align 8, !tbaa !36
  %108 = getelementptr inbounds i8, ptr %102, i64 168
  store i8 0, ptr %108, align 8, !tbaa !37
  %109 = trunc i64 %.04672 to i8
  %110 = getelementptr inbounds i8, ptr %102, i64 145
  store i8 %109, ptr %110, align 1, !tbaa !38
  %111 = add i8 %109, -61
  %112 = getelementptr inbounds i8, ptr %102, i64 144
  store i8 %111, ptr %112, align 8, !tbaa !39
  %113 = getelementptr inbounds i8, ptr %102, i64 76
  store i8 0, ptr %113, align 4, !tbaa !40
  %114 = call zeroext i8 @BiosInitBlockIo(ptr noundef nonnull %102) #3
  %.not = icmp eq i8 %114, 0
  br i1 %.not, label %146, label %115

115:                                              ; preds = %99
  %116 = load ptr, ptr %9, align 8, !tbaa !5
  %117 = load ptr, ptr %8, align 8, !tbaa !5
  %118 = getelementptr inbounds i8, ptr %117, i64 144
  %119 = getelementptr inbounds i8, ptr %117, i64 120
  call void @SetBiosInitBlockIoDevicePath(ptr noundef %116, ptr noundef nonnull %118, ptr noundef nonnull %119)
  %120 = load ptr, ptr @gBS, align 8, !tbaa !5
  %121 = getelementptr inbounds i8, ptr %120, i64 328
  %122 = load ptr, ptr %121, align 8, !tbaa !41
  %123 = load ptr, ptr %8, align 8, !tbaa !5
  %124 = getelementptr inbounds i8, ptr %123, i64 8
  %125 = getelementptr inbounds i8, ptr %123, i64 24
  %126 = getelementptr inbounds i8, ptr %123, i64 120
  %127 = load ptr, ptr %126, align 8, !tbaa !42
  %128 = call i64 (ptr, ...) %122(ptr noundef nonnull %124, ptr noundef nonnull @gEfiBlockIoProtocolGuid, ptr noundef nonnull %125, ptr noundef nonnull @gEfiDevicePathProtocolGuid, ptr noundef %127, ptr noundef null) #3
  %129 = icmp slt i64 %128, 0
  br i1 %129, label %130, label %136

130:                                              ; preds = %115
  %131 = load ptr, ptr @gBS, align 8, !tbaa !5
  %132 = getelementptr inbounds i8, ptr %131, i64 72
  %133 = load ptr, ptr %132, align 8, !tbaa !43
  %134 = load ptr, ptr %8, align 8, !tbaa !5
  %135 = call i64 %133(ptr noundef %134) #3
  br label %136

136:                                              ; preds = %130, %115
  %137 = load ptr, ptr @gBS, align 8, !tbaa !5
  %138 = getelementptr inbounds i8, ptr %137, i64 280
  %139 = load ptr, ptr %138, align 8, !tbaa !14
  %140 = load ptr, ptr %8, align 8, !tbaa !5
  %141 = getelementptr inbounds i8, ptr %140, i64 128
  %142 = load ptr, ptr %20, align 8, !tbaa !15
  %143 = getelementptr inbounds i8, ptr %140, i64 8
  %144 = load ptr, ptr %143, align 8, !tbaa !44
  %145 = call i64 %139(ptr noundef %1, ptr noundef nonnull @gEfiPciIoProtocolGuid, ptr noundef nonnull %141, ptr noundef %142, ptr noundef %144, i32 noundef 8) #3
  br label %152

146:                                              ; preds = %99
  %147 = load ptr, ptr @gBS, align 8, !tbaa !5
  %148 = getelementptr inbounds i8, ptr %147, i64 72
  %149 = load ptr, ptr %148, align 8, !tbaa !43
  %150 = load ptr, ptr %8, align 8, !tbaa !5
  %151 = call i64 %149(ptr noundef %150) #3
  br label %152

152:                                              ; preds = %136, %146
  %.2 = phi i64 [ %145, %136 ], [ %97, %146 ]
  %153 = add nuw nsw i64 %.04672, 1
  %154 = load i8, ptr %7, align 1, !tbaa !25
  %155 = zext i8 %154 to i64
  %156 = icmp ult i64 %153, %155
  br i1 %156, label %.lr.ph, label %._crit_edge, !llvm.loop !45

._crit_edge:                                      ; preds = %152
  %157 = icmp slt i64 %.2, 0
  br i1 %157, label %.thread, label %._crit_edge.thread

.thread:                                          ; preds = %.lr.ph, %72, %43, %37, %31, %24, %16, %3, %._crit_edge
  %.not6470 = phi i1 [ false, %._crit_edge ], [ false, %72 ], [ false, %43 ], [ false, %37 ], [ true, %31 ], [ true, %24 ], [ true, %16 ], [ true, %3 ], [ false, %.lr.ph ]
  %.369 = phi i64 [ %.2, %._crit_edge ], [ -9223372036854775799, %72 ], [ %47, %43 ], [ %41, %37 ], [ %35, %31 ], [ %29, %24 ], [ %22, %16 ], [ %14, %3 ], [ %97, %.lr.ph ]
  %158 = load ptr, ptr %5, align 8, !tbaa !5
  %.not63 = icmp eq ptr %158, null
  br i1 %.not63, label %190, label %159

159:                                              ; preds = %.thread
  br i1 %.not6470, label %164, label %160

160:                                              ; preds = %159
  %161 = getelementptr inbounds i8, ptr %158, i64 120
  %162 = load ptr, ptr %161, align 8, !tbaa !17
  %163 = call i64 %162(ptr noundef nonnull %158, i32 noundef 3, i64 noundef 1792, ptr noundef null) #3
  br label %164

164:                                              ; preds = %160, %159
  %165 = load ptr, ptr @gBS, align 8, !tbaa !5
  %166 = getelementptr inbounds i8, ptr %165, i64 288
  %167 = load ptr, ptr %166, align 8, !tbaa !47
  %168 = getelementptr inbounds i8, ptr %0, i64 40
  %169 = load ptr, ptr %168, align 8, !tbaa !15
  %170 = call i64 %167(ptr noundef %1, ptr noundef nonnull @gEfiPciIoProtocolGuid, ptr noundef %169, ptr noundef %1) #3
  %171 = load ptr, ptr %9, align 8, !tbaa !5
  %.not65 = icmp eq ptr %171, null
  br i1 %.not65, label %178, label %172

172:                                              ; preds = %164
  %173 = load ptr, ptr @gBS, align 8, !tbaa !5
  %174 = getelementptr inbounds i8, ptr %173, i64 288
  %175 = load ptr, ptr %174, align 8, !tbaa !47
  %176 = load ptr, ptr %168, align 8, !tbaa !15
  %177 = call i64 %175(ptr noundef %1, ptr noundef nonnull @gEfiDevicePathProtocolGuid, ptr noundef %176, ptr noundef %1) #3
  br label %178

178:                                              ; preds = %172, %164
  %179 = load i64, ptr @mBufferUnder1Mb, align 8, !tbaa !23
  %180 = icmp ne i64 %179, 0
  %181 = load i64, ptr @mActiveInstances, align 8
  %182 = icmp eq i64 %181, 0
  %or.cond = select i1 %180, i1 %182, i1 false
  br i1 %or.cond, label %183, label %190

183:                                              ; preds = %178
  %184 = load ptr, ptr @gBS, align 8, !tbaa !5
  %185 = getelementptr inbounds i8, ptr %184, i64 48
  %186 = load ptr, ptr %185, align 8, !tbaa !48
  %187 = call i64 %186(i64 noundef %179, i64 noundef 16) #3
  call void @EfiAcquireLock(ptr noundef nonnull @mGlobalDataLock) #3
  store i64 0, ptr @mBufferUnder1Mb, align 8, !tbaa !23
  br label %.sink.split

._crit_edge.thread:                               ; preds = %89, %._crit_edge
  %.1.lcssa75 = phi i64 [ %.2, %._crit_edge ], [ %.045, %89 ]
  call void @EfiAcquireLock(ptr noundef nonnull @mGlobalDataLock) #3
  %188 = load i64, ptr @mActiveInstances, align 8, !tbaa !23
  %189 = add i64 %188, 1
  store i64 %189, ptr @mActiveInstances, align 8, !tbaa !23
  br label %.sink.split

.sink.split:                                      ; preds = %._crit_edge.thread, %183
  %.368.ph = phi i64 [ %.1.lcssa75, %._crit_edge.thread ], [ %.369, %183 ]
  call void @EfiReleaseLock(ptr noundef nonnull @mGlobalDataLock) #3
  br label %190

190:                                              ; preds = %.sink.split, %.thread, %178
  %.368 = phi i64 [ %.369, %.thread ], [ %.369, %178 ], [ %.368.ph, %.sink.split ]
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %10) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %9) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %8) #3
  call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %7) #3
  call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %6) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #3
  ret i64 %.368
}

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

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

declare zeroext i8 @DebugAssertEnabled() local_unnamed_addr #2

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

declare void @EfiAcquireLock(ptr noundef) local_unnamed_addr #2

declare void @EfiReleaseLock(ptr noundef) local_unnamed_addr #2

declare zeroext i8 @DebugPrintEnabled() local_unnamed_addr #2

declare zeroext i8 @DebugPrintLevelEnabled(i64 noundef) local_unnamed_addr #2

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

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

declare zeroext i8 @BiosInitBlockIo(ptr noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
declare dso_local void @SetBiosInitBlockIoDevicePath(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #0

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, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !6, i64 320}
!10 = !{!"", !11, 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}
!11 = !{!"", !12, i64 0, !13, i64 8, !13, i64 12, !13, i64 16, !13, i64 20}
!12 = !{!"long long", !7, i64 0}
!13 = !{!"int", !7, i64 0}
!14 = !{!10, !6, i64 280}
!15 = !{!16, !6, i64 40}
!16 = !{!"_EFI_DRIVER_BINDING_PROTOCOL", !6, i64 0, !6, i64 8, !6, i64 16, !13, i64 24, !6, i64 32, !6, i64 40}
!17 = !{!18, !6, i64 120}
!18 = !{!"_EFI_PCI_IO_PROTOCOL", !6, i64 0, !6, i64 8, !19, i64 16, !19, i64 32, !19, i64 48, !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, !12, i64 144, !6, i64 152}
!19 = !{!"", !6, i64 0, !6, i64 8}
!20 = !{!21, !6, i64 16}
!21 = !{!"_EFI_LEGACY_BIOS_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, !6, i64 64, !6, i64 72, !6, i64 80, !6, i64 88}
!22 = !{!21, !6, i64 24}
!23 = !{!12, !12, i64 0}
!24 = !{!10, !6, i64 40}
!25 = !{!7, !7, i64 0}
!26 = !{!10, !6, i64 64}
!27 = !{!28, !12, i64 0}
!28 = !{!"", !12, i64 0, !6, i64 8, !6, i64 16, !29, i64 24, !30, i64 72, !6, i64 120, !6, i64 128, !6, i64 136, !31, i64 144}
!29 = !{!"_EFI_BLOCK_IO_PROTOCOL", !12, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40}
!30 = !{!"", !13, i64 0, !7, i64 4, !7, i64 5, !7, i64 6, !7, i64 7, !7, i64 8, !13, i64 12, !13, i64 16, !12, i64 24, !12, i64 32, !13, i64 40, !13, i64 44}
!31 = !{!"", !7, i64 0, !7, i64 1, !7, i64 2, !7, i64 3, !7, i64 4, !7, i64 5, !7, i64 6, !7, i64 7, !7, i64 8, !6, i64 16, !7, i64 24, !7, i64 25, !7, i64 26, !7, i64 27, !32, i64 28, !32, i64 30, !33, i64 32}
!32 = !{!"short", !7, i64 0}
!33 = !{!"", !32, i64 0, !32, i64 2, !13, i64 4, !13, i64 8, !13, i64 12, !12, i64 16, !32, i64 24, !13, i64 26, !32, i64 30, !7, i64 32, !7, i64 33, !32, i64 34, !7, i64 36, !7, i64 40, !7, i64 48, !7, i64 56, !7, i64 72, !7, i64 73}
!34 = !{!28, !6, i64 16}
!35 = !{!28, !6, i64 136}
!36 = !{!28, !6, i64 128}
!37 = !{!28, !7, i64 168}
!38 = !{!28, !7, i64 145}
!39 = !{!28, !7, i64 144}
!40 = !{!28, !7, i64 76}
!41 = !{!10, !6, i64 328}
!42 = !{!28, !6, i64 120}
!43 = !{!10, !6, i64 72}
!44 = !{!28, !6, i64 8}
!45 = distinct !{!45, !46}
!46 = !{!"llvm.loop.mustprogress"}
!47 = !{!10, !6, i64 288}
!48 = !{!10, !6, i64 48}


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