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

; 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
@.str.34 = external hidden unnamed_addr constant [22 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 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 @UfsRwFlags(ptr noundef %0, i8 noundef zeroext %1, i8 noundef zeroext %2, ptr noundef %3) #0 {
  %5 = alloca i64, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i8, align 1
  %8 = alloca i8, align 1
  %9 = alloca ptr, align 8
  %10 = alloca i64, align 8
  %11 = alloca %struct._UFS_DEVICE_MANAGEMENT_REQUEST_PACKET, align 8
  %12 = alloca i8, align 1
  %13 = alloca ptr, align 8
  %14 = alloca i64, align 8
  %15 = alloca ptr, align 8
  %16 = alloca i32, align 4
  %17 = alloca ptr, align 8
  %18 = alloca ptr, align 8
  %19 = alloca ptr, align 8
  %20 = alloca i32, align 4
  store ptr %0, ptr %6, align 8, !tbaa !5
  store i8 %1, ptr %7, align 1, !tbaa !9
  store i8 %2, ptr %8, align 1, !tbaa !9
  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 40, ptr %11) #3
  call void @llvm.lifetime.start.p0(i64 1, ptr %12) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #3
  call void @llvm.lifetime.start.p0(i64 4, 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
  %21 = load ptr, ptr %9, align 8, !tbaa !5
  %22 = icmp eq ptr %21, null
  br i1 %22, label %23, label %24

23:                                               ; preds = %4
  store i64 -9223372036854775806, ptr %5, align 8
  store i32 1, ptr %20, align 4
  br label %198

24:                                               ; preds = %4
  %25 = call ptr @ZeroMem(ptr noundef %11, i64 noundef 40)
  %26 = load i8, ptr %7, align 1, !tbaa !9
  %27 = icmp ne i8 %26, 0
  br i1 %27, label %28, label %42

28:                                               ; preds = %24
  br label %29

29:                                               ; preds = %28
  %30 = call zeroext i8 @DebugAssertEnabled()
  %31 = icmp ne i8 %30, 0
  br i1 %31, label %32, label %37

32:                                               ; preds = %29
  %33 = load ptr, ptr %9, align 8, !tbaa !5
  %34 = icmp ne ptr %33, null
  br i1 %34, label %36, label %35

35:                                               ; preds = %32
  call void @DebugAssert(ptr noundef @.str.10, i64 noundef 1055, ptr noundef @.str.34)
  br label %36

36:                                               ; preds = %35, %32
  br label %37

37:                                               ; preds = %36, %29
  br label %38

38:                                               ; preds = %37
  br label %39

39:                                               ; preds = %38
  %40 = getelementptr inbounds %struct._UFS_DEVICE_MANAGEMENT_REQUEST_PACKET, ptr %11, i32 0, i32 9
  store i8 2, ptr %40, align 4, !tbaa !10
  %41 = getelementptr inbounds %struct._UFS_DEVICE_MANAGEMENT_REQUEST_PACKET, ptr %11, i32 0, i32 3
  store i8 5, ptr %41, align 8, !tbaa !14
  br label %60

42:                                               ; preds = %24
  %43 = getelementptr inbounds %struct._UFS_DEVICE_MANAGEMENT_REQUEST_PACKET, ptr %11, i32 0, i32 9
  store i8 1, ptr %43, align 4, !tbaa !10
  %44 = load ptr, ptr %9, align 8, !tbaa !5
  %45 = load i8, ptr %44, align 1, !tbaa !9
  %46 = zext i8 %45 to i32
  %47 = icmp eq i32 %46, 1
  br i1 %47, label %48, label %50

48:                                               ; preds = %42
  %49 = getelementptr inbounds %struct._UFS_DEVICE_MANAGEMENT_REQUEST_PACKET, ptr %11, i32 0, i32 3
  store i8 6, ptr %49, align 8, !tbaa !14
  br label %59

50:                                               ; preds = %42
  %51 = load ptr, ptr %9, align 8, !tbaa !5
  %52 = load i8, ptr %51, align 1, !tbaa !9
  %53 = zext i8 %52 to i32
  %54 = icmp eq i32 %53, 0
  br i1 %54, label %55, label %57

55:                                               ; preds = %50
  %56 = getelementptr inbounds %struct._UFS_DEVICE_MANAGEMENT_REQUEST_PACKET, ptr %11, i32 0, i32 3
  store i8 7, ptr %56, align 8, !tbaa !14
  br label %58

57:                                               ; preds = %50
  store i64 -9223372036854775806, ptr %5, align 8
  store i32 1, ptr %20, align 4
  br label %198

58:                                               ; preds = %55
  br label %59

59:                                               ; preds = %58, %48
  br label %60

60:                                               ; preds = %59, %39
  %61 = load i8, ptr %8, align 1, !tbaa !9
  %62 = getelementptr inbounds %struct._UFS_DEVICE_MANAGEMENT_REQUEST_PACKET, ptr %11, i32 0, i32 4
  store i8 %61, ptr %62, align 1, !tbaa !15
  %63 = getelementptr inbounds %struct._UFS_DEVICE_MANAGEMENT_REQUEST_PACKET, ptr %11, i32 0, i32 5
  store i8 0, ptr %63, align 2, !tbaa !16
  %64 = getelementptr inbounds %struct._UFS_DEVICE_MANAGEMENT_REQUEST_PACKET, ptr %11, i32 0, i32 6
  store i8 0, ptr %64, align 1, !tbaa !17
  %65 = call i64 @MultU64x32(i64 noundef 3, i32 noundef 10000000)
  %66 = getelementptr inbounds %struct._UFS_DEVICE_MANAGEMENT_REQUEST_PACKET, ptr %11, i32 0, i32 0
  store i64 %65, ptr %66, align 8, !tbaa !18
  %67 = load ptr, ptr %6, align 8, !tbaa !5
  %68 = call i64 @UfsFindAvailableSlotInTrl(ptr noundef %67, ptr noundef %12)
  store i64 %68, ptr %10, align 8, !tbaa !19
  %69 = load i64, ptr %10, align 8, !tbaa !19
  %70 = icmp slt i64 %69, 0
  br i1 %70, label %71, label %73

71:                                               ; preds = %60
  %72 = load i64, ptr %10, align 8, !tbaa !19
  store i64 %72, ptr %5, align 8
  store i32 1, ptr %20, align 4
  br label %198

73:                                               ; preds = %60
  %74 = load ptr, ptr %6, align 8, !tbaa !5
  %75 = getelementptr inbounds %struct._UFS_PASS_THRU_PRIVATE_DATA, ptr %74, i32 0, i32 8
  %76 = load ptr, ptr %75, align 8, !tbaa !20
  %77 = load i8, ptr %12, align 1, !tbaa !9
  %78 = zext i8 %77 to i32
  %79 = sext i32 %78 to i64
  %80 = getelementptr inbounds %struct.UTP_TRD, ptr %76, i64 %79
  store ptr %80, ptr %13, align 8, !tbaa !5
  %81 = load ptr, ptr %6, align 8, !tbaa !5
  %82 = load ptr, ptr %13, align 8, !tbaa !5
  %83 = call i64 @UfsCreateDMCommandDesc(ptr noundef %81, ptr noundef %11, ptr noundef %82, ptr noundef %17, ptr noundef %18)
  store i64 %83, ptr %10, align 8, !tbaa !19
  %84 = load i64, ptr %10, align 8, !tbaa !19
  %85 = icmp slt i64 %84, 0
  br i1 %85, label %86, label %88

86:                                               ; preds = %73
  %87 = load i64, ptr %10, align 8, !tbaa !19
  store i64 %87, ptr %5, align 8
  store i32 1, ptr %20, align 4
  br label %198

88:                                               ; preds = %73
  %89 = load ptr, ptr %6, align 8, !tbaa !5
  %90 = getelementptr inbounds %struct._UFS_PASS_THRU_PRIVATE_DATA, ptr %89, i32 0, i32 4
  %91 = load ptr, ptr %90, align 8, !tbaa !26
  store ptr %91, ptr %19, align 8, !tbaa !5
  %92 = load ptr, ptr %17, align 8, !tbaa !5
  %93 = load ptr, ptr %13, align 8, !tbaa !5
  %94 = getelementptr inbounds %struct.UTP_TRD, ptr %93, i32 0, i32 7
  %95 = load i16, ptr %94, align 1, !tbaa !27
  %96 = zext i16 %95 to i64
  %97 = mul i64 %96, 4
  %98 = getelementptr inbounds i8, ptr %92, i64 %97
  store ptr %98, ptr %15, align 8, !tbaa !5
  br label %99

99:                                               ; preds = %88
  %100 = call zeroext i8 @DebugAssertEnabled()
  %101 = icmp ne i8 %100, 0
  br i1 %101, label %102, label %107

102:                                              ; preds = %99
  %103 = load ptr, ptr %15, align 8, !tbaa !5
  %104 = icmp ne ptr %103, null
  br i1 %104, label %106, label %105

105:                                              ; preds = %102
  call void @DebugAssert(ptr noundef @.str.10, i64 noundef 1095, ptr noundef @.str.33)
  br label %106

106:                                              ; preds = %105, %102
  br label %107

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

108:                                              ; preds = %107
  br label %109

109:                                              ; preds = %108
  %110 = load ptr, ptr %13, align 8, !tbaa !5
  %111 = getelementptr inbounds %struct.UTP_TRD, ptr %110, i32 0, i32 7
  %112 = load i16, ptr %111, align 1, !tbaa !27
  %113 = zext i16 %112 to i64
  %114 = mul i64 %113, 4
  %115 = load ptr, ptr %13, align 8, !tbaa !5
  %116 = getelementptr inbounds %struct.UTP_TRD, ptr %115, i32 0, i32 6
  %117 = load i16, ptr %116, align 1, !tbaa !29
  %118 = zext i16 %117 to i64
  %119 = mul i64 %118, 4
  %120 = add i64 %114, %119
  %121 = trunc i64 %120 to i32
  store i32 %121, ptr %16, align 4, !tbaa !30
  %122 = load ptr, ptr %6, align 8, !tbaa !5
  %123 = load i8, ptr %12, align 1, !tbaa !9
  call void @UfsStartExecCmd(ptr noundef %122, i8 noundef zeroext %123)
  %124 = load ptr, ptr %6, align 8, !tbaa !5
  %125 = getelementptr inbounds %struct._UFS_PASS_THRU_PRIVATE_DATA, ptr %124, i32 0, i32 5
  %126 = load i64, ptr %125, align 8, !tbaa !31
  %127 = add i64 %126, 88
  store i64 %127, ptr %14, align 8, !tbaa !19
  %128 = load i64, ptr %14, align 8, !tbaa !19
  %129 = getelementptr inbounds %struct._UFS_DEVICE_MANAGEMENT_REQUEST_PACKET, ptr %11, i32 0, i32 0
  %130 = load i64, ptr %129, align 8, !tbaa !18
  %131 = call i64 @UfsWaitMemSet(i64 noundef %128, i32 noundef 1, i32 noundef 0, i64 noundef %130)
  store i64 %131, ptr %10, align 8, !tbaa !19
  %132 = load i64, ptr %10, align 8, !tbaa !19
  %133 = icmp slt i64 %132, 0
  br i1 %133, label %134, label %135

134:                                              ; preds = %109
  br label %160

135:                                              ; preds = %109
  %136 = load ptr, ptr %15, align 8, !tbaa !5
  %137 = getelementptr inbounds %struct.UTP_QUERY_RESP_UPIU, ptr %136, i32 0, i32 6
  %138 = load i8, ptr %137, align 1, !tbaa !32
  %139 = zext i8 %138 to i32
  %140 = icmp ne i32 %139, 0
  br i1 %140, label %141, label %145

141:                                              ; preds = %135
  %142 = load ptr, ptr %15, align 8, !tbaa !5
  %143 = getelementptr inbounds %struct.UTP_QUERY_RESP_UPIU, ptr %142, i32 0, i32 6
  %144 = load i8, ptr %143, align 1, !tbaa !32
  call void @DumpQueryResponseResult(i8 noundef zeroext %144)
  store i64 -9223372036854775801, ptr %10, align 8, !tbaa !19
  br label %160

145:                                              ; preds = %135
  %146 = load ptr, ptr %13, align 8, !tbaa !5
  %147 = getelementptr inbounds %struct.UTP_TRD, ptr %146, i32 0, i32 2
  %148 = load i32, ptr %147, align 1
  %149 = and i32 %148, 255
  %150 = icmp eq i32 %149, 0
  br i1 %150, label %151, label %158

151:                                              ; preds = %145
  %152 = load ptr, ptr %15, align 8, !tbaa !5
  %153 = getelementptr inbounds %struct.UTP_QUERY_RESP_UPIU, ptr %152, i32 0, i32 11
  %154 = getelementptr inbounds %struct.UTP_UPIU_TSF, ptr %153, i32 0, i32 6
  %155 = load i32, ptr %154, align 1, !tbaa !35
  %156 = trunc i32 %155 to i8
  %157 = load ptr, ptr %9, align 8, !tbaa !5
  store i8 %156, ptr %157, align 1, !tbaa !9
  br label %159

158:                                              ; preds = %145
  store i64 -9223372036854775801, ptr %10, align 8, !tbaa !19
  br label %159

159:                                              ; preds = %158, %151
  br label %160

160:                                              ; preds = %159, %141, %134
  %161 = load ptr, ptr %19, align 8, !tbaa !5
  %162 = getelementptr inbounds %struct._EDKII_UFS_HOST_CONTROLLER_PROTOCOL, ptr %161, i32 0, i32 5
  %163 = load ptr, ptr %162, align 8, !tbaa !36
  %164 = load ptr, ptr %19, align 8, !tbaa !5
  %165 = call i64 %163(ptr noundef %164)
  %166 = load ptr, ptr %6, align 8, !tbaa !5
  %167 = load i8, ptr %12, align 1, !tbaa !9
  call void @UfsStopExecCmd(ptr noundef %166, i8 noundef zeroext %167)
  %168 = load ptr, ptr %18, align 8, !tbaa !5
  %169 = icmp ne ptr %168, null
  br i1 %169, label %170, label %177

170:                                              ; preds = %160
  %171 = load ptr, ptr %19, align 8, !tbaa !5
  %172 = getelementptr inbounds %struct._EDKII_UFS_HOST_CONTROLLER_PROTOCOL, ptr %171, i32 0, i32 4
  %173 = load ptr, ptr %172, align 8, !tbaa !38
  %174 = load ptr, ptr %19, align 8, !tbaa !5
  %175 = load ptr, ptr %18, align 8, !tbaa !5
  %176 = call i64 %173(ptr noundef %174, ptr noundef %175)
  br label %177

177:                                              ; preds = %170, %160
  %178 = load ptr, ptr %17, align 8, !tbaa !5
  %179 = icmp ne ptr %178, null
  br i1 %179, label %180, label %196

180:                                              ; preds = %177
  %181 = load ptr, ptr %19, align 8, !tbaa !5
  %182 = getelementptr inbounds %struct._EDKII_UFS_HOST_CONTROLLER_PROTOCOL, ptr %181, i32 0, i32 2
  %183 = load ptr, ptr %182, align 8, !tbaa !39
  %184 = load ptr, ptr %19, align 8, !tbaa !5
  %185 = load i32, ptr %16, align 4, !tbaa !30
  %186 = lshr i32 %185, 12
  %187 = load i32, ptr %16, align 4, !tbaa !30
  %188 = and i32 %187, 4095
  %189 = icmp ne i32 %188, 0
  %190 = zext i1 %189 to i64
  %191 = select i1 %189, i32 1, i32 0
  %192 = add i32 %186, %191
  %193 = zext i32 %192 to i64
  %194 = load ptr, ptr %17, align 8, !tbaa !5
  %195 = call i64 %183(ptr noundef %184, i64 noundef %193, ptr noundef %194)
  br label %196

196:                                              ; preds = %180, %177
  %197 = load i64, ptr %10, align 8, !tbaa !19
  store i64 %197, ptr %5, align 8
  store i32 1, ptr %20, align 4
  br label %198

198:                                              ; preds = %196, %86, %71, %57, %23
  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 4, ptr %16) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #3
  call void @llvm.lifetime.end.p0(i64 1, ptr %12) #3
  call void @llvm.lifetime.end.p0(i64 40, ptr %11) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #3
  %199 = load i64, ptr %5, align 8
  ret i64 %199
}

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 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 @UfsRwFlags(ptr noundef %0, i8 noundef zeroext %1, i8 noundef zeroext %2, ptr noundef %3) local_unnamed_addr #0 {
  %5 = alloca %struct._UFS_DEVICE_MANAGEMENT_REQUEST_PACKET, align 8
  %6 = alloca i8, align 1
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  call void @llvm.lifetime.start.p0(i64 40, ptr nonnull %5) #3
  call void @llvm.lifetime.start.p0(i64 1, ptr nonnull %6) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %7) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %8) #3
  %9 = icmp eq ptr %3, null
  br i1 %9, label %96, label %10

10:                                               ; preds = %4
  %11 = call ptr @ZeroMem(ptr noundef nonnull %5, i64 noundef 40) #3
  %.not = icmp eq i8 %1, 0
  br i1 %.not, label %15, label %12

12:                                               ; preds = %10
  %13 = call zeroext i8 @DebugAssertEnabled() #3
  %14 = getelementptr inbounds i8, ptr %5, i64 36
  store i8 2, ptr %14, align 4, !tbaa !5
  br label %19

15:                                               ; preds = %10
  %16 = getelementptr inbounds i8, ptr %5, i64 36
  store i8 1, ptr %16, align 4, !tbaa !5
  %17 = load i8, ptr %3, align 1, !tbaa !12
  switch i8 %17, label %96 [
    i8 1, label %19
    i8 0, label %18
  ]

18:                                               ; preds = %15
  br label %19

19:                                               ; preds = %15, %18, %12
  %.sink = phi i8 [ 7, %18 ], [ 5, %12 ], [ 6, %15 ]
  %20 = getelementptr inbounds i8, ptr %5, i64 24
  store i8 %.sink, ptr %20, align 8, !tbaa !13
  %21 = getelementptr inbounds i8, ptr %5, i64 25
  store i8 %2, ptr %21, align 1, !tbaa !14
  %22 = getelementptr inbounds i8, ptr %5, i64 26
  store i8 0, ptr %22, align 2, !tbaa !15
  %23 = getelementptr inbounds i8, ptr %5, i64 27
  store i8 0, ptr %23, align 1, !tbaa !16
  %24 = call i64 @MultU64x32(i64 noundef 3, i32 noundef 10000000) #3
  store i64 %24, ptr %5, align 8, !tbaa !17
  %25 = call i64 @UfsFindAvailableSlotInTrl(ptr noundef %0, ptr noundef nonnull %6)
  %26 = icmp slt i64 %25, 0
  br i1 %26, label %96, label %27

