// File: lhydave[P]SysYCompilerLab/front/node.cpp
// Function: sysY_AST::vardef_node::gen_code()
void vardef_node::gen_code()
{
	if (is_param) // do nothing for parameters
		return;
	var_entry query;
	find_var(name, query);
	if (blk_id == 0) // only declare global variables
		code = gen_vardecl(query, false);
	else if (!val.empty()) // generate initial values
	{
		if (!is_array) // variable
		{
			code += val[0]->code;
			code +=
				"\t" + query.eeyore_name + " = " + val[0]->eeyore_name + "\n";
		}
		else // an array
			for (auto i = 0; i < val.size(); i++)
			{
				code += val[i]->code;
				code += "\t" + query.eeyore_name + "[" +
					to_string(i * int_size) + "] = " + val[i]->eeyore_name +
					"\n";
			}
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x230, %rsp            # imm = 0x230
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x220(%rbp)
testb $0x1, 0xa1(%rax)
je 0xb938
jmp 0xbe2e
leaq -0x80(%rbp), %rdi
movq %rdi, -0x228(%rbp)
callq 0x13220
movq -0x220(%rbp), %rdi
movq -0x228(%rbp), %rsi
addq $0x48, %rdi
callq 0x1c4c0
jmp 0xb961
leaq 0x66b30(%rip), %rax     # 0x72498
cmpl $0x0, (%rax)
jne 0xb9c0
leaq -0xb0(%rbp), %rdi
leaq -0x80(%rbp), %rsi
xorl %edx, %edx
callq 0xbe50
jmp 0xb981
movq -0x220(%rbp), %rdi
addq $0x18, %rdi
leaq -0xb0(%rbp), %rsi
callq 0x5410
leaq -0xb0(%rbp), %rdi
callq 0x56c0
jmp 0xbe25
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x88(%rbp)
movl %eax, -0x8c(%rbp)
jmp 0xbe37
movq -0x220(%rbp), %rdi
addq $0x88, %rdi
callq 0x13270
testb $0x1, %al
jne 0xbe23
movq -0x220(%rbp), %rax
testb $0x1, 0x6a(%rax)
jne 0xbb71
movq -0x220(%rbp), %rdi
addq $0x88, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x132b0
movq -0x220(%rbp), %rdi
movq (%rax), %rsi
addq $0x18, %rsi
addq $0x18, %rdi
callq 0x5440
jmp 0xba1c
leaq 0x4323c(%rip), %rsi     # 0x4ec5f
leaq -0x130(%rbp), %rdi
leaq -0x80(%rbp), %rdx
callq 0x12d60
jmp 0xba35
leaq 0x42153(%rip), %rdx     # 0x4db8f
leaq -0x110(%rbp), %rdi
leaq -0x130(%rbp), %rsi
callq 0x12d10
jmp 0xba51
movq -0x220(%rbp), %rdi
addq $0x88, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x132b0
movq (%rax), %rdx
addq $0x70, %rdx
leaq -0xf0(%rbp), %rdi
leaq -0x110(%rbp), %rsi
callq 0x132d0
jmp 0xba84
leaq 0x421b5(%rip), %rdx     # 0x4dc40
leaq -0xd0(%rbp), %rdi
leaq -0xf0(%rbp), %rsi
callq 0x12d10
jmp 0xbaa0
movq -0x220(%rbp), %rdi
addq $0x18, %rdi
leaq -0xd0(%rbp), %rsi
callq 0x5440
jmp 0xbab9
leaq -0xd0(%rbp), %rdi
callq 0x56c0
leaq -0xf0(%rbp), %rdi
callq 0x56c0
leaq -0x110(%rbp), %rdi
callq 0x56c0
leaq -0x130(%rbp), %rdi
callq 0x56c0
jmp 0xbe21
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x88(%rbp)
movl %eax, -0x8c(%rbp)
jmp 0xbb60
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x88(%rbp)
movl %eax, -0x8c(%rbp)
jmp 0xbb54
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x88(%rbp)
movl %eax, -0x8c(%rbp)
jmp 0xbb48
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x88(%rbp)
movl %eax, -0x8c(%rbp)
leaq -0xd0(%rbp), %rdi
callq 0x56c0
leaq -0xf0(%rbp), %rdi
callq 0x56c0
leaq -0x110(%rbp), %rdi
callq 0x56c0
leaq -0x130(%rbp), %rdi
callq 0x56c0
jmp 0xbe37
movl $0x0, -0x134(%rbp)
movq -0x220(%rbp), %rdi
movslq -0x134(%rbp), %rax
movq %rax, -0x230(%rbp)
addq $0x88, %rdi
callq 0x13320
movq %rax, %rcx
movq -0x230(%rbp), %rax
cmpq %rcx, %rax
jae 0xbe1f
movq -0x220(%rbp), %rdi
addq $0x88, %rdi
movslq -0x134(%rbp), %rsi
callq 0x132b0
movq -0x220(%rbp), %rdi
movq (%rax), %rsi
addq $0x18, %rsi
addq $0x18, %rdi
callq 0x5440
jmp 0xbbe2
leaq 0x43076(%rip), %rsi     # 0x4ec5f
leaq -0x1f8(%rbp), %rdi
leaq -0x80(%rbp), %rdx
callq 0x12d60
jmp 0xbbfb
leaq 0x42ae5(%rip), %rdx     # 0x4e6e7
leaq -0x1d8(%rbp), %rdi
leaq -0x1f8(%rbp), %rsi
callq 0x12d10
jmp 0xbc17
movl -0x134(%rbp), %esi
shll $0x2, %esi
leaq -0x218(%rbp), %rdi
callq 0x13410
jmp 0xbc2e
leaq -0x1b8(%rbp), %rdi
leaq -0x1d8(%rbp), %rsi
leaq -0x218(%rbp), %rdx
callq 0x13340
jmp 0xbc4a
leaq 0x41f3d(%rip), %rdx     # 0x4db8e
leaq -0x198(%rbp), %rdi
leaq -0x1b8(%rbp), %rsi
callq 0x12d10
jmp 0xbc66
movq -0x220(%rbp), %rdi
addq $0x88, %rdi
movslq -0x134(%rbp), %rsi
callq 0x132b0
movq (%rax), %rdx
addq $0x70, %rdx
leaq -0x178(%rbp), %rdi
leaq -0x198(%rbp), %rsi
callq 0x132d0
jmp 0xbc9c
leaq 0x41f9d(%rip), %rdx     # 0x4dc40
leaq -0x158(%rbp), %rdi
leaq -0x178(%rbp), %rsi
callq 0x12d10
jmp 0xbcb8
movq -0x220(%rbp), %rdi
addq $0x18, %rdi
leaq -0x158(%rbp), %rsi
callq 0x5440
jmp 0xbcd1
leaq -0x158(%rbp), %rdi
callq 0x56c0
leaq -0x178(%rbp), %rdi
callq 0x56c0
leaq -0x198(%rbp), %rdi
callq 0x56c0
leaq -0x1b8(%rbp), %rdi
callq 0x56c0
leaq -0x218(%rbp), %rdi
callq 0x56c0
leaq -0x1d8(%rbp), %rdi
callq 0x56c0
leaq -0x1f8(%rbp), %rdi
callq 0x56c0
movl -0x134(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x134(%rbp)
jmp 0xbb7b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x88(%rbp)
movl %eax, -0x8c(%rbp)
jmp 0xbe11
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x88(%rbp)
movl %eax, -0x8c(%rbp)
jmp 0xbe05
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x88(%rbp)
movl %eax, -0x8c(%rbp)
jmp 0xbdf9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x88(%rbp)
movl %eax, -0x8c(%rbp)
jmp 0xbded
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x88(%rbp)
movl %eax, -0x8c(%rbp)
jmp 0xbde1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x88(%rbp)
movl %eax, -0x8c(%rbp)
jmp 0xbdd5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x88(%rbp)
movl %eax, -0x8c(%rbp)
leaq -0x158(%rbp), %rdi
callq 0x56c0
leaq -0x178(%rbp), %rdi
callq 0x56c0
leaq -0x198(%rbp), %rdi
callq 0x56c0
leaq -0x1b8(%rbp), %rdi
callq 0x56c0
leaq -0x218(%rbp), %rdi
callq 0x56c0
leaq -0x1d8(%rbp), %rdi
callq 0x56c0
leaq -0x1f8(%rbp), %rdi
callq 0x56c0
jmp 0xbe37
jmp 0xbe21
jmp 0xbe23
jmp 0xbe25
leaq -0x80(%rbp), %rdi
callq 0x13530
addq $0x230, %rsp            # imm = 0x230
popq %rbp
retq
leaq -0x80(%rbp), %rdi
callq 0x13530
movq -0x88(%rbp), %rdi
callq 0x5610
nopl (%rax)