// File: /workspace/github_cpp_makefile_star2_O1/eatonphil[P]cpp-json/json.cpp
// Function: json::lex(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
std::tuple<std::vector<JSONToken>, std::string> lex(std::string raw_json) {
  std::vector<JSONToken> tokens;
  auto original_copy = std::make_shared<std::string>(raw_json);
  auto generic_lexers = {lex_syntax, lex_string, lex_number,
                         lex_null,   lex_true,   lex_false};
  for (int i = 0; i < raw_json.length(); i++) {
    if (auto new_index = lex_whitespace(raw_json, i); i != new_index) {
      i = new_index - 1;
      continue;
    }

    auto found = false;
    for (auto lexer : generic_lexers) {
      if (auto [token, new_index, error] = lexer(raw_json, i); i != new_index) {
        if (error.length()) {
          return {{}, error};
        }

        token.full_source = original_copy;
        tokens.push_back(token);
        i = new_index - 1;
        found = true;
        break;
      }
    }

    if (found) {
      continue;
    }

    return {{}, format_error("Unable to lex", raw_json, i)};
  }

  return {tokens, ""};
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x138, %rsp            # imm = 0x138
movq %rsi, %r15
movq %rdi, -0x30(%rbp)
xorl %eax, %eax
movq %rax, -0xd0(%rbp)
xorps %xmm0, %xmm0
movaps %xmm0, -0xe0(%rbp)
leaq -0x60(%rbp), %rdi
movq %rax, -0x8(%rdi)
leaq -0x68(%rbp), %rsi
leaq -0xc8(%rbp), %rdx
movq %r15, %rcx
callq 0x8e5a
movq 0x8(%r15), %rdx
testq %rdx, %rdx
je 0x33d4
leaq -0x150(%rbp), %r14
xorl %r12d, %r12d
leaq -0x160(%rbp), %r13
movq %r15, -0x38(%rbp)
movq %r14, -0x160(%rbp)
movq (%r15), %rsi
addq %rsi, %rdx
movq %r13, %rdi
callq 0x853e
movq %r13, %rdi
movl %r12d, %esi
callq 0x2830
movl %eax, %r15d
movq -0x160(%rbp), %rdi
cmpq %r14, %rdi
je 0x321b
movq -0x150(%rbp), %rsi
incq %rsi
callq 0x21c0
leal -0x1(%r15), %ebx
cmpl %r15d, %r12d
cmovel %r12d, %ebx
jne 0x3398
movq $0x0, -0x58(%rbp)
xorl %r15d, %r15d
leaq 0xba32(%rip), %rax      # 0xec70
movq (%r15,%rax), %r14
leaq -0x130(%rbp), %r12
movq %r12, -0x140(%rbp)
movq -0x38(%rbp), %rax
movq (%rax), %rsi
movq 0x8(%rax), %rdx
addq %rsi, %rdx
leaq -0x140(%rbp), %r13
movq %r13, %rdi
callq 0x853e
leaq -0xc8(%rbp), %rdi
movq %r13, %rsi
movl %ebx, %edx
callq *%r14
movq -0x140(%rbp), %rdi
cmpq %r12, %rdi
je 0x3297
movq -0x130(%rbp), %rsi
incq %rsi
callq 0x21c0
movl -0xa8(%rbp), %r13d
xorl %r14d, %r14d
cmpl %r13d, %ebx
je 0x32e8
cmpq $0x0, -0xc0(%rbp)
je 0x3355
xorps %xmm0, %xmm0
movaps %xmm0, -0x50(%rbp)
movq $0x0, -0x40(%rbp)
movq -0x30(%rbp), %rdi
leaq -0x50(%rbp), %r14
movq %r14, %rsi
leaq -0xc8(%rbp), %rdx
callq 0x6f50
movq %r14, %rdi
callq 0x67c8
movl $0x1, %r14d
movl %ebx, %r12d
movq -0x70(%rbp), %rdi
testq %rdi, %rdi
je 0x32f9
callq 0x6ff2
movq -0xa0(%rbp), %rdi
leaq -0x90(%rbp), %rax
cmpq %rax, %rdi
je 0x331b
movq -0x90(%rbp), %rsi
incq %rsi
callq 0x21c0
movq -0xc8(%rbp), %rdi
leaq -0xb8(%rbp), %rax
cmpq %rax, %rdi
je 0x333d
movq -0xb8(%rbp), %rsi
incq %rsi
callq 0x21c0
cmpl %r13d, %ebx
jne 0x33a3
addq $0x8, %r15
movl %r12d, %ebx
cmpq $0x30, %r15
jne 0x3237
jmp 0x339d
movq -0x68(%rbp), %rax
movq %rax, -0x78(%rbp)
leaq -0x70(%rbp), %rdi
leaq -0x60(%rbp), %rsi
callq 0x6fac
leaq -0xe0(%rbp), %rdi
leaq -0xa0(%rbp), %rsi
callq 0x6806
movl -0xa8(%rbp), %r12d
decl %r12d
movl $0x5, %r14d
movb $0x1, %al
movq %rax, -0x58(%rbp)
jmp 0x32eb
movl %ebx, %r12d
jmp 0x33b6
movl $0x5, %r14d
cmpl $0x5, %r14d
jne 0x33eb
testb $0x1, -0x58(%rbp)
je 0x341b
leaq -0x150(%rbp), %r14
incl %r12d
movslq %r12d, %rax
movq -0x38(%rbp), %r15
movq 0x8(%r15), %rdx
cmpq %rax, %rdx
leaq -0x160(%rbp), %r13
ja 0x31dd
leaq 0x7e2c(%rip), %rdx      # 0xb207
leaq -0xe0(%rbp), %rsi
movq -0x30(%rbp), %rdi
callq 0x705e
movq -0x60(%rbp), %rdi
testq %rdi, %rdi
je 0x33f9
callq 0x6ff2
leaq -0xe0(%rbp), %rdi
callq 0x67c8
movq -0x30(%rbp), %rax
addq $0x138, %rsp            # imm = 0x138
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
xorps %xmm0, %xmm0
movaps %xmm0, -0x50(%rbp)
movq $0x0, -0x40(%rbp)
leaq -0x110(%rbp), %r15
movq %r15, -0x10(%r15)
leaq 0x7c92(%rip), %rsi      # 0xb0ce
leaq 0x7c98(%rip), %rdx      # 0xb0db
leaq -0x120(%rbp), %rdi
callq 0x8c74
leaq -0xf0(%rbp), %r13
movq %r13, -0x10(%r13)
movq -0x38(%rbp), %rax
movq (%rax), %rsi
movq 0x8(%rax), %rdx
addq %rsi, %rdx
leaq -0x100(%rbp), %rdi
callq 0x853e
leaq -0xc8(%rbp), %rdi
leaq -0x120(%rbp), %rsi
leaq -0x100(%rbp), %rdx
movl %r12d, %ecx
callq 0x24ae
leaq -0x50(%rbp), %rsi
leaq -0xc8(%rbp), %rdx
movq -0x30(%rbp), %rdi
callq 0x6f50
movq -0xc8(%rbp), %rdi
leaq -0xb8(%rbp), %rax
cmpq %rax, %rdi
je 0x34c7
movq -0xb8(%rbp), %rsi
incq %rsi
callq 0x21c0
movq -0x100(%rbp), %rdi
cmpq %r13, %rdi
je 0x34e2
movq -0xf0(%rbp), %rsi
incq %rsi
callq 0x21c0
movq -0x120(%rbp), %rdi
cmpq %r15, %rdi
je 0x34fd
movq -0x110(%rbp), %rsi
incq %rsi
callq 0x21c0
leaq -0x50(%rbp), %rdi
callq 0x67c8
jmp 0x33eb
movq %rax, %rbx
movq -0xc8(%rbp), %rdi
leaq -0xb8(%rbp), %rax
cmpq %rax, %rdi
je 0x3535
movq -0xb8(%rbp), %rsi
incq %rsi
callq 0x21c0
jmp 0x3535
movq %rax, %rbx
movq -0x100(%rbp), %rdi
cmpq %r13, %rdi
je 0x3555
movq -0xf0(%rbp), %rsi
incq %rsi
callq 0x21c0
jmp 0x3555
movq %rax, %rbx
movq -0x120(%rbp), %rdi
cmpq %r15, %rdi
je 0x3575
movq -0x110(%rbp), %rsi
incq %rsi
callq 0x21c0
jmp 0x3575
movq %rax, %rbx
leaq -0x50(%rbp), %rdi
callq 0x67c8
jmp 0x35cb
jmp 0x35c8
movq %rax, %rbx
jmp 0x35d9
jmp 0x35c8
movq %rax, %rbx
jmp 0x359a
movq %rax, %rbx
leaq -0x50(%rbp), %rdi
callq 0x67c8
leaq -0xc8(%rbp), %rdi
callq 0x6842
jmp 0x35cb
movq %rax, %rbx
movq -0x140(%rbp), %rdi
cmpq %r12, %rdi
je 0x35cb
movq -0x130(%rbp), %rsi
incq %rsi
callq 0x21c0
jmp 0x35cb
movq %rax, %rbx
movq -0x60(%rbp), %rdi
testq %rdi, %rdi
je 0x35d9
callq 0x6ff2
leaq -0xe0(%rbp), %rdi
callq 0x67c8
movq %rbx, %rdi
callq 0x2290