; 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 }
%struct.hw_iaa_aecs_analytic = type { %struct.hw_iaa_aecs_filter, [36 x i32], %struct.hw_iaa_aecs_decompress }
%struct.hw_iaa_aecs_filter = type { i32, i32, i32, i32, i32, i32 }
%struct.hw_iaa_aecs_decompress = type { [2 x i32], i32, i32, [32 x i64], [32 x i8], i32, i8, i8, i16, [5 x i32], [5 x i32], [5 x i32], [5 x i32], [62 x i32], %union.anon, i16, i16, %union.anon.0, %struct.anon.2, i16, [4096 x i8], [6 x i32] }
%union.anon = type { %struct.anon }
%struct.anon = type { [6 x i32], [224 x i8], [5 x i32] }
%union.anon.0 = type { %struct.anon.1 }
%struct.anon.1 = type { [2 x i32], [144 x i8], [5 x i32] }
%struct.anon.2 = type { i16 }

; 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_inflate_body(ptr noundef %0, ptr noundef %1, i8 noundef zeroext %2) #1 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i8, align 1
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store i8 %2, ptr %6, align 1, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #2
  %9 = load ptr, ptr %4, align 8, !tbaa !5
  store ptr %9, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #2
  %10 = load ptr, ptr %5, align 8, !tbaa !5
  store ptr %10, ptr %8, align 8, !tbaa !5
  %11 = load ptr, ptr %7, align 8, !tbaa !5
  %12 = getelementptr inbounds %struct.hw_decompress_analytics_descriptor, ptr %11, i32 0, i32 0
  store i32 0, ptr %12, align 1, !tbaa !10
  %13 = load ptr, ptr %7, align 8, !tbaa !5
  %14 = getelementptr inbounds %struct.hw_decompress_analytics_descriptor, ptr %13, i32 0, i32 1
  store i32 1107361792, ptr %14, align 1, !tbaa !14
  %15 = load i8, ptr %6, align 1, !tbaa !9
  %16 = zext i8 %15 to i32
  %17 = and i32 7, %16
  %18 = and i32 %17, 7
  %19 = shl i32 %18, 6
  %20 = or i32 7, %19
  %21 = trunc i32 %20 to i16
  %22 = load ptr, ptr %7, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct.hw_decompress_analytics_descriptor, ptr %22, i32 0, i32 7
  store i16 %21, ptr %23, align 1, !tbaa !15
  %24 = load ptr, ptr %8, align 8, !tbaa !5
  %25 = load ptr, ptr %7, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.hw_decompress_analytics_descriptor, ptr %25, i32 0, i32 8
  store ptr %24, ptr %26, align 1, !tbaa !16
  %27 = load ptr, ptr %7, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct.hw_decompress_analytics_descriptor, ptr %27, i32 0, i32 10
  store i32 1248, ptr %28, align 1, !tbaa !17
  %29 = load ptr, ptr %8, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.hw_iaa_aecs_analytic, ptr %29, i32 0, i32 2
  %31 = getelementptr inbounds %struct.hw_iaa_aecs_decompress, ptr %30, i32 0, i32 15
  store i16 0, ptr %31, align 4, !tbaa !18
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #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 = !{!7, !7, i64 0}
!10 = !{!11, !12, i64 0}
!11 = !{!"", !12, i64 0, !12, i64 4, !6, i64 8, !6, i64 16, !6, i64 24, !12, i64 32, !13, i64 36, !13, i64 38, !6, i64 40, !12, i64 48, !12, i64 52, !12, i64 56, !12, i64 60}
!12 = !{!"int", !7, i64 0}
!13 = !{!"short", !7, i64 0}
!14 = !{!11, !12, i64 4}
!15 = !{!11, !13, i64 38}
!16 = !{!11, !6, i64 40}
!17 = !{!11, !12, i64 52}
!18 = !{!19, !13, i64 1076}
!19 = !{!"", !20, i64 0, !7, i64 24, !21, i64 168}
!20 = !{!"", !12, i64 0, !12, i64 4, !12, i64 8, !12, i64 12, !12, i64 16, !12, i64 20}
!21 = !{!"", !7, i64 0, !12, i64 8, !12, i64 12, !7, i64 16, !7, i64 272, !12, i64 304, !7, i64 308, !7, i64 309, !13, i64 310, !7, i64 312, !7, i64 332, !7, i64 352, !7, i64 372, !7, i64 392, !7, i64 640, !13, i64 908, !13, i64 910, !7, i64 912, !22, i64 1084, !13, i64 1086, !7, i64 1088, !7, i64 5184}
!22 = !{!"", !13, i64 0, !13, i64 1}


; 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_inflate_body(ptr nocapture noundef writeonly %0, ptr noundef %1, i8 noundef zeroext %2) local_unnamed_addr #0 {
  store i32 0, ptr %0, align 1, !tbaa !5
  %4 = getelementptr inbounds i8, ptr %0, i64 4
  store i32 1107361792, ptr %4, align 1, !tbaa !12
  %5 = and i8 %2, 7
  %6 = zext nneg i8 %5 to i16
  %7 = shl nuw nsw i16 %6, 6
  %8 = or disjoint i16 %7, 7
  %9 = getelementptr inbounds i8, ptr %0, i64 38
  store i16 %8, ptr %9, align 1, !tbaa !13
  %10 = getelementptr inbounds i8, ptr %0, i64 40
  store ptr %1, ptr %10, align 1, !tbaa !14
  %11 = getelementptr inbounds i8, ptr %0, i64 52
  store i32 1248, ptr %11, align 1, !tbaa !15
  %12 = getelementptr inbounds i8, ptr %1, i64 1076
  store i16 0, ptr %12, align 4, !tbaa !16
  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}
!16 = !{!17, !11, i64 1076}
!17 = !{!"", !18, i64 0, !8, i64 24, !19, i64 168}
!18 = !{!"", !7, i64 0, !7, i64 4, !7, i64 8, !7, i64 12, !7, i64 16, !7, i64 20}
!19 = !{!"", !8, i64 0, !7, i64 8, !7, i64 12, !8, i64 16, !8, i64 272, !7, i64 304, !8, i64 308, !8, i64 309, !11, i64 310, !8, i64 312, !8, i64 332, !8, i64 352, !8, i64 372, !8, i64 392, !8, i64 640, !11, i64 908, !11, i64 910, !8, i64 912, !20, i64 1084, !11, i64 1086, !8, i64 1088, !8, i64 5184}
!20 = !{!"", !11, i64 0, !11, i64 1}


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