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

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

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

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

; 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 i64 @MultU64x32(i64 noundef, i32 noundef) #2

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

26:                                               ; preds = %4
  %27 = load ptr, ptr %7, align 8, !tbaa !5
  store i8 0, ptr %27, align 1, !tbaa !9
  store i64 -9223372036854775801, ptr %5, align 8
  store i32 1, ptr %21, align 4
  br label %185

28:                                               ; preds = %4
  %29 = load ptr, ptr %6, align 8, !tbaa !5
  %30 = call ptr @AllocateAlignedBuffer(ptr noundef %29, i64 noundef 32)
  store ptr %30, ptr %20, align 8, !tbaa !5
  %31 = load ptr, ptr %20, align 8, !tbaa !5
  %32 = icmp eq ptr %31, null
  br i1 %32, label %33, label %36

33:                                               ; preds = %28
  %34 = load ptr, ptr %19, align 8, !tbaa !5
  call void @FreeAlignedBuffer(ptr noundef %34, i64 noundef 8)
  %35 = load ptr, ptr %7, align 8, !tbaa !5
  store i8 0, ptr %35, align 1, !tbaa !9
  store i64 -9223372036854775801, ptr %5, align 8
  store i32 1, ptr %21, align 4
  br label %185

36:                                               ; preds = %28
  store i8 0, ptr %16, align 1, !tbaa !9
  store i32 8, ptr %17, align 4, !tbaa !10
  store i32 32, ptr %18, align 4, !tbaa !10
  %37 = load ptr, ptr %19, align 8, !tbaa !5
  %38 = call ptr @ZeroMem(ptr noundef %37, i64 noundef 8)
  %39 = load ptr, ptr %20, align 8, !tbaa !5
  %40 = call ptr @ZeroMem(ptr noundef %39, i64 noundef 32)
  %41 = load ptr, ptr %9, align 8, !tbaa !5
  store i64 0, ptr %41, align 8, !tbaa !12
  %42 = load ptr, ptr %7, align 8, !tbaa !5
  store i8 0, ptr %42, align 1, !tbaa !9
  %43 = load ptr, ptr %6, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct.SCSI_DISK_DEV, ptr %43, i32 0, i32 4
  %45 = load ptr, ptr %44, align 8, !tbaa !14
  %46 = call i64 @MultU64x32(i64 noundef 3, i32 noundef 10000000)
  %47 = load ptr, ptr %19, align 8, !tbaa !5
  %48 = call i64 @ScsiReadCapacityCommand(ptr noundef %45, i64 noundef %46, ptr noundef null, ptr noundef %16, ptr noundef %10, ptr noundef %11, ptr noundef %47, ptr noundef %17, i8 noundef zeroext 0)
  store i64 %48, ptr %12, align 8, !tbaa !12
  %49 = load ptr, ptr %6, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct.SCSI_DISK_DEV, ptr %49, i32 0, i32 16
  store i8 0, ptr %50, align 8, !tbaa !23
  %51 = load i64, ptr %12, align 8, !tbaa !12
  %52 = icmp slt i64 %51, 0
  br i1 %52, label %86, label %53

53:                                               ; preds = %36
  %54 = load ptr, ptr %19, align 8, !tbaa !5
  %55 = getelementptr inbounds %struct.EFI_SCSI_DISK_CAPACITY_DATA, ptr %54, i32 0, i32 0
  %56 = load i8, ptr %55, align 1, !tbaa !24
  %57 = zext i8 %56 to i32
  %58 = icmp eq i32 %57, 255
  br i1 %58, label %59, label %86

59:                                               ; preds = %53
  %60 = load ptr, ptr %19, align 8, !tbaa !5
  %61 = getelementptr inbounds %struct.EFI_SCSI_DISK_CAPACITY_DATA, ptr %60, i32 0, i32 1
  %62 = load i8, ptr %61, align 1, !tbaa !26
  %63 = zext i8 %62 to i32
  %64 = icmp eq i32 %63, 255
  br i1 %64, label %65, label %86