27:                                               ; preds = %19
  %28 = getelementptr inbounds i8, ptr %0, i64 120
  %29 = load ptr, ptr %28, align 8, !tbaa !18
  %30 = load i8, ptr %6, align 1, !tbaa !12
  %31 = zext i8 %30 to i64
  %32 = getelementptr inbounds %struct.UTP_TRD, ptr %29, i64 %31
  %33 = call i64 @UfsCreateDMCommandDesc(ptr noundef %0, ptr noundef nonnull %5, ptr noundef %32, ptr noundef nonnull %7, ptr noundef nonnull %8)
  %34 = icmp slt i64 %33, 0
  br i1 %34, label %96, label %35

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

47:                                               ; preds = %35
  call void @DebugAssert(ptr noundef nonnull @.str.10, i64 noundef 1095, ptr noundef nonnull @.str.33) #3
  br label %48

48:                                               ; preds = %47, %35
  %49 = load i16, ptr %39, align 1, !tbaa !26
  %50 = zext i16 %49 to i32
  %51 = getelementptr inbounds i8, ptr %32, i64 24
  %52 = load i16, ptr %51, align 1, !tbaa !28
  %53 = zext i16 %52 to i32
  %54 = add nuw nsw i32 %53, %50
  %55 = load i8, ptr %6, align 1, !tbaa !12
  call void @UfsStartExecCmd(ptr noundef nonnull %0, i8 noundef zeroext %55)
  %56 = getelementptr inbounds i8, ptr %0, i64 104
  %57 = load i64, ptr %56, align 8, !tbaa !29
  %58 = add i64 %57, 88
  %59 = load i64, ptr %5, align 8, !tbaa !17
  %60 = call i64 @UfsWaitMemSet(i64 noundef %58, i32 noundef 1, i32 noundef 0, i64 noundef %59)
  %61 = icmp slt i64 %60, 0
  br i1 %61, label %75, label %62

62:                                               ; preds = %48
  %63 = getelementptr inbounds i8, ptr %43, i64 6
  %64 = load i8, ptr %63, align 1, !tbaa !30
  %.not49 = icmp eq i8 %64, 0
  br i1 %.not49, label %66, label %65

65:                                               ; preds = %62
  call void @DumpQueryResponseResult(i8 noundef zeroext %64)
  br label %75

66:                                               ; preds = %62
  %67 = getelementptr inbounds i8, ptr %32, i64 8
  %68 = load i32, ptr %67, align 1
  %69 = and i32 %68, 255
  %70 = icmp eq i32 %69, 0
  br i1 %70, label %71, label %75

71:                                               ; preds = %66
  %72 = getelementptr inbounds i8, ptr %43, i64 20
  %73 = load i32, ptr %72, align 1, !tbaa !33
  %74 = trunc i32 %73 to i8
  store i8 %74, ptr %3, align 1, !tbaa !12
  br label %75

75:                                               ; preds = %66, %71, %48, %65
  %.041 = phi i64 [ %60, %48 ], [ -9223372036854775801, %65 ], [ %60, %71 ], [ -9223372036854775801, %66 ]
  %76 = getelementptr inbounds i8, ptr %37, i64 40
  %77 = load ptr, ptr %76, align 8, !tbaa !34
  %78 = call i64 %77(ptr noundef %37) #3
  %79 = load i8, ptr %6, align 1, !tbaa !12
  call void @UfsStopExecCmd(ptr noundef nonnull %0, i8 noundef zeroext %79)
  %80 = load ptr, ptr %8, align 8, !tbaa !25
  %.not50 = icmp eq ptr %80, null
  br i1 %.not50, label %85, label %81

