; 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_lEv(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 i8, align 1
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  %8 = 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 1, ptr %5) #4
  %9 = getelementptr inbounds %"class.gz_generator::grammar_c", ptr %8, i32 0, i32 0
  %10 = call noundef zeroext i8 @_ZN14token_parser_c9get_tokenEP7token_c(ptr noundef nonnull align 8 dereferenceable(24) %9, ptr noundef %3)
  store i8 %10, ptr %5, align 1, !tbaa !11
  br label %11

11:                                               ; preds = %76, %36, %1
  br label %12

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

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

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

24:                                               ; preds = %17
  %25 = load i8, ptr %5, align 1, !tbaa !11
  %26 = zext i8 %25 to i32
  %27 = icmp eq i32 %26, 0
  br i1 %27, label %28, label %32

28:                                               ; preds = %24, %17
  %29 = getelementptr inbounds %"class.gz_generator::grammar_c", ptr %8, i32 0, i32 1
  %30 = load ptr, ptr %29, align 8, !tbaa !13
  %31 = load i32, ptr %4, align 4, !tbaa !9
  call void @_ZN12gz_generator5gen_c8proc_litEi(ptr noundef nonnull align 8 dereferenceable(178336) %30, i32 noundef %31)
  store i32 1, ptr %6, align 4
  br label %77

32:                                               ; preds = %24
  %33 = load i8, ptr %5, align 1, !tbaa !11
  %34 = zext i8 %33 to i32
  %35 = icmp eq i32 %34, 1
  br i1 %35, label %36, label %40

36:                                               ; preds = %32
  %37 = getelementptr inbounds %"class.gz_generator::grammar_c", ptr %8, i32 0, i32 1
  %38 = load ptr, ptr %37, align 8, !tbaa !13
  %39 = load i32, ptr %4, align 4, !tbaa !9
  call void @_ZN12gz_generator5gen_c8proc_litEi(ptr noundef nonnull align 8 dereferenceable(178336) %38, i32 noundef %39)
  br label %11, !llvm.loop !18

40:                                               ; preds = %32
  %41 = load i8, ptr %5, align 1, !tbaa !11
  %42 = zext i8 %41 to i32
  %43 = icmp ne i32 %42, 24
  br i1 %43, label %44, label %45

44:                                               ; preds = %40
  call void @_ZN12gz_generator9grammar_c12syntax_errorEv(ptr noundef nonnull align 8 dereferenceable(32) %8)
  br label %45

45:                                               ; preds = %44, %40
  %46 = getelementptr inbounds %"class.gz_generator::grammar_c", ptr %8, i32 0, i32 0
  %47 = call noundef zeroext i8 @_ZN14token_parser_c9get_tokenEP7token_c(ptr noundef nonnull align 8 dereferenceable(24) %46, ptr noundef %3)
  store i8 %47, ptr %5, align 1, !tbaa !11
  %48 = load i8, ptr %5, align 1, !tbaa !11
  %49 = zext i8 %48 to i32
  %50 = icmp ne i32 %49, 1
  br i1 %50, label %51, label %52

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

52:                                               ; preds = %51, %45
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #4
  store i32 0, ptr %7, align 4, !tbaa !9
  br label %53

53:                                               ; preds = %62, %52
  %54 = load i32, ptr %7, align 4, !tbaa !9
  %55 = call noundef i32 @_ZNK7token_c11get_m_valueEv(ptr noundef nonnull align 4 dereferenceable(8) %3)
  %56 = icmp ult i32 %54, %55
  br i1 %56, label %58, label %57

57:                                               ; preds = %53
  store i32 4, ptr %6, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  br label %65

58:                                               ; preds = %53
  %59 = getelementptr inbounds %"class.gz_generator::grammar_c", ptr %8, i32 0, i32 1
  %60 = load ptr, ptr %59, align 8, !tbaa !13
  %61 = load i32, ptr %4, align 4, !tbaa !9
  call void @_ZN12gz_generator5gen_c8proc_litEi(ptr noundef nonnull align 8 dereferenceable(178336) %60, i32 noundef %61)
  br label %62

62:                                               ; preds = %58
  %63 = load i32, ptr %7, align 4, !tbaa !9
  %64 = add i32 %63, 1
  store i32 %64, ptr %7, align 4, !tbaa !9
  br label %53, !llvm.loop !20

65:                                               ; preds = %57
  %66 = getelementptr inbounds %"class.gz_generator::grammar_c", ptr %8, i32 0, i32 0
  %67 = call noundef zeroext i8 @_ZN14token_parser_c9get_tokenEP7token_c(ptr noundef nonnull align 8 dereferenceable(24) %66, ptr noundef %3)
  store i8 %67, ptr %5, align 1, !tbaa !11
  %68 = load i8, ptr %5, align 1, !tbaa !11
  %69 = zext i8 %68 to i32
  %70 = icmp eq i32 %69, 2
  br i1 %70, label %75, label %71

71:                                               ; preds = %65
  %72 = load i8, ptr %5, align 1, !tbaa !11
  %73 = zext i8 %72 to i32
  %74 = icmp eq i32 %73, 0
  br i1 %74, label %75, label %76

75:                                               ; preds = %71, %65
  store i32 1, ptr %6, align 4
  br label %77

76:                                               ; preds = %71
  br label %11, !llvm.loop !18

77:                                               ; preds = %75, %28
  call void @llvm.lifetime.end.p0(i64 1, 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_c8proc_litEi(ptr noundef nonnull align 8 dereferenceable(178336), 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_lEv(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
  %.018 = phi i8 [ %3, %1 ], [ %.018.be, %.backedge.backedge ]
  %.not = icmp eq i8 %.018, 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)
  %9 = and i8 %8, -3
  %or.cond = icmp eq i8 %9, 0
  br i1 %or.cond, label %10, label %12

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

12:                                               ; preds = %6
  switch i8 %8, label %15 [
    i8 1, label %13
    i8 24, label %16
  ]

13:                                               ; preds = %12
  %14 = load ptr, ptr %4, align 8, !tbaa !5
  call void @_ZN12gz_generator5gen_c8proc_litEi(ptr noundef nonnull align 8 dereferenceable(178336) %14, i32 noundef %7)
  br label %.backedge.backedge

.backedge.backedge:                               ; preds = %13, %._crit_edge
  %.018.be = phi i8 [ 1, %13 ], [ %21, %._crit_edge ]
  br label %.backedge, !llvm.loop !15

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

16:                                               ; preds = %12, %15
  %17 = call noundef zeroext i8 @_ZN14token_parser_c9get_tokenEP7token_c(ptr noundef nonnull align 8 dereferenceable(24) %0, ptr noundef nonnull %2)
  %.not21 = icmp eq i8 %17, 1
  br i1 %.not21, label %19, label %18

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

19:                                               ; preds = %18, %16
  %20 = call noundef i32 @_ZNK7token_c11get_m_valueEv(ptr noundef nonnull align 4 dereferenceable(8) %2)
  %.not24 = icmp eq i32 %20, 0
  br i1 %.not24, label %._crit_edge, label %.lr.ph

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

.lr.ph:                                           ; preds = %19, %.lr.ph
  %.023 = phi i32 [ %24, %.lr.ph ], [ 0, %19 ]
  %23 = load ptr, ptr %4, align 8, !tbaa !5
  call void @_ZN12gz_generator5gen_c8proc_litEi(ptr noundef nonnull align 8 dereferenceable(178336) %23, i32 noundef %7)
  %24 = add nuw i32 %.023, 1
  %25 = call noundef i32 @_ZNK7token_c11get_m_valueEv(ptr noundef nonnull align 4 dereferenceable(8) %2)
  %26 = icmp ult i32 %24, %25
  br i1 %26, label %.lr.ph, label %._crit_edge, !llvm.loop !17

.loopexit:                                        ; preds = %._crit_edge, %10
  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_c8proc_litEi(ptr noundef nonnull align 8 dereferenceable(178336), 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