65:                                               ; preds = %59
  %66 = load ptr, ptr %19, align 8, !tbaa !5
  %67 = getelementptr inbounds %struct.EFI_SCSI_DISK_CAPACITY_DATA, ptr %66, i32 0, i32 2
  %68 = load i8, ptr %67, align 1, !tbaa !27
  %69 = zext i8 %68 to i32
  %70 = icmp eq i32 %69, 255
  br i1 %70, label %71, label %86

71:                                               ; preds = %65
  %72 = load ptr, ptr %19, align 8, !tbaa !5
  %73 = getelementptr inbounds %struct.EFI_SCSI_DISK_CAPACITY_DATA, ptr %72, i32 0, i32 3
  %74 = load i8, ptr %73, align 1, !tbaa !28
  %75 = zext i8 %74 to i32
  %76 = icmp eq i32 %75, 255
  br i1 %76, label %77, label %86

77:                                               ; preds = %71
  %78 = load ptr, ptr %6, align 8, !tbaa !5
  %79 = getelementptr inbounds %struct.SCSI_DISK_DEV, ptr %78, i32 0, i32 16
  store i8 1, ptr %79, align 8, !tbaa !23
  %80 = load ptr, ptr %6, align 8, !tbaa !5
  %81 = getelementptr inbounds %struct.SCSI_DISK_DEV, ptr %80, i32 0, i32 4
  %82 = load ptr, ptr %81, align 8, !tbaa !14
  %83 = call i64 @MultU64x32(i64 noundef 3, i32 noundef 10000000)
  %84 = load ptr, ptr %20, align 8, !tbaa !5
  %85 = call i64 @ScsiReadCapacity16Command(ptr noundef %82, i64 noundef %83, ptr noundef null, ptr noundef %16, ptr noundef %10, ptr noundef %11, ptr noundef %84, ptr noundef %18, i8 noundef zeroext 0)
  store i64 %85, ptr %12, align 8, !tbaa !12
  br label %86

86:                                               ; preds = %77, %71, %65, %59, %53, %36
  %87 = load i64, ptr %12, align 8, !tbaa !12
  %88 = icmp eq i64 %87, 0
  br i1 %88, label %89, label %95

89:                                               ; preds = %86
  %90 = load ptr, ptr %6, align 8, !tbaa !5
  %91 = load ptr, ptr %19, align 8, !tbaa !5
  %92 = load ptr, ptr %20, align 8, !tbaa !5
  call void @GetMediaInfo(ptr noundef %90, ptr noundef %91, ptr noundef %92)
  %93 = load ptr, ptr %19, align 8, !tbaa !5
  call void @FreeAlignedBuffer(ptr noundef %93, i64 noundef 8)
  %94 = load ptr, ptr %20, align 8, !tbaa !5
  call void @FreeAlignedBuffer(ptr noundef %94, i64 noundef 32)
  store i64 0, ptr %5, align 8
  store i32 1, ptr %21, align 4
  br label %185

95:                                               ; preds = %86
  %96 = load ptr, ptr %19, align 8, !tbaa !5
  call void @FreeAlignedBuffer(ptr noundef %96, i64 noundef 8)
  %97 = load ptr, ptr %20, align 8, !tbaa !5
  call void @FreeAlignedBuffer(ptr noundef %97, i64 noundef 32)
  %98 = load i64, ptr %12, align 8, !tbaa !12
  %99 = icmp eq i64 %98, -9223372036854775802
  br i1 %99, label %100, label %102

100:                                              ; preds = %95
  %101 = load ptr, ptr %7, align 8, !tbaa !5
  store i8 1, ptr %101, align 1, !tbaa !9
  store i64 -9223372036854775801, ptr %5, align 8
  store i32 1, ptr %21, align 4
  br label %185

102:                                              ; preds = %95
  %103 = load i64, ptr %12, align 8, !tbaa !12
  %104 = icmp eq i64 %103, -9223372036854775806
  br i1 %104, label %108, label %105

105:                                              ; preds = %102
  %106 = load i64, ptr %12, align 8, !tbaa !12
  %107 = icmp eq i64 %106, -9223372036854775805
  br i1 %107, label %108, label %110

108:                                              ; preds = %105, %102
  %109 = load ptr, ptr %7, align 8, !tbaa !5
  store i8 0, ptr %109, align 1, !tbaa !9
  store i64 -9223372036854775801, ptr %5, align 8
  store i32 1, ptr %21, align 4
  br label %185

110:                                              ; preds = %105
  br label %111

111:                                              ; preds = %110
  %112 = load i8, ptr %10, align 1, !tbaa !9
  %113 = call i64 @CheckHostAdapterStatus(i8 noundef zeroext %112)
  store i64 %113, ptr %13, align 8, !tbaa !12
  %114 = load i64, ptr %13, align 8, !tbaa !12
  %115 = icmp eq i64 %114, -9223372036854775790
  br i1 %115, label %119, label %116

116:                                              ; preds = %111
  %117 = load i64, ptr %13, align 8, !tbaa !12
  %118 = icmp eq i64 %117, -9223372036854775802
  br i1 %118, label %119, label %121

119:                                              ; preds = %116, %111
  %120 = load ptr, ptr %7, align 8, !tbaa !5
  store i8 1, ptr %120, align 1, !tbaa !9
  store i64 -9223372036854775801, ptr %5, align 8
  store i32 1, ptr %21, align 4
  br label %185

121:                                              ; preds = %116
  %122 = load i64, ptr %13, align 8, !tbaa !12
  %123 = icmp eq i64 %122, -9223372036854775801
  br i1 %123, label %124, label %135

124:                                              ; preds = %121
  %125 = load ptr, ptr %6, align 8, !tbaa !5
  %126 = getelementptr inbounds %struct.SCSI_DISK_DEV, ptr %125, i32 0, i32 4
  %127 = load ptr, ptr %126, align 8, !tbaa !14
  %128 = getelementptr inbounds %struct._EFI_SCSI_IO_PROTOCOL, ptr %127, i32 0, i32 2
  %129 = load ptr, ptr %128, align 8, !tbaa !29
  %130 = load ptr, ptr %6, align 8, !tbaa !5
  %131 = getelementptr inbounds %struct.SCSI_DISK_DEV, ptr %130, i32 0, i32 4
  %132 = load ptr, ptr %131, align 8, !tbaa !14
  %133 = call i64 %129(ptr noundef %132)
  %134 = load ptr, ptr %7, align 8, !tbaa !5
  store i8 0, ptr %134, align 1, !tbaa !9
  store i64 -9223372036854775801, ptr %5, align 8
  store i32 1, ptr %21, align 4
  br label %185

135:                                              ; preds = %121
  br label %136

136:                                              ; preds = %135
  %137 = load i8, ptr %11, align 1, !tbaa !9
  %138 = call i64 @CheckTargetStatus(i8 noundef zeroext %137)
  store i64 %138, ptr %13, align 8, !tbaa !12
  %139 = load i64, ptr %13, align 8, !tbaa !12
  %140 = icmp eq i64 %139, -9223372036854775802
  br i1 %140, label %141, label %152

141:                                              ; preds = %136
  %142 = load ptr, ptr %6, align 8, !tbaa !5
  %143 = getelementptr inbounds %struct.SCSI_DISK_DEV, ptr %142, i32 0, i32 4
  %144 = load ptr, ptr %143, align 8, !tbaa !14
  %145 = getelementptr inbounds %struct._EFI_SCSI_IO_PROTOCOL, ptr %144, i32 0, i32 3
  %146 = load ptr, ptr %145, align 8, !tbaa !31
  %147 = load ptr, ptr %6, align 8, !tbaa !5
  %148 = getelementptr inbounds %struct.SCSI_DISK_DEV, ptr %147, i32 0, i32 4
  %149 = load ptr, ptr %148, align 8, !tbaa !14
  %150 = call i64 %146(ptr noundef %149)
  %151 = load ptr, ptr %7, align 8, !tbaa !5
  store i8 1, ptr %151, align 1, !tbaa !9
  store i64 -9223372036854775801, ptr %5, align 8
  store i32 1, ptr %21, align 4
  br label %185

152:                                              ; preds = %136
  %153 = load i64, ptr %13, align 8, !tbaa !12
  %154 = icmp eq i64 %153, -9223372036854775801
  br i1 %154, label %155, label %157

155:                                              ; preds = %152
  %156 = load ptr, ptr %7, align 8, !tbaa !5
  store i8 0, ptr %156, align 1, !tbaa !9
  store i64 -9223372036854775801, ptr %5, align 8
  store i32 1, ptr %21, align 4
  br label %185

157:                                              ; preds = %152
  br label %158

158:                                              ; preds = %157
  store i8 3, ptr %15, align 1, !tbaa !9
  store i8 0, ptr %14, align 1, !tbaa !9
  br label %159

159:                                              ; preds = %180, %158
  %160 = load i8, ptr %14, align 1, !tbaa !9
  %161 = zext i8 %160 to i32
  %162 = load i8, ptr %15, align 1, !tbaa !9
  %163 = zext i8 %162 to i32
  %164 = icmp slt i32 %161, %163
  br i1 %164, label %165, label %183

165:                                              ; preds = %159
  %166 = load ptr, ptr %6, align 8, !tbaa !5
  %167 = load ptr, ptr %7, align 8, !tbaa !5
  %168 = load ptr, ptr %8, align 8, !tbaa !5
  %169 = load ptr, ptr %9, align 8, !tbaa !5
  %170 = call i64 @ScsiDiskRequestSenseKeys(ptr noundef %166, ptr noundef %167, ptr noundef %168, ptr noundef %169, i8 noundef zeroext 1)
  store i64 %170, ptr %13, align 8, !tbaa !12
  %171 = load i64, ptr %13, align 8, !tbaa !12
  %172 = icmp slt i64 %171, 0
  br i1 %172, label %174, label %173

173:                                              ; preds = %165
  store i64 0, ptr %5, align 8
  store i32 1, ptr %21, align 4
  br label %185

174:                                              ; preds = %165
  %175 = load ptr, ptr %7, align 8, !tbaa !5
  %176 = load i8, ptr %175, align 1, !tbaa !9
  %177 = icmp ne i8 %176, 0
  br i1 %177, label %179, label %178

178:                                              ; preds = %174
  store i64 -9223372036854775801, ptr %5, align 8
  store i32 1, ptr %21, align 4
  br label %185

179:                                              ; preds = %174
  br label %180

180:                                              ; preds = %179
  %181 = load i8, ptr %14, align 1, !tbaa !9
  %182 = add i8 %181, 1
  store i8 %182, ptr %14, align 1, !tbaa !9
  br label %159, !llvm.loop !32

183:                                              ; preds = %159
  %184 = load ptr, ptr %7, align 8, !tbaa !5
  store i8 0, ptr %184, align 1, !tbaa !9
  store i64 -9223372036854775801, ptr %5, align 8
  store i32 1, ptr %21, align 4
  br label %185

185:                                              ; preds = %183, %178, %173, %155, %141, %124, %119, %108, %100, %89, %33, %26
  call void @llvm.lifetime.end.p0(i64 8, ptr %20) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %19) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #3
  call void @llvm.lifetime.end.p0(i64 1, ptr %16) #3
  call void @llvm.lifetime.end.p0(i64 1, ptr %15) #3
  call void @llvm.lifetime.end.p0(i64 1, 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
  %186 = load i64, ptr %5, align 8
  ret i64 %186
}

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

; Function Attrs: nounwind uwtable
declare dso_local i64 @CheckHostAdapterStatus(i8 noundef zeroext) #0

; Function Attrs: nounwind uwtable
declare dso_local i64 @CheckTargetStatus(i8 noundef zeroext) #0

; Function Attrs: nounwind uwtable
declare dso_local i64 @ScsiDiskRequestSenseKeys(ptr noundef, ptr noundef, ptr noundef, ptr noundef, i8 noundef zeroext) #0

declare i64 @ScsiReadCapacityCommand(ptr noundef, i64 noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, i8 noundef zeroext) #2

declare i64 @ScsiReadCapacity16Command(ptr noundef, i64 noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, i8 noundef zeroext) #2

; Function Attrs: nounwind uwtable
declare dso_local void @GetMediaInfo(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, !11, i64 0}
!11 = !{!"int", !7, i64 0}
!12 = !{!13, !13, i64 0}
!13 = !{!"long long", !7, i64 0}
!14 = !{!15, !6, i64 112}
!15 = !{!"", !11, i64 0, !6, i64 8, !16, i64 16, !17, i64 64, !6, i64 112, !7, i64 120, !7, i64 121, !18, i64 122, !6, i64 128, !13, i64 136, !19, i64 144, !6, i64 240, !20, i64 248, !11, i64 296, !11, i64 300, !22, i64 304, !7, i64 816}
!16 = !{!"_EFI_BLOCK_IO_PROTOCOL", !13, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40}
!17 = !{!"", !11, i64 0, !7, i64 4, !7, i64 5, !7, i64 6, !7, i64 7, !7, i64 8, !11, i64 12, !11, i64 16, !13, i64 24, !13, i64 32, !11, i64 40, !11, i64 44}
!18 = !{!"short", !7, i64 0}
!19 = !{!"", !7, i64 0, !7, i64 0, !7, i64 1, !7, i64 1, !7, i64 2, !7, i64 3, !7, i64 4, !7, i64 5}
!20 = !{!"_EFI_DISK_INFO_PROTOCOL", !21, i64 0, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40}
!21 = !{!"", !11, i64 0, !18, i64 4, !18, i64 6, !7, i64 8}
!22 = !{!"", !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}
!23 = !{!15, !7, i64 816}
!24 = !{!25, !7, i64 0}
!25 = !{!"", !7, i64 0, !7, i64 1, !7, i64 2, !7, i64 3, !7, i64 4, !7, i64 5, !7, i64 6, !7, i64 7}
!26 = !{!25, !7, i64 1}
!27 = !{!25, !7, i64 2}
!28 = !{!25, !7, i64 3}
!29 = !{!30, !6, i64 16}
!30 = !{!"_EFI_SCSI_IO_PROTOCOL", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !11, i64 40}
!31 = !{!30, !6, i64 24}
!32 = distinct !{!32, !33}
!33 = !{!"llvm.loop.mustprogress"}


; 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"

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

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

; 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 i64 @MultU64x32(i64 noundef, i32 noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
define dso_local range(i64 -9223372036854775801, 1) i64 @ScsiDiskReadCapacity(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3) local_unnamed_addr #0 {
  %5 = alloca i8, align 1
  %6 = alloca i8, align 1
  %7 = alloca i8, align 1
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 1, 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 4, ptr nonnull %8) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %9) #3
  %10 = tail call ptr @AllocateAlignedBuffer(ptr noundef %0, i64 noundef 8)
  %11 = icmp eq ptr %10, null
  br i1 %11, label %12, label %13

12:                                               ; preds = %4
  store i8 0, ptr %1, align 1, !tbaa !5
  br label %.loopexit

13:                                               ; preds = %4
  %14 = tail call ptr @AllocateAlignedBuffer(ptr noundef %0, i64 noundef 32)
  %15 = icmp eq ptr %14, null
  br i1 %15, label %16, label %17

16:                                               ; preds = %13
  tail call void @FreeAlignedBuffer(ptr noundef nonnull %10, i64 noundef 8)
  store i8 0, ptr %1, align 1, !tbaa !5
  br label %.loopexit

17:                                               ; preds = %13
  store i8 0, ptr %7, align 1, !tbaa !5
  store i32 8, ptr %8, align 4, !tbaa !8
  store i32 32, ptr %9, align 4, !tbaa !8
  %18 = tail call ptr @ZeroMem(ptr noundef nonnull %10, i64 noundef 8) #3
  %19 = tail call ptr @ZeroMem(ptr noundef nonnull %14, i64 noundef 32) #3
  store i64 0, ptr %3, align 8, !tbaa !10
  store i8 0, ptr %1, align 1, !tbaa !5
  %20 = getelementptr inbounds i8, ptr %0, i64 112
  %21 = load ptr, ptr %20, align 8, !tbaa !12
  %22 = tail call i64 @MultU64x32(i64 noundef 3, i32 noundef 10000000) #3
  %23 = call i64 @ScsiReadCapacityCommand(ptr noundef %21, i64 noundef %22, ptr noundef null, ptr noundef nonnull %7, ptr noundef nonnull %5, ptr noundef nonnull %6, ptr noundef nonnull %10, ptr noundef nonnull %8, i8 noundef zeroext 0) #3
  %24 = getelementptr inbounds i8, ptr %0, i64 816
  store i8 0, ptr %24, align 8, !tbaa !22
  %25 = icmp slt i64 %23, 0
  br i1 %25, label %.thread, label %26

26:                                               ; preds = %17
  %27 = load i8, ptr %10, align 1, !tbaa !23
  %28 = icmp eq i8 %27, -1
  br i1 %28, label %29, label %45

29:                                               ; preds = %26
  %30 = getelementptr inbounds i8, ptr %10, i64 1
  %31 = load i8, ptr %30, align 1, !tbaa !25
  %32 = icmp eq i8 %31, -1
  br i1 %32, label %33, label %45

33:                                               ; preds = %29
  %34 = getelementptr inbounds i8, ptr %10, i64 2
  %35 = load i8, ptr %34, align 1, !tbaa !26
  %36 = icmp eq i8 %35, -1
  br i1 %36, label %37, label %45

37:                                               ; preds = %33
  %38 = getelementptr inbounds i8, ptr %10, i64 3
  %39 = load i8, ptr %38, align 1, !tbaa !27
  %40 = icmp eq i8 %39, -1
  br i1 %40, label %41, label %45

41:                                               ; preds = %37
  store i8 1, ptr %24, align 8, !tbaa !22
  %42 = load ptr, ptr %20, align 8, !tbaa !12
  %43 = call i64 @MultU64x32(i64 noundef 3, i32 noundef 10000000) #3
  %44 = call i64 @ScsiReadCapacity16Command(ptr noundef %42, i64 noundef %43, ptr noundef null, ptr noundef nonnull %7, ptr noundef nonnull %5, ptr noundef nonnull %6, ptr noundef nonnull %14, ptr noundef nonnull %9, i8 noundef zeroext 0) #3
  br label %45

45:                                               ; preds = %41, %37, %33, %29, %26
  %.061 = phi i64 [ %44, %41 ], [ %23, %37 ], [ %23, %33 ], [ %23, %29 ], [ %23, %26 ]
  %46 = icmp eq i64 %.061, 0
  br i1 %46, label %47, label %.thread

47:                                               ; preds = %45
  call void @GetMediaInfo(ptr noundef nonnull %0, ptr noundef nonnull %10, ptr noundef nonnull %14)
  call void @FreeAlignedBuffer(ptr noundef nonnull %10, i64 noundef 8)
  call void @FreeAlignedBuffer(ptr noundef nonnull %14, i64 noundef 32)
  br label %.loopexit

.thread:                                          ; preds = %17, %45
  %.06169 = phi i64 [ %.061, %45 ], [ %23, %17 ]
  call void @FreeAlignedBuffer(ptr noundef nonnull %10, i64 noundef 8)
  call void @FreeAlignedBuffer(ptr noundef nonnull %14, i64 noundef 32)
  %48 = icmp eq i64 %.06169, -9223372036854775802
  br i1 %48, label %49, label %50

49:                                               ; preds = %.thread
  store i8 1, ptr %1, align 1, !tbaa !5
  br label %.loopexit

50:                                               ; preds = %.thread
  %51 = and i64 %.06169, -2
  %or.cond = icmp eq i64 %51, -9223372036854775806
  br i1 %or.cond, label %52, label %53

52:                                               ; preds = %50
  store i8 0, ptr %1, align 1, !tbaa !5
  br label %.loopexit

53:                                               ; preds = %50
  %54 = load i8, ptr %5, align 1, !tbaa !5
  %55 = call i64 @CheckHostAdapterStatus(i8 noundef zeroext %54)
  switch i64 %55, label %62 [
    i64 -9223372036854775790, label %56
    i64 -9223372036854775802, label %56
    i64 -9223372036854775801, label %57
  ]

56:                                               ; preds = %53, %53
  store i8 1, ptr %1, align 1, !tbaa !5
  br label %.loopexit

57:                                               ; preds = %53
  %58 = load ptr, ptr %20, align 8, !tbaa !12
  %59 = getelementptr inbounds i8, ptr %58, i64 16
  %60 = load ptr, ptr %59, align 8, !tbaa !28
  %61 = call i64 %60(ptr noundef %58) #3
  store i8 0, ptr %1, align 1, !tbaa !5
  br label %.loopexit

62:                                               ; preds = %53
  %63 = load i8, ptr %6, align 1, !tbaa !5
  %64 = call i64 @CheckTargetStatus(i8 noundef zeroext %63)
  switch i64 %64, label %.preheader.preheader [
    i64 -9223372036854775802, label %67
    i64 -9223372036854775801, label %72
  ]

.preheader.preheader:                             ; preds = %62
  %65 = call i64 @ScsiDiskRequestSenseKeys(ptr noundef nonnull %0, ptr noundef nonnull %1, ptr noundef %2, ptr noundef nonnull %3, i8 noundef zeroext 1)
  %66 = icmp slt i64 %65, 0
  br i1 %66, label %82, label %.loopexit

67:                                               ; preds = %62
  %68 = load ptr, ptr %20, align 8, !tbaa !12
  %69 = getelementptr inbounds i8, ptr %68, i64 24
  %70 = load ptr, ptr %69, align 8, !tbaa !30
  %71 = call i64 %70(ptr noundef %68) #3
  store i8 1, ptr %1, align 1, !tbaa !5
  br label %.loopexit

72:                                               ; preds = %62
  store i8 0, ptr %1, align 1, !tbaa !5
  br label %.loopexit

.preheader.1:                                     ; preds = %82
  %73 = call i64 @ScsiDiskRequestSenseKeys(ptr noundef nonnull %0, ptr noundef nonnull %1, ptr noundef %2, ptr noundef nonnull %3, i8 noundef zeroext 1)
  %74 = icmp slt i64 %73, 0
  br i1 %74, label %75, label %.loopexit

75:                                               ; preds = %.preheader.1
  %76 = load i8, ptr %1, align 1, !tbaa !5
  %.not.1 = icmp eq i8 %76, 0
  br i1 %.not.1, label %.loopexit, label %.preheader.2

.preheader.2:                                     ; preds = %75
  %77 = call i64 @ScsiDiskRequestSenseKeys(ptr noundef nonnull %0, ptr noundef nonnull %1, ptr noundef %2, ptr noundef nonnull %3, i8 noundef zeroext 1)
  %78 = icmp slt i64 %77, 0
  br i1 %78, label %79, label %.loopexit

79:                                               ; preds = %.preheader.2
  %80 = load i8, ptr %1, align 1, !tbaa !5
  %.not.2 = icmp eq i8 %80, 0
  br i1 %.not.2, label %.loopexit, label %81

81:                                               ; preds = %79
  store i8 0, ptr %1, align 1, !tbaa !5
  br label %.loopexit

82:                                               ; preds = %.preheader.preheader
  %83 = load i8, ptr %1, align 1, !tbaa !5
  %.not = icmp eq i8 %83, 0
  br i1 %.not, label %.loopexit, label %.preheader.1

.loopexit:                                        ; preds = %82, %.preheader.preheader, %.preheader.1, %75, %.preheader.2, %79, %81, %72, %67, %57, %56, %52, %49, %47, %16, %12
  %.0 = phi i64 [ -9223372036854775801, %12 ], [ -9223372036854775801, %16 ], [ 0, %47 ], [ -9223372036854775801, %49 ], [ -9223372036854775801, %52 ], [ -9223372036854775801, %56 ], [ -9223372036854775801, %57 ], [ -9223372036854775801, %67 ], [ -9223372036854775801, %72 ], [ -9223372036854775801, %81 ], [ 0, %.preheader.preheader ], [ -9223372036854775801, %82 ], [ 0, %.preheader.1 ], [ -9223372036854775801, %75 ], [ 0, %.preheader.2 ], [ -9223372036854775801, %79 ]
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %9) #3
  call void @llvm.lifetime.end.p0(i64 4, 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 1, ptr nonnull %5) #3
  ret i64 %.0
}

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

; Function Attrs: nounwind uwtable
declare dso_local i64 @CheckHostAdapterStatus(i8 noundef zeroext) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local i64 @CheckTargetStatus(i8 noundef zeroext) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local i64 @ScsiDiskRequestSenseKeys(ptr noundef, ptr noundef, ptr noundef, ptr noundef, i8 noundef zeroext) local_unnamed_addr #0

declare i64 @ScsiReadCapacityCommand(ptr noundef, i64 noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, i8 noundef zeroext) local_unnamed_addr #2

declare i64 @ScsiReadCapacity16Command(ptr noundef, i64 noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, i8 noundef zeroext) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
declare dso_local void @GetMediaInfo(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 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C/C++ TBAA"}
!8 = !{!9, !9, i64 0}
!9 = !{!"int", !6, i64 0}
!10 = !{!11, !11, i64 0}
!11 = !{!"long long", !6, i64 0}
!12 = !{!13, !14, i64 112}
!13 = !{!"", !9, i64 0, !14, i64 8, !15, i64 16, !16, i64 64, !14, i64 112, !6, i64 120, !6, i64 121, !17, i64 122, !14, i64 128, !11, i64 136, !18, i64 144, !14, i64 240, !19, i64 248, !9, i64 296, !9, i64 300, !21, i64 304, !6, i64 816}
!14 = !{!"any pointer", !6, i64 0}
!15 = !{!"_EFI_BLOCK_IO_PROTOCOL", !11, i64 0, !14, i64 8, !14, i64 16, !14, i64 24, !14, i64 32, !14, i64 40}
!16 = !{!"", !9, i64 0, !6, i64 4, !6, i64 5, !6, i64 6, !6, i64 7, !6, i64 8, !9, i64 12, !9, i64 16, !11, i64 24, !11, i64 32, !9, i64 40, !9, i64 44}
!17 = !{!"short", !6, i64 0}
!18 = !{!"", !6, i64 0, !6, i64 0, !6, i64 1, !6, i64 1, !6, i64 2, !6, i64 3, !6, i64 4, !6, i64 5}
!19 = !{!"_EFI_DISK_INFO_PROTOCOL", !20, i64 0, !14, i64 16, !14, i64 24, !14, i64 32, !14, i64 40}
!20 = !{!"", !9, i64 0, !17, i64 4, !17, i64 6, !6, i64 8}
!21 = !{!"", !17, i64 0, !17, i64 2, !17, i64 4, !6, i64 6, !6, i64 20, !6, i64 40, !6, i64 46, !6, i64 54, !6, i64 94, !17, i64 98, !17, i64 100, !17, i64 102, !17, i64 104, !17, i64 106, !6, i64 108, !17, i64 124, !17, i64 126, !17, i64 128, !17, i64 130, !17, i64 132, !17, i64 134, !17, i64 136, !6, i64 138, !6, i64 142, !6, 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, !6, i64 190, !6, i64 216, !6, i64 224, !6, i64 232, !17, i64 238, !17, i64 240, !6, i64 242, !17, i64 250, !6, i64 252, !17, i64 256, !6, i64 258, !6, i64 320, !6, i64 352, !17, i64 444, !17, i64 446, !6, i64 448, !17, i64 510}
!22 = !{!13, !6, i64 816}
!23 = !{!24, !6, i64 0}
!24 = !{!"", !6, i64 0, !6, i64 1, !6, i64 2, !6, i64 3, !6, i64 4, !6, i64 5, !6, i64 6, !6, i64 7}
!25 = !{!24, !6, i64 1}
!26 = !{!24, !6, i64 2}
!27 = !{!24, !6, i64 3}
!28 = !{!29, !14, i64 16}
!29 = !{!"_EFI_SCSI_IO_PROTOCOL", !14, i64 0, !14, i64 8, !14, i64 16, !14, i64 24, !14, i64 32, !9, i64 40}
!30 = !{!29, !14, i64 24}


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