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

; 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_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_NOP_OUT_UPIU = type { i8, i8, i8, i8, [4 x i8], i8, i8, i16, [20 x 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.30 = external hidden unnamed_addr constant [51 x i8], align 1
@.str.31 = external hidden unnamed_addr constant [27 x i8], align 1

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

declare i64 @DivU64x32(i64 noundef, i32 noundef) #1

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

declare zeroext i8 @DebugAssertEnabled() #1

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

declare i64 @RShiftU64(i64 noundef, i64 noundef) #1

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

; Function Attrs: nounwind uwtable
define dso_local i64 @UfsCreateNopCommandDesc(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3) #2 {
  %5 = alloca i64, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca i64, align 8
  %11 = alloca ptr, align 8
  %12 = alloca i64, align 8
  %13 = alloca i64, align 8
  %14 = alloca i32, align 4
  store ptr %0, ptr %6, align 8, !tbaa !5
  store ptr %1, ptr %7, align 8, !tbaa !5
  store ptr %2, ptr %8, align 8, !tbaa !5
  store ptr %3, ptr %9, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #3
  br label %15

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

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

21:                                               ; preds = %18
  %22 = load ptr, ptr %7, align 8, !tbaa !5
  %23 = icmp ne ptr %22, null
  br i1 %23, label %25, label %24

24:                                               ; preds = %21, %18
  call void @DebugAssert(ptr noundef @.str.10, i64 noundef 629, ptr noundef @.str.30)
  br label %25

25:                                               ; preds = %24, %21
  br label %26

26:                                               ; preds = %25, %15
  br label %27

27:                                               ; preds = %26
  br label %28

28:                                               ; preds = %27
  store i64 64, ptr %10, align 8, !tbaa !9
  %29 = load ptr, ptr %6, align 8, !tbaa !5
  %30 = load i64, ptr %10, align 8, !tbaa !9
  %31 = load ptr, ptr %8, align 8, !tbaa !5
  %32 = load ptr, ptr %9, align 8, !tbaa !5
  %33 = call i64 @UfsAllocateAlignCommonBuffer(ptr noundef %29, i64 noundef %30, ptr noundef %31, ptr noundef %13, ptr noundef %32)
  store i64 %33, ptr %12, align 8, !tbaa !9
  %34 = load i64, ptr %12, align 8, !tbaa !9
  %35 = icmp slt i64 %34, 0
  br i1 %35, label %36, label %38

36:                                               ; preds = %28
  %37 = load i64, ptr %12, align 8, !tbaa !9
  store i64 %37, ptr %5, align 8
  store i32 1, ptr %14, align 4
  br label %93

38:                                               ; preds = %28
  %39 = load ptr, ptr %8, align 8, !tbaa !5
  %40 = load ptr, ptr %39, align 8, !tbaa !5
  store ptr %40, ptr %11, align 8, !tbaa !5
  br label %41

41:                                               ; preds = %38
  %42 = call zeroext i8 @DebugAssertEnabled()
  %43 = icmp ne i8 %42, 0
  br i1 %43, label %44, label %49

44:                                               ; preds = %41
  %45 = load ptr, ptr %11, align 8, !tbaa !5
  %46 = icmp ne ptr %45, null
  br i1 %46, label %48, label %47

47:                                               ; preds = %44
  call void @DebugAssert(ptr noundef @.str.10, i64 noundef 638, ptr noundef @.str.31)
  br label %48

48:                                               ; preds = %47, %44
  br label %49

49:                                               ; preds = %48, %41
  br label %50

50:                                               ; preds = %49
  br label %51

51:                                               ; preds = %50
  %52 = load ptr, ptr %6, align 8, !tbaa !5
  %53 = getelementptr inbounds %struct._UFS_PASS_THRU_PRIVATE_DATA, ptr %52, i32 0, i32 7
  %54 = load i8, ptr %53, align 4, !tbaa !11
  %55 = add i8 %54, 1
  store i8 %55, ptr %53, align 4, !tbaa !11
  %56 = load ptr, ptr %11, align 8, !tbaa !5
  %57 = getelementptr inbounds %struct.UTP_NOP_OUT_UPIU, ptr %56, i32 0, i32 3
  store i8 %54, ptr %57, align 1, !tbaa !18
  %58 = load ptr, ptr %7, align 8, !tbaa !5
  %59 = load i32, ptr %58, align 1
  %60 = and i32 %59, -16777217
  %61 = or i32 %60, 16777216
  store i32 %61, ptr %58, align 1
  %62 = load ptr, ptr %7, align 8, !tbaa !5
  %63 = load i32, ptr %62, align 1
  %64 = and i32 %63, -100663297
  %65 = or i32 %64, 0
  store i32 %65, ptr %62, align 1
  %66 = load ptr, ptr %7, align 8, !tbaa !5
  %67 = load i32, ptr %66, align 1
  %68 = and i32 %67, 268435455
  %69 = or i32 %68, 268435456
  store i32 %69, ptr %66, align 1
  %70 = load i64, ptr %13, align 8, !tbaa !9
  %71 = call i64 @RShiftU64(i64 noundef %70, i64 noundef 7)
  %72 = trunc i64 %71 to i32
  %73 = load ptr, ptr %7, align 8, !tbaa !5
  %74 = getelementptr inbounds %struct.UTP_TRD, ptr %73, i32 0, i32 4
  %75 = load i32, ptr %74, align 1
  %76 = and i32 %72, 33554431
  %77 = shl i32 %76, 7
  %78 = and i32 %75, 127
  %79 = or i32 %78, %77
  store i32 %79, ptr %74, align 1
  %80 = load i64, ptr %13, align 8, !tbaa !9
  %81 = call i64 @RShiftU64(i64 noundef %80, i64 noundef 32)
  %82 = trunc i64 %81 to i32
  %83 = load ptr, ptr %7, align 8, !tbaa !5
  %84 = getelementptr inbounds %struct.UTP_TRD, ptr %83, i32 0, i32 5
  store i32 %82, ptr %84, align 1, !tbaa !20
  %85 = call i64 @DivU64x32(i64 noundef 32, i32 noundef 4)
  %86 = trunc i64 %85 to i16
  %87 = load ptr, ptr %7, align 8, !tbaa !5
  %88 = getelementptr inbounds %struct.UTP_TRD, ptr %87, i32 0, i32 6
  store i16 %86, ptr %88, align 1, !tbaa !22
  %89 = call i64 @DivU64x32(i64 noundef 32, i32 noundef 4)
  %90 = trunc i64 %89 to i16
  %91 = load ptr, ptr %7, align 8, !tbaa !5
  %92 = getelementptr inbounds %struct.UTP_TRD, ptr %91, i32 0, i32 7
  store i16 %90, ptr %92, align 1, !tbaa !23
  store i64 0, ptr %5, align 8
  store i32 1, ptr %14, align 4
  br label %93

93:                                               ; preds = %51, %36
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #3
  %94 = load i64, ptr %5, align 8
  ret i64 %94
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { nounwind 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 #3 = { nounwind }

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

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"long long", !7, i64 0}
!11 = !{!12, !7, i64 116}
!12 = !{!"_UFS_PASS_THRU_PRIVATE_DATA", !13, i64 0, !6, i64 8, !14, i64 16, !15, i64 32, !6, i64 96, !10, 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, !16, i64 168}
!13 = !{!"int", !7, i64 0}
!14 = !{!"", !13, i64 0, !13, i64 4, !13, i64 8}
!15 = !{!"_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}
!16 = !{!"", !7, i64 0, !17, i64 12, !17, i64 13}
!17 = !{!"short", !7, i64 0}
!18 = !{!19, !7, i64 3}
!19 = !{!"", !7, i64 0, !7, i64 0, !7, i64 0, !7, i64 1, !7, i64 2, !7, i64 3, !7, i64 4, !7, i64 8, !7, i64 9, !17, i64 10, !7, i64 12}
!20 = !{!21, !13, i64 20}
!21 = !{!"", !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, !17, i64 24, !17, i64 26, !17, i64 28, !17, i64 30}
!22 = !{!21, !17, i64 24}
!23 = !{!21, !17, i64 26}


; 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"

@.str.10 = external hidden unnamed_addr constant [154 x i8], align 1
@.str.30 = external hidden unnamed_addr constant [51 x i8], align 1
@.str.31 = external hidden unnamed_addr constant [27 x i8], align 1

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

declare i64 @DivU64x32(i64 noundef, i32 noundef) local_unnamed_addr #1

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

declare zeroext i8 @DebugAssertEnabled() local_unnamed_addr #1

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

declare i64 @RShiftU64(i64 noundef, i64 noundef) local_unnamed_addr #1

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

; Function Attrs: nounwind uwtable
define dso_local range(i64 -9223372036854775808, 1) i64 @UfsCreateNopCommandDesc(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3) local_unnamed_addr #2 {
  %5 = alloca i64, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %5) #3
  %6 = tail call zeroext i8 @DebugAssertEnabled() #3
  %.not = icmp eq i8 %6, 0
  br i1 %.not, label %11, label %7

7:                                                ; preds = %4
  %8 = icmp ne ptr %0, null
  %9 = icmp ne ptr %1, null
  %or.cond = and i1 %8, %9
  br i1 %or.cond, label %11, label %10

10:                                               ; preds = %7
  tail call void @DebugAssert(ptr noundef nonnull @.str.10, i64 noundef 629, ptr noundef nonnull @.str.30) #3
  br label %11

11:                                               ; preds = %10, %7, %4
  %12 = call i64 @UfsAllocateAlignCommonBuffer(ptr noundef %0, i64 noundef 64, ptr noundef %2, ptr noundef nonnull %5, ptr noundef %3)
  %13 = icmp slt i64 %12, 0
  br i1 %13, label %46, label %14

14:                                               ; preds = %11
  %15 = load ptr, ptr %2, align 8, !tbaa !5
  %16 = call zeroext i8 @DebugAssertEnabled() #3
  %17 = icmp eq i8 %16, 0
  %18 = icmp ne ptr %15, null
  %or.cond3 = select i1 %17, i1 true, i1 %18
  br i1 %or.cond3, label %20, label %19

19:                                               ; preds = %14
  call void @DebugAssert(ptr noundef nonnull @.str.10, i64 noundef 638, ptr noundef nonnull @.str.31) #3
  br label %20

20:                                               ; preds = %19, %14
  %21 = getelementptr inbounds i8, ptr %0, i64 116
  %22 = load i8, ptr %21, align 4, !tbaa !9
  %23 = add i8 %22, 1
  store i8 %23, ptr %21, align 4, !tbaa !9
  %24 = getelementptr inbounds i8, ptr %15, i64 3
  store i8 %22, ptr %24, align 1, !tbaa !17
  %25 = load i32, ptr %1, align 1
  %26 = and i32 %25, 150994943
  %27 = or disjoint i32 %26, 285212672
  store i32 %27, ptr %1, align 1
  %28 = load i64, ptr %5, align 8, !tbaa !19
  %29 = call i64 @RShiftU64(i64 noundef %28, i64 noundef 7) #3
  %30 = trunc i64 %29 to i32
  %31 = getelementptr inbounds i8, ptr %1, i64 16
  %32 = load i32, ptr %31, align 1
  %33 = shl i32 %30, 7
  %34 = and i32 %32, 127
  %35 = or disjoint i32 %34, %33
  store i32 %35, ptr %31, align 1
  %36 = load i64, ptr %5, align 8, !tbaa !19
  %37 = call i64 @RShiftU64(i64 noundef %36, i64 noundef 32) #3
  %38 = trunc i64 %37 to i32
  %39 = getelementptr inbounds i8, ptr %1, i64 20
  store i32 %38, ptr %39, align 1, !tbaa !20
  %40 = call i64 @DivU64x32(i64 noundef 32, i32 noundef 4) #3
  %41 = trunc i64 %40 to i16
  %42 = getelementptr inbounds i8, ptr %1, i64 24
  store i16 %41, ptr %42, align 1, !tbaa !22
  %43 = call i64 @DivU64x32(i64 noundef 32, i32 noundef 4) #3
  %44 = trunc i64 %43 to i16
  %45 = getelementptr inbounds i8, ptr %1, i64 26
  store i16 %44, ptr %45, align 1, !tbaa !23
  br label %46

46:                                               ; preds = %11, %20
  %.0 = phi i64 [ 0, %20 ], [ %12, %11 ]
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #3
  ret i64 %.0
}

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

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

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !7, i64 116}
!10 = !{!"_UFS_PASS_THRU_PRIVATE_DATA", !11, i64 0, !6, i64 8, !12, i64 16, !13, 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, !15, i64 168}
!11 = !{!"int", !7, i64 0}
!12 = !{!"", !11, i64 0, !11, i64 4, !11, i64 8}
!13 = !{!"_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}
!14 = !{!"long long", !7, i64 0}
!15 = !{!"", !7, i64 0, !16, i64 12, !16, i64 13}
!16 = !{!"short", !7, i64 0}
!17 = !{!18, !7, i64 3}
!18 = !{!"", !7, i64 0, !7, i64 0, !7, i64 0, !7, i64 1, !7, i64 2, !7, i64 3, !7, i64 4, !7, i64 8, !7, i64 9, !16, i64 10, !7, i64 12}
!19 = !{!14, !14, i64 0}
!20 = !{!21, !11, i64 20}
!21 = !{!"", !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, !16, i64 24, !16, i64 26, !16, i64 28, !16, i64 30}
!22 = !{!21, !16, i64 24}
!23 = !{!21, !16, i64 26}


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