// File: /workspace/github_cpp_makefile_star2_O2/rfotino[P]consolite-compiler/src/syntax.cpp
// Function: ReturnStatement::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&, std::shared_ptr<FunctionToken> const&)
bool ReturnStatement::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,
      const std::shared_ptr<FunctionToken>& currentFunc) {
  _lineNum = tokenizer->peekNext().line();
  // Make sure the first token is the "return" keyword.
  if (!_expect(tokenizer, "return")) {
    return false;
  }
  // If the next token is not a semicolon, parse the expression.
  if (";" != tokenizer->peekNext().str()) {
    _hasExpr = true;
    if (!_returnExpr.parse(tokenizer, functions, globals,
                           parameters, localVars)) {
      return false;
    }
  } else {
    _hasExpr = false;
  }
  // Check for the trailing semicolon.
  if (!_expect(tokenizer, ";")) {
    return false;
  }
  // Make sure that _hasExpr matches up with the void-ness of the
  // containing function.
  if (_hasExpr && "void" == currentFunc->type().name()) {
    _error("Cannot return a value from a void function.", _lineNum);
    return false;
  } else if (!_hasExpr && "void" != currentFunc->type().name()) {
    _error("Return statement must include a value in a non-void function.",
           _lineNum);
    return false;
  }
  return true;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movq %r9, %r12
movq %r8, 0x60(%rsp)
movq %rcx, %r13
movq %rdx, %rbp
movq %rsi, %r14
movq %rdi, %rbx
movq %rsp, %r15
movq %r15, %rdi
callq 0x279a6
movl 0x8(%r15), %eax
movl %eax, 0x8(%rbx)
movq %r15, %rdi
callq 0x7b20
leaq 0x1480b(%rip), %rsi     # 0x2a5b6
movq %rsp, %rdi
leaq 0x38(%rsp), %rdx
callq 0x9502
movq %rsp, %rsi
pushq $0x1
popq %rdx
movq %r14, %rdi
callq 0x286c3
movl %eax, %r15d
movq %rsp, %rdi
callq 0x75c8
testb %r15b, %r15b
je 0x15f7b
movq %r12, 0x58(%rsp)
movq %rsp, %rdi
movq %r14, %rsi
callq 0x279a6
leaq 0x10(%rsp), %rsi
leaq 0x38(%rsp), %rdi
callq 0x73e0
leaq 0x13dc1(%rip), %rdi     # 0x29bc1
leaq 0x38(%rsp), %r15
movq %r15, %rsi
callq 0x9976
movl %eax, %r12d
movq %r15, %rdi
callq 0x75c8
movq %rsp, %rdi
callq 0x7b20
testb %r12b, %r12b
je 0x15e4e
movb $0x1, 0x38(%rbx)
leaq 0x10(%rbx), %rdi
movq %r14, %rsi
movq %rbp, %rdx
movq %r13, %rcx
movq 0x60(%rsp), %r8
movq 0x58(%rsp), %r9
callq 0xe5a8
testb %al, %al
jne 0x15e52
jmp 0x15f7b
movb $0x0, 0x38(%rbx)
leaq 0x13d68(%rip), %rsi     # 0x29bc1
movq %rsp, %rdi
leaq 0x38(%rsp), %rdx
callq 0x9502
movq %rsp, %rsi
pushq $0x1
popq %rdx
movq %r14, %rdi
callq 0x286c3
movl %eax, %ebp
movq %rsp, %rdi
callq 0x75c8
testb %bpl, %bpl
je 0x15f7b
movq 0xa0(%rsp), %r15
movb 0x38(%rbx), %al
cmpb $0x1, %al
jne 0x15f03
movq (%r15), %rsi
addq $0x20, %rsi
movq %rsp, %rdi
callq 0x9b54
leaq 0x10(%rsp), %rsi
leaq 0x38(%rsp), %rdi
callq 0x73e0
leaq 0x13175(%rip), %rdi     # 0x29030
leaq 0x38(%rsp), %r14
movq %r14, %rsi
callq 0x97dd
movl %eax, %ebp
movq %r14, %rdi
callq 0x75c8
movq %rsp, %rdi
callq 0x97a8
testb %bpl, %bpl
je 0x15f00
leaq 0x140ae(%rip), %rsi     # 0x29f94
movq %rsp, %rdi
leaq 0x38(%rsp), %rdx
callq 0x9502
movl 0x8(%rbx), %esi
movq %rsp, %rdi
callq 0x285f3
jmp 0x15f73
movb 0x38(%rbx), %al
movb $0x1, %bpl
testb $0x1, %al
jne 0x15f7d
movq (%r15), %rsi
addq $0x20, %rsi
movq %rsp, %rdi
callq 0x9b54
leaq 0x10(%rsp), %rsi
leaq 0x38(%rsp), %rdi
callq 0x73e0
leaq 0x13101(%rip), %rdi     # 0x29030
leaq 0x38(%rsp), %r14
movq %r14, %rsi
callq 0x9976
movl %eax, %r15d
movq %r14, %rdi
callq 0x75c8
movq %rsp, %rdi
callq 0x97a8
testb %r15b, %r15b
je 0x15f7d
leaq 0x14065(%rip), %rsi     # 0x29fc0
movq %rsp, %rdi
leaq 0x38(%rsp), %rdx
callq 0x9502
movl 0x8(%rbx), %esi
movq %rsp, %rdi
callq 0x285f3
movq %rsp, %rdi
callq 0x75c8
xorl %ebp, %ebp
movl %ebp, %eax
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x15fb6
jmp 0x15fc3
jmp 0x15fb6
jmp 0x15fc3
jmp 0x15f98
movq %rax, %rbx
movq %rsp, %rdi
callq 0x97a8
jmp 0x15fc6
jmp 0x15fb6
jmp 0x15fc3
movq %rax, %rbx
movq %rsp, %rdi
callq 0x7b20
jmp 0x15fc6
movq %rax, %rbx
movq %rsp, %rdi
callq 0x75c8
jmp 0x15fc6
movq %rax, %rbx
movq %rbx, %rdi
callq 0x7510