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

; 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._EFI_DRIVER_BINDING_PROTOCOL = type { ptr, ptr, ptr, i32, ptr, ptr }
%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.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
@gEfiUsbIoProtocolGuid = external global %struct.GUID, align 4
@.str.6 = external hidden unnamed_addr constant [24 x i8], align 1
@gEfiBlockIoProtocolGuid = external global %struct.GUID, align 4
@gEfiDiskInfoProtocolGuid = external global %struct.GUID, align 4
@.str.12 = external hidden unnamed_addr constant [53 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [42 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

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

declare zeroext i8 @DebugPrintEnabled() #2

declare zeroext i8 @DebugPrintLevelEnabled(i64 noundef) #2

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

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

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

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

declare ptr @AllocateZeroPool(i64 noundef) #2

declare void @FreePool(ptr noundef) #2

declare void @InitializeDiskInfo(ptr noundef) #2

; Function Attrs: nounwind uwtable
define dso_local i64 @UsbMassInitNonLun(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 ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca i64, align 8
  %13 = 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 8, ptr %10) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #3
  store ptr null, ptr %11, align 8, !tbaa !5
  %14 = call ptr @AllocateZeroPool(i64 noundef 240)
  store ptr %14, ptr %10, align 8, !tbaa !5
  br label %15

15:                                               ; preds = %4
  %16 = call zeroext i8 @DebugAssertEnabled()
  %17 = icmp ne i8 %16, 0
  br i1 %17, label %18, label %23

18:                                               ; preds = %15
  %19 = load ptr, ptr %10, align 8, !tbaa !5
  %20 = icmp ne ptr %19, null
  br i1 %20, label %22, label %21

21:                                               ; preds = %18
  call void @DebugAssert(ptr noundef @.str, i64 noundef 622, ptr noundef @.str.6)
  br label %22

22:                                               ; preds = %21, %18
  br label %23

23:                                               ; preds = %22, %15
  br label %24

24:                                               ; preds = %23
  br label %25

25:                                               ; preds = %24
  %26 = load ptr, ptr @gBS, align 8, !tbaa !5
  %27 = getelementptr inbounds %struct.EFI_BOOT_SERVICES, ptr %26, i32 0, i32 33
  %28 = load ptr, ptr %27, align 8, !tbaa !9
  %29 = load ptr, ptr %7, align 8, !tbaa !5
  %30 = load ptr, ptr %6, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct._EFI_DRIVER_BINDING_PROTOCOL, ptr %30, i32 0, i32 5
  %32 = load ptr, ptr %31, align 8, !tbaa !14
  %33 = load ptr, ptr %7, align 8, !tbaa !5
  %34 = call i64 %28(ptr noundef %29, ptr noundef @gEfiUsbIoProtocolGuid, ptr noundef %11, ptr noundef %32, ptr noundef %33, i32 noundef 16)
  store i64 %34, ptr %12, align 8, !tbaa !16
  %35 = load i64, ptr %12, align 8, !tbaa !16
  %36 = icmp slt i64 %35, 0
  br i1 %36, label %37, label %53

37:                                               ; preds = %25
  br label %38

38:                                               ; preds = %37
  %39 = call zeroext i8 @DebugPrintEnabled()
  %40 = icmp ne i8 %39, 0
  br i1 %40, label %41, label %50

41:                                               ; preds = %38
  br label %42

42:                                               ; preds = %41
  %43 = call zeroext i8 @DebugPrintLevelEnabled(i64 noundef 2147483648)
  %44 = icmp ne i8 %43, 0
  br i1 %44, label %45, label %47

45:                                               ; preds = %42
  %46 = load i64, ptr %12, align 8, !tbaa !16
  call void (i64, ptr, ...) @DebugPrint(i64 noundef 2147483648, ptr noundef @.str.12, i64 noundef %46)
  br label %47

47:                                               ; preds = %45, %42
  br label %48

48:                                               ; preds = %47
  br label %49

49:                                               ; preds = %48
  br label %50

50:                                               ; preds = %49, %38
  br label %51

51:                                               ; preds = %50
  br label %52

52:                                               ; preds = %51
  br label %124

53:                                               ; preds = %25
  %54 = load ptr, ptr %10, align 8, !tbaa !5
  %55 = getelementptr inbounds %struct._USB_MASS_DEVICE, ptr %54, i32 0, i32 0
  store i32 1298297685, ptr %55, align 8, !tbaa !17
  %56 = load ptr, ptr %7, align 8, !tbaa !5
  %57 = load ptr, ptr %10, align 8, !tbaa !5
  %58 = getelementptr inbounds %struct._USB_MASS_DEVICE, ptr %57, i32 0, i32 1
  store ptr %56, ptr %58, align 8, !tbaa !25
  %59 = load ptr, ptr %11, align 8, !tbaa !5
  %60 = load ptr, ptr %10, align 8, !tbaa !5
  %61 = getelementptr inbounds %struct._USB_MASS_DEVICE, ptr %60, i32 0, i32 2
  store ptr %59, ptr %61, align 8, !tbaa !26
  %62 = load ptr, ptr %10, align 8, !tbaa !5
  %63 = getelementptr inbounds %struct._USB_MASS_DEVICE, ptr %62, i32 0, i32 5
  %64 = load ptr, ptr %10, align 8, !tbaa !5
  %65 = getelementptr inbounds %struct._USB_MASS_DEVICE, ptr %64, i32 0, i32 4
  %66 = getelementptr inbounds %struct._EFI_BLOCK_IO_PROTOCOL, ptr %65, i32 0, i32 1
  store ptr %63, ptr %66, align 8, !tbaa !27
  %67 = load ptr, ptr %10, align 8, !tbaa !5
  %68 = getelementptr inbounds %struct._USB_MASS_DEVICE, ptr %67, i32 0, i32 4
  %69 = getelementptr inbounds %struct._EFI_BLOCK_IO_PROTOCOL, ptr %68, i32 0, i32 2
  store ptr @UsbMassReset, ptr %69, align 8, !tbaa !28
  %70 = load ptr, ptr %10, align 8, !tbaa !5
  %71 = getelementptr inbounds %struct._USB_MASS_DEVICE, ptr %70, i32 0, i32 4
  %72 = getelementptr inbounds %struct._EFI_BLOCK_IO_PROTOCOL, ptr %71, i32 0, i32 3
  store ptr @UsbMassReadBlocks, ptr %72, align 8, !tbaa !29
  %73 = load ptr, ptr %10, align 8, !tbaa !5
  %74 = getelementptr inbounds %struct._USB_MASS_DEVICE, ptr %73, i32 0, i32 4
  %75 = getelementptr inbounds %struct._EFI_BLOCK_IO_PROTOCOL, ptr %74, i32 0, i32 4
  store ptr @UsbMassWriteBlocks, ptr %75, align 8, !tbaa !30
  %76 = load ptr, ptr %10, align 8, !tbaa !5
  %77 = getelementptr inbounds %struct._USB_MASS_DEVICE, ptr %76, i32 0, i32 4
  %78 = getelementptr inbounds %struct._EFI_BLOCK_IO_PROTOCOL, ptr %77, i32 0, i32 5
  store ptr @UsbMassFlushBlocks, ptr %78, align 8, !tbaa !31
  %79 = load ptr, ptr %10, align 8, !tbaa !5
  %80 = getelementptr inbounds %struct._USB_MASS_DEVICE, ptr %79, i32 0, i32 6
  store i8 0, ptr %80, align 8, !tbaa !32
  %81 = load ptr, ptr %8, align 8, !tbaa !5
  %82 = load ptr, ptr %10, align 8, !tbaa !5
  %83 = getelementptr inbounds %struct._USB_MASS_DEVICE, ptr %82, i32 0, i32 9
  store ptr %81, ptr %83, align 8, !tbaa !33
  %84 = load ptr, ptr %9, align 8, !tbaa !5
  %85 = load ptr, ptr %10, align 8, !tbaa !5
  %86 = getelementptr inbounds %struct._USB_MASS_DEVICE, ptr %85, i32 0, i32 10
  store ptr %84, ptr %86, align 8, !tbaa !34
  %87 = load ptr, ptr %10, align 8, !tbaa !5
  %88 = call i64 @UsbMassInitMedia(ptr noundef %87)
  store i64 %88, ptr %12, align 8, !tbaa !16
  %89 = load i64, ptr %12, align 8, !tbaa !16
  %90 = icmp slt i64 %89, 0
  br i1 %90, label %91, label %110

91:                                               ; preds = %53
  %92 = load i64, ptr %12, align 8, !tbaa !16
  %93 = icmp ne i64 %92, -9223372036854775796
  br i1 %93, label %94, label %110

94:                                               ; preds = %91
  br label %95

95:                                               ; preds = %94
  %96 = call zeroext i8 @DebugPrintEnabled()
  %97 = icmp ne i8 %96, 0
  br i1 %97, label %98, label %107

98:                                               ; preds = %95
  br label %99

99:                                               ; preds = %98
  %100 = call zeroext i8 @DebugPrintLevelEnabled(i64 noundef 2147483648)
  %101 = icmp ne i8 %100, 0
  br i1 %101, label %102, label %104

102:                                              ; preds = %99
  %103 = load i64, ptr %12, align 8, !tbaa !16
  call void (i64, ptr, ...) @DebugPrint(i64 noundef 2147483648, ptr noundef @.str.13, i64 noundef %103)
  br label %104

104:                                              ; preds = %102, %99
  br label %105

105:                                              ; preds = %104
  br label %106

106:                                              ; preds = %105
  br label %107

107:                                              ; preds = %106, %95
  br label %108

108:                                              ; preds = %107
  br label %109

109:                                              ; preds = %108
  br label %124

110:                                              ; preds = %91, %53
  %111 = load ptr, ptr %10, align 8, !tbaa !5
  call void @InitializeDiskInfo(ptr noundef %111)
  %112 = load ptr, ptr @gBS, align 8, !tbaa !5
  %113 = getelementptr inbounds %struct.EFI_BOOT_SERVICES, ptr %112, i32 0, i32 39
  %114 = load ptr, ptr %113, align 8, !tbaa !35
  %115 = load ptr, ptr %10, align 8, !tbaa !5
  %116 = getelementptr inbounds %struct._USB_MASS_DEVICE, ptr %115, i32 0, i32 4
  %117 = load ptr, ptr %10, align 8, !tbaa !5
  %118 = getelementptr inbounds %struct._USB_MASS_DEVICE, ptr %117, i32 0, i32 11
  %119 = call i64 (ptr, ...) %114(ptr noundef %7, ptr noundef @gEfiBlockIoProtocolGuid, ptr noundef %116, ptr noundef @gEfiDiskInfoProtocolGuid, ptr noundef %118, ptr noundef null)
  store i64 %119, ptr %12, align 8, !tbaa !16
  %120 = load i64, ptr %12, align 8, !tbaa !16
  %121 = icmp slt i64 %120, 0
  br i1 %121, label %122, label %123

122:                                              ; preds = %110
  br label %124

123:                                              ; preds = %110
  store i64 0, ptr %5, align 8
  store i32 1, ptr %13, align 4
  br label %144

124:                                              ; preds = %122, %109, %52
  %125 = load ptr, ptr %10, align 8, !tbaa !5
  %126 = icmp ne ptr %125, null
  br i1 %126, label %127, label %129

127:                                              ; preds = %124
  %128 = load ptr, ptr %10, align 8, !tbaa !5
  call void @FreePool(ptr noundef %128)
  br label %129

129:                                              ; preds = %127, %124
  %130 = load ptr, ptr %11, align 8, !tbaa !5
  %131 = icmp ne ptr %130, null
  br i1 %131, label %132, label %142

132:                                              ; preds = %129
  %133 = load ptr, ptr @gBS, align 8, !tbaa !5
  %134 = getelementptr inbounds %struct.EFI_BOOT_SERVICES, ptr %133, i32 0, i32 34
  %135 = load ptr, ptr %134, align 8, !tbaa !36
  %136 = load ptr, ptr %7, align 8, !tbaa !5
  %137 = load ptr, ptr %6, align 8, !tbaa !5
  %138 = getelementptr inbounds %struct._EFI_DRIVER_BINDING_PROTOCOL, ptr %137, i32 0, i32 5
  %139 = load ptr, ptr %138, align 8, !tbaa !14
  %140 = load ptr, ptr %7, align 8, !tbaa !5
  %141 = call i64 %135(ptr noundef %136, ptr noundef @gEfiUsbIoProtocolGuid, ptr noundef %139, ptr noundef %140)
  br label %142

142:                                              ; preds = %132, %129
  %143 = load i64, ptr %12, align 8, !tbaa !16
  store i64 %143, ptr %5, align 8
  store i32 1, ptr %13, align 4
  br label %144

144:                                              ; preds = %142, %123
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #3
  %145 = load i64, ptr %5, align 8
  ret i64 %145
}

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, !6, i64 280}
!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, !6, i64 40}
!15 = !{!"_EFI_DRIVER_BINDING_PROTOCOL", !6, i64 0, !6, i64 8, !6, i64 16, !13, i64 24, !6, i64 32, !6, i64 40}
!16 = !{!12, !12, i64 0}
!17 = !{!18, !13, i64 0}
!18 = !{!"_USB_MASS_DEVICE", !13, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !19, i64 32, !20, i64 80, !7, i64 128, !7, i64 129, !7, i64 130, !6, i64 136, !6, i64 144, !21, i64 152, !24, i64 200, !7, i64 236}
!19 = !{!"_EFI_BLOCK_IO_PROTOCOL", !12, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40}
!20 = !{!"", !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}
!21 = !{!"_EFI_DISK_INFO_PROTOCOL", !22, i64 0, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40}
!22 = !{!"", !13, i64 0, !23, i64 4, !23, i64 6, !7, i64 8}
!23 = !{!"short", !7, i64 0}
!24 = !{!"", !7, i64 0, !7, i64 1, !7, i64 2, !7, i64 4, !7, i64 5, !7, i64 8, !7, i64 16, !7, i64 32}
!25 = !{!18, !6, i64 8}
!26 = !{!18, !6, i64 16}
!27 = !{!18, !6, i64 40}
!28 = !{!18, !6, i64 48}
!29 = !{!18, !6, i64 56}
!30 = !{!18, !6, i64 64}
!31 = !{!18, !6, i64 72}
!32 = !{!18, !7, i64 128}
!33 = !{!18, !6, i64 136}
!34 = !{!18, !6, i64 144}
!35 = !{!10, !6, i64 328}
!36 = !{!10, !6, i64 288}


; 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] }

@gBS = external local_unnamed_addr global ptr, align 8
@.str = external hidden unnamed_addr constant [154 x i8], align 1
@gEfiUsbIoProtocolGuid = external global %struct.GUID, align 4
@.str.6 = external hidden unnamed_addr constant [24 x i8], align 1
@gEfiBlockIoProtocolGuid = external global %struct.GUID, align 4
@gEfiDiskInfoProtocolGuid = external global %struct.GUID, align 4
@.str.12 = external hidden unnamed_addr constant [53 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [42 x i8], align 1

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

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

declare zeroext i8 @DebugAssertEnabled() local_unnamed_addr #2

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

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

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

declare zeroext i8 @DebugPrintEnabled() local_unnamed_addr #2

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

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

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

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

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

declare ptr @AllocateZeroPool(i64 noundef) local_unnamed_addr #2

declare void @FreePool(ptr noundef) local_unnamed_addr #2

declare void @InitializeDiskInfo(ptr noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
define dso_local range(i64 -9223372036854775808, 1) i64 @UsbMassInitNonLun(ptr nocapture noundef readonly %0, ptr noundef %1, ptr noundef %2, ptr noundef %3) local_unnamed_addr #0 {
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  store ptr %1, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %6) #3
  store ptr null, ptr %6, align 8, !tbaa !5
  %7 = tail call ptr @AllocateZeroPool(i64 noundef 240) #3
  %8 = tail call zeroext i8 @DebugAssertEnabled() #3
  %9 = icmp eq i8 %8, 0
  %10 = icmp ne ptr %7, null
  %or.cond3 = select i1 %9, i1 true, i1 %10
  br i1 %or.cond3, label %12, label %11

11:                                               ; preds = %4
  tail call void @DebugAssert(ptr noundef nonnull @.str, i64 noundef 622, ptr noundef nonnull @.str.6) #3
  br label %12

12:                                               ; preds = %11, %4
  %13 = load ptr, ptr @gBS, align 8, !tbaa !5
  %14 = getelementptr inbounds i8, ptr %13, i64 280
  %15 = load ptr, ptr %14, align 8, !tbaa !9
  %16 = getelementptr inbounds i8, ptr %0, i64 40
  %17 = load ptr, ptr %16, align 8, !tbaa !14
  %18 = call i64 %15(ptr noundef %1, ptr noundef nonnull @gEfiUsbIoProtocolGuid, ptr noundef nonnull %6, ptr noundef %17, ptr noundef %1, i32 noundef 16) #3
  %19 = icmp slt i64 %18, 0
  br i1 %19, label %20, label %25

20:                                               ; preds = %12
  %21 = call zeroext i8 @DebugPrintEnabled() #3
  %.not39 = icmp eq i8 %21, 0
  br i1 %.not39, label %54, label %22

22:                                               ; preds = %20
  %23 = call zeroext i8 @DebugPrintLevelEnabled(i64 noundef 2147483648) #3
  %.not40 = icmp eq i8 %23, 0
  br i1 %.not40, label %54, label %24

24:                                               ; preds = %22
  call void (i64, ptr, ...) @DebugPrint(i64 noundef 2147483648, ptr noundef nonnull @.str.12, i64 noundef %18) #3
  br label %54

25:                                               ; preds = %12
  store i32 1298297685, ptr %7, align 8, !tbaa !16
  %26 = getelementptr inbounds i8, ptr %7, i64 8
  store ptr %1, ptr %26, align 8, !tbaa !24
  %27 = load ptr, ptr %6, align 8, !tbaa !5
  %28 = getelementptr inbounds i8, ptr %7, i64 16
  store ptr %27, ptr %28, align 8, !tbaa !25
  %29 = getelementptr inbounds i8, ptr %7, i64 80
  %30 = getelementptr inbounds i8, ptr %7, i64 40
  store ptr %29, ptr %30, align 8, !tbaa !26
  %31 = getelementptr inbounds i8, ptr %7, i64 48
  store ptr @UsbMassReset, ptr %31, align 8, !tbaa !27
  %32 = getelementptr inbounds i8, ptr %7, i64 56
  store ptr @UsbMassReadBlocks, ptr %32, align 8, !tbaa !28
  %33 = getelementptr inbounds i8, ptr %7, i64 64
  store ptr @UsbMassWriteBlocks, ptr %33, align 8, !tbaa !29
  %34 = getelementptr inbounds i8, ptr %7, i64 72
  store ptr @UsbMassFlushBlocks, ptr %34, align 8, !tbaa !30
  %35 = getelementptr inbounds i8, ptr %7, i64 128
  store i8 0, ptr %35, align 8, !tbaa !31
  %36 = getelementptr inbounds i8, ptr %7, i64 136
  store ptr %2, ptr %36, align 8, !tbaa !32
  %37 = getelementptr inbounds i8, ptr %7, i64 144
  store ptr %3, ptr %37, align 8, !tbaa !33
  %38 = call i64 @UsbMassInitMedia(ptr noundef nonnull %7)
  %39 = icmp slt i64 %38, 0
  %40 = icmp ne i64 %38, -9223372036854775796
  %or.cond = and i1 %39, %40
  br i1 %or.cond, label %41, label %46

41:                                               ; preds = %25
  %42 = call zeroext i8 @DebugPrintEnabled() #3
  %.not = icmp eq i8 %42, 0
  br i1 %.not, label %.thread, label %43

43:                                               ; preds = %41
  %44 = call zeroext i8 @DebugPrintLevelEnabled(i64 noundef 2147483648) #3
  %.not38 = icmp eq i8 %44, 0
  br i1 %.not38, label %.thread, label %45

45:                                               ; preds = %43
  call void (i64, ptr, ...) @DebugPrint(i64 noundef 2147483648, ptr noundef nonnull @.str.13, i64 noundef %38) #3
  br label %.thread

46:                                               ; preds = %25
  %47 = getelementptr inbounds i8, ptr %7, i64 32
  call void @InitializeDiskInfo(ptr noundef nonnull %7) #3
  %48 = load ptr, ptr @gBS, align 8, !tbaa !5
  %49 = getelementptr inbounds i8, ptr %48, i64 328
  %50 = load ptr, ptr %49, align 8, !tbaa !34
  %51 = getelementptr inbounds i8, ptr %7, i64 152
  %52 = call i64 (ptr, ...) %50(ptr noundef nonnull %5, ptr noundef nonnull @gEfiBlockIoProtocolGuid, ptr noundef nonnull %47, ptr noundef nonnull @gEfiDiskInfoProtocolGuid, ptr noundef nonnull %51, ptr noundef null) #3
  %53 = icmp slt i64 %52, 0
  br i1 %53, label %.thread, label %64

54:                                               ; preds = %20, %24, %22
  br i1 %10, label %.thread, label %55

.thread:                                          ; preds = %43, %45, %41, %46, %54
  %.044 = phi i64 [ %18, %54 ], [ %52, %46 ], [ %38, %41 ], [ %38, %43 ], [ %38, %45 ]
  call void @FreePool(ptr noundef nonnull %7) #3
  br label %55

55:                                               ; preds = %.thread, %54
  %.043 = phi i64 [ %.044, %.thread ], [ %18, %54 ]
  %56 = load ptr, ptr %6, align 8, !tbaa !5
  %.not41 = icmp eq ptr %56, null
  br i1 %.not41, label %64, label %57

57:                                               ; preds = %55
  %58 = load ptr, ptr @gBS, align 8, !tbaa !5
  %59 = getelementptr inbounds i8, ptr %58, i64 288
  %60 = load ptr, ptr %59, align 8, !tbaa !35
  %61 = load ptr, ptr %5, align 8, !tbaa !5
  %62 = load ptr, ptr %16, align 8, !tbaa !14
  %63 = call i64 %60(ptr noundef %61, ptr noundef nonnull @gEfiUsbIoProtocolGuid, ptr noundef %62, ptr noundef %61) #3
  br label %64

64:                                               ; preds = %55, %57, %46
  %.033 = phi i64 [ 0, %46 ], [ %.043, %57 ], [ %.043, %55 ]
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %6) #3
  ret i64 %.033
}

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

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

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !6, i64 280}
!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, !6, i64 40}
!15 = !{!"_EFI_DRIVER_BINDING_PROTOCOL", !6, i64 0, !6, i64 8, !6, i64 16, !13, i64 24, !6, i64 32, !6, i64 40}
!16 = !{!17, !13, i64 0}
!17 = !{!"_USB_MASS_DEVICE", !13, 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 = !{!"", !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}
!20 = !{!"_EFI_DISK_INFO_PROTOCOL", !21, i64 0, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40}
!21 = !{!"", !13, 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 = !{!17, !6, i64 8}
!25 = !{!17, !6, i64 16}
!26 = !{!17, !6, i64 40}
!27 = !{!17, !6, i64 48}
!28 = !{!17, !6, i64 56}
!29 = !{!17, !6, i64 64}
!30 = !{!17, !6, i64 72}
!31 = !{!17, !7, i64 128}
!32 = !{!17, !6, i64 136}
!33 = !{!17, !6, i64 144}
!34 = !{!10, !6, i64 328}
!35 = !{!10, !6, i64 288}


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