81:                                               ; preds = %75
  %82 = getelementptr inbounds i8, ptr %37, i64 32
  %83 = load ptr, ptr %82, align 8, !tbaa !36
  %84 = call i64 %83(ptr noundef nonnull %37, ptr noundef nonnull %80) #3
  br label %85

85:                                               ; preds = %81, %75
  %86 = load ptr, ptr %7, align 8, !tbaa !25
  %.not51 = icmp eq ptr %86, null
  br i1 %.not51, label %96, label %87

87:                                               ; preds = %85
  %88 = getelementptr inbounds i8, ptr %37, i64 16
  %89 = load ptr, ptr %88, align 8, !tbaa !37
  %90 = lshr i32 %54, 10
  %91 = and i32 %54, 1023
  %.not52 = icmp ne i32 %91, 0
  %92 = zext i1 %.not52 to i32
  %93 = add nuw nsw i32 %90, %92
  %94 = zext nneg i32 %93 to i64
  %95 = call i64 %89(ptr noundef nonnull %37, i64 noundef %94, ptr noundef nonnull %86) #3
  br label %96

96:                                               ; preds = %85, %87, %27, %19, %15, %4
  %.0 = phi i64 [ -9223372036854775806, %4 ], [ -9223372036854775806, %15 ], [ %25, %19 ], [ %33, %27 ], [ %.041, %87 ], [ %.041, %85 ]
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %8) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %7) #3
  call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %6) #3
  call void @llvm.lifetime.end.p0(i64 40, ptr nonnull %5) #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 36}
