; LLVM IR from intel/qpl :: tools/utils/generators/deflate_generator (gen)

; 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.gz_generator::gen_c" = type { %struct.anon, i8, %"class.gz_generator::huffman_c", %"class.gz_generator::grammar_c", %"class.gz_generator::BitBuffer", ptr, i32, [286 x i32], i32, [32 x i32], i32, [19 x i32], i32, [19 x i32], i32, [1024 x i32], i32, [1024 x i32], i32, [19 x i32], i32, i32, i32, i8, [32768 x i8], i32, i32, [3 x i8], i32 }
%struct.anon = type { i8, i8, i8, i8 }
%"class.gz_generator::huffman_c" = type { %class.symbol_list, %class.histogram, [288 x i32], [32 x i32], i8, i8, i8, i32, %"class.std::vector" }
%class.symbol_list = type { ptr, ptr, i32, i32 }
%class.histogram = type { [32768 x i32], [513 x i32], [32 x i32], [286 x i32] }
%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<unsigned int, std::allocator<unsigned int>>::_Vector_impl" }
%"struct.std::_Vector_base<unsigned int, std::allocator<unsigned int>>::_Vector_impl" = type { %"struct.std::_Vector_base<unsigned int, std::allocator<unsigned int>>::_Vector_impl_data" }
%"struct.std::_Vector_base<unsigned int, std::allocator<unsigned int>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"class.gz_generator::grammar_c" = type { %class.token_parser_c, ptr }
%class.token_parser_c = type { ptr, %class.token_c, i8, i32 }
%class.token_c = type { i8, i32 }
%"class.gz_generator::BitBuffer" = type { i8, i32, %struct.anon.0, ptr }
%struct.anon.0 = type { i64, i32 }

@stderr = external global ptr, align 8
@_ZTISt9exception = external constant ptr
@.str.17 = external hidden unnamed_addr constant [48 x i8], align 1
@.str.18 = external hidden unnamed_addr constant [51 x i8], align 1
@.str.19 = external hidden unnamed_addr constant [42 x i8], align 1
@.str.20 = external hidden unnamed_addr constant [26 x i8], align 1
@.str.21 = external hidden unnamed_addr constant [23 x i8], align 1

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_ZN12gz_generator5gen_c8line_numEv(ptr noundef nonnull align 8 dereferenceable(178336)) #0 align 2

; Function Attrs: nounwind
declare i32 @fprintf(ptr noundef, ptr noundef, ...) #1

declare ptr @__cxa_allocate_exception(i64)

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt9exceptionC2Ev(ptr noundef nonnull align 8 dereferenceable(8)) unnamed_addr #2 align 2

; Function Attrs: nounwind
declare void @_ZNSt9exceptionD1Ev(ptr noundef nonnull align 8 dereferenceable(8)) unnamed_addr #1

declare void @__cxa_throw(ptr, ptr, ptr)

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN12gz_generator5gen_c4warnENS0_6warn_tE(ptr noundef nonnull align 8 dereferenceable(178336) %0, i8 noundef zeroext %1) #0 align 2 {
  %3 = alloca ptr, align 8
  %4 = alloca i8, align 1
  store ptr %0, ptr %3, align 8, !tbaa !5
  store i8 %1, ptr %4, align 1, !tbaa !9
  %5 = load ptr, ptr %3, align 8
  %6 = getelementptr inbounds %"class.gz_generator::gen_c", ptr %5, i32 0, i32 27
  %7 = load i8, ptr %4, align 1, !tbaa !9
  %8 = zext i8 %7 to i64
  %9 = getelementptr inbounds [3 x i8], ptr %6, i64 0, i64 %8
  %10 = load i8, ptr %9, align 1, !tbaa !11, !range !13, !noundef !14
  %11 = trunc i8 %10 to i1
  br i1 %11, label %12, label %13

12:                                               ; preds = %2
  br label %37

13:                                               ; preds = %2
  %14 = load i8, ptr %4, align 1, !tbaa !9
  %15 = zext i8 %14 to i32
  switch i32 %15, label %25 [
    i32 0, label %16
    i32 1, label %19
    i32 2, label %22
  ]

16:                                               ; preds = %13
  %17 = load ptr, ptr @stderr, align 8, !tbaa !5
  %18 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %17, ptr noundef @.str.17) #3
  br label %29

19:                                               ; preds = %13
  %20 = load ptr, ptr @stderr, align 8, !tbaa !5
  %21 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %20, ptr noundef @.str.18) #3
  br label %29

22:                                               ; preds = %13
  %23 = load ptr, ptr @stderr, align 8, !tbaa !5
  %24 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %23, ptr noundef @.str.19) #3
  br label %29

25:                                               ; preds = %13
  %26 = load ptr, ptr @stderr, align 8, !tbaa !5
  %27 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %26, ptr noundef @.str.20) #3
  %28 = call ptr @__cxa_allocate_exception(i64 8) #3
  call void @_ZNSt9exceptionC2Ev(ptr noundef nonnull align 8 dereferenceable(8) %28) #3
  call void @__cxa_throw(ptr %28, ptr @_ZTISt9exception, ptr @_ZNSt9exceptionD1Ev) #4
  unreachable

29:                                               ; preds = %22, %19, %16
  %30 = load ptr, ptr @stderr, align 8, !tbaa !5
  %31 = call noundef i32 @_ZN12gz_generator5gen_c8line_numEv(ptr noundef nonnull align 8 dereferenceable(178336) %5)
  %32 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %30, ptr noundef @.str.21, i32 noundef %31) #3
  %33 = getelementptr inbounds %"class.gz_generator::gen_c", ptr %5, i32 0, i32 27
  %34 = load i8, ptr %4, align 1, !tbaa !9
  %35 = zext i8 %34 to i64
  %36 = getelementptr inbounds [3 x i8], ptr %33, i64 0, i64 %35
  store i8 1, ptr %36, align 1, !tbaa !11
  br label %37

37:                                               ; preds = %29, %12
  ret void
}

attributes #0 = { mustprogress 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 = { nounwind "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 = { nounwind }
attributes #4 = { noreturn }

!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, !10, i64 0}
!10 = !{!"_ZTSN12gz_generator5gen_c6warn_tE", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"bool", !7, i64 0}
!13 = !{i8 0, i8 2}
!14 = !{}


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

@stderr = external local_unnamed_addr global ptr, align 8
@_ZTISt9exception = external constant ptr
@.str.17 = external hidden unnamed_addr constant [48 x i8], align 1
@.str.18 = external hidden unnamed_addr constant [51 x i8], align 1
@.str.19 = external hidden unnamed_addr constant [42 x i8], align 1
@.str.20 = external hidden unnamed_addr constant [26 x i8], align 1
@.str.21 = external hidden unnamed_addr constant [23 x i8], align 1
@switch.table._ZN12gz_generator5gen_c4warnENS0_6warn_tE = private unnamed_addr constant [3 x ptr] [ptr @.str.17, ptr @.str.18, ptr @.str.19], align 8

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_ZN12gz_generator5gen_c8line_numEv(ptr noundef nonnull align 8 dereferenceable(178336)) local_unnamed_addr #0 align 2

; Function Attrs: nofree nounwind
declare noundef i32 @fprintf(ptr nocapture noundef, ptr nocapture noundef readonly, ...) local_unnamed_addr #1

declare ptr @__cxa_allocate_exception(i64) local_unnamed_addr

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt9exceptionC2Ev(ptr noundef nonnull align 8 dereferenceable(8)) unnamed_addr #2 align 2

; Function Attrs: nounwind
declare void @_ZNSt9exceptionD1Ev(ptr noundef nonnull align 8 dereferenceable(8)) unnamed_addr #3

declare void @__cxa_throw(ptr, ptr, ptr) local_unnamed_addr

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN12gz_generator5gen_c4warnENS0_6warn_tE(ptr noundef nonnull align 8 dereferenceable(178336) %0, i8 noundef zeroext %1) local_unnamed_addr #0 align 2 {
  %3 = getelementptr inbounds i8, ptr %0, i64 178328
  %4 = zext i8 %1 to i64
  %5 = getelementptr inbounds [3 x i8], ptr %3, i64 0, i64 %4
  %6 = load i8, ptr %5, align 1, !tbaa !5, !range !9, !noundef !10
  %7 = trunc nuw i8 %6 to i1
  br i1 %7, label %19, label %8

8:                                                ; preds = %2
  %9 = load ptr, ptr @stderr, align 8, !tbaa !11
  %10 = icmp ult i8 %1, 3
  br i1 %10, label %switch.lookup, label %11

11:                                               ; preds = %8
  %12 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %9, ptr noundef nonnull @.str.20) #4
  %13 = tail call ptr @__cxa_allocate_exception(i64 8) #5
  tail call void @_ZNSt9exceptionC2Ev(ptr noundef nonnull align 8 dereferenceable(8) %13) #5
  tail call void @__cxa_throw(ptr nonnull %13, ptr nonnull @_ZTISt9exception, ptr nonnull @_ZNSt9exceptionD1Ev) #6
  unreachable

switch.lookup:                                    ; preds = %8
  %14 = zext nneg i8 %1 to i64
  %switch.gep = getelementptr inbounds [3 x ptr], ptr @switch.table._ZN12gz_generator5gen_c4warnENS0_6warn_tE, i64 0, i64 %14
  %switch.load = load ptr, ptr %switch.gep, align 8
  %15 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %9, ptr noundef nonnull %switch.load) #4
  %16 = load ptr, ptr @stderr, align 8, !tbaa !11
  %17 = tail call noundef i32 @_ZN12gz_generator5gen_c8line_numEv(ptr noundef nonnull align 8 dereferenceable(178336) %0)
  %18 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %16, ptr noundef nonnull @.str.21, i32 noundef %17) #4
  store i8 1, ptr %5, align 1, !tbaa !5
  br label %19

19:                                               ; preds = %2, %switch.lookup
  ret void
}

attributes #0 = { mustprogress 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 = { nofree nounwind "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 = { nounwind "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 = { cold nounwind }
attributes #5 = { nounwind }
attributes #6 = { noreturn }

!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 = !{!"bool", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{i8 0, i8 2}
!10 = !{}
!11 = !{!12, !12, i64 0}
!12 = !{!"any pointer", !7, i64 0}


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