// File: /workspace/github_cpp_makefile_star2_O2/eatonphil[P]cpp-json/json.cpp
// Function: json::parse[abi:cxx11](std::vector<json::JSONToken, std::allocator<json::JSONToken>>, int)
std::tuple<JSONValue, int, std::string> parse(std::vector<JSONToken> tokens,
                                              int index) {
  auto token = tokens[index];
  switch (token.type) {
  case JSONTokenType::Number: {
    auto n = std::stod(token.value);
    return {JSONValue{.number = n, .type = JSONValueType::Number}, index + 1,
            ""};
  }
  case JSONTokenType::Boolean:
    return {JSONValue{.boolean = token.value == "true",
                      .type = JSONValueType::Boolean},
            index + 1, ""};
  case JSONTokenType::Null:
    return {JSONValue{.type = JSONValueType::Null}, index + 1, ""};
  case JSONTokenType::String:
    return {JSONValue{.string = token.value, .type = JSONValueType::String},
            index + 1, ""};
  case JSONTokenType::Syntax:
    if (token.value == "[") {
      auto [array, new_index, error] = parse_array(tokens, index + 1);
      return {JSONValue{.array = array, .type = JSONValueType::Array},
              new_index, error};
    }

    if (token.value == "{") {
      auto [object, new_index, error] = parse_object(tokens, index + 1);
      return {JSONValue{.object = std::optional(object),
                        .type = JSONValueType::Object},
              new_index, error};
    }
  }

  return {{}, index, format_parse_error("Failed to parse", token)};
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x1c0, %rsp            # imm = 0x1C0
movl %edx, %r14d
movq %rsi, %r15
movq %rdi, %rbx
movl %edx, -0x28(%rbp)
movslq %edx, %rax
imulq $0x38, %rax, %rsi
addq (%r15), %rsi
leaq -0x188(%rbp), %r12
movq %r12, %rdi
callq 0x5956
movl 0x20(%r12), %eax
cmpq $0x4, %rax
ja 0x47d2
leaq 0x4aec(%rip), %rcx      # 0x9018
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq -0x120(%rbp), %rdi
leaq -0x188(%rbp), %rsi
callq 0x6f86
xorl %eax, %eax
leaq -0x120(%rbp), %rsi
movb %al, 0x30(%rsi)
movb %al, 0x39(%rsi)
movb %al, 0x58(%rsi)
movb %al, 0x90(%rsi)
andl $0x0, 0x98(%rsi)
incl %r14d
leaq -0x80(%rbp), %rdx
movl %r14d, (%rdx)
leaq 0x4c8f(%rip), %rcx      # 0x9207
movq %rbx, %rdi
callq 0x6dc6
jmp 0x4872
xorl %eax, %eax
leaq -0x120(%rbp), %rsi
movb %al, 0x20(%rsi)
movb %al, 0x30(%rsi)
movb %al, 0x39(%rsi)
movb %al, 0x58(%rsi)
movb %al, 0x90(%rsi)
movl $0x5, 0x98(%rsi)
incl %r14d
leaq -0x80(%rbp), %rdx
movl %r14d, (%rdx)
leaq 0x4c4c(%rip), %rcx      # 0x9207
movq %rbx, %rdi
callq 0x6dc6
jmp 0x4872
leaq 0x4c20(%rip), %rsi      # 0x91ef
leaq -0x188(%rbp), %rdi
callq 0x5987
testb %al, %al
je 0x472d
leaq -0x150(%rbp), %rdi
movq %r15, %rsi
callq 0x59f6
incl %r14d
leaq -0x80(%rbp), %rdi
leaq -0x150(%rbp), %rsi
movl %r14d, %edx
callq 0x40f6
leaq -0x150(%rbp), %rdi
callq 0x58ce
leaq -0x58(%rbp), %rsi
xorl %eax, %eax
leaq -0xe0(%rbp), %rdi
movb %al, -0x20(%rdi)
movb %al, -0x10(%rdi)
movb %al, -0x7(%rdi)
callq 0x6fa0
leaq -0x60(%rbp), %rdx
leaq -0x120(%rbp), %rsi
movb $0x0, 0x90(%rsi)
movl $0x3, 0x98(%rsi)
leaq -0x80(%rbp), %rcx
movq %rbx, %rdi
callq 0x6fba
leaq -0x120(%rbp), %rdi
callq 0x5b9e
leaq -0x80(%rbp), %rdi
callq 0x5bc8
jmp 0x487e
xorl %r12d, %r12d
leaq -0x120(%rbp), %r15
movb %r12b, 0x20(%r15)
movb %r12b, 0x30(%r15)
leaq 0x4a39(%rip), %rsi      # 0x90c3
leaq -0x188(%rbp), %rdi
callq 0x5987
movb %al, 0x38(%r15)
movb $0x1, 0x39(%r15)
movb %r12b, 0x58(%r15)
movb %r12b, 0x90(%r15)
movl $0x4, 0x98(%r15)
incl %r14d
leaq -0x80(%rbp), %rdx
movl %r14d, (%rdx)
leaq 0x4b41(%rip), %rcx      # 0x9207
movq %rbx, %rdi
movq %r15, %rsi
callq 0x6dc6
jmp 0x4872
leaq -0x188(%rbp), %rdi
xorl %esi, %esi
callq 0x5b7f
xorl %eax, %eax
leaq -0x120(%rbp), %rsi
movb %al, 0x20(%rsi)
movsd %xmm0, 0x28(%rsi)
movb $0x1, 0x30(%rsi)
movb %al, 0x39(%rsi)
movb %al, 0x58(%rsi)
movb %al, 0x90(%rsi)
movl $0x1, 0x98(%rsi)
incl %r14d
leaq -0x80(%rbp), %rdx
movl %r14d, (%rdx)
leaq 0x4ae7(%rip), %rcx      # 0x9207
movq %rbx, %rdi
callq 0x6dc6
jmp 0x4872
leaq 0x4abd(%rip), %rsi      # 0x91f1
leaq -0x188(%rbp), %rdi
callq 0x5987
testb %al, %al
je 0x47d2
leaq -0x138(%rbp), %rdi
movq %r15, %rsi
callq 0x59f6
incl %r14d
leaq -0x80(%rbp), %rdi
leaq -0x138(%rbp), %rsi
movl %r14d, %edx
callq 0x4985
leaq -0x138(%rbp), %rdi
callq 0x58ce
leaq -0x58(%rbp), %rsi
xorl %eax, %eax
leaq -0xc0(%rbp), %rdi
movb %al, -0x40(%rdi)
movb %al, -0x30(%rdi)
movb %al, -0x27(%rdi)
movb %al, -0x8(%rdi)
callq 0x7006
leaq -0x60(%rbp), %rdx
leaq -0x120(%rbp), %rsi
movl $0x2, 0x98(%rsi)
leaq -0x80(%rbp), %rcx
movq %rbx, %rdi
callq 0x6fba
leaq -0x120(%rbp), %rdi
callq 0x5b9e
leaq -0x80(%rbp), %rdi
callq 0x5be8
jmp 0x487e
xorl %eax, %eax
movb %al, -0x100(%rbp)
movb %al, -0xf0(%rbp)
movb %al, -0xe7(%rbp)
movb %al, -0xc8(%rbp)
movb %al, -0x90(%rbp)
andl $0x0, -0x88(%rbp)
leaq 0x49f3(%rip), %rsi      # 0x91f3
leaq -0x1a8(%rbp), %rdi
leaq -0x21(%rbp), %rdx
callq 0x5820
leaq -0x1e0(%rbp), %rdi
leaq -0x188(%rbp), %rsi
callq 0x5956
leaq -0x80(%rbp), %rdi
leaq -0x1a8(%rbp), %rsi
leaq -0x1e0(%rbp), %rdx
callq 0x3fb8
leaq -0x120(%rbp), %rsi
leaq -0x28(%rbp), %rdx
leaq -0x80(%rbp), %rcx
movq %rbx, %rdi
callq 0x7020
leaq -0x80(%rbp), %rdi
callq 0x585c
leaq -0x1e0(%rbp), %rdi
callq 0x5870
leaq -0x1a8(%rbp), %rdi
callq 0x585c
leaq -0x120(%rbp), %rdi
callq 0x5b9e
leaq -0x188(%rbp), %rdi
callq 0x5870
movq %rbx, %rax
addq $0x1c0, %rsp            # imm = 0x1C0
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq -0x120(%rbp), %rdi
callq 0x5b9e
jmp 0x48c9
movq %rax, %rbx
leaq -0xe0(%rbp), %rdi
callq 0x65ba
leaq -0x120(%rbp), %rdi
callq 0x6478
leaq -0x80(%rbp), %rdi
callq 0x5be8
jmp 0x4971
movq %rax, %rbx
leaq -0x138(%rbp), %rdi
jmp 0x491a
jmp 0x4929
movq %rax, %rbx
leaq -0x120(%rbp), %rdi
callq 0x5b9e
jmp 0x4905
movq %rax, %rbx
leaq -0x120(%rbp), %rdi
callq 0x6478
leaq -0x80(%rbp), %rdi
callq 0x5bc8
jmp 0x4971
movq %rax, %rbx
leaq -0x150(%rbp), %rdi
callq 0x58ce
jmp 0x4971
jmp 0x4929
jmp 0x4962
jmp 0x4962
jmp 0x4929
movq %rax, %rbx
jmp 0x4971
jmp 0x4962
jmp 0x4962
movq %rax, %rbx
leaq -0x80(%rbp), %rdi
callq 0x585c
jmp 0x4943
movq %rax, %rbx
leaq -0x1e0(%rbp), %rdi
callq 0x5870
jmp 0x4954
movq %rax, %rbx
leaq -0x1a8(%rbp), %rdi
callq 0x585c
jmp 0x4965
movq %rax, %rbx
leaq -0x120(%rbp), %rdi
callq 0x5b9e
leaq -0x188(%rbp), %rdi
callq 0x5870
movq %rbx, %rdi
callq 0x3260