// File: rfotino[P]consolite-compiler/src/syntax.cpp
// Function: CompoundStatement::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::vector<std::shared_ptr<LabelStatement>, std::allocator<std::shared_ptr<LabelStatement>>>&, std::vector<std::shared_ptr<GotoStatement>, std::allocator<std::shared_ptr<GotoStatement>>>&, std::shared_ptr<FunctionToken> const&, bool)
bool CompoundStatement::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,
      std::vector<std::shared_ptr<LabelStatement>>& labels,
      std::vector<std::shared_ptr<GotoStatement>>& gotos,
      const std::shared_ptr<FunctionToken>& currentFunc,
      bool inLoop) {
  _lineNum = tokenizer->peekNext().line();
  // Make sure the first token is a '{'.
  if (!_expect(tokenizer, "{")) {
    return false;
  }
  // Get the inner statements.
  while ("}" != tokenizer->peekNext().str()) {
    auto statement = StatementToken::parse(tokenizer, functions, globals,
                                           parameters, localVars, labels,
                                           gotos, currentFunc, inLoop);
    if (!statement) {
      return false;
    }
    // Local variables are only allowed as top level statements in
    // a function.
    if (std::dynamic_pointer_cast<LocalVarToken>(statement)) {
      _error("Local variables can only be declared as top level "
             "statements in a function.", statement->line());
      return false;
    }
    _statements.push_back(statement);
  }
  // Consume the final '}' token.
  tokenizer->getNext();
  return true;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
subq $0x1e8, %rsp            # imm = 0x1E8
movb 0x28(%rbp), %al
movq 0x20(%rbp), %r10
movq 0x18(%rbp), %r10
movq 0x10(%rbp), %r10
movq %rdi, -0x18(%rbp)
movq %rsi, -0x20(%rbp)
movq %rdx, -0x28(%rbp)
movq %rcx, -0x30(%rbp)
movq %r8, -0x38(%rbp)
movq %r9, -0x40(%rbp)
andb $0x1, %al
movb %al, -0x41(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x198(%rbp)
movq -0x20(%rbp), %rsi
leaq -0x78(%rbp), %rdi
movq %rdi, -0x190(%rbp)
callq 0x6bae0
movq -0x190(%rbp), %rdi
callq 0x32270
movl %eax, -0x184(%rbp)
jmp 0x2ad8b
movq -0x198(%rbp), %rax
movl -0x184(%rbp), %ecx
movl %ecx, 0x8(%rax)
leaq -0x78(%rbp), %rdi
callq 0x99b0
movq -0x20(%rbp), %rax
movq %rax, -0x1a8(%rbp)
leaq -0xa9(%rbp), %rdi
movq %rdi, -0x1a0(%rbp)
callq 0x8760
movq -0x1a0(%rbp), %rdx
leaq 0x44c93(%rip), %rsi     # 0x6fa63
leaq -0xa8(%rbp), %rdi
callq 0xced0
jmp 0x2adde
movq -0x1a8(%rbp), %rdi
leaq -0xa8(%rbp), %rsi
movl $0x1, %edx
callq 0x6da60
movb %al, -0x1a9(%rbp)
jmp 0x2adfe
movb -0x1a9(%rbp), %al
xorb $-0x1, %al
movb %al, -0x1aa(%rbp)
leaq -0xa8(%rbp), %rdi
callq 0x8848
leaq -0xa9(%rbp), %rdi
callq 0x8460
movb -0x1aa(%rbp), %al
testb $0x1, %al
jne 0x2ae30
jmp 0x2ae93
movb $0x0, -0x9(%rbp)
jmp 0x2b129
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
leaq -0x78(%rbp), %rdi
callq 0x99b0
jmp 0x2b138
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
jmp 0x2ae82
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
leaq -0xa8(%rbp), %rdi
callq 0x8848
leaq -0xa9(%rbp), %rdi
callq 0x8460
jmp 0x2b138
jmp 0x2ae95
movq -0x20(%rbp), %rsi
leaq -0x100(%rbp), %rdi
movq %rdi, -0x1b8(%rbp)
callq 0x6bae0
movq -0x1b8(%rbp), %rsi
leaq -0xd0(%rbp), %rdi
callq 0xd5c0
jmp 0x2aec1
leaq 0x44b9d(%rip), %rdi     # 0x6fa65
leaq -0xd0(%rbp), %rsi
callq 0xd8e0
movb %al, -0x1b9(%rbp)
jmp 0x2aedc
leaq -0xd0(%rbp), %rdi
callq 0x8848
leaq -0x100(%rbp), %rdi
callq 0x99b0
movb -0x1b9(%rbp), %al
testb $0x1, %al
jne 0x2af03
jmp 0x2b109
movq -0x20(%rbp), %rsi
movq -0x28(%rbp), %rdx
movq -0x30(%rbp), %rcx
movq -0x38(%rbp), %r8
movq -0x40(%rbp), %r9
movq 0x10(%rbp), %rbx
movq 0x18(%rbp), %r11
movq 0x20(%rbp), %r10
movb -0x41(%rbp), %al
leaq -0x110(%rbp), %rdi
andb $0x1, %al
movq %rbx, (%rsp)
movq %r11, 0x8(%rsp)
movq %r10, 0x10(%rsp)
movzbl %al, %eax
movl %eax, 0x18(%rsp)
callq 0x27d10
leaq -0x110(%rbp), %rdi
callq 0x34140
testb $0x1, %al
jne 0x2afa9
movb $0x0, -0x9(%rbp)
movl $0x1, -0x114(%rbp)
jmp 0x2b0cd
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
jmp 0x2af98
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
leaq -0xd0(%rbp), %rdi
callq 0x8848
leaq -0x100(%rbp), %rdi
callq 0x99b0
jmp 0x2b138
leaq -0x128(%rbp), %rdi
leaq -0x110(%rbp), %rsi
callq 0x34160
leaq -0x128(%rbp), %rdi
callq 0x33410
movb %al, -0x1ba(%rbp)
leaq -0x128(%rbp), %rdi
callq 0x10dc0
movb -0x1ba(%rbp), %al
testb $0x1, %al
jne 0x2afe9
jmp 0x2b0aa
leaq -0x149(%rbp), %rdi
movq %rdi, -0x1c8(%rbp)
callq 0x8760
movq -0x1c8(%rbp), %rdx
leaq 0x44e4d(%rip), %rsi     # 0x6fe57
leaq -0x148(%rbp), %rdi
callq 0xced0
jmp 0x2b018
leaq -0x110(%rbp), %rdi
callq 0x341f0
movq %rax, %rdi
callq 0x32270
movl %eax, -0x1cc(%rbp)
jmp 0x2b034
movl -0x1cc(%rbp), %esi
leaq -0x148(%rbp), %rdi
callq 0x6d960
jmp 0x2b048
leaq -0x148(%rbp), %rdi
callq 0x8848
leaq -0x149(%rbp), %rdi
callq 0x8460
movb $0x0, -0x9(%rbp)
movl $0x1, -0x114(%rbp)
jmp 0x2b0cd
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
jmp 0x2b09c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
leaq -0x148(%rbp), %rdi
callq 0x8848
leaq -0x149(%rbp), %rdi
callq 0x8460
jmp 0x2b0fb
movq -0x198(%rbp), %rdi
addq $0x10, %rdi
leaq -0x110(%rbp), %rsi
callq 0x34240
jmp 0x2b0c3
movl $0x0, -0x114(%rbp)
leaq -0x110(%rbp), %rdi
callq 0xfcd0
movl -0x114(%rbp), %eax
testl %eax, %eax
je 0x2b0e7
jmp 0x2b0e5
jmp 0x2b129
jmp 0x2ae95
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
leaq -0x110(%rbp), %rdi
callq 0xfcd0
jmp 0x2b138
movq -0x20(%rbp), %rsi
leaq -0x180(%rbp), %rdi
callq 0x6ae20
leaq -0x180(%rbp), %rdi
callq 0x99b0
movb $0x1, -0x9(%rbp)
movb -0x9(%rbp), %al
andb $0x1, %al
addq $0x1e8, %rsp            # imm = 0x1E8
popq %rbx
popq %rbp
retq
movq -0x80(%rbp), %rdi
callq 0x8750
nopw %cs:(%rax,%rax)