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

; 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.lex = type { ptr, i64, i64, i32 }
%struct.config_list = type { %struct.strbuf, %struct.strbuf, i64, ptr }
%struct.strbuf = type { i64, i64, ptr }

; 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: nounwind willreturn memory(none)
declare ptr @__ctype_b_loc() #1

; Function Attrs: nounwind uwtable
declare dso_local void @consume(ptr noundef, i64 noundef) #2

declare void @strbuf_add(ptr noundef, ptr noundef, i64 noundef) #3

; Function Attrs: nounwind uwtable
define dso_local i32 @parse_string(ptr noundef %0, ptr noundef %1, i32 noundef %2) #2 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca i64, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store i32 %2, ptr %6, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #4
  %8 = load ptr, ptr %5, align 8, !tbaa !5
  %9 = getelementptr inbounds %struct.lex, ptr %8, i32 0, i32 1
  %10 = load i64, ptr %9, align 8, !tbaa !11
  store i64 %10, ptr %7, align 8, !tbaa !14
  %11 = load i32, ptr %6, align 4, !tbaa !9
  %12 = icmp ne i32 %11, 0
  br i1 %12, label %13, label %53

13:                                               ; preds = %3
  br label %14

14:                                               ; preds = %49, %13
  %15 = load i64, ptr %7, align 8, !tbaa !14
  %16 = load ptr, ptr %5, align 8, !tbaa !5
  %17 = getelementptr inbounds %struct.lex, ptr %16, i32 0, i32 2
  %18 = load i64, ptr %17, align 8, !tbaa !15
  %19 = icmp ult i64 %15, %18
  br i1 %19, label %20, label %47

20:                                               ; preds = %14
  %21 = call ptr @__ctype_b_loc() #5
  %22 = load ptr, ptr %21, align 8, !tbaa !5
  %23 = load ptr, ptr %5, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct.lex, ptr %23, i32 0, i32 0
  %25 = load ptr, ptr %24, align 8, !tbaa !16
  %26 = load i64, ptr %7, align 8, !tbaa !14
  %27 = getelementptr inbounds i8, ptr %25, i64 %26
  %28 = load i8, ptr %27, align 1, !tbaa !17
  %29 = sext i8 %28 to i32
  %30 = sext i32 %29 to i64
  %31 = getelementptr inbounds i16, ptr %22, i64 %30
  %32 = load i16, ptr %31, align 2, !tbaa !18
  %33 = zext i16 %32 to i32
  %34 = and i32 %33, 8
  %35 = icmp ne i32 %34, 0
  br i1 %35, label %45, label %36

36:                                               ; preds = %20
  %37 = load ptr, ptr %5, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct.lex, ptr %37, i32 0, i32 0
  %39 = load ptr, ptr %38, align 8, !tbaa !16
  %40 = load i64, ptr %7, align 8, !tbaa !14
  %41 = getelementptr inbounds i8, ptr %39, i64 %40
  %42 = load i8, ptr %41, align 1, !tbaa !17
  %43 = sext i8 %42 to i32
  %44 = icmp eq i32 %43, 45
  br label %45

45:                                               ; preds = %36, %20
  %46 = phi i1 [ true, %20 ], [ %44, %36 ]
  br label %47

47:                                               ; preds = %45, %14
  %48 = phi i1 [ false, %14 ], [ %46, %45 ]
  br i1 %48, label %49, label %52

49:                                               ; preds = %47
  %50 = load i64, ptr %7, align 8, !tbaa !14
  %51 = add i64 %50, 1
  store i64 %51, ptr %7, align 8, !tbaa !14
  br label %14, !llvm.loop !20

52:                                               ; preds = %47
  br label %75

53:                                               ; preds = %3
  br label %54

54:                                               ; preds = %71, %53
  %55 = load i64, ptr %7, align 8, !tbaa !14
  %56 = load ptr, ptr %5, align 8, !tbaa !5
  %57 = getelementptr inbounds %struct.lex, ptr %56, i32 0, i32 2
  %58 = load i64, ptr %57, align 8, !tbaa !15
  %59 = icmp ult i64 %55, %58
  br i1 %59, label %60, label %69

60:                                               ; preds = %54
  %61 = load ptr, ptr %5, align 8, !tbaa !5
  %62 = getelementptr inbounds %struct.lex, ptr %61, i32 0, i32 0
  %63 = load ptr, ptr %62, align 8, !tbaa !16
  %64 = load i64, ptr %7, align 8, !tbaa !14
  %65 = getelementptr inbounds i8, ptr %63, i64 %64
  %66 = load i8, ptr %65, align 1, !tbaa !17
  %67 = sext i8 %66 to i32
  %68 = icmp ne i32 %67, 10
  br label %69

69:                                               ; preds = %60, %54
  %70 = phi i1 [ false, %54 ], [ %68, %60 ]
  br i1 %70, label %71, label %74

71:                                               ; preds = %69
  %72 = load i64, ptr %7, align 8, !tbaa !14
  %73 = add i64 %72, 1
  store i64 %73, ptr %7, align 8, !tbaa !14
  br label %54, !llvm.loop !22

74:                                               ; preds = %69
  br label %75

75:                                               ; preds = %74, %52
  %76 = load i32, ptr %6, align 4, !tbaa !9
  %77 = icmp ne i32 %76, 0
  br i1 %77, label %78, label %93

78:                                               ; preds = %75
  %79 = load ptr, ptr %4, align 8, !tbaa !5
  %80 = getelementptr inbounds %struct.config_list, ptr %79, i32 0, i32 0
  %81 = load ptr, ptr %5, align 8, !tbaa !5
  %82 = getelementptr inbounds %struct.lex, ptr %81, i32 0, i32 0
  %83 = load ptr, ptr %82, align 8, !tbaa !16
  %84 = load ptr, ptr %5, align 8, !tbaa !5
  %85 = getelementptr inbounds %struct.lex, ptr %84, i32 0, i32 1
  %86 = load i64, ptr %85, align 8, !tbaa !11
  %87 = getelementptr inbounds i8, ptr %83, i64 %86
  %88 = load i64, ptr %7, align 8, !tbaa !14
  %89 = load ptr, ptr %5, align 8, !tbaa !5
  %90 = getelementptr inbounds %struct.lex, ptr %89, i32 0, i32 1
  %91 = load i64, ptr %90, align 8, !tbaa !11
  %92 = sub i64 %88, %91
  call void @strbuf_add(ptr noundef %80, ptr noundef %87, i64 noundef %92)
  br label %108

93:                                               ; preds = %75
  %94 = load ptr, ptr %4, align 8, !tbaa !5
  %95 = getelementptr inbounds %struct.config_list, ptr %94, i32 0, i32 1
  %96 = load ptr, ptr %5, align 8, !tbaa !5
  %97 = getelementptr inbounds %struct.lex, ptr %96, i32 0, i32 0
  %98 = load ptr, ptr %97, align 8, !tbaa !16
  %99 = load ptr, ptr %5, align 8, !tbaa !5
  %100 = getelementptr inbounds %struct.lex, ptr %99, i32 0, i32 1
  %101 = load i64, ptr %100, align 8, !tbaa !11
  %102 = getelementptr inbounds i8, ptr %98, i64 %101
  %103 = load i64, ptr %7, align 8, !tbaa !14
  %104 = load ptr, ptr %5, align 8, !tbaa !5
  %105 = getelementptr inbounds %struct.lex, ptr %104, i32 0, i32 1
  %106 = load i64, ptr %105, align 8, !tbaa !11
  %107 = sub i64 %103, %106
  call void @strbuf_add(ptr noundef %95, ptr noundef %102, i64 noundef %107)
  br label %108

108:                                              ; preds = %93, %78
  %109 = load ptr, ptr %5, align 8, !tbaa !5
  %110 = load i64, ptr %7, align 8, !tbaa !14
  %111 = load ptr, ptr %5, align 8, !tbaa !5
  %112 = getelementptr inbounds %struct.lex, ptr %111, i32 0, i32 1
  %113 = load i64, ptr %112, align 8, !tbaa !11
  %114 = sub i64 %110, %113
  call void @consume(ptr noundef %109, i64 noundef %114)
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #4
  ret i32 0
}

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

!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 = !{!"int", !7, i64 0}
!11 = !{!12, !13, i64 8}
!12 = !{!"lex", !6, i64 0, !13, i64 8, !13, i64 16, !10, i64 24}
!13 = !{!"long", !7, i64 0}
!14 = !{!13, !13, i64 0}
!15 = !{!12, !13, i64 16}
!16 = !{!12, !6, i64 0}
!17 = !{!7, !7, i64 0}
!18 = !{!19, !19, i64 0}
!19 = !{!"short", !7, i64 0}
!20 = distinct !{!20, !21}
!21 = !{!"llvm.loop.mustprogress"}
!22 = distinct !{!22, !21}


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

; Function Attrs: mustprogress nofree nosync nounwind willreturn memory(none)
declare ptr @__ctype_b_loc() local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local void @consume(ptr noundef, i64 noundef) local_unnamed_addr #1

declare void @strbuf_add(ptr noundef, ptr noundef, i64 noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @parse_string(ptr noundef %0, ptr noundef %1, i32 noundef %2) local_unnamed_addr #1 {
  %4 = getelementptr inbounds i8, ptr %1, i64 8
  %5 = load i64, ptr %4, align 8, !tbaa !5
  %.not = icmp eq i32 %2, 0
  %6 = getelementptr inbounds i8, ptr %1, i64 16
  %7 = load i64, ptr %6, align 8, !tbaa !12
  %8 = icmp ult i64 %5, %7
  br i1 %.not, label %.preheader, label %.preheader33

.preheader33:                                     ; preds = %3
  br i1 %8, label %.lr.ph, label %.critedge.thread49

.lr.ph:                                           ; preds = %.preheader33
  %9 = tail call ptr @__ctype_b_loc() #3
  %10 = load ptr, ptr %9, align 8, !tbaa !13
  %11 = load ptr, ptr %1, align 8, !tbaa !14
  br label %13

.preheader:                                       ; preds = %3
  br i1 %8, label %.lr.ph39, label %.critedge.thread

.lr.ph39:                                         ; preds = %.preheader
  %12 = load ptr, ptr %1, align 8, !tbaa !14
  br label %22

13:                                               ; preds = %.lr.ph, %.critedge2
  %.035 = phi i64 [ %5, %.lr.ph ], [ %21, %.critedge2 ]
  %14 = getelementptr inbounds i8, ptr %11, i64 %.035
  %15 = load i8, ptr %14, align 1, !tbaa !15
  %16 = sext i8 %15 to i64
  %17 = getelementptr inbounds i16, ptr %10, i64 %16
  %18 = load i16, ptr %17, align 2, !tbaa !16
  %19 = and i16 %18, 8
  %.not32 = icmp ne i16 %19, 0
  %20 = icmp eq i8 %15, 45
  %or.cond = or i1 %20, %.not32
  br i1 %or.cond, label %.critedge2, label %.critedge

.critedge2:                                       ; preds = %13
  %21 = add i64 %.035, 1
  %exitcond.not = icmp eq i64 %21, %7
  br i1 %exitcond.not, label %.critedge, label %13, !llvm.loop !18

22:                                               ; preds = %.lr.ph39, %25
  %.138 = phi i64 [ %5, %.lr.ph39 ], [ %26, %25 ]
  %23 = getelementptr inbounds i8, ptr %12, i64 %.138
  %24 = load i8, ptr %23, align 1, !tbaa !15
  %.not31 = icmp eq i8 %24, 10
  br i1 %.not31, label %.critedge, label %25

25:                                               ; preds = %22
  %26 = add i64 %.138, 1
  %exitcond45.not = icmp eq i64 %26, %7
  br i1 %exitcond45.not, label %.critedge, label %22, !llvm.loop !20

.critedge:                                        ; preds = %.critedge2, %13, %25, %22
  %.2 = phi i64 [ %7, %25 ], [ %.138, %22 ], [ %7, %.critedge2 ], [ %.035, %13 ]
  br i1 %.not, label %.critedge.thread, label %.critedge.thread49

.critedge.thread49:                               ; preds = %.preheader33, %.critedge
  %.251 = phi i64 [ %.2, %.critedge ], [ %5, %.preheader33 ]
  %27 = load ptr, ptr %1, align 8, !tbaa !14
  %28 = getelementptr inbounds i8, ptr %27, i64 %5
  %29 = sub i64 %.251, %5
  tail call void @strbuf_add(ptr noundef %0, ptr noundef %28, i64 noundef %29) #4
  br label %34

.critedge.thread:                                 ; preds = %.preheader, %.critedge
  %.248 = phi i64 [ %.2, %.critedge ], [ %5, %.preheader ]
  %30 = getelementptr inbounds i8, ptr %0, i64 24
  %31 = load ptr, ptr %1, align 8, !tbaa !14
  %32 = getelementptr inbounds i8, ptr %31, i64 %5
  %33 = sub i64 %.248, %5
  tail call void @strbuf_add(ptr noundef nonnull %30, ptr noundef %32, i64 noundef %33) #4
  br label %34

34:                                               ; preds = %.critedge.thread, %.critedge.thread49
  %.247 = phi i64 [ %.248, %.critedge.thread ], [ %.251, %.critedge.thread49 ]
  %35 = load i64, ptr %4, align 8, !tbaa !5
  %36 = sub i64 %.247, %35
  tail call void @consume(ptr noundef nonnull %1, i64 noundef %36)
  ret i32 0
}

attributes #0 = { mustprogress nofree nosync nounwind willreturn memory(none) "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 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 = { "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 willreturn memory(none) }
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, !10, i64 8}
!6 = !{!"lex", !7, i64 0, !10, i64 8, !10, i64 16, !11, i64 24}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"long", !8, i64 0}
!11 = !{!"int", !8, i64 0}
!12 = !{!6, !10, i64 16}
!13 = !{!7, !7, i64 0}
!14 = !{!6, !7, i64 0}
!15 = !{!8, !8, i64 0}
!16 = !{!17, !17, i64 0}
!17 = !{!"short", !8, i64 0}
!18 = distinct !{!18, !19}
!19 = !{!"llvm.loop.mustprogress"}
!20 = distinct !{!20, !19}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass