// File: /workspace/github_cpp_makefile_star2_O3/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, %rbx
movl 0x58(%rdi), %eax
movl %eax, -0x74(%rbp)
movslq 0x80(%rdi), %rax
leal 0x1(%rax), %ecx
movl %ecx, 0x80(%rdi)
movq (%rdi), %rcx
leaq (%rax,%rax,4), %rax
leaq 0x8(%rcx,%rax,8), %rsi
movl -0x8(%rsi), %eax
movl %eax, 0x58(%rdi)
leaq 0x60(%rdi), %r14
movq %r14, %rdi
callq 0x3130
xorps %xmm0, %xmm0
leaq -0x40(%rbp), %rax
movaps %xmm0, (%rax)
movq $0x0, 0x10(%rax)
leaq 0x918f(%rip), %rax      # 0x13ac8
addq $0x10, %rax
movq %rax, -0x80(%rbp)
leaq 0x9258(%rip), %rax      # 0x13ba0
addq $0x10, %rax
movq %rax, -0x68(%rbp)
movq %r14, -0x88(%rbp)
movq %rbx, %rdi
callq 0xa2a4
movq %rax, %r12
movl 0x58(%rbx), %eax
cmpl $0x2c, %eax
je 0xa9f8
cmpl $0x3d, %eax
je 0xa97d
cmpl $0x3b, %eax
jne 0xa957
jmp 0xab1b
movslq 0x80(%rbx), %rax
leal 0x1(%rax), %ecx
movl %ecx, 0x80(%rbx)
movq (%rbx), %rcx
leaq (%rax,%rax,4), %rax
leaq 0x8(%rcx,%rax,8), %rsi
movl -0x8(%rsi), %eax
movl %eax, 0x58(%rbx)
movq %r14, %rdi
callq 0x3130
movq %rbx, %rdi
callq 0x9b8a
movq %rax, %r15
movl $0x20, %edi
callq 0x31e0
movabsq $0x3d00000000, %rcx     # imm = 0x3D00000000
movq %rcx, 0x8(%rax)
movq -0x68(%rbp), %rcx
movq %rcx, (%rax)
movq %r12, 0x10(%rax)
movq %r15, 0x18(%rax)
movq %rax, -0x60(%rbp)
movq -0x38(%rbp), %rsi
cmpq -0x30(%rbp), %rsi
je 0xaac2
movq %rax, (%rsi)
addq $0x8, -0x38(%rbp)
jmp 0xaacf
movslq 0x80(%rbx), %rax
leal 0x1(%rax), %ecx
movl %ecx, 0x80(%rbx)
movq (%rbx), %rcx
leaq (%rax,%rax,4), %rax
leaq 0x8(%rcx,%rax,8), %rsi
movl -0x8(%rsi), %eax
movl %eax, 0x58(%rbx)
movq %r14, %rdi
callq 0x3130
movl $0x20, %edi
callq 0x31e0
movq %rax, %r13
movl $0x30, %edi
callq 0x31e0
movq %rax, %r15
leaq -0x50(%rbp), %rax
movq %rax, -0x60(%rbp)
leaq -0x60(%rbp), %rdi
leaq 0x488f(%rip), %rsi      # 0xf2de
leaq 0x4889(%rip), %rdx      # 0xf2df
callq 0x47d0
movl $0x0, 0x8(%r15)
movq -0x80(%rbp), %rax
movq %rax, (%r15)
leaq 0x10(%r15), %rdi
movq %r15, %rax
addq $0x20, %rax
movq %rax, 0x10(%r15)
movq -0x60(%rbp), %rsi
movq -0x58(%rbp), %rdx
addq %rsi, %rdx
movb $0x1, %r14b
callq 0x42b0
movabsq $0x3d00000000, %rax     # imm = 0x3D00000000
movq %rax, 0x8(%r13)
movq -0x68(%rbp), %rax
movq %rax, (%r13)
movq %r12, 0x10(%r13)
movq %r15, 0x18(%r13)
movq %r13, -0x70(%rbp)
movq -0x38(%rbp), %rsi
cmpq -0x30(%rbp), %rsi
je 0xaaed
movq %r13, (%rsi)
addq $0x8, -0x38(%rbp)
jmp 0xaafd
leaq -0x40(%rbp), %rdi
leaq -0x60(%rbp), %rdx
callq 0xb854
movslq 0x80(%rbx), %rax
movq (%rbx), %rcx
leaq (%rax,%rax,4), %rax
cmpl $0x3b, -0x50(%rcx,%rax,8)
jne 0xa957
jmp 0xac05
xorl %r14d, %r14d
leaq -0x40(%rbp), %rdi
leaq -0x70(%rbp), %rdx
callq 0xb854
movq -0x60(%rbp), %rdi
leaq -0x50(%rbp), %rax
cmpq %rax, %rdi
je 0xab0f
callq 0x31c0
movq -0x88(%rbp), %r14
jmp 0xa957
movslq 0x80(%rbx), %rax
leal 0x1(%rax), %ecx
movl %ecx, 0x80(%rbx)
movq (%rbx), %rcx
leaq (%rax,%rax,4), %rax
leaq 0x8(%rcx,%rax,8), %rsi
movl -0x8(%rsi), %eax
movl %eax, 0x58(%rbx)
movq %r14, %rdi
callq 0x3130
movl $0x20, %edi
callq 0x31e0
movq %rax, %r14
movl $0x30, %edi
callq 0x31e0
movq %rax, %r15
leaq -0x60(%rbp), %rdi
leaq -0x50(%rbp), %rax
movq %rax, (%rdi)
leaq 0x476d(%rip), %rsi      # 0xf2de
leaq 0x4767(%rip), %rdx      # 0xf2df
callq 0x47d0
movl $0x0, 0x8(%r15)
movq -0x80(%rbp), %rax
movq %rax, (%r15)
leaq 0x10(%r15), %rdi
movq %r15, %rax
addq $0x20, %rax
movq %rax, 0x10(%r15)
movq -0x60(%rbp), %rsi
movq -0x58(%rbp), %rdx
addq %rsi, %rdx
movb $0x1, %r13b
callq 0x42b0
movabsq $0x3d00000000, %rax     # imm = 0x3D00000000
movq %rax, 0x8(%r14)
movq -0x68(%rbp), %rax
movq %rax, (%r14)
movq %r12, 0x10(%r14)
movq %r15, 0x18(%r14)
movq %r14, -0x70(%rbp)
movq -0x38(%rbp), %rsi
cmpq -0x30(%rbp), %rsi
je 0xabe3
movq %r14, (%rsi)
addq $0x8, -0x38(%rbp)
jmp 0xabf3
xorl %r13d, %r13d
leaq -0x40(%rbp), %rdi
leaq -0x70(%rbp), %rdx
callq 0xb854
movq -0x60(%rbp), %rdi
leaq -0x50(%rbp), %rax
cmpq %rax, %rdi
je 0xac05
callq 0x31c0
movl $0x28, %edi
callq 0x31e0
movq %rax, %r14
movl $0x0, 0x8(%rax)
leaq 0x8f38(%rip), %rax      # 0x13b58
addq $0x10, %rax
movq %rax, (%r14)
movl -0x74(%rbp), %eax
movl %eax, 0xc(%r14)
movq %r14, %rdi
addq $0x10, %rdi
leaq -0x40(%rbp), %rsi
callq 0xadee
movq -0x40(%rbp), %rdi
testq %rdi, %rdi
je 0xac4c
callq 0x31c0
movq %r14, %rax
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
jmp 0xac83
jmp 0xac8d
jmp 0xacd3
jmp 0xacd3
movq %rax, %rbx
movq -0x60(%rbp), %rdi
leaq -0x50(%rbp), %rax
cmpq %rax, %rdi
je 0xac7e
callq 0x31c0
testb %r13b, %r13b
je 0xacd6
movq %r15, %rdi
callq 0x31c0
jmp 0xac90
movq %rax, %rbx
movq %r14, %rdi
jmp 0xaccc
jmp 0xacd3
jmp 0xacd3
movq %rax, %rbx
jmp 0xacc1
movq %rax, %rbx
jmp 0xacc9
jmp 0xacd3
jmp 0xacd3
movq %rax, %rbx
movq -0x60(%rbp), %rdi
leaq -0x50(%rbp), %rax
cmpq %rax, %rdi
je 0xacbc
callq 0x31c0
testb %r14b, %r14b
je 0xacd6
movq %r15, %rdi
callq 0x31c0
movq %r13, %rdi
callq 0x31c0
jmp 0xacd6
movq %rax, %rbx
movq -0x40(%rbp), %rdi
testq %rdi, %rdi
je 0xace4
callq 0x31c0
movq %rbx, %rdi
callq 0x3330