; LLVM IR from intel/qpl :: sources/middle-layer/compression/deflate/compression_units (icf_units)

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

%"class.qpl::ml::compression::deflate_state" = type { %"class.qpl::ml::compression::compression_stream.base", ptr, ptr, %"class.qpl::ml::compression::huffman_table_icf", %struct.deflate_hash_table_t, %"class.qpl::ml::compression::index_table_t", i8, i8, ptr, i8, ptr, i32, i32, i32, i8, ptr, ptr }
%"class.qpl::ml::compression::compression_stream.base" = type <{ ptr, %"struct.qpl::ml::util::checksum_accumulator", i8, i8, %"struct.qpl::ml::compression::chunk_type", i32, i32 }>
%"struct.qpl::ml::util::checksum_accumulator" = type { i32, i32 }
%"struct.qpl::ml::compression::chunk_type" = type { i8, i8 }
%"class.qpl::ml::compression::huffman_table_icf" = type { ptr, i32, i32 }
%struct.deflate_hash_table_t = type { ptr, ptr, i32, i32, i32, i32, i32 }
%"class.qpl::ml::compression::index_table_t" = type <{ ptr, i32, i32, i32, [4 x i8] }>
%struct.isal_zstream = type { ptr, i32, i32, ptr, i32, i32, ptr, i32, i32, ptr, i16, i16, i16, i16, %struct.isal_zstate }
%struct.isal_zstate = type { i32, i32, i32, i32, i32, i32, %struct.BitBuf2, i32, i8, i8, i8, i8, i16, i32, [16 x i8], i32, i32, i32, i32, [65824 x i8], [8192 x i16] }
%struct.BitBuf2 = type { i64, i32, ptr, ptr, ptr }

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

declare i32 @__gxx_personality_v0(...)

; Function Attrs: noinline noreturn nounwind uwtable
declare hidden void @__clang_call_terminate(ptr noundef) #1

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

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef i32 @_ZN3qpl2ml11compression18deflate_icf_finishERNS1_13deflate_stateILNS0_16execution_path_tE2EEERNS1_19compression_state_tE(ptr noundef nonnull align 8 dereferenceable(192) %0, ptr noundef nonnull align 1 dereferenceable(1) %1) #2 personality ptr @__gxx_personality_v0 {
  %3 = alloca i32, align 4
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #4
  %8 = load ptr, ptr %4, align 8, !tbaa !5
  %9 = getelementptr inbounds %"class.qpl::ml::compression::deflate_state", ptr %8, i32 0, i32 1
  %10 = load ptr, ptr %9, align 8, !tbaa !9
  %11 = getelementptr inbounds %struct.isal_zstream, ptr %10, i32 0, i32 14
  store ptr %11, ptr %6, align 8, !tbaa !5
  %12 = load ptr, ptr %6, align 8, !tbaa !5
  %13 = getelementptr inbounds %struct.isal_zstate, ptr %12, i32 0, i32 5
  store i32 4, ptr %13, align 4, !tbaa !23
  %14 = load ptr, ptr %4, align 8, !tbaa !5
  %15 = getelementptr inbounds %"class.qpl::ml::compression::deflate_state", ptr %14, i32 0, i32 1
  %16 = load ptr, ptr %15, align 8, !tbaa !9
  invoke void @qpl_isal_deflate_icf_finish_lvl3(ptr noundef %16)
          to label %17 unwind label %27

17:                                               ; preds = %2
  %18 = load ptr, ptr %6, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct.isal_zstate, ptr %18, i32 0, i32 5
  %20 = load i32, ptr %19, align 4, !tbaa !23
  %21 = icmp eq i32 %20, 2
  br i1 %21, label %22, label %24

22:                                               ; preds = %17
  %23 = load ptr, ptr %5, align 8, !tbaa !5
  store i8 5, ptr %23, align 1, !tbaa !29
  store i32 0, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %25

24:                                               ; preds = %17
  store i32 2, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %25

25:                                               ; preds = %24, %22
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #4
  %26 = load i32, ptr %3, align 4
  ret i32 %26

27:                                               ; preds = %2
  %28 = landingpad { ptr, i32 }
          catch ptr null
  %29 = extractvalue { ptr, i32 } %28, 0
  call void @__clang_call_terminate(ptr %29) #5
  unreachable
}

declare void @qpl_isal_deflate_icf_finish_lvl3(ptr noundef) #3

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { noinline noreturn nounwind uwtable "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 = { mustprogress 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 = { "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 #4 = { nounwind }
attributes #5 = { noreturn 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++ TBAA"}
!9 = !{!10, !6, i64 32}
!10 = !{!"_ZTSN3qpl2ml11compression13deflate_stateILNS0_16execution_path_tE2EEE", !11, i64 0, !6, i64 32, !6, i64 40, !18, i64 48, !19, i64 64, !20, i64 104, !21, i64 128, !22, i64 129, !6, i64 136, !17, i64 144, !6, i64 152, !13, i64 160, !13, i64 164, !13, i64 168, !17, i64 172, !6, i64 176, !6, i64 184}
!11 = !{!"_ZTSN3qpl2ml11compression18compression_streamE", !12, i64 8, !14, i64 16, !15, i64 17, !16, i64 18, !13, i64 20, !13, i64 24}
!12 = !{!"_ZTSN3qpl2ml4util20checksum_accumulatorE", !13, i64 0, !13, i64 4}
!13 = !{!"int", !7, i64 0}
!14 = !{!"_ZTSN3qpl2ml11compression18compression_mode_tE", !7, i64 0}
!15 = !{!"_ZTSN3qpl2ml11compression17mini_block_size_tE", !7, i64 0}
!16 = !{!"_ZTSN3qpl2ml11compression10chunk_typeE", !17, i64 0, !17, i64 1}
!17 = !{!"bool", !7, i64 0}
!18 = !{!"_ZTSN3qpl2ml11compression17huffman_table_icfE", !6, i64 0, !13, i64 8, !13, i64 12}
!19 = !{!"_ZTS20deflate_hash_table_t", !6, i64 0, !6, i64 8, !13, i64 16, !13, i64 20, !13, i64 24, !13, i64 28, !13, i64 32}
!20 = !{!"_ZTSN3qpl2ml11compression13index_table_tE", !6, i64 0, !13, i64 8, !13, i64 12, !13, i64 16}
!21 = !{!"_ZTSN3qpl2ml11compression19compression_level_tE", !7, i64 0}
!22 = !{!"_ZTSN3qpl2ml11compression20dictionary_support_tE", !7, i64 0}
!23 = !{!24, !25, i64 20}
!24 = !{!"_ZTS11isal_zstate", !13, i64 0, !13, i64 4, !13, i64 8, !13, i64 12, !13, i64 16, !25, i64 20, !26, i64 24, !13, i64 64, !7, i64 68, !7, i64 69, !7, i64 70, !7, i64 71, !28, i64 72, !13, i64 76, !7, i64 80, !13, i64 96, !13, i64 100, !13, i64 104, !13, i64 108, !7, i64 112, !7, i64 65936}
!25 = !{!"_ZTS17isal_zstate_state", !7, i64 0}
!26 = !{!"_ZTS7BitBuf2", !27, i64 0, !13, i64 8, !6, i64 16, !6, i64 24, !6, i64 32}
!27 = !{!"long", !7, i64 0}
!28 = !{!"short", !7, i64 0}
!29 = !{!30, !30, i64 0}
!30 = !{!"_ZTSN3qpl2ml11compression19compression_state_tE", !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"

declare i32 @__gxx_personality_v0(...)

; Function Attrs: noinline noreturn nounwind uwtable
declare hidden void @__clang_call_terminate(ptr noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef range(i32 0, 3) i32 @_ZN3qpl2ml11compression18deflate_icf_finishERNS1_13deflate_stateILNS0_16execution_path_tE2EEERNS1_19compression_state_tE(ptr nocapture noundef nonnull readonly align 8 dereferenceable(192) %0, ptr nocapture noundef nonnull writeonly align 1 dereferenceable(1) %1) local_unnamed_addr #1 personality ptr @__gxx_personality_v0 {
  %3 = getelementptr inbounds i8, ptr %0, i64 32
  %4 = load ptr, ptr %3, align 8, !tbaa !5
  %5 = getelementptr inbounds i8, ptr %4, i64 84
  store i32 4, ptr %5, align 4, !tbaa !22
  invoke void @qpl_isal_deflate_icf_finish_lvl3(ptr noundef nonnull %4)
          to label %6 unwind label %11

6:                                                ; preds = %2
  %7 = load i32, ptr %5, align 4, !tbaa !22
  %8 = icmp eq i32 %7, 2
  br i1 %8, label %9, label %10

9:                                                ; preds = %6
  store i8 5, ptr %1, align 1, !tbaa !28
  br label %10

10:                                               ; preds = %6, %9
  %.0 = phi i32 [ 0, %9 ], [ 2, %6 ]
  ret i32 %.0

11:                                               ; preds = %2
  %12 = landingpad { ptr, i32 }
          catch ptr null
  %13 = extractvalue { ptr, i32 } %12, 0
  tail call void @__clang_call_terminate(ptr %13) #3
  unreachable
}

declare void @qpl_isal_deflate_icf_finish_lvl3(ptr noundef) local_unnamed_addr #2

attributes #0 = { noinline noreturn nounwind uwtable "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 = { mustprogress 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 = { "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 = { noreturn 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, !16, i64 32}
!6 = !{!"_ZTSN3qpl2ml11compression13deflate_stateILNS0_16execution_path_tE2EEE", !7, i64 0, !16, i64 32, !16, i64 40, !17, i64 48, !18, i64 64, !19, i64 104, !20, i64 128, !21, i64 129, !16, i64 136, !15, i64 144, !16, i64 152, !9, i64 160, !9, i64 164, !9, i64 168, !15, i64 172, !16, i64 176, !16, i64 184}
!7 = !{!"_ZTSN3qpl2ml11compression18compression_streamE", !8, i64 8, !12, i64 16, !13, i64 17, !14, i64 18, !9, i64 20, !9, i64 24}
!8 = !{!"_ZTSN3qpl2ml4util20checksum_accumulatorE", !9, i64 0, !9, i64 4}
!9 = !{!"int", !10, i64 0}
!10 = !{!"omnipotent char", !11, i64 0}
!11 = !{!"Simple C++ TBAA"}
!12 = !{!"_ZTSN3qpl2ml11compression18compression_mode_tE", !10, i64 0}
!13 = !{!"_ZTSN3qpl2ml11compression17mini_block_size_tE", !10, i64 0}
!14 = !{!"_ZTSN3qpl2ml11compression10chunk_typeE", !15, i64 0, !15, i64 1}
!15 = !{!"bool", !10, i64 0}
!16 = !{!"any pointer", !10, i64 0}
!17 = !{!"_ZTSN3qpl2ml11compression17huffman_table_icfE", !16, i64 0, !9, i64 8, !9, i64 12}
!18 = !{!"_ZTS20deflate_hash_table_t", !16, i64 0, !16, i64 8, !9, i64 16, !9, i64 20, !9, i64 24, !9, i64 28, !9, i64 32}
!19 = !{!"_ZTSN3qpl2ml11compression13index_table_tE", !16, i64 0, !9, i64 8, !9, i64 12, !9, i64 16}
!20 = !{!"_ZTSN3qpl2ml11compression19compression_level_tE", !10, i64 0}
!21 = !{!"_ZTSN3qpl2ml11compression20dictionary_support_tE", !10, i64 0}
!22 = !{!23, !24, i64 20}
!23 = !{!"_ZTS11isal_zstate", !9, i64 0, !9, i64 4, !9, i64 8, !9, i64 12, !9, i64 16, !24, i64 20, !25, i64 24, !9, i64 64, !10, i64 68, !10, i64 69, !10, i64 70, !10, i64 71, !27, i64 72, !9, i64 76, !10, i64 80, !9, i64 96, !9, i64 100, !9, i64 104, !9, i64 108, !10, i64 112, !10, i64 65936}
!24 = !{!"_ZTS17isal_zstate_state", !10, i64 0}
!25 = !{!"_ZTS7BitBuf2", !26, i64 0, !9, i64 8, !16, i64 16, !16, i64 24, !16, i64 32}
!26 = !{!"long", !10, i64 0}
!27 = !{!"short", !10, i64 0}
!28 = !{!29, !29, i64 0}
!29 = !{!"_ZTSN3qpl2ml11compression19compression_state_tE", !10, i64 0}


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