; LLVM IR from intel/qpl :: sources/core-iaa/sources/aecs (hw_aecs_decompress)

; 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_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 }
%struct.qplc_huffman_table_flat_format = type { [15 x i16], [15 x i16], [15 x i16], %union.anon.3, i32 }
%union.anon.3 = type { [265 x i16] }

; Function Attrs: nounwind uwtable
define dso_local void @hw_iaa_aecs_decompress_set_huffman_only_huffman_table(ptr noundef %0, ptr noundef %1) #0 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  %5 = load ptr, ptr %3, align 8, !tbaa !5
  call void @call_c_set_zeros_uint8_t(ptr noundef %5, i32 noundef 5376)
  %6 = load ptr, ptr %3, align 8, !tbaa !5
  %7 = getelementptr inbounds %struct.hw_iaa_aecs_decompress, ptr %6, i32 0, i32 12
  %8 = getelementptr inbounds [5 x i32], ptr %7, i64 0, i64 0
  store i32 134217727, ptr %8, align 4, !tbaa !9
  %9 = load ptr, ptr %3, align 8, !tbaa !5
  %10 = getelementptr inbounds %struct.hw_iaa_aecs_decompress, ptr %9, i32 0, i32 12
  %11 = getelementptr inbounds [5 x i32], ptr %10, i64 0, i64 1
  store i32 134217727, ptr %11, align 4, !tbaa !9
  %12 = load ptr, ptr %3, align 8, !tbaa !5
  %13 = getelementptr inbounds %struct.hw_iaa_aecs_decompress, ptr %12, i32 0, i32 12
  %14 = getelementptr inbounds [5 x i32], ptr %13, i64 0, i64 2
  store i32 8388607, ptr %14, align 4, !tbaa !9
  %15 = load ptr, ptr %3, align 8, !tbaa !5
  %16 = getelementptr inbounds %struct.hw_iaa_aecs_decompress, ptr %15, i32 0, i32 12
  %17 = getelementptr inbounds [5 x i32], ptr %16, i64 0, i64 3
  store i32 134217727, ptr %17, align 4, !tbaa !9
  %18 = load ptr, ptr %3, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct.hw_iaa_aecs_decompress, ptr %18, i32 0, i32 12
  %20 = getelementptr inbounds [5 x i32], ptr %19, i64 0, i64 4
  store i32 2147483647, ptr %20, align 4, !tbaa !9
  %21 = load ptr, ptr %3, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.hw_iaa_aecs_decompress, ptr %21, i32 0, i32 10
  %23 = getelementptr inbounds [5 x i32], ptr %22, i64 0, i64 0
  %24 = load ptr, ptr %4, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct.qplc_huffman_table_flat_format, ptr %24, i32 0, i32 0
  %26 = getelementptr inbounds [15 x i16], ptr %25, i64 0, i64 0
  call void @pack_table(ptr noundef %23, ptr noundef %26)
  %27 = load ptr, ptr %3, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct.hw_iaa_aecs_decompress, ptr %27, i32 0, i32 11
  %29 = getelementptr inbounds [5 x i32], ptr %28, i64 0, i64 0
  %30 = load ptr, ptr %4, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct.qplc_huffman_table_flat_format, ptr %30, i32 0, i32 1
  %32 = getelementptr inbounds [15 x i16], ptr %31, i64 0, i64 0
  call void @pack_table(ptr noundef %29, ptr noundef %32)
  %33 = load ptr, ptr %4, align 8, !tbaa !5
  %34 = getelementptr inbounds %struct.qplc_huffman_table_flat_format, ptr %33, i32 0, i32 4
  %35 = load i32, ptr %34, align 4, !tbaa !11
  %36 = icmp eq i32 %35, 0
  br i1 %36, label %37, label %50

37:                                               ; preds = %2
  %38 = load ptr, ptr %3, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.hw_iaa_aecs_decompress, ptr %38, i32 0, i32 9
  %40 = getelementptr inbounds [5 x i32], ptr %39, i64 0, i64 0
  %41 = load ptr, ptr %4, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct.qplc_huffman_table_flat_format, ptr %41, i32 0, i32 2
  %43 = getelementptr inbounds [15 x i16], ptr %42, i64 0, i64 0
  call void @pack_table(ptr noundef %40, ptr noundef %43)
  %44 = load ptr, ptr %4, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct.qplc_huffman_table_flat_format, ptr %44, i32 0, i32 3
  %46 = getelementptr inbounds [257 x i8], ptr %45, i64 0, i64 0
  %47 = load ptr, ptr %3, align 8, !tbaa !5
  %48 = getelementptr inbounds %struct.hw_iaa_aecs_decompress, ptr %47, i32 0, i32 14
  %49 = getelementptr inbounds [268 x i8], ptr %48, i64 0, i64 0
  call void @call_c_copy_uint8_t(ptr noundef %46, ptr noundef %49, i32 noundef 256)
  br label %62

