// File: lhydave[P]SysYCompilerLab/front/node.cpp
// Function: sysY_AST::vardef_node::vardef_node(char const*, bool, bool, bool, sysY_AST::exp_node*, sysY_AST::exp_node*)
vardef_node::vardef_node(const char *_name, bool _is_const, bool _is_pt,
	bool _is_param, exp_node *first_dim, exp_node *first_val)
{
	name = string(_name);
	dbg_printf("var %s, ", _name);
	is_const = _is_const;
	is_pt = _is_pt;
	is_param = _is_param;

	set_shape(first_dim);
	is_array = (dim.size() != 0);
	dbg_printf("is_array: %d, is_param: %d, is_const: %d\n", is_array, is_param,
		is_const);
	if (first_val) // initialize
	{
		if (is_array && first_val->exp_type != EXP_INITVAL)
		{
			auto msg = "array '" + name + "' must be initialized by a list";
			yyerror(msg.c_str());
		}
		if (is_array)
			val = set_val(dim, first_val->child);
		else
			val = set_val(dim, first_val);
	}
	vector<int> int_val;
	for (auto i : val)
	{
		int_val.push_back(i->num);
		dbg_printf("%d ", *int_val.rbegin());
	}
	int_val.insert(int_val.end(), size - int_val.size(), 0);
	reg_var(name, is_const, is_array, is_param, dim, int_val);
	gen_code();
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x170, %rsp            # imm = 0x170
movb %r8b, %al
movq 0x10(%rbp), %r8
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
andb $0x1, %dl
movb %dl, -0x11(%rbp)
andb $0x1, %cl
movb %cl, -0x12(%rbp)
andb $0x1, %al
movb %al, -0x13(%rbp)
movq %r9, -0x20(%rbp)
movq -0x8(%rbp), %rdi
movq %rdi, -0x140(%rbp)
callq 0x8720
movq -0x140(%rbp), %rdi
leaq 0x668bb(%rip), %rax     # 0x713b8
movq %rax, (%rdi)
movq $0x0, 0x40(%rdi)
addq $0x48, %rdi
movq %rdi, -0x150(%rbp)
callq 0x54c0
movq -0x140(%rbp), %rdi
addq $0x70, %rdi
movq %rdi, -0x148(%rbp)
callq 0x12cb0
movq -0x140(%rbp), %rdi
addq $0x88, %rdi
movq %rdi, -0x138(%rbp)
callq 0x12cd0
movq -0x10(%rbp), %rax
movq %rax, -0x130(%rbp)
leaq -0x41(%rbp), %rdi
movq %rdi, -0x128(%rbp)
callq 0x5620
movq -0x130(%rbp), %rsi
movq -0x128(%rbp), %rdx
leaq -0x40(%rbp), %rdi
callq 0x8780
jmp 0xab7d
movq -0x140(%rbp), %rdi
addq $0x48, %rdi
leaq -0x40(%rbp), %rsi
movq %rsi, -0x158(%rbp)
callq 0x5410
movq -0x158(%rbp), %rdi
callq 0x56c0
leaq -0x41(%rbp), %rdi
callq 0x5370
movq -0x140(%rbp), %rdi
movb -0x11(%rbp), %al
andb $0x1, %al
movb %al, 0x68(%rdi)
movb -0x12(%rbp), %al
andb $0x1, %al
movb %al, 0xa0(%rdi)
movb -0x13(%rbp), %al
andb $0x1, %al
movb %al, 0xa1(%rdi)
movq -0x20(%rbp), %rsi
callq 0xaf70
jmp 0xabdd
movq -0x140(%rbp), %rdi
addq $0x70, %rdi
callq 0x12cf0
movq %rax, %rcx
movq -0x140(%rbp), %rax
cmpq $0x0, %rcx
setne %cl
andb $0x1, %cl
movb %cl, 0x6a(%rax)
cmpq $0x0, 0x10(%rbp)
je 0xad84
movq -0x140(%rbp), %rax
testb $0x1, 0x6a(%rax)
je 0xace3
movq 0x10(%rbp), %rax
cmpl $0x5, 0x98(%rax)
je 0xace3
movq -0x140(%rbp), %rdx
addq $0x48, %rdx
leaq 0x42eea(%rip), %rsi     # 0x4db2d
leaq -0x98(%rbp), %rdi
callq 0x12d60
jmp 0xac51
leaq 0x42edd(%rip), %rdx     # 0x4db35
leaq -0x78(%rbp), %rdi
leaq -0x98(%rbp), %rsi
callq 0x12d10
jmp 0xac6a
leaq -0x98(%rbp), %rdi
callq 0x56c0
leaq -0x78(%rbp), %rdi
callq 0x5160
movq %rax, %rdi
leaq 0x676e7(%rip), %rax     # 0x72370
movl (%rax), %esi
callq 0xa6c0
leaq -0x78(%rbp), %rdi
callq 0x56c0
jmp 0xace3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x41(%rbp), %rdi
callq 0x5370
jmp 0xaf36
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0xaf36
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x98(%rbp), %rdi
callq 0x56c0
jmp 0xaf36
movq -0x140(%rbp), %rax
testb $0x1, 0x6a(%rax)
je 0xad3c
movq -0x140(%rbp), %rsi
movq %rsi, %rdx
addq $0x70, %rdx
movq 0x10(%rbp), %rax
movq 0x48(%rax), %rcx
leaq -0xb0(%rbp), %rdi
callq 0xb060
jmp 0xad14
movq -0x140(%rbp), %rdi
addq $0x88, %rdi
leaq -0xb0(%rbp), %rsi
callq 0x12e70
leaq -0xb0(%rbp), %rdi
callq 0x12ea0
jmp 0xad82
movq -0x140(%rbp), %rsi
movq %rsi, %rdx
addq $0x70, %rdx
movq 0x10(%rbp), %rcx
leaq -0xc8(%rbp), %rdi
callq 0xb060
jmp 0xad5c
movq -0x140(%rbp), %rdi
addq $0x88, %rdi
leaq -0xc8(%rbp), %rsi
callq 0x12e70
leaq -0xc8(%rbp), %rdi
callq 0x12ea0
jmp 0xad84
leaq -0xe0(%rbp), %rdi
callq 0x12cb0
movq -0x140(%rbp), %rax
addq $0x88, %rax
movq %rax, -0xe8(%rbp)
movq -0xe8(%rbp), %rdi
callq 0x12f00
movq %rax, -0xf0(%rbp)
movq -0xe8(%rbp), %rdi
callq 0x12f30
movq %rax, -0xf8(%rbp)
leaq -0xf0(%rbp), %rdi
leaq -0xf8(%rbp), %rsi
callq 0x12f60
testb $0x1, %al
jne 0xade3
jmp 0xae42
leaq -0xf0(%rbp), %rdi
callq 0x12fa0
movq (%rax), %rax
movq %rax, -0x100(%rbp)
movq -0x100(%rbp), %rsi
addq $0x94, %rsi
leaq -0xe0(%rbp), %rdi
callq 0x12fc0
jmp 0xae15
jmp 0xae17
leaq -0xf0(%rbp), %rdi
callq 0x13030
jmp 0xadca
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0xe0(%rbp), %rdi
callq 0x13160
jmp 0xaf36
leaq -0xe0(%rbp), %rdi
movq %rdi, -0x168(%rbp)
callq 0x130f0
movq %rax, -0x110(%rbp)
leaq -0x108(%rbp), %rdi
leaq -0x110(%rbp), %rsi
callq 0x13120
movq -0x140(%rbp), %rax
movq -0x168(%rbp), %rdi
movslq 0xa4(%rax), %rax
movq %rax, -0x170(%rbp)
callq 0x12cf0
movq -0x170(%rbp), %rdx
movq -0x168(%rbp), %rdi
subq %rax, %rdx
movl $0x0, -0x114(%rbp)
movq -0x108(%rbp), %rsi
leaq -0x114(%rbp), %rcx
callq 0x13050
movq %rax, -0x160(%rbp)
jmp 0xaec7
movq -0x140(%rbp), %rax
movq -0x160(%rbp), %rcx
movq %rcx, -0x120(%rbp)
movq %rax, %rdi
addq $0x48, %rdi
movq %rax, %r8
addq $0x70, %r8
movzbl 0xa1(%rax), %ecx
movzbl 0x6a(%rax), %edx
movzbl 0x68(%rax), %esi
andl $0x1, %esi
andl $0x1, %edx
andl $0x1, %ecx
leaq -0xe0(%rbp), %r9
callq 0x1c140
jmp 0xaf10
movq -0x140(%rbp), %rdi
movq (%rdi), %rax
movq (%rax), %rax
callq *%rax
jmp 0xaf21
leaq -0xe0(%rbp), %rdi
callq 0x13160
addq $0x170, %rsp            # imm = 0x170
popq %rbp
retq
movq -0x138(%rbp), %rdi
callq 0x12ea0
movq -0x148(%rbp), %rdi
callq 0x13160
movq -0x150(%rbp), %rdi
callq 0x56c0
movq -0x140(%rbp), %rdi
callq 0x131c0
movq -0x50(%rbp), %rdi
callq 0x5610
nop