; 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: nounwind uwtable
define dso_local void @hw_iaa_descriptor_inflate_set_aecs(ptr noundef %0, ptr noundef %1, i32 noundef %2, i32 noundef %3) #0 {
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca ptr, align 8
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca i8, align 1
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store i32 %2, ptr %7, align 4, !tbaa !9
  store i32 %3, ptr %8, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #2
  %14 = load ptr, ptr %5, align 8, !tbaa !5
  store ptr %14, ptr %9, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #2
  %15 = load i32, ptr %8, align 4, !tbaa !9
  %16 = and i32 %15, 16
  %17 = icmp ne i32 %16, 0
  %18 = zext i1 %17 to i64
  %19 = select i1 %17, i32 65536, i32 0
  store i32 %19, ptr %10, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #2
  store i32 0, ptr %11, align 4, !tbaa !9
  %20 = load i32, ptr %8, align 4, !tbaa !9
  %21 = and i32 %20, 256
  %22 = icmp ne i32 %21, 0
  br i1 %22, label %23, label %24

23:                                               ; preds = %4
  store i32 262144, ptr %11, align 4, !tbaa !9
  br label %30

24:                                               ; preds = %4
  %25 = load i32, ptr %8, align 4, !tbaa !9
  %26 = and i32 %25, 512
  %27 = icmp ne i32 %26, 0
  br i1 %27, label %28, label %29

28:                                               ; preds = %24
  store i32 524288, ptr %11, align 4, !tbaa !9
  br label %29

29:                                               ; preds = %28, %24
  br label %30

30:                                               ; preds = %29, %23
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #2
  %31 = load i32, ptr %8, align 4, !tbaa !9
  %32 = and i32 %31, 1
  %33 = icmp ne i32 %32, 0
  %34 = zext i1 %33 to i64
  %35 = select i1 %33, i32 4194304, i32 0
  store i32 %35, ptr %12, align 4, !tbaa !9
  %36 = load i32, ptr %10, align 4, !tbaa !9
  %37 = load i32, ptr %11, align 4, !tbaa !9
  %38 = or i32 %36, %37
  %39 = load i32, ptr %12, align 4, !tbaa !9
  %40 = or i32 %38, %39
  %41 = load ptr, ptr %9, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct.hw_decompress_analytics_descriptor, ptr %41, i32 0, i32 1
  %43 = load i32, ptr %42, align 1, !tbaa !11
  %44 = or i32 %43, %40
  store i32 %44, ptr %42, align 1, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 1, ptr %13) #2
  %45 = load i32, ptr %8, align 4, !tbaa !9
  %46 = and i32 %45, 512
  %47 = icmp ne i32 %46, 0
  %48 = zext i1 %47 to i8
  store i8 %48, ptr %13, align 1, !tbaa !14
  %49 = load ptr, ptr %6, align 8, !tbaa !5
  %50 = load ptr, ptr %9, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct.hw_decompress_analytics_descriptor, ptr %50, i32 0, i32 8
  store ptr %49, ptr %51, align 1, !tbaa !16
  %52 = load i32, ptr %7, align 4, !tbaa !9
  %53 = load ptr, ptr %9, align 8, !tbaa !5
  %54 = getelementptr inbounds %struct.hw_decompress_analytics_descriptor, ptr %53, i32 0, i32 10
  store i32 %52, ptr %54, align 1, !tbaa !17
  %55 = load i8, ptr %13, align 1, !tbaa !14, !range !18, !noundef !19
  %56 = trunc i8 %55 to i1
  br i1 %56, label %57, label %64

57:                                               ; preds = %30
  %58 = load ptr, ptr %9, align 8, !tbaa !5
  %59 = getelementptr inbounds %struct.hw_decompress_analytics_descriptor, ptr %58, i32 0, i32 7
  %60 = load i16, ptr %59, align 1, !tbaa !20
  %61 = zext i16 %60 to i32
  %62 = or i32 %61, 2
  %63 = trunc i32 %62 to i16
  store i16 %63, ptr %59, align 1, !tbaa !20
  br label %64

64:                                               ; preds = %57, %30
  call void @llvm.lifetime.end.p0(i64 1, ptr %13) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #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 = !{!"int", !7, i64 0}
!11 = !{!12, !10, i64 4}
!12 = !{!"", !10, i64 0, !10, i64 4, !6, i64 8, !6, i64 16, !6, i64 24, !10, i64 32, !13, i64 36, !13, i64 38, !6, i64 40, !10, i64 48, !10, i64 52, !10, i64 56, !10, i64 60}
!13 = !{!"short", !7, i64 0}
!14 = !{!15, !15, i64 0}
!15 = !{!"_Bool", !7, i64 0}
!16 = !{!12, !6, i64 40}
!17 = !{!12, !10, i64 52}
!18 = !{i8 0, i8 2}
!19 = !{}
!20 = !{!12, !13, i64 38}


; 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_inflate_set_aecs(ptr nocapture noundef %0, ptr noundef %1, i32 noundef %2, i32 noundef %3) local_unnamed_addr #0 {
  %5 = shl i32 %3, 12
  %6 = and i32 %5, 65536
  %7 = and i32 %3, 256
  %.not = icmp eq i32 %7, 0
  %8 = and i32 %3, 512
  %.not15 = icmp eq i32 %8, 0
  %spec.select = shl nuw nsw i32 %8, 10
  %.0 = select i1 %.not, i32 %spec.select, i32 262144
  %9 = shl i32 %3, 22
  %10 = and i32 %9, 4194304
  %11 = getelementptr inbounds i8, ptr %0, i64 4
  %12 = load i32, ptr %11, align 1, !tbaa !5
  %13 = or disjoint i32 %10, %6
  %14 = or disjoint i32 %13, %.0
  %15 = or i32 %14, %12
  store i32 %15, ptr %11, align 1, !tbaa !5
  %16 = getelementptr inbounds i8, ptr %0, i64 40
  store ptr %1, ptr %16, align 1, !tbaa !12
  %17 = getelementptr inbounds i8, ptr %0, i64 52
  store i32 %2, ptr %17, align 1, !tbaa !13
  br i1 %.not15, label %22, label %18

18:                                               ; preds = %4
  %19 = getelementptr inbounds i8, ptr %0, i64 38
  %20 = load i16, ptr %19, align 1, !tbaa !14
  %21 = or i16 %20, 2
  store i16 %21, ptr %19, align 1, !tbaa !14
  br label %22

22:                                               ; preds = %18, %4
  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, !7, i64 4}
!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, !10, i64 40}
!13 = !{!6, !7, i64 52}
!14 = !{!6, !11, i64 38}


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