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

; 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_QUERY_REQ_UPIU = type { i8, i8, i8, i8, i8, i8, [2 x i8], i8, i8, i16, %struct.UTP_UPIU_TSF, [4 x i8] }
%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.27 = external hidden unnamed_addr constant [25 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 @UfsFillTsfOfQueryReqUpiu(ptr noundef, i8 noundef zeroext, i8 noundef zeroext, i8 noundef zeroext, i8 noundef zeroext, i16 noundef zeroext, i32 noundef) #1

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

; Function Attrs: nounwind uwtable
define dso_local i64 @UfsInitQueryRequestUpiu(ptr noundef %0, i8 noundef zeroext %1, i8 noundef zeroext %2, i8 noundef zeroext %3, i8 noundef zeroext %4, i8 noundef zeroext %5, i64 noundef %6, ptr noundef %7) #1 {
  %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 i8, align 1
  %15 = alloca i64, align 8
  %16 = alloca ptr, align 8
  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 i8 %5, ptr %14, align 1, !tbaa !9
  store i64 %6, ptr %15, align 8, !tbaa !10
  store ptr %7, ptr %16, align 8, !tbaa !5
  br label %17

17:                                               ; preds = %8
  %18 = call zeroext i8 @DebugAssertEnabled()
  %19 = icmp ne i8 %18, 0
  br i1 %19, label %20, label %25

20:                                               ; preds = %17
  %21 = load ptr, ptr %9, align 8, !tbaa !5
  %22 = icmp ne ptr %21, null
  br i1 %22, label %24, label %23

23:                                               ; preds = %20
  call void @DebugAssert(ptr noundef @.str.10, i64 noundef 387, ptr noundef @.str.27)
  br label %24

24:                                               ; preds = %23, %20
  br label %25

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

26:                                               ; preds = %25
  %27 = load ptr, ptr %9, align 8, !tbaa !5
  %28 = load i8, ptr %27, align 1
  %29 = and i8 %28, -64
  %30 = or i8 %29, 22
  store i8 %30, ptr %27, align 1
  %31 = load i8, ptr %10, align 1, !tbaa !9
  %32 = load ptr, ptr %9, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct.UTP_QUERY_REQ_UPIU, ptr %32, i32 0, i32 3
  store i8 %31, ptr %33, align 1, !tbaa !12
  %34 = load i8, ptr %11, align 1, !tbaa !9
  %35 = zext i8 %34 to i32
  %36 = icmp eq i32 %35, 1
  br i1 %36, label %45, label %37

37:                                               ; preds = %26
  %38 = load i8, ptr %11, align 1, !tbaa !9
  %39 = zext i8 %38 to i32
  %40 = icmp eq i32 %39, 5
  br i1 %40, label %45, label %41

41:                                               ; preds = %37
  %42 = load i8, ptr %11, align 1, !tbaa !9
  %43 = zext i8 %42 to i32
  %44 = icmp eq i32 %43, 3
  br i1 %44, label %45, label %48

45:                                               ; preds = %41, %37, %26
  %46 = load ptr, ptr %9, align 8, !tbaa !5
  %47 = getelementptr inbounds %struct.UTP_QUERY_REQ_UPIU, ptr %46, i32 0, i32 5
  store i8 1, ptr %47, align 1, !tbaa !17
  br label %51

48:                                               ; preds = %41
  %49 = load ptr, ptr %9, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct.UTP_QUERY_REQ_UPIU, ptr %49, i32 0, i32 5
  store i8 -127, ptr %50, align 1, !tbaa !17
  br label %51

51:                                               ; preds = %48, %45
  %52 = load i8, ptr %11, align 1, !tbaa !9
  %53 = zext i8 %52 to i32
  %54 = icmp eq i32 %53, 4
  br i1 %54, label %55, label %64

55:                                               ; preds = %51
  %56 = load ptr, ptr %9, align 8, !tbaa !5
  %57 = getelementptr inbounds %struct.UTP_QUERY_REQ_UPIU, ptr %56, i32 0, i32 10
  %58 = load i8, ptr %11, align 1, !tbaa !9
  %59 = load i8, ptr %12, align 1, !tbaa !9
  %60 = load i8, ptr %13, align 1, !tbaa !9
  %61 = load i8, ptr %14, align 1, !tbaa !9
  %62 = load ptr, ptr %16, align 8, !tbaa !5
  %63 = load i32, ptr %62, align 4, !tbaa !18
  call void @UfsFillTsfOfQueryReqUpiu(ptr noundef %57, i8 noundef zeroext %58, i8 noundef zeroext %59, i8 noundef zeroext %60, i8 noundef zeroext %61, i16 noundef zeroext 0, i32 noundef %63)
  br label %89

64:                                               ; preds = %51
  %65 = load i8, ptr %11, align 1, !tbaa !9
  %66 = zext i8 %65 to i32
  %67 = icmp eq i32 %66, 1
  br i1 %67, label %72, label %68

68:                                               ; preds = %64
  %69 = load i8, ptr %11, align 1, !tbaa !9
  %70 = zext i8 %69 to i32
  %71 = icmp eq i32 %70, 2
  br i1 %71, label %72, label %81

72:                                               ; preds = %68, %64
  %73 = load ptr, ptr %9, align 8, !tbaa !5
  %74 = getelementptr inbounds %struct.UTP_QUERY_REQ_UPIU, ptr %73, i32 0, i32 10
  %75 = load i8, ptr %11, align 1, !tbaa !9
  %76 = load i8, ptr %12, align 1, !tbaa !9
  %77 = load i8, ptr %13, align 1, !tbaa !9
  %78 = load i8, ptr %14, align 1, !tbaa !9
  %79 = load i64, ptr %15, align 8, !tbaa !10
  %80 = trunc i64 %79 to i16
  call void @UfsFillTsfOfQueryReqUpiu(ptr noundef %74, i8 noundef zeroext %75, i8 noundef zeroext %76, i8 noundef zeroext %77, i8 noundef zeroext %78, i16 noundef zeroext %80, i32 noundef 0)
  br label %88

81:                                               ; preds = %68
  %82 = load ptr, ptr %9, align 8, !tbaa !5
  %83 = getelementptr inbounds %struct.UTP_QUERY_REQ_UPIU, ptr %82, i32 0, i32 10
  %84 = load i8, ptr %11, align 1, !tbaa !9
  %85 = load i8, ptr %12, align 1, !tbaa !9
  %86 = load i8, ptr %13, align 1, !tbaa !9
  %87 = load i8, ptr %14, align 1, !tbaa !9
  call void @UfsFillTsfOfQueryReqUpiu(ptr noundef %83, i8 noundef zeroext %84, i8 noundef zeroext %85, i8 noundef zeroext %86, i8 noundef zeroext %87, i16 noundef zeroext 0, i32 noundef 0)
  br label %88

88:                                               ; preds = %81, %72
  br label %89

89:                                               ; preds = %88, %55
  %90 = load i8, ptr %11, align 1, !tbaa !9
  %91 = zext i8 %90 to i32
  %92 = icmp eq i32 %91, 2
  br i1 %92, label %93, label %99

93:                                               ; preds = %89
  %94 = load ptr, ptr %9, align 8, !tbaa !5
  %95 = getelementptr inbounds %struct.UTP_QUERY_REQ_UPIU, ptr %94, i64 1
  %96 = load ptr, ptr %16, align 8, !tbaa !5
  %97 = load i64, ptr %15, align 8, !tbaa !10
  %98 = call ptr @CopyMem(ptr noundef %95, ptr noundef %96, i64 noundef %97)
  br label %99

99:                                               ; preds = %93, %89
  ret i64 0
}

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 = !{!"long long", !7, i64 0}
!12 = !{!13, !7, i64 3}
!13 = !{!"", !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 8, !7, i64 9, !14, i64 10, !15, i64 12, !7, i64 28}
!14 = !{!"short", !7, i64 0}
!15 = !{!"", !7, i64 0, !7, i64 1, !7, i64 2, !7, i64 3, !14, i64 4, !14, i64 6, !16, i64 8, !16, i64 12}
!16 = !{!"int", !7, i64 0}
!17 = !{!13, !7, i64 5}
!18 = !{!16, !16, i64 0}


; 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.27 = external hidden unnamed_addr constant [25 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 @UfsFillTsfOfQueryReqUpiu(ptr noundef, i8 noundef zeroext, i8 noundef zeroext, i8 noundef zeroext, i8 noundef zeroext, i16 noundef zeroext, i32 noundef) local_unnamed_addr #1

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

; Function Attrs: nounwind uwtable
define dso_local noundef i64 @UfsInitQueryRequestUpiu(ptr noundef %0, i8 noundef zeroext %1, i8 noundef zeroext %2, i8 noundef zeroext %3, i8 noundef zeroext %4, i8 noundef zeroext %5, i64 noundef %6, ptr noundef %7) local_unnamed_addr #1 {
  %9 = tail call zeroext i8 @DebugAssertEnabled() #2
  %10 = icmp eq i8 %9, 0
  %11 = icmp ne ptr %0, null
  %or.cond10 = or i1 %11, %10
  br i1 %or.cond10, label %13, label %12

12:                                               ; preds = %8
  tail call void @DebugAssert(ptr noundef nonnull @.str.10, i64 noundef 387, ptr noundef nonnull @.str.27) #2
  br label %13

13:                                               ; preds = %8, %12
  %14 = load i8, ptr %0, align 1
  %15 = and i8 %14, -64
  %16 = or disjoint i8 %15, 22
  store i8 %16, ptr %0, align 1
  %17 = getelementptr inbounds i8, ptr %0, i64 3
  store i8 %1, ptr %17, align 1, !tbaa !5
  %18 = icmp ult i8 %2, 6
  %switch.idx.mult = shl i8 %2, 7
  %switch.offset = add i8 %switch.idx.mult, -127
  %.sink = select i1 %18, i8 %switch.offset, i8 -127
  %19 = getelementptr inbounds i8, ptr %0, i64 5
  store i8 %.sink, ptr %19, align 1, !tbaa !12
  %20 = icmp eq i8 %2, 4
  br i1 %20, label %21, label %24

21:                                               ; preds = %13
  %22 = getelementptr inbounds i8, ptr %0, i64 12
  %23 = load i32, ptr %7, align 4, !tbaa !13
  tail call void @UfsFillTsfOfQueryReqUpiu(ptr noundef nonnull %22, i8 noundef zeroext 4, i8 noundef zeroext %3, i8 noundef zeroext %4, i8 noundef zeroext %5, i16 noundef zeroext 0, i32 noundef %23)
  br label %.thread

24:                                               ; preds = %13
  %25 = add i8 %2, -1
  %or.cond8 = icmp ult i8 %25, 2
  %26 = getelementptr inbounds i8, ptr %0, i64 12
  br i1 %or.cond8, label %28, label %27

27:                                               ; preds = %24
  tail call void @UfsFillTsfOfQueryReqUpiu(ptr noundef nonnull %26, i8 noundef zeroext %2, i8 noundef zeroext %3, i8 noundef zeroext %4, i8 noundef zeroext %5, i16 noundef zeroext 0, i32 noundef 0)
  br label %.thread

28:                                               ; preds = %24
  %29 = trunc i64 %6 to i16
  tail call void @UfsFillTsfOfQueryReqUpiu(ptr noundef nonnull %26, i8 noundef zeroext %2, i8 noundef zeroext %3, i8 noundef zeroext %4, i8 noundef zeroext %5, i16 noundef zeroext %29, i32 noundef 0)
  %30 = icmp eq i8 %2, 2
  br i1 %30, label %31, label %.thread

31:                                               ; preds = %28
  %32 = getelementptr inbounds i8, ptr %0, i64 32
  %33 = tail call ptr @CopyMem(ptr noundef nonnull %32, ptr noundef %7, i64 noundef %6) #2
  br label %.thread

.thread:                                          ; preds = %21, %27, %31, %28
  ret i64 0
}

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


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