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

; 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._UFS_DEVICE_MANAGEMENT_REQUEST_PACKET = type { i64, ptr, ptr, i8, i8, i8, i8, i32, i32, i8, i8 }
%struct._UFS_PASS_THRU_PRIVATE_DATA = type { i32, ptr, %struct.EFI_EXT_SCSI_PASS_THRU_MODE, %struct._EFI_EXT_SCSI_PASS_THRU_PROTOCOL, ptr, i64, i32, i8, ptr, i8, ptr, ptr, i8, ptr, %struct.UFS_EXPOSED_LUNS }
%struct.EFI_EXT_SCSI_PASS_THRU_MODE = type { i32, i32, i32 }
%struct._EFI_EXT_SCSI_PASS_THRU_PROTOCOL = type { ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr }
%struct.UFS_EXPOSED_LUNS = type { [12 x i8], i16 }
%struct.UTP_TRD = type { i32, i32, i32, i32, i32, i32, i16, i16, i16, i16 }
%struct.UTP_QUERY_RESP_UPIU = type { i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i16, %struct.UTP_UPIU_TSF, [4 x i8] }
%struct.UTP_UPIU_TSF = type { i8, i8, i8, i8, i16, i16, i32, i32 }
%struct._EDKII_UFS_HOST_CONTROLLER_PROTOCOL = type { ptr, ptr, ptr, ptr, ptr, ptr }

@.str.10 = external hidden unnamed_addr constant [154 x i8], align 1
@.str.33 = external hidden unnamed_addr constant [26 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local i64 @UfsWaitMemSet(i64 noundef, i32 noundef, i32 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 zeroext i8 @DebugAssertEnabled() #2

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

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

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

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

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

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

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

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

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

31:                                               ; preds = %7
  %32 = getelementptr inbounds %struct._UFS_DEVICE_MANAGEMENT_REQUEST_PACKET, ptr %17, i32 0, i32 9
  store i8 2, ptr %32, align 4, !tbaa !12
  %33 = load ptr, ptr %14, align 8, !tbaa !5
  %34 = getelementptr inbounds %struct._UFS_DEVICE_MANAGEMENT_REQUEST_PACKET, ptr %17, i32 0, i32 1
  store ptr %33, ptr %34, align 8, !tbaa !15
  %35 = load i32, ptr %15, align 4, !tbaa !10
  %36 = getelementptr inbounds %struct._UFS_DEVICE_MANAGEMENT_REQUEST_PACKET, ptr %17, i32 0, i32 7
  store i32 %35, ptr %36, align 4, !tbaa !16
  %37 = getelementptr inbounds %struct._UFS_DEVICE_MANAGEMENT_REQUEST_PACKET, ptr %17, i32 0, i32 3
  store i8 1, ptr %37, align 8, !tbaa !17
  br label %45

38:                                               ; preds = %7
  %39 = getelementptr inbounds %struct._UFS_DEVICE_MANAGEMENT_REQUEST_PACKET, ptr %17, i32 0, i32 9
  store i8 1, ptr %39, align 4, !tbaa !12
  %40 = load ptr, ptr %14, align 8, !tbaa !5
  %41 = getelementptr inbounds %struct._UFS_DEVICE_MANAGEMENT_REQUEST_PACKET, ptr %17, i32 0, i32 2
  store ptr %40, ptr %41, align 8, !tbaa !18
  %42 = load i32, ptr %15, align 4, !tbaa !10
  %43 = getelementptr inbounds %struct._UFS_DEVICE_MANAGEMENT_REQUEST_PACKET, ptr %17, i32 0, i32 8
  store i32 %42, ptr %43, align 8, !tbaa !19
  %44 = getelementptr inbounds %struct._UFS_DEVICE_MANAGEMENT_REQUEST_PACKET, ptr %17, i32 0, i32 3
  store i8 2, ptr %44, align 8, !tbaa !17
  br label %45

45:                                               ; preds = %38, %31
  %46 = load i8, ptr %11, align 1, !tbaa !9
  %47 = getelementptr inbounds %struct._UFS_DEVICE_MANAGEMENT_REQUEST_PACKET, ptr %17, i32 0, i32 4
  store i8 %46, ptr %47, align 1, !tbaa !20
  %48 = load i8, ptr %12, align 1, !tbaa !9
  %49 = getelementptr inbounds %struct._UFS_DEVICE_MANAGEMENT_REQUEST_PACKET, ptr %17, i32 0, i32 5
  store i8 %48, ptr %49, align 2, !tbaa !21
  %50 = load i8, ptr %13, align 1, !tbaa !9
  %51 = getelementptr inbounds %struct._UFS_DEVICE_MANAGEMENT_REQUEST_PACKET, ptr %17, i32 0, i32 6
  store i8 %50, ptr %51, align 1, !tbaa !22
  %52 = call i64 @MultU64x32(i64 noundef 3, i32 noundef 10000000)
  %53 = getelementptr inbounds %struct._UFS_DEVICE_MANAGEMENT_REQUEST_PACKET, ptr %17, i32 0, i32 0
  store i64 %52, ptr %53, align 8, !tbaa !23
  %54 = load ptr, ptr %9, align 8, !tbaa !5
  %55 = call i64 @UfsFindAvailableSlotInTrl(ptr noundef %54, ptr noundef %18)
  store i64 %55, ptr %16, align 8, !tbaa !24
  %56 = load i64, ptr %16, align 8, !tbaa !24
  %57 = icmp slt i64 %56, 0
  br i1 %57, label %58, label %60

58:                                               ; preds = %45
  %59 = load i64, ptr %16, align 8, !tbaa !24
  store i64 %59, ptr %8, align 8
  store i32 1, ptr %27, align 4
  br label %201

60:                                               ; preds = %45
  %61 = load ptr, ptr %9, align 8, !tbaa !5
  %62 = getelementptr inbounds %struct._UFS_PASS_THRU_PRIVATE_DATA, ptr %61, i32 0, i32 8
  %63 = load ptr, ptr %62, align 8, !tbaa !25
  %64 = load i8, ptr %18, align 1, !tbaa !9
  %65 = zext i8 %64 to i32
  %66 = sext i32 %65 to i64
  %67 = getelementptr inbounds %struct.UTP_TRD, ptr %63, i64 %66
  store ptr %67, ptr %19, align 8, !tbaa !5
  %68 = load ptr, ptr %9, align 8, !tbaa !5
  %69 = load ptr, ptr %19, align 8, !tbaa !5
  %70 = call i64 @UfsCreateDMCommandDesc(ptr noundef %68, ptr noundef %17, ptr noundef %69, ptr noundef %24, ptr noundef %25)
  store i64 %70, ptr %16, align 8, !tbaa !24
  %71 = load i64, ptr %16, align 8, !tbaa !24
  %72 = icmp slt i64 %71, 0
  br i1 %72, label %73, label %75

73:                                               ; preds = %60
  %74 = load i64, ptr %16, align 8, !tbaa !24
  store i64 %74, ptr %8, align 8
  store i32 1, ptr %27, align 4
  br label %201

75:                                               ; preds = %60
  %76 = load ptr, ptr %9, align 8, !tbaa !5
  %77 = getelementptr inbounds %struct._UFS_PASS_THRU_PRIVATE_DATA, ptr %76, i32 0, i32 4
  %78 = load ptr, ptr %77, align 8, !tbaa !31
  store ptr %78, ptr %26, align 8, !tbaa !5
  %79 = load ptr, ptr %24, align 8, !tbaa !5
  %80 = load ptr, ptr %19, align 8, !tbaa !5
  %81 = getelementptr inbounds %struct.UTP_TRD, ptr %80, i32 0, i32 7
  %82 = load i16, ptr %81, align 1, !tbaa !32
  %83 = zext i16 %82 to i64
  %84 = mul i64 %83, 4
  %85 = getelementptr inbounds i8, ptr %79, i64 %84
  store ptr %85, ptr %21, align 8, !tbaa !5
  br label %86

86:                                               ; preds = %75
  %87 = call zeroext i8 @DebugAssertEnabled()
  %88 = icmp ne i8 %87, 0
  br i1 %88, label %89, label %94

89:                                               ; preds = %86
  %90 = load ptr, ptr %21, align 8, !tbaa !5
  %91 = icmp ne ptr %90, null
  br i1 %91, label %93, label %92

92:                                               ; preds = %89
  call void @DebugAssert(ptr noundef @.str.10, i64 noundef 844, ptr noundef @.str.33)
  br label %93

93:                                               ; preds = %92, %89
  br label %94

94:                                               ; preds = %93, %86
  br label %95

95:                                               ; preds = %94
  br label %96

96:                                               ; preds = %95
  %97 = load ptr, ptr %19, align 8, !tbaa !5
  %98 = getelementptr inbounds %struct.UTP_TRD, ptr %97, i32 0, i32 7
  %99 = load i16, ptr %98, align 1, !tbaa !32
  %100 = zext i16 %99 to i64
  %101 = mul i64 %100, 4
  %102 = load ptr, ptr %19, align 8, !tbaa !5
  %103 = getelementptr inbounds %struct.UTP_TRD, ptr %102, i32 0, i32 6
  %104 = load i16, ptr %103, align 1, !tbaa !34
  %105 = zext i16 %104 to i64
  %106 = mul i64 %105, 4
  %107 = add i64 %101, %106
  %108 = trunc i64 %107 to i32
  store i32 %108, ptr %22, align 4, !tbaa !10
  %109 = load ptr, ptr %9, align 8, !tbaa !5
  %110 = load i8, ptr %18, align 1, !tbaa !9
  call void @UfsStartExecCmd(ptr noundef %109, i8 noundef zeroext %110)
  %111 = load ptr, ptr %9, align 8, !tbaa !5
  %112 = getelementptr inbounds %struct._UFS_PASS_THRU_PRIVATE_DATA, ptr %111, i32 0, i32 5
  %113 = load i64, ptr %112, align 8, !tbaa !35
  %114 = add i64 %113, 88
  store i64 %114, ptr %20, align 8, !tbaa !24
  %115 = load i64, ptr %20, align 8, !tbaa !24
  %116 = getelementptr inbounds %struct._UFS_DEVICE_MANAGEMENT_REQUEST_PACKET, ptr %17, i32 0, i32 0
  %117 = load i64, ptr %116, align 8, !tbaa !23
  %118 = call i64 @UfsWaitMemSet(i64 noundef %115, i32 noundef 1, i32 noundef 0, i64 noundef %117)
  store i64 %118, ptr %16, align 8, !tbaa !24
  %119 = load i64, ptr %16, align 8, !tbaa !24
  %120 = icmp slt i64 %119, 0
  br i1 %120, label %121, label %122

121:                                              ; preds = %96
  br label %163

122:                                              ; preds = %96
  %123 = load ptr, ptr %21, align 8, !tbaa !5
  %124 = getelementptr inbounds %struct.UTP_QUERY_RESP_UPIU, ptr %123, i32 0, i32 6
  %125 = load i8, ptr %124, align 1, !tbaa !36
  %126 = zext i8 %125 to i32
  %127 = icmp ne i32 %126, 0
  br i1 %127, label %128, label %132

128:                                              ; preds = %122
  %129 = load ptr, ptr %21, align 8, !tbaa !5
  %130 = getelementptr inbounds %struct.UTP_QUERY_RESP_UPIU, ptr %129, i32 0, i32 6
  %131 = load i8, ptr %130, align 1, !tbaa !36
  call void @DumpQueryResponseResult(i8 noundef zeroext %131)
  store i64 -9223372036854775801, ptr %16, align 8, !tbaa !24
  br label %163

132:                                              ; preds = %122
  %133 = load ptr, ptr %19, align 8, !tbaa !5
  %134 = getelementptr inbounds %struct.UTP_TRD, ptr %133, i32 0, i32 2
  %135 = load i32, ptr %134, align 1
  %136 = and i32 %135, 255
  %137 = icmp eq i32 %136, 0
  br i1 %137, label %138, label %161

138:                                              ; preds = %132
  %139 = load ptr, ptr %21, align 8, !tbaa !5
  %140 = getelementptr inbounds %struct.UTP_QUERY_RESP_UPIU, ptr %139, i32 0, i32 11
  %141 = getelementptr inbounds %struct.UTP_UPIU_TSF, ptr %140, i32 0, i32 5
  %142 = load i16, ptr %141, align 1, !tbaa !39
  store i16 %142, ptr %23, align 2, !tbaa !40
  call void @SwapLittleEndianToBigEndian(ptr noundef %23, i32 noundef 2)
  %143 = load i8, ptr %10, align 1, !tbaa !9
  %144 = icmp ne i8 %143, 0
  br i1 %144, label %145, label %156

145:                                              ; preds = %138
  %146 = getelementptr inbounds %struct._UFS_DEVICE_MANAGEMENT_REQUEST_PACKET, ptr %17, i32 0, i32 1
  %147 = load ptr, ptr %146, align 8, !tbaa !15
  %148 = load ptr, ptr %21, align 8, !tbaa !5
  %149 = getelementptr inbounds %struct.UTP_QUERY_RESP_UPIU, ptr %148, i64 1
  %150 = load i16, ptr %23, align 2, !tbaa !40
  %151 = zext i16 %150 to i64
  %152 = call ptr @CopyMem(ptr noundef %147, ptr noundef %149, i64 noundef %151)
  %153 = load i16, ptr %23, align 2, !tbaa !40
  %154 = zext i16 %153 to i32
  %155 = getelementptr inbounds %struct._UFS_DEVICE_MANAGEMENT_REQUEST_PACKET, ptr %17, i32 0, i32 7
  store i32 %154, ptr %155, align 4, !tbaa !16
  br label %160

156:                                              ; preds = %138
  %157 = load i16, ptr %23, align 2, !tbaa !40
  %158 = zext i16 %157 to i32
  %159 = getelementptr inbounds %struct._UFS_DEVICE_MANAGEMENT_REQUEST_PACKET, ptr %17, i32 0, i32 8
  store i32 %158, ptr %159, align 8, !tbaa !19
  br label %160

160:                                              ; preds = %156, %145
  br label %162

161:                                              ; preds = %132
  store i64 -9223372036854775801, ptr %16, align 8, !tbaa !24
  br label %162

162:                                              ; preds = %161, %160
  br label %163

163:                                              ; preds = %162, %128, %121
  %164 = load ptr, ptr %26, align 8, !tbaa !5
  %165 = getelementptr inbounds %struct._EDKII_UFS_HOST_CONTROLLER_PROTOCOL, ptr %164, i32 0, i32 5
  %166 = load ptr, ptr %165, align 8, !tbaa !41
  %167 = load ptr, ptr %26, align 8, !tbaa !5
  %168 = call i64 %166(ptr noundef %167)
  %169 = load ptr, ptr %9, align 8, !tbaa !5
  %170 = load i8, ptr %18, align 1, !tbaa !9
  call void @UfsStopExecCmd(ptr noundef %169, i8 noundef zeroext %170)
  %171 = load ptr, ptr %25, align 8, !tbaa !5
  %172 = icmp ne ptr %171, null
  br i1 %172, label %173, label %180

173:                                              ; preds = %163
  %174 = load ptr, ptr %26, align 8, !tbaa !5
  %175 = getelementptr inbounds %struct._EDKII_UFS_HOST_CONTROLLER_PROTOCOL, ptr %174, i32 0, i32 4
  %176 = load ptr, ptr %175, align 8, !tbaa !43
  %177 = load ptr, ptr %26, align 8, !tbaa !5
  %178 = load ptr, ptr %25, align 8, !tbaa !5
  %179 = call i64 %176(ptr noundef %177, ptr noundef %178)
  br label %180

180:                                              ; preds = %173, %163
  %181 = load ptr, ptr %24, align 8, !tbaa !5
  %182 = icmp ne ptr %181, null
  br i1 %182, label %183, label %199

183:                                              ; preds = %180
  %184 = load ptr, ptr %26, align 8, !tbaa !5
  %185 = getelementptr inbounds %struct._EDKII_UFS_HOST_CONTROLLER_PROTOCOL, ptr %184, i32 0, i32 2
  %186 = load ptr, ptr %185, align 8, !tbaa !44
  %187 = load ptr, ptr %26, align 8, !tbaa !5
  %188 = load i32, ptr %22, align 4, !tbaa !10
  %189 = lshr i32 %188, 12
  %190 = load i32, ptr %22, align 4, !tbaa !10
  %191 = and i32 %190, 4095
  %192 = icmp ne i32 %191, 0
  %193 = zext i1 %192 to i64
  %194 = select i1 %192, i32 1, i32 0
  %195 = add i32 %189, %194
  %196 = zext i32 %195 to i64
  %197 = load ptr, ptr %24, align 8, !tbaa !5
  %198 = call i64 %186(ptr noundef %187, i64 noundef %196, ptr noundef %197)
  br label %199

199:                                              ; preds = %183, %180
  %200 = load i64, ptr %16, align 8, !tbaa !24
  store i64 %200, ptr %8, align 8
  store i32 1, ptr %27, align 4
  br label %201

201:                                              ; preds = %199, %73, %58
  call void @llvm.lifetime.end.p0(i64 8, ptr %26) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %25) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %24) #3
  call void @llvm.lifetime.end.p0(i64 2, ptr %23) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %22) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %21) #3
  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 1, ptr %18) #3
  call void @llvm.lifetime.end.p0(i64 40, ptr %17) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #3
  %202 = load i64, ptr %8, align 8
  ret i64 %202
}

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

declare i64 @MultU64x32(i64 noundef, i32 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 = !{!7, !7, i64 0}
!10 = !{!11, !11, i64 0}
!11 = !{!"int", !7, i64 0}
!12 = !{!13, !7, i64 36}
!13 = !{!"_UFS_DEVICE_MANAGEMENT_REQUEST_PACKET", !14, i64 0, !6, i64 8, !6, i64 16, !7, i64 24, !7, i64 25, !7, i64 26, !7, i64 27, !11, i64 28, !11, i64 32, !7, i64 36, !7, i64 37}
!14 = !{!"long long", !7, i64 0}
!15 = !{!13, !6, i64 8}
!16 = !{!13, !11, i64 28}
!17 = !{!13, !7, i64 24}
!18 = !{!13, !6, i64 16}
!19 = !{!13, !11, i64 32}
!20 = !{!13, !7, i64 25}
!21 = !{!13, !7, i64 26}
!22 = !{!13, !7, i64 27}
!23 = !{!13, !14, i64 0}
!24 = !{!14, !14, i64 0}
!25 = !{!26, !6, i64 120}
!26 = !{!"_UFS_PASS_THRU_PRIVATE_DATA", !11, i64 0, !6, i64 8, !27, i64 16, !28, i64 32, !6, i64 96, !14, i64 104, !11, i64 112, !7, i64 116, !6, i64 120, !7, i64 128, !6, i64 136, !6, i64 144, !7, i64 152, !6, i64 160, !29, i64 168}
!27 = !{!"", !11, i64 0, !11, i64 4, !11, i64 8}
!28 = !{!"_EFI_EXT_SCSI_PASS_THRU_PROTOCOL", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !6, i64 56}
!29 = !{!"", !7, i64 0, !30, i64 12, !30, i64 13}
!30 = !{!"short", !7, i64 0}
!31 = !{!26, !6, i64 96}
!32 = !{!33, !30, i64 26}
!33 = !{!"", !11, i64 0, !11, i64 3, !11, i64 3, !11, i64 3, !11, i64 3, !11, i64 4, !11, i64 8, !11, i64 9, !11, i64 12, !11, i64 16, !11, i64 16, !11, i64 20, !30, i64 24, !30, i64 26, !30, i64 28, !30, i64 30}
!34 = !{!33, !30, i64 24}
!35 = !{!26, !14, i64 104}
!36 = !{!37, !7, i64 6}
!37 = !{!"", !7, i64 0, !7, i64 0, !7, i64 0, !7, i64 1, !7, i64 2, !7, i64 3, !7, i64 4, !7, i64 5, !7, i64 6, !7, i64 7, !7, i64 8, !7, i64 9, !30, i64 10, !38, i64 12, !7, i64 28}
!38 = !{!"", !7, i64 0, !7, i64 1, !7, i64 2, !7, i64 3, !30, i64 4, !30, i64 6, !11, i64 8, !11, i64 12}
!39 = !{!37, !30, i64 18}
!40 = !{!30, !30, i64 0}
!41 = !{!42, !6, i64 40}
!42 = !{!"_EDKII_UFS_HOST_CONTROLLER_PROTOCOL", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40}
!43 = !{!42, !6, i64 32}
!44 = !{!42, !6, i64 16}


; 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._UFS_DEVICE_MANAGEMENT_REQUEST_PACKET = type { i64, ptr, ptr, i8, i8, i8, i8, i32, i32, i8, i8 }
%struct.UTP_TRD = type { i32, i32, i32, i32, i32, i32, i16, i16, i16, i16 }

@.str.10 = external hidden unnamed_addr constant [154 x i8], align 1
@.str.33 = external hidden unnamed_addr constant [26 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local i64 @UfsWaitMemSet(i64 noundef, i32 noundef, i32 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 zeroext i8 @DebugAssertEnabled() local_unnamed_addr #2

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

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

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

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

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

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

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

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

; Function Attrs: nounwind uwtable
define dso_local i64 @UfsRwDeviceDesc(ptr noundef %0, i8 noundef zeroext %1, i8 noundef zeroext %2, i8 noundef zeroext %3, i8 noundef zeroext %4, ptr noundef %5, i32 noundef %6) local_unnamed_addr #0 {
  %8 = alloca %struct._UFS_DEVICE_MANAGEMENT_REQUEST_PACKET, align 8
  %9 = alloca i8, align 1
  %10 = alloca i16, align 2
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  call void @llvm.lifetime.start.p0(i64 40, ptr nonnull %8) #3
  call void @llvm.lifetime.start.p0(i64 1, ptr nonnull %9) #3
  call void @llvm.lifetime.start.p0(i64 2, ptr nonnull %10) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %11) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %12) #3
  %13 = call ptr @ZeroMem(ptr noundef nonnull %8, i64 noundef 40) #3
  %.not = icmp eq i8 %1, 0
  br i1 %.not, label %17, label %14

14:                                               ; preds = %7
  %15 = getelementptr inbounds i8, ptr %8, i64 8
  store ptr %5, ptr %15, align 8, !tbaa !5
  %16 = getelementptr inbounds i8, ptr %8, i64 28
  store i32 %6, ptr %16, align 4, !tbaa !12
  br label %20

17:                                               ; preds = %7
  %18 = getelementptr inbounds i8, ptr %8, i64 16
  store ptr %5, ptr %18, align 8, !tbaa !13
  %19 = getelementptr inbounds i8, ptr %8, i64 32
  store i32 %6, ptr %19, align 8, !tbaa !14
  br label %20

20:                                               ; preds = %17, %14
  %.sink52 = phi i8 [ 1, %17 ], [ 2, %14 ]
  %.sink = phi i8 [ 2, %17 ], [ 1, %14 ]
  %21 = getelementptr inbounds i8, ptr %8, i64 36
  store i8 %.sink52, ptr %21, align 4
  %22 = getelementptr inbounds i8, ptr %8, i64 24
  store i8 %.sink, ptr %22, align 8
  %23 = getelementptr inbounds i8, ptr %8, i64 25
  store i8 %2, ptr %23, align 1, !tbaa !15
  %24 = getelementptr inbounds i8, ptr %8, i64 26
  store i8 %3, ptr %24, align 2, !tbaa !16
  %25 = getelementptr inbounds i8, ptr %8, i64 27
  store i8 %4, ptr %25, align 1, !tbaa !17
  %26 = call i64 @MultU64x32(i64 noundef 3, i32 noundef 10000000) #3
  store i64 %26, ptr %8, align 8, !tbaa !18
  %27 = call i64 @UfsFindAvailableSlotInTrl(ptr noundef %0, ptr noundef nonnull %9)
  %28 = icmp slt i64 %27, 0
  br i1 %28, label %111, label %29

29:                                               ; preds = %20
  %30 = getelementptr inbounds i8, ptr %0, i64 120
  %31 = load ptr, ptr %30, align 8, !tbaa !19
  %32 = load i8, ptr %9, align 1, !tbaa !25
  %33 = zext i8 %32 to i64
  %34 = getelementptr inbounds %struct.UTP_TRD, ptr %31, i64 %33
  %35 = call i64 @UfsCreateDMCommandDesc(ptr noundef %0, ptr noundef nonnull %8, ptr noundef %34, ptr noundef nonnull %11, ptr noundef nonnull %12)
  %36 = icmp slt i64 %35, 0
  br i1 %36, label %111, label %37

37:                                               ; preds = %29
  %38 = getelementptr inbounds i8, ptr %0, i64 96
  %39 = load ptr, ptr %38, align 8, !tbaa !26
  %40 = load ptr, ptr %11, align 8, !tbaa !27
  %41 = getelementptr inbounds i8, ptr %34, i64 26
  %42 = load i16, ptr %41, align 1, !tbaa !28
  %43 = zext i16 %42 to i64
  %44 = shl nuw nsw i64 %43, 2
  %45 = getelementptr inbounds i8, ptr %40, i64 %44
  %46 = call zeroext i8 @DebugAssertEnabled() #3
  %47 = icmp eq i8 %46, 0
  %48 = icmp ne ptr %40, null
  %or.cond = select i1 %47, i1 true, i1 %48
  br i1 %or.cond, label %50, label %49

49:                                               ; preds = %37
  call void @DebugAssert(ptr noundef nonnull @.str.10, i64 noundef 844, ptr noundef nonnull @.str.33) #3
  br label %50

50:                                               ; preds = %49, %37
  %51 = load i16, ptr %41, align 1, !tbaa !28
  %52 = zext i16 %51 to i32
  %53 = getelementptr inbounds i8, ptr %34, i64 24
  %54 = load i16, ptr %53, align 1, !tbaa !30
  %55 = zext i16 %54 to i32
  %56 = add nuw nsw i32 %55, %52
  %57 = load i8, ptr %9, align 1, !tbaa !25
  call void @UfsStartExecCmd(ptr noundef nonnull %0, i8 noundef zeroext %57)
  %58 = getelementptr inbounds i8, ptr %0, i64 104
  %59 = load i64, ptr %58, align 8, !tbaa !31
  %60 = add i64 %59, 88
  %61 = load i64, ptr %8, align 8, !tbaa !18
  %62 = call i64 @UfsWaitMemSet(i64 noundef %60, i32 noundef 1, i32 noundef 0, i64 noundef %61)
  %63 = icmp slt i64 %62, 0
  br i1 %63, label %90, label %64

64:                                               ; preds = %50
  %65 = getelementptr inbounds i8, ptr %45, i64 6
  %66 = load i8, ptr %65, align 1, !tbaa !32
  %.not48 = icmp eq i8 %66, 0
  br i1 %.not48, label %68, label %67

67:                                               ; preds = %64
  call void @DumpQueryResponseResult(i8 noundef zeroext %66)
  br label %90

68:                                               ; preds = %64
  %69 = getelementptr inbounds i8, ptr %34, i64 8
  %70 = load i32, ptr %69, align 1
  %71 = and i32 %70, 255
  %72 = icmp eq i32 %71, 0
  br i1 %72, label %73, label %90

73:                                               ; preds = %68
  %74 = getelementptr inbounds i8, ptr %45, i64 18
  %75 = load i16, ptr %74, align 1, !tbaa !35
  store i16 %75, ptr %10, align 2, !tbaa !36
  call void @SwapLittleEndianToBigEndian(ptr noundef nonnull %10, i32 noundef 2)
  br i1 %.not, label %86, label %76

76:                                               ; preds = %73
  %77 = getelementptr inbounds i8, ptr %8, i64 8
  %78 = load ptr, ptr %77, align 8, !tbaa !5
  %79 = getelementptr inbounds i8, ptr %45, i64 32
  %80 = load i16, ptr %10, align 2, !tbaa !36
  %81 = zext i16 %80 to i64
  %82 = call ptr @CopyMem(ptr noundef %78, ptr noundef nonnull %79, i64 noundef %81) #3
  %83 = load i16, ptr %10, align 2, !tbaa !36
  %84 = zext i16 %83 to i32
  %85 = getelementptr inbounds i8, ptr %8, i64 28
  store i32 %84, ptr %85, align 4, !tbaa !12
  br label %90

86:                                               ; preds = %73
  %87 = load i16, ptr %10, align 2, !tbaa !36
  %88 = zext i16 %87 to i32
  %89 = getelementptr inbounds i8, ptr %8, i64 32
  store i32 %88, ptr %89, align 8, !tbaa !14
  br label %90

90:                                               ; preds = %68, %86, %76, %50, %67
  %.042 = phi i64 [ %62, %50 ], [ -9223372036854775801, %67 ], [ %62, %76 ], [ %62, %86 ], [ -9223372036854775801, %68 ]
  %91 = getelementptr inbounds i8, ptr %39, i64 40
  %92 = load ptr, ptr %91, align 8, !tbaa !37
  %93 = call i64 %92(ptr noundef %39) #3
  %94 = load i8, ptr %9, align 1, !tbaa !25
  call void @UfsStopExecCmd(ptr noundef nonnull %0, i8 noundef zeroext %94)
  %95 = load ptr, ptr %12, align 8, !tbaa !27
  %.not49 = icmp eq ptr %95, null
  br i1 %.not49, label %100, label %96

96:                                               ; preds = %90
  %97 = getelementptr inbounds i8, ptr %39, i64 32
  %98 = load ptr, ptr %97, align 8, !tbaa !39
  %99 = call i64 %98(ptr noundef nonnull %39, ptr noundef nonnull %95) #3
  br label %100

100:                                              ; preds = %96, %90
  %101 = load ptr, ptr %11, align 8, !tbaa !27
  %.not50 = icmp eq ptr %101, null
  br i1 %.not50, label %111, label %102

102:                                              ; preds = %100
  %103 = getelementptr inbounds i8, ptr %39, i64 16
  %104 = load ptr, ptr %103, align 8, !tbaa !40
  %105 = lshr i32 %56, 10
  %106 = and i32 %56, 1023
  %.not51 = icmp ne i32 %106, 0
  %107 = zext i1 %.not51 to i32
  %108 = add nuw nsw i32 %105, %107
  %109 = zext nneg i32 %108 to i64
  %110 = call i64 %104(ptr noundef nonnull %39, i64 noundef %109, ptr noundef nonnull %101) #3
  br label %111

111:                                              ; preds = %100, %102, %29, %20
  %.0 = phi i64 [ %27, %20 ], [ %35, %29 ], [ %.042, %102 ], [ %.042, %100 ]
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %12) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %11) #3
  call void @llvm.lifetime.end.p0(i64 2, ptr nonnull %10) #3
  call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %9) #3
  call void @llvm.lifetime.end.p0(i64 40, ptr nonnull %8) #3
  ret i64 %.0
}

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