50:                                               ; preds = %2
  %51 = load ptr, ptr %3, align 8, !tbaa !5
  %52 = getelementptr inbounds %struct.hw_iaa_aecs_decompress, ptr %51, i32 0, i32 14
  %53 = getelementptr inbounds %struct.anon, ptr %52, i32 0, i32 1
  %54 = getelementptr inbounds [224 x i8], ptr %53, i64 0, i64 0
  %55 = load ptr, ptr %3, align 8, !tbaa !5
  %56 = getelementptr inbounds %struct.hw_iaa_aecs_decompress, ptr %55, i32 0, i32 17
  %57 = getelementptr inbounds %struct.anon.1, ptr %56, i32 0, i32 1
  %58 = getelementptr inbounds [144 x i8], ptr %57, i64 0, i64 0
  %59 = load ptr, ptr %4, align 8, !tbaa !5
  %60 = getelementptr inbounds %struct.qplc_huffman_table_flat_format, ptr %59, i32 0, i32 3
  %61 = getelementptr inbounds [265 x i16], ptr %60, i64 0, i64 0
  call void @pack_cam(ptr noundef %54, ptr noundef %58, ptr noundef %61)
  br label %62

62:                                               ; preds = %50, %37
  %63 = load ptr, ptr %3, align 8, !tbaa !5
  %64 = load ptr, ptr %4, align 8, !tbaa !5
  %65 = getelementptr inbounds %struct.qplc_huffman_table_flat_format, ptr %64, i32 0, i32 4
  %66 = load i32, ptr %65, align 4, !tbaa !11
  %67 = icmp eq i32 %66, 1
  call void @hw_iaa_aecs_decompress_state_set_aecs_format(ptr noundef %63, i1 noundef zeroext %67)
  ret void
}

declare void @call_c_set_zeros_uint8_t(ptr noundef, i32 noundef) #1

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @pack_table(ptr noundef, ptr noundef) #2

declare void @call_c_copy_uint8_t(ptr noundef, ptr noundef, i32 noundef) #1

; Function Attrs: nounwind uwtable
declare hidden void @pack_cam(ptr noundef, ptr noundef, ptr noundef) #0

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @hw_iaa_aecs_decompress_state_set_aecs_format(ptr noundef, i1 noundef zeroext) #2

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 = { "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 = { inlinehint 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 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !10, i64 620}
!12 = !{!"", !7, i64 0, !7, i64 30, !7, i64 60, !7, i64 90, !10, i64 620}


; 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: nounwind uwtable
define dso_local void @hw_iaa_aecs_decompress_set_huffman_only_huffman_table(ptr noundef %0, ptr noundef %1) local_unnamed_addr #0 {
  tail call void @call_c_set_zeros_uint8_t(ptr noundef %0, i32 noundef 5376) #3
  %3 = getelementptr inbounds i8, ptr %0, i64 372
  store <4 x i32> <i32 134217727, i32 134217727, i32 8388607, i32 134217727>, ptr %3, align 4, !tbaa !5
  %4 = getelementptr inbounds i8, ptr %0, i64 388
  store i32 2147483647, ptr %4, align 4, !tbaa !5
  %5 = getelementptr inbounds i8, ptr %0, i64 332
  tail call void @pack_table(ptr noundef nonnull %5, ptr noundef %1)
  %6 = getelementptr inbounds i8, ptr %0, i64 352
  %7 = getelementptr inbounds i8, ptr %1, i64 30
  tail call void @pack_table(ptr noundef nonnull %6, ptr noundef nonnull %7)
  %8 = getelementptr inbounds i8, ptr %1, i64 620
  %9 = load i32, ptr %8, align 4, !tbaa !9
  %10 = icmp eq i32 %9, 0
  br i1 %10, label %11, label %16

11:                                               ; preds = %2
  %12 = getelementptr inbounds i8, ptr %0, i64 312
  %13 = getelementptr inbounds i8, ptr %1, i64 60
  tail call void @pack_table(ptr noundef nonnull %12, ptr noundef nonnull %13)
  %14 = getelementptr inbounds i8, ptr %1, i64 90
  %15 = getelementptr inbounds i8, ptr %0, i64 640
  tail call void @call_c_copy_uint8_t(ptr noundef nonnull %14, ptr noundef nonnull %15, i32 noundef 256) #3
  br label %20

16:                                               ; preds = %2
  %17 = getelementptr inbounds i8, ptr %0, i64 664
  %18 = getelementptr inbounds i8, ptr %0, i64 920
  %19 = getelementptr inbounds i8, ptr %1, i64 90
  tail call void @pack_cam(ptr noundef nonnull %17, ptr noundef nonnull %18, ptr noundef nonnull %19)
  br label %20

20:                                               ; preds = %16, %11
  %21 = load i32, ptr %8, align 4, !tbaa !9
  %22 = icmp eq i32 %21, 1
  tail call void @hw_iaa_aecs_decompress_state_set_aecs_format(ptr noundef nonnull %0, i1 noundef zeroext %22)
  ret void
}

declare void @call_c_set_zeros_uint8_t(ptr noundef, i32 noundef) local_unnamed_addr #1

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @pack_table(ptr noundef, ptr noundef) local_unnamed_addr #2

declare void @call_c_copy_uint8_t(ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare hidden void @pack_cam(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @hw_iaa_aecs_decompress_state_set_aecs_format(ptr noundef, i1 noundef zeroext) local_unnamed_addr #2

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 = { "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 = { inlinehint 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 #3 = { 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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !6, i64 620}
!10 = !{!"", !7, i64 0, !7, i64 30, !7, i64 60, !7, i64 90, !6, i64 620}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,InstCombinePass,SLPVectorizerPass,SROAPass,TailCallElimPass