// File: /workspace/github_cpp_makefile_star2_O2/KJTang[P]SimpleCompiler/Parser.cpp
// Function: Parser::parseVarDeclaration()
ASTNode *Parser::parseVarDeclaration() {
    #ifdef DEBUG
    std::cout<<curToken.second<<"\tparseVarDeclaration"<<std::endl;
    #endif
    Token type = curToken.first;
    getNextToken(); // eat type name
    std::vector<ASTNode*> varList;
    while (true) {
        ASTNode *var = this->parseIdentifier();
        if (curToken.first == static_cast<Token>(',')) {
            getNextToken();
            varList.push_back(new BinaryExprAST('=', var, new NumberAST("0")));
        } else if (curToken.first == static_cast<Token>('=')) {
            getNextToken();
            ASTNode *expr = this->parseExpression();
            varList.push_back(new BinaryExprAST('=', var, expr));
            if (lookAheadToken(-1).first == static_cast<Token>(';')) {
                break;
            }
        } else if (curToken.first == static_cast<Token>(';')) {
            getNextToken();
            varList.push_back(new BinaryExprAST('=', var, new NumberAST("0")));
            break;
        }
    }
    return new AssignmentAST(type, varList);   
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movq %rdi, %r14
movl 0x58(%rdi), %eax
movl %eax, -0x44(%rbp)
callq 0x7fbe
xorps %xmm0, %xmm0
leaq -0x70(%rbp), %rax
movaps %xmm0, (%rax)
andq $0x0, 0x10(%rax)
pushq $0x20
popq %rbx
leaq 0x9e68(%rip), %rax      # 0x11bb0
addq $0x10, %rax
movq %rax, -0x40(%rbp)
movq %r14, -0x38(%rbp)
movq %r14, %rdi
callq 0x79b2
movq %rax, %r15
movl 0x58(%r14), %eax
cmpl $0x2c, %eax
je 0x7df4
cmpl $0x3d, %eax
je 0x7d7f
cmpl $0x3b, %eax
movq -0x38(%rbp), %r14
jne 0x7d54
jmp 0x7e88
movq -0x38(%rbp), %r14
movq %r14, %rdi
callq 0x7fbe
movq %r14, %rdi
callq 0x75c8
movq %rax, %r12
movq %rbx, %rdi
callq 0x31e0
movabsq $0x3d00000000, %rcx     # imm = 0x3D00000000
movq %rcx, 0x8(%rax)
movq -0x40(%rbp), %rcx
movq %rcx, (%rax)
movq %r15, 0x10(%rax)
movq %r12, 0x18(%rax)
movq %rax, -0x90(%rbp)
leaq -0x70(%rbp), %rdi
leaq -0x90(%rbp), %rsi
callq 0x8e94
movq -0x38(%rbp), %r14
movslq 0x80(%r14), %rax
movq (%r14), %rcx
imulq $0x28, %rax, %rax
cmpl $0x3b, -0x50(%rcx,%rax)
jne 0x7d54
jmp 0x7f0b
movq -0x38(%rbp), %rdi
callq 0x7fbe
movq %rbx, %rdi
callq 0x31e0
movq %rax, %r13
pushq $0x30
popq %rdi
callq 0x31e0
movq %rax, -0x50(%rbp)
leaq -0x90(%rbp), %r14
movq %r14, %rdi
leaq 0x4491(%rip), %rsi      # 0xc2b6
leaq -0x29(%rbp), %rdx
callq 0x30d0
movb $0x1, %bl
movq -0x50(%rbp), %r12
movq %r12, %rdi
movq %r14, %rsi
callq 0x8008
movabsq $0x3d00000000, %rax     # imm = 0x3D00000000
movq %rax, 0x8(%r13)
movq -0x40(%rbp), %rax
movq %rax, (%r13)
movq %r15, 0x10(%r13)
movq %r12, 0x18(%r13)
movq %r13, -0x58(%rbp)
xorl %ebx, %ebx
leaq -0x70(%rbp), %rdi
leaq -0x58(%rbp), %rsi
callq 0x8e94
leaq -0x90(%rbp), %rdi
callq 0x33a8
pushq $0x20
popq %rbx
movq -0x38(%rbp), %r14
jmp 0x7d54
movq %r14, %rdi
callq 0x7fbe
pushq $0x20
popq %rdi
callq 0x31e0
movq %rax, %r14
pushq $0x30
popq %rdi
callq 0x31e0
movq %rax, %r12
leaq 0x4409(%rip), %rsi      # 0xc2b6
leaq -0x90(%rbp), %rdi
leaq -0x29(%rbp), %rdx
callq 0x30d0
movb $0x1, %r13b
leaq -0x90(%rbp), %rsi
movq %r12, %rdi
callq 0x8008
movabsq $0x3d00000000, %rax     # imm = 0x3D00000000
movq %rax, 0x8(%r14)
movq -0x40(%rbp), %rax
movq %rax, (%r14)
movq %r15, 0x10(%r14)
movq %r12, 0x18(%r14)
leaq -0x58(%rbp), %rsi
movq %r14, (%rsi)
xorl %r13d, %r13d
leaq -0x70(%rbp), %rdi
callq 0x8e94
leaq -0x90(%rbp), %rdi
callq 0x33a8
pushq $0x28
popq %rdi
callq 0x31e0
movq %rax, %r14
leaq -0x70(%rbp), %rdx
movq %rax, %rdi
movl -0x44(%rbp), %esi
callq 0x812a
leaq -0x70(%rbp), %rdi
callq 0x44ba
movq %r14, %rax
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %r15
jmp 0x7f66
jmp 0x7f4b
jmp 0x7fa9
jmp 0x7fa9
movq %rax, %r15
jmp 0x7f6e
jmp 0x7fa9
movq %rax, %r15
leaq -0x90(%rbp), %rdi
callq 0x33a8
testb %r13b, %r13b
je 0x7fac
movq %r12, %rdi
callq 0x31c0
movq %r14, %rdi
jmp 0x7fa0
jmp 0x7fa9
movq %rax, %r15
jmp 0x7f9d
movq %rax, %r15
jmp 0x7f94
jmp 0x7fa9
movq %rax, %r15
leaq -0x90(%rbp), %rdi
callq 0x33a8
testb %bl, %bl
je 0x7fac
movq -0x50(%rbp), %rdi
callq 0x31c0
movq %r13, %rdi
callq 0x31c0
jmp 0x7fac
jmp 0x7fa9
movq %rax, %r15
leaq -0x70(%rbp), %rdi
callq 0x44ba
movq %r15, %rdi
callq 0x3350
nop