declare i64 @MultU64x32(i64 noundef, i32 noundef) local_unnamed_addr #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 = { 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, !10, i64 8}
!6 = !{!"_UFS_DEVICE_MANAGEMENT_REQUEST_PACKET", !7, i64 0, !10, i64 8, !10, i64 16, !8, i64 24, !8, i64 25, !8, i64 26, !8, i64 27, !11, i64 28, !11, i64 32, !8, i64 36, !8, i64 37}
!7 = !{!"long long", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!"int", !8, i64 0}
!12 = !{!6, !11, i64 28}
!13 = !{!6, !10, i64 16}
!14 = !{!6, !11, i64 32}
!15 = !{!6, !8, i64 25}
!16 = !{!6, !8, i64 26}
!17 = !{!6, !8, i64 27}
!18 = !{!6, !7, i64 0}
!19 = !{!20, !10, i64 120}
!20 = !{!"_UFS_PASS_THRU_PRIVATE_DATA", !11, i64 0, !10, i64 8, !21, i64 16, !22, i64 32, !10, i64 96, !7, i64 104, !11, i64 112, !8, i64 116, !10, i64 120, !8, i64 128, !10, i64 136, !10, i64 144, !8, i64 152, !10, i64 160, !23, i64 168}
!21 = !{!"", !11, i64 0, !11, i64 4, !11, i64 8}
!22 = !{!"_EFI_EXT_SCSI_PASS_THRU_PROTOCOL", !10, i64 0, !10, i64 8, !10, i64 16, !10, i64 24, !10, i64 32, !10, i64 40, !10, i64 48, !10, i64 56}
!23 = !{!"", !8, i64 0, !24, i64 12, !24, i64 13}
!24 = !{!"short", !8, i64 0}
!25 = !{!8, !8, i64 0}
!26 = !{!20, !10, i64 96}
!27 = !{!10, !10, i64 0}
!28 = !{!29, !24, i64 26}
!29 = !{!"", !11, i64 0, !11, i64 3, !11, i64 3, !11, i64 3, !11, i64 3, !11, i64 4, !11, i64 8, !11, i64 9, !11, i64 12, !11, i64 16, !11, i64 16, !11, i64 20, !24, i64 24, !24, i64 26, !24, i64 28, !24, i64 30}
!30 = !{!29, !24, i64 24}
!31 = !{!20, !7, i64 104}
!32 = !{!33, !8, i64 6}
!33 = !{!"", !8, i64 0, !8, i64 0, !8, i64 0, !8, i64 1, !8, i64 2, !8, i64 3, !8, i64 4, !8, i64 5, !8, i64 6, !8, i64 7, !8, i64 8, !8, i64 9, !24, i64 10, !34, i64 12, !8, i64 28}
!34 = !{!"", !8, i64 0, !8, i64 1, !8, i64 2, !8, i64 3, !24, i64 4, !24, i64 6, !11, i64 8, !11, i64 12}
!35 = !{!33, !24, i64 18}
!36 = !{!24, !24, i64 0}
!37 = !{!38, !10, i64 40}
!38 = !{!"_EDKII_UFS_HOST_CONTROLLER_PROTOCOL", !10, i64 0, !10, i64 8, !10, i64 16, !10, i64 24, !10, i64 32, !10, i64 40}
!39 = !{!38, !10, i64 32}
!40 = !{!38, !10, i64 16}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,MergedLoadStoreMotionPass,ReassociatePass,SROAPass,SimplifyCFGPass