; LLVM IR from thalium/icebox :: third_party/virtualbox/src/VBox/Devices/EFI/Firmware/MdeModulePkg/Bus/Scsi (InitializeInstallDiskInfo)

; 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_DISK_INFO_PROTOCOL = type { %struct.GUID, ptr, ptr, ptr, ptr }
%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.SCSI_DISK_DEV = type { i32, ptr, %struct._EFI_BLOCK_IO_PROTOCOL, %struct.EFI_BLOCK_IO_MEDIA, ptr, i8, i8, i16, ptr, i64, %struct.EFI_SCSI_INQUIRY_DATA, ptr, %struct._EFI_DISK_INFO_PROTOCOL, i32, i32, %struct.ATAPI_IDENTIFY_DATA, i8 }
%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.EFI_SCSI_INQUIRY_DATA = type { i16, i8, i8, i8, [91 x i8] }
%struct.ATAPI_IDENTIFY_DATA = type { i16, i16, i16, [7 x i16], [20 x i8], [3 x i16], [8 x i8], [40 x i8], [2 x i16], i16, i16, i16, i16, i16, [8 x i16], i16, i16, i16, i16, i16, i16, i16, [2 x i16], [2 x i16], [2 x i16], i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, [13 x i16], [4 x i16], [4 x i16], [3 x i16], i16, i16, [4 x i16], i16, [2 x i16], i16, [31 x i16], [16 x i16], [46 x i16], i16, i16, [31 x i16], i16 }
%struct.ATAPI_DEVICE_PATH = type { %struct.EFI_DEVICE_PATH_PROTOCOL, i8, i8, i16 }
%struct.EFI_DEVICE_PATH_PROTOCOL = type { i8, i8, [2 x i8] }
%struct.SATA_DEVICE_PATH = type { %struct.EFI_DEVICE_PATH_PROTOCOL, i16, i16, i16 }

@gScsiDiskInfoProtocolTemplate = external dso_local global %struct._EFI_DISK_INFO_PROTOCOL, align 8
@.str = external hidden unnamed_addr constant [33 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [146 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [20 x i8], align 1
@gBS = external global ptr, align 8
@gEfiDiskInfoUfsInterfaceGuid = external global %struct.GUID, align 4
@gEfiDevicePathProtocolGuid = external global %struct.GUID, align 4
@gEfiDiskInfoIdeInterfaceGuid = external global %struct.GUID, align 4
@gEfiDiskInfoAhciInterfaceGuid = external global %struct.GUID, align 4

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

declare zeroext i8 @DebugAssertEnabled() #1

declare zeroext i8 @DebugPrintEnabled() #1

declare zeroext i8 @DebugPrintLevelEnabled(i64 noundef) #1

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

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

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

; Function Attrs: nounwind uwtable
define dso_local void @InitializeInstallDiskInfo(ptr noundef %0, ptr noundef %1) #2 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i64, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca i64, align 8
  %11 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #3
  %12 = load ptr, ptr @gBS, align 8, !tbaa !5
  %13 = getelementptr inbounds %struct.EFI_BOOT_SERVICES, ptr %12, i32 0, i32 17
  %14 = load ptr, ptr %13, align 8, !tbaa !9
  %15 = load ptr, ptr %4, align 8, !tbaa !5
  %16 = call i64 %14(ptr noundef %15, ptr noundef @gEfiDevicePathProtocolGuid, ptr noundef %6)
  store i64 %16, ptr %5, align 8, !tbaa !14
  br label %17

17:                                               ; preds = %2
  %18 = call zeroext i8 @DebugAssertEnabled()
  %19 = icmp ne i8 %18, 0
  br i1 %19, label %20, label %40

20:                                               ; preds = %17
  %21 = load i64, ptr %5, align 8, !tbaa !14
  %22 = icmp slt i64 %21, 0
  br i1 %22, label %23, label %39

23:                                               ; preds = %20
  br label %24

24:                                               ; preds = %23
  %25 = call zeroext i8 @DebugPrintEnabled()
  %26 = icmp ne i8 %25, 0
  br i1 %26, label %27, label %36

27:                                               ; preds = %24
  br label %28

28:                                               ; preds = %27
  %29 = call zeroext i8 @DebugPrintLevelEnabled(i64 noundef 2147483648)
  %30 = icmp ne i8 %29, 0
  br i1 %30, label %31, label %33

31:                                               ; preds = %28
  %32 = load i64, ptr %5, align 8, !tbaa !14
  call void (i64, ptr, ...) @DebugPrint(i64 noundef 2147483648, ptr noundef @.str, i64 noundef %32)
  br label %33

33:                                               ; preds = %31, %28
  br label %34

34:                                               ; preds = %33
  br label %35

35:                                               ; preds = %34
  br label %36

36:                                               ; preds = %35, %24
  br label %37

37:                                               ; preds = %36
  br label %38

38:                                               ; preds = %37
  call void @DebugAssert(ptr noundef @.str.1, i64 noundef 3255, ptr noundef @.str.2)
  br label %39

39:                                               ; preds = %38, %20
  br label %40

40:                                               ; preds = %39, %17
  br label %41

41:                                               ; preds = %40
  br label %42

42:                                               ; preds = %41
  %43 = load ptr, ptr %3, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct.SCSI_DISK_DEV, ptr %43, i32 0, i32 12
  %45 = call ptr @CopyMem(ptr noundef %44, ptr noundef @gScsiDiskInfoProtocolTemplate, i64 noundef 48)
  br label %46

46:                                               ; preds = %148, %42
  %47 = load ptr, ptr %6, align 8, !tbaa !5
  %48 = call zeroext i8 @IsDevicePathEnd(ptr noundef %47)
  %49 = icmp ne i8 %48, 0
  %50 = xor i1 %49, true
  br i1 %50, label %51, label %150

51:                                               ; preds = %46
  %52 = load ptr, ptr %6, align 8, !tbaa !5
  %53 = call ptr @NextDevicePathNode(ptr noundef %52)
  store ptr %53, ptr %7, align 8, !tbaa !5
  %54 = load ptr, ptr %6, align 8, !tbaa !5
  %55 = call zeroext i8 @DevicePathType(ptr noundef %54)
  %56 = zext i8 %55 to i32
  %57 = icmp eq i32 %56, 1
  br i1 %57, label %58, label %132

58:                                               ; preds = %51
  %59 = load ptr, ptr %6, align 8, !tbaa !5
  %60 = call zeroext i8 @DevicePathSubType(ptr noundef %59)
  %61 = zext i8 %60 to i32
  %62 = icmp eq i32 %61, 1
  br i1 %62, label %63, label %132

63:                                               ; preds = %58
  %64 = load ptr, ptr %7, align 8, !tbaa !5
  %65 = call zeroext i8 @DevicePathType(ptr noundef %64)
  %66 = zext i8 %65 to i32
  %67 = icmp eq i32 %66, 3
  br i1 %67, label %68, label %132

68:                                               ; preds = %63
  %69 = load ptr, ptr %7, align 8, !tbaa !5
  %70 = call zeroext i8 @DevicePathSubType(ptr noundef %69)
  %71 = zext i8 %70 to i32
  %72 = icmp eq i32 %71, 1
  br i1 %72, label %78, label %73

73:                                               ; preds = %68
  %74 = load ptr, ptr %7, align 8, !tbaa !5
  %75 = call zeroext i8 @DevicePathSubType(ptr noundef %74)
  %76 = zext i8 %75 to i32
  %77 = icmp eq i32 %76, 18
  br i1 %77, label %78, label %132

78:                                               ; preds = %73, %68
  store i64 3, ptr %10, align 8, !tbaa !14
  br label %79

79:                                               ; preds = %127, %78
  %80 = load ptr, ptr %3, align 8, !tbaa !5
  %81 = call i64 @AtapiIdentifyDevice(ptr noundef %80)
  store i64 %81, ptr %5, align 8, !tbaa !14
  %82 = load i64, ptr %5, align 8, !tbaa !14
  %83 = icmp slt i64 %82, 0
  br i1 %83, label %126, label %84

84:                                               ; preds = %79
  %85 = load ptr, ptr %7, align 8, !tbaa !5
  %86 = call zeroext i8 @DevicePathSubType(ptr noundef %85)
  %87 = zext i8 %86 to i32
  %88 = icmp eq i32 %87, 1
  br i1 %88, label %89, label %107

89:                                               ; preds = %84
  %90 = load ptr, ptr %7, align 8, !tbaa !5
  store ptr %90, ptr %8, align 8, !tbaa !5
  %91 = load ptr, ptr %8, align 8, !tbaa !5
  %92 = getelementptr inbounds %struct.ATAPI_DEVICE_PATH, ptr %91, i32 0, i32 1
  %93 = load i8, ptr %92, align 1, !tbaa !15
  %94 = zext i8 %93 to i32
  %95 = load ptr, ptr %3, align 8, !tbaa !5
  %96 = getelementptr inbounds %struct.SCSI_DISK_DEV, ptr %95, i32 0, i32 13
  store i32 %94, ptr %96, align 8, !tbaa !19
  %97 = load ptr, ptr %8, align 8, !tbaa !5
  %98 = getelementptr inbounds %struct.ATAPI_DEVICE_PATH, ptr %97, i32 0, i32 2
  %99 = load i8, ptr %98, align 1, !tbaa !27
  %100 = zext i8 %99 to i32
  %101 = load ptr, ptr %3, align 8, !tbaa !5
  %102 = getelementptr inbounds %struct.SCSI_DISK_DEV, ptr %101, i32 0, i32 14
  store i32 %100, ptr %102, align 4, !tbaa !28
  %103 = load ptr, ptr %3, align 8, !tbaa !5
  %104 = getelementptr inbounds %struct.SCSI_DISK_DEV, ptr %103, i32 0, i32 12
  %105 = getelementptr inbounds %struct._EFI_DISK_INFO_PROTOCOL, ptr %104, i32 0, i32 0
  %106 = call ptr @CopyGuid(ptr noundef %105, ptr noundef @gEfiDiskInfoIdeInterfaceGuid)
  br label %125

107:                                              ; preds = %84
  %108 = load ptr, ptr %7, align 8, !tbaa !5
  store ptr %108, ptr %9, align 8, !tbaa !5
  %109 = load ptr, ptr %9, align 8, !tbaa !5
  %110 = getelementptr inbounds %struct.SATA_DEVICE_PATH, ptr %109, i32 0, i32 1
  %111 = load i16, ptr %110, align 1, !tbaa !29
  %112 = zext i16 %111 to i32
  %113 = load ptr, ptr %3, align 8, !tbaa !5
  %114 = getelementptr inbounds %struct.SCSI_DISK_DEV, ptr %113, i32 0, i32 13
  store i32 %112, ptr %114, align 8, !tbaa !19
  %115 = load ptr, ptr %9, align 8, !tbaa !5
  %116 = getelementptr inbounds %struct.SATA_DEVICE_PATH, ptr %115, i32 0, i32 2
  %117 = load i16, ptr %116, align 1, !tbaa !31
  %118 = zext i16 %117 to i32
  %119 = load ptr, ptr %3, align 8, !tbaa !5
  %120 = getelementptr inbounds %struct.SCSI_DISK_DEV, ptr %119, i32 0, i32 14
  store i32 %118, ptr %120, align 4, !tbaa !28
  %121 = load ptr, ptr %3, align 8, !tbaa !5
  %122 = getelementptr inbounds %struct.SCSI_DISK_DEV, ptr %121, i32 0, i32 12
  %123 = getelementptr inbounds %struct._EFI_DISK_INFO_PROTOCOL, ptr %122, i32 0, i32 0
  %124 = call ptr @CopyGuid(ptr noundef %123, ptr noundef @gEfiDiskInfoAhciInterfaceGuid)
  br label %125

125:                                              ; preds = %107, %89
  store i32 1, ptr %11, align 4
  br label %151

126:                                              ; preds = %79
  br label %127

127:                                              ; preds = %126
  %128 = load i64, ptr %10, align 8, !tbaa !14
  %129 = add i64 %128, -1
  store i64 %129, ptr %10, align 8, !tbaa !14
  %130 = icmp ugt i64 %129, 0
  br i1 %130, label %79, label %131, !llvm.loop !32

131:                                              ; preds = %127
  br label %148

132:                                              ; preds = %73, %63, %58, %51
  %133 = load ptr, ptr %7, align 8, !tbaa !5
  %134 = call zeroext i8 @DevicePathType(ptr noundef %133)
  %135 = zext i8 %134 to i32
  %136 = icmp eq i32 %135, 3
  br i1 %136, label %137, label %147

137:                                              ; preds = %132
  %138 = load ptr, ptr %7, align 8, !tbaa !5
  %139 = call zeroext i8 @DevicePathSubType(ptr noundef %138)
  %140 = zext i8 %139 to i32
  %141 = icmp eq i32 %140, 25
  br i1 %141, label %142, label %147

142:                                              ; preds = %137
  %143 = load ptr, ptr %3, align 8, !tbaa !5
  %144 = getelementptr inbounds %struct.SCSI_DISK_DEV, ptr %143, i32 0, i32 12
  %145 = getelementptr inbounds %struct._EFI_DISK_INFO_PROTOCOL, ptr %144, i32 0, i32 0
  %146 = call ptr @CopyGuid(ptr noundef %145, ptr noundef @gEfiDiskInfoUfsInterfaceGuid)
  br label %150

147:                                              ; preds = %137, %132
  br label %148

148:                                              ; preds = %147, %131
  %149 = load ptr, ptr %7, align 8, !tbaa !5
  store ptr %149, ptr %6, align 8, !tbaa !5
  br label %46, !llvm.loop !34

150:                                              ; preds = %142, %46
  store i32 1, ptr %11, align 4
  br label %151

151:                                              ; preds = %150, %125
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #3
  ret void
}

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

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

declare zeroext i8 @IsDevicePathEnd(ptr noundef) #1

declare ptr @NextDevicePathNode(ptr noundef) #1

declare zeroext i8 @DevicePathType(ptr noundef) #1

declare zeroext i8 @DevicePathSubType(ptr noundef) #1

declare ptr @CopyGuid(ptr noundef, ptr noundef) #1

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { nounwind }

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !6, i64 152}
!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 = !{!12, !12, i64 0}
!15 = !{!16, !7, i64 4}
!16 = !{!"", !17, i64 0, !7, i64 4, !7, i64 5, !18, i64 6}
!17 = !{!"", !7, i64 0, !7, i64 1, !7, i64 2}
!18 = !{!"short", !7, i64 0}
!19 = !{!20, !13, i64 296}
!20 = !{!"", !13, i64 0, !6, i64 8, !21, i64 16, !22, i64 64, !6, i64 112, !7, i64 120, !7, i64 121, !18, i64 122, !6, i64 128, !12, i64 136, !23, i64 144, !6, i64 240, !24, i64 248, !13, i64 296, !13, i64 300, !26, i64 304, !7, i64 816}
!21 = !{!"_EFI_BLOCK_IO_PROTOCOL", !12, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40}
!22 = !{!"", !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}
!23 = !{!"", !7, i64 0, !7, i64 0, !7, i64 1, !7, i64 1, !7, i64 2, !7, i64 3, !7, i64 4, !7, i64 5}
!24 = !{!"_EFI_DISK_INFO_PROTOCOL", !25, i64 0, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40}
!25 = !{!"", !13, i64 0, !18, i64 4, !18, i64 6, !7, i64 8}
!26 = !{!"", !18, i64 0, !18, i64 2, !18, i64 4, !7, i64 6, !7, i64 20, !7, i64 40, !7, i64 46, !7, i64 54, !7, i64 94, !18, i64 98, !18, i64 100, !18, i64 102, !18, i64 104, !18, i64 106, !7, i64 108, !18, i64 124, !18, i64 126, !18, i64 128, !18, i64 130, !18, i64 132, !18, i64 134, !18, i64 136, !7, i64 138, !7, i64 142, !7, i64 146, !18, i64 150, !18, i64 152, !18, i64 154, !18, i64 156, !18, i64 158, !18, i64 160, !18, i64 162, !18, i64 164, !18, i64 166, !18, i64 168, !18, i64 170, !18, i64 172, !18, i64 174, !18, i64 176, !18, i64 178, !18, i64 180, !18, i64 182, !18, i64 184, !18, i64 186, !18, i64 188, !7, i64 190, !7, i64 216, !7, i64 224, !7, i64 232, !18, i64 238, !18, i64 240, !7, i64 242, !18, i64 250, !7, i64 252, !18, i64 256, !7, i64 258, !7, i64 320, !7, i64 352, !18, i64 444, !18, i64 446, !7, i64 448, !18, i64 510}
!27 = !{!16, !7, i64 5}
!28 = !{!20, !13, i64 300}
!29 = !{!30, !18, i64 4}
!30 = !{!"", !17, i64 0, !18, i64 4, !18, i64 6, !18, i64 8}
!31 = !{!30, !18, i64 6}
!32 = distinct !{!32, !33}
!33 = !{!"llvm.loop.mustprogress"}
!34 = distinct !{!34, !33}


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

