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

; 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: nounwind uwtable
define dso_local void @hw_iaa_descriptor_analytic_enable_decompress(ptr noundef %0, i1 noundef zeroext %1, i32 noundef %2) #0 {
  %4 = alloca ptr, align 8
  %5 = alloca i8, align 1
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  %8 = zext i1 %1 to i8
  store i8 %8, ptr %5, align 1, !tbaa !9
  store i32 %2, ptr %6, align 4, !tbaa !11
  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
  %10 = load i32, ptr %6, align 4, !tbaa !11
  %11 = and i32 %10, 7
  %12 = and i32 %11, 7
  %13 = shl i32 %12, 6
  %14 = or i32 3, %13
  %15 = load i8, ptr %5, align 1, !tbaa !9, !range !13, !noundef !14
  %16 = trunc i8 %15 to i1
  %17 = zext i1 %16 to i64
  %18 = select i1 %16, i32 32, i32 0
  %19 = or i32 %14, %18
  %20 = load ptr, ptr %7, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct.hw_decompress_analytics_descriptor, ptr %20, i32 0, i32 7
  %22 = load i16, ptr %21, align 1, !tbaa !15
  %23 = zext i16 %22 to i32
  %24 = or i32 %23, %19
  %25 = trunc i32 %24 to i16
  store i16 %25, ptr %21, align 1, !tbaa !15
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #2
  ret void
}

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

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

attributes #0 = { 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 #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{i8 0, i8 2}
!14 = !{}
!15 = !{!16, !17, i64 38}
!16 = !{!"", !12, i64 0, !12, i64 4, !6, i64 8, !6, i64 16, !6, i64 24, !12, i64 32, !17, i64 36, !17, i64 38, !6, i64 40, !12, i64 48, !12, i64 52, !12, i64 56, !12, i64 60}
!17 = !{!"short", !7, 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"

; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: readwrite) uwtable
define dso_local void @hw_iaa_descriptor_analytic_enable_decompress(ptr nocapture noundef %0, i1 noundef zeroext %1, i32 noundef %2) local_unnamed_addr #0 {
  %4 = shl i32 %2, 6
  %5 = and i32 %4, 448
  %6 = select i1 %1, i32 32, i32 0
  %7 = or disjoint i32 %5, %6
  %8 = getelementptr inbounds i8, ptr %0, i64 38
  %9 = load i16, ptr %8, align 1, !tbaa !5
  %10 = trunc nuw nsw i32 %7 to i16
  %11 = or i16 %9, %10
  %12 = or i16 %11, 3
  store i16 %12, ptr %8, align 1, !tbaa !5
  ret void
}

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: readwrite) 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, !11, i64 38}
!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}


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