// File: /workspace/github_cpp_makefile_star2_O2/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movq %r9, 0x40(%rsp)
movl %r8d, %ebp
movl %ecx, %r12d
movq %rdi, %rbx
leaq 0x28(%rdi), %rax
xorps %xmm0, %xmm0
movups %xmm0, 0x8(%rdi)
movq %rax, 0x18(%rdi)
andq $0x0, 0x20(%rdi)
movl %edx, %r15d
xorl %eax, %eax
movb %al, 0x28(%rdi)
leaq 0x266b7(%rip), %rcx     # 0x2e2b8
movl (%rcx), %ecx
movl %ecx, 0x38(%rdi)
leaq 0x257e3(%rip), %rcx     # 0x2d3f0
movq %rcx, (%rdi)
andq $0x0, 0x40(%rdi)
leaq 0x58(%rdi), %rcx
movq %rcx, 0x48(%rdi)
andq $0x0, 0x50(%rdi)
leaq 0x48(%rdi), %r13
movb %al, 0x58(%rdi)
leaq 0x70(%rdi), %rax
movq %rax, (%rsp)
leaq 0x88(%rdi), %rax
movq %rax, 0x8(%rsp)
movups %xmm0, 0x70(%rdi)
movups %xmm0, 0x80(%rdi)
movups %xmm0, 0x90(%rdi)
leaq 0x10(%rsp), %rdi
leaq 0x48(%rsp), %rdx
movq %r13, 0x38(%rsp)
callq 0x68d2
leaq 0x10(%rsp), %r14
movq %r13, %rdi
movq %r14, %rsi
callq 0x5300
movq %r14, %rdi
callq 0x5548
movb %r15b, 0x68(%rbx)
movb %r12b, 0xa0(%rbx)
movb %bpl, 0xa1(%rbx)
movq %rbx, %rdi
movq 0x40(%rsp), %rsi
callq 0x7e6e
movq 0xa0(%rsp), %r13
movq 0x70(%rbx), %rax
movq 0x78(%rbx), %rcx
cmpq %rax, %rcx
setne 0x6a(%rbx)
testq %r13, %r13
movq 0x38(%rsp), %rbp
je 0x7d6b
cmpq %rax, %rcx
je 0x7d3d
cmpl $0x5, 0x98(%r13)
je 0x7d26
leaq 0x16bf4(%rip), %rsi     # 0x1e8c9
leaq 0x48(%rsp), %rdi
movq %rbp, %rdx
callq 0xc598
leaq 0x16be8(%rip), %rdx     # 0x1e8d1
leaq 0x10(%rsp), %rdi
leaq 0x48(%rsp), %rsi
callq 0xc579
leaq 0x48(%rsp), %rdi
callq 0x5548
leaq 0x10(%rsp), %r14
movq (%r14), %rdi
leaq 0x265a7(%rip), %rax     # 0x2e2b8
movl (%rax), %esi
callq 0x79c8
movq %r14, %rdi
callq 0x5548
testb $0x1, 0x6a(%rbx)
je 0x7d3d
movq 0x48(%r13), %rcx
leaq 0x10(%rsp), %rdi
movq %rbx, %rsi
movq (%rsp), %rdx
callq 0x7f1c
jmp 0x7d51
leaq 0x10(%rsp), %rdi
movq %rbx, %rsi
movq (%rsp), %rdx
movq %r13, %rcx
callq 0x7f1c
leaq 0x10(%rsp), %r14
movq 0x8(%rsp), %rdi
movq %r14, %rsi
callq 0xcc12
movq %r14, %rdi
callq 0xcbde
xorps %xmm0, %xmm0
leaq 0x10(%rsp), %r15
andq $0x0, 0x10(%r15)
movaps %xmm0, (%r15)
movq 0x88(%rbx), %r14
movq 0x90(%rbx), %r12
movl $0x94, %r13d
cmpq %r12, %r14
je 0x7da9
movq (%r14), %rsi
addq %r13, %rsi
movq %r15, %rdi
callq 0xc60e
addq $0x8, %r14
jmp 0x7d90
leaq 0x10(%rsp), %rdi
movq 0x8(%rdi), %rsi
movslq 0xa4(%rbx), %rdx
movq %rsi, %rax
subq (%rdi), %rax
sarq $0x2, %rax
subq %rax, %rdx
leaq 0x48(%rsp), %rcx
andl $0x0, (%rcx)
callq 0xc62c
movzbl 0x68(%rbx), %esi
movzbl 0x6a(%rbx), %edx
movzbl 0xa1(%rbx), %ecx
leaq 0x10(%rsp), %r9
movq %rbp, %rdi
movq (%rsp), %r8
callq 0xe5ca
movq (%rbx), %rax
movq %rbx, %rdi
callq *(%rax)
leaq 0x10(%rsp), %rdi
callq 0xcbaa
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %r13
leaq 0x48(%rsp), %rdi
callq 0x5548
jmp 0x7e41
jmp 0x7e2d
jmp 0x7e2d
jmp 0x7e2d
jmp 0x7e34
jmp 0x7e2d
movq %rax, %r13
jmp 0x7e41
jmp 0x7e34
movq %rax, %r13
leaq 0x10(%rsp), %rdi
callq 0xcbaa
movq 0x8(%rsp), %rdi
callq 0xcbde
movq (%rsp), %rdi
callq 0xcbaa
movq 0x38(%rsp), %rdi
callq 0x5548
movq %rbx, %rdi
callq 0xc94c
movq %r13, %rdi
callq 0x54c0