// File: /workspace/github_cpp_makefile_star2_O3/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 $0x148, %rsp            # imm = 0x148
movq %rsi, %r13
movq %rdi, -0x38(%rbp)
xorl %eax, %eax
movq %rax, -0xe0(%rbp)
xorps %xmm0, %xmm0
movaps %xmm0, -0xf0(%rbp)
leaq -0x70(%rbp), %rdi
movq %rax, -0x8(%rdi)
leaq -0x78(%rbp), %rsi
leaq -0xd8(%rbp), %rdx
movq %r13, %rcx
callq 0x8e34
movq 0x8(%r13), %rdx
testq %rdx, %rdx
je 0x3394
leaq -0x160(%rbp), %r14
xorl %ebx, %ebx
leaq -0x170(%rbp), %r15
movq %r13, -0x40(%rbp)
movq %r14, -0x170(%rbp)
movq (%r13), %rsi
addq %rsi, %rdx
movq %r15, %rdi
callq 0x84f0
movq %r15, %rdi
movl %ebx, %esi
callq 0x27ff
movl %eax, %r12d
movq -0x170(%rbp), %rdi
cmpq %r14, %rdi
je 0x31db
movq -0x160(%rbp), %rsi
incq %rsi
callq 0x21c0
cmpl %r12d, %ebx
jne 0x335c
movq $0x0, -0x68(%rbp)
xorl %r15d, %r15d
movl %ebx, -0x2c(%rbp)
leaq 0xbaaf(%rip), %rax      # 0xeca8
movq (%r15,%rax), %r14
leaq -0x140(%rbp), %r12
movq %r12, -0x150(%rbp)
movq (%r13), %rsi
movq 0x8(%r13), %rdx
addq %rsi, %rdx
leaq -0x150(%rbp), %rbx
movq %rbx, %rdi
callq 0x84f0
leaq -0xd8(%rbp), %rdi
movq %rbx, %rsi
movl -0x2c(%rbp), %ebx
movl %ebx, %edx
callq *%r14
movq -0x150(%rbp), %rdi
cmpq %r12, %rdi
je 0x3252
movq -0x140(%rbp), %rsi
incq %rsi
callq 0x21c0
movl -0xb8(%rbp), %r14d
cmpl %r14d, %ebx
jne 0x3263
xorl %r13d, %r13d
jmp 0x32a5
cmpq $0x0, -0xd0(%rbp)
leaq -0x60(%rbp), %rbx
je 0x3316
xorps %xmm0, %xmm0
movaps %xmm0, -0x60(%rbp)
movq $0x0, -0x50(%rbp)
movq -0x38(%rbp), %rdi
movq %rbx, %rsi
leaq -0xd8(%rbp), %rdx
callq 0x6efc
movq %rbx, %rdi
callq 0x6770
xorl %r13d, %r13d
movl -0x2c(%rbp), %ebx
movl %ebx, %r12d
movq -0x80(%rbp), %rdi
testq %rdi, %rdi
je 0x32b6
callq 0x6fa2
movq -0xb0(%rbp), %rdi
leaq -0xa0(%rbp), %rax
cmpq %rax, %rdi
je 0x32d8
movq -0xa0(%rbp), %rsi
incq %rsi
callq 0x21c0
movq -0xd8(%rbp), %rdi
leaq -0xc8(%rbp), %rax
cmpq %rax, %rdi
je 0x32fa
movq -0xc8(%rbp), %rsi
incq %rsi
callq 0x21c0
cmpl %r14d, %ebx
jne 0x3361
addq $0x8, %r15
movl %r12d, %ebx
cmpq $0x30, %r15
movq -0x40(%rbp), %r13
jne 0x31ef
jmp 0x336a
movq -0x78(%rbp), %rax
movq %rax, -0x88(%rbp)
leaq -0x80(%rbp), %rdi
leaq -0x70(%rbp), %rsi
callq 0x6f58
leaq -0xf0(%rbp), %rdi
leaq -0xb0(%rbp), %rsi
callq 0x67ae
movl -0xb8(%rbp), %r12d
decl %r12d
movb $0x1, %al
movq %rax, -0x68(%rbp)
movb $0x1, %r13b
movl -0x2c(%rbp), %ebx
jmp 0x32a8
decl %r12d
jmp 0x337e
testb %r13b, %r13b
movq -0x40(%rbp), %r13
je 0x33ab
testb $0x1, -0x68(%rbp)
je 0x33db
leaq -0x160(%rbp), %r14
leaq -0x170(%rbp), %r15
incl %r12d
movslq %r12d, %rax
movq 0x8(%r13), %rdx
movl %r12d, %ebx
cmpq %rax, %rdx
ja 0x319d
leaq 0x7e6c(%rip), %rdx      # 0xb207
leaq -0xf0(%rbp), %rsi
movq -0x38(%rbp), %rdi
callq 0x700e
movq -0x70(%rbp), %rdi
testq %rdi, %rdi
je 0x33b9
callq 0x6fa2
leaq -0xf0(%rbp), %rdi
callq 0x6770
movq -0x38(%rbp), %rax
addq $0x148, %rsp            # imm = 0x148
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
xorps %xmm0, %xmm0
movaps %xmm0, -0x60(%rbp)
movq $0x0, -0x50(%rbp)
leaq -0x120(%rbp), %r15
movq %r15, -0x10(%r15)
leaq 0x7cd2(%rip), %rsi      # 0xb0ce
leaq 0x7cd8(%rip), %rdx      # 0xb0db
leaq -0x130(%rbp), %rdi
callq 0x8c32
leaq -0x100(%rbp), %r13
movq %r13, -0x10(%r13)
movq -0x40(%rbp), %rax
movq (%rax), %rsi
movq 0x8(%rax), %rdx
addq %rsi, %rdx
leaq -0x110(%rbp), %rdi
callq 0x84f0
leaq -0xd8(%rbp), %rdi
leaq -0x130(%rbp), %rsi
leaq -0x110(%rbp), %rdx
movl %r12d, %ecx
callq 0x24ae
leaq -0x60(%rbp), %rsi
leaq -0xd8(%rbp), %rdx
movq -0x38(%rbp), %rdi
callq 0x6efc
movq -0xd8(%rbp), %rdi
leaq -0xc8(%rbp), %rax
cmpq %rax, %rdi
je 0x3487
movq -0xc8(%rbp), %rsi
incq %rsi
callq 0x21c0
movq -0x110(%rbp), %rdi
cmpq %r13, %rdi
je 0x34a2
movq -0x100(%rbp), %rsi
incq %rsi
callq 0x21c0
movq -0x130(%rbp), %rdi
cmpq %r15, %rdi
je 0x34bd
movq -0x120(%rbp), %rsi
incq %rsi
callq 0x21c0
leaq -0x60(%rbp), %rdi
callq 0x6770
jmp 0x33ab
movq %rax, %rbx
movq -0xd8(%rbp), %rdi
leaq -0xc8(%rbp), %rax
cmpq %rax, %rdi
je 0x34f5
movq -0xc8(%rbp), %rsi
incq %rsi
callq 0x21c0
jmp 0x34f5
movq %rax, %rbx
movq -0x110(%rbp), %rdi
cmpq %r13, %rdi
je 0x3515
movq -0x100(%rbp), %rsi
incq %rsi
callq 0x21c0
jmp 0x3515
movq %rax, %rbx
movq -0x130(%rbp), %rdi
cmpq %r15, %rdi
je 0x3535
movq -0x120(%rbp), %rsi
incq %rsi
callq 0x21c0
jmp 0x3535
movq %rax, %rbx
leaq -0x60(%rbp), %rdi
callq 0x6770
jmp 0x358b
jmp 0x3588
movq %rax, %rbx
jmp 0x3599
jmp 0x3588
movq %rax, %rbx
jmp 0x355a
movq %rax, %rbx
leaq -0x60(%rbp), %rdi
callq 0x6770
leaq -0xd8(%rbp), %rdi
callq 0x67ea
jmp 0x358b
movq %rax, %rbx
movq -0x150(%rbp), %rdi
cmpq %r12, %rdi
je 0x358b
movq -0x140(%rbp), %rsi
incq %rsi
callq 0x21c0
jmp 0x358b
movq %rax, %rbx
movq -0x70(%rbp), %rdi
testq %rdi, %rdi
je 0x3599
callq 0x6fa2
leaq -0xf0(%rbp), %rdi
callq 0x6770
movq %rbx, %rdi
callq 0x2290