// File: /workspace/github_cpp_makefile_star2_O1/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, -0x7c(%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)
addq $0x60, %rdi
movq %rdi, -0x70(%rbp)
callq 0x3130
xorps %xmm0, %xmm0
leaq -0x40(%rbp), %rax
movaps %xmm0, (%rax)
movq $0x0, 0x10(%rax)
leaq -0x50(%rbp), %r14
leaq 0x9226(%rip), %rax      # 0x13ba0
addq $0x10, %rax
movq %rax, -0x68(%rbp)
leaq 0x913f(%rip), %rax      # 0x13ac8
addq $0x10, %rax
movq %rax, -0x88(%rbp)
movq %rbx, %rdi
callq 0xa2d8
movq %rax, %r13
movl 0x58(%rbx), %eax
cmpl $0x3d, %eax
je 0xab65
cmpl $0x3b, %eax
je 0xaa91
cmpl $0x2c, %eax
jne 0xac53
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 -0x70(%rbp), %rdi
callq 0x3130
movl $0x20, %edi
callq 0x31e0
movq %rax, %r15
movl $0x30, %edi
callq 0x31e0
movq %rax, %r12
movq %r14, -0x60(%rbp)
leaq -0x60(%rbp), %rdi
leaq 0x48cd(%rip), %rsi      # 0xf2de
leaq 0x48c7(%rip), %rdx      # 0xf2df
callq 0x47f6
movl $0x0, 0x8(%r12)
movq -0x88(%rbp), %rax
movq %rax, (%r12)
leaq 0x10(%r12), %rdi
movq %r12, %rax
addq $0x20, %rax
movq %rax, 0x10(%r12)
movq -0x60(%rbp), %rsi
movq -0x58(%rbp), %rdx
addq %rsi, %rdx
movb $0x1, %r14b
callq 0x42ce
movabsq $0x3d00000000, %rax     # imm = 0x3D00000000
movq %rax, 0x8(%r15)
movq -0x68(%rbp), %rax
movq %rax, (%r15)
movq %r13, 0x10(%r15)
movq %r12, 0x18(%r15)
movq %r15, -0x78(%rbp)
movq -0x38(%rbp), %rsi
cmpq -0x30(%rbp), %rsi
je 0xac31
movq %r15, (%rsi)
addq $0x8, -0x38(%rbp)
jmp 0xac41
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 -0x70(%rbp), %rdi
callq 0x3130
movl $0x20, %edi
callq 0x31e0
movq %rax, %r15
movl $0x30, %edi
callq 0x31e0
movq %rax, %r12
movq %r14, -0x60(%rbp)
leaq -0x60(%rbp), %rdi
leaq 0x47f9(%rip), %rsi      # 0xf2de
leaq 0x47f3(%rip), %rdx      # 0xf2df
callq 0x47f6
movl $0x0, 0x8(%r12)
movq -0x88(%rbp), %rax
movq %rax, (%r12)
leaq 0x10(%r12), %rdi
movq %r12, %rax
addq $0x20, %rax
movq %rax, 0x10(%r12)
movq -0x60(%rbp), %rsi
movq -0x58(%rbp), %rdx
addq %rsi, %rdx
movb $0x1, %r14b
callq 0x42ce
movabsq $0x3d00000000, %rax     # imm = 0x3D00000000
movq %rax, 0x8(%r15)
movq -0x68(%rbp), %rax
movq %rax, (%r15)
movq %r13, 0x10(%r15)
movq %r12, 0x18(%r15)
movq %r15, -0x78(%rbp)
movq -0x38(%rbp), %rsi
cmpq -0x30(%rbp), %rsi
je 0xac08
movq %r15, (%rsi)
addq $0x8, -0x38(%rbp)
jmp 0xac18
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 -0x70(%rbp), %rdi
callq 0x3130
movq %rbx, %rdi
callq 0x9b7a
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 %r13, 0x10(%rax)
movq %r15, 0x18(%rax)
movq %rax, -0x60(%rbp)
movq -0x38(%rbp), %rsi
cmpq -0x30(%rbp), %rsi
je 0xabda
movq %rax, (%rsi)
addq $0x8, -0x38(%rbp)
jmp 0xabe7
leaq -0x40(%rbp), %rdi
leaq -0x60(%rbp), %rdx
callq 0xb884
movslq 0x80(%rbx), %rax
movq (%rbx), %rcx
leaq (%rax,%rax,4), %rdx
xorl %eax, %eax
cmpl $0x3b, -0x50(%rcx,%rdx,8)
sete %cl
jne 0xac53
movb %cl, %al
leal (%rax,%rax,2), %eax
jmp 0xac55
xorl %r14d, %r14d
leaq -0x40(%rbp), %rdi
leaq -0x78(%rbp), %rdx
callq 0xb884
movq -0x60(%rbp), %rdi
leaq -0x50(%rbp), %r14
cmpq %r14, %rdi
je 0xac2a
callq 0x31c0
movl $0x3, %eax
jmp 0xac55
xorl %r14d, %r14d
leaq -0x40(%rbp), %rdi
leaq -0x78(%rbp), %rdx
callq 0xb884
movq -0x60(%rbp), %rdi
leaq -0x50(%rbp), %r14
cmpq %r14, %rdi
je 0xac53
callq 0x31c0
xorl %eax, %eax
testl %eax, %eax
je 0xa994
movl $0x28, %edi
callq 0x31e0
movq %rax, %r14
movl $0x0, 0x8(%rax)
leaq 0x8ee0(%rip), %rax      # 0x13b58
addq $0x10, %rax
movq %rax, (%r14)
movl -0x7c(%rbp), %eax
movl %eax, 0xc(%r14)
movq %r14, %rdi
addq $0x10, %rdi
leaq -0x40(%rbp), %rsi
callq 0xae2a
movq -0x40(%rbp), %rdi
testq %rdi, %rdi
je 0xaca4
callq 0x31c0
movq %r14, %rax
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
movq %r14, %rdi
jmp 0xad06
jmp 0xad0f
jmp 0xacc6
jmp 0xad0f
jmp 0xacd2
movq %rax, %rbx
movb $0x1, %r14b
jmp 0xacfe
jmp 0xad0f
jmp 0xad0f
movq %rax, %rbx
movb $0x1, %r14b
jmp 0xacf1
jmp 0xacdc
movq %rax, %rbx
movq -0x60(%rbp), %rdi
leaq -0x50(%rbp), %rax
cmpq %rax, %rdi
je 0xacf1
callq 0x31c0
testb %r14b, %r14b
je 0xacfe
movq %r12, %rdi
callq 0x31c0
testb %r14b, %r14b
je 0xad12
movq %r15, %rdi
callq 0x31c0
jmp 0xad12
jmp 0xad0f
movq %rax, %rbx
movq -0x40(%rbp), %rdi
testq %rdi, %rdi
je 0xad20
callq 0x31c0
movq %rbx, %rdi
callq 0x3330