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

; 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

; 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

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

declare i64 @MultU64x32(i64 noundef, i32 noundef) #2

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

29:                                               ; preds = %6
  %30 = getelementptr inbounds %struct._UFS_DEVICE_MANAGEMENT_REQUEST_PACKET, ptr %15, i32 0, i32 9
  store i8 2, ptr %30, align 4, !tbaa !10
  %31 = getelementptr inbounds %struct._UFS_DEVICE_MANAGEMENT_REQUEST_PACKET, ptr %15, i32 0, i32 3
  store i8 3, ptr %31, align 8, !tbaa !14
  br label %35

32:                                               ; preds = %6
  %33 = getelementptr inbounds %struct._UFS_DEVICE_MANAGEMENT_REQUEST_PACKET, ptr %15, i32 0, i32 9
  store i8 1, ptr %33, align 4, !tbaa !10
  %34 = getelementptr inbounds %struct._UFS_DEVICE_MANAGEMENT_REQUEST_PACKET, ptr %15, i32 0, i32 3
  store i8 4, ptr %34, align 8, !tbaa !14
  br label %35

35:                                               ; preds = %32, %29
  %36 = load i8, ptr %10, align 1, !tbaa !9
  %37 = getelementptr inbounds %struct._UFS_DEVICE_MANAGEMENT_REQUEST_PACKET, ptr %15, i32 0, i32 4
  store i8 %36, ptr %37, align 1, !tbaa !15
  %38 = load i8, ptr %11, align 1, !tbaa !9
  %39 = getelementptr inbounds %struct._UFS_DEVICE_MANAGEMENT_REQUEST_PACKET, ptr %15, i32 0, i32 5
  store i8 %38, ptr %39, align 2, !tbaa !16
  %40 = load i8, ptr %12, align 1, !tbaa !9
  %41 = getelementptr inbounds %struct._UFS_DEVICE_MANAGEMENT_REQUEST_PACKET, ptr %15, i32 0, i32 6
  store i8 %40, ptr %41, align 1, !tbaa !17
  %42 = call i64 @MultU64x32(i64 noundef 3, i32 noundef 10000000)
  %43 = getelementptr inbounds %struct._UFS_DEVICE_MANAGEMENT_REQUEST_PACKET, ptr %15, i32 0, i32 0
  store i64 %42, ptr %43, align 8, !tbaa !18
  %44 = load ptr, ptr %8, align 8, !tbaa !5
  %45 = call i64 @UfsFindAvailableSlotInTrl(ptr noundef %44, ptr noundef %16)
  store i64 %45, ptr %14, align 8, !tbaa !19
  %46 = load i64, ptr %14, align 8, !tbaa !19
  %47 = icmp slt i64 %46, 0
  br i1 %47, label %48, label %50

48:                                               ; preds = %35
  %49 = load i64, ptr %14, align 8, !tbaa !19
  store i64 %49, ptr %7, align 8
  store i32 1, ptr %25, align 4
  br label %175

50:                                               ; preds = %35
  %51 = load ptr, ptr %8, align 8, !tbaa !5
  %52 = getelementptr inbounds %struct._UFS_PASS_THRU_PRIVATE_DATA, ptr %51, i32 0, i32 8
  %53 = load ptr, ptr %52, align 8, !tbaa !20
  %54 = load i8, ptr %16, align 1, !tbaa !9
  %55 = zext i8 %54 to i32
  %56 = sext i32 %55 to i64
  %57 = getelementptr inbounds %struct.UTP_TRD, ptr %53, i64 %56
  store ptr %57, ptr %17, align 8, !tbaa !5
  %58 = load ptr, ptr %8, align 8, !tbaa !5
  %59 = load ptr, ptr %17, align 8, !tbaa !5
  %60 = call i64 @UfsCreateDMCommandDesc(ptr noundef %58, ptr noundef %15, ptr noundef %59, ptr noundef %22, ptr noundef %23)
  store i64 %60, ptr %14, align 8, !tbaa !19
  %61 = load i64, ptr %14, align 8, !tbaa !19
  %62 = icmp slt i64 %61, 0
  br i1 %62, label %63, label %65

63:                                               ; preds = %50
  %64 = load i64, ptr %14, align 8, !tbaa !19
  store i64 %64, ptr %7, align 8
  store i32 1, ptr %25, align 4
  br label %175

65:                                               ; preds = %50
  %66 = load ptr, ptr %8, align 8, !tbaa !5
  %67 = getelementptr inbounds %struct._UFS_PASS_THRU_PRIVATE_DATA, ptr %66, i32 0, i32 4
  %68 = load ptr, ptr %67, align 8, !tbaa !26
  store ptr %68, ptr %24, align 8, !tbaa !5
  %69 = load ptr, ptr %22, align 8, !tbaa !5
  %70 = load ptr, ptr %17, align 8, !tbaa !5
  %71 = getelementptr inbounds %struct.UTP_TRD, ptr %70, i32 0, i32 7
  %72 = load i16, ptr %71, align 1, !tbaa !27
  %73 = zext i16 %72 to i64
  %74 = mul i64 %73, 4
  %75 = getelementptr inbounds i8, ptr %69, i64 %74
  store ptr %75, ptr %19, align 8, !tbaa !5
  br label %76

76:                                               ; preds = %65
  %77 = call zeroext i8 @DebugAssertEnabled()
  %78 = icmp ne i8 %77, 0
  br i1 %78, label %79, label %84

79:                                               ; preds = %76
  %80 = load ptr, ptr %19, align 8, !tbaa !5
  %81 = icmp ne ptr %80, null
  br i1 %81, label %83, label %82

82:                                               ; preds = %79
  call void @DebugAssert(ptr noundef @.str.10, i64 noundef 969, ptr noundef @.str.33)
  br label %83

83:                                               ; preds = %82, %79
  br label %84

84:                                               ; preds = %83, %76
  br label %85

85:                                               ; preds = %84
  br label %86

86:                                               ; preds = %85
  %87 = load ptr, ptr %17, align 8, !tbaa !5
  %88 = getelementptr inbounds %struct.UTP_TRD, ptr %87, i32 0, i32 7
  %89 = load i16, ptr %88, align 1, !tbaa !27
  %90 = zext i16 %89 to i64
  %91 = mul i64 %90, 4
  %92 = load ptr, ptr %17, align 8, !tbaa !5
  %93 = getelementptr inbounds %struct.UTP_TRD, ptr %92, i32 0, i32 6
  %94 = load i16, ptr %93, align 1, !tbaa !29
  %95 = zext i16 %94 to i64
  %96 = mul i64 %95, 4
  %97 = add i64 %91, %96
  %98 = trunc i64 %97 to i32
  store i32 %98, ptr %20, align 4, !tbaa !30
  %99 = load ptr, ptr %8, align 8, !tbaa !5
  %100 = load i8, ptr %16, align 1, !tbaa !9
  call void @UfsStartExecCmd(ptr noundef %99, i8 noundef zeroext %100)
  %101 = load ptr, ptr %8, align 8, !tbaa !5
  %102 = getelementptr inbounds %struct._UFS_PASS_THRU_PRIVATE_DATA, ptr %101, i32 0, i32 5
  %103 = load i64, ptr %102, align 8, !tbaa !31
  %104 = add i64 %103, 88
  store i64 %104, ptr %18, align 8, !tbaa !19
  %105 = load i64, ptr %18, align 8, !tbaa !19
  %106 = getelementptr inbounds %struct._UFS_DEVICE_MANAGEMENT_REQUEST_PACKET, ptr %15, i32 0, i32 0
  %107 = load i64, ptr %106, align 8, !tbaa !18
  %108 = call i64 @UfsWaitMemSet(i64 noundef %105, i32 noundef 1, i32 noundef 0, i64 noundef %107)
  store i64 %108, ptr %14, align 8, !tbaa !19
  %109 = load i64, ptr %14, align 8, !tbaa !19
  %110 = icmp slt i64 %109, 0
  br i1 %110, label %111, label %112

