// File: /workspace/github_cpp_makefile_star2_O3/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 $0xa8, %rsp
movq %r9, 0x40(%rsp)
movq %r8, 0x38(%rsp)
movq %rcx, %r12
movq %rdx, %r13
movq %rsi, %rbp
movq %rdi, %rbx
leaq 0x8(%rsp), %r14
movq %r14, %rdi
callq 0x32bec
movl 0x8(%r14), %eax
movl %eax, 0x8(%rbx)
leaq 0x298d8(%rip), %rax     # 0x45d10
movq %rax, (%r14)
movq 0x10(%r14), %rdi
leaq 0x28(%rsp), %rax
cmpq %rax, %rdi
je 0x1c456
movq 0x28(%rsp), %rsi
incq %rsi
callq 0x72c0
leaq 0x18(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x1994c(%rip), %rsi     # 0x35db2
leaq 0x19947(%rip), %rdx     # 0x35db4
leaq 0x8(%rsp), %rdi
callq 0xbdee
leaq 0x8(%rsp), %rsi
movq %rbp, %rdi
movl $0x1, %edx
callq 0x342b6
movl %eax, %r14d
movq 0x8(%rsp), %rdi
cmpq %r15, %rdi
je 0x1c4a3
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x72c0
testb %r14b, %r14b
je 0x1c715
leaq 0x8(%rsp), %rdi
movq %r15, (%rdi)
leaq 0x18bfe(%rip), %rsi     # 0x350b9
leaq 0x18bf8(%rip), %rdx     # 0x350ba
callq 0xbdee
leaq 0x8(%rsp), %rsi
movq %rbp, %rdi
movl $0x1, %edx
callq 0x342b6
movl %eax, %r14d
movq 0x8(%rsp), %rdi
cmpq %r15, %rdi
je 0x1c4f3
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x72c0
testb %r14b, %r14b
je 0x1c715
leaq 0x10(%rbx), %rdi
movq %rbp, %rsi
movq %r13, %rdx
movq %r12, %rcx
movq 0x38(%rsp), %r8
movq 0x40(%rsp), %r9
callq 0x1131a
testb %al, %al
je 0x1c715
leaq 0x8(%rsp), %rdi
movq %r15, (%rdi)
leaq 0x1a3af(%rip), %rsi     # 0x368de
leaq 0x1a3a9(%rip), %rdx     # 0x368df
callq 0xbdee
leaq 0x8(%rsp), %rsi
movq %rbp, %rdi
movl $0x1, %edx
callq 0x342b6
movl %eax, %r14d
movq 0x8(%rsp), %rdi
cmpq %r15, %rdi
je 0x1c567
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x72c0
testb %r14b, %r14b
je 0x1c715
movzbl 0xf8(%rsp), %r15d
leaq 0x8(%rsp), %r14
movq %r14, %rdi
movq %rbp, %rsi
movq %r13, %rdx
movq %r12, %rcx
movq 0x38(%rsp), %r8
movq 0x40(%rsp), %r9
pushq %r15
pushq 0xf8(%rsp)
pushq 0xf8(%rsp)
pushq 0xf8(%rsp)
callq 0x19e3a
addq $0x20, %rsp
movq (%r14), %rax
movq 0x8(%r14), %rcx
movq %rax, 0x38(%rbx)
movq 0x40(%rbx), %rdi
movq %rcx, 0x40(%rbx)
testq %rdi, %rdi
je 0x1c5d5
callq 0x8036
movq 0x38(%rbx), %rax
testq %rax, %rax
je 0x1c715
movq %r15, 0x50(%rsp)
leaq 0x8(%rsp), %r14
movq %r14, %rdi
movq %rbp, %rsi
callq 0x32bec
leaq 0x68(%rsp), %r15
movq %r15, -0x10(%r15)
movq 0x10(%r14), %rsi
movq 0x18(%r14), %rdx
addq %rsi, %rdx
leaq 0x58(%rsp), %rdi
callq 0xbd58
leaq 0x198b1(%rip), %rsi     # 0x35ec9
leaq 0x58(%rsp), %r14
movq %r14, %rdi
callq 0x70c0
movl %eax, 0x4c(%rsp)
movq (%r14), %rdi
cmpq %r15, %rdi
je 0x1c63e
movq 0x68(%rsp), %rsi
incq %rsi
callq 0x72c0
leaq 0x296cb(%rip), %r15     # 0x45d10
movq %r15, 0x8(%rsp)
movq 0x18(%rsp), %rdi
leaq 0x28(%rsp), %rax
cmpq %rax, %rdi
je 0x1c666
movq 0x28(%rsp), %rsi
incq %rsi
callq 0x72c0
cmpl $0x0, 0x4c(%rsp)
je 0x1c676
movb $0x0, 0x58(%rbx)
jmp 0x1c711
movb $0x1, 0x58(%rbx)
leaq 0x78(%rsp), %r14
movq %r14, %rdi
movq %rbp, %rsi
callq 0x32902
movq %r15, (%r14)
movq 0x10(%r14), %rdi
leaq 0x98(%rsp), %rax
cmpq %rax, %rdi
je 0x1c6ae
movq 0x98(%rsp), %rsi
incq %rsi
callq 0x72c0
leaq 0x8(%rsp), %r14
movq %r14, %rdi
movq %rbp, %rsi
movq %r13, %rdx
movq %r12, %rcx
movq 0x38(%rsp), %r8
movq 0x40(%rsp), %r9
pushq 0x50(%rsp)
pushq 0xf8(%rsp)
pushq 0xf8(%rsp)
pushq 0xf8(%rsp)
callq 0x19e3a
addq $0x20, %rsp
movq (%r14), %rax
movq 0x8(%r14), %rcx
movq %rax, 0x48(%rbx)
movq 0x50(%rbx), %rdi
movq %rcx, 0x50(%rbx)
testq %rdi, %rdi
je 0x1c70c
callq 0x8036
movq 0x48(%rbx), %rax
testq %rax, %rax
je 0x1c715
movb $0x1, %al
jmp 0x1c717
xorl %eax, %eax
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq 0x295dd(%rip), %rax     # 0x45d10
movq %rax, 0x8(%rsp)
movq 0x18(%rsp), %rdi
leaq 0x28(%rsp), %rax
cmpq %rax, %rdi
je 0x1c775
movq 0x28(%rsp), %rsi
jmp 0x1c768
jmp 0x1c756
jmp 0x1c772
jmp 0x1c756
jmp 0x1c772
movq %rax, %rbx
movq 0x8(%rsp), %rdi
cmpq %r15, %rdi
je 0x1c775
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x72c0
jmp 0x1c775
movq %rax, %rbx
movq %rbx, %rdi
callq 0x74f0
nop