; 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 signext i8 @last_char(ptr noundef) #0

; 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_standard_base(ptr noundef %0) #0 {
  %2 = alloca ptr, align 8
  %3 = alloca i8, align 1
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 1, ptr %3) #3
  %6 = load ptr, ptr %2, align 8, !tbaa !5
  %7 = call signext i8 @next_char(ptr noundef %6)
  store i8 %7, ptr %3, align 1, !tbaa !9
  br label %8

8:                                                ; preds = %73, %1
  %9 = load i8, ptr %3, align 1, !tbaa !9
  %10 = sext i8 %9 to i32
  %11 = icmp ne i32 %10, 95
  br i1 %11, label %12, label %15

12:                                               ; preds = %8
  %13 = load i8, ptr %3, align 1, !tbaa !9
  %14 = load ptr, ptr %2, align 8, !tbaa !5
  call void @emit(i8 noundef signext %13, ptr noundef %14)
  br label %20

15:                                               ; preds = %8
  %16 = load ptr, ptr %2, align 8, !tbaa !5
  %17 = getelementptr inbounds %struct.Lexer, ptr %16, i32 0, i32 3
  %18 = load i64, ptr %17, align 8, !tbaa !10
  %19 = add i64 %18, 1
  store i64 %19, ptr %17, align 8, !tbaa !10
  br label %20

20:                                               ; preds = %15, %12
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #3
  %21 = call ptr @__ctype_tolower_loc() #4
  %22 = load ptr, ptr %21, align 8, !tbaa !5
  %23 = load ptr, ptr %2, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct.Lexer, ptr %23, i32 0, i32 0
  %25 = load ptr, ptr %24, align 8, !tbaa !16
  %26 = load ptr, ptr %2, align 8, !tbaa !5
  %27 = getelementptr inbounds %struct.Lexer, ptr %26, i32 0, i32 3
  %28 = load i64, ptr %27, align 8, !tbaa !10
  %29 = getelementptr inbounds i8, ptr %25, i64 %28
  %30 = load i8, ptr %29, align 1, !tbaa !9
  %31 = sext i8 %30 to i32
  %32 = sext i32 %31 to i64
  %33 = getelementptr inbounds i32, ptr %22, i64 %32
  %34 = load i32, ptr %33, align 4, !tbaa !17
  store i32 %34, ptr %4, align 4, !tbaa !17
  %35 = load i32, ptr %4, align 4, !tbaa !17
  store i32 %35, ptr %5, align 4, !tbaa !17
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #3
  %36 = load i32, ptr %5, align 4, !tbaa !17
  %37 = trunc i32 %36 to i8
  store i8 %37, ptr %3, align 1, !tbaa !9
  br label %38

38:                                               ; preds = %20
  %39 = call ptr @__ctype_b_loc() #4
  %40 = load ptr, ptr %39, align 8, !tbaa !5
  %41 = load i8, ptr %3, align 1, !tbaa !9
  %42 = sext i8 %41 to i32
  %43 = sext i32 %42 to i64
  %44 = getelementptr inbounds i16, ptr %40, i64 %43
  %45 = load i16, ptr %44, align 2, !tbaa !18
  %46 = zext i16 %45 to i32
  %47 = and i32 %46, 2048
  %48 = icmp ne i32 %47, 0
  br i1 %48, label %73, label %49

49:                                               ; preds = %38
  %50 = load i8, ptr %3, align 1, !tbaa !9
  %51 = sext i8 %50 to i32
  %52 = icmp eq i32 %51, 46
  br i1 %52, label %73, label %53

53:                                               ; preds = %49
  %54 = load i8, ptr %3, align 1, !tbaa !9
  %55 = sext i8 %54 to i32
  %56 = icmp eq i32 %55, 101
  br i1 %56, label %73, label %57

57:                                               ; preds = %53
  %58 = load i8, ptr %3, align 1, !tbaa !9
  %59 = sext i8 %58 to i32
  %60 = icmp eq i32 %59, 69
  br i1 %60, label %73, label %61

61:                                               ; preds = %57
  %62 = load i8, ptr %3, align 1, !tbaa !9
  %63 = sext i8 %62 to i32
  %64 = icmp eq i32 %63, 43
  br i1 %64, label %73, label %65

65:                                               ; preds = %61
  %66 = load i8, ptr %3, align 1, !tbaa !9
  %67 = sext i8 %66 to i32
  %68 = icmp eq i32 %67, 45
  br i1 %68, label %73, label %69

69:                                               ; preds = %65
  %70 = load i8, ptr %3, align 1, !tbaa !9
  %71 = sext i8 %70 to i32
  %72 = icmp eq i32 %71, 95
  br label %73

73:                                               ; preds = %69, %65, %61, %57, %53, %49, %38
  %74 = phi i1 [ true, %65 ], [ true, %61 ], [ true, %57 ], [ true, %53 ], [ true, %49 ], [ true, %38 ], [ %72, %69 ]
  br i1 %74, label %8, label %75, !llvm.loop !20

75:                                               ; preds = %73
  %76 = load ptr, ptr %2, align 8, !tbaa !5
  %77 = call signext i8 @last_char(ptr noundef %76)
  %78 = sext i8 %77 to i32
  %79 = icmp eq i32 %78, 46
  br i1 %79, label %80, label %82

80:                                               ; preds = %75
  %81 = load ptr, ptr %2, align 8, !tbaa !5
  call void @emit_in_place(i8 noundef signext 48, ptr noundef %81)
  br label %82

82:                                               ; preds = %80, %75
  call void @llvm.lifetime.end.p0(i64 1, ptr %3) #3
  ret ptr getelementptr inbounds ([5 x %struct.State], ptr @states, i64 0, i64 1)
}

; Function Attrs: nounwind willreturn memory(none)
declare ptr @__ctype_tolower_loc() #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 = { 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, !12, i64 40}
!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, !6, i64 0}
!17 = !{!14, !14, i64 0}
!18 = !{!19, !19, i64 0}
!19 = !{!"short", !7, i64 0}
!20 = distinct !{!20, !21}
!21 = !{!"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"

%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 signext i8 @last_char(ptr noundef) local_unnamed_addr #0

; 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 nonnull ptr @handle_numeric_standard_base(ptr noundef %0) local_unnamed_addr #0 {
  %2 = tail call signext i8 @next_char(ptr noundef %0)
  %3 = getelementptr inbounds i8, ptr %0, i64 40
  br label %.critedge

.critedge:                                        ; preds = %8, %1
  %.0 = phi i8 [ %2, %1 ], [ %18, %8 ]
  %.not = icmp eq i8 %.0, 95
  br i1 %.not, label %5, label %4

4:                                                ; preds = %.critedge
  tail call void @emit(i8 noundef signext %.0, ptr noundef %0)
  %.pre = load i64, ptr %3, align 8, !tbaa !5
  br label %8

5:                                                ; preds = %.critedge
  %6 = load i64, ptr %3, align 8, !tbaa !5
  %7 = add i64 %6, 1
  store i64 %7, ptr %3, align 8, !tbaa !5
  br label %8

8:                                                ; preds = %5, %4
  %9 = phi i64 [ %7, %5 ], [ %.pre, %4 ]
  %10 = tail call ptr @__ctype_tolower_loc() #2
  %11 = load ptr, ptr %10, align 8, !tbaa !14
  %12 = load ptr, ptr %0, align 8, !tbaa !15
  %13 = getelementptr inbounds i8, ptr %12, i64 %9
  %14 = load i8, ptr %13, align 1, !tbaa !16
  %15 = sext i8 %14 to i64
  %16 = getelementptr inbounds i32, ptr %11, i64 %15
  %17 = load i32, ptr %16, align 4, !tbaa !17
  %18 = trunc i32 %17 to i8
  %19 = tail call ptr @__ctype_b_loc() #2
  %20 = load ptr, ptr %19, align 8, !tbaa !14
  %sext = shl i32 %17, 24
  %21 = ashr exact i32 %sext, 24
  %22 = sext i32 %21 to i64
  %23 = getelementptr inbounds i16, ptr %20, i64 %22
  %24 = load i16, ptr %23, align 2, !tbaa !18
  %25 = and i16 %24, 2048
  %26 = icmp ne i16 %25, 0
  %27 = icmp eq i32 %sext, 771751936
  %or.cond = or i1 %27, %26
  %28 = and i32 %17, 223
  %29 = icmp eq i32 %28, 69
  %or.cond8 = or i1 %29, %or.cond
  %30 = icmp eq i32 %sext, 721420288
  %or.cond11 = or i1 %30, %or.cond8
  %31 = icmp eq i32 %sext, 754974720
  %or.cond14 = or i1 %31, %or.cond11
  %32 = icmp eq i32 %sext, 1593835520
  %or.cond17 = or i1 %32, %or.cond14
  br i1 %or.cond17, label %.critedge, label %33, !llvm.loop !20

33:                                               ; preds = %8
  %34 = tail call signext i8 @last_char(ptr noundef nonnull %0)
  %35 = icmp eq i8 %34, 46
  br i1 %35, label %36, label %37

36:                                               ; preds = %33
  tail call void @emit_in_place(i8 noundef signext 48, ptr noundef nonnull %0)
  br label %37

37:                                               ; preds = %36, %33
  ret ptr getelementptr inbounds (i8, ptr @states, i64 8)
}

; Function Attrs: mustprogress nofree nosync nounwind willreturn memory(none)
declare ptr @__ctype_tolower_loc() local_unnamed_addr #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 = { 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, !10, i64 40}
!6 = !{!"Lexer", !7, i64 0, !10, i64 8, !11, i64 16, !10, i64 40, !12, i64 48, !7, i64 56, !11, i64 64, !10, i64 88, !13, i64 96}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"long", !8, i64 0}
!11 = !{!"CharBuffer", !7, i64 0, !10, i64 8, !10, i64 16}
!12 = !{!"int", !8, i64 0}
!13 = !{!"_Bool", !8, i64 0}
!14 = !{!7, !7, i64 0}
!15 = !{!6, !7, i64 0}
!16 = !{!8, !8, i64 0}
!17 = !{!12, !12, i64 0}
!18 = !{!19, !19, i64 0}
!19 = !{!"short", !8, i64 0}
!20 = distinct !{!20, !21}
!21 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,LICMPass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass