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

; 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.token_c = type { i8, i32 }
%"class.gz_generator::grammar_c" = type { %class.token_parser_c, ptr }
%class.token_parser_c = type { ptr, %class.token_c, i8, i32 }

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN12gz_generator9grammar_c12syntax_errorEv(ptr noundef nonnull align 8 dereferenceable(32)) #0 align 2

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

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i8 @_ZN14token_parser_c9get_tokenEP7token_c(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef) #0 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN12gz_generator9grammar_c7parse_rEv(ptr noundef nonnull align 8 dereferenceable(32) %0) #0 align 2 {
  %2 = alloca ptr, align 8
  %3 = alloca %class.token_c, align 4
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i8, align 1
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  %9 = load ptr, ptr %2, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #4
  call void @_ZN7token_cC2Ev(ptr noundef nonnull align 4 dereferenceable(8) %3)
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #4
  store i32 0, ptr %4, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #4
  store i32 0, ptr %5, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 1, ptr %6) #4
  %10 = getelementptr inbounds %"class.gz_generator::grammar_c", ptr %9, i32 0, i32 0
  %11 = call noundef zeroext i8 @_ZN14token_parser_c9get_tokenEP7token_c(ptr noundef nonnull align 8 dereferenceable(24) %10, ptr noundef %3)
  store i8 %11, ptr %6, align 1, !tbaa !11
  br label %12

12:                                               ; preds = %88, %46, %1
  br label %13

13:                                               ; preds = %12
  %14 = load i8, ptr %6, align 1, !tbaa !11
  %15 = zext i8 %14 to i32
  %16 = icmp ne i32 %15, 1
  br i1 %16, label %17, label %18

17:                                               ; preds = %13
  call void @_ZN12gz_generator9grammar_c12syntax_errorEv(ptr noundef nonnull align 8 dereferenceable(32) %9)
  br label %18

18:                                               ; preds = %17, %13
  %19 = call noundef i32 @_ZNK7token_c11get_m_valueEv(ptr noundef nonnull align 4 dereferenceable(8) %3)
  store i32 %19, ptr %4, align 4, !tbaa !9
  %20 = getelementptr inbounds %"class.gz_generator::grammar_c", ptr %9, i32 0, i32 0
  %21 = call noundef zeroext i8 @_ZN14token_parser_c9get_tokenEP7token_c(ptr noundef nonnull align 8 dereferenceable(24) %20, ptr noundef %3)
  store i8 %21, ptr %6, align 1, !tbaa !11
  %22 = load i8, ptr %6, align 1, !tbaa !11
  %23 = zext i8 %22 to i32
  %24 = icmp ne i32 %23, 1
  br i1 %24, label %25, label %26

25:                                               ; preds = %18
  call void @_ZN12gz_generator9grammar_c12syntax_errorEv(ptr noundef nonnull align 8 dereferenceable(32) %9)
  br label %26

26:                                               ; preds = %25, %18
  %27 = call noundef i32 @_ZNK7token_c11get_m_valueEv(ptr noundef nonnull align 4 dereferenceable(8) %3)
  store i32 %27, ptr %5, align 4, !tbaa !9
  %28 = getelementptr inbounds %"class.gz_generator::grammar_c", ptr %9, i32 0, i32 0
  %29 = call noundef zeroext i8 @_ZN14token_parser_c9get_tokenEP7token_c(ptr noundef nonnull align 8 dereferenceable(24) %28, ptr noundef %3)
  store i8 %29, ptr %6, align 1, !tbaa !11
  %30 = load i8, ptr %6, align 1, !tbaa !11
  %31 = zext i8 %30 to i32
  %32 = icmp eq i32 %31, 2
  br i1 %32, label %37, label %33

33:                                               ; preds = %26
  %34 = load i8, ptr %6, align 1, !tbaa !11
  %35 = zext i8 %34 to i32
  %36 = icmp eq i32 %35, 0
  br i1 %36, label %37, label %42

37:                                               ; preds = %33, %26
  %38 = getelementptr inbounds %"class.gz_generator::grammar_c", ptr %9, i32 0, i32 1
  %39 = load ptr, ptr %38, align 8, !tbaa !13
  %40 = load i32, ptr %4, align 4, !tbaa !9
  %41 = load i32, ptr %5, align 4, !tbaa !9
  call void @_ZN12gz_generator5gen_c13proc_len_distEjj(ptr noundef nonnull align 8 dereferenceable(178336) %39, i32 noundef %40, i32 noundef %41)
  store i32 1, ptr %7, align 4
  br label %89

42:                                               ; preds = %33
  %43 = load i8, ptr %6, align 1, !tbaa !11
  %44 = zext i8 %43 to i32
  %45 = icmp eq i32 %44, 1
  br i1 %45, label %46, label %51

46:                                               ; preds = %42
  %47 = getelementptr inbounds %"class.gz_generator::grammar_c", ptr %9, i32 0, i32 1
  %48 = load ptr, ptr %47, align 8, !tbaa !13
  %49 = load i32, ptr %4, align 4, !tbaa !9
  %50 = load i32, ptr %5, align 4, !tbaa !9
  call void @_ZN12gz_generator5gen_c13proc_len_distEjj(ptr noundef nonnull align 8 dereferenceable(178336) %48, i32 noundef %49, i32 noundef %50)
  br label %12, !llvm.loop !18

51:                                               ; preds = %42
  %52 = load i8, ptr %6, align 1, !tbaa !11
  %53 = zext i8 %52 to i32
  %54 = icmp ne i32 %53, 24
  br i1 %54, label %55, label %56

55:                                               ; preds = %51
  call void @_ZN12gz_generator9grammar_c12syntax_errorEv(ptr noundef nonnull align 8 dereferenceable(32) %9)
  br label %56

56:                                               ; preds = %55, %51
  %57 = getelementptr inbounds %"class.gz_generator::grammar_c", ptr %9, i32 0, i32 0
  %58 = call noundef zeroext i8 @_ZN14token_parser_c9get_tokenEP7token_c(ptr noundef nonnull align 8 dereferenceable(24) %57, ptr noundef %3)
  store i8 %58, ptr %6, align 1, !tbaa !11
  %59 = load i8, ptr %6, align 1, !tbaa !11
  %60 = zext i8 %59 to i32
  %61 = icmp ne i32 %60, 1
  br i1 %61, label %62, label %63

62:                                               ; preds = %56
  call void @_ZN12gz_generator9grammar_c12syntax_errorEv(ptr noundef nonnull align 8 dereferenceable(32) %9)
  br label %63

63:                                               ; preds = %62, %56
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #4
  store i32 0, ptr %8, align 4, !tbaa !9
  br label %64

64:                                               ; preds = %74, %63
  %65 = load i32, ptr %8, align 4, !tbaa !9
  %66 = call noundef i32 @_ZNK7token_c11get_m_valueEv(ptr noundef nonnull align 4 dereferenceable(8) %3)
  %67 = icmp ult i32 %65, %66
  br i1 %67, label %69, label %68

68:                                               ; preds = %64
  store i32 4, ptr %7, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #4
  br label %77

69:                                               ; preds = %64
  %70 = getelementptr inbounds %"class.gz_generator::grammar_c", ptr %9, i32 0, i32 1
  %71 = load ptr, ptr %70, align 8, !tbaa !13
  %72 = load i32, ptr %4, align 4, !tbaa !9
  %73 = load i32, ptr %5, align 4, !tbaa !9
  call void @_ZN12gz_generator5gen_c13proc_len_distEjj(ptr noundef nonnull align 8 dereferenceable(178336) %71, i32 noundef %72, i32 noundef %73)
  br label %74

74:                                               ; preds = %69
  %75 = load i32, ptr %8, align 4, !tbaa !9
  %76 = add i32 %75, 1
  store i32 %76, ptr %8, align 4, !tbaa !9
  br label %64, !llvm.loop !20

77:                                               ; preds = %68
  %78 = getelementptr inbounds %"class.gz_generator::grammar_c", ptr %9, i32 0, i32 0
  %79 = call noundef zeroext i8 @_ZN14token_parser_c9get_tokenEP7token_c(ptr noundef nonnull align 8 dereferenceable(24) %78, ptr noundef %3)
  store i8 %79, ptr %6, align 1, !tbaa !11
  %80 = load i8, ptr %6, align 1, !tbaa !11
  %81 = zext i8 %80 to i32
  %82 = icmp eq i32 %81, 2
  br i1 %82, label %87, label %83

83:                                               ; preds = %77
  %84 = load i8, ptr %6, align 1, !tbaa !11
  %85 = zext i8 %84 to i32
  %86 = icmp eq i32 %85, 0
  br i1 %86, label %87, label %88

87:                                               ; preds = %83, %77
  store i32 1, ptr %7, align 4
  br label %89

88:                                               ; preds = %83
  br label %12, !llvm.loop !18

89:                                               ; preds = %87, %37
  call void @llvm.lifetime.end.p0(i64 1, ptr %6) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #4
  ret void
}

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK7token_c11get_m_valueEv(ptr noundef nonnull align 4 dereferenceable(8)) #2 align 2

declare void @_ZN12gz_generator5gen_c13proc_len_distEjj(ptr noundef nonnull align 8 dereferenceable(178336), i32 noundef, i32 noundef) #3

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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 }

!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 = !{!"int", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"_ZTS12token_type_t", !7, i64 0}
!13 = !{!14, !6, i64 24}
!14 = !{!"_ZTSN12gz_generator9grammar_cE", !15, i64 0, !6, i64 24}
!15 = !{!"_ZTS14token_parser_c", !6, i64 0, !16, i64 8, !17, i64 16, !10, i64 20}
!16 = !{!"_ZTS7token_c", !12, i64 0, !10, i64 4}
!17 = !{!"bool", !7, i64 0}
!18 = distinct !{!18, !19}
!19 = !{!"llvm.loop.mustprogress"}
!20 = distinct !{!20, !19}


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

%class.token_c = type { i8, i32 }

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN12gz_generator9grammar_c12syntax_errorEv(ptr noundef nonnull align 8 dereferenceable(32)) local_unnamed_addr #0 align 2

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

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i8 @_ZN14token_parser_c9get_tokenEP7token_c(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN12gz_generator9grammar_c7parse_rEv(ptr noundef nonnull align 8 dereferenceable(32) %0) local_unnamed_addr #0 align 2 {
  %2 = alloca %class.token_c, align 4
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %2) #4
  call void @_ZN7token_cC2Ev(ptr noundef nonnull align 4 dereferenceable(8) %2)
  %3 = call noundef zeroext i8 @_ZN14token_parser_c9get_tokenEP7token_c(ptr noundef nonnull align 8 dereferenceable(24) %0, ptr noundef nonnull %2)
  %4 = getelementptr inbounds i8, ptr %0, i64 24
  br label %.backedge

.backedge:                                        ; preds = %.backedge.backedge, %1
  %.022 = phi i8 [ %3, %1 ], [ %.022.be, %.backedge.backedge ]
  %.not = icmp eq i8 %.022, 1
  br i1 %.not, label %6, label %5

5:                                                ; preds = %.backedge
  call void @_ZN12gz_generator9grammar_c12syntax_errorEv(ptr noundef nonnull align 8 dereferenceable(32) %0)
  br label %6

6:                                                ; preds = %5, %.backedge
  %7 = call noundef i32 @_ZNK7token_c11get_m_valueEv(ptr noundef nonnull align 4 dereferenceable(8) %2)
  %8 = call noundef zeroext i8 @_ZN14token_parser_c9get_tokenEP7token_c(ptr noundef nonnull align 8 dereferenceable(24) %0, ptr noundef nonnull %2)
  %.not24 = icmp eq i8 %8, 1
  br i1 %.not24, label %10, label %9

9:                                                ; preds = %6
  call void @_ZN12gz_generator9grammar_c12syntax_errorEv(ptr noundef nonnull align 8 dereferenceable(32) %0)
  br label %10

10:                                               ; preds = %9, %6
  %11 = call noundef i32 @_ZNK7token_c11get_m_valueEv(ptr noundef nonnull align 4 dereferenceable(8) %2)
  %12 = call noundef zeroext i8 @_ZN14token_parser_c9get_tokenEP7token_c(ptr noundef nonnull align 8 dereferenceable(24) %0, ptr noundef nonnull %2)
  %13 = and i8 %12, -3
  %or.cond = icmp eq i8 %13, 0
  br i1 %or.cond, label %14, label %16

14:                                               ; preds = %10
  %15 = load ptr, ptr %4, align 8, !tbaa !5
  call void @_ZN12gz_generator5gen_c13proc_len_distEjj(ptr noundef nonnull align 8 dereferenceable(178336) %15, i32 noundef %7, i32 noundef %11)
  br label %.loopexit

16:                                               ; preds = %10
  switch i8 %12, label %19 [
    i8 1, label %17
    i8 24, label %20
  ]

17:                                               ; preds = %16
  %18 = load ptr, ptr %4, align 8, !tbaa !5
  call void @_ZN12gz_generator5gen_c13proc_len_distEjj(ptr noundef nonnull align 8 dereferenceable(178336) %18, i32 noundef %7, i32 noundef %11)
  br label %.backedge.backedge

.backedge.backedge:                               ; preds = %17, %._crit_edge
  %.022.be = phi i8 [ 1, %17 ], [ %25, %._crit_edge ]
  br label %.backedge, !llvm.loop !15

19:                                               ; preds = %16
  call void @_ZN12gz_generator9grammar_c12syntax_errorEv(ptr noundef nonnull align 8 dereferenceable(32) %0)
  br label %20

20:                                               ; preds = %16, %19
  %21 = call noundef zeroext i8 @_ZN14token_parser_c9get_tokenEP7token_c(ptr noundef nonnull align 8 dereferenceable(24) %0, ptr noundef nonnull %2)
  %.not26 = icmp eq i8 %21, 1
  br i1 %.not26, label %23, label %22

22:                                               ; preds = %20
  call void @_ZN12gz_generator9grammar_c12syntax_errorEv(ptr noundef nonnull align 8 dereferenceable(32) %0)
  br label %23

23:                                               ; preds = %22, %20
  %24 = call noundef i32 @_ZNK7token_c11get_m_valueEv(ptr noundef nonnull align 4 dereferenceable(8) %2)
  %.not31 = icmp eq i32 %24, 0
  br i1 %.not31, label %._crit_edge, label %.lr.ph

._crit_edge:                                      ; preds = %.lr.ph, %23
  %25 = call noundef zeroext i8 @_ZN14token_parser_c9get_tokenEP7token_c(ptr noundef nonnull align 8 dereferenceable(24) %0, ptr noundef nonnull %2)
  %26 = and i8 %25, -3
  %or.cond5 = icmp eq i8 %26, 0
  br i1 %or.cond5, label %.loopexit, label %.backedge.backedge

.lr.ph:                                           ; preds = %23, %.lr.ph
  %.030 = phi i32 [ %28, %.lr.ph ], [ 0, %23 ]
  %27 = load ptr, ptr %4, align 8, !tbaa !5
  call void @_ZN12gz_generator5gen_c13proc_len_distEjj(ptr noundef nonnull align 8 dereferenceable(178336) %27, i32 noundef %7, i32 noundef %11)
  %28 = add nuw i32 %.030, 1
  %29 = call noundef i32 @_ZNK7token_c11get_m_valueEv(ptr noundef nonnull align 4 dereferenceable(8) %2)
  %30 = icmp ult i32 %28, %29
  br i1 %30, label %.lr.ph, label %._crit_edge, !llvm.loop !17

.loopexit:                                        ; preds = %._crit_edge, %14
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #4
  ret void
}

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK7token_c11get_m_valueEv(ptr noundef nonnull align 4 dereferenceable(8)) local_unnamed_addr #2 align 2

declare void @_ZN12gz_generator5gen_c13proc_len_distEjj(ptr noundef nonnull align 8 dereferenceable(178336), i32 noundef, i32 noundef) local_unnamed_addr #3

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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 }

!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, !8, i64 24}
!6 = !{!"_ZTSN12gz_generator9grammar_cE", !7, i64 0, !8, i64 24}
!7 = !{!"_ZTS14token_parser_c", !8, i64 0, !11, i64 8, !14, i64 16, !13, i64 20}
!8 = !{!"any pointer", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C++ TBAA"}
!11 = !{!"_ZTS7token_c", !12, i64 0, !13, i64 4}
!12 = !{!"_ZTS12token_type_t", !9, i64 0}
!13 = !{!"int", !9, i64 0}
!14 = !{!"bool", !9, i64 0}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}
!17 = distinct !{!17, !16}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass