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

; 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_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._USB_MASS_DEVICE = type { i32, ptr, ptr, ptr, %struct._EFI_BLOCK_IO_PROTOCOL, %struct.EFI_BLOCK_IO_MEDIA, i8, i8, i8, ptr, ptr, %struct._EFI_DISK_INFO_PROTOCOL, %struct.USB_BOOT_INQUIRY_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_DISK_INFO_PROTOCOL = type { %struct.GUID, ptr, ptr, ptr, ptr }
%struct.GUID = type { i32, i16, i16, [8 x i8] }
%struct.USB_BOOT_INQUIRY_DATA = type { i8, i8, [2 x i8], i8, [3 x i8], [8 x i8], [16 x i8], [4 x i8] }

@gBS = external global ptr, align 8
@.str = external hidden unnamed_addr constant [154 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [21 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [54 x i8], align 1

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

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

declare zeroext i8 @DebugAssertEnabled() #2

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

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

declare i64 @UsbBootDetectMedia(ptr noundef) #2

declare zeroext i8 @DebugPrintEnabled() #2

declare zeroext i8 @DebugPrintLevelEnabled(i64 noundef) #2

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

; Function Attrs: nounwind uwtable
define dso_local i64 @UsbMassWriteBlocks(ptr noundef %0, i32 noundef %1, i64 noundef %2, i64 noundef %3, ptr noundef %4) #0 {
  %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
  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
  %16 = load ptr, ptr @gBS, align 8, !tbaa !5
  %17 = getelementptr inbounds %struct.EFI_BOOT_SERVICES, ptr %16, i32 0, i32 1
  %18 = load ptr, ptr %17, align 8, !tbaa !13
  %19 = call i64 %18(i64 noundef 16)
  store i64 %19, ptr %14, align 8, !tbaa !11
  %20 = call zeroext i8 @DebugAssertEnabled()
  %21 = zext i8 %20 to i32
  %22 = icmp ne i32 %21, 0
  br i1 %22, label %23, label %33

23:                                               ; preds = %5
  %24 = load ptr, ptr %6, align 8, !tbaa !5
  %25 = ptrtoint ptr %24 to i64
  %26 = sub i64 %25, ptrtoint (ptr getelementptr inbounds (%struct._USB_MASS_DEVICE, ptr null, i32 0, i32 4) to i64)
  %27 = inttoptr i64 %26 to ptr
  %28 = getelementptr inbounds %struct._USB_MASS_DEVICE, ptr %27, i32 0, i32 0
  %29 = load i32, ptr %28, align 8, !tbaa !16
  %30 = icmp ne i32 %29, 1298297685
  br i1 %30, label %31, label %33

31:                                               ; preds = %23
  call void @DebugAssert(ptr noundef @.str, i64 noundef 237, ptr noundef @.str.1)
  %32 = load ptr, ptr %6, align 8, !tbaa !5
  br label %38

33:                                               ; preds = %23, %5
  %34 = load ptr, ptr %6, align 8, !tbaa !5
  %35 = ptrtoint ptr %34 to i64
  %36 = sub i64 %35, ptrtoint (ptr getelementptr inbounds (%struct._USB_MASS_DEVICE, ptr null, i32 0, i32 4) to i64)
  %37 = inttoptr i64 %36 to ptr
  br label %38

38:                                               ; preds = %33, %31
  %39 = phi ptr [ %32, %31 ], [ %37, %33 ]
  store ptr %39, ptr %11, align 8, !tbaa !5
  %40 = load ptr, ptr %11, align 8, !tbaa !5
  %41 = getelementptr inbounds %struct._USB_MASS_DEVICE, ptr %40, i32 0, i32 5
  store ptr %41, ptr %12, align 8, !tbaa !5
  %42 = load ptr, ptr %12, align 8, !tbaa !5
  %43 = getelementptr inbounds %struct.EFI_BLOCK_IO_MEDIA, ptr %42, i32 0, i32 1
  %44 = load i8, ptr %43, align 4, !tbaa !24
  %45 = icmp ne i8 %44, 0
  br i1 %45, label %46, label %53

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

51:                                               ; preds = %46
  br label %139

52:                                               ; preds = %46
  br label %53

53:                                               ; preds = %52, %38
  %54 = load ptr, ptr %12, align 8, !tbaa !5
  %55 = getelementptr inbounds %struct.EFI_BLOCK_IO_MEDIA, ptr %54, i32 0, i32 2
  %56 = load i8, ptr %55, align 1, !tbaa !25
  %57 = icmp ne i8 %56, 0
  br i1 %57, label %59, label %58

58:                                               ; preds = %53
  store i64 -9223372036854775796, ptr %13, align 8, !tbaa !11
  br label %139

59:                                               ; preds = %53
  %60 = load i32, ptr %7, align 4, !tbaa !9
  %61 = load ptr, ptr %12, align 8, !tbaa !5
  %62 = getelementptr inbounds %struct.EFI_BLOCK_IO_MEDIA, ptr %61, i32 0, i32 0
  %63 = load i32, ptr %62, align 8, !tbaa !26
  %64 = icmp ne i32 %60, %63
  br i1 %64, label %65, label %66

65:                                               ; preds = %59
  store i64 -9223372036854775795, ptr %13, align 8, !tbaa !11
  br label %139

66:                                               ; preds = %59
  %67 = load i64, ptr %9, align 8, !tbaa !11
  %68 = icmp eq i64 %67, 0
  br i1 %68, label %69, label %70

69:                                               ; preds = %66
  store i64 0, ptr %13, align 8, !tbaa !11
  br label %139

70:                                               ; preds = %66
  %71 = load ptr, ptr %10, align 8, !tbaa !5
  %72 = icmp eq ptr %71, null
  br i1 %72, label %73, label %74

73:                                               ; preds = %70
  store i64 -9223372036854775806, ptr %13, align 8, !tbaa !11
  br label %139

74:                                               ; preds = %70
  %75 = load i64, ptr %9, align 8, !tbaa !11
  %76 = load ptr, ptr %12, align 8, !tbaa !5
  %77 = getelementptr inbounds %struct.EFI_BLOCK_IO_MEDIA, ptr %76, i32 0, i32 6
  %78 = load i32, ptr %77, align 4, !tbaa !27
  %79 = zext i32 %78 to i64
  %80 = urem i64 %75, %79
  %81 = icmp ne i64 %80, 0
  br i1 %81, label %82, label %83

82:                                               ; preds = %74
  store i64 -9223372036854775804, ptr %13, align 8, !tbaa !11
  br label %139

83:                                               ; preds = %74
  %84 = load i64, ptr %9, align 8, !tbaa !11
  %85 = load ptr, ptr %12, align 8, !tbaa !5
  %86 = getelementptr inbounds %struct.EFI_BLOCK_IO_MEDIA, ptr %85, i32 0, i32 6
  %87 = load i32, ptr %86, align 4, !tbaa !27
  %88 = zext i32 %87 to i64
  %89 = udiv i64 %84, %88
  store i64 %89, ptr %15, align 8, !tbaa !11
  %90 = load i64, ptr %8, align 8, !tbaa !11
  %91 = load i64, ptr %15, align 8, !tbaa !11
  %92 = add i64 %90, %91
  %93 = sub i64 %92, 1
  %94 = load ptr, ptr %12, align 8, !tbaa !5
  %95 = getelementptr inbounds %struct.EFI_BLOCK_IO_MEDIA, ptr %94, i32 0, i32 8
  %96 = load i64, ptr %95, align 8, !tbaa !28
  %97 = icmp ugt i64 %93, %96
  br i1 %97, label %98, label %99

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

99:                                               ; preds = %83
  %100 = load ptr, ptr %11, align 8, !tbaa !5
  %101 = getelementptr inbounds %struct._USB_MASS_DEVICE, ptr %100, i32 0, i32 13
  %102 = load i8, ptr %101, align 4, !tbaa !29
  %103 = icmp ne i8 %102, 0
  br i1 %103, label %104, label %110

104:                                              ; preds = %99
  %105 = load ptr, ptr %11, align 8, !tbaa !5
  %106 = load i64, ptr %8, align 8, !tbaa !11
  %107 = load i64, ptr %15, align 8, !tbaa !11
  %108 = load ptr, ptr %10, align 8, !tbaa !5
  %109 = call i64 @UsbBootWriteBlocks16(ptr noundef %105, i64 noundef %106, i64 noundef %107, ptr noundef %108)
  store i64 %109, ptr %13, align 8, !tbaa !11
  br label %117

110:                                              ; preds = %99
  %111 = load ptr, ptr %11, align 8, !tbaa !5
  %112 = load i64, ptr %8, align 8, !tbaa !11
  %113 = trunc i64 %112 to i32
  %114 = load i64, ptr %15, align 8, !tbaa !11
  %115 = load ptr, ptr %10, align 8, !tbaa !5
  %116 = call i64 @UsbBootWriteBlocks(ptr noundef %111, i32 noundef %113, i64 noundef %114, ptr noundef %115)
  store i64 %116, ptr %13, align 8, !tbaa !11
  br label %117

117:                                              ; preds = %110, %104
  %118 = load i64, ptr %13, align 8, !tbaa !11
  %119 = icmp slt i64 %118, 0
  br i1 %119, label %120, label %138

120:                                              ; preds = %117
  br label %121

121:                                              ; preds = %120
  %122 = call zeroext i8 @DebugPrintEnabled()
  %123 = icmp ne i8 %122, 0
  br i1 %123, label %124, label %133

124:                                              ; preds = %121
  br label %125

125:                                              ; preds = %124
  %126 = call zeroext i8 @DebugPrintLevelEnabled(i64 noundef 2147483648)
  %127 = icmp ne i8 %126, 0
  br i1 %127, label %128, label %130

128:                                              ; preds = %125
  %129 = load i64, ptr %13, align 8, !tbaa !11
  call void (i64, ptr, ...) @DebugPrint(i64 noundef 2147483648, ptr noundef @.str.3, i64 noundef %129)
  br label %130

130:                                              ; preds = %128, %125
  br label %131

131:                                              ; preds = %130
  br label %132

132:                                              ; preds = %131
  br label %133

133:                                              ; preds = %132, %121
  br label %134

134:                                              ; preds = %133
  br label %135

135:                                              ; preds = %134
  %136 = load ptr, ptr %6, align 8, !tbaa !5
  %137 = call i64 @UsbMassReset(ptr noundef %136, i8 noundef zeroext 1)
  br label %138

138:                                              ; preds = %135, %117
  br label %139

139:                                              ; preds = %138, %98, %82, %73, %69, %65, %58, %51
  %140 = load ptr, ptr @gBS, align 8, !tbaa !5
  %141 = getelementptr inbounds %struct.EFI_BOOT_SERVICES, ptr %140, i32 0, i32 2
  %142 = load ptr, ptr %141, align 8, !tbaa !30
  %143 = load i64, ptr %14, align 8, !tbaa !11
  call void %142(i64 noundef %143)
  %144 = load i64, ptr %13, align 8, !tbaa !11
  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 %144
}

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

declare i64 @UsbBootWriteBlocks(ptr noundef, i32 noundef, i64 noundef, ptr noundef) #2

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 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"long long", !7, i64 0}
!13 = !{!14, !6, i64 24}
!14 = !{!"", !15, 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}
!15 = !{!"", !12, i64 0, !10, i64 8, !10, i64 12, !10, i64 16, !10, i64 20}
!16 = !{!17, !10, i64 0}
!17 = !{!"_USB_MASS_DEVICE", !10, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !18, i64 32, !19, i64 80, !7, i64 128, !7, i64 129, !7, i64 130, !6, i64 136, !6, i64 144, !20, i64 152, !23, i64 200, !7, i64 236}
!18 = !{!"_EFI_BLOCK_IO_PROTOCOL", !12, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40}
!19 = !{!"", !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}
!20 = !{!"_EFI_DISK_INFO_PROTOCOL", !21, i64 0, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40}
!21 = !{!"", !10, i64 0, !22, i64 4, !22, i64 6, !7, i64 8}
!22 = !{!"short", !7, i64 0}
!23 = !{!"", !7, i64 0, !7, i64 1, !7, i64 2, !7, i64 4, !7, i64 5, !7, i64 8, !7, i64 16, !7, i64 32}
!24 = !{!19, !7, i64 4}
!25 = !{!19, !7, i64 5}
!26 = !{!19, !10, i64 0}
!27 = !{!19, !10, i64 12}
!28 = !{!19, !12, i64 24}
!29 = !{!17, !7, i64 236}
!30 = !{!14, !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"

@gBS = external local_unnamed_addr global ptr, align 8
@.str = external hidden unnamed_addr constant [154 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [21 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [54 x i8], align 1

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

declare zeroext i8 @DebugAssertEnabled() local_unnamed_addr #1

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

declare i64 @UsbBootDetectMedia(ptr noundef) 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

; Function Attrs: nounwind uwtable
define dso_local i64 @UsbMassWriteBlocks(ptr noundef %0, i32 noundef %1, i64 noundef %2, i64 noundef %3, ptr noundef %4) local_unnamed_addr #0 {
  %6 = load ptr, ptr @gBS, align 8, !tbaa !5
  %7 = getelementptr inbounds i8, ptr %6, i64 24
  %8 = load ptr, ptr %7, align 8, !tbaa !9
  %9 = tail call i64 %8(i64 noundef 16) #2
  %10 = tail call zeroext i8 @DebugAssertEnabled() #2
  %.not = icmp eq i8 %10, 0
  %.pre = ptrtoint ptr %0 to i64
  %.pre43 = add i64 %.pre, -32
  %.pre45 = inttoptr i64 %.pre43 to ptr
  br i1 %.not, label %._crit_edge, label %11

11:                                               ; preds = %5
  %12 = load i32, ptr %.pre45, align 8, !tbaa !14
  %.not35 = icmp eq i32 %12, 1298297685
  br i1 %.not35, label %._crit_edge, label %13

13:                                               ; preds = %11
  tail call void @DebugAssert(ptr noundef nonnull @.str, i64 noundef 237, ptr noundef nonnull @.str.1) #2
  br label %._crit_edge

._crit_edge:                                      ; preds = %5, %11, %13
  %14 = phi ptr [ %0, %13 ], [ %.pre45, %11 ], [ %.pre45, %5 ]
  %15 = getelementptr inbounds i8, ptr %14, i64 80
  %16 = getelementptr inbounds i8, ptr %14, i64 84
  %17 = load i8, ptr %16, align 4, !tbaa !22
  %.not36 = icmp eq i8 %17, 0
  br i1 %.not36, label %21, label %18

18:                                               ; preds = %._crit_edge
  %19 = tail call i64 @UsbBootDetectMedia(ptr noundef nonnull %14) #2
  %20 = icmp slt i64 %19, 0
  br i1 %20, label %59, label %21

21:                                               ; preds = %18, %._crit_edge
  %22 = getelementptr inbounds i8, ptr %14, i64 85
  %23 = load i8, ptr %22, align 1, !tbaa !23
  %.not37 = icmp eq i8 %23, 0
  br i1 %.not37, label %59, label %24

24:                                               ; preds = %21
  %25 = load i32, ptr %15, align 8, !tbaa !24
  %.not38 = icmp eq i32 %25, %1
  br i1 %.not38, label %26, label %59

26:                                               ; preds = %24
  %27 = icmp eq i64 %3, 0
  br i1 %27, label %59, label %28

28:                                               ; preds = %26
  %29 = icmp eq ptr %4, null
  br i1 %29, label %59, label %30

30:                                               ; preds = %28
  %31 = getelementptr inbounds i8, ptr %14, i64 92
  %32 = load i32, ptr %31, align 4, !tbaa !25
  %33 = zext i32 %32 to i64
  %34 = urem i64 %3, %33
  %35 = udiv i64 %3, %33
  %.not39 = icmp eq i64 %34, 0
  br i1 %.not39, label %36, label %59

36:                                               ; preds = %30
  %37 = add i64 %2, -1
  %38 = add i64 %37, %35
  %39 = getelementptr inbounds i8, ptr %14, i64 104
  %40 = load i64, ptr %39, align 8, !tbaa !26
  %41 = icmp ugt i64 %38, %40
  br i1 %41, label %59, label %42

42:                                               ; preds = %36
  %43 = getelementptr inbounds i8, ptr %14, i64 236
  %44 = load i8, ptr %43, align 4, !tbaa !27
  %.not40 = icmp eq i8 %44, 0
  br i1 %.not40, label %47, label %45

45:                                               ; preds = %42
  %46 = tail call i64 @UsbBootWriteBlocks16(ptr noundef nonnull %14, i64 noundef %2, i64 noundef %35, ptr noundef nonnull %4) #2
  br label %50

47:                                               ; preds = %42
  %48 = trunc i64 %2 to i32
  %49 = tail call i64 @UsbBootWriteBlocks(ptr noundef nonnull %14, i32 noundef %48, i64 noundef %35, ptr noundef nonnull %4) #2
  br label %50

50:                                               ; preds = %47, %45
  %.0 = phi i64 [ %46, %45 ], [ %49, %47 ]
  %51 = icmp slt i64 %.0, 0
  br i1 %51, label %52, label %59

52:                                               ; preds = %50
  %53 = tail call zeroext i8 @DebugPrintEnabled() #2
  %.not41 = icmp eq i8 %53, 0
  br i1 %.not41, label %57, label %54

54:                                               ; preds = %52
  %55 = tail call zeroext i8 @DebugPrintLevelEnabled(i64 noundef 2147483648) #2
  %.not42 = icmp eq i8 %55, 0
  br i1 %.not42, label %57, label %56

56:                                               ; preds = %54
  tail call void (i64, ptr, ...) @DebugPrint(i64 noundef 2147483648, ptr noundef nonnull @.str.3, i64 noundef %.0) #2
  br label %57

57:                                               ; preds = %54, %56, %52
  %58 = tail call i64 @UsbMassReset(ptr noundef %0, i8 noundef zeroext 1)
  br label %59

59:                                               ; preds = %36, %30, %28, %26, %24, %21, %50, %57, %18
  %.1 = phi i64 [ %19, %18 ], [ %.0, %57 ], [ %.0, %50 ], [ -9223372036854775796, %21 ], [ -9223372036854775795, %24 ], [ 0, %26 ], [ -9223372036854775806, %28 ], [ -9223372036854775804, %30 ], [ -9223372036854775806, %36 ]
  %60 = load ptr, ptr @gBS, align 8, !tbaa !5
  %61 = getelementptr inbounds i8, ptr %60, i64 32
  %62 = load ptr, ptr %61, align 8, !tbaa !28
  tail call void %62(i64 noundef %9) #2
  ret i64 %.1
}

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

declare i64 @UsbBootWriteBlocks(ptr noundef, i32 noundef, i64 noundef, ptr noundef) local_unnamed_addr #1

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 = { "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 }

!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 24}
!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, !13, i64 0}
!15 = !{!"_USB_MASS_DEVICE", !13, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !16, i64 32, !17, i64 80, !7, i64 128, !7, i64 129, !7, i64 130, !6, i64 136, !6, i64 144, !18, i64 152, !21, i64 200, !7, i64 236}
!16 = !{!"_EFI_BLOCK_IO_PROTOCOL", !12, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40}
!17 = !{!"", !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}
!18 = !{!"_EFI_DISK_INFO_PROTOCOL", !19, i64 0, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40}
!19 = !{!"", !13, i64 0, !20, i64 4, !20, i64 6, !7, i64 8}
!20 = !{!"short", !7, i64 0}
!21 = !{!"", !7, i64 0, !7, i64 1, !7, i64 2, !7, i64 4, !7, i64 5, !7, i64 8, !7, i64 16, !7, i64 32}
!22 = !{!17, !7, i64 4}
!23 = !{!17, !7, i64 5}
!24 = !{!17, !13, i64 0}
!25 = !{!17, !13, i64 12}
!26 = !{!17, !12, i64 24}
!27 = !{!15, !7, i64 236}
!28 = !{!10, !6, i64 32}


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