; LLVM IR from jspd-group/pegit :: src (stage)

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

%struct.stage_options = type { i32, i32, i32, i32, i64, i8, i8, i32, ptr, ptr, ptr, %struct.pack_file_cache }
%struct.pack_file_cache = type { ptr, %struct.strbuf }
%struct.strbuf = type { i64, i64, ptr }

@opts = external dso_local global %struct.stage_options, align 8
@__const.parse_ignore_list.buf = external hidden unnamed_addr constant %struct.strbuf, align 8
@__const.parse_ignore_list.entry = external hidden unnamed_addr constant %struct.strbuf, align 8
@.str.40 = external hidden unnamed_addr constant [2 x i8], align 1

; 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

declare void @strbuf_init(ptr noundef, i64 noundef) #1

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #2

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @strbuf_addstr(ptr noundef, ptr noundef) #3

; Function Attrs: nounwind allocsize(0)
declare noalias ptr @malloc(i64 noundef) #4

; Function Attrs: nounwind uwtable
declare dso_local i64 @findch(ptr noundef, i8 noundef signext) #5

; Function Attrs: nounwind uwtable
define dso_local void @parse_ignore_list(ptr noundef %0) #5 {
  %2 = alloca ptr, align 8
  %3 = alloca i64, align 8
  %4 = alloca i64, align 8
  %5 = alloca %struct.strbuf, align 8
  %6 = alloca %struct.strbuf, align 8
  %7 = alloca ptr, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #7
  store i64 0, ptr %3, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #7
  store i64 0, ptr %4, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 24, ptr %5) #7
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %5, ptr align 8 @__const.parse_ignore_list.buf, i64 24, i1 false)
  call void @llvm.lifetime.start.p0(i64 24, ptr %6) #7
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %6, ptr align 8 @__const.parse_ignore_list.entry, i64 24, i1 false)
  %8 = load ptr, ptr %2, align 8, !tbaa !5
  %9 = load ptr, ptr %2, align 8, !tbaa !5
  %10 = call i64 @findch(ptr noundef %9, i8 noundef signext 61)
  %11 = getelementptr inbounds i8, ptr %8, i64 %10
  %12 = getelementptr inbounds i8, ptr %11, i64 1
  call void @strbuf_addstr(ptr noundef %5, ptr noundef %12)
  %13 = call i64 @strbuf_count(ptr noundef %5, i8 noundef signext 58)
  %14 = getelementptr inbounds %struct.strbuf, ptr %5, i32 0, i32 2
  %15 = load ptr, ptr %14, align 8, !tbaa !11
  %16 = getelementptr inbounds %struct.strbuf, ptr %5, i32 0, i32 1
  %17 = load i64, ptr %16, align 8, !tbaa !13
  %18 = sub i64 %17, 1
  %19 = getelementptr inbounds i8, ptr %15, i64 %18
  %20 = load i8, ptr %19, align 1, !tbaa !14
  %21 = sext i8 %20 to i32
  %22 = icmp eq i32 %21, 58
  %23 = zext i1 %22 to i64
  %24 = select i1 %22, i32 0, i32 1
  %25 = sext i32 %24 to i64
  %26 = add i64 %13, %25
  store i64 %26, ptr %4, align 8, !tbaa !9
  %27 = load i64, ptr %4, align 8, !tbaa !9
  %28 = mul i64 24, %27
  %29 = call noalias ptr @malloc(i64 noundef %28) #8
  store ptr %29, ptr getelementptr inbounds (%struct.stage_options, ptr @opts, i32 0, i32 8), align 8, !tbaa !15
  %30 = load i64, ptr %4, align 8, !tbaa !9
  %31 = trunc i64 %30 to i32
  store i32 %31, ptr getelementptr inbounds (%struct.stage_options, ptr @opts, i32 0, i32 1), align 4, !tbaa !20
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #7
  %32 = getelementptr inbounds %struct.strbuf, ptr %5, i32 0, i32 2
  %33 = load ptr, ptr %32, align 8, !tbaa !11
  %34 = call ptr @strtok(ptr noundef %33, ptr noundef @.str.40) #7
  store ptr %34, ptr %7, align 8, !tbaa !5
  br label %35

35:                                               ; preds = %38, %1
  %36 = load ptr, ptr %7, align 8, !tbaa !5
  %37 = icmp ne ptr %36, null
  br i1 %37, label %38, label %49

38:                                               ; preds = %35
  %39 = load ptr, ptr getelementptr inbounds (%struct.stage_options, ptr @opts, i32 0, i32 8), align 8, !tbaa !15
  %40 = load i64, ptr %3, align 8, !tbaa !9
  %41 = getelementptr inbounds %struct.strbuf, ptr %39, i64 %40
  call void @strbuf_init(ptr noundef %41, i64 noundef 128)
  %42 = load ptr, ptr getelementptr inbounds (%struct.stage_options, ptr @opts, i32 0, i32 8), align 8, !tbaa !15
  %43 = load i64, ptr %3, align 8, !tbaa !9
  %44 = getelementptr inbounds %struct.strbuf, ptr %42, i64 %43
  %45 = load ptr, ptr %7, align 8, !tbaa !5
  call void @get_peg_path_buf(ptr noundef %44, ptr noundef %45)
  %46 = call ptr @strtok(ptr noundef null, ptr noundef @.str.40) #7
  store ptr %46, ptr %7, align 8, !tbaa !5
  %47 = load i64, ptr %3, align 8, !tbaa !9
  %48 = add i64 %47, 1
  store i64 %48, ptr %3, align 8, !tbaa !9
  br label %35, !llvm.loop !21

49:                                               ; preds = %35
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #7
  call void @llvm.lifetime.end.p0(i64 24, ptr %6) #7
  call void @llvm.lifetime.end.p0(i64 24, ptr %5) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #7
  ret void
}

; Function Attrs: inlinehint nounwind uwtable
declare hidden i64 @strbuf_count(ptr noundef, i8 noundef signext) #3

; Function Attrs: nounwind
declare ptr @strtok(ptr noundef, ptr noundef) #6

declare void @get_peg_path_buf(ptr noundef, ptr noundef) #1

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { "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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { inlinehint 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 #4 = { nounwind allocsize(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 #5 = { 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 #6 = { 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 #7 = { nounwind }
attributes #8 = { nounwind allocsize(0) }

!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/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"long", !7, i64 0}
!11 = !{!12, !6, i64 16}
!12 = !{!"strbuf", !10, i64 0, !10, i64 8, !6, i64 16}
!13 = !{!12, !10, i64 8}
!14 = !{!7, !7, i64 0}
!15 = !{!16, !6, i64 32}
!16 = !{!"stage_options", !17, i64 0, !17, i64 4, !17, i64 8, !17, i64 12, !10, i64 16, !18, i64 24, !18, i64 25, !17, i64 28, !6, i64 32, !6, i64 40, !6, i64 48, !19, i64 56}
!17 = !{!"int", !7, i64 0}
!18 = !{!"_Bool", !7, i64 0}
!19 = !{!"pack_file_cache", !6, i64 0, !12, i64 8}
!20 = !{!16, !17, i64 4}
!21 = distinct !{!21, !22}
!22 = !{!"llvm.loop.mustprogress"}


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

%struct.stage_options = type { i32, i32, i32, i32, i64, i8, i8, i32, ptr, ptr, ptr, %struct.pack_file_cache }
%struct.pack_file_cache = type { ptr, %struct.strbuf }
%struct.strbuf = type { i64, i64, ptr }

@opts = external dso_local local_unnamed_addr global %struct.stage_options, align 8
@__const.parse_ignore_list.buf = external hidden unnamed_addr constant %struct.strbuf, align 8
@.str.40 = external hidden unnamed_addr constant [2 x i8], align 1

; 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

declare void @strbuf_init(ptr noundef, i64 noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #2

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @strbuf_addstr(ptr noundef, ptr noundef) local_unnamed_addr #3

; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @malloc(i64 noundef) local_unnamed_addr #4

; Function Attrs: nounwind uwtable
declare dso_local i64 @findch(ptr noundef, i8 noundef signext) local_unnamed_addr #5

; Function Attrs: nounwind uwtable
define dso_local void @parse_ignore_list(ptr noundef %0) local_unnamed_addr #5 {
  %2 = alloca %struct.strbuf, align 8
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %2) #7
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(24) %2, ptr noundef nonnull align 8 dereferenceable(24) @__const.parse_ignore_list.buf, i64 24, i1 false)
  %3 = tail call i64 @findch(ptr noundef %0, i8 noundef signext 61)
  %4 = getelementptr inbounds i8, ptr %0, i64 %3
  %5 = getelementptr inbounds i8, ptr %4, i64 1
  call void @strbuf_addstr(ptr noundef nonnull %2, ptr noundef nonnull %5)
  %6 = call i64 @strbuf_count(ptr noundef nonnull %2, i8 noundef signext 58)
  %7 = getelementptr inbounds i8, ptr %2, i64 16
  %8 = load ptr, ptr %7, align 8, !tbaa !5
  %9 = getelementptr inbounds i8, ptr %2, i64 8
  %10 = load i64, ptr %9, align 8, !tbaa !11
  %11 = getelementptr i8, ptr %8, i64 %10
  %12 = getelementptr i8, ptr %11, i64 -1
  %13 = load i8, ptr %12, align 1, !tbaa !12
  %14 = icmp ne i8 %13, 58
  %15 = zext i1 %14 to i64
  %16 = add i64 %6, %15
  %17 = mul i64 %16, 24
  %18 = call noalias ptr @malloc(i64 noundef %17) #8
  store ptr %18, ptr getelementptr inbounds (i8, ptr @opts, i64 32), align 8, !tbaa !13
  %19 = trunc i64 %16 to i32
  store i32 %19, ptr getelementptr inbounds (i8, ptr @opts, i64 4), align 4, !tbaa !18
  %20 = call ptr @strtok(ptr noundef %8, ptr noundef nonnull @.str.40) #7
  %.not9 = icmp eq ptr %20, null
  br i1 %.not9, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %1, %.lr.ph
  %.011 = phi ptr [ %25, %.lr.ph ], [ %20, %1 ]
  %.0810 = phi i64 [ %26, %.lr.ph ], [ 0, %1 ]
  %21 = load ptr, ptr getelementptr inbounds (i8, ptr @opts, i64 32), align 8, !tbaa !13
  %22 = getelementptr inbounds %struct.strbuf, ptr %21, i64 %.0810
  call void @strbuf_init(ptr noundef %22, i64 noundef 128) #7
  %23 = load ptr, ptr getelementptr inbounds (i8, ptr @opts, i64 32), align 8, !tbaa !13
  %24 = getelementptr inbounds %struct.strbuf, ptr %23, i64 %.0810
  call void @get_peg_path_buf(ptr noundef %24, ptr noundef nonnull %.011) #7
  %25 = call ptr @strtok(ptr noundef null, ptr noundef nonnull @.str.40) #7
  %26 = add i64 %.0810, 1
  %.not = icmp eq ptr %25, null
  br i1 %.not, label %._crit_edge, label %.lr.ph, !llvm.loop !19

._crit_edge:                                      ; preds = %.lr.ph, %1
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %2) #7
  ret void
}

; Function Attrs: inlinehint nounwind uwtable
declare hidden i64 @strbuf_count(ptr noundef, i8 noundef signext) local_unnamed_addr #3

; Function Attrs: mustprogress nofree nounwind willreturn
declare ptr @strtok(ptr noundef, ptr nocapture noundef readonly) local_unnamed_addr #6

declare void @get_peg_path_buf(ptr noundef, ptr noundef) local_unnamed_addr #1

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { "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 nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { inlinehint 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 #4 = { mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" "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 #5 = { 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 #6 = { mustprogress nofree nounwind willreturn "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 #7 = { nounwind }
attributes #8 = { nounwind allocsize(0) }

!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, !10, i64 16}
!6 = !{!"strbuf", !7, i64 0, !7, i64 8, !10, i64 16}
!7 = !{!"long", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!6, !7, i64 8}
!12 = !{!8, !8, i64 0}
!13 = !{!14, !10, i64 32}
!14 = !{!"stage_options", !15, i64 0, !15, i64 4, !15, i64 8, !15, i64 12, !7, i64 16, !16, i64 24, !16, i64 25, !15, i64 28, !10, i64 32, !10, i64 40, !10, i64 48, !17, i64 56}
!15 = !{!"int", !8, i64 0}
!16 = !{!"_Bool", !8, i64 0}
!17 = !{!"pack_file_cache", !10, i64 0, !6, i64 8}
!18 = !{!14, !15, i64 4}
!19 = distinct !{!19, !20}
!20 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass