; 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 }
%struct.stage_stats = type { i64, i64, i64, i64, i64 }

@opts = external dso_local global %struct.stage_options, align 8
@stdout = external global ptr, align 8
@.str.10 = external hidden unnamed_addr constant [18 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [15 x i8], align 1
@.str.14 = external hidden unnamed_addr constant [57 x i8], align 1
@.str.15 = external hidden unnamed_addr constant [57 x i8], align 1
@.str.16 = external hidden unnamed_addr constant [57 x i8], align 1
@.str.17 = external hidden unnamed_addr constant [33 x i8], align 1
@.str.18 = external hidden unnamed_addr constant [46 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

; Function Attrs: nounwind uwtable
define dso_local void @print_stage_stats(ptr noundef %0) #1 {
  %2 = alloca ptr, align 8
  %3 = alloca i64, align 8
  %4 = alloca i64, align 8
  %5 = alloca i64, align 8
  %6 = alloca i32, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #3
  store i64 0, ptr %3, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #3
  store i64 0, ptr %4, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #3
  %7 = load ptr, ptr %2, align 8, !tbaa !5
  %8 = getelementptr inbounds %struct.stage_stats, ptr %7, i32 0, i32 3
  %9 = load i64, ptr %8, align 8, !tbaa !11
  store i64 %9, ptr %5, align 8, !tbaa !9
  %10 = load i8, ptr getelementptr inbounds (%struct.stage_options, ptr @opts, i32 0, i32 5), align 8, !tbaa !13, !range !19, !noundef !20
  %11 = trunc i8 %10 to i1
  br i1 %11, label %12, label %13

12:                                               ; preds = %1
  store i32 1, ptr %6, align 4
  br label %101

13:                                               ; preds = %1
  %14 = load ptr, ptr %2, align 8, !tbaa !5
  %15 = getelementptr inbounds %struct.stage_stats, ptr %14, i32 0, i32 0
  %16 = load i64, ptr %15, align 8, !tbaa !21
  %17 = icmp ne i64 %16, 0
  br i1 %17, label %18, label %39

18:                                               ; preds = %13
  %19 = load ptr, ptr %2, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.stage_stats, ptr %19, i32 0, i32 0
  %21 = load i64, ptr %20, align 8, !tbaa !21
  %22 = load ptr, ptr %2, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct.stage_stats, ptr %22, i32 0, i32 3
  %24 = load i64, ptr %23, align 8, !tbaa !11
  %25 = sub i64 %21, %24
  %26 = icmp ne i64 %25, 0
  br i1 %26, label %27, label %39

27:                                               ; preds = %18
  %28 = load ptr, ptr @stdout, align 8, !tbaa !5
  %29 = load ptr, ptr %2, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.stage_stats, ptr %29, i32 0, i32 0
  %31 = load i64, ptr %30, align 8, !tbaa !21
  %32 = load ptr, ptr %2, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct.stage_stats, ptr %32, i32 0, i32 0
  %34 = load i64, ptr %33, align 8, !tbaa !21
  %35 = icmp ule i64 %34, 1
  %36 = zext i1 %35 to i64
  %37 = select i1 %35, ptr @.str.11, ptr @.str.12
  %38 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %28, ptr noundef @.str.10, i64 noundef %31, ptr noundef %37) #3
  br label %39

39:                                               ; preds = %27, %18, %13
  %40 = load ptr, ptr %2, align 8, !tbaa !5
  %41 = getelementptr inbounds %struct.stage_stats, ptr %40, i32 0, i32 1
  %42 = load i64, ptr %41, align 8, !tbaa !22
  %43 = icmp ne i64 %42, 0
  br i1 %43, label %44, label %77

44:                                               ; preds = %39
  %45 = load ptr, ptr %2, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct.stage_stats, ptr %45, i32 0, i32 1
  %47 = load i64, ptr %46, align 8, !tbaa !22
  %48 = load ptr, ptr %2, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct.stage_stats, ptr %48, i32 0, i32 3
  %50 = load i64, ptr %49, align 8, !tbaa !11
  %51 = sub i64 %47, %50
  %52 = icmp ne i64 %51, 0
  br i1 %52, label %53, label %77

53:                                               ; preds = %44
  %54 = load ptr, ptr @stdout, align 8, !tbaa !5
  %55 = load ptr, ptr %2, align 8, !tbaa !5
  %56 = getelementptr inbounds %struct.stage_stats, ptr %55, i32 0, i32 1
  %57 = load i64, ptr %56, align 8, !tbaa !22
  %58 = load ptr, ptr %2, align 8, !tbaa !5
  %59 = getelementptr inbounds %struct.stage_stats, ptr %58, i32 0, i32 3
  %60 = load i64, ptr %59, align 8, !tbaa !11
  %61 = sub i64 %57, %60
  %62 = load ptr, ptr %2, align 8, !tbaa !5
  %63 = getelementptr inbounds %struct.stage_stats, ptr %62, i32 0, i32 1
  %64 = load i64, ptr %63, align 8, !tbaa !22
  %65 = load ptr, ptr %2, align 8, !tbaa !5
  %66 = getelementptr inbounds %struct.stage_stats, ptr %65, i32 0, i32 3
  %67 = load i64, ptr %66, align 8, !tbaa !11
  %68 = sub i64 %64, %67
  %69 = icmp ule i64 %68, 1
  %70 = zext i1 %69 to i64
  %71 = select i1 %69, ptr @.str.11, ptr @.str.12
  %72 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %54, ptr noundef @.str.13, i64 noundef %61, ptr noundef %71) #3
  %73 = load ptr, ptr @stdout, align 8, !tbaa !5
  %74 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %73, ptr noundef @.str.14) #3
  %75 = load ptr, ptr @stdout, align 8, !tbaa !5
  %76 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %75, ptr noundef @.str.15) #3
  br label %77

77:                                               ; preds = %53, %44, %39
  %78 = load ptr, ptr %2, align 8, !tbaa !5
  %79 = getelementptr inbounds %struct.stage_stats, ptr %78, i32 0, i32 3
  %80 = load i64, ptr %79, align 8, !tbaa !11
  %81 = icmp ne i64 %80, 0
  br i1 %81, label %82, label %100

82:                                               ; preds = %77
  %83 = load ptr, ptr @stdout, align 8, !tbaa !5
  %84 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %83, ptr noundef @.str.16) #3
  %85 = load ptr, ptr @stdout, align 8, !tbaa !5
  %86 = load ptr, ptr %2, align 8, !tbaa !5
  %87 = getelementptr inbounds %struct.stage_stats, ptr %86, i32 0, i32 3
  %88 = load i64, ptr %87, align 8, !tbaa !11
  %89 = load ptr, ptr %2, align 8, !tbaa !5
  %90 = getelementptr inbounds %struct.stage_stats, ptr %89, i32 0, i32 3
  %91 = load i64, ptr %90, align 8, !tbaa !11
  %92 = icmp ule i64 %91, 1
  %93 = zext i1 %92 to i64
  %94 = select i1 %92, ptr @.str.11, ptr @.str.12
  %95 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %85, ptr noundef @.str.17, i64 noundef %88, ptr noundef %94) #3
  %96 = load ptr, ptr @stdout, align 8, !tbaa !5
  %97 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %96, ptr noundef @.str.14) #3
  %98 = load ptr, ptr @stdout, align 8, !tbaa !5
  %99 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %98, ptr noundef @.str.18) #3
  br label %100

100:                                              ; preds = %82, %77
  store i32 0, ptr %6, align 4
  br label %101

101:                                              ; preds = %100, %12
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #3
  %102 = load i32, ptr %6, align 4
  switch i32 %102, label %104 [
    i32 0, label %103
    i32 1, label %103
  ]

103:                                              ; preds = %101, %101
  ret void

104:                                              ; preds = %101
  unreachable
}

; Function Attrs: nounwind
declare i32 @fprintf(ptr noundef, ptr noundef, ...) #2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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 #3 = { 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/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"long", !7, i64 0}
!11 = !{!12, !10, i64 24}
!12 = !{!"stage_stats", !10, i64 0, !10, i64 8, !10, i64 16, !10, i64 24, !10, i64 32}
!13 = !{!14, !16, i64 24}
!14 = !{!"stage_options", !15, i64 0, !15, i64 4, !15, i64 8, !15, i64 12, !10, i64 16, !16, i64 24, !16, i64 25, !15, i64 28, !6, i64 32, !6, i64 40, !6, i64 48, !17, i64 56}
!15 = !{!"int", !7, i64 0}
!16 = !{!"_Bool", !7, i64 0}
!17 = !{!"pack_file_cache", !6, i64 0, !18, i64 8}
!18 = !{!"strbuf", !10, i64 0, !10, i64 8, !6, i64 16}
!19 = !{i8 0, i8 2}
!20 = !{}
!21 = !{!12, !10, i64 0}
!22 = !{!12, !10, i64 8}


; 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
@stdout = external local_unnamed_addr global ptr, align 8
@.str.10 = external hidden unnamed_addr constant [18 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [15 x i8], align 1
@.str.14 = external hidden unnamed_addr constant [57 x i8], align 1
@.str.15 = external hidden unnamed_addr constant [57 x i8], align 1
@.str.16 = external hidden unnamed_addr constant [57 x i8], align 1
@.str.17 = external hidden unnamed_addr constant [33 x i8], align 1
@.str.18 = external hidden unnamed_addr constant [46 x i8], align 1

; Function Attrs: nofree nounwind uwtable
define dso_local void @print_stage_stats(ptr nocapture noundef readonly %0) local_unnamed_addr #0 {
  %2 = getelementptr inbounds i8, ptr %0, i64 24
  %3 = load i8, ptr getelementptr inbounds (i8, ptr @opts, i64 24), align 8, !tbaa !5, !range !15, !noundef !16
  %4 = trunc nuw i8 %3 to i1
  br i1 %4, label %39, label %5

5:                                                ; preds = %1
  %6 = load i64, ptr %0, align 8, !tbaa !17
  %.not = icmp eq i64 %6, 0
  %.pr.pre23.pre25 = load i64, ptr %2, align 8, !tbaa !19
  br i1 %.not, label %13, label %7

7:                                                ; preds = %5
  %.not18 = icmp eq i64 %6, %.pr.pre23.pre25
  br i1 %.not18, label %13, label %8

8:                                                ; preds = %7
  %9 = load ptr, ptr @stdout, align 8, !tbaa !20
  %10 = icmp eq i64 %6, 1
  %11 = select i1 %10, ptr @.str.11, ptr @.str.12
  %12 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %9, ptr noundef nonnull @.str.10, i64 noundef %6, ptr noundef nonnull %11) #2
  %.pr.pre23.pre = load i64, ptr %2, align 8, !tbaa !19
  br label %13

13:                                               ; preds = %8, %7, %5
  %.pr.pre23 = phi i64 [ %.pr.pre23.pre, %8 ], [ %6, %7 ], [ %.pr.pre23.pre25, %5 ]
  %14 = getelementptr inbounds i8, ptr %0, i64 8
  %15 = load i64, ptr %14, align 8, !tbaa !21
  %.not19 = icmp eq i64 %15, 0
  br i1 %.not19, label %27, label %16

16:                                               ; preds = %13
  %.not20 = icmp eq i64 %15, %.pr.pre23
  br i1 %.not20, label %.thread, label %17

17:                                               ; preds = %16
  %18 = sub i64 %15, %.pr.pre23
  %19 = load ptr, ptr @stdout, align 8, !tbaa !20
  %20 = icmp ult i64 %18, 2
  %21 = select i1 %20, ptr @.str.11, ptr @.str.12
  %22 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %19, ptr noundef nonnull @.str.13, i64 noundef %18, ptr noundef nonnull %21) #2
  %23 = load ptr, ptr @stdout, align 8, !tbaa !20
  %24 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %23, ptr noundef nonnull @.str.14) #2
  %25 = load ptr, ptr @stdout, align 8, !tbaa !20
  %26 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %25, ptr noundef nonnull @.str.15) #2
  %.pr.pre = load i64, ptr %2, align 8, !tbaa !19
  br label %27

27:                                               ; preds = %17, %13
  %.pr = phi i64 [ %.pr.pre, %17 ], [ %.pr.pre23, %13 ]
  %.not21 = icmp eq i64 %.pr, 0
  br i1 %.not21, label %39, label %.thread

.thread:                                          ; preds = %16, %27
  %28 = load ptr, ptr @stdout, align 8, !tbaa !20
  %29 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %28, ptr noundef nonnull @.str.16) #2
  %30 = load ptr, ptr @stdout, align 8, !tbaa !20
  %31 = load i64, ptr %2, align 8, !tbaa !19
  %32 = icmp ult i64 %31, 2
  %33 = select i1 %32, ptr @.str.11, ptr @.str.12
  %34 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %30, ptr noundef nonnull @.str.17, i64 noundef %31, ptr noundef nonnull %33) #2
  %35 = load ptr, ptr @stdout, align 8, !tbaa !20
  %36 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %35, ptr noundef nonnull @.str.14) #2
  %37 = load ptr, ptr @stdout, align 8, !tbaa !20
  %38 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %37, ptr noundef nonnull @.str.18) #2
  br label %39

39:                                               ; preds = %27, %.thread, %1
  ret void
}

; Function Attrs: nofree nounwind
declare noundef i32 @fprintf(ptr nocapture noundef, ptr nocapture noundef readonly, ...) local_unnamed_addr #1

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


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass