// File: /workspace/github_cpp_makefile_star2_O2/rfotino[P]consolite-compiler/src/syntax.cpp
// Function: FunctionToken::parse(Tokenizer*, std::vector<std::shared_ptr<FunctionToken>, std::allocator<std::shared_ptr<FunctionToken>>>&, std::vector<std::shared_ptr<GlobalVarToken>, std::allocator<std::shared_ptr<GlobalVarToken>>>&)
bool FunctionToken::parse(
      Tokenizer *tokenizer,
      std::vector<std::shared_ptr<FunctionToken>>& functions,
      std::vector<std::shared_ptr<GlobalVarToken>>& globals) {
  _lineNum = _type.line();
  // Validate the type
  if (_type.isArray()) {
    _error("Function return type cannot be array-valued.", _type.line());
    return false;
  }
  // Validate the name
  if (!isValidName(_name)) {
    _error("Invalid function name '" + _name + "'.", _type.line());
    return false;
  } else if (getFunction(_name, functions)) {
    _error("Function '" + _name + "' conflicts with existing function name.",
           _type.line());
    return false;
  } else if (getGlobal(_name, globals)) {
    _error("Function '" + _name + "' conflicts with existing global var name.",
           _type.line());
    return false;
  }
  // Make sure the first token is an open parenthesis
  if (!_expect(tokenizer, "(")) {
    return false;
  }
  // Get the parameters
  while (")" != tokenizer->peekNext().str()) {
    std::shared_ptr<ParamToken> param(new ParamToken());
    if (!param->parse(tokenizer, functions, globals)) {
      return false;
    } else if (getParameter(param->name(), _parameters)) {
      _error("Parameter '" + param->name() + "' conflicts with existing "
             "parameter name.", param->line());
      return false;
    }
    _parameters.push_back(param);
    AtomToken t = tokenizer->peekNext();
    if (t.str().empty()) {
      _error("Unexpected EOF.", t.line());
      return false;
    } else if ("," == t.str()) {
      tokenizer->getNext();
      continue;
    } else if (")" != t.str()) {
      _error("Unexpected token '" + t.str() + "'.", t.line());
      return false;
    }
  }
  // Consume the closing parenthesis
  tokenizer->getNext();
  // Add self to the functions list
  functions.push_back(shared_from_this());
  // Get the function body. Make sure it starts with a '{'.
  if (!_expect(tokenizer, "{")) {
    return false;
  }
  // Get the statements within the function body. Local variable
  // declarations must come before any other statements.
  bool inDeclarations = true;
  while ("}" != tokenizer->peekNext().str()) {
    auto statement = StatementToken::parse(tokenizer, functions, globals,
                                           _parameters, _localVars, _labels,
                                           _gotos, shared_from_this());
    if (!statement) {
      return false;
    }
    // If it's a local variable declaration, add it to the list of local
    // variables.
    if (std::dynamic_pointer_cast<LocalVarToken>(statement)) {
      if (!inDeclarations) {
        _error("Declarations must come before other "
               "statements in function '" + _name + "()'.",
               statement->line());
        return false;
      }
      _localVars.push_back(std::dynamic_pointer_cast<LocalVarToken>(statement));
    } else {
      inDeclarations = false;
      _statements.push_back(statement);
    }
    // Check for EOF
    AtomToken t = tokenizer->peekNext();
    if (t.str().empty()) {
      _error("Unexpected EOF.", t.line());
      return false;
    }
  }
  // Consume the '}' token
  tokenizer->getNext();
  // Make sure all of the goto statements match up with a label.
  bool ret = true;
  for (auto gotoStatement : _gotos) {
    if (!getLabel(gotoStatement->label(), _labels)) {
      _error("Label '" + gotoStatement->label() + "' does not exist in "
             "function '" + _name + "' for goto statement.",
             gotoStatement->line());
      ret = false;
    }
  }
  return ret;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1a8, %rsp            # imm = 0x1A8
movq %rdi, %r14
movl 0x28(%rdi), %eax
movl %eax, 0x8(%rdi)
cmpb $0x1, 0x50(%rdi)
jne 0x12bde
leaq 0x170d1(%rip), %rsi     # 0x29c88
leaq 0x8(%rsp), %rdi
leaq 0x38(%rsp), %rdx
callq 0x9502
movl 0x28(%r14), %esi
leaq 0x8(%rsp), %rdi
callq 0x285f3
leaq 0x8(%rsp), %rdi
jmp 0x12ca9
movq %rcx, %r12
movq %rdx, %r13
movq %rsi, %r15
leaq 0x58(%r14), %rbx
movq %rbx, %rdi
callq 0x2804b
testb %al, %al
je 0x12c61
movq %r12, 0x60(%rsp)
leaq 0x8(%rsp), %r12
movq %r12, %rdi
movq %rbx, %rsi
movq %r13, %rdx
callq 0x283f4
movq (%r12), %r12
leaq 0x10(%rsp), %rdi
callq 0x7a34
testq %r12, %r12
je 0x12cc8
leaq 0x16dd9(%rip), %rsi     # 0x29a06
leaq 0x38(%rsp), %r15
movq %r15, %rdi
movq %rbx, %rdx
callq 0x9980
leaq 0x16ee8(%rip), %rdx     # 0x29b2c
leaq 0x8(%rsp), %rdi
movq %r15, %rsi
callq 0x9ad4
movl 0x28(%r14), %esi
leaq 0x8(%rsp), %rdi
callq 0x285f3
jmp 0x12c9a
leaq 0x1704d(%rip), %rsi     # 0x29cb5
leaq 0x38(%rsp), %r15
movq %r15, %rdi
movq %rbx, %rdx
callq 0x9980
leaq 0x170c3(%rip), %rdx     # 0x29d42
leaq 0x8(%rsp), %rdi
movq %r15, %rsi
callq 0x9ad4
movl 0x28(%r14), %esi
leaq 0x8(%rsp), %rdi
callq 0x285f3
leaq 0x8(%rsp), %rdi
callq 0x75c8
leaq 0x38(%rsp), %rdi
callq 0x75c8
xorl %ebp, %ebp
andb $0x1, %bpl
movl %ebp, %eax
addq $0x1a8, %rsp            # imm = 0x1A8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x8(%rsp), %r12
movq %r12, %rdi
movq %rbx, %rsi
movq 0x60(%rsp), %rdx
callq 0x28490
movq (%r12), %r12
leaq 0x10(%rsp), %rdi
callq 0x7a34
testq %r12, %r12
je 0x12d2e
leaq 0x16d0f(%rip), %rsi     # 0x29a06
leaq 0x38(%rsp), %r15
movq %r15, %rdi
movq %rbx, %rdx
callq 0x9980
leaq 0x16e47(%rip), %rdx     # 0x29b55
leaq 0x8(%rsp), %rdi
movq %r15, %rsi
callq 0x9ad4
movl 0x28(%r14), %esi
leaq 0x8(%rsp), %rdi
callq 0x285f3
jmp 0x12c9a
leaq 0x16374(%rip), %rsi     # 0x290a9
leaq 0x8(%rsp), %rdi
leaq 0x38(%rsp), %rdx
callq 0x9502
leaq 0x8(%rsp), %rsi
pushq $0x1
popq %rdx
movq %r15, %rdi
callq 0x286c3
movl %eax, %ebp
leaq 0x8(%rsp), %rdi
callq 0x75c8
testb %bpl, %bpl
je 0x12cae
movq %r15, 0x58(%rsp)
movq %rbx, 0x90(%rsp)
leaq 0x78(%r14), %rax
movq %rax, 0x88(%rsp)
leaq 0x8(%rsp), %r12
leaq 0x38(%rsp), %rbp
movq %r13, %r15
movq %r12, %rdi
movq 0x58(%rsp), %rsi
callq 0x279a6
movq %rbp, %rdi
leaq 0x18(%rsp), %rsi
callq 0x73e0
leaq 0x17b2e(%rip), %rdi     # 0x2a8de
movq %rbp, %rsi
callq 0x9976
movl %eax, %r13d
movq %rbp, %rdi
callq 0x75c8
movq %r12, %rbx
movq %r12, %rdi
callq 0x7b20
testb %r13b, %r13b
je 0x12f4c
movl $0x98, %edi
callq 0x72b0
movq %rax, %r12
movq %rax, %rdi
callq 0x18828
leaq 0xa8(%rsp), %rdi
movq %r12, %rsi
callq 0x26092
movq 0xa8(%rsp), %rdi
movq 0x58(%rsp), %rsi
movq %r15, %rdx
movq 0x60(%rsp), %rcx
callq 0x127e8
testb %al, %al
je 0x132a4
movq %rbx, %r12
movq 0xa8(%rsp), %rsi
addq $0x70, %rsi
movq %rbx, %rdi
callq 0x73e0
movq %rbp, %rdi
movq %r12, %rsi
movq 0x88(%rsp), %rdx
callq 0x282bc
movq 0x38(%rsp), %r13
leaq 0x40(%rsp), %rdi
callq 0x7a34
movq %r12, %rdi
callq 0x75c8
testq %r13, %r13
jne 0x1322f
movq 0x88(%rsp), %rdi
leaq 0xa8(%rsp), %rsi
callq 0x18850
movq %r15, %r13
movq %rbx, %rdi
movq 0x58(%rsp), %r15
movq %r15, %rsi
callq 0x279a6
movq %rbp, %rdi
leaq 0x18(%rsp), %rsi
callq 0x73e0
movq 0x40(%rsp), %r12
movq %rbp, %rdi
callq 0x75c8
testq %r12, %r12
je 0x132a9
movq %rbp, %rdi
leaq 0x18(%rsp), %rsi
callq 0x73e0
leaq 0x16b20(%rip), %rdi     # 0x299e7
movq %rbp, %rsi
callq 0x97dd
movl %eax, %r12d
movq %rbp, %rdi
callq 0x75c8
testb %r12b, %r12b
je 0x12eff
leaq 0x178(%rsp), %r12
movq %r12, %rdi
movq %r15, %rsi
callq 0x2772c
movq %r12, %rdi
callq 0x7b20
movq %rbx, %r12
jmp 0x12f32
movq %rbp, %rdi
leaq 0x18(%rsp), %rsi
callq 0x73e0
leaq 0x179cb(%rip), %rdi     # 0x2a8de
movq %rbp, %rsi
callq 0x9976
movl %eax, %r12d
movq %rbp, %rdi
callq 0x75c8
testb %r12b, %r12b
movq %rbx, %r12
jne 0x132d4
movq %r12, %rdi
callq 0x7b20
leaq 0xb0(%rsp), %rdi
callq 0x7a34
jmp 0x12d8c
leaq 0x148(%rsp), %r12
movq %r12, %rdi
movq 0x58(%rsp), %rsi
callq 0x2772c
movq %r12, %rdi
callq 0x7b20
leaq 0x10(%r14), %rsi
leaq 0x8(%rsp), %r12
movq %r12, %rdi
movq %rsi, 0xf0(%rsp)
callq 0x262aa
movq %r15, 0xe8(%rsp)
movq %r15, %rdi
movq %r12, %rsi
callq 0xab66
leaq 0x10(%rsp), %rdi
callq 0x7a34
leaq 0x16a2d(%rip), %rsi     # 0x299d3
leaq 0x8(%rsp), %rdi
leaq 0x38(%rsp), %rdx
callq 0x9502
leaq 0x8(%rsp), %rsi
pushq $0x1
popq %rdx
movq 0x58(%rsp), %r15
movq %r15, %rdi
callq 0x286c3
movl %eax, %ebp
leaq 0x8(%rsp), %rdi
callq 0x75c8
testb %bpl, %bpl
je 0x12cae
leaq 0x90(%r14), %rax
movq %rax, 0x98(%rsp)
leaq 0xa8(%r14), %rax
movq %rax, 0xa0(%rsp)
leaq 0xc0(%r14), %rax
movq %rax, 0xe0(%rsp)
leaq 0xd8(%r14), %rax
movq %rax, 0xd8(%rsp)
movb $0x1, %bl
leaq 0x8(%rsp), %r13
movq %r13, %rdi
movq %r15, %rsi
callq 0x279a6
leaq 0x38(%rsp), %r12
movq %r12, %rdi
leaq 0x18(%rsp), %rsi
callq 0x73e0
leaq 0x1698f(%rip), %rdi     # 0x299d5
movq %r12, %rsi
callq 0x9976
movl %eax, %ebp
movq %r12, %rdi
callq 0x75c8
movq %r13, %rdi
callq 0x7b20
testb %bpl, %bpl
je 0x13360
movq %r13, %rdi
movq 0xf0(%rsp), %rsi
callq 0x262aa
leaq 0x68(%rsp), %rbp
movq %rbp, %rdi
movq %r15, %rsi
movq 0xe8(%rsp), %rdx
movq 0x60(%rsp), %rcx
movq 0x88(%rsp), %r8
movq 0x98(%rsp), %r9
pushq $0x0
pushq %r13
pushq 0xf0(%rsp)
pushq 0xb8(%rsp)
callq 0x136f2
addq $0x20, %rsp
leaq 0x10(%rsp), %rdi
callq 0x7a34
cmpq $0x0, 0x68(%rsp)
je 0x13133
movq %r13, %rdi
movq %rbp, %rsi
callq 0x1887c
movq %rbp, %r12
movq 0x8(%rsp), %rbp
leaq 0x10(%rsp), %rdi
callq 0x7a34
testq %rbp, %rbp
setne %r13b
je 0x1313b
testb $0x1, %bl
leaq 0x38(%rsp), %r12
je 0x131c0
leaq 0x8(%rsp), %rbp
movq %rbp, %rdi
leaq 0x68(%rsp), %rsi
callq 0x1887c
movq 0x98(%rsp), %rdi
movq %rbp, %rsi
callq 0x2633e
leaq 0x10(%rsp), %rdi
callq 0x7a34
movl %r13d, %ebx
jmp 0x13158
xorl %r13d, %r13d
jmp 0x13215
movq 0xd8(%rsp), %rdi
movq %r12, %rsi
callq 0x188d2
leaq 0x8(%rsp), %rbp
leaq 0x38(%rsp), %r12
movl %r13d, %ebx
movq %rbp, %rdi
movq %r15, %rsi
callq 0x279a6
movq %r12, %rdi
leaq 0x18(%rsp), %rsi
callq 0x73e0
movq %r12, %rdi
movq 0x40(%rsp), %r12
callq 0x75c8
testq %r12, %r12
setne %r13b
jne 0x131b6
leaq 0x38(%rsp), %r12
movq %r12, %rdi
leaq 0x16842(%rip), %rsi     # 0x299d7
leaq 0xf8(%rsp), %rdx
callq 0x9502
movl 0x10(%rsp), %esi
movq %r12, %rdi
callq 0x285f3
movq %r12, %rdi
callq 0x75c8
movq %rbp, %rdi
callq 0x7b20
jmp 0x13215
movq %r12, %rdi
leaq 0x16b39(%rip), %rsi     # 0x29d03
movq 0x90(%rsp), %rdx
callq 0x9980
movq %r12, %rsi
leaq 0x8(%rsp), %r12
movq %r12, %rdi
leaq 0x16b57(%rip), %rdx     # 0x29d40
callq 0x9ad4
movq 0x68(%rsp), %rax
movl 0x8(%rax), %esi
movq %r12, %rdi
callq 0x285f3
movq %r12, %rdi
callq 0x75c8
leaq 0x38(%rsp), %rdi
callq 0x75c8
xorl %r13d, %r13d
xorl %ebx, %ebx
leaq 0x70(%rsp), %rdi
callq 0x7a34
xorl %ebp, %ebp
testb %r13b, %r13b
jne 0x1301d
jmp 0x12cb0
movq 0xa8(%rsp), %rsi
addq $0x70, %rsi
leaq 0x68(%rsp), %rdi
callq 0x73e0
leaq 0x16a81(%rip), %rsi     # 0x29ccd
leaq 0x38(%rsp), %rdi
leaq 0x68(%rsp), %rdx
callq 0x1832f
leaq 0x16a77(%rip), %rdx     # 0x29cd9
leaq 0x8(%rsp), %rdi
leaq 0x38(%rsp), %rsi
callq 0x9ad4
movq 0xa8(%rsp), %rax
movl 0x8(%rax), %esi
leaq 0x8(%rsp), %rdi
callq 0x285f3
leaq 0x8(%rsp), %rdi
callq 0x75c8
leaq 0x38(%rsp), %rdi
callq 0x75c8
leaq 0x68(%rsp), %rdi
callq 0x75c8
jmp 0x1334e
leaq 0x16727(%rip), %rsi     # 0x299d7
leaq 0x38(%rsp), %rdi
leaq 0x68(%rsp), %rdx
callq 0x9502
movl 0x10(%rsp), %esi
leaq 0x38(%rsp), %rdi
callq 0x285f3
leaq 0x38(%rsp), %rdi
jmp 0x1333f
leaq 0xf8(%rsp), %rdi
leaq 0x18(%rsp), %rsi
callq 0x73e0
leaq 0x165ba(%rip), %rsi     # 0x298a7
leaq 0x68(%rsp), %rdi
leaq 0xf8(%rsp), %rdx
callq 0x1832f
leaq 0x16a3c(%rip), %rdx     # 0x29d42
leaq 0x38(%rsp), %rdi
leaq 0x68(%rsp), %rsi
callq 0x9ad4
movl 0x10(%rsp), %esi
leaq 0x38(%rsp), %rdi
callq 0x285f3
leaq 0x38(%rsp), %rdi
callq 0x75c8
leaq 0x68(%rsp), %rdi
callq 0x75c8
leaq 0xf8(%rsp), %rdi
callq 0x75c8
leaq 0x8(%rsp), %rdi
callq 0x7b20
leaq 0xb0(%rsp), %rdi
callq 0x7a34
jmp 0x12cae
leaq 0x118(%rsp), %r12
movq %r12, %rdi
movq %r15, %rsi
callq 0x2772c
movq %r12, %rdi
callq 0x7b20
movq 0xc0(%r14), %r12
movq 0xc8(%r14), %rax
movq %rax, 0x58(%rsp)
movb $0x1, %bpl
leaq 0x8(%rsp), %r13
leaq 0x38(%rsp), %rbx
leaq 0x68(%rsp), %r14
cmpq 0x58(%rsp), %r12
je 0x12cb0
leaq 0xc8(%rsp), %rdi
movq %r12, %rsi
callq 0x18ecc
movq 0xc8(%rsp), %rsi
addq $0x10, %rsi
movq %r13, %rdi
callq 0x73e0
movq %r12, 0x60(%rsp)
movq %rbx, %r15
movq %rbx, %rdi
movq %r13, %rsi
movq 0xa0(%rsp), %rdx
callq 0x2852c
movq 0x38(%rsp), %r12
leaq 0x40(%rsp), %rdi
callq 0x7a34
movq %r13, %rdi
callq 0x75c8
testq %r12, %r12
jne 0x134bf
movq 0xc8(%rsp), %rsi
addq $0x10, %rsi
leaq 0xa8(%rsp), %r12
movq %r12, %rdi
callq 0x73e0
leaq 0xf8(%rsp), %rbp
movq %rbp, %rdi
leaq 0x1690d(%rip), %rsi     # 0x29d45
movq %r12, %rdx
callq 0x1832f
movq %r14, %rbx
movq %r14, %rdi
movq %rbp, %rsi
leaq 0x168fd(%rip), %rdx     # 0x29d4d
callq 0x9ad4
movq %r15, %r13
movq %r15, %rdi
movq %rbx, %rsi
movq 0x90(%rsp), %rdx
callq 0x9ab5
leaq 0x8(%rsp), %rbx
movq %rbx, %rdi
movq %r13, %rsi
leaq 0x168ef(%rip), %rdx     # 0x29d6c
callq 0x9ad4
movq 0xc8(%rsp), %rax
movl 0x8(%rax), %esi
movq %rbx, %rdi
callq 0x285f3
movq %rbx, %rdi
callq 0x75c8
movq %r15, %rdi
callq 0x75c8
movq %r14, %rdi
callq 0x75c8
movq %rbp, %rdi
callq 0x75c8
movq %r12, %rdi
callq 0x75c8
xorl %ebp, %ebp
leaq 0xd0(%rsp), %rdi
callq 0x7a34
movq 0x60(%rsp), %r12
addq $0x10, %r12
movq %r15, %rbx
leaq 0x8(%rsp), %r13
jmp 0x133a0
movq %rax, %rbx
leaq 0x38(%rsp), %rdi
callq 0x75c8
jmp 0x134f4
movq %rax, %rbx
leaq 0x68(%rsp), %rdi
callq 0x75c8
jmp 0x13503
movq %rax, %rbx
leaq 0xf8(%rsp), %rdi
jmp 0x1351a
jmp 0x13658
movq %rax, %rbx
leaq 0x38(%rsp), %rdi
callq 0x75c8
jmp 0x1365b
jmp 0x13658
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x75c8
jmp 0x1353b
movq %rax, %rbx
leaq 0x38(%rsp), %rdi
callq 0x75c8
jmp 0x1354a
movq %rax, %rbx
leaq 0x68(%rsp), %rdi
jmp 0x1366f
jmp 0x136ad
jmp 0x136d8
jmp 0x136e7
jmp 0x13636
movq %rax, %rbx
leaq 0x38(%rsp), %rdi
callq 0x75c8
jmp 0x135fe
jmp 0x135fb
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x75c8
jmp 0x1358e
movq %rax, %rbx
leaq 0x38(%rsp), %rdi
callq 0x75c8
jmp 0x1360d
jmp 0x1360a
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0x7a34
jmp 0x1360d
jmp 0x1360a
movq %rax, %rbx
jmp 0x135cb
jmp 0x13617
movq %rax, %rbx
jmp 0x135d5
movq %rax, %rbx
jmp 0x135df
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x75c8
leaq 0x38(%rsp), %rdi
callq 0x75c8
leaq 0x68(%rsp), %rdi
callq 0x75c8
leaq 0xf8(%rsp), %rdi
callq 0x75c8
jmp 0x135f1
movq %rax, %rbx
leaq 0xa8(%rsp), %rdi
jmp 0x13624
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x7b20
jmp 0x1360d
movq %rax, %rbx
leaq 0x70(%rsp), %rdi
jmp 0x136b8
movq %rax, %rbx
jmp 0x13629
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x75c8
leaq 0xd0(%rsp), %rdi
jmp 0x136b8
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
jmp 0x136b8
jmp 0x1368a
jmp 0x136d8
jmp 0x136e7
jmp 0x13658
jmp 0x13658
jmp 0x13699
jmp 0x136a8
jmp 0x13658
jmp 0x136ad
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x7b20
jmp 0x136b0
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x75c8
jmp 0x136b0
jmp 0x136ad
movq %rax, %rbx
movl $0x98, %esi
movq %r12, %rdi
callq 0x72c0
jmp 0x136ea
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x7b20
jmp 0x136ea
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x75c8
jmp 0x136d1
movq %rax, %rbx
jmp 0x136d1
movq %rax, %rbx
leaq 0xb0(%rsp), %rdi
callq 0x7a34
jmp 0x136ea
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x75c8
jmp 0x136d1
movq %rax, %rbx
leaq 0x38(%rsp), %rdi
jmp 0x136e0
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x75c8
jmp 0x136ea
movq %rax, %rbx
movq %rbx, %rdi
callq 0x7510