// File: /workspace/github_cpp_makefile_star2_O3/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 $0x78, %rsp
movq %r9, %rbp
movq %r8, %r13
movq %rcx, 0x70(%rsp)
movq %rdx, 0x68(%rsp)
movq %rsi, %r14
movq %rdi, %r15
movq %rsp, %rbx
movq %rbx, %rdi
callq 0x32bec
movl 0x8(%rbx), %eax
movl %eax, 0x8(%r15)
leaq 0x28463(%rip), %rax     # 0x45d10
movq %rax, (%rbx)
movq 0x10(%rbx), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
je 0x1d8cb
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x72c0
leaq 0x10(%rsp), %r12
movq %r12, -0x10(%r12)
leaq 0x18cda(%rip), %rsi     # 0x365b6
leaq 0x18cd9(%rip), %rdx     # 0x365bc
movq %rsp, %rdi
callq 0xbdee
movq %rsp, %rsi
movq %r14, %rdi
movl $0x1, %edx
callq 0x342b6
movl %eax, %ebx
movq (%rsp), %rdi
cmpq %r12, %rdi
je 0x1d913
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x72c0
testb %bl, %bl
je 0x1dc0c
movq %r13, 0x60(%rsp)
movq %rbp, %r13
movq %r15, 0x38(%rsp)
movq %rsp, %rbx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x32bec
leaq 0x50(%rsp), %rbp
movq %rbp, -0x10(%rbp)
movq 0x10(%rbx), %rsi
movq 0x18(%rbx), %rdx
addq %rsi, %rdx
leaq 0x40(%rsp), %rdi
callq 0xbd58
leaq 0x18266(%rip), %rsi     # 0x35bc1
leaq 0x40(%rsp), %r15
movq %r15, %rdi
callq 0x70c0
movl %eax, %ebx
movq (%r15), %rdi
cmpq %rbp, %rdi
je 0x1d97f
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x72c0
leaq 0x2838a(%rip), %rax     # 0x45d10
movq %rax, (%rsp)
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
movq 0x38(%rsp), %r15
je 0x1d9ab
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x72c0
testl %ebx, %ebx
je 0x1d9db
movb $0x1, 0x38(%r15)
leaq 0x10(%r15), %rdi
movq %r14, %rsi
movq 0x68(%rsp), %rdx
movq 0x70(%rsp), %rcx
movq 0x60(%rsp), %r8
movq %r13, %r9
callq 0x1131a
testb %al, %al
jne 0x1d9e0
jmp 0x1dc0c
movb $0x0, 0x38(%r15)
movq %rsp, %rdi
movq %r12, (%rdi)
leaq 0x181d4(%rip), %rsi     # 0x35bc1
leaq 0x181ce(%rip), %rdx     # 0x35bc2
callq 0xbdee
movq %rsp, %rsi
movq %r14, %rdi
movl $0x1, %edx
callq 0x342b6
movl %eax, %ebx
movq (%rsp), %rdi
cmpq %r12, %rdi
je 0x1da21
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x72c0
testb %bl, %bl
je 0x1dc0c
movq 0xb0(%rsp), %r12
movb 0x38(%r15), %al
cmpb $0x1, %al
jne 0x1daf2
movq (%r12), %rbx
movl 0x28(%rbx), %eax
leaq 0x10(%rsp), %r14
movl %eax, -0x8(%r14)
leaq 0x282fc(%rip), %r13     # 0x45d50
movq %r13, -0x10(%r14)
leaq 0x20(%rsp), %rax
movq %rax, (%r14)
movq 0x30(%rbx), %rsi
movq 0x38(%rbx), %rdx
addq %rsi, %rdx
movq %r14, %rdi
callq 0xbd58
movl 0x50(%rbx), %eax
movl %eax, 0x20(%r14)
leaq 0x40(%rsp), %rdi
leaq 0x50(%rsp), %rbp
movq %rbp, (%rdi)
movq (%r14), %rsi
movq 0x8(%r14), %rdx
addq %rsi, %rdx
callq 0xbd58
leaq 0x175a3(%rip), %rsi     # 0x35040
leaq 0x40(%rsp), %r15
movq %r15, %rdi
callq 0x70c0
movl %eax, %ebx
movq (%r15), %rdi
cmpq %rbp, %rdi
je 0x1dac1
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x72c0
movq %r13, (%rsp)
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
movq 0x38(%rsp), %r15
je 0x1dae6
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x72c0
testl %ebx, %ebx
je 0x1dbd1
movb 0x38(%r15), %al
movb $0x1, %bpl
testb $0x1, %al
jne 0x1dc0e
movq (%r12), %rbx
movl 0x28(%rbx), %eax
leaq 0x10(%rsp), %r14
movl %eax, -0x8(%r14)
leaq 0x2823c(%rip), %r12     # 0x45d50
movq %r12, -0x10(%r14)
leaq 0x20(%rsp), %rax
movq %rax, (%r14)
movq 0x30(%rbx), %rsi
movq 0x38(%rbx), %rdx
addq %rsi, %rdx
movq %r14, %rdi
callq 0xbd58
movl 0x50(%rbx), %eax
movl %eax, 0x20(%r14)
leaq 0x40(%rsp), %rdi
leaq 0x50(%rsp), %r13
movq %r13, (%rdi)
movq (%r14), %rsi
movq 0x8(%r14), %rdx
addq %rsi, %rdx
callq 0xbd58
leaq 0x174e3(%rip), %rsi     # 0x35040
leaq 0x40(%rsp), %r15
movq %r15, %rdi
callq 0x70c0
movl %eax, %ebx
movq (%r15), %rdi
cmpq %r13, %rdi
je 0x1db81
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x72c0
movq %r12, (%rsp)
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
movq 0x38(%rsp), %r15
je 0x1dba6
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x72c0
testl %ebx, %ebx
je 0x1dc0e
movq %rsp, %rdi
movq %r14, (%rdi)
leaq 0x18409(%rip), %rsi     # 0x35fc0
leaq 0x1843f(%rip), %rdx     # 0x35ffd
callq 0xbdee
movl 0x8(%r15), %esi
movq %rsp, %rdi
callq 0x34178
jmp 0x1dbf6
movq %rsp, %rdi
movq %r14, (%rdi)
leaq 0x183b6(%rip), %rsi     # 0x35f94
leaq 0x183da(%rip), %rdx     # 0x35fbf
callq 0xbdee
movl 0x8(%r15), %esi
movq %rsp, %rdi
callq 0x34178
movq (%rsp), %rdi
cmpq %r14, %rdi
je 0x1dc0c
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x72c0
xorl %ebp, %ebp
movl %ebp, %eax
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x1dc23
jmp 0x1dc88
movq %rax, %rbx
movq (%rsp), %rdi
cmpq %r14, %rdi
jne 0x1dc79
jmp 0x1dc8b
jmp 0x1dc88
movq %rax, %rbx
movq %r12, (%rsp)
jmp 0x1dc57
movq %rax, %rbx
movq %r13, (%rsp)
jmp 0x1dc57
jmp 0x1dc6d
jmp 0x1dc88
movq %rax, %rbx
leaq 0x280bd(%rip), %rax     # 0x45d10
movq %rax, (%rsp)
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
je 0x1dc8b
movq 0x20(%rsp), %rsi
jmp 0x1dc7e
movq %rax, %rbx
movq (%rsp), %rdi
cmpq %r12, %rdi
je 0x1dc8b
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x72c0
jmp 0x1dc8b
movq %rax, %rbx
movq %rbx, %rdi
callq 0x74f0
nop