!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 = !{!8, !8, i64 0}
!13 = !{!6, !8, i64 24}
!14 = !{!6, !8, i64 25}
!15 = !{!6, !8, i64 26}
!16 = !{!6, !8, i64 27}
!17 = !{!6, !7, i64 0}
!18 = !{!19, !10, i64 120}
!19 = !{!"_UFS_PASS_THRU_PRIVATE_DATA", !11, i64 0, !10, i64 8, !20, i64 16, !21, 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, !22, i64 168}
!20 = !{!"", !11, i64 0, !11, i64 4, !11, i64 8}
!21 = !{!"_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}
!22 = !{!"", !8, i64 0, !23, i64 12, !23, i64 13}
!23 = !{!"short", !8, i64 0}
!24 = !{!19, !10, i64 96}
!25 = !{!10, !10, i64 0}
!26 = !{!27, !23, i64 26}
!27 = !{!"", !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, !23, i64 24, !23, i64 26, !23, i64 28, !23, i64 30}
!28 = !{!27, !23, i64 24}
!29 = !{!19, !7, i64 104}
!30 = !{!31, !8, i64 6}
!31 = !{!"", !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, !23, i64 10, !32, i64 12, !8, i64 28}
!32 = !{!"", !8, i64 0, !8, i64 1, !8, i64 2, !8, i64 3, !23, i64 4, !23, i64 6, !11, i64 8, !11, i64 12}
!33 = !{!31, !11, i64 20}
!34 = !{!35, !10, i64 40}
!35 = !{!"_EDKII_UFS_HOST_CONTROLLER_PROTOCOL", !10, i64 0, !10, i64 8, !10, i64 16, !10, i64 24, !10, i64 32, !10, i64 40}
!36 = !{!35, !10, i64 32}
!37 = !{!35, !10, i64 16}


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