111:                                              ; preds = %86
  br label %137

112:                                              ; preds = %86
  %113 = load ptr, ptr %19, align 8, !tbaa !5
  %114 = getelementptr inbounds %struct.UTP_QUERY_RESP_UPIU, ptr %113, i32 0, i32 6
  %115 = load i8, ptr %114, align 1, !tbaa !32
  %116 = zext i8 %115 to i32
  %117 = icmp ne i32 %116, 0
  br i1 %117, label %118, label %122

118:                                              ; preds = %112
  %119 = load ptr, ptr %19, align 8, !tbaa !5
  %120 = getelementptr inbounds %struct.UTP_QUERY_RESP_UPIU, ptr %119, i32 0, i32 6
  %121 = load i8, ptr %120, align 1, !tbaa !32
  call void @DumpQueryResponseResult(i8 noundef zeroext %121)
  store i64 -9223372036854775801, ptr %14, align 8, !tbaa !19
  br label %137

122:                                              ; preds = %112
  %123 = load ptr, ptr %17, align 8, !tbaa !5
  %124 = getelementptr inbounds %struct.UTP_TRD, ptr %123, i32 0, i32 2
  %125 = load i32, ptr %124, align 1
  %126 = and i32 %125, 255
  %127 = icmp eq i32 %126, 0
  br i1 %127, label %128, label %135

128:                                              ; preds = %122
  %129 = load ptr, ptr %19, align 8, !tbaa !5
  %130 = getelementptr inbounds %struct.UTP_QUERY_RESP_UPIU, ptr %129, i32 0, i32 11
  %131 = getelementptr inbounds %struct.UTP_UPIU_TSF, ptr %130, i32 0, i32 6
  %132 = load i32, ptr %131, align 1, !tbaa !35
  store i32 %132, ptr %21, align 4, !tbaa !30
  call void @SwapLittleEndianToBigEndian(ptr noundef %21, i32 noundef 4)
  %133 = load i32, ptr %21, align 4, !tbaa !30
  %134 = load ptr, ptr %13, align 8, !tbaa !5
  store i32 %133, ptr %134, align 4, !tbaa !30
  br label %136

135:                                              ; preds = %122
  store i64 -9223372036854775801, ptr %14, align 8, !tbaa !19
  br label %136

136:                                              ; preds = %135, %128
  br label %137

137:                                              ; preds = %136, %118, %111
  %138 = load ptr, ptr %24, align 8, !tbaa !5
  %139 = getelementptr inbounds %struct._EDKII_UFS_HOST_CONTROLLER_PROTOCOL, ptr %138, i32 0, i32 5
  %140 = load ptr, ptr %139, align 8, !tbaa !36
  %141 = load ptr, ptr %24, align 8, !tbaa !5
  %142 = call i64 %140(ptr noundef %141)
  %143 = load ptr, ptr %8, align 8, !tbaa !5
  %144 = load i8, ptr %16, align 1, !tbaa !9
  call void @UfsStopExecCmd(ptr noundef %143, i8 noundef zeroext %144)
  %145 = load ptr, ptr %23, align 8, !tbaa !5
  %146 = icmp ne ptr %145, null
  br i1 %146, label %147, label %154

147:                                              ; preds = %137
  %148 = load ptr, ptr %24, align 8, !tbaa !5
  %149 = getelementptr inbounds %struct._EDKII_UFS_HOST_CONTROLLER_PROTOCOL, ptr %148, i32 0, i32 4
  %150 = load ptr, ptr %149, align 8, !tbaa !38
  %151 = load ptr, ptr %24, align 8, !tbaa !5
  %152 = load ptr, ptr %23, align 8, !tbaa !5
  %153 = call i64 %150(ptr noundef %151, ptr noundef %152)
  br label %154

154:                                              ; preds = %147, %137
  %155 = load ptr, ptr %22, align 8, !tbaa !5
  %156 = icmp ne ptr %155, null
  br i1 %156, label %157, label %173

157:                                              ; preds = %154
  %158 = load ptr, ptr %24, align 8, !tbaa !5
  %159 = getelementptr inbounds %struct._EDKII_UFS_HOST_CONTROLLER_PROTOCOL, ptr %158, i32 0, i32 2
  %160 = load ptr, ptr %159, align 8, !tbaa !39
  %161 = load ptr, ptr %24, align 8, !tbaa !5
  %162 = load i32, ptr %20, align 4, !tbaa !30
  %163 = lshr i32 %162, 12
  %164 = load i32, ptr %20, align 4, !tbaa !30
  %165 = and i32 %164, 4095
  %166 = icmp ne i32 %165, 0
  %167 = zext i1 %166 to i64
  %168 = select i1 %166, i32 1, i32 0
  %169 = add i32 %163, %168
  %170 = zext i32 %169 to i64
  %171 = load ptr, ptr %22, align 8, !tbaa !5
  %172 = call i64 %160(ptr noundef %161, i64 noundef %170, ptr noundef %171)
  br label %173

173:                                              ; preds = %157, %154
  %174 = load i64, ptr %14, align 8, !tbaa !19
  store i64 %174, ptr %7, align 8
  store i32 1, ptr %25, align 4
  br label %175

175:                                              ; preds = %173, %63, %48
  call void @llvm.lifetime.end.p0(i64 8, ptr %24) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %23) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %22) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %21) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %20) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %19) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %18) #3
  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 40, ptr %15) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #3
  %176 = load i64, ptr %7, align 8
  ret i64 %176
}

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

; 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

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

declare i64 @MultU64x32(i64 noundef, i32 noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
define dso_local i64 @UfsRwAttributes(ptr noundef %0, i8 noundef zeroext %1, i8 noundef zeroext %2, i8 noundef zeroext %3, i8 noundef zeroext %4, ptr nocapture noundef writeonly %5) local_unnamed_addr #0 {
  %7 = alloca %struct._UFS_DEVICE_MANAGEMENT_REQUEST_PACKET, align 8
  %8 = alloca i8, align 1
  %9 = alloca i32, align 4
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  call void @llvm.lifetime.start.p0(i64 40, ptr nonnull %7) #3
  call void @llvm.lifetime.start.p0(i64 1, ptr nonnull %8) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %9) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %10) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %11) #3
  %12 = call ptr @ZeroMem(ptr noundef nonnull %7, i64 noundef 40) #3
  %.not = icmp eq i8 %1, 0
  %spec.select = select i1 %.not, i8 1, i8 2
  %spec.select48 = select i1 %.not, i8 4, i8 3
  %13 = getelementptr inbounds i8, ptr %7, i64 36
  store i8 %spec.select, ptr %13, align 4
  %14 = getelementptr inbounds i8, ptr %7, i64 24
  store i8 %spec.select48, ptr %14, align 8
  %15 = getelementptr inbounds i8, ptr %7, i64 25
  store i8 %2, ptr %15, align 1, !tbaa !5
  %16 = getelementptr inbounds i8, ptr %7, i64 26
  store i8 %3, ptr %16, align 2, !tbaa !12
  %17 = getelementptr inbounds i8, ptr %7, i64 27
  store i8 %4, ptr %17, align 1, !tbaa !13
  %18 = call i64 @MultU64x32(i64 noundef 3, i32 noundef 10000000) #3
  store i64 %18, ptr %7, align 8, !tbaa !14
  %19 = call i64 @UfsFindAvailableSlotInTrl(ptr noundef %0, ptr noundef nonnull %8)
  %20 = icmp slt i64 %19, 0
  br i1 %20, label %90, label %21

21:                                               ; preds = %6
  %22 = getelementptr inbounds i8, ptr %0, i64 120
  %23 = load ptr, ptr %22, align 8, !tbaa !15
  %24 = load i8, ptr %8, align 1, !tbaa !21
  %25 = zext i8 %24 to i64
  %26 = getelementptr inbounds %struct.UTP_TRD, ptr %23, i64 %25
  %27 = call i64 @UfsCreateDMCommandDesc(ptr noundef %0, ptr noundef nonnull %7, ptr noundef %26, ptr noundef nonnull %10, ptr noundef nonnull %11)
  %28 = icmp slt i64 %27, 0
  br i1 %28, label %90, label %29

29:                                               ; preds = %21
  %30 = getelementptr inbounds i8, ptr %0, i64 96
  %31 = load ptr, ptr %30, align 8, !tbaa !22
  %32 = load ptr, ptr %10, align 8, !tbaa !23
  %33 = getelementptr inbounds i8, ptr %26, i64 26
  %34 = load i16, ptr %33, align 1, !tbaa !24
  %35 = zext i16 %34 to i64
  %36 = shl nuw nsw i64 %35, 2
  %37 = getelementptr inbounds i8, ptr %32, i64 %36
  %38 = call zeroext i8 @DebugAssertEnabled() #3
  %39 = icmp eq i8 %38, 0
  %40 = icmp ne ptr %32, null
  %or.cond = select i1 %39, i1 true, i1 %40
  br i1 %or.cond, label %42, label %41

41:                                               ; preds = %29
  call void @DebugAssert(ptr noundef nonnull @.str.10, i64 noundef 969, ptr noundef nonnull @.str.33) #3
  br label %42

42:                                               ; preds = %41, %29
  %43 = load i16, ptr %33, align 1, !tbaa !24
  %44 = zext i16 %43 to i32
  %45 = getelementptr inbounds i8, ptr %26, i64 24
  %46 = load i16, ptr %45, align 1, !tbaa !26
  %47 = zext i16 %46 to i32
  %48 = add nuw nsw i32 %47, %44
  %49 = load i8, ptr %8, align 1, !tbaa !21
  call void @UfsStartExecCmd(ptr noundef nonnull %0, i8 noundef zeroext %49)
  %50 = getelementptr inbounds i8, ptr %0, i64 104
  %51 = load i64, ptr %50, align 8, !tbaa !27
  %52 = add i64 %51, 88
  %53 = load i64, ptr %7, align 8, !tbaa !14
  %54 = call i64 @UfsWaitMemSet(i64 noundef %52, i32 noundef 1, i32 noundef 0, i64 noundef %53)
  %55 = icmp slt i64 %54, 0
  br i1 %55, label %69, label %56

56:                                               ; preds = %42
  %57 = getelementptr inbounds i8, ptr %37, i64 6
  %58 = load i8, ptr %57, align 1, !tbaa !28
  %.not43 = icmp eq i8 %58, 0
  br i1 %.not43, label %60, label %59

59:                                               ; preds = %56
  call void @DumpQueryResponseResult(i8 noundef zeroext %58)
  br label %69

60:                                               ; preds = %56
  %61 = getelementptr inbounds i8, ptr %26, i64 8
  %62 = load i32, ptr %61, align 1
  %63 = and i32 %62, 255
  %64 = icmp eq i32 %63, 0
  br i1 %64, label %65, label %69

65:                                               ; preds = %60
  %66 = getelementptr inbounds i8, ptr %37, i64 20
  %67 = load i32, ptr %66, align 1, !tbaa !31
  store i32 %67, ptr %9, align 4, !tbaa !32
  call void @SwapLittleEndianToBigEndian(ptr noundef nonnull %9, i32 noundef 4)
  %68 = load i32, ptr %9, align 4, !tbaa !32
  store i32 %68, ptr %5, align 4, !tbaa !32
  br label %69

69:                                               ; preds = %60, %65, %42, %59
  %.037 = phi i64 [ %54, %42 ], [ -9223372036854775801, %59 ], [ %54, %65 ], [ -9223372036854775801, %60 ]
  %70 = getelementptr inbounds i8, ptr %31, i64 40
  %71 = load ptr, ptr %70, align 8, !tbaa !33
  %72 = call i64 %71(ptr noundef %31) #3
  %73 = load i8, ptr %8, align 1, !tbaa !21
  call void @UfsStopExecCmd(ptr noundef nonnull %0, i8 noundef zeroext %73)
  %74 = load ptr, ptr %11, align 8, !tbaa !23
  %.not44 = icmp eq ptr %74, null
  br i1 %.not44, label %79, label %75

75:                                               ; preds = %69
  %76 = getelementptr inbounds i8, ptr %31, i64 32
  %77 = load ptr, ptr %76, align 8, !tbaa !35
  %78 = call i64 %77(ptr noundef nonnull %31, ptr noundef nonnull %74) #3
  br label %79

79:                                               ; preds = %75, %69
  %80 = load ptr, ptr %10, align 8, !tbaa !23
  %.not45 = icmp eq ptr %80, null
  br i1 %.not45, label %90, label %81

81:                                               ; preds = %79
  %82 = getelementptr inbounds i8, ptr %31, i64 16
  %83 = load ptr, ptr %82, align 8, !tbaa !36
  %84 = lshr i32 %48, 10
  %85 = and i32 %48, 1023
  %.not46 = icmp ne i32 %85, 0
  %86 = zext i1 %.not46 to i32
  %87 = add nuw nsw i32 %84, %86
  %88 = zext nneg i32 %87 to i64
  %89 = call i64 %83(ptr noundef nonnull %31, i64 noundef %88, ptr noundef nonnull %80) #3
  br label %90

90:                                               ; preds = %79, %81, %21, %6
  %.0 = phi i64 [ %19, %6 ], [ %27, %21 ], [ %.037, %81 ], [ %.037, %79 ]
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %11) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %10) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %9) #3
  call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %8) #3
  call void @llvm.lifetime.end.p0(i64 40, ptr nonnull %7) #3
  ret i64 %.0
}

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

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

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !8, i64 25}
!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, !8, i64 26}
!13 = !{!6, !8, i64 27}
!14 = !{!6, !7, i64 0}
!15 = !{!16, !10, i64 120}
!16 = !{!"_UFS_PASS_THRU_PRIVATE_DATA", !11, i64 0, !10, i64 8, !17, i64 16, !18, 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, !19, i64 168}
!17 = !{!"", !11, i64 0, !11, i64 4, !11, i64 8}
!18 = !{!"_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}
!19 = !{!"", !8, i64 0, !20, i64 12, !20, i64 13}
!20 = !{!"short", !8, i64 0}
!21 = !{!8, !8, i64 0}
!22 = !{!16, !10, i64 96}
!23 = !{!10, !10, i64 0}
!24 = !{!25, !20, i64 26}
!25 = !{!"", !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, !20, i64 24, !20, i64 26, !20, i64 28, !20, i64 30}
!26 = !{!25, !20, i64 24}
!27 = !{!16, !7, i64 104}
!28 = !{!29, !8, i64 6}
!29 = !{!"", !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, !20, i64 10, !30, i64 12, !8, i64 28}
!30 = !{!"", !8, i64 0, !8, i64 1, !8, i64 2, !8, i64 3, !20, i64 4, !20, i64 6, !11, i64 8, !11, i64 12}
!31 = !{!29, !11, i64 20}
!32 = !{!11, !11, i64 0}
!33 = !{!34, !10, i64 40}
!34 = !{!"_EDKII_UFS_HOST_CONTROLLER_PROTOCOL", !10, i64 0, !10, i64 8, !10, i64 16, !10, i64 24, !10, i64 32, !10, i64 40}
!35 = !{!34, !10, i64 32}
!36 = !{!34, !10, i64 16}


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