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

; 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.UTP_UPIU_TSF = type { i8, i8, i8, i8, i16, i16, i32, i32 }

@.str.10 = external hidden unnamed_addr constant [154 x i8], align 1
@.str.23 = external hidden unnamed_addr constant [24 x i8], align 1
@.str.24 = external hidden unnamed_addr constant [36 x i8], align 1

declare zeroext i8 @DebugAssertEnabled() #0

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

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

; Function Attrs: nounwind uwtable
define dso_local void @UfsFillTsfOfQueryReqUpiu(ptr noundef %0, i8 noundef zeroext %1, i8 noundef zeroext %2, i8 noundef zeroext %3, i8 noundef zeroext %4, i16 noundef zeroext %5, i32 noundef %6) #1 {
  %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 i16, align 2
  %14 = 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 i16 %5, ptr %13, align 2, !tbaa !10
  store i32 %6, ptr %14, align 4, !tbaa !12
  br label %15

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

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

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

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

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

24:                                               ; preds = %23
  br label %25

25:                                               ; preds = %24
  %26 = call zeroext i8 @DebugAssertEnabled()
  %27 = icmp ne i8 %26, 0
  br i1 %27, label %28, label %34

28:                                               ; preds = %25
  %29 = load i8, ptr %9, align 1, !tbaa !9
  %30 = zext i8 %29 to i32
  %31 = icmp sle i32 %30, 8
  br i1 %31, label %33, label %32

32:                                               ; preds = %28
  call void @DebugAssert(ptr noundef @.str.10, i64 noundef 236, ptr noundef @.str.24)
  br label %33

33:                                               ; preds = %32, %28
  br label %34

34:                                               ; preds = %33, %25
  br label %35

35:                                               ; preds = %34
  %36 = load i8, ptr %9, align 1, !tbaa !9
  %37 = load ptr, ptr %8, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct.UTP_UPIU_TSF, ptr %37, i32 0, i32 0
  store i8 %36, ptr %38, align 1, !tbaa !14
  %39 = load i8, ptr %9, align 1, !tbaa !9
  %40 = zext i8 %39 to i32
  %41 = icmp ne i32 %40, 0
  br i1 %41, label %42, label %72

42:                                               ; preds = %35
  %43 = load i8, ptr %10, align 1, !tbaa !9
  %44 = load ptr, ptr %8, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct.UTP_UPIU_TSF, ptr %44, i32 0, i32 1
  store i8 %43, ptr %45, align 1, !tbaa !16
  %46 = load i8, ptr %11, align 1, !tbaa !9
  %47 = load ptr, ptr %8, align 8, !tbaa !5
  %48 = getelementptr inbounds %struct.UTP_UPIU_TSF, ptr %47, i32 0, i32 2
  store i8 %46, ptr %48, align 1, !tbaa !17
  %49 = load i8, ptr %12, align 1, !tbaa !9
  %50 = load ptr, ptr %8, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct.UTP_UPIU_TSF, ptr %50, i32 0, i32 3
  store i8 %49, ptr %51, align 1, !tbaa !18
  %52 = load i8, ptr %9, align 1, !tbaa !9
  %53 = zext i8 %52 to i32
  %54 = icmp eq i32 %53, 1
  br i1 %54, label %59, label %55

55:                                               ; preds = %42
  %56 = load i8, ptr %9, align 1, !tbaa !9
  %57 = zext i8 %56 to i32
  %58 = icmp eq i32 %57, 2
  br i1 %58, label %59, label %63

59:                                               ; preds = %55, %42
  call void @SwapLittleEndianToBigEndian(ptr noundef %13, i32 noundef 2)
  %60 = load i16, ptr %13, align 2, !tbaa !10
  %61 = load ptr, ptr %8, align 8, !tbaa !5
  %62 = getelementptr inbounds %struct.UTP_UPIU_TSF, ptr %61, i32 0, i32 5
  store i16 %60, ptr %62, align 1, !tbaa !19
  br label %63

63:                                               ; preds = %59, %55
  %64 = load i8, ptr %9, align 1, !tbaa !9
  %65 = zext i8 %64 to i32
  %66 = icmp eq i32 %65, 4
  br i1 %66, label %67, label %71

67:                                               ; preds = %63
  call void @SwapLittleEndianToBigEndian(ptr noundef %14, i32 noundef 4)
  %68 = load i32, ptr %14, align 4, !tbaa !12
  %69 = load ptr, ptr %8, align 8, !tbaa !5
  %70 = getelementptr inbounds %struct.UTP_UPIU_TSF, ptr %69, i32 0, i32 6
  store i32 %68, ptr %70, align 1, !tbaa !20
  br label %71

71:                                               ; preds = %67, %63
  br label %72

72:                                               ; preds = %71, %35
  ret void
}

attributes #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 = { 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" }

!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 = !{!"short", !7, i64 0}
!12 = !{!13, !13, i64 0}
!13 = !{!"int", !7, i64 0}
!14 = !{!15, !7, i64 0}
!15 = !{!"", !7, i64 0, !7, i64 1, !7, i64 2, !7, i64 3, !11, i64 4, !11, i64 6, !13, i64 8, !13, i64 12}
!16 = !{!15, !7, i64 1}
!17 = !{!15, !7, i64 2}
!18 = !{!15, !7, i64 3}
!19 = !{!15, !11, i64 6}
!20 = !{!15, !13, i64 8}


; 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.23 = external hidden unnamed_addr constant [24 x i8], align 1
@.str.24 = external hidden unnamed_addr constant [36 x i8], align 1

declare zeroext i8 @DebugAssertEnabled() local_unnamed_addr #0

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

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

; Function Attrs: nounwind uwtable
define dso_local void @UfsFillTsfOfQueryReqUpiu(ptr noundef writeonly %0, i8 noundef zeroext %1, i8 noundef zeroext %2, i8 noundef zeroext %3, i8 noundef zeroext %4, i16 noundef zeroext %5, i32 noundef %6) local_unnamed_addr #1 {
  %8 = alloca i16, align 2
  %9 = alloca i32, align 4
  store i16 %5, ptr %8, align 2, !tbaa !5
  store i32 %6, ptr %9, align 4, !tbaa !9
  %10 = tail call zeroext i8 @DebugAssertEnabled() #2
  %11 = icmp eq i8 %10, 0
  %12 = icmp ne ptr %0, null
  %or.cond4 = or i1 %12, %11
  br i1 %or.cond4, label %14, label %13

13:                                               ; preds = %7
  tail call void @DebugAssert(ptr noundef nonnull @.str.10, i64 noundef 235, ptr noundef nonnull @.str.23) #2
  br label %14

14:                                               ; preds = %13, %7
  %15 = tail call zeroext i8 @DebugAssertEnabled() #2
  %16 = icmp eq i8 %15, 0
  %17 = icmp ult i8 %1, 9
  %or.cond7 = or i1 %17, %16
  br i1 %or.cond7, label %21, label %.thread23

.thread23:                                        ; preds = %14
  tail call void @DebugAssert(ptr noundef nonnull @.str.10, i64 noundef 236, ptr noundef nonnull @.str.24) #2
  store i8 %1, ptr %0, align 1, !tbaa !11
  %18 = getelementptr inbounds i8, ptr %0, i64 1
  store i8 %2, ptr %18, align 1, !tbaa !13
  %19 = getelementptr inbounds i8, ptr %0, i64 2
  store i8 %3, ptr %19, align 1, !tbaa !14
  %20 = getelementptr inbounds i8, ptr %0, i64 3
  store i8 %4, ptr %20, align 1, !tbaa !15
  br label %.thread25

21:                                               ; preds = %14
  store i8 %1, ptr %0, align 1, !tbaa !11
  %.not = icmp eq i8 %1, 0
  br i1 %.not, label %.thread25, label %22

22:                                               ; preds = %21
  %23 = getelementptr inbounds i8, ptr %0, i64 1
  store i8 %2, ptr %23, align 1, !tbaa !13
  %24 = getelementptr inbounds i8, ptr %0, i64 2
  store i8 %3, ptr %24, align 1, !tbaa !14
  %25 = getelementptr inbounds i8, ptr %0, i64 3
  store i8 %4, ptr %25, align 1, !tbaa !15
  %or.cond = icmp ult i8 %1, 3
  br i1 %or.cond, label %26, label %29

26:                                               ; preds = %22
  call void @SwapLittleEndianToBigEndian(ptr noundef nonnull %8, i32 noundef 2)
  %27 = load i16, ptr %8, align 2, !tbaa !5
  %28 = getelementptr inbounds i8, ptr %0, i64 6
  store i16 %27, ptr %28, align 1, !tbaa !16
  br label %.thread25

29:                                               ; preds = %22
  %30 = icmp eq i8 %1, 4
  br i1 %30, label %31, label %.thread25

31:                                               ; preds = %29
  call void @SwapLittleEndianToBigEndian(ptr noundef nonnull %9, i32 noundef 4)
  %32 = load i32, ptr %9, align 4, !tbaa !9
  %33 = getelementptr inbounds i8, ptr %0, i64 8
  store i32 %32, ptr %33, align 1, !tbaa !17
  br label %.thread25

.thread25:                                        ; preds = %26, %.thread23, %29, %31, %21
  ret void
}

attributes #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 = { 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 #2 = { 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 = !{!"short", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !7, i64 0}
!12 = !{!"", !7, i64 0, !7, i64 1, !7, i64 2, !7, i64 3, !6, i64 4, !6, i64 6, !10, i64 8, !10, i64 12}
!13 = !{!12, !7, i64 1}
!14 = !{!12, !7, i64 2}
!15 = !{!12, !7, i64 3}
!16 = !{!12, !6, i64 6}
!17 = !{!12, !10, i64 8}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InstCombinePass,JumpThreadingPass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass