// File: /workspace/github_cpp_makefile_star2_O2/rfotino[P]consolite-compiler/src/syntax.cpp
// Function: ForStatement::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 ForStatement::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();
  // Start with the "for" keyword.
  if (!_expect(tokenizer, "for")) {
    return false;
  }
  // Next get the "(" token.
  if (!_expect(tokenizer, "(")) {
    return false;
  }
  // Get the INIT_LIST.
  if (";" != tokenizer->peekNext().str()) {
    while (true) {
      std::shared_ptr<ExprToken> expr(new ExprToken());
      if (!expr->parse(tokenizer, functions, globals, parameters, localVars)) {
        return false;
      }
      _initExprs.push_back(expr);
      // If the next token is not a comma, we are done. Otherwise consume
      // the comma and continue.
      if ("," != tokenizer->peekNext().str()) {
        break;
      }
      tokenizer->getNext();
    }
  }
  // Make sure the INIT_LIST ended with a ';'.
  if (!_expect(tokenizer, ";")) {
    return false;
  }
  // Get the COND_EXPR. If the next token is a ';', then the COND_EXPR
  // is an implicit truthy value.
  if (";" == tokenizer->peekNext().str()) {
    _condExpr = std::shared_ptr<ExprToken>(new ExprToken(1));
  } else {
    _condExpr = std::shared_ptr<ExprToken>(new ExprToken());
    if (!_condExpr->parse(tokenizer, functions, globals,
                          parameters, localVars)) {
      return false;
    }
  }
  // Make sure the COND_EXPR ended with a ';'.
  if (!_expect(tokenizer, ";")) {
    return false;
  }
  // Get the LOOP_LIST.
  if (")" != tokenizer->peekNext().str()) {
    while (true) {
      std::shared_ptr<ExprToken> expr(new ExprToken());
      if (!expr->parse(tokenizer, functions, globals, parameters, localVars)) {
        return false;
      }
      _loopExprs.push_back(expr);
      // If the next token is not a comma, we are done. Otherwise consume
      // the comma and continue.
      if ("," != tokenizer->peekNext().str()) {
        break;
      }
      tokenizer->getNext();
    }
  }
  // Make sure the LOOP_LIST ended with a ')'.
  if (!_expect(tokenizer, ")")) {
    return false;
  }
  // Get the statement that is the body of the loop, make sure it is valid.
  _body = StatementToken::parse(tokenizer, functions, globals, parameters,
                                localVars, labels, gotos, currentFunc, true);
  if (!_body) {
    return false;
  }
  return true;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xf8, %rsp
movq %r9, 0x68(%rsp)
movq %r8, 0x60(%rsp)
movq %rcx, 0x58(%rsp)
movq %rdx, 0x50(%rsp)
movq %rsi, %rbp
movq %rdi, %r14
leaq 0x8(%rsp), %rbx
movq %rbx, %rdi
callq 0x279a6
movl 0x8(%rbx), %eax
movq %r14, 0x38(%rsp)
movl %eax, 0x8(%r14)
movq %rbx, %rdi
callq 0x7b20
leaq 0x14c46(%rip), %rsi     # 0x29db5
leaq 0x8(%rsp), %rdi
leaq 0x78(%rsp), %rdx
callq 0x9502
leaq 0x8(%rsp), %rsi
pushq $0x1
popq %rdx
movq %rbp, %rdi
callq 0x286c3
movl %eax, %ebx
leaq 0x8(%rsp), %rdi
callq 0x75c8
testb %bl, %bl
je 0x15683
leaq 0x13f00(%rip), %rsi     # 0x290a9
leaq 0x8(%rsp), %rdi
leaq 0x78(%rsp), %rdx
callq 0x9502
leaq 0x8(%rsp), %rsi
pushq $0x1
popq %rdx
movq %rbp, %rdi
callq 0x286c3
movl %eax, %ebx
leaq 0x8(%rsp), %rdi
callq 0x75c8
testb %bl, %bl
je 0x15683
leaq 0x8(%rsp), %rdi
movq %rbp, %rsi
callq 0x279a6
leaq 0x18(%rsp), %rsi
leaq 0x78(%rsp), %rdi
callq 0x73e0
leaq 0x149c2(%rip), %rdi     # 0x29bc1
leaq 0x78(%rsp), %rbx
movq %rbx, %rsi
callq 0x9976
movl %eax, %r14d
movq %rbx, %rdi
callq 0x75c8
leaq 0x8(%rsp), %rdi
callq 0x7b20
testb %r14b, %r14b
je 0x1532b
movq 0x38(%rsp), %rax
addq $0x30, %rax
movq %rax, 0x70(%rsp)
leaq 0x40(%rsp), %r13
leaq 0x8(%rsp), %rbx
leaq 0x78(%rsp), %r15
leaq 0xc8(%rsp), %r12
pushq $0x28
popq %rdi
callq 0x72b0
orl $-0x1, 0x8(%rax)
leaq 0x28de6(%rip), %rcx     # 0x3e048
movq %rcx, (%rax)
movb $0x1, 0xc(%rax)
xorps %xmm0, %xmm0
movups %xmm0, 0xe(%rax)
movups %xmm0, 0x18(%rax)
movq %r13, %rdi
movq %rax, %rsi
callq 0x25cd0
movq 0x40(%rsp), %rdi
movq %rbp, %rsi
movq 0x50(%rsp), %rdx
movq 0x58(%rsp), %rcx
movq 0x60(%rsp), %r8
movq 0x68(%rsp), %r9
callq 0xe5a8
testb %al, %al
je 0x15312
movq 0x70(%rsp), %rdi
movq %r13, %rsi
callq 0x186e8
movq %rbx, %rdi
movq %rbp, %rsi
callq 0x279a6
movq %r15, %rdi
leaq 0x18(%rsp), %rsi
callq 0x73e0
leaq 0x14717(%rip), %rdi     # 0x299e7
movq %r15, %rsi
callq 0x9976
movl %eax, %r14d
movq %r15, %rdi
callq 0x75c8
movq %rbx, %rdi
callq 0x7b20
testb %r14b, %r14b
jne 0x15321
movq %r12, %rdi
movq %rbp, %rsi
callq 0x2772c
movq %r12, %rdi
callq 0x7b20
leaq 0x48(%rsp), %rdi
callq 0x7a34
jmp 0x1524f
leaq 0x48(%rsp), %rdi
callq 0x7a34
jmp 0x15683
leaq 0x48(%rsp), %rdi
callq 0x7a34
leaq 0x1488f(%rip), %rsi     # 0x29bc1
leaq 0x8(%rsp), %rdi
leaq 0x78(%rsp), %rdx
callq 0x9502
leaq 0x8(%rsp), %rsi
pushq $0x1
popq %rdx
movq %rbp, %rdi
callq 0x286c3
movl %eax, %ebx
leaq 0x8(%rsp), %rdi
callq 0x75c8
testb %bl, %bl
je 0x15683
leaq 0x8(%rsp), %rdi
movq %rbp, %rsi
callq 0x279a6
leaq 0x18(%rsp), %rsi
leaq 0x78(%rsp), %rdi
callq 0x73e0
leaq 0x14839(%rip), %rdi     # 0x29bc1
leaq 0x78(%rsp), %rbx
movq %rbx, %rsi
callq 0x97dd
movl %eax, %r14d
movq %rbx, %rdi
callq 0x75c8
leaq 0x8(%rsp), %rdi
callq 0x7b20
testb %r14b, %r14b
je 0x153f2
pushq $0x28
popq %rdi
callq 0x72b0
movq %rax, %rbx
pushq $0x1
popq %rsi
movq %rax, %rdi
callq 0xf832
leaq 0x8(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rsi
callq 0x25cd0
movq 0x38(%rsp), %rax
leaq 0x10(%rax), %rdi
movq %r14, %rsi
callq 0x27600
leaq 0x10(%rsp), %rdi
callq 0x7a34
jmp 0x1546a
pushq $0x28
popq %rdi
callq 0x72b0
orl $-0x1, 0x8(%rax)
leaq 0x28c43(%rip), %rcx     # 0x3e048
movq %rcx, (%rax)
movb $0x1, 0xc(%rax)
xorps %xmm0, %xmm0
movups %xmm0, 0xe(%rax)
movups %xmm0, 0x18(%rax)
leaq 0x8(%rsp), %rbx
movq %rbx, %rdi
movq %rax, %rsi
callq 0x25cd0
movq 0x38(%rsp), %r14
leaq 0x10(%r14), %rdi
movq %rbx, %rsi
callq 0x27600
leaq 0x10(%rsp), %rdi
callq 0x7a34
movq 0x10(%r14), %rdi
movq %rbp, %rsi
movq 0x50(%rsp), %rdx
movq 0x58(%rsp), %rcx
movq 0x60(%rsp), %r8
movq 0x68(%rsp), %r9
callq 0xe5a8
testb %al, %al
je 0x15683
leaq 0x14750(%rip), %rsi     # 0x29bc1
leaq 0x8(%rsp), %rdi
leaq 0x78(%rsp), %rdx
callq 0x9502
leaq 0x8(%rsp), %rsi
pushq $0x1
popq %rdx
movq %rbp, %rdi
callq 0x286c3
movl %eax, %ebx
leaq 0x8(%rsp), %rdi
callq 0x75c8
testb %bl, %bl
je 0x15683
leaq 0x8(%rsp), %rdi
movq %rbp, %rsi
callq 0x279a6
leaq 0x18(%rsp), %rsi
leaq 0x78(%rsp), %rdi
callq 0x73e0
leaq 0x15417(%rip), %rdi     # 0x2a8de
leaq 0x78(%rsp), %rbx
movq %rbx, %rsi
callq 0x9976
movl %eax, %r14d
movq %rbx, %rdi
callq 0x75c8
leaq 0x8(%rsp), %rdi
callq 0x7b20
testb %r14b, %r14b
je 0x155e9
movq 0x38(%rsp), %rax
addq $0x48, %rax
movq %rax, 0x70(%rsp)
leaq 0x40(%rsp), %r13
leaq 0x8(%rsp), %rbx
leaq 0x78(%rsp), %r15
leaq 0x98(%rsp), %r12
pushq $0x28
popq %rdi
callq 0x72b0
orl $-0x1, 0x8(%rax)
leaq 0x28b1e(%rip), %rcx     # 0x3e048
movq %rcx, (%rax)
movb $0x1, 0xc(%rax)
xorps %xmm0, %xmm0
movups %xmm0, 0xe(%rax)
movups %xmm0, 0x18(%rax)
movq %r13, %rdi
movq %rax, %rsi
callq 0x25cd0
movq 0x40(%rsp), %rdi
movq %rbp, %rsi
movq 0x50(%rsp), %rdx
movq 0x58(%rsp), %rcx
movq 0x60(%rsp), %r8
movq 0x68(%rsp), %r9
callq 0xe5a8
testb %al, %al
je 0x155da
movq 0x70(%rsp), %rdi
movq %r13, %rsi
callq 0x186e8
movq %rbx, %rdi
movq %rbp, %rsi
callq 0x279a6
movq %r15, %rdi
leaq 0x18(%rsp), %rsi
callq 0x73e0
leaq 0x1444f(%rip), %rdi     # 0x299e7
movq %r15, %rsi
callq 0x9976
movl %eax, %r14d
movq %r15, %rdi
callq 0x75c8
movq %rbx, %rdi
callq 0x7b20
testb %r14b, %r14b
jne 0x155df
movq %r12, %rdi
movq %rbp, %rsi
callq 0x2772c
movq %r12, %rdi
callq 0x7b20
leaq 0x48(%rsp), %rdi
callq 0x7a34
jmp 0x15517
jmp 0x15312
leaq 0x48(%rsp), %rdi
callq 0x7a34
leaq 0x152ee(%rip), %rsi     # 0x2a8de
leaq 0x8(%rsp), %rdi
leaq 0x78(%rsp), %rdx
callq 0x9502
leaq 0x8(%rsp), %rsi
pushq $0x1
popq %rdx
movq %rbp, %rdi
callq 0x286c3
movl %eax, %ebx
leaq 0x8(%rsp), %rdi
callq 0x75c8
testb %bl, %bl
je 0x15683
leaq 0x8(%rsp), %rbx
movq %rbx, %rdi
movq %rbp, %rsi
movq 0x50(%rsp), %rdx
movq 0x58(%rsp), %rcx
movq 0x60(%rsp), %r8
movq 0x68(%rsp), %r9
pushq $0x1
pushq 0x148(%rsp)
pushq 0x148(%rsp)
pushq 0x148(%rsp)
callq 0x136f2
addq $0x20, %rsp
movq 0x38(%rsp), %r14
leaq 0x20(%r14), %rdi
movq %rbx, %rsi
callq 0x275d2
leaq 0x10(%rsp), %rdi
callq 0x7a34
cmpq $0x0, 0x20(%r14)
setne %al
jmp 0x15685
xorl %eax, %eax
addq $0xf8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x156e0
jmp 0x156ef
jmp 0x156b7
movq %rax, %r14
pushq $0x28
popq %rsi
movq %rbx, %rdi
callq 0x72c0
jmp 0x15712
jmp 0x156e0
jmp 0x156ef
jmp 0x156b7
jmp 0x156e0
jmp 0x156ef
movq %rax, %r14
leaq 0x8(%rsp), %rdi
callq 0x7b20
jmp 0x15712
jmp 0x156db
movq %rax, %r14
leaq 0x8(%rsp), %rdi
callq 0x7b20
jmp 0x15708
jmp 0x156e0
jmp 0x156ef
movq %rax, %r14
jmp 0x15708
movq %rax, %r14
leaq 0x8(%rsp), %rdi
callq 0x75c8
jmp 0x15712
movq %rax, %r14
jmp 0x15712
jmp 0x15705
movq %rax, %r14
leaq 0x8(%rsp), %rdi
callq 0x7b20
jmp 0x15708
movq %rax, %r14
leaq 0x48(%rsp), %rdi
callq 0x7a34
movq %r14, %rdi
callq 0x7510