; 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
@.str = external hidden unnamed_addr constant [5 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [4 x i8], align 1

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

19:                                               ; preds = %1
  %20 = load i8, ptr %4, align 1, !tbaa !9
  %21 = sext i8 %20 to i32
  %22 = icmp eq i32 %21, 39
  br i1 %22, label %27, label %23

23:                                               ; preds = %19
  %24 = load i8, ptr %4, align 1, !tbaa !9
  %25 = sext i8 %24 to i32
  %26 = icmp eq i32 %25, 96
  br i1 %26, label %27, label %30

27:                                               ; preds = %23, %19, %1
  %28 = load ptr, ptr %3, align 8, !tbaa !5
  %29 = call ptr @handle_quoted(ptr noundef %28)
  store ptr %29, ptr %2, align 8
  store i32 1, ptr %6, align 4
  br label %108

30:                                               ; preds = %23
  %31 = call ptr @__ctype_b_loc() #5
  %32 = load ptr, ptr %31, align 8, !tbaa !5
  %33 = load i8, ptr %4, align 1, !tbaa !9
  %34 = sext i8 %33 to i32
  %35 = sext i32 %34 to i64
  %36 = getelementptr inbounds i16, ptr %32, i64 %35
  %37 = load i16, ptr %36, align 2, !tbaa !17
  %38 = zext i16 %37 to i32
  %39 = and i32 %38, 2048
  %40 = icmp ne i32 %39, 0
  br i1 %40, label %49, label %41

41:                                               ; preds = %30
  %42 = load i8, ptr %4, align 1, !tbaa !9
  %43 = sext i8 %42 to i32
  %44 = icmp eq i32 %43, 46
  br i1 %44, label %49, label %45

45:                                               ; preds = %41
  %46 = load i8, ptr %4, align 1, !tbaa !9
  %47 = sext i8 %46 to i32
  %48 = icmp eq i32 %47, 45
  br i1 %48, label %49, label %60

49:                                               ; preds = %45, %41, %30
  %50 = load ptr, ptr %3, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct.Lexer, ptr %50, i32 0, i32 8
  %52 = load i8, ptr %51, align 8, !tbaa !19, !range !20, !noundef !21
  %53 = trunc i8 %52 to i1
  br i1 %53, label %54, label %57

54:                                               ; preds = %49
  %55 = load ptr, ptr %3, align 8, !tbaa !5
  %56 = call ptr @handle_unrecognized(ptr noundef %55)
  store ptr %56, ptr %2, align 8
  store i32 1, ptr %6, align 4
  br label %108

57:                                               ; preds = %49
  %58 = load ptr, ptr %3, align 8, !tbaa !5
  %59 = call ptr @handle_numeric(ptr noundef %58)
  store ptr %59, ptr %2, align 8
  store i32 1, ptr %6, align 4
  br label %108

60:                                               ; preds = %45
  %61 = load ptr, ptr %5, align 8, !tbaa !5
  %62 = call i32 @strncmp(ptr noundef %61, ptr noundef @.str, i64 noundef 4) #6
  %63 = icmp eq i32 %62, 0
  br i1 %63, label %64, label %67

64:                                               ; preds = %60
  %65 = load ptr, ptr %3, align 8, !tbaa !5
  %66 = call ptr @_handle_string(ptr noundef %65, ptr noundef @.str, i64 noundef 4)
  store ptr %66, ptr %2, align 8
  store i32 1, ptr %6, align 4
  br label %108

67:                                               ; preds = %60
  %68 = load ptr, ptr %5, align 8, !tbaa !5
  %69 = call i32 @strncmp(ptr noundef %68, ptr noundef @.str.1, i64 noundef 5) #6
  %70 = icmp eq i32 %69, 0
  br i1 %70, label %71, label %74

71:                                               ; preds = %67
  %72 = load ptr, ptr %3, align 8, !tbaa !5
  %73 = call ptr @_handle_string(ptr noundef %72, ptr noundef @.str.1, i64 noundef 5)
  store ptr %73, ptr %2, align 8
  store i32 1, ptr %6, align 4
  br label %108

74:                                               ; preds = %67
  %75 = load ptr, ptr %5, align 8, !tbaa !5
  %76 = call i32 @strncmp(ptr noundef %75, ptr noundef @.str.2, i64 noundef 4) #6
  %77 = icmp eq i32 %76, 0
  br i1 %77, label %78, label %81

78:                                               ; preds = %74
  %79 = load ptr, ptr %3, align 8, !tbaa !5
  %80 = call ptr @_handle_string(ptr noundef %79, ptr noundef @.str.2, i64 noundef 4)
  store ptr %80, ptr %2, align 8
  store i32 1, ptr %6, align 4
  br label %108

81:                                               ; preds = %74
  %82 = load i8, ptr %4, align 1, !tbaa !9
  %83 = sext i8 %82 to i32
  %84 = icmp eq i32 %83, 93
  br i1 %84, label %97, label %85

85:                                               ; preds = %81
  %86 = load i8, ptr %4, align 1, !tbaa !9
  %87 = sext i8 %86 to i32
  %88 = icmp eq i32 %87, 125
  br i1 %88, label %97, label %89

89:                                               ; preds = %85
  %90 = load i8, ptr %4, align 1, !tbaa !9
  %91 = sext i8 %90 to i32
  %92 = icmp eq i32 %91, 91
  br i1 %92, label %97, label %93

93:                                               ; preds = %89
  %94 = load i8, ptr %4, align 1, !tbaa !9
  %95 = sext i8 %94 to i32
  %96 = icmp eq i32 %95, 123
  br i1 %96, label %97, label %98

97:                                               ; preds = %93, %89, %85, %81
  store ptr getelementptr inbounds ([5 x %struct.State], ptr @states, i64 0, i64 1), ptr %2, align 8
  store i32 1, ptr %6, align 4
  br label %108

98:                                               ; preds = %93
  %99 = load ptr, ptr %5, align 8, !tbaa !5
  %100 = call i32 @strncmp(ptr noundef %99, ptr noundef @.str.3, i64 noundef 3) #6
  %101 = icmp eq i32 %100, 0
  br i1 %101, label %102, label %105

102:                                              ; preds = %98
  %103 = load ptr, ptr %3, align 8, !tbaa !5
  %104 = call ptr @_handle_string(ptr noundef %103, ptr noundef @.str.3, i64 noundef 3)
  store ptr %104, ptr %2, align 8
  store i32 1, ptr %6, align 4
  br label %108

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

108:                                              ; preds = %105, %102, %97, %78, %71, %64, %57, %54, %27
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #4
  call void @llvm.lifetime.end.p0(i64 1, ptr %4) #4
  %109 = load ptr, ptr %2, align 8
  ret ptr %109
}

; 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 ptr @_handle_string(ptr noundef, ptr noundef, i64 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: nounwind uwtable
declare dso_local ptr @handle_unrecognized(ptr noundef) #0

; 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
declare dso_local ptr @handle_quoted(ptr noundef) #0

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

; Function Attrs: nounwind willreturn memory(read)
declare i32 @strncmp(ptr noundef, ptr noundef, i64 noundef) #3

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 willreturn memory(read) "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 }
attributes #5 = { nounwind willreturn memory(none) }
attributes #6 = { nounwind willreturn memory(read) }

!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 = !{!18, !18, i64 0}
!18 = !{!"short", !7, i64 0}
!19 = !{!11, !15, i64 96}
!20 = !{i8 0, i8 2}
!21 = !{}


; 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
@.str = external hidden unnamed_addr constant [5 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [4 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local ptr @value(ptr noundef %0) local_unnamed_addr #0 {
  %2 = tail call signext i8 @next_char(ptr noundef %0)
  %3 = load ptr, ptr %0, align 8, !tbaa !5
  %4 = getelementptr inbounds i8, ptr %0, i64 40
  %5 = load i64, ptr %4, align 8, !tbaa !14
  %6 = getelementptr inbounds i8, ptr %3, i64 %5
  switch i8 %2, label %9 [
    i8 96, label %7
    i8 39, label %7
    i8 34, label %7
  ]

7:                                                ; preds = %1, %1, %1
  %8 = tail call ptr @handle_quoted(ptr noundef nonnull %0)
  br label %50

9:                                                ; preds = %1
  %10 = tail call ptr @__ctype_b_loc() #3
  %11 = load ptr, ptr %10, align 8, !tbaa !15
  %12 = sext i8 %2 to i64
  %13 = getelementptr inbounds i16, ptr %11, i64 %12
  %14 = load i16, ptr %13, align 2, !tbaa !16
  %15 = and i16 %14, 2048
  %16 = icmp ne i16 %15, 0
  %17 = add i8 %2, -45
  %18 = icmp ult i8 %17, 2
  %or.cond11 = or i1 %18, %16
  br i1 %or.cond11, label %19, label %27

19:                                               ; preds = %9
  %20 = getelementptr inbounds i8, ptr %0, i64 96
  %21 = load i8, ptr %20, align 8, !tbaa !18, !range !19, !noundef !20
  %22 = trunc nuw i8 %21 to i1
  br i1 %22, label %23, label %25

23:                                               ; preds = %19
  %24 = tail call ptr @handle_unrecognized(ptr noundef nonnull %0)
  br label %50

25:                                               ; preds = %19
  %26 = tail call ptr @handle_numeric(ptr noundef nonnull %0)
  br label %50

27:                                               ; preds = %9
  %28 = tail call i32 @strncmp(ptr noundef nonnull dereferenceable(1) %6, ptr noundef nonnull dereferenceable(1) @.str, i64 noundef 4) #4
  %29 = icmp eq i32 %28, 0
  br i1 %29, label %30, label %32

30:                                               ; preds = %27
  %31 = tail call ptr @_handle_string(ptr noundef nonnull %0, ptr noundef nonnull @.str, i64 noundef 4)
  br label %50

32:                                               ; preds = %27
  %33 = tail call i32 @strncmp(ptr noundef nonnull dereferenceable(1) %6, ptr noundef nonnull dereferenceable(1) @.str.1, i64 noundef 5) #4
  %34 = icmp eq i32 %33, 0
  br i1 %34, label %35, label %37

35:                                               ; preds = %32
  %36 = tail call ptr @_handle_string(ptr noundef nonnull %0, ptr noundef nonnull @.str.1, i64 noundef 5)
  br label %50

37:                                               ; preds = %32
  %38 = tail call i32 @strncmp(ptr noundef nonnull dereferenceable(1) %6, ptr noundef nonnull dereferenceable(1) @.str.2, i64 noundef 4) #4
  %39 = icmp eq i32 %38, 0
  br i1 %39, label %40, label %42

40:                                               ; preds = %37
  %41 = tail call ptr @_handle_string(ptr noundef nonnull %0, ptr noundef nonnull @.str.2, i64 noundef 4)
  br label %50

42:                                               ; preds = %37
  switch i8 %2, label %43 [
    i8 125, label %50
    i8 123, label %50
    i8 93, label %50
    i8 91, label %50
  ]

43:                                               ; preds = %42
  %44 = tail call i32 @strncmp(ptr noundef nonnull dereferenceable(1) %6, ptr noundef nonnull dereferenceable(1) @.str.3, i64 noundef 3) #4
  %45 = icmp eq i32 %44, 0
  br i1 %45, label %46, label %48

46:                                               ; preds = %43
  %47 = tail call ptr @_handle_string(ptr noundef nonnull %0, ptr noundef nonnull @.str.3, i64 noundef 3)
  br label %50

48:                                               ; preds = %43
  %49 = tail call ptr @handle_unrecognized(ptr noundef nonnull %0)
  br label %50

50:                                               ; preds = %42, %42, %42, %42, %48, %46, %40, %35, %30, %25, %23, %7
  %.0 = phi ptr [ %8, %7 ], [ %24, %23 ], [ %26, %25 ], [ %31, %30 ], [ %36, %35 ], [ %41, %40 ], [ %47, %46 ], [ %49, %48 ], [ getelementptr inbounds (i8, ptr @states, i64 8), %42 ], [ getelementptr inbounds (i8, ptr @states, i64 8), %42 ], [ getelementptr inbounds (i8, ptr @states, i64 8), %42 ], [ getelementptr inbounds (i8, ptr @states, i64 8), %42 ]
  ret ptr %.0
}

; 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 ptr @_handle_string(ptr noundef, ptr noundef, i64 noundef) local_unnamed_addr #0

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

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

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

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: read)
declare i32 @strncmp(ptr nocapture noundef, ptr nocapture noundef, i64 noundef) local_unnamed_addr #2

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 = { mustprogress nofree nounwind willreturn memory(argmem: read) "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 willreturn memory(none) }
attributes #4 = { nounwind willreturn memory(read) }

!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, !7, i64 0}
!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 = !{!6, !10, i64 40}
!15 = !{!7, !7, i64 0}
!16 = !{!17, !17, i64 0}
!17 = !{!"short", !8, i64 0}
!18 = !{!6, !13, i64 96}
!19 = !{i8 0, i8 2}
!20 = !{}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass