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

; 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.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._EFI_DISK_INFO_PROTOCOL = type { %struct.GUID, ptr, ptr, ptr, ptr }
%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 }

@.str.1 = external hidden unnamed_addr constant [146 x i8], align 1
@gBS = external global ptr, align 8
@gEfiBlockIoProtocolGuid = external global %struct.GUID, align 4
@.str.6 = external hidden unnamed_addr constant [21 x i8], align 1

; 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 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 i64 @ScsiDiskWriteBlocks(ptr noundef %0, i32 noundef %1, i64 noundef %2, i64 noundef %3, ptr noundef %4) #2 {
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca i64, align 8
  %9 = alloca i64, align 8
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  %13 = alloca i64, align 8
  %14 = alloca i64, align 8
  %15 = alloca i64, align 8
  %16 = alloca i8, align 1
  %17 = alloca i64, align 8
  store ptr %0, ptr %6, align 8, !tbaa !5
  store i32 %1, ptr %7, align 4, !tbaa !9
  store i64 %2, ptr %8, align 8, !tbaa !11
  store i64 %3, ptr %9, align 8, !tbaa !11
  store ptr %4, ptr %10, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, 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 1, ptr %16) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #3
  store i8 0, ptr %16, align 1, !tbaa !13
  %18 = load ptr, ptr @gBS, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct.EFI_BOOT_SERVICES, ptr %18, i32 0, i32 1
  %20 = load ptr, ptr %19, align 8, !tbaa !14
  %21 = call i64 %20(i64 noundef 8)
  store i64 %21, ptr %17, align 8, !tbaa !11
  %22 = call zeroext i8 @DebugAssertEnabled()
  %23 = zext i8 %22 to i32
  %24 = icmp ne i32 %23, 0
  br i1 %24, label %25, label %35

25:                                               ; preds = %5
  %26 = load ptr, ptr %6, align 8, !tbaa !5
  %27 = ptrtoint ptr %26 to i64
  %28 = sub i64 %27, ptrtoint (ptr getelementptr inbounds (%struct.SCSI_DISK_DEV, ptr null, i32 0, i32 2) to i64)
  %29 = inttoptr i64 %28 to ptr
  %30 = getelementptr inbounds %struct.SCSI_DISK_DEV, ptr %29, i32 0, i32 0
  %31 = load i32, ptr %30, align 8, !tbaa !17
  %32 = icmp ne i32 %31, 1801741171
  br i1 %32, label %33, label %35

33:                                               ; preds = %25
  call void @DebugAssert(ptr noundef @.str.1, i64 noundef 626, ptr noundef @.str.6)
  %34 = load ptr, ptr %6, align 8, !tbaa !5
  br label %40

35:                                               ; preds = %25, %5
  %36 = load ptr, ptr %6, align 8, !tbaa !5
  %37 = ptrtoint ptr %36 to i64
  %38 = sub i64 %37, ptrtoint (ptr getelementptr inbounds (%struct.SCSI_DISK_DEV, ptr null, i32 0, i32 2) to i64)
  %39 = inttoptr i64 %38 to ptr
  br label %40

40:                                               ; preds = %35, %33
  %41 = phi ptr [ %34, %33 ], [ %39, %35 ]
  store ptr %41, ptr %11, align 8, !tbaa !5
  %42 = load ptr, ptr %11, align 8, !tbaa !5
  %43 = getelementptr inbounds %struct.SCSI_DISK_DEV, ptr %42, i32 0, i32 6
  %44 = load i8, ptr %43, align 1, !tbaa !26
  %45 = icmp ne i8 %44, 0
  br i1 %45, label %47, label %46

46:                                               ; preds = %40
  br i1 true, label %48, label %70

47:                                               ; preds = %40
  br i1 false, label %48, label %70

48:                                               ; preds = %47, %46
  %49 = load ptr, ptr %11, align 8, !tbaa !5
  %50 = call i64 @ScsiDiskDetectMedia(ptr noundef %49, i8 noundef zeroext 0, ptr noundef %16)
  store i64 %50, ptr %13, align 8, !tbaa !11
  %51 = load i64, ptr %13, align 8, !tbaa !11
  %52 = icmp slt i64 %51, 0
  br i1 %52, label %53, label %54

53:                                               ; preds = %48
  store i64 -9223372036854775801, ptr %13, align 8, !tbaa !11
  br label %147

54:                                               ; preds = %48
  %55 = load i8, ptr %16, align 1, !tbaa !13
  %56 = icmp ne i8 %55, 0
  br i1 %56, label %57, label %69

