// File: eatonphil[P]cpp-json/json.cpp
// Function: json::parse_array[abi:cxx11](std::vector<json::JSONToken, std::allocator<json::JSONToken>>, int)
std::tuple<std::vector<JSONValue>, int, std::string>
parse_array(std::vector<JSONToken> tokens, int index) {
  std::vector<JSONValue> children = {};
  while (index < tokens.size()) {
    auto t = tokens[index];
    if (t.type == JSONTokenType::Syntax) {
      if (t.value == "]") {
        return {children, index + 1, ""};
      }

      if (t.value == ",") {
        index++;
        t = tokens[index];
      } else if (children.size() > 0) {
        return {{},
                index,
                format_parse_error("Expected comma after element in array", t)};
      }
    }

    auto [child, new_index, error] = parse(tokens, index);
    if (error.size()) {
      return {{}, index, error};
    }

    children.push_back(child);
    index = new_index;
  }

  return {
      {},
      index,
      format_parse_error("Unexpected EOF while parsing array", tokens[index])};
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x310, %rsp            # imm = 0x310
movq %rsi, -0x2e8(%rbp)
movq %rdi, -0x2e0(%rbp)
movq %rdi, %rax
movq %rax, -0x2d8(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
leaq -0x30(%rbp), %rdi
xorl %esi, %esi
movl $0x18, %edx
callq 0x40f0
leaq -0x30(%rbp), %rdi
callq 0x8d50
movq -0x2e8(%rbp), %rdi
movslq -0x14(%rbp), %rax
movq %rax, -0x2f0(%rbp)
callq 0x8d70
movq %rax, %rcx
movq -0x2f0(%rbp), %rax
cmpq %rcx, %rax
jae 0x62ee
movq -0x2e8(%rbp), %rdi
movslq -0x14(%rbp), %rsi
callq 0x8da0
movq %rax, %rsi
leaq -0x68(%rbp), %rdi
callq 0x8dc0
jmp 0x5f1f
cmpl $0x2, -0x48(%rbp)
jne 0x6163
leaq 0xf1b7(%rip), %rsi      # 0x150e7
leaq -0x68(%rbp), %rdi
callq 0x8e10
movb %al, -0x2f1(%rbp)
jmp 0x5f41
movb -0x2f1(%rbp), %al
testb $0x1, %al
jne 0x5f4d
jmp 0x5fa0
movq -0x2e0(%rbp), %rdi
movl -0x14(%rbp), %eax
incl %eax
movl %eax, -0x78(%rbp)
leaq 0xf288(%rip), %rcx      # 0x151eb
leaq -0x30(%rbp), %rsi
leaq -0x78(%rbp), %rdx
callq 0x8e40
jmp 0x5f72
movl $0x1, -0x7c(%rbp)
jmp 0x62ad
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x70(%rbp)
movl %eax, -0x74(%rbp)
jmp 0x646d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x70(%rbp)
movl %eax, -0x74(%rbp)
jmp 0x62e0
leaq 0xf142(%rip), %rsi      # 0x150e9
leaq -0x68(%rbp), %rdi
callq 0x8e10
movb %al, -0x2f2(%rbp)
jmp 0x5fb8
movb -0x2f2(%rbp), %al
testb $0x1, %al
jne 0x5fc4
jmp 0x5fef
movq -0x2e8(%rbp), %rdi
movl -0x14(%rbp), %eax
incl %eax
movl %eax, -0x14(%rbp)
movslq -0x14(%rbp), %rsi
callq 0x8da0
movq %rax, %rsi
leaq -0x68(%rbp), %rdi
callq 0x8e80
jmp 0x5fea
jmp 0x6161
leaq -0x30(%rbp), %rdi
callq 0x8ed0
cmpq $0x0, %rax
jbe 0x615f
xorps %xmm0, %xmm0
movaps %xmm0, -0xa0(%rbp)
movq $0x0, -0x90(%rbp)
leaq -0xa0(%rbp), %rdi
callq 0x8d50
leaq -0xe1(%rbp), %rdi
movq %rdi, -0x300(%rbp)
callq 0x42b0
movq -0x300(%rbp), %rdx
leaq 0xf0a7(%rip), %rsi      # 0x150eb
leaq -0xe0(%rbp), %rdi
callq 0x8560
jmp 0x6052
leaq -0x120(%rbp), %rdi
leaq -0x68(%rbp), %rsi
callq 0x8dc0
jmp 0x6064
leaq -0xc0(%rbp), %rdi
leaq -0xe0(%rbp), %rsi
leaq -0x120(%rbp), %rdx
callq 0x5c50
jmp 0x6080
movq -0x2e0(%rbp), %rdi
leaq -0xa0(%rbp), %rsi
leaq -0x14(%rbp), %rdx
leaq -0xc0(%rbp), %rcx
callq 0x8f00
jmp 0x60a0
leaq -0xc0(%rbp), %rdi
callq 0x87f0
leaq -0x120(%rbp), %rdi
callq 0x88b0
leaq -0xe0(%rbp), %rdi
callq 0x87f0
leaq -0xe1(%rbp), %rdi
callq 0x41d0
leaq -0xa0(%rbp), %rdi
callq 0x8f40
movl $0x1, -0x7c(%rbp)
jmp 0x62ad
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x70(%rbp)
movl %eax, -0x74(%rbp)
jmp 0x6142
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x70(%rbp)
movl %eax, -0x74(%rbp)
jmp 0x6136
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x70(%rbp)
movl %eax, -0x74(%rbp)
jmp 0x612a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x70(%rbp)
movl %eax, -0x74(%rbp)
leaq -0xc0(%rbp), %rdi
callq 0x87f0
leaq -0x120(%rbp), %rdi
callq 0x88b0
leaq -0xe0(%rbp), %rdi
callq 0x87f0
leaq -0xe1(%rbp), %rdi
callq 0x41d0
leaq -0xa0(%rbp), %rdi
callq 0x8f40
jmp 0x62e0
jmp 0x6161
jmp 0x6163
movq -0x2e8(%rbp), %rsi
leaq -0x200(%rbp), %rdi
callq 0x8fa0
jmp 0x6178
movl -0x14(%rbp), %edx
leaq -0x1e8(%rbp), %rdi
leaq -0x200(%rbp), %rsi
callq 0x6480
jmp 0x6190
leaq -0x200(%rbp), %rdi
callq 0x8bb0
leaq -0x1e8(%rbp), %rdi
callq 0x9090
movq %rax, -0x208(%rbp)
leaq -0x1e8(%rbp), %rdi
callq 0x90b0
movq %rax, -0x210(%rbp)
leaq -0x1e8(%rbp), %rdi
callq 0x90d0
movq %rax, -0x218(%rbp)
movq -0x218(%rbp), %rdi
callq 0x87a0
cmpq $0x0, %rax
je 0x627c
xorps %xmm0, %xmm0
movaps %xmm0, -0x230(%rbp)
movq $0x0, -0x220(%rbp)
leaq -0x230(%rbp), %rdi
movq %rdi, -0x308(%rbp)
callq 0x8d50
movq -0x2e0(%rbp), %rdi
movq -0x308(%rbp), %rsi
movq -0x218(%rbp), %rcx
leaq -0x14(%rbp), %rdx
callq 0x8f00
jmp 0x6233
leaq -0x230(%rbp), %rdi
callq 0x8f40
movl $0x1, -0x7c(%rbp)
jmp 0x62a1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x70(%rbp)
movl %eax, -0x74(%rbp)
leaq -0x200(%rbp), %rdi
callq 0x8bb0
jmp 0x62e0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x70(%rbp)
movl %eax, -0x74(%rbp)
leaq -0x230(%rbp), %rdi
callq 0x8f40
jmp 0x62d4
movq -0x208(%rbp), %rsi
leaq -0x30(%rbp), %rdi
callq 0x90f0
jmp 0x628e
movq -0x210(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x14(%rbp)
movl $0x0, -0x7c(%rbp)
leaq -0x1e8(%rbp), %rdi
callq 0x9160
leaq -0x68(%rbp), %rdi
callq 0x88b0
movl -0x7c(%rbp), %eax
testl %eax, %eax
jne 0x6454
jmp 0x62c3
jmp 0x5ed7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x70(%rbp)
movl %eax, -0x74(%rbp)
leaq -0x1e8(%rbp), %rdi
callq 0x9160
leaq -0x68(%rbp), %rdi
callq 0x88b0
jmp 0x646d
xorps %xmm0, %xmm0
movaps %xmm0, -0x250(%rbp)
movq $0x0, -0x240(%rbp)
leaq -0x250(%rbp), %rdi
callq 0x8d50
leaq -0x291(%rbp), %rdi
movq %rdi, -0x310(%rbp)
callq 0x42b0
movq -0x310(%rbp), %rdx
leaq 0xede1(%rip), %rsi      # 0x15111
leaq -0x290(%rbp), %rdi
callq 0x8560
jmp 0x633e
movq -0x2e8(%rbp), %rdi
movslq -0x14(%rbp), %rsi
callq 0x8da0
movq %rax, %rsi
leaq -0x2d0(%rbp), %rdi
callq 0x8dc0
jmp 0x635f
leaq -0x270(%rbp), %rdi
leaq -0x290(%rbp), %rsi
leaq -0x2d0(%rbp), %rdx
callq 0x5c50
jmp 0x637b
movq -0x2e0(%rbp), %rdi
leaq -0x250(%rbp), %rsi
leaq -0x14(%rbp), %rdx
leaq -0x270(%rbp), %rcx
callq 0x8f00
jmp 0x639b
leaq -0x270(%rbp), %rdi
callq 0x87f0
leaq -0x2d0(%rbp), %rdi
callq 0x88b0
leaq -0x290(%rbp), %rdi
callq 0x87f0
leaq -0x291(%rbp), %rdi
callq 0x41d0
leaq -0x250(%rbp), %rdi
callq 0x8f40
movl $0x1, -0x7c(%rbp)
jmp 0x6454
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x70(%rbp)
movl %eax, -0x74(%rbp)
jmp 0x643a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x70(%rbp)
movl %eax, -0x74(%rbp)
jmp 0x642e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x70(%rbp)
movl %eax, -0x74(%rbp)
jmp 0x6422
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x70(%rbp)
movl %eax, -0x74(%rbp)
leaq -0x270(%rbp), %rdi
callq 0x87f0
leaq -0x2d0(%rbp), %rdi
callq 0x88b0
leaq -0x290(%rbp), %rdi
callq 0x87f0
leaq -0x291(%rbp), %rdi
callq 0x41d0
leaq -0x250(%rbp), %rdi
callq 0x8f40
jmp 0x646d
leaq -0x30(%rbp), %rdi
callq 0x8f40
movq -0x2d8(%rbp), %rax
addq $0x310, %rsp            # imm = 0x310
popq %rbp
retq
leaq -0x30(%rbp), %rdi
callq 0x8f40
movq -0x70(%rbp), %rdi
callq 0x42a0
nop