// File: 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
movq %rsp, %rbp
pushq %rbx
subq $0x228, %rsp            # imm = 0x228
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, -0x1b8(%rbp)
movq -0x20(%rbp), %rsi
leaq -0x78(%rbp), %rdi
movq %rdi, -0x1b0(%rbp)
callq 0x6bae0
movq -0x1b0(%rbp), %rdi
callq 0x32270
movl %eax, -0x1a4(%rbp)
jmp 0x2b1bb
movq -0x1b8(%rbp), %rax
movl -0x1a4(%rbp), %ecx
movl %ecx, 0x8(%rax)
leaq -0x78(%rbp), %rdi
callq 0x99b0
movq -0x20(%rbp), %rax
movq %rax, -0x1c8(%rbp)
leaq -0xa9(%rbp), %rdi
movq %rdi, -0x1c0(%rbp)
callq 0x8760
movq -0x1c0(%rbp), %rdx
leaq 0x44c42(%rip), %rsi     # 0x6fe42
leaq -0xa8(%rbp), %rdi
callq 0xced0
jmp 0x2b20e
movq -0x1c8(%rbp), %rdi
leaq -0xa8(%rbp), %rsi
movl $0x1, %edx
callq 0x6da60
movb %al, -0x1c9(%rbp)
jmp 0x2b22e
movb -0x1c9(%rbp), %al
xorb $-0x1, %al
movb %al, -0x1ca(%rbp)
leaq -0xa8(%rbp), %rdi
callq 0x8848
leaq -0xa9(%rbp), %rdi
callq 0x8460
movb -0x1ca(%rbp), %al
testb $0x1, %al
jne 0x2b260
jmp 0x2b2c3
movb $0x0, -0x9(%rbp)
jmp 0x2b681
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
leaq -0x78(%rbp), %rdi
callq 0x99b0
jmp 0x2b690
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
jmp 0x2b2b2
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 0x2b690
movq -0x20(%rbp), %rax
movq %rax, -0x1e0(%rbp)
leaq -0xd1(%rbp), %rdi
movq %rdi, -0x1d8(%rbp)
callq 0x8760
movq -0x1d8(%rbp), %rdx
leaq 0x43dbe(%rip), %rsi     # 0x6f0ad
leaq -0xd0(%rbp), %rdi
callq 0xced0
jmp 0x2b2fd
movq -0x1e0(%rbp), %rdi
leaq -0xd0(%rbp), %rsi
movl $0x1, %edx
callq 0x6da60
movb %al, -0x1e1(%rbp)
jmp 0x2b31d
movb -0x1e1(%rbp), %al
xorb $-0x1, %al
movb %al, -0x1e2(%rbp)
leaq -0xd0(%rbp), %rdi
callq 0x8848
leaq -0xd1(%rbp), %rdi
callq 0x8460
movb -0x1e2(%rbp), %al
testb $0x1, %al
jne 0x2b34f
jmp 0x2b395
movb $0x0, -0x9(%rbp)
jmp 0x2b681
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
jmp 0x2b384
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
leaq -0xd0(%rbp), %rdi
callq 0x8848
leaq -0xd1(%rbp), %rdi
callq 0x8460
jmp 0x2b690
movq -0x1b8(%rbp), %rdi
addq $0x10, %rdi
movq -0x20(%rbp), %rsi
movq -0x28(%rbp), %rdx
movq -0x30(%rbp), %rcx
movq -0x38(%rbp), %r8
movq -0x40(%rbp), %r9
callq 0x1d9b0
testb $0x1, %al
jne 0x2b3c6
movb $0x0, -0x9(%rbp)
jmp 0x2b681
movq -0x20(%rbp), %rax
movq %rax, -0x1f8(%rbp)
leaq -0xf9(%rbp), %rdi
movq %rdi, -0x1f0(%rbp)
callq 0x8760
movq -0x1f0(%rbp), %rdx
leaq 0x4557c(%rip), %rsi     # 0x7096e
leaq -0xf8(%rbp), %rdi
callq 0xced0
jmp 0x2b400
movq -0x1f8(%rbp), %rdi
leaq -0xf8(%rbp), %rsi
movl $0x1, %edx
callq 0x6da60
movb %al, -0x1f9(%rbp)
jmp 0x2b420
movb -0x1f9(%rbp), %al
xorb $-0x1, %al
movb %al, -0x1fa(%rbp)
leaq -0xf8(%rbp), %rdi
callq 0x8848
leaq -0xf9(%rbp), %rdi
callq 0x8460
movb -0x1fa(%rbp), %al
testb $0x1, %al
jne 0x2b452
jmp 0x2b498
movb $0x0, -0x9(%rbp)
jmp 0x2b681
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
jmp 0x2b487
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
leaq -0xf8(%rbp), %rdi
callq 0x8848
leaq -0xf9(%rbp), %rdi
callq 0x8460
jmp 0x2b690
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
movq -0x1b8(%rbp), %rdi
addq $0x38, %rdi
leaq -0x110(%rbp), %rsi
callq 0x357b0
leaq -0x110(%rbp), %rdi
callq 0xfcd0
movq -0x1b8(%rbp), %rdi
addq $0x38, %rdi
callq 0x34140
testb $0x1, %al
jne 0x2b51e
movb $0x0, -0x9(%rbp)
jmp 0x2b681
movq -0x20(%rbp), %rsi
leaq -0x160(%rbp), %rdi
movq %rdi, -0x208(%rbp)
callq 0x6bae0
movq -0x208(%rbp), %rsi
leaq -0x130(%rbp), %rdi
callq 0xd5c0
jmp 0x2b54a
leaq 0x44a08(%rip), %rdi     # 0x6ff59
leaq -0x130(%rbp), %rsi
callq 0xd590
movb %al, -0x209(%rbp)
jmp 0x2b565
leaq -0x130(%rbp), %rdi
callq 0x8848
leaq -0x160(%rbp), %rdi
callq 0x99b0
movb -0x209(%rbp), %al
testb $0x1, %al
jne 0x2b58c
jmp 0x2b672
movq -0x1b8(%rbp), %rax
movb $0x1, 0x58(%rax)
movq -0x20(%rbp), %rsi
leaq -0x190(%rbp), %rdi
callq 0x6ae20
leaq -0x190(%rbp), %rdi
callq 0x99b0
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 -0x1a0(%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
movq -0x1b8(%rbp), %rdi
addq $0x48, %rdi
leaq -0x1a0(%rbp), %rsi
callq 0x357b0
leaq -0x1a0(%rbp), %rdi
callq 0xfcd0
movq -0x1b8(%rbp), %rdi
addq $0x48, %rdi
callq 0x34140
testb $0x1, %al
jne 0x2b670
movb $0x0, -0x9(%rbp)
jmp 0x2b681
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
jmp 0x2b662
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
leaq -0x130(%rbp), %rdi
callq 0x8848
leaq -0x160(%rbp), %rdi
callq 0x99b0
jmp 0x2b690
jmp 0x2b67d
movq -0x1b8(%rbp), %rax
movb $0x0, 0x58(%rax)
movb $0x1, -0x9(%rbp)
movb -0x9(%rbp), %al
andb $0x1, %al
addq $0x228, %rsp            # imm = 0x228
popq %rbx
popq %rbp
retq
movq -0x80(%rbp), %rdi
callq 0x8750
nopl (%rax)