57:                                               ; preds = %54
  %58 = load ptr, ptr @gBS, align 8, !tbaa !5
  %59 = getelementptr inbounds %struct.EFI_BOOT_SERVICES, ptr %58, i32 0, i32 15
  %60 = load ptr, ptr %59, align 8, !tbaa !27
  %61 = load ptr, ptr %11, align 8, !tbaa !5
  %62 = getelementptr inbounds %struct.SCSI_DISK_DEV, ptr %61, i32 0, i32 1
  %63 = load ptr, ptr %62, align 8, !tbaa !28
  %64 = load ptr, ptr %11, align 8, !tbaa !5
  %65 = getelementptr inbounds %struct.SCSI_DISK_DEV, ptr %64, i32 0, i32 2
  %66 = load ptr, ptr %11, align 8, !tbaa !5
  %67 = getelementptr inbounds %struct.SCSI_DISK_DEV, ptr %66, i32 0, i32 2
  %68 = call i64 %60(ptr noundef %63, ptr noundef @gEfiBlockIoProtocolGuid, ptr noundef %65, ptr noundef %67)
  store i64 -9223372036854775795, ptr %13, align 8, !tbaa !11
  br label %147

69:                                               ; preds = %54
  br label %70

70:                                               ; preds = %69, %47, %46
  %71 = load ptr, ptr %11, align 8, !tbaa !5
  %72 = getelementptr inbounds %struct.SCSI_DISK_DEV, ptr %71, i32 0, i32 2
  %73 = getelementptr inbounds %struct._EFI_BLOCK_IO_PROTOCOL, ptr %72, i32 0, i32 1
  %74 = load ptr, ptr %73, align 8, !tbaa !29
  store ptr %74, ptr %12, align 8, !tbaa !5
  %75 = load ptr, ptr %12, align 8, !tbaa !5
  %76 = getelementptr inbounds %struct.EFI_BLOCK_IO_MEDIA, ptr %75, i32 0, i32 6
  %77 = load i32, ptr %76, align 4, !tbaa !30
  %78 = zext i32 %77 to i64
  store i64 %78, ptr %14, align 8, !tbaa !11
  %79 = load i64, ptr %9, align 8, !tbaa !11
  %80 = load i64, ptr %14, align 8, !tbaa !11
  %81 = udiv i64 %79, %80
  store i64 %81, ptr %15, align 8, !tbaa !11
  %82 = load ptr, ptr %12, align 8, !tbaa !5
  %83 = getelementptr inbounds %struct.EFI_BLOCK_IO_MEDIA, ptr %82, i32 0, i32 2
  %84 = load i8, ptr %83, align 1, !tbaa !31
  %85 = icmp ne i8 %84, 0
  br i1 %85, label %87, label %86

86:                                               ; preds = %70
  store i64 -9223372036854775796, ptr %13, align 8, !tbaa !11
  br label %147

87:                                               ; preds = %70
  %88 = load i32, ptr %7, align 4, !tbaa !9
  %89 = load ptr, ptr %12, align 8, !tbaa !5
  %90 = getelementptr inbounds %struct.EFI_BLOCK_IO_MEDIA, ptr %89, i32 0, i32 0
  %91 = load i32, ptr %90, align 8, !tbaa !32
  %92 = icmp ne i32 %88, %91
  br i1 %92, label %93, label %94

93:                                               ; preds = %87
  store i64 -9223372036854775795, ptr %13, align 8, !tbaa !11
  br label %147

94:                                               ; preds = %87
  %95 = load i64, ptr %9, align 8, !tbaa !11
  %96 = icmp eq i64 %95, 0
  br i1 %96, label %97, label %98

97:                                               ; preds = %94
  store i64 0, ptr %13, align 8, !tbaa !11
  br label %147

98:                                               ; preds = %94
  %99 = load ptr, ptr %10, align 8, !tbaa !5
  %100 = icmp eq ptr %99, null
  br i1 %100, label %101, label %102

101:                                              ; preds = %98
  store i64 -9223372036854775806, ptr %13, align 8, !tbaa !11
  br label %147

102:                                              ; preds = %98
  %103 = load i64, ptr %9, align 8, !tbaa !11
  %104 = load i64, ptr %14, align 8, !tbaa !11
  %105 = urem i64 %103, %104
  %106 = icmp ne i64 %105, 0
  br i1 %106, label %107, label %108

107:                                              ; preds = %102
  store i64 -9223372036854775804, ptr %13, align 8, !tbaa !11
  br label %147

108:                                              ; preds = %102
  %109 = load i64, ptr %8, align 8, !tbaa !11
  %110 = load ptr, ptr %12, align 8, !tbaa !5
  %111 = getelementptr inbounds %struct.EFI_BLOCK_IO_MEDIA, ptr %110, i32 0, i32 8
  %112 = load i64, ptr %111, align 8, !tbaa !33
  %113 = icmp ugt i64 %109, %112
  br i1 %113, label %114, label %115

114:                                              ; preds = %108
  store i64 -9223372036854775806, ptr %13, align 8, !tbaa !11
  br label %147

115:                                              ; preds = %108
  %116 = load i64, ptr %8, align 8, !tbaa !11
  %117 = load i64, ptr %15, align 8, !tbaa !11
  %118 = add i64 %116, %117
  %119 = sub i64 %118, 1
  %120 = load ptr, ptr %12, align 8, !tbaa !5
  %121 = getelementptr inbounds %struct.EFI_BLOCK_IO_MEDIA, ptr %120, i32 0, i32 8
  %122 = load i64, ptr %121, align 8, !tbaa !33
  %123 = icmp ugt i64 %119, %122
  br i1 %123, label %124, label %125

124:                                              ; preds = %115
  store i64 -9223372036854775806, ptr %13, align 8, !tbaa !11
  br label %147

125:                                              ; preds = %115
  %126 = load ptr, ptr %12, align 8, !tbaa !5
  %127 = getelementptr inbounds %struct.EFI_BLOCK_IO_MEDIA, ptr %126, i32 0, i32 7
  %128 = load i32, ptr %127, align 8, !tbaa !34
  %129 = icmp ugt i32 %128, 1
  br i1 %129, label %130, label %141

130:                                              ; preds = %125
  %131 = load ptr, ptr %10, align 8, !tbaa !5
  %132 = ptrtoint ptr %131 to i64
  %133 = load ptr, ptr %12, align 8, !tbaa !5
  %134 = getelementptr inbounds %struct.EFI_BLOCK_IO_MEDIA, ptr %133, i32 0, i32 7
  %135 = load i32, ptr %134, align 8, !tbaa !34
  %136 = sub i32 %135, 1
  %137 = zext i32 %136 to i64
  %138 = and i64 %132, %137
  %139 = icmp ne i64 %138, 0
  br i1 %139, label %140, label %141

140:                                              ; preds = %130
  store i64 -9223372036854775806, ptr %13, align 8, !tbaa !11
  br label %147

141:                                              ; preds = %130, %125
  %142 = load ptr, ptr %11, align 8, !tbaa !5
  %143 = load ptr, ptr %10, align 8, !tbaa !5
  %144 = load i64, ptr %8, align 8, !tbaa !11
  %145 = load i64, ptr %15, align 8, !tbaa !11
  %146 = call i64 @ScsiDiskWriteSectors(ptr noundef %142, ptr noundef %143, i64 noundef %144, i64 noundef %145)
  store i64 %146, ptr %13, align 8, !tbaa !11
  br label %147

147:                                              ; preds = %141, %140, %124, %114, %107, %101, %97, %93, %86, %57, %53
  %148 = load ptr, ptr @gBS, align 8, !tbaa !5
  %149 = getelementptr inbounds %struct.EFI_BOOT_SERVICES, ptr %148, i32 0, i32 2
  %150 = load ptr, ptr %149, align 8, !tbaa !35
  %151 = load i64, ptr %17, align 8, !tbaa !11
  call void %150(i64 noundef %151)
  %152 = load i64, ptr %13, align 8, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #3
  call void @llvm.lifetime.end.p0(i64 1, 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 8, ptr %11) #3
  ret i64 %152
}

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

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

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, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"long long", !7, i64 0}
!13 = !{!7, !7, i64 0}
!14 = !{!15, !6, i64 24}
!15 = !{!"", !16, 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}
!16 = !{!"", !12, i64 0, !10, i64 8, !10, i64 12, !10, i64 16, !10, i64 20}
!17 = !{!18, !10, i64 0}
!18 = !{!"", !10, i64 0, !6, i64 8, !19, i64 16, !20, i64 64, !6, i64 112, !7, i64 120, !7, i64 121, !21, i64 122, !6, i64 128, !12, i64 136, !22, i64 144, !6, i64 240, !23, i64 248, !10, i64 296, !10, i64 300, !25, i64 304, !7, i64 816}
!19 = !{!"_EFI_BLOCK_IO_PROTOCOL", !12, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40}
!20 = !{!"", !10, i64 0, !7, i64 4, !7, i64 5, !7, i64 6, !7, i64 7, !7, i64 8, !10, i64 12, !10, i64 16, !12, i64 24, !12, i64 32, !10, i64 40, !10, i64 44}
!21 = !{!"short", !7, i64 0}
!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 = !{!"", !10, i64 0, !21, i64 4, !21, i64 6, !7, i64 8}
!25 = !{!"", !21, i64 0, !21, i64 2, !21, i64 4, !7, i64 6, !7, i64 20, !7, i64 40, !7, i64 46, !7, i64 54, !7, i64 94, !21, i64 98, !21, i64 100, !21, i64 102, !21, i64 104, !21, i64 106, !7, i64 108, !21, i64 124, !21, i64 126, !21, i64 128, !21, i64 130, !21, i64 132, !21, i64 134, !21, i64 136, !7, i64 138, !7, i64 142, !7, i64 146, !21, i64 150, !21, i64 152, !21, i64 154, !21, i64 156, !21, i64 158, !21, i64 160, !21, i64 162, !21, i64 164, !21, i64 166, !21, i64 168, !21, i64 170, !21, i64 172, !21, i64 174, !21, i64 176, !21, i64 178, !21, i64 180, !21, i64 182, !21, i64 184, !21, i64 186, !21, i64 188, !7, i64 190, !7, i64 216, !7, i64 224, !7, i64 232, !21, i64 238, !21, i64 240, !7, i64 242, !21, i64 250, !7, i64 252, !21, i64 256, !7, i64 258, !7, i64 320, !7, i64 352, !21, i64 444, !21, i64 446, !7, i64 448, !21, i64 510}
!26 = !{!18, !7, i64 121}
!27 = !{!15, !6, i64 136}
!28 = !{!18, !6, i64 8}
!29 = !{!18, !6, i64 24}
!30 = !{!20, !10, i64 12}
!31 = !{!20, !7, i64 5}
!32 = !{!20, !10, i64 0}
!33 = !{!20, !12, i64 24}
!34 = !{!20, !10, i64 16}
!35 = !{!15, !6, i64 32}


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

@.str.1 = external hidden unnamed_addr constant [146 x i8], align 1
@gBS = external local_unnamed_addr global ptr, align 8
@gEfiBlockIoProtocolGuid = external global %struct.GUID, align 4
@.str.6 = external hidden unnamed_addr constant [21 x i8], align 1

; 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 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 i64 @ScsiDiskWriteBlocks(ptr noundef %0, i32 noundef %1, i64 noundef %2, i64 noundef %3, ptr noundef %4) local_unnamed_addr #2 {
  %6 = alloca i8, align 1
  call void @llvm.lifetime.start.p0(i64 1, ptr nonnull %6) #3
  store i8 0, ptr %6, align 1, !tbaa !5
  %7 = load ptr, ptr @gBS, align 8, !tbaa !8
  %8 = getelementptr inbounds i8, ptr %7, i64 24
  %9 = load ptr, ptr %8, align 8, !tbaa !10
  %10 = tail call i64 %9(i64 noundef 8) #3
  %11 = tail call zeroext i8 @DebugAssertEnabled() #3
  %.not = icmp eq i8 %11, 0
  %.pre = ptrtoint ptr %0 to i64
  %.pre45 = add i64 %.pre, -16
  %.pre47 = inttoptr i64 %.pre45 to ptr
  br i1 %.not, label %._crit_edge, label %12

12:                                               ; preds = %5
  %13 = load i32, ptr %.pre47, align 8, !tbaa !15
  %.not38 = icmp eq i32 %13, 1801741171
  br i1 %.not38, label %._crit_edge, label %14

14:                                               ; preds = %12
  tail call void @DebugAssert(ptr noundef nonnull @.str.1, i64 noundef 626, ptr noundef nonnull @.str.6) #3
  br label %._crit_edge

._crit_edge:                                      ; preds = %5, %12, %14
  %15 = phi ptr [ %0, %14 ], [ %.pre47, %12 ], [ %.pre47, %5 ]
  %16 = getelementptr inbounds i8, ptr %15, i64 121
  %17 = load i8, ptr %16, align 1, !tbaa !24
  %.not39 = icmp eq i8 %17, 0
  br i1 %.not39, label %18, label %31

18:                                               ; preds = %._crit_edge
  %19 = call i64 @ScsiDiskDetectMedia(ptr noundef nonnull %15, i8 noundef zeroext 0, ptr noundef nonnull %6)
  %20 = icmp slt i64 %19, 0
  br i1 %20, label %67, label %21

21:                                               ; preds = %18
  %22 = load i8, ptr %6, align 1, !tbaa !5
  %.not40 = icmp eq i8 %22, 0
  br i1 %.not40, label %31, label %23

23:                                               ; preds = %21
  %24 = load ptr, ptr @gBS, align 8, !tbaa !8
  %25 = getelementptr inbounds i8, ptr %24, i64 136
  %26 = load ptr, ptr %25, align 8, !tbaa !25
  %27 = getelementptr inbounds i8, ptr %15, i64 8
  %28 = load ptr, ptr %27, align 8, !tbaa !26
  %29 = getelementptr inbounds i8, ptr %15, i64 16
  %30 = call i64 %26(ptr noundef %28, ptr noundef nonnull @gEfiBlockIoProtocolGuid, ptr noundef nonnull %29, ptr noundef nonnull %29) #3
  br label %67

31:                                               ; preds = %21, %._crit_edge
  %32 = getelementptr inbounds i8, ptr %15, i64 24
  %33 = load ptr, ptr %32, align 8, !tbaa !27
  %34 = getelementptr inbounds i8, ptr %33, i64 12
  %35 = load i32, ptr %34, align 4, !tbaa !28
  %36 = zext i32 %35 to i64
  %37 = udiv i64 %3, %36
  %38 = urem i64 %3, %36
  %39 = getelementptr inbounds i8, ptr %33, i64 5
  %40 = load i8, ptr %39, align 1, !tbaa !29
  %.not41 = icmp eq i8 %40, 0
  br i1 %.not41, label %67, label %41

41:                                               ; preds = %31
  %42 = load i32, ptr %33, align 8, !tbaa !30
  %.not42 = icmp eq i32 %42, %1
  br i1 %.not42, label %43, label %67

43:                                               ; preds = %41
  %44 = icmp eq i64 %3, 0
  br i1 %44, label %67, label %45

45:                                               ; preds = %43
  %46 = icmp eq ptr %4, null
  br i1 %46, label %67, label %47

47:                                               ; preds = %45
  %.not43 = icmp eq i64 %38, 0
  br i1 %.not43, label %48, label %67

48:                                               ; preds = %47
  %49 = getelementptr inbounds i8, ptr %33, i64 24
  %50 = load i64, ptr %49, align 8, !tbaa !31
  %51 = icmp ult i64 %50, %2
  br i1 %51, label %67, label %52

52:                                               ; preds = %48
  %53 = add i64 %2, -1
  %54 = add i64 %53, %37
  %55 = icmp ugt i64 %54, %50
  br i1 %55, label %67, label %56

56:                                               ; preds = %52
  %57 = getelementptr inbounds i8, ptr %33, i64 16
  %58 = load i32, ptr %57, align 8, !tbaa !32
  %59 = icmp ugt i32 %58, 1
  br i1 %59, label %60, label %65

60:                                               ; preds = %56
  %61 = ptrtoint ptr %4 to i64
  %62 = add i32 %58, -1
  %63 = zext i32 %62 to i64
  %64 = and i64 %63, %61
  %.not44 = icmp eq i64 %64, 0
  br i1 %.not44, label %65, label %67

65:                                               ; preds = %60, %56
  %66 = call i64 @ScsiDiskWriteSectors(ptr noundef nonnull %15, ptr noundef nonnull %4, i64 noundef %2, i64 noundef %37)
  br label %67

67:                                               ; preds = %60, %52, %48, %47, %45, %43, %41, %31, %18, %65, %23
  %.0 = phi i64 [ %66, %65 ], [ -9223372036854775795, %23 ], [ -9223372036854775801, %18 ], [ -9223372036854775796, %31 ], [ -9223372036854775795, %41 ], [ 0, %43 ], [ -9223372036854775806, %45 ], [ -9223372036854775804, %47 ], [ -9223372036854775806, %48 ], [ -9223372036854775806, %52 ], [ -9223372036854775806, %60 ]
  %68 = load ptr, ptr @gBS, align 8, !tbaa !8
  %69 = getelementptr inbounds i8, ptr %68, i64 32
  %70 = load ptr, ptr %69, align 8, !tbaa !33
  call void %70(i64 noundef %10) #3
  call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %6) #3
  ret i64 %.0
}

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

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

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 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C/C++ TBAA"}
!8 = !{!9, !9, i64 0}
!9 = !{!"any pointer", !6, i64 0}
!10 = !{!11, !9, i64 24}
!11 = !{!"", !12, i64 0, !9, i64 24, !9, i64 32, !9, i64 40, !9, i64 48, !9, i64 56, !9, i64 64, !9, i64 72, !9, i64 80, !9, i64 88, !9, i64 96, !9, i64 104, !9, i64 112, !9, i64 120, !9, i64 128, !9, i64 136, !9, i64 144, !9, i64 152, !9, i64 160, !9, i64 168, !9, i64 176, !9, i64 184, !9, i64 192, !9, i64 200, !9, i64 208, !9, i64 216, !9, i64 224, !9, i64 232, !9, i64 240, !9, i64 248, !9, i64 256, !9, i64 264, !9, i64 272, !9, i64 280, !9, i64 288, !9, i64 296, !9, i64 304, !9, i64 312, !9, i64 320, !9, i64 328, !9, i64 336, !9, i64 344, !9, i64 352, !9, i64 360, !9, i64 368}
!12 = !{!"", !13, i64 0, !14, i64 8, !14, i64 12, !14, i64 16, !14, i64 20}
!13 = !{!"long long", !6, i64 0}
!14 = !{!"int", !6, i64 0}
!15 = !{!16, !14, i64 0}
!16 = !{!"", !14, i64 0, !9, i64 8, !17, i64 16, !18, i64 64, !9, i64 112, !6, i64 120, !6, i64 121, !19, i64 122, !9, i64 128, !13, i64 136, !20, i64 144, !9, i64 240, !21, i64 248, !14, i64 296, !14, i64 300, !23, i64 304, !6, i64 816}
!17 = !{!"_EFI_BLOCK_IO_PROTOCOL", !13, i64 0, !9, i64 8, !9, i64 16, !9, i64 24, !9, i64 32, !9, i64 40}
!18 = !{!"", !14, i64 0, !6, i64 4, !6, i64 5, !6, i64 6, !6, i64 7, !6, i64 8, !14, i64 12, !14, i64 16, !13, i64 24, !13, i64 32, !14, i64 40, !14, i64 44}
!19 = !{!"short", !6, i64 0}
!20 = !{!"", !6, i64 0, !6, i64 0, !6, i64 1, !6, i64 1, !6, i64 2, !6, i64 3, !6, i64 4, !6, i64 5}
!21 = !{!"_EFI_DISK_INFO_PROTOCOL", !22, i64 0, !9, i64 16, !9, i64 24, !9, i64 32, !9, i64 40}
!22 = !{!"", !14, i64 0, !19, i64 4, !19, i64 6, !6, i64 8}
!23 = !{!"", !19, i64 0, !19, i64 2, !19, i64 4, !6, i64 6, !6, i64 20, !6, i64 40, !6, i64 46, !6, i64 54, !6, i64 94, !19, i64 98, !19, i64 100, !19, i64 102, !19, i64 104, !19, i64 106, !6, i64 108, !19, i64 124, !19, i64 126, !19, i64 128, !19, i64 130, !19, i64 132, !19, i64 134, !19, i64 136, !6, i64 138, !6, i64 142, !6, i64 146, !19, i64 150, !19, i64 152, !19, i64 154, !19, i64 156, !19, i64 158, !19, i64 160, !19, i64 162, !19, i64 164, !19, i64 166, !19, i64 168, !19, i64 170, !19, i64 172, !19, i64 174, !19, i64 176, !19, i64 178, !19, i64 180, !19, i64 182, !19, i64 184, !19, i64 186, !19, i64 188, !6, i64 190, !6, i64 216, !6, i64 224, !6, i64 232, !19, i64 238, !19, i64 240, !6, i64 242, !19, i64 250, !6, i64 252, !19, i64 256, !6, i64 258, !6, i64 320, !6, i64 352, !19, i64 444, !19, i64 446, !6, i64 448, !19, i64 510}
!24 = !{!16, !6, i64 121}
!25 = !{!11, !9, i64 136}
!26 = !{!16, !9, i64 8}
!27 = !{!16, !9, i64 24}
!28 = !{!18, !14, i64 12}
!29 = !{!18, !6, i64 5}
!30 = !{!18, !14, i64 0}
!31 = !{!18, !13, i64 24}
!32 = !{!18, !14, i64 16}
!33 = !{!11, !9, i64 32}


; Effective O3 passes: BDCEPass,CorrelatedValuePropagationPass,DivRemPairsPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass