// File: vssense[P]Compiler/src/front-end/tree.cpp
// Function: GetStatement(Parser*, unsigned long*)
Node* GetStatement(Parser* parser, size_t* ofs)
{
    assert(parser);

    if (TYPE == TYPE_OP && VALUE.op == DECLARATOR) // Initialization
    {
        (*ofs)++;
        if (NEXT_TYPE == TYPE_OP && NEXT_VALUE.op == OPENING_SQUARE_BRACKET)
        {
            Node* tmp = GetArrayDeclaration(parser, ofs);
            CheckSemicolon(parser, ofs);
            return tmp;
        }

        Node* tmp = GetAssignment(parser, ofs);
        tmp->type = DECL_TYPE;
        CheckSemicolon(parser, ofs);
        return tmp;
    }

    if (TYPE == TYPE_ID && NEXT_TYPE == TYPE_OP &&
       (NEXT_VALUE.op == ASSIGNMENT || NEXT_VALUE.op == OPENING_SQUARE_BRACKET))
    {
        Node* tmp = GetAssignment(parser, ofs);
        CheckSemicolon(parser, ofs);
        return tmp;
    }

    if (TYPE == TYPE_OP && VALUE.op == RET) // return
    {
        Node* tmp = GetJump(parser, ofs);
        CheckSemicolon(parser, ofs);
        return tmp;
    }

    if (TYPE == TYPE_OP && VALUE.op == IF)
    {
        return GetCondition(parser, ofs);
    }

    if (TYPE == TYPE_OP && VALUE.op == LOOP)
    {
        return GetLoop(parser, ofs);
    }

    Node* tmp = GetExpression(parser, ofs);
    CheckSemicolon(parser, ofs);
    return tmp;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
cmpq $0x0, -0x10(%rbp)
je 0x83c9
jmp 0x83e8
leaq 0x319f(%rip), %rdi      # 0xb56f
leaq 0x3be0(%rip), %rsi      # 0xbfb7
movl $0xf7, %edx
leaq 0x3d21(%rip), %rcx      # 0xc104
callq 0x20a0
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq -0x18(%rbp), %rcx
imulq $0x18, (%rcx), %rcx
addq %rcx, %rax
cmpl $0x2, (%rax)
jne 0x84ca
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq -0x18(%rbp), %rcx
imulq $0x18, (%rcx), %rcx
addq %rcx, %rax
cmpl $0x0, 0x8(%rax)
jne 0x84ca
movq -0x18(%rbp), %rax
movq (%rax), %rcx
addq $0x1, %rcx
movq %rcx, (%rax)
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq -0x18(%rbp), %rcx
movq (%rcx), %rcx
addq $0x1, %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
cmpl $0x2, (%rax)
jne 0x8495
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq -0x18(%rbp), %rcx
movq (%rcx), %rcx
addq $0x1, %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
cmpl $0x15, 0x8(%rax)
jne 0x8495
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x8720
movq %rax, -0x20(%rbp)
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x87e0
movq -0x20(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x8670
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x8880
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rax
movl $0x1, (%rax)
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x87e0
movq -0x28(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x8670
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq -0x18(%rbp), %rcx
imulq $0x18, (%rcx), %rcx
addq %rcx, %rax
cmpl $0x1, (%rax)
jne 0x856c
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq -0x18(%rbp), %rcx
movq (%rcx), %rcx
addq $0x1, %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
cmpl $0x2, (%rax)
jne 0x856c
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq -0x18(%rbp), %rcx
movq (%rcx), %rcx
addq $0x1, %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
cmpl $0x6, 0x8(%rax)
je 0x8541
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq -0x18(%rbp), %rcx
movq (%rcx), %rcx
addq $0x1, %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
cmpl $0x15, 0x8(%rax)
jne 0x856c
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x8880
movq %rax, -0x30(%rbp)
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x87e0
movq -0x30(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x8670
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq -0x18(%rbp), %rcx
imulq $0x18, (%rcx), %rcx
addq %rcx, %rax
cmpl $0x2, (%rax)
jne 0x85c6
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq -0x18(%rbp), %rcx
imulq $0x18, (%rcx), %rcx
addq %rcx, %rax
cmpl $0x3, 0x8(%rax)
jne 0x85c6
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x8910
movq %rax, -0x38(%rbp)
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x87e0
movq -0x38(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x8670
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq -0x18(%rbp), %rcx
imulq $0x18, (%rcx), %rcx
addq %rcx, %rax
cmpl $0x2, (%rax)
jne 0x8608
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq -0x18(%rbp), %rcx
imulq $0x18, (%rcx), %rcx
addq %rcx, %rax
cmpl $0x4, 0x8(%rax)
jne 0x8608
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x89c0
movq %rax, -0x8(%rbp)
jmp 0x8670
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq -0x18(%rbp), %rcx
imulq $0x18, (%rcx), %rcx
addq %rcx, %rax
cmpl $0x2, (%rax)
jne 0x864a
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq -0x18(%rbp), %rcx
imulq $0x18, (%rcx), %rcx
addq %rcx, %rax
cmpl $0x2, 0x8(%rax)
jne 0x864a
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x8af0
movq %rax, -0x8(%rbp)
jmp 0x8670
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x8bb0
movq %rax, -0x40(%rbp)
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x87e0
movq -0x40(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x40, %rsp
popq %rbp
retq
nopw (%rax,%rax)