@gScsiDiskInfoProtocolTemplate = external dso_local global %struct._EFI_DISK_INFO_PROTOCOL, align 8
@.str = external hidden unnamed_addr constant [33 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [146 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [20 x i8], align 1
@gBS = external local_unnamed_addr global ptr, align 8
@gEfiDiskInfoUfsInterfaceGuid = external global %struct.GUID, align 4
@gEfiDevicePathProtocolGuid = external global %struct.GUID, align 4
@gEfiDiskInfoIdeInterfaceGuid = external global %struct.GUID, align 4
@gEfiDiskInfoAhciInterfaceGuid = external global %struct.GUID, align 4

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

declare zeroext i8 @DebugAssertEnabled() local_unnamed_addr #1

declare zeroext i8 @DebugPrintEnabled() local_unnamed_addr #1

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

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

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

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

; Function Attrs: nounwind uwtable
define dso_local void @InitializeInstallDiskInfo(ptr noundef %0, ptr noundef %1) local_unnamed_addr #2 {
  %3 = alloca ptr, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #3
  %4 = load ptr, ptr @gBS, align 8, !tbaa !5
  %5 = getelementptr inbounds i8, ptr %4, i64 152
  %6 = load ptr, ptr %5, align 8, !tbaa !9
  %7 = call i64 %6(ptr noundef %1, ptr noundef nonnull @gEfiDevicePathProtocolGuid, ptr noundef nonnull %3) #3
  %8 = call zeroext i8 @DebugAssertEnabled() #3
  %9 = icmp ne i8 %8, 0
  %10 = icmp slt i64 %7, 0
  %or.cond = select i1 %9, i1 %10, i1 false
  br i1 %or.cond, label %11, label %17

11:                                               ; preds = %2
  %12 = call zeroext i8 @DebugPrintEnabled() #3
  %.not = icmp eq i8 %12, 0
  br i1 %.not, label %16, label %13

13:                                               ; preds = %11
  %14 = call zeroext i8 @DebugPrintLevelEnabled(i64 noundef 2147483648) #3
  %.not29 = icmp eq i8 %14, 0
  br i1 %.not29, label %16, label %15

15:                                               ; preds = %13
  call void (i64, ptr, ...) @DebugPrint(i64 noundef 2147483648, ptr noundef nonnull @.str, i64 noundef %7) #3
  br label %16

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

17:                                               ; preds = %16, %2
  %18 = getelementptr inbounds i8, ptr %0, i64 248
  %19 = call ptr @CopyMem(ptr noundef nonnull %18, ptr noundef nonnull @gScsiDiskInfoProtocolTemplate, i64 noundef 48) #3
  %20 = load ptr, ptr %3, align 8, !tbaa !5
  %21 = call zeroext i8 @IsDevicePathEnd(ptr noundef %20) #3
  %.not3034 = icmp eq i8 %21, 0
  br i1 %.not3034, label %.lr.ph, label %.loopexit32

.lr.ph:                                           ; preds = %17, %.loopexit
  %22 = load ptr, ptr %3, align 8, !tbaa !5
  %23 = call ptr @NextDevicePathNode(ptr noundef %22) #3
  %24 = load ptr, ptr %3, align 8, !tbaa !5
  %25 = call zeroext i8 @DevicePathType(ptr noundef %24) #3
  %26 = icmp eq i8 %25, 1
  br i1 %26, label %27, label %67

27:                                               ; preds = %.lr.ph
  %28 = load ptr, ptr %3, align 8, !tbaa !5
  %29 = call zeroext i8 @DevicePathSubType(ptr noundef %28) #3
  %30 = icmp eq i8 %29, 1
  br i1 %30, label %31, label %67

31:                                               ; preds = %27
  %32 = call zeroext i8 @DevicePathType(ptr noundef %23) #3
  %33 = icmp eq i8 %32, 3
  br i1 %33, label %34, label %67

34:                                               ; preds = %31
  %35 = call zeroext i8 @DevicePathSubType(ptr noundef %23) #3
  %36 = icmp eq i8 %35, 1
  br i1 %36, label %40, label %37

37:                                               ; preds = %34
  %38 = call zeroext i8 @DevicePathSubType(ptr noundef %23) #3
  %39 = icmp eq i8 %38, 18
  br i1 %39, label %40, label %67

40:                                               ; preds = %37, %34
  %41 = call i64 @AtapiIdentifyDevice(ptr noundef %0)
  %42 = icmp slt i64 %41, 0
  br i1 %42, label %61, label %43

43:                                               ; preds = %64, %61, %40
  %44 = call zeroext i8 @DevicePathSubType(ptr noundef %23) #3
  %45 = icmp eq i8 %44, 1
  %46 = getelementptr inbounds i8, ptr %23, i64 4
  %47 = getelementptr inbounds i8, ptr %0, i64 296
  %48 = getelementptr inbounds i8, ptr %0, i64 300
  br i1 %45, label %49, label %55

49:                                               ; preds = %43
  %50 = load i8, ptr %46, align 1, !tbaa !14
  %51 = zext i8 %50 to i32
  store i32 %51, ptr %47, align 8, !tbaa !18
  %52 = getelementptr inbounds i8, ptr %23, i64 5
  %53 = load i8, ptr %52, align 1, !tbaa !26
  %54 = zext i8 %53 to i32
  br label %.loopexit32.sink.split.sink.split

55:                                               ; preds = %43
  %56 = load i16, ptr %46, align 1, !tbaa !27
  %57 = zext i16 %56 to i32
  store i32 %57, ptr %47, align 8, !tbaa !18
  %58 = getelementptr inbounds i8, ptr %23, i64 6
  %59 = load i16, ptr %58, align 1, !tbaa !29
  %60 = zext i16 %59 to i32
  br label %.loopexit32.sink.split.sink.split

61:                                               ; preds = %40
  %62 = call i64 @AtapiIdentifyDevice(ptr noundef %0)
  %63 = icmp slt i64 %62, 0
  br i1 %63, label %64, label %43

64:                                               ; preds = %61
  %65 = call i64 @AtapiIdentifyDevice(ptr noundef %0)
  %66 = icmp slt i64 %65, 0
  br i1 %66, label %.loopexit, label %43

67:                                               ; preds = %37, %31, %27, %.lr.ph
  %68 = call zeroext i8 @DevicePathType(ptr noundef %23) #3
  %69 = icmp eq i8 %68, 3
  br i1 %69, label %70, label %.loopexit

70:                                               ; preds = %67
  %71 = call zeroext i8 @DevicePathSubType(ptr noundef %23) #3
  %72 = icmp eq i8 %71, 25
  br i1 %72, label %.loopexit32.sink.split, label %.loopexit

.loopexit:                                        ; preds = %64, %67, %70
  store ptr %23, ptr %3, align 8, !tbaa !5
  %73 = call zeroext i8 @IsDevicePathEnd(ptr noundef %23) #3
  %.not30 = icmp eq i8 %73, 0
  br i1 %.not30, label %.lr.ph, label %.loopexit32, !llvm.loop !30

.loopexit32.sink.split.sink.split:                ; preds = %49, %55
  %.sink = phi i32 [ %60, %55 ], [ %54, %49 ]
  %gEfiDiskInfoUfsInterfaceGuid.sink.ph = phi ptr [ @gEfiDiskInfoAhciInterfaceGuid, %55 ], [ @gEfiDiskInfoIdeInterfaceGuid, %49 ]
  store i32 %.sink, ptr %48, align 4, !tbaa !32
  br label %.loopexit32.sink.split

.loopexit32.sink.split:                           ; preds = %70, %.loopexit32.sink.split.sink.split
  %gEfiDiskInfoUfsInterfaceGuid.sink = phi ptr [ %gEfiDiskInfoUfsInterfaceGuid.sink.ph, %.loopexit32.sink.split.sink.split ], [ @gEfiDiskInfoUfsInterfaceGuid, %70 ]
  %74 = call ptr @CopyGuid(ptr noundef nonnull %18, ptr noundef nonnull %gEfiDiskInfoUfsInterfaceGuid.sink) #3
  br label %.loopexit32

.loopexit32:                                      ; preds = %.loopexit, %.loopexit32.sink.split, %17
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #3
  ret void
}

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

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

declare zeroext i8 @IsDevicePathEnd(ptr noundef) local_unnamed_addr #1

declare ptr @NextDevicePathNode(ptr noundef) local_unnamed_addr #1

declare zeroext i8 @DevicePathType(ptr noundef) local_unnamed_addr #1

declare zeroext i8 @DevicePathSubType(ptr noundef) local_unnamed_addr #1

declare ptr @CopyGuid(ptr noundef, ptr noundef) local_unnamed_addr #1

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { nounwind }

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !6, i64 152}
!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 = !{!15, !7, i64 4}
!15 = !{!"", !16, i64 0, !7, i64 4, !7, i64 5, !17, i64 6}
!16 = !{!"", !7, i64 0, !7, i64 1, !7, i64 2}
!17 = !{!"short", !7, i64 0}
!18 = !{!19, !13, i64 296}
!19 = !{!"", !13, i64 0, !6, i64 8, !20, i64 16, !21, i64 64, !6, i64 112, !7, i64 120, !7, i64 121, !17, i64 122, !6, i64 128, !12, i64 136, !22, i64 144, !6, i64 240, !23, i64 248, !13, i64 296, !13, i64 300, !25, i64 304, !7, i64 816}
!20 = !{!"_EFI_BLOCK_IO_PROTOCOL", !12, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40}
!21 = !{!"", !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}
!22 = !{!"", !7, i64 0, !7, i64 0, !7, i64 1, !7, i64 1, !7, i64 2, !7, i64 3, !7, i64 4, !7, i64 5}
!23 = !{!"_EFI_DISK_INFO_PROTOCOL", !24, i64 0, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40}
!24 = !{!"", !13, i64 0, !17, i64 4, !17, i64 6, !7, i64 8}
!25 = !{!"", !17, i64 0, !17, i64 2, !17, i64 4, !7, i64 6, !7, i64 20, !7, i64 40, !7, i64 46, !7, i64 54, !7, i64 94, !17, i64 98, !17, i64 100, !17, i64 102, !17, i64 104, !17, i64 106, !7, i64 108, !17, i64 124, !17, i64 126, !17, i64 128, !17, i64 130, !17, i64 132, !17, i64 134, !17, i64 136, !7, i64 138, !7, i64 142, !7, i64 146, !17, i64 150, !17, i64 152, !17, i64 154, !17, i64 156, !17, i64 158, !17, i64 160, !17, i64 162, !17, i64 164, !17, i64 166, !17, i64 168, !17, i64 170, !17, i64 172, !17, i64 174, !17, i64 176, !17, i64 178, !17, i64 180, !17, i64 182, !17, i64 184, !17, i64 186, !17, i64 188, !7, i64 190, !7, i64 216, !7, i64 224, !7, i64 232, !17, i64 238, !17, i64 240, !7, i64 242, !17, i64 250, !7, i64 252, !17, i64 256, !7, i64 258, !7, i64 320, !7, i64 352, !17, i64 444, !17, i64 446, !7, i64 448, !17, i64 510}
!26 = !{!15, !7, i64 5}
!27 = !{!28, !17, i64 4}
!28 = !{!"", !16, i64 0, !17, i64 4, !17, i64 6, !17, i64 8}
!29 = !{!28, !17, i64 6}
!30 = distinct !{!30, !31}
!31 = !{!"llvm.loop.mustprogress"}
!32 = !{!19, !13, i64 300}


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