; LLVM IR from Nykakin/chompjs :: _chompjs (parser)

; 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.State = type { ptr }
%struct.Lexer = type { ptr, i64, %struct.CharBuffer, i64, i32, ptr, %struct.CharBuffer, i64, i8 }
%struct.CharBuffer = type { ptr, i64, i64 }

@states = external dso_local global [5 x %struct.State], align 16

; Function Attrs: nounwind uwtable
declare dso_local signext i8 @next_char(ptr noundef) #0

; Function Attrs: nounwind willreturn memory(none)
declare ptr @__ctype_b_loc() #1

; Function Attrs: nounwind uwtable
declare dso_local void @emit(i8 noundef signext, ptr noundef) #0

; Function Attrs: nounwind uwtable
declare dso_local void @emit_in_place(i8 noundef signext, ptr noundef) #0

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

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

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

14:                                               ; preds = %1
  %15 = load i8, ptr %4, align 1, !tbaa !9
  %16 = sext i8 %15 to i32
  %17 = icmp sle i32 %16, 57
  br i1 %17, label %18, label %21

18:                                               ; preds = %14
  %19 = load ptr, ptr %3, align 8, !tbaa !5
  %20 = call ptr @handle_numeric_standard_base(ptr noundef %19)
  store ptr %20, ptr %2, align 8
  store i32 1, ptr %5, align 4
  br label %128

21:                                               ; preds = %14, %1
  %22 = load i8, ptr %4, align 1, !tbaa !9
  %23 = sext i8 %22 to i32
  %24 = icmp eq i32 %23, 46
  br i1 %24, label %25, label %30

25:                                               ; preds = %21
  %26 = load ptr, ptr %3, align 8, !tbaa !5
  call void @emit_in_place(i8 noundef signext 48, ptr noundef %26)
  %27 = load ptr, ptr %3, align 8, !tbaa !5
  call void @emit(i8 noundef signext 46, ptr noundef %27)
  %28 = load ptr, ptr %3, align 8, !tbaa !5
  %29 = call ptr @handle_numeric_standard_base(ptr noundef %28)
  store ptr %29, ptr %2, align 8
  store i32 1, ptr %5, align 4
  br label %128

30:                                               ; preds = %21
  %31 = load i8, ptr %4, align 1, !tbaa !9
  %32 = sext i8 %31 to i32
  %33 = icmp eq i32 %32, 45
  br i1 %33, label %34, label %38

34:                                               ; preds = %30
  %35 = load ptr, ptr %3, align 8, !tbaa !5
  call void @emit(i8 noundef signext 45, ptr noundef %35)
  %36 = load ptr, ptr %3, align 8, !tbaa !5
  %37 = call ptr @handle_numeric(ptr noundef %36)
  store ptr %37, ptr %2, align 8
  store i32 1, ptr %5, align 4
  br label %128

38:                                               ; preds = %30
  %39 = load i8, ptr %4, align 1, !tbaa !9
  %40 = sext i8 %39 to i32
  %41 = icmp eq i32 %40, 48
  br i1 %41, label %42, label %127

42:                                               ; preds = %38
  call void @llvm.lifetime.start.p0(i64 1, ptr %6) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #3
  %43 = call ptr @__ctype_tolower_loc() #4
  %44 = load ptr, ptr %43, align 8, !tbaa !5
  %45 = load ptr, ptr %3, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct.Lexer, ptr %45, i32 0, i32 0
  %47 = load ptr, ptr %46, align 8, !tbaa !10
  %48 = load ptr, ptr %3, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct.Lexer, ptr %48, i32 0, i32 3
  %50 = load i64, ptr %49, align 8, !tbaa !16
  %51 = add i64 %50, 1
  %52 = getelementptr inbounds i8, ptr %47, i64 %51
  %53 = load i8, ptr %52, align 1, !tbaa !9
  %54 = sext i8 %53 to i32
  %55 = sext i32 %54 to i64
  %56 = getelementptr inbounds i32, ptr %44, i64 %55
  %57 = load i32, ptr %56, align 4, !tbaa !17
  store i32 %57, ptr %7, align 4, !tbaa !17
  %58 = load i32, ptr %7, align 4, !tbaa !17
  store i32 %58, ptr %8, align 4, !tbaa !17
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #3
  %59 = load i32, ptr %8, align 4, !tbaa !17
  %60 = trunc i32 %59 to i8
  store i8 %60, ptr %6, align 1, !tbaa !9
  %61 = load i8, ptr %6, align 1, !tbaa !9
  %62 = sext i8 %61 to i32
  %63 = icmp eq i32 %62, 46
  br i1 %63, label %64, label %69

64:                                               ; preds = %42
  %65 = load ptr, ptr %3, align 8, !tbaa !5
  call void @emit(i8 noundef signext 48, ptr noundef %65)
  %66 = load ptr, ptr %3, align 8, !tbaa !5
  call void @emit(i8 noundef signext 46, ptr noundef %66)
  %67 = load ptr, ptr %3, align 8, !tbaa !5
  %68 = call ptr @handle_numeric_standard_base(ptr noundef %67)
  store ptr %68, ptr %2, align 8
  store i32 1, ptr %5, align 4
  br label %126

69:                                               ; preds = %42
  %70 = load i8, ptr %6, align 1, !tbaa !9
  %71 = sext i8 %70 to i32
  %72 = icmp eq i32 %71, 120
  br i1 %72, label %77, label %73

73:                                               ; preds = %69
  %74 = load i8, ptr %6, align 1, !tbaa !9
  %75 = sext i8 %74 to i32
  %76 = icmp eq i32 %75, 88
  br i1 %76, label %77, label %80

77:                                               ; preds = %73, %69
  %78 = load ptr, ptr %3, align 8, !tbaa !5
  %79 = call ptr @handle_numeric_non_standard_base(ptr noundef %78, i32 noundef 16)
  store ptr %79, ptr %2, align 8
  store i32 1, ptr %5, align 4
  br label %126

80:                                               ; preds = %73
  %81 = load i8, ptr %6, align 1, !tbaa !9
  %82 = sext i8 %81 to i32
  %83 = icmp eq i32 %82, 111
  br i1 %83, label %88, label %84

84:                                               ; preds = %80
  %85 = load i8, ptr %6, align 1, !tbaa !9
  %86 = sext i8 %85 to i32
  %87 = icmp eq i32 %86, 79
  br i1 %87, label %88, label %95

88:                                               ; preds = %84, %80
  %89 = load ptr, ptr %3, align 8, !tbaa !5
  %90 = getelementptr inbounds %struct.Lexer, ptr %89, i32 0, i32 3
  %91 = load i64, ptr %90, align 8, !tbaa !16
  %92 = add i64 %91, 2
  store i64 %92, ptr %90, align 8, !tbaa !16
  %93 = load ptr, ptr %3, align 8, !tbaa !5
  %94 = call ptr @handle_numeric_non_standard_base(ptr noundef %93, i32 noundef 8)
  store ptr %94, ptr %2, align 8
  store i32 1, ptr %5, align 4
  br label %126

95:                                               ; preds = %84
  %96 = call ptr @__ctype_b_loc() #4
  %97 = load ptr, ptr %96, align 8, !tbaa !5
  %98 = load i8, ptr %6, align 1, !tbaa !9
  %99 = sext i8 %98 to i32
  %100 = sext i32 %99 to i64
  %101 = getelementptr inbounds i16, ptr %97, i64 %100
  %102 = load i16, ptr %101, align 2, !tbaa !18
  %103 = zext i16 %102 to i32
  %104 = and i32 %103, 2048
  %105 = icmp ne i32 %104, 0
  br i1 %105, label %106, label %109

106:                                              ; preds = %95
  %107 = load ptr, ptr %3, align 8, !tbaa !5
  %108 = call ptr @handle_numeric_non_standard_base(ptr noundef %107, i32 noundef 8)
  store ptr %108, ptr %2, align 8
  store i32 1, ptr %5, align 4
  br label %126

109:                                              ; preds = %95
  %110 = load i8, ptr %6, align 1, !tbaa !9
  %111 = sext i8 %110 to i32
  %112 = icmp eq i32 %111, 98
  br i1 %112, label %117, label %113

113:                                              ; preds = %109
  %114 = load i8, ptr %6, align 1, !tbaa !9
  %115 = sext i8 %114 to i32
  %116 = icmp eq i32 %115, 66
  br i1 %116, label %117, label %124

117:                                              ; preds = %113, %109
  %118 = load ptr, ptr %3, align 8, !tbaa !5
  %119 = getelementptr inbounds %struct.Lexer, ptr %118, i32 0, i32 3
  %120 = load i64, ptr %119, align 8, !tbaa !16
  %121 = add i64 %120, 2
  store i64 %121, ptr %119, align 8, !tbaa !16
  %122 = load ptr, ptr %3, align 8, !tbaa !5
  %123 = call ptr @handle_numeric_non_standard_base(ptr noundef %122, i32 noundef 2)
  store ptr %123, ptr %2, align 8
  store i32 1, ptr %5, align 4
  br label %126

124:                                              ; preds = %113
  %125 = load ptr, ptr %3, align 8, !tbaa !5
  call void @emit(i8 noundef signext 48, ptr noundef %125)
  store ptr getelementptr inbounds ([5 x %struct.State], ptr @states, i64 0, i64 1), ptr %2, align 8
  store i32 1, ptr %5, align 4
  br label %126

126:                                              ; preds = %124, %117, %106, %88, %77, %64
  call void @llvm.lifetime.end.p0(i64 1, ptr %6) #3
  br label %128

127:                                              ; preds = %38
  store ptr getelementptr inbounds ([5 x %struct.State], ptr @states, i64 0, i64 4), ptr %2, align 8
  store i32 1, ptr %5, align 4
  br label %128

128:                                              ; preds = %127, %126, %34, %25, %18
  call void @llvm.lifetime.end.p0(i64 1, ptr %4) #3
  %129 = load ptr, ptr %2, align 8
  ret ptr %129
}

; Function Attrs: nounwind uwtable
declare dso_local ptr @handle_numeric_standard_base(ptr noundef) #0

; Function Attrs: nounwind willreturn memory(none)
declare ptr @__ctype_tolower_loc() #1

; Function Attrs: nounwind uwtable
declare dso_local ptr @handle_numeric_non_standard_base(ptr noundef, i32 noundef) #0

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 = { 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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { nounwind }
attributes #4 = { 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 = !{!7, !7, i64 0}
!10 = !{!11, !6, i64 0}
!11 = !{!"Lexer", !6, i64 0, !12, i64 8, !13, i64 16, !12, i64 40, !14, i64 48, !6, i64 56, !13, i64 64, !12, i64 88, !15, i64 96}
!12 = !{!"long", !7, i64 0}
!13 = !{!"CharBuffer", !6, i64 0, !12, i64 8, !12, i64 16}
!14 = !{!"int", !7, i64 0}
!15 = !{!"_Bool", !7, i64 0}
!16 = !{!11, !12, i64 40}
!17 = !{!14, !14, i64 0}
!18 = !{!19, !19, i64 0}
!19 = !{!"short", !7, i64 0}


; 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.State = type { ptr }

@states = external dso_local global [5 x %struct.State], align 16

; Function Attrs: nounwind uwtable
declare dso_local signext i8 @next_char(ptr noundef) local_unnamed_addr #0

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

; Function Attrs: nounwind uwtable
declare dso_local void @emit(i8 noundef signext, ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local void @emit_in_place(i8 noundef signext, ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local ptr @handle_numeric(ptr noundef %0) local_unnamed_addr #0 {
  %2 = tail call signext i8 @next_char(ptr noundef %0)
  %3 = add i8 %2, -49
  %or.cond47 = icmp ult i8 %3, 9
  br i1 %or.cond47, label %tailrecurse._crit_edge, label %.lr.ph

tailrecurse._crit_edge:                           ; preds = %tailrecurse, %1
  %4 = tail call ptr @handle_numeric_standard_base(ptr noundef %0)
  br label %.loopexit

.lr.ph:                                           ; preds = %1, %tailrecurse
  %5 = phi i8 [ %8, %tailrecurse ], [ %2, %1 ]
  switch i8 %5, label %.loopexit [
    i8 46, label %6
    i8 45, label %tailrecurse
    i8 48, label %10
  ]

6:                                                ; preds = %.lr.ph
  tail call void @emit_in_place(i8 noundef signext 48, ptr noundef %0)
  tail call void @emit(i8 noundef signext 46, ptr noundef %0)
  %7 = tail call ptr @handle_numeric_standard_base(ptr noundef %0)
  br label %.loopexit

tailrecurse:                                      ; preds = %.lr.ph
  tail call void @emit(i8 noundef signext 45, ptr noundef %0)
  %8 = tail call signext i8 @next_char(ptr noundef %0)
  %9 = add i8 %8, -49
  %or.cond = icmp ult i8 %9, 9
  br i1 %or.cond, label %tailrecurse._crit_edge, label %.lr.ph

10:                                               ; preds = %.lr.ph
  %11 = tail call ptr @__ctype_tolower_loc() #2
  %12 = load ptr, ptr %11, align 8, !tbaa !5
  %13 = load ptr, ptr %0, align 8, !tbaa !9
  %14 = getelementptr inbounds i8, ptr %0, i64 40
  %15 = load i64, ptr %14, align 8, !tbaa !15
  %16 = getelementptr i8, ptr %13, i64 %15
  %17 = getelementptr i8, ptr %16, i64 1
  %18 = load i8, ptr %17, align 1, !tbaa !16
  %19 = sext i8 %18 to i64
  %20 = getelementptr inbounds i32, ptr %12, i64 %19
  %21 = load i32, ptr %20, align 4, !tbaa !17
  %sext = shl i32 %21, 24
  %22 = ashr exact i32 %sext, 24
  %23 = icmp eq i32 %sext, 771751936
  br i1 %23, label %24, label %26

24:                                               ; preds = %10
  tail call void @emit(i8 noundef signext 48, ptr noundef nonnull %0)
  tail call void @emit(i8 noundef signext 46, ptr noundef nonnull %0)
  %25 = tail call ptr @handle_numeric_standard_base(ptr noundef nonnull %0)
  br label %.loopexit

26:                                               ; preds = %10
  %27 = and i32 %21, 223
  %trunc = trunc nuw i32 %27 to i8
  switch i8 %trunc, label %33 [
    i8 88, label %28
    i8 79, label %30
  ]

28:                                               ; preds = %26
  %29 = tail call ptr @handle_numeric_non_standard_base(ptr noundef nonnull %0, i32 noundef 16)
  br label %.loopexit

30:                                               ; preds = %26
  %31 = add i64 %15, 2
  store i64 %31, ptr %14, align 8, !tbaa !15
  %32 = tail call ptr @handle_numeric_non_standard_base(ptr noundef nonnull %0, i32 noundef 8)
  br label %.loopexit

33:                                               ; preds = %26
  %34 = tail call ptr @__ctype_b_loc() #2
  %35 = load ptr, ptr %34, align 8, !tbaa !5
  %36 = sext i32 %22 to i64
  %37 = getelementptr inbounds i16, ptr %35, i64 %36
  %38 = load i16, ptr %37, align 2, !tbaa !18
  %39 = and i16 %38, 2048
  %.not = icmp eq i16 %39, 0
  br i1 %.not, label %42, label %40

40:                                               ; preds = %33
  %41 = tail call ptr @handle_numeric_non_standard_base(ptr noundef nonnull %0, i32 noundef 8)
  br label %.loopexit

42:                                               ; preds = %33
  %or.cond11 = icmp eq i32 %27, 66
  br i1 %or.cond11, label %43, label %46

43:                                               ; preds = %42
  %44 = add i64 %15, 2
  store i64 %44, ptr %14, align 8, !tbaa !15
  %45 = tail call ptr @handle_numeric_non_standard_base(ptr noundef nonnull %0, i32 noundef 2)
  br label %.loopexit

46:                                               ; preds = %42
  tail call void @emit(i8 noundef signext 48, ptr noundef nonnull %0)
  br label %.loopexit

.loopexit:                                        ; preds = %.lr.ph, %24, %28, %30, %40, %43, %46, %6, %tailrecurse._crit_edge
  %.1 = phi ptr [ %4, %tailrecurse._crit_edge ], [ %7, %6 ], [ %25, %24 ], [ %29, %28 ], [ %32, %30 ], [ %41, %40 ], [ %45, %43 ], [ getelementptr inbounds (i8, ptr @states, i64 8), %46 ], [ getelementptr inbounds (i8, ptr @states, i64 32), %.lr.ph ]
  ret ptr %.1
}

; Function Attrs: nounwind uwtable
declare dso_local ptr @handle_numeric_standard_base(ptr noundef) local_unnamed_addr #0

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

; Function Attrs: nounwind uwtable
declare dso_local ptr @handle_numeric_non_standard_base(ptr noundef, i32 noundef) local_unnamed_addr #0

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 = { 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 #2 = { 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, !6, i64 0}
!10 = !{!"Lexer", !6, i64 0, !11, i64 8, !12, i64 16, !11, i64 40, !13, i64 48, !6, i64 56, !12, i64 64, !11, i64 88, !14, i64 96}
!11 = !{!"long", !7, i64 0}
!12 = !{!"CharBuffer", !6, i64 0, !11, i64 8, !11, i64 16}
!13 = !{!"int", !7, i64 0}
!14 = !{!"_Bool", !7, i64 0}
!15 = !{!10, !11, i64 40}
!16 = !{!7, !7, i64 0}
!17 = !{!13, !13, i64 0}
!18 = !{!19, !19, i64 0}
!19 = !{!"short", !7, i64 0}


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