; LLVM IR from intel/qpl :: sources/core-iaa/sources/descriptors (hw_decompress_descriptor)

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

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

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

; Function Attrs: nounwind uwtable
define dso_local void @hw_iaa_descriptor_init_huffman_only_decompress(ptr noundef %0, ptr noundef %1, i1 noundef zeroext %2, i8 noundef zeroext %3, i1 noundef zeroext %4) #1 {
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i8, align 1
  %9 = alloca i8, align 1
  %10 = alloca i8, align 1
  %11 = alloca ptr, align 8
  store ptr %0, ptr %6, align 8, !tbaa !5
  store ptr %1, ptr %7, align 8, !tbaa !5
  %12 = zext i1 %2 to i8
  store i8 %12, ptr %8, align 1, !tbaa !9
  store i8 %3, ptr %9, align 1, !tbaa !11
  %13 = zext i1 %4 to i8
  store i8 %13, ptr %10, align 1, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #2
  %14 = load ptr, ptr %6, align 8, !tbaa !5
  store ptr %14, ptr %11, align 8, !tbaa !5
  %15 = load ptr, ptr %11, align 8, !tbaa !5
  %16 = getelementptr inbounds %struct.hw_decompress_analytics_descriptor, ptr %15, i32 0, i32 0
  store i32 0, ptr %16, align 1, !tbaa !12
  %17 = load ptr, ptr %11, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.hw_decompress_analytics_descriptor, ptr %17, i32 0, i32 1
  store i32 1107361792, ptr %18, align 1, !tbaa !16
  %19 = load i8, ptr %8, align 1, !tbaa !9, !range !17, !noundef !18
  %20 = trunc i8 %19 to i1
  %21 = zext i1 %20 to i64
  %22 = select i1 %20, i32 32, i32 0
  %23 = or i32 3, %22
  %24 = load i8, ptr %9, align 1, !tbaa !11
  %25 = zext i8 %24 to i32
  %26 = and i32 7, %25
  %27 = and i32 %26, 7
  %28 = shl i32 %27, 6
  %29 = or i32 %23, %28
  %30 = trunc i32 %29 to i16
  %31 = load ptr, ptr %11, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.hw_decompress_analytics_descriptor, ptr %31, i32 0, i32 7
  store i16 %30, ptr %32, align 1, !tbaa !19
  %33 = load i8, ptr %10, align 1, !tbaa !9, !range !17, !noundef !18
  %34 = trunc i8 %33 to i1
  br i1 %34, label %47, label %35

35:                                               ; preds = %5
  %36 = load i8, ptr %9, align 1, !tbaa !11
  %37 = zext i8 %36 to i32
  %38 = icmp ugt i32 %37, 7
  %39 = zext i1 %38 to i64
  %40 = select i1 %38, i32 16384, i32 0
  %41 = load ptr, ptr %11, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct.hw_decompress_analytics_descriptor, ptr %41, i32 0, i32 7
  %43 = load i16, ptr %42, align 1, !tbaa !19
  %44 = zext i16 %43 to i32
  %45 = or i32 %44, %40
  %46 = trunc i32 %45 to i16
  store i16 %46, ptr %42, align 1, !tbaa !19
  br label %47

47:                                               ; preds = %35, %5
  %48 = load ptr, ptr %7, align 8, !tbaa !5
  %49 = load ptr, ptr %11, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct.hw_decompress_analytics_descriptor, ptr %49, i32 0, i32 8
  store ptr %48, ptr %50, align 1, !tbaa !20
  %51 = load ptr, ptr %11, align 8, !tbaa !5
  %52 = getelementptr inbounds %struct.hw_decompress_analytics_descriptor, ptr %51, i32 0, i32 10
  store i32 1248, ptr %52, align 1, !tbaa !21
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #2
  ret void
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"_Bool", !7, i64 0}
!11 = !{!7, !7, i64 0}
!12 = !{!13, !14, i64 0}
!13 = !{!"", !14, i64 0, !14, i64 4, !6, i64 8, !6, i64 16, !6, i64 24, !14, i64 32, !15, i64 36, !15, i64 38, !6, i64 40, !14, i64 48, !14, i64 52, !14, i64 56, !14, i64 60}
!14 = !{!"int", !7, i64 0}
!15 = !{!"short", !7, i64 0}
!16 = !{!13, !14, i64 4}
!17 = !{i8 0, i8 2}
!18 = !{}
!19 = !{!13, !15, i64 38}
!20 = !{!13, !6, i64 40}
!21 = !{!13, !14, i64 52}


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

; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: write) uwtable
define dso_local void @hw_iaa_descriptor_init_huffman_only_decompress(ptr nocapture noundef writeonly %0, ptr noundef %1, i1 noundef zeroext %2, i8 noundef zeroext %3, i1 noundef zeroext %4) local_unnamed_addr #0 {
  store i32 0, ptr %0, align 1, !tbaa !5
  %6 = getelementptr inbounds i8, ptr %0, i64 4
  store i32 1107361792, ptr %6, align 1, !tbaa !12
  %7 = select i1 %2, i16 35, i16 3
  %8 = zext i8 %3 to i16
  %9 = shl nuw nsw i16 %8, 6
  %10 = and i16 %9, 448
  %11 = or disjoint i16 %10, %7
  %12 = icmp ugt i8 %3, 7
  %13 = select i1 %12, i16 16384, i16 0
  %14 = select i1 %4, i16 0, i16 %13
  %storemerge.in = or disjoint i16 %11, %14
  %15 = getelementptr inbounds i8, ptr %0, i64 38
  store i16 %storemerge.in, ptr %15, align 1, !tbaa !13
  %16 = getelementptr inbounds i8, ptr %0, i64 40
  store ptr %1, ptr %16, align 1, !tbaa !14
  %17 = getelementptr inbounds i8, ptr %0, i64 52
  store i32 1248, ptr %17, align 1, !tbaa !15
  ret void
}

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: write) 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, !7, i64 0}
!6 = !{!"", !7, i64 0, !7, i64 4, !10, i64 8, !10, i64 16, !10, i64 24, !7, i64 32, !11, i64 36, !11, i64 38, !10, i64 40, !7, i64 48, !7, i64 52, !7, i64 56, !7, i64 60}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!"short", !8, i64 0}
!12 = !{!6, !7, i64 4}
!13 = !{!6, !11, i64 38}
!14 = !{!6, !10, i64 40}
!15 = !{!6, !7, i64 52}


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