// File: rfotino[P]consolite-compiler/src/syntax.cpp
// Function: DoWhileStatement::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 DoWhileStatement::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) {
  _lineNum = tokenizer->peekNext().line();
  // Make sure the first token is the "do" keyword.
  if (!_expect(tokenizer, "do")) {
    return false;
  }
  // Make sure the body exists and is valid.
  _body = StatementToken::parse(tokenizer, functions, globals,
                                parameters, localVars, labels, gotos,
                                currentFunc, true);
  if (!_body) {
    return false;
  }
  // Next token should be the "while" keyword.
  if (!_expect(tokenizer, "while")) {
    return false;
  }
  // Next token should be an opening parenthesis.
  if (!_expect(tokenizer, "(")) {
    return false;
  }
  // Next we should be able to parse the expression.
  _condExpr = std::shared_ptr<ExprToken>(new ExprToken());
  if (!_condExpr->parse(tokenizer, functions, globals,
                        parameters, localVars)) {
    return false;
  }
  // Next two tokens should be a closing parenthesis followed by
  // a semicolon.
  if (!_expect(tokenizer, ")")) {
    return false;
  }
  if (!_expect(tokenizer, ";")) {
    return false;
  }
  return true;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x210, %rsp            # imm = 0x210
movq 0x20(%rbp), %rax
movq 0x18(%rbp), %rax
movq 0x10(%rbp), %rax
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movq %r8, -0x30(%rbp)
movq %r9, -0x38(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x170(%rbp)
movq -0x18(%rbp), %rsi
leaq -0x68(%rbp), %rdi
movq %rdi, -0x168(%rbp)
callq 0x6bae0
movq -0x168(%rbp), %rdi
callq 0x32270
movl %eax, -0x160(%rbp)
jmp 0x2c782
movq -0x170(%rbp), %rax
movl -0x160(%rbp), %ecx
movl %ecx, 0x8(%rax)
leaq -0x68(%rbp), %rdi
callq 0x99b0
movq -0x18(%rbp), %rax
movq %rax, -0x180(%rbp)
leaq -0x99(%rbp), %rdi
movq %rdi, -0x178(%rbp)
callq 0x8760
movq -0x178(%rbp), %rdx
leaq 0x43688(%rip), %rsi     # 0x6fe4f
leaq -0x98(%rbp), %rdi
callq 0xced0
jmp 0x2c7d5
movq -0x180(%rbp), %rdi
leaq -0x98(%rbp), %rsi
movl $0x1, %edx
callq 0x6da60
movb %al, -0x181(%rbp)
jmp 0x2c7f5
movb -0x181(%rbp), %al
xorb $-0x1, %al
movb %al, -0x182(%rbp)
leaq -0x98(%rbp), %rdi
callq 0x8848
leaq -0x99(%rbp), %rdi
callq 0x8460
movb -0x182(%rbp), %al
testb $0x1, %al
jne 0x2c827
jmp 0x2c881
movb $0x0, -0x1(%rbp)
jmp 0x2cce0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x70(%rbp)
movl %eax, -0x74(%rbp)
leaq -0x68(%rbp), %rdi
callq 0x99b0
jmp 0x2ccee
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x70(%rbp)
movl %eax, -0x74(%rbp)
jmp 0x2c870
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x70(%rbp)
movl %eax, -0x74(%rbp)
leaq -0x98(%rbp), %rdi
callq 0x8848
leaq -0x99(%rbp), %rdi
callq 0x8460
jmp 0x2ccee
movq -0x18(%rbp), %rsi
movq -0x20(%rbp), %rdx
movq -0x28(%rbp), %rcx
movq -0x30(%rbp), %r8
movq -0x38(%rbp), %r9
movq 0x10(%rbp), %r11
movq 0x18(%rbp), %r10
movq 0x20(%rbp), %rax
leaq -0xb0(%rbp), %rdi
movq %r11, (%rsp)
movq %r10, 0x8(%rsp)
movq %rax, 0x10(%rsp)
movl $0x1, 0x18(%rsp)
callq 0x27d10
movq -0x170(%rbp), %rdi
addq $0x20, %rdi
leaq -0xb0(%rbp), %rsi
callq 0x357b0
leaq -0xb0(%rbp), %rdi
callq 0xfcd0
movq -0x170(%rbp), %rdi
addq $0x20, %rdi
callq 0x34140
testb $0x1, %al
jne 0x2c903
movb $0x0, -0x1(%rbp)
jmp 0x2cce0
movq -0x18(%rbp), %rax
movq %rax, -0x198(%rbp)
leaq -0xd1(%rbp), %rdi
movq %rdi, -0x190(%rbp)
callq 0x8760
movq -0x190(%rbp), %rdx
leaq 0x4351a(%rip), %rsi     # 0x6fe49
leaq -0xd0(%rbp), %rdi
callq 0xced0
jmp 0x2c93d
movq -0x198(%rbp), %rdi
leaq -0xd0(%rbp), %rsi
movl $0x1, %edx
callq 0x6da60
movb %al, -0x199(%rbp)
jmp 0x2c95d
movb -0x199(%rbp), %al
xorb $-0x1, %al
movb %al, -0x19a(%rbp)
leaq -0xd0(%rbp), %rdi
callq 0x8848
leaq -0xd1(%rbp), %rdi
callq 0x8460
movb -0x19a(%rbp), %al
testb $0x1, %al
jne 0x2c98f
jmp 0x2c9cf
movb $0x0, -0x1(%rbp)
jmp 0x2cce0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x70(%rbp)
movl %eax, -0x74(%rbp)
jmp 0x2c9be
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x70(%rbp)
movl %eax, -0x74(%rbp)
leaq -0xd0(%rbp), %rdi
callq 0x8848
leaq -0xd1(%rbp), %rdi
callq 0x8460
jmp 0x2ccee
movq -0x18(%rbp), %rax
movq %rax, -0x1b0(%rbp)
leaq -0xf9(%rbp), %rdi
movq %rdi, -0x1a8(%rbp)
callq 0x8760
movq -0x1a8(%rbp), %rdx
leaq 0x426b2(%rip), %rsi     # 0x6f0ad
leaq -0xf8(%rbp), %rdi
callq 0xced0
jmp 0x2ca09
movq -0x1b0(%rbp), %rdi
leaq -0xf8(%rbp), %rsi
movl $0x1, %edx
callq 0x6da60
movb %al, -0x1b1(%rbp)
jmp 0x2ca29
movb -0x1b1(%rbp), %al
xorb $-0x1, %al
movb %al, -0x1b2(%rbp)
leaq -0xf8(%rbp), %rdi
callq 0x8848
leaq -0xf9(%rbp), %rdi
callq 0x8460
movb -0x1b2(%rbp), %al
testb $0x1, %al
jne 0x2ca5b
jmp 0x2ca9b
movb $0x0, -0x1(%rbp)
jmp 0x2cce0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x70(%rbp)
movl %eax, -0x74(%rbp)
jmp 0x2ca8a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x70(%rbp)
movl %eax, -0x74(%rbp)
leaq -0xf8(%rbp), %rdi
callq 0x8848
leaq -0xf9(%rbp), %rdi
callq 0x8460
jmp 0x2ccee
movl $0x28, %edi
callq 0x83e0
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x1c0(%rbp)
callq 0x32670
jmp 0x2cab9
movq -0x1c0(%rbp), %rsi
leaq -0x110(%rbp), %rdi
callq 0x33ab0
movq -0x170(%rbp), %rdi
addq $0x10, %rdi
leaq -0x110(%rbp), %rsi
callq 0x35810
leaq -0x110(%rbp), %rdi
callq 0x33b70
movq -0x170(%rbp), %rdi
addq $0x10, %rdi
callq 0x33ae0
movq %rax, %rdi
movq -0x18(%rbp), %rsi
movq -0x20(%rbp), %rdx
movq -0x28(%rbp), %rcx
movq -0x30(%rbp), %r8
movq -0x38(%rbp), %r9
callq 0x1d9b0
testb $0x1, %al
jne 0x2cb4a
movb $0x0, -0x1(%rbp)
jmp 0x2cce0
movq -0x1c0(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x70(%rbp)
movl %eax, -0x74(%rbp)
movl $0x28, %esi
callq 0x83f0
jmp 0x2ccee
movq -0x18(%rbp), %rax
movq %rax, -0x1d0(%rbp)
leaq -0x131(%rbp), %rdi
movq %rdi, -0x1c8(%rbp)
callq 0x8760
movq -0x1c8(%rbp), %rdx
leaq 0x43df8(%rip), %rsi     # 0x7096e
leaq -0x130(%rbp), %rdi
callq 0xced0
jmp 0x2cb84
movq -0x1d0(%rbp), %rdi
leaq -0x130(%rbp), %rsi
movl $0x1, %edx
callq 0x6da60
movb %al, -0x1d1(%rbp)
jmp 0x2cba4
movb -0x1d1(%rbp), %al
xorb $-0x1, %al
movb %al, -0x1d2(%rbp)
leaq -0x130(%rbp), %rdi
callq 0x8848
leaq -0x131(%rbp), %rdi
callq 0x8460
movb -0x1d2(%rbp), %al
testb $0x1, %al
jne 0x2cbd6
jmp 0x2cc16
movb $0x0, -0x1(%rbp)
jmp 0x2cce0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x70(%rbp)
movl %eax, -0x74(%rbp)
jmp 0x2cc05
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x70(%rbp)
movl %eax, -0x74(%rbp)
leaq -0x130(%rbp), %rdi
callq 0x8848
leaq -0x131(%rbp), %rdi
callq 0x8460
jmp 0x2ccee
movq -0x18(%rbp), %rax
movq %rax, -0x1e8(%rbp)
leaq -0x159(%rbp), %rdi
movq %rdi, -0x1e0(%rbp)
callq 0x8760
movq -0x1e0(%rbp), %rdx
leaq 0x4300f(%rip), %rsi     # 0x6fc51
leaq -0x158(%rbp), %rdi
callq 0xced0
jmp 0x2cc50
movq -0x1e8(%rbp), %rdi
leaq -0x158(%rbp), %rsi
movl $0x1, %edx
callq 0x6da60
movb %al, -0x1e9(%rbp)
jmp 0x2cc70
movb -0x1e9(%rbp), %al
xorb $-0x1, %al
movb %al, -0x1ea(%rbp)
leaq -0x158(%rbp), %rdi
callq 0x8848
leaq -0x159(%rbp), %rdi
callq 0x8460
movb -0x1ea(%rbp), %al
testb $0x1, %al
jne 0x2cca2
jmp 0x2ccdc
movb $0x0, -0x1(%rbp)
jmp 0x2cce0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x70(%rbp)
movl %eax, -0x74(%rbp)
jmp 0x2ccce
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x70(%rbp)
movl %eax, -0x74(%rbp)
leaq -0x158(%rbp), %rdi
callq 0x8848
leaq -0x159(%rbp), %rdi
callq 0x8460
jmp 0x2ccee
movb $0x1, -0x1(%rbp)
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0x210, %rsp            # imm = 0x210
popq %rbp
retq
movq -0x70(%rbp), %rdi
callq 0x8750
nopw (%rax,%rax)