// File: /workspace/github_cpp_makefile_star2_O2/rfotino[P]consolite-compiler/src/syntax.cpp
// Function: IfStatement::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 IfStatement::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 it starts with "if"
  if (!_expect(tokenizer, "if")) {
    return false;
  }
  // Followed by an open parenthesis
  if (!_expect(tokenizer, "(")) {
    return false;
  }
  // Followed by a valid expression
  if (!_condExpr.parse(tokenizer, functions, globals, parameters, localVars)) {
    return false;
  }
  // Followed by a closing parenthesis
  if (!_expect(tokenizer, ")")) {
    return false;
  }
  // Followed by a valid statement
  _trueStatement = StatementToken::parse(tokenizer, functions, globals,
                                         parameters, localVars, labels,
                                         gotos, currentFunc, inLoop);
  if (!_trueStatement) {
    return false;
  }
  // If the next token is "else", check for the else statement.
  if ("else" == tokenizer->peekNext().str()) {
    _hasElse = true;
    // Consume the "else" token.
    tokenizer->getNext();
    // Make sure it is followed by a valid statement.
    _falseStatement = StatementToken::parse(tokenizer, functions, globals,
                                            parameters, localVars, labels,
                                            gotos, currentFunc, inLoop);
    if (!_falseStatement) {
      return false;
    }
  } else {
    _hasElse = false;
  }
  return true;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x98, %rsp
movq %r9, 0x8(%rsp)
movq %r8, %r15
movq %rcx, %r12
movq %rdx, %r13
movq %rsi, %rbp
movq %rdi, %rbx
leaq 0x10(%rsp), %r14
movq %r14, %rdi
callq 0x279a6
movl 0x8(%r14), %eax
movl %eax, 0x8(%rbx)
movq %r14, %rdi
callq 0x7b20
leaq 0x14eda(%rip), %rsi     # 0x29db2
leaq 0x10(%rsp), %rdi
leaq 0x48(%rsp), %rdx
callq 0x9502
leaq 0x10(%rsp), %rsi
pushq $0x1
popq %rdx
movq %rbp, %rdi
callq 0x286c3
movl %eax, %r14d
leaq 0x10(%rsp), %rdi
callq 0x75c8
testb %r14b, %r14b
je 0x150ce
leaq 0x14195(%rip), %rsi     # 0x290a9
leaq 0x10(%rsp), %rdi
leaq 0x48(%rsp), %rdx
callq 0x9502
leaq 0x10(%rsp), %rsi
pushq $0x1
popq %rdx
movq %rbp, %rdi
callq 0x286c3
movl %eax, %r14d
leaq 0x10(%rsp), %rdi
callq 0x75c8
testb %r14b, %r14b
je 0x150ce
leaq 0x10(%rbx), %rdi
movq %rbp, %rsi
movq %r13, %rdx
movq %r12, %rcx
movq %r15, %r8
movq 0x8(%rsp), %r9
callq 0xe5a8
testb %al, %al
je 0x150ce
leaq 0x1596c(%rip), %rsi     # 0x2a8de
leaq 0x10(%rsp), %rdi
leaq 0x48(%rsp), %rdx
callq 0x9502
leaq 0x10(%rsp), %rsi
pushq $0x1
popq %rdx
movq %rbp, %rdi
callq 0x286c3
movl %eax, %r14d
leaq 0x10(%rsp), %rdi
callq 0x75c8
testb %r14b, %r14b
je 0x150ce
movzbl 0xe8(%rsp), %eax
leaq 0x10(%rsp), %r14
movq %r14, %rdi
movq %rbp, %rsi
movq %r13, %rdx
movq %r12, %rcx
movq %r15, %r8
movq 0x8(%rsp), %r9
movq %rax, 0x40(%rsp)
pushq %rax
pushq 0xe8(%rsp)
pushq 0xe8(%rsp)
pushq 0xe8(%rsp)
callq 0x136f2
addq $0x20, %rsp
leaq 0x38(%rbx), %rdi
movq %r14, %rsi
callq 0x275d2
leaq 0x18(%rsp), %rdi
callq 0x7a34
cmpq $0x0, 0x38(%rbx)
je 0x150ce
leaq 0x10(%rsp), %rdi
movq %rbp, %rsi
callq 0x279a6
leaq 0x20(%rsp), %rsi
leaq 0x48(%rsp), %rdi
callq 0x73e0
leaq 0x14e99(%rip), %rdi     # 0x29ec9
leaq 0x48(%rsp), %rsi
callq 0x97dd
movl %eax, %r14d
leaq 0x48(%rsp), %rdi
callq 0x75c8
leaq 0x10(%rsp), %rdi
callq 0x7b20
testb %r14b, %r14b
je 0x150e2
movb $0x1, 0x58(%rbx)
leaq 0x68(%rsp), %r14
movq %r14, %rdi
movq %rbp, %rsi
callq 0x2772c
movq %r14, %rdi
callq 0x7b20
leaq 0x10(%rsp), %r14
movq %r14, %rdi
movq %rbp, %rsi
movq %r13, %rdx
movq %r12, %rcx
movq %r15, %r8
movq 0x8(%rsp), %r9
pushq 0x40(%rsp)
pushq 0xe8(%rsp)
pushq 0xe8(%rsp)
pushq 0xe8(%rsp)
callq 0x136f2
addq $0x20, %rsp
leaq 0x48(%rbx), %rdi
movq %r14, %rsi
callq 0x275d2
leaq 0x18(%rsp), %rdi
callq 0x7a34
cmpq $0x0, 0x48(%rbx)
jne 0x150e6
xorl %eax, %eax
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movb $0x0, 0x58(%rbx)
movb $0x1, %al
jmp 0x150d0
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0x7b20
jmp 0x15113
jmp 0x15101
jmp 0x15110
jmp 0x15101
jmp 0x15110
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0x75c8
jmp 0x15113
movq %rax, %rbx
movq %rbx, %rdi
callq 0x7510
nop