// File: /workspace/github_cpp_makefile_star2_O2/rfotino[P]consolite-compiler/src/syntax.cpp
// Function: LocalVarToken::parse(Tokenizer*, std::vector<std::shared_ptr<FunctionToken>, std::allocator<std::shared_ptr<FunctionToken>>> const&, std::vector<std::shared_ptr<GlobalVarToken>, std::allocator<std::shared_ptr<GlobalVarToken>>> const&, std::vector<std::shared_ptr<ParamToken>, std::allocator<std::shared_ptr<ParamToken>>> const&, std::vector<std::shared_ptr<LocalVarToken>, std::allocator<std::shared_ptr<LocalVarToken>>> const&)
bool LocalVarToken::parse(
      Tokenizer *tokenizer,
      const std::vector<std::shared_ptr<FunctionToken>>& functions,
      const std::vector<std::shared_ptr<GlobalVarToken>>& globals,
      const std::vector<std::shared_ptr<ParamToken>>& parameters,
      const std::vector<std::shared_ptr<LocalVarToken>>& localVars) {
  _lineNum = tokenizer->peekNext().line();
  // Parse the type
  if (!_type.parse(tokenizer, functions, globals, parameters, localVars)) {
    return false;
  }
  // Validate the type
  if ("void" == _type.name()) {
    _error("Local var cannot be of type 'void'.", _type.line());
    return false;
  }
  // Get and validate the name
  AtomToken nameToken = tokenizer->getNext();
  if (nameToken.str().empty()) {
    _error("Unexpected EOF.", nameToken.line());
    return false;
  }
  _name = nameToken.str();
  if (!isValidName(_name)) {
    _error("Invalid local var name '" + _name + "'.", _type.line());
    return false;
  } else if (getFunction(_name, functions)) {
    _error("Local var '" + _name + "' conflicts with existing function name.",
           nameToken.line());
    return false;
  } else if (getGlobal(_name, globals)) {
    _error("Local var '" + _name + "' conflicts with existing global var name.",
           nameToken.line());
    return false;
  } else if (getParameter(_name, parameters)) {
    _error("Local var '" + _name + "' conflicts with existing parameter name.",
           nameToken.line());
    return false;
  } else if (getLocal(_name, localVars)) {
    _error("Local var '" + _name + "' conflicts with existing local var name.",
           nameToken.line());
    return false;
  }
  // Validate the value (if set)
  AtomToken next = tokenizer->getNext();
  AtomToken last = next;
  if ("=" == next.str()) {
    if (_type.isArray()) {
      // Make sure array expression has as many values as the type
      // requires, and make sure they are all constant.
      ArrayExprToken arrayExpr;
      if (!arrayExpr.parse(tokenizer, functions, globals,
                           parameters, localVars)) {
        return false;
      } else if (arrayExpr.size() != _type.arraySize()) {
        _error("Array size mismatch.", _lineNum);
        return false;
      }
      for (size_t i = 0; i < arrayExpr.size(); i++) {
        _initExprs.push_back(arrayExpr.get(i));
      }
    } else {
      // Not an array value, get the singleton initialization expression
      std::shared_ptr<ExprToken> expr(new ExprToken());
      if (!expr->parse(tokenizer, functions, globals,
                       parameters, localVars)) {
        return false;
      }
      _initExprs.push_back(expr);
    }
    // This should be a semicolon
    last = tokenizer->getNext();
  }
  if (last.empty()) {
    _error("Unexpected EOF.", last.line());
    return false;
  } else if (";" != last.str()) {
    _error("Unexpected token '" + last.str() + "', expected ';'.", last.line());
    return false;
  }
  return true;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x128, %rsp            # imm = 0x128
movq %r9, 0x30(%rsp)
movq %r8, %r13
movq %rcx, %rbp
movq %rdx, %r14
movq %rsi, %rbx
movq %rdi, %r12
leaq 0xd8(%rsp), %r15
movq %r15, %rdi
callq 0x279a6
movl 0x8(%r15), %eax
movl %eax, 0x8(%r12)
movq %r15, %rdi
callq 0x7b20
leaq 0x38(%r12), %rdi
movq %rbx, 0xb0(%rsp)
movq %rbx, %rsi
movq 0x30(%rsp), %r9
movq %r14, 0xa8(%rsp)
movq %r14, %rdx
movq %rbp, 0xa0(%rsp)
movq %rbp, %rcx
movq %r13, 0x98(%rsp)
movq %r13, %r8
callq 0xe2ac
testb %al, %al
je 0x16454
leaq 0x48(%r12), %rsi
leaq 0xd8(%rsp), %r15
movq %r15, %rdi
callq 0x73e0
leaq 0x12c29(%rip), %rdi     # 0x29030
movq %r15, %rsi
callq 0x97dd
movl %eax, %ebx
movq %r15, %rdi
callq 0x75c8
testb %bl, %bl
movq %r12, %rbx
je 0x1645b
leaq 0x139ec(%rip), %rsi     # 0x29e13
leaq 0xd8(%rsp), %rdi
movq %rsp, %rdx
callq 0x9502
movl 0x40(%rbx), %esi
leaq 0xd8(%rsp), %rdi
callq 0x285f3
leaq 0xd8(%rsp), %rdi
callq 0x75c8
xorl %ebx, %ebx
jmp 0x165b4
leaq 0xd8(%rsp), %rdi
movq 0xb0(%rsp), %r14
movq %r14, %rsi
callq 0x2772c
leaq 0xe8(%rsp), %r15
movq %rsp, %rdi
movq %r15, %rsi
callq 0x73e0
movq %rsp, %rdi
movq 0x8(%rdi), %r12
callq 0x75c8
testq %r12, %r12
je 0x16538
movq %rsp, %rdi
movq %r15, %rsi
callq 0x73e0
leaq 0x70(%rbx), %r13
movq %rsp, %r15
movq %r13, %rdi
movq %r15, %rsi
callq 0x7360
movq %r15, %rdi
callq 0x75c8
movq %r13, %rdi
callq 0x2804b
movq 0x30(%rsp), %r12
testb %al, %al
je 0x16560
movq %rsp, %rdi
movq %r13, %rsi
movq 0xa8(%rsp), %rdx
callq 0x283f4
leaq 0x8(%rsp), %rdi
movq -0x8(%rdi), %r15
callq 0x7a34
testq %r15, %r15
je 0x165c8
leaq 0x1394a(%rip), %rsi     # 0x29e50
leaq 0x68(%rsp), %rdi
movq %r13, %rdx
callq 0x9980
leaq 0x13612(%rip), %rdx     # 0x29b2c
movq %rsp, %rdi
leaq 0x68(%rsp), %rsi
callq 0x9ad4
movl 0xe0(%rsp), %esi
movq %rsp, %rdi
callq 0x285f3
jmp 0x16593
leaq 0x13498(%rip), %rsi     # 0x299d7
movq %rsp, %rdi
leaq 0x68(%rsp), %rdx
callq 0x9502
movl 0xe0(%rsp), %esi
movq %rsp, %rdi
callq 0x285f3
movq %rsp, %rdi
jmp 0x165a0
leaq 0x138d0(%rip), %rsi     # 0x29e37
leaq 0x68(%rsp), %rdi
movq %r13, %rdx
callq 0x9980
leaq 0x137c7(%rip), %rdx     # 0x29d42
movq %rsp, %rdi
leaq 0x68(%rsp), %rsi
callq 0x9ad4
movl 0x40(%rbx), %esi
movq %rsp, %rdi
callq 0x285f3
movq %rsp, %rdi
callq 0x75c8
leaq 0x68(%rsp), %rdi
callq 0x75c8
xorl %ebx, %ebx
leaq 0xd8(%rsp), %rdi
callq 0x7b20
movl %ebx, %eax
addq $0x128, %rsp            # imm = 0x128
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rsp, %rdi
movq %r13, %rsi
movq 0xa0(%rsp), %rdx
callq 0x28490
leaq 0x8(%rsp), %rdi
movq -0x8(%rdi), %r15
callq 0x7a34
testq %r15, %r15
je 0x1662a
leaq 0x1385b(%rip), %rsi     # 0x29e50
leaq 0x68(%rsp), %rdi
movq %r13, %rdx
callq 0x9980
leaq 0x1354c(%rip), %rdx     # 0x29b55
movq %rsp, %rdi
leaq 0x68(%rsp), %rsi
callq 0x9ad4
movl 0xe0(%rsp), %esi
movq %rsp, %rdi
callq 0x285f3
jmp 0x16593
movq %rsp, %rdi
movq %r13, %rsi
movq 0x98(%rsp), %rdx
callq 0x282bc
leaq 0x8(%rsp), %rdi
movq -0x8(%rdi), %r15
callq 0x7a34
testq %r15, %r15
je 0x1668c
leaq 0x137f9(%rip), %rsi     # 0x29e50
leaq 0x68(%rsp), %rdi
movq %r13, %rdx
callq 0x9980
leaq 0x1366e(%rip), %rdx     # 0x29cd9
movq %rsp, %rdi
leaq 0x68(%rsp), %rsi
callq 0x9ad4
movl 0xe0(%rsp), %esi
movq %rsp, %rdi
callq 0x285f3
jmp 0x16593
movq %rsp, %rdi
movq %r13, %rsi
movq %r12, %rdx
callq 0x28358
leaq 0x8(%rsp), %rdi
movq -0x8(%rdi), %r15
callq 0x7a34
testq %r15, %r15
je 0x166e9
leaq 0x1379c(%rip), %rsi     # 0x29e50
leaq 0x68(%rsp), %rdi
movq %r13, %rdx
callq 0x9980
leaq 0x13794(%rip), %rdx     # 0x29e5c
movq %rsp, %rdi
leaq 0x68(%rsp), %rsi
callq 0x9ad4
movl 0xe0(%rsp), %esi
movq %rsp, %rdi
callq 0x285f3
jmp 0x16593
movq %rsp, %rdi
movq %r14, %rsi
callq 0x2772c
leaq 0x68(%rsp), %rdi
movq %rsp, %rsi
callq 0x187be
leaq 0x10(%rsp), %rsi
leaq 0x38(%rsp), %rdi
callq 0x73e0
leaq 0x12edb(%rip), %rdi     # 0x295f2
leaq 0x38(%rsp), %r15
movq %r15, %rsi
callq 0x97dd
movl %eax, %r12d
movq %r15, %rdi
callq 0x75c8
testb %r12b, %r12b
je 0x16921
cmpb $0x1, 0x68(%rbx)
jne 0x1680e
leaq 0x38(%rsp), %rdi
orl $-0x1, 0x8(%rdi)
leaq 0x27cfe(%rip), %rax     # 0x3e450
movq %rax, (%rdi)
xorps %xmm0, %xmm0
movups %xmm0, 0x10(%rdi)
andq $0x0, 0x20(%rdi)
movq %r14, %rsi
movq 0xa8(%rsp), %rdx
movq 0xa0(%rsp), %rcx
movq 0x98(%rsp), %r8
movq 0x30(%rsp), %r9
callq 0x11b90
testb %al, %al
je 0x168d9
movq 0x48(%rsp), %rcx
movq 0x50(%rsp), %rax
movq %rax, %rdx
subq %rcx, %rdx
sarq $0x4, %rdx
movzwl 0x6a(%rbx), %esi
cmpq %rsi, %rdx
jne 0x168a0
addq $0x98, %rbx
leaq 0xc0(%rsp), %r15
xorl %r12d, %r12d
leaq 0xb8(%rsp), %r13
leaq 0x38(%rsp), %rbp
subq %rcx, %rax
sarq $0x4, %rax
cmpq %rax, %r12
jae 0x168e8
movq %r13, %rdi
movq %rbp, %rsi
movl %r12d, %edx
callq 0x187dc
movq %rbx, %rdi
movq %r13, %rsi
callq 0x274c6
movq %r15, %rdi
callq 0x7a34
incq %r12
movq 0x48(%rsp), %rcx
movq 0x50(%rsp), %rax
jmp 0x167ce
pushq $0x28
popq %rdi
callq 0x72b0
movq 0x30(%rsp), %r15
orl $-0x1, 0x8(%rax)
leaq 0x27822(%rip), %rcx     # 0x3e048
movq %rcx, (%rax)
movb $0x1, 0xc(%rax)
xorps %xmm0, %xmm0
movups %xmm0, 0xe(%rax)
movups %xmm0, 0x18(%rax)
leaq 0x38(%rsp), %rdi
movq %rax, %rsi
callq 0x25cd0
movq 0x38(%rsp), %rdi
movq %r14, %rsi
movq 0xa8(%rsp), %rdx
movq 0xa0(%rsp), %rcx
movq 0x98(%rsp), %r8
movq %r15, %r9
callq 0xe5a8
testb %al, %al
je 0x16891
addq $0x98, %rbx
leaq 0x38(%rsp), %rsi
movq %rbx, %rdi
callq 0x186e8
leaq 0x40(%rsp), %rdi
callq 0x7a34
jmp 0x168fa
leaq 0x40(%rsp), %rdi
callq 0x7a34
jmp 0x16a10
leaq 0x132d9(%rip), %rsi     # 0x29b80
leaq 0xb8(%rsp), %rdi
leaq 0x108(%rsp), %rdx
callq 0x9502
movl 0x8(%rbx), %esi
leaq 0xb8(%rsp), %rdi
callq 0x285f3
leaq 0xb8(%rsp), %rdi
callq 0x75c8
leaq 0x38(%rsp), %rdi
callq 0x187f8
jmp 0x16a10
leaq 0x38(%rsp), %rdi
callq 0x187f8
movq 0xb0(%rsp), %r14
leaq 0x38(%rsp), %rdi
movq %r14, %rsi
callq 0x2772c
leaq 0x68(%rsp), %rdi
leaq 0x38(%rsp), %rbx
movq %rbx, %rsi
callq 0x1880c
movq %rbx, %rdi
callq 0x7b20
cmpq $0x0, 0x80(%rsp)
je 0x169df
leaq 0x78(%rsp), %r14
leaq 0x38(%rsp), %rdi
movq %r14, %rsi
callq 0x73e0
leaq 0x13278(%rip), %rdi     # 0x29bc1
leaq 0x38(%rsp), %rbx
movq %rbx, %rsi
callq 0x9976
movl %eax, %ebp
movq %rbx, %rdi
callq 0x75c8
movb $0x1, %bl
testb %bpl, %bpl
je 0x16a12
leaq 0x108(%rsp), %rdi
movq %r14, %rsi
callq 0x73e0
leaq 0x12f25(%rip), %rsi     # 0x298a7
leaq 0xb8(%rsp), %rdi
leaq 0x108(%rsp), %rdx
callq 0x1832f
leaq 0x13225(%rip), %rdx     # 0x29bc3
leaq 0x38(%rsp), %rdi
leaq 0xb8(%rsp), %rsi
callq 0x9ad4
movl 0x70(%rsp), %esi
leaq 0x38(%rsp), %rdi
callq 0x285f3
leaq 0x38(%rsp), %rdi
callq 0x75c8
leaq 0xb8(%rsp), %rdi
callq 0x75c8
leaq 0x108(%rsp), %rdi
jmp 0x16a0b
leaq 0x12ff1(%rip), %rsi     # 0x299d7
leaq 0x38(%rsp), %rdi
leaq 0xb8(%rsp), %rdx
callq 0x9502
movl 0x70(%rsp), %esi
leaq 0x38(%rsp), %rdi
callq 0x285f3
leaq 0x38(%rsp), %rdi
callq 0x75c8
xorl %ebx, %ebx
leaq 0x68(%rsp), %rdi
callq 0x7b20
movq %rsp, %rdi
callq 0x7b20
jmp 0x165a7
movq %rax, %rbx
leaq 0xb8(%rsp), %rdi
callq 0x75c8
jmp 0x16abe
jmp 0x16a72
jmp 0x16a9b
movq %rax, %rbx
leaq 0x38(%rsp), %rdi
callq 0x75c8
jmp 0x16a54
movq %rax, %rbx
leaq 0xb8(%rsp), %rdi
callq 0x75c8
jmp 0x16a66
movq %rax, %rbx
leaq 0x108(%rsp), %rdi
jmp 0x16a7f
jmp 0x16a9b
movq %rax, %rbx
jmp 0x16abe
movq %rax, %rbx
leaq 0x38(%rsp), %rdi
callq 0x75c8
jmp 0x16ac8
jmp 0x16a9b
movq %rax, %rbx
leaq 0x40(%rsp), %rdi
callq 0x7a34
jmp 0x16ac8
jmp 0x16a9b
jmp 0x16a9b
movq %rax, %rbx
jmp 0x16ac8
movq %rax, %rbx
jmp 0x16ad2
jmp 0x16b34
jmp 0x16af4
jmp 0x16b01
jmp 0x16b34
movq %rax, %rbx
movq %r15, %rdi
callq 0x7a34
leaq 0x38(%rsp), %rdi
callq 0x187f8
leaq 0x68(%rsp), %rdi
callq 0x7b20
movq %rsp, %rdi
callq 0x7b20
jmp 0x16b37
jmp 0x16b34
jmp 0x16af4
jmp 0x16b01
jmp 0x16b34
jmp 0x16b34
jmp 0x16af4
jmp 0x16b01
jmp 0x16b34
jmp 0x16b34
jmp 0x16af4
jmp 0x16b01
jmp 0x16b34
movq %rax, %rbx
movq %rsp, %rdi
callq 0x75c8
jmp 0x16b04
movq %rax, %rbx
leaq 0x68(%rsp), %rdi
jmp 0x16b15
jmp 0x16b34
jmp 0x16b34
movq %rax, %rbx
movq %rsp, %rdi
callq 0x75c8
jmp 0x16b37
jmp 0x16b34
jmp 0x16b34
jmp 0x16b34
movq %rax, %rbx
leaq 0xd8(%rsp), %rdi
callq 0x75c8
jmp 0x16b44
movq %rax, %rbx
leaq 0xd8(%rsp), %rdi
callq 0x7b20
movq %rbx, %rdi
callq 0x7510
movq %rax, %rbx
jmp 0x16b44
nop