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

; Function Attrs: nounwind uwtable
define dso_local i64 @goto_next(ptr noundef %0, i8 noundef signext %1, i64 noundef %2, ptr noundef %3) #0 {
  %5 = alloca i64, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i8, align 1
  %8 = alloca i64, align 8
  %9 = alloca ptr, align 8
  %10 = alloca i64, align 8
  %11 = alloca i32, align 4
  store ptr %0, ptr %6, align 8, !tbaa !5
  store i8 %1, ptr %7, align 1, !tbaa !9
  store i64 %2, ptr %8, align 8, !tbaa !10
  store ptr %3, ptr %9, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #2
  store i64 0, ptr %10, align 8, !tbaa !10
  %12 = load ptr, ptr %9, align 8, !tbaa !5
  %13 = load i64, ptr %12, align 8, !tbaa !10
  %14 = load i64, ptr %8, align 8, !tbaa !10
  %15 = icmp eq i64 %13, %14
  br i1 %15, label %16, label %17

16:                                               ; preds = %4
  store i64 -1, ptr %5, align 8
  store i32 1, ptr %11, align 4
  br label %48

17:                                               ; preds = %4
  %18 = load ptr, ptr %9, align 8, !tbaa !5
  %19 = load i64, ptr %18, align 8, !tbaa !10
  store i64 %19, ptr %10, align 8, !tbaa !10
  br label %20

20:                                               ; preds = %41, %17
  %21 = load ptr, ptr %6, align 8, !tbaa !5
  %22 = load i64, ptr %10, align 8, !tbaa !10
  %23 = getelementptr inbounds i8, ptr %21, i64 %22
  %24 = load i8, ptr %23, align 1, !tbaa !9
  %25 = sext i8 %24 to i32
  %26 = icmp ne i32 %25, 0
  br i1 %26, label %27, label %44

27:                                               ; preds = %20
  %28 = load ptr, ptr %6, align 8, !tbaa !5
  %29 = load i64, ptr %10, align 8, !tbaa !10
  %30 = getelementptr inbounds i8, ptr %28, i64 %29
  %31 = load i8, ptr %30, align 1, !tbaa !9
  %32 = sext i8 %31 to i32
  %33 = load i8, ptr %7, align 1, !tbaa !9
  %34 = sext i8 %33 to i32
  %35 = icmp eq i32 %32, %34
  br i1 %35, label %36, label %40

36:                                               ; preds = %27
  %37 = load i64, ptr %10, align 8, !tbaa !10
  %38 = load ptr, ptr %9, align 8, !tbaa !5
  store i64 %37, ptr %38, align 8, !tbaa !10
  %39 = load i64, ptr %10, align 8, !tbaa !10
  store i64 %39, ptr %5, align 8
  store i32 1, ptr %11, align 4
  br label %48

40:                                               ; preds = %27
  br label %41

41:                                               ; preds = %40
  %42 = load i64, ptr %10, align 8, !tbaa !10
  %43 = add i64 %42, 1
  store i64 %43, ptr %10, align 8, !tbaa !10
  br label %20, !llvm.loop !12

44:                                               ; preds = %20
  %45 = load i64, ptr %10, align 8, !tbaa !10
  %46 = load ptr, ptr %9, align 8, !tbaa !5
  store i64 %45, ptr %46, align 8, !tbaa !10
  %47 = load i64, ptr %10, align 8, !tbaa !10
  store i64 %47, ptr %5, align 8
  store i32 1, ptr %11, align 4
  br label %48

48:                                               ; preds = %44, %36, %16
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #2
  %49 = load i64, ptr %5, align 8
  ret i64 %49
}

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

attributes #0 = { 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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!7, !7, i64 0}
!10 = !{!11, !11, i64 0}
!11 = !{!"long", !7, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"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"

; Function Attrs: nofree norecurse nosync nounwind memory(argmem: readwrite) uwtable
define dso_local i64 @goto_next(ptr nocapture noundef readonly %0, i8 noundef signext %1, i64 noundef %2, ptr nocapture noundef %3) local_unnamed_addr #0 {
  %5 = load i64, ptr %3, align 8, !tbaa !5
  %6 = icmp eq i64 %5, %2
  br i1 %6, label %15, label %.preheader

.preheader:                                       ; preds = %4
  %7 = getelementptr inbounds i8, ptr %0, i64 %5
  %8 = load i8, ptr %7, align 1, !tbaa !9
  %.not19 = icmp eq i8 %8, 0
  br i1 %.not19, label %.sink.split, label %.lr.ph

.lr.ph:                                           ; preds = %.preheader, %11
  %9 = phi i8 [ %14, %11 ], [ %8, %.preheader ]
  %.020 = phi i64 [ %12, %11 ], [ %5, %.preheader ]
  %10 = icmp eq i8 %9, %1
  br i1 %10, label %.sink.split, label %11

11:                                               ; preds = %.lr.ph
  %12 = add i64 %.020, 1
  %13 = getelementptr inbounds i8, ptr %0, i64 %12
  %14 = load i8, ptr %13, align 1, !tbaa !9
  %.not = icmp eq i8 %14, 0
  br i1 %.not, label %.sink.split, label %.lr.ph, !llvm.loop !10

.sink.split:                                      ; preds = %11, %.lr.ph, %.preheader
  %.0.lcssa.sink = phi i64 [ %5, %.preheader ], [ %.020, %.lr.ph ], [ %12, %11 ]
  store i64 %.0.lcssa.sink, ptr %3, align 8, !tbaa !5
  br label %15

15:                                               ; preds = %.sink.split, %4
  %.015 = phi i64 [ -1, %4 ], [ %.0.lcssa.sink, %.sink.split ]
  ret i64 %.015
}

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

!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 = !{!"long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!7, !7, i64 0}
!10 = distinct !{!10, !11}
!11 = !{!"llvm.loop.mustprogress"}


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