; 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

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

9:                                                ; preds = %33, %2
  %10 = load i64, ptr %5, align 8, !tbaa !13
  %11 = load ptr, ptr %4, align 8, !tbaa !5
  %12 = getelementptr inbounds %struct.lex, ptr %11, i32 0, i32 2
  %13 = load i64, ptr %12, align 8, !tbaa !14
  %14 = icmp ult i64 %10, %13
  br i1 %14, label %15, label %31

15:                                               ; preds = %9
  %16 = call ptr @__ctype_b_loc() #6
  %17 = load ptr, ptr %16, align 8, !tbaa !5
  %18 = load ptr, ptr %4, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct.lex, ptr %18, i32 0, i32 0
  %20 = load ptr, ptr %19, align 8, !tbaa !15
  %21 = load i64, ptr %5, align 8, !tbaa !13
  %22 = getelementptr inbounds i8, ptr %20, i64 %21
  %23 = load i8, ptr %22, align 1, !tbaa !16
  %24 = sext i8 %23 to i32
  %25 = sext i32 %24 to i64
  %26 = getelementptr inbounds i16, ptr %17, i64 %25
  %27 = load i16, ptr %26, align 2, !tbaa !17
  %28 = zext i16 %27 to i32
  %29 = and i32 %28, 2048
  %30 = icmp ne i32 %29, 0
  br label %31

31:                                               ; preds = %15, %9
  %32 = phi i1 [ false, %9 ], [ %30, %15 ]
  br i1 %32, label %33, label %36

33:                                               ; preds = %31
  %34 = load i64, ptr %5, align 8, !tbaa !13
  %35 = add i64 %34, 1
  store i64 %35, ptr %5, align 8, !tbaa !13
  br label %9, !llvm.loop !19

36:                                               ; preds = %31
  %37 = load ptr, ptr %3, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct.config_list, ptr %37, i32 0, i32 1
  %39 = load ptr, ptr %4, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.lex, ptr %39, i32 0, i32 0
  %41 = load ptr, ptr %40, align 8, !tbaa !15
  %42 = load ptr, ptr %4, align 8, !tbaa !5
  %43 = getelementptr inbounds %struct.lex, ptr %42, i32 0, i32 1
  %44 = load i64, ptr %43, align 8, !tbaa !9
  %45 = getelementptr inbounds i8, ptr %41, i64 %44
  %46 = load i64, ptr %5, align 8, !tbaa !13
  %47 = load ptr, ptr %4, align 8, !tbaa !5
  %48 = getelementptr inbounds %struct.lex, ptr %47, i32 0, i32 1
  %49 = load i64, ptr %48, align 8, !tbaa !9
  %50 = sub i64 %46, %49
  call void @strbuf_add(ptr noundef %38, ptr noundef %45, i64 noundef %50)
  %51 = load ptr, ptr %3, align 8, !tbaa !5
  %52 = getelementptr inbounds %struct.config_list, ptr %51, i32 0, i32 1
  %53 = getelementptr inbounds %struct.strbuf, ptr %52, i32 0, i32 2
  %54 = load ptr, ptr %53, align 8, !tbaa !21
  %55 = call i64 @strtol(ptr noundef %54, ptr noundef null, i32 noundef 10) #5
  %56 = load ptr, ptr %3, align 8, !tbaa !5
  %57 = getelementptr inbounds %struct.config_list, ptr %56, i32 0, i32 2
  store i64 %55, ptr %57, align 8, !tbaa !24
  %58 = load ptr, ptr %4, align 8, !tbaa !5
  %59 = load i64, ptr %5, align 8, !tbaa !13
  %60 = load ptr, ptr %4, align 8, !tbaa !5
  %61 = getelementptr inbounds %struct.lex, ptr %60, i32 0, i32 1
  %62 = load i64, ptr %61, align 8, !tbaa !9
  %63 = sub i64 %59, %62
  call void @consume(ptr noundef %58, i64 noundef %63)
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #5
  ret i32 0
}

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

; Function Attrs: nounwind
declare i64 @strtol(ptr noundef, ptr noundef, i32 noundef) #4

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


; 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

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @read_number(ptr noundef %0, ptr noundef %1) local_unnamed_addr #1 {
  %3 = getelementptr inbounds i8, ptr %1, i64 8
  %4 = load i64, ptr %3, align 8, !tbaa !5
  %5 = getelementptr inbounds i8, ptr %1, i64 16
  %6 = load i64, ptr %5, align 8, !tbaa !12
  %7 = icmp ult i64 %4, %6
  %.pre = load ptr, ptr %1, align 8, !tbaa !13
  br i1 %7, label %.lr.ph, label %.critedge

.lr.ph:                                           ; preds = %2
  %8 = tail call ptr @__ctype_b_loc() #4
  %9 = load ptr, ptr %8, align 8, !tbaa !14
  br label %10

10:                                               ; preds = %.lr.ph, %17
  %.015 = phi i64 [ %4, %.lr.ph ], [ %18, %17 ]
  %11 = getelementptr inbounds i8, ptr %.pre, i64 %.015
  %12 = load i8, ptr %11, align 1, !tbaa !15
  %13 = sext i8 %12 to i64
  %14 = getelementptr inbounds i16, ptr %9, i64 %13
  %15 = load i16, ptr %14, align 2, !tbaa !16
  %16 = and i16 %15, 2048
  %.not = icmp eq i16 %16, 0
  br i1 %.not, label %.critedge, label %17

17:                                               ; preds = %10
  %18 = add i64 %.015, 1
  %exitcond.not = icmp eq i64 %18, %6
  br i1 %exitcond.not, label %.critedge, label %10, !llvm.loop !18

.critedge:                                        ; preds = %10, %17, %2
  %.0.lcssa = phi i64 [ %4, %2 ], [ %6, %17 ], [ %.015, %10 ]
  %19 = getelementptr inbounds i8, ptr %0, i64 24
  %20 = getelementptr inbounds i8, ptr %.pre, i64 %4
  %21 = sub i64 %.0.lcssa, %4
  tail call void @strbuf_add(ptr noundef nonnull %19, ptr noundef %20, i64 noundef %21) #5
  %22 = getelementptr inbounds i8, ptr %0, i64 40
  %23 = load ptr, ptr %22, align 8, !tbaa !20
  %24 = tail call i64 @strtol(ptr nocapture noundef %23, ptr noundef null, i32 noundef 10) #5
  %25 = getelementptr inbounds i8, ptr %0, i64 48
  store i64 %24, ptr %25, align 8, !tbaa !23
  %26 = load i64, ptr %3, align 8, !tbaa !5
  %27 = sub i64 %.0.lcssa, %26
  tail call void @consume(ptr noundef nonnull %1, i64 noundef %27)
  ret i32 0
}

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

; Function Attrs: mustprogress nofree nounwind willreturn
declare i64 @strtol(ptr noundef readonly, ptr nocapture noundef, i32 noundef) local_unnamed_addr #3

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 = { 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 #4 = { nounwind willreturn memory(none) }
attributes #5 = { 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 = !{!6, !7, i64 0}
!14 = !{!7, !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 = !{!21, !7, i64 40}
!21 = !{!"config_list", !22, i64 0, !22, i64 24, !10, i64 48, !7, i64 56}
!22 = !{!"strbuf", !10, i64 0, !10, i64 8, !7, i64 16}
!23 = !{!21, !10, i64 48}


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