; LLVM IR from intel/qpl :: sources/middle-layer/compression/dictionary (dictionary_utils)

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

@_ZN3qpl2ml11compressionL24hardware_hash_table_sizeE = external hidden constant [3 x i32], align 4
@_ZN3qpl2ml11compressionL24software_hash_table_sizeE = external hidden constant [10 x i32], align 16

; 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: mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZN3qpl2ml11compression31get_history_size_for_dictionaryE25hardware_dictionary_level(i8 noundef signext) #1

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef i64 @_ZN3qpl2ml11compression19get_dictionary_sizeE26software_compression_level25hardware_dictionary_levelm(i8 noundef signext %0, i8 noundef signext %1, i64 noundef %2) #1 personality ptr @__gxx_personality_v0 {
  %4 = alloca i8, align 1
  %5 = alloca i8, align 1
  %6 = alloca i64, align 8
  %7 = alloca i64, align 8
  %8 = alloca i64, align 8
  %9 = alloca i64, align 8
  store i8 %0, ptr %4, align 1, !tbaa !5
  store i8 %1, ptr %5, align 1, !tbaa !9
  store i64 %2, ptr %6, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #4
  %10 = load i8, ptr %5, align 1, !tbaa !9
  %11 = call noundef i64 @_ZN3qpl2ml11compression31get_history_size_for_dictionaryE25hardware_dictionary_level(i8 noundef signext %10) #4
  store i64 %11, ptr %7, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #4
  %12 = load i64, ptr %7, align 8, !tbaa !11
  store i64 %12, ptr %8, align 8, !tbaa !11
  %13 = invoke noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3minImERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %6, ptr noundef nonnull align 8 dereferenceable(8) %8)
          to label %14 unwind label %43

14:                                               ; preds = %3
  %15 = load i64, ptr %13, align 8, !tbaa !11
  store i64 %15, ptr %6, align 8, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #4
  %16 = load i64, ptr %6, align 8, !tbaa !11
  %17 = add i64 %16, 40
  store i64 %17, ptr %9, align 8, !tbaa !11
  %18 = load i8, ptr %4, align 1, !tbaa !5
  %19 = icmp ne i8 -1, %18
  br i1 %19, label %20, label %29

20:                                               ; preds = %14
  %21 = load i8, ptr %4, align 1, !tbaa !5
  %22 = sext i8 %21 to i32
  %23 = zext i32 %22 to i64
  %24 = getelementptr inbounds [10 x i32], ptr @_ZN3qpl2ml11compressionL24software_hash_table_sizeE, i64 0, i64 %23
  %25 = load i32, ptr %24, align 4, !tbaa !13
  %26 = zext i32 %25 to i64
  %27 = load i64, ptr %9, align 8, !tbaa !11
  %28 = add i64 %27, %26
  store i64 %28, ptr %9, align 8, !tbaa !11
  br label %29

29:                                               ; preds = %20, %14
  %30 = load i8, ptr %5, align 1, !tbaa !9
  %31 = icmp ne i8 -1, %30
  br i1 %31, label %32, label %41

32:                                               ; preds = %29
  %33 = load i8, ptr %5, align 1, !tbaa !9
  %34 = sext i8 %33 to i32
  %35 = zext i32 %34 to i64
  %36 = getelementptr inbounds [3 x i32], ptr @_ZN3qpl2ml11compressionL24hardware_hash_table_sizeE, i64 0, i64 %35
  %37 = load i32, ptr %36, align 4, !tbaa !13
  %38 = zext i32 %37 to i64
  %39 = load i64, ptr %9, align 8, !tbaa !11
  %40 = add i64 %39, %38
  store i64 %40, ptr %9, align 8, !tbaa !11
  br label %41

41:                                               ; preds = %32, %29
  %42 = load i64, ptr %9, align 8, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #4
  ret i64 %42

43:                                               ; preds = %3
  %44 = landingpad { ptr, i32 }
          catch ptr null
  %45 = extractvalue { ptr, i32 } %44, 0
  call void @__clang_call_terminate(ptr %45) #5
  unreachable
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3minImERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(8)) #2

declare i32 @__gxx_personality_v0(...)

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { inlinehint 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 = { 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 #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 = !{!"_ZTS26software_compression_level", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"_ZTS25hardware_dictionary_level", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"long", !7, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"int", !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"

@_ZN3qpl2ml11compressionL24hardware_hash_table_sizeE = external hidden local_unnamed_addr constant [3 x i32], align 4
@_ZN3qpl2ml11compressionL24software_hash_table_sizeE = external hidden local_unnamed_addr constant [10 x i32], align 16

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZN3qpl2ml11compression31get_history_size_for_dictionaryE25hardware_dictionary_level(i8 noundef signext) local_unnamed_addr #1

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef i64 @_ZN3qpl2ml11compression19get_dictionary_sizeE26software_compression_level25hardware_dictionary_levelm(i8 noundef signext %0, i8 noundef signext %1, i64 noundef %2) local_unnamed_addr #1 personality ptr @__gxx_personality_v0 {
  %4 = alloca i64, align 8
  %5 = alloca i64, align 8
  store i64 %2, ptr %4, align 8, !tbaa !5
  %6 = tail call noundef i64 @_ZN3qpl2ml11compression31get_history_size_for_dictionaryE25hardware_dictionary_level(i8 noundef signext %1) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %5) #3
  store i64 %6, ptr %5, align 8, !tbaa !5
  %7 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3minImERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %4, ptr noundef nonnull align 8 dereferenceable(8) %5)
  %8 = load i64, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #3
  %9 = add i64 %8, 40
  %.not = icmp eq i8 %0, -1
  br i1 %.not, label %17, label %10

10:                                               ; preds = %3
  %11 = sext i8 %0 to i64
  %12 = and i64 %11, 4294967295
  %13 = getelementptr inbounds [10 x i32], ptr @_ZN3qpl2ml11compressionL24software_hash_table_sizeE, i64 0, i64 %12
  %14 = load i32, ptr %13, align 4, !tbaa !9
  %15 = zext i32 %14 to i64
  %16 = add i64 %9, %15
  br label %17

17:                                               ; preds = %10, %3
  %.0 = phi i64 [ %16, %10 ], [ %9, %3 ]
  %.not11 = icmp eq i8 %1, -1
  br i1 %.not11, label %25, label %18

18:                                               ; preds = %17
  %19 = sext i8 %1 to i64
  %20 = and i64 %19, 4294967295
  %21 = getelementptr inbounds [3 x i32], ptr @_ZN3qpl2ml11compressionL24hardware_hash_table_sizeE, i64 0, i64 %20
  %22 = load i32, ptr %21, align 4, !tbaa !9
  %23 = zext i32 %22 to i64
  %24 = add i64 %.0, %23
  br label %25

25:                                               ; preds = %18, %17
  %.1 = phi i64 [ %24, %18 ], [ %.0, %17 ]
  ret i64 %.1
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3minImERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #2

declare i32 @__gxx_personality_v0(...)

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { inlinehint 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 = { 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 = !{!"long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}


; Effective O3 passes: DSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass