// File: lhydave[P]SysYCompilerLab/front/node.cpp
// Function: sysY_AST::array_exp_node::array_exp_node(sysY_AST::exp_node*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&)
array_exp_node::array_exp_node(
	exp_node *first_dim, const string &_sysy_array_name) :
	exp_node(EXP_ARRAY),
	sysy_array_name(_sysy_array_name)
{
	var_entry query;
	if (!find_var(sysy_array_name, query)) // not defined
	{
		string msg = "identifier '" + sysy_array_name + "' is not defined";
		yyerror(msg.c_str());
		return;
	}
	if (!query.is_array) // not an array
	{
		if (first_dim) // should not be indexed!
		{
			string msg = "identifier '" + sysy_array_name + "' is not an array";
			yyerror(msg.c_str());
			return;
		}
		exp_type = EXP_VAR;
		eeyore_name = query.eeyore_name;
	}
	else
		while (first_dim) // an array
		{
			first_dim->reduce();
			first_dim->new_temp();
			assert(exp_type != EXP_INITVAL);
			sysy_idx.push_back(first_dim);
			first_dim = first_dim->next;
		}
	reduce();
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x180, %rsp            # imm = 0x180
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x160(%rbp)
leaq -0x39(%rbp), %rdi
movq %rdi, -0x158(%rbp)
callq 0x5620
movq -0x158(%rbp), %rdx
leaq 0x3f670(%rip), %rsi     # 0x4ec60
leaq -0x38(%rbp), %rdi
callq 0x8780
jmp 0xf5fb
movq -0x160(%rbp), %rdi
xorl %r8d, %r8d
movl %r8d, %r9d
movl $0x4, %esi
leaq -0x38(%rbp), %rdx
movl %r8d, %ecx
callq 0xef50
jmp 0xf61b
leaq -0x38(%rbp), %rdi
callq 0x56c0
leaq -0x39(%rbp), %rdi
callq 0x5370
movq -0x160(%rbp), %rdi
leaq 0x61f05(%rip), %rax     # 0x71540
movq %rax, (%rdi)
addq $0xa0, %rdi
movq %rdi, -0x170(%rbp)
callq 0x12cd0
movq -0x160(%rbp), %rdi
addq $0xc0, %rdi
movq %rdi, -0x168(%rbp)
movq -0x18(%rbp), %rsi
callq 0x5170
jmp 0xf671
leaq -0xc8(%rbp), %rdi
movq %rdi, -0x180(%rbp)
callq 0x13220
movq -0x160(%rbp), %rdi
movq -0x180(%rbp), %rsi
addq $0xc0, %rdi
callq 0x1c4c0
movb %al, -0x171(%rbp)
jmp 0xf6a6
movb -0x171(%rbp), %al
testb $0x1, %al
jne 0xf7a9
jmp 0xf6b6
movq -0x160(%rbp), %rdx
addq $0xc0, %rdx
leaq 0x3e61d(%rip), %rsi     # 0x4dce8
leaq -0x108(%rbp), %rdi
callq 0x12d60
jmp 0xf6d9
leaq 0x3e615(%rip), %rdx     # 0x4dcf5
leaq -0xe8(%rbp), %rdi
leaq -0x108(%rbp), %rsi
callq 0x12d10
jmp 0xf6f5
leaq -0x108(%rbp), %rdi
callq 0x56c0
leaq -0xe8(%rbp), %rdi
callq 0x5160
movq %rax, %rdi
leaq 0x62c59(%rip), %rax     # 0x72370
movl (%rax), %esi
callq 0xa6c0
movl $0x1, -0x10c(%rbp)
leaq -0xe8(%rbp), %rdi
callq 0x56c0
jmp 0xf8f2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0xf75c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x38(%rbp), %rdi
callq 0x56c0
leaq -0x39(%rbp), %rdi
callq 0x5370
jmp 0xf937
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0xf91f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0xf907
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x108(%rbp), %rdi
callq 0x56c0
jmp 0xf907
testb $0x1, -0x88(%rbp)
jne 0xf886
cmpq $0x0, -0x10(%rbp)
je 0xf861
movq -0x160(%rbp), %rdx
addq $0xc0, %rdx
leaq 0x3e512(%rip), %rsi     # 0x4dce8
leaq -0x150(%rbp), %rdi
callq 0x12d60
jmp 0xf7e4
leaq 0x3e51b(%rip), %rdx     # 0x4dd06
leaq -0x130(%rbp), %rdi
leaq -0x150(%rbp), %rsi
callq 0x12d10
jmp 0xf800
leaq -0x150(%rbp), %rdi
callq 0x56c0
leaq -0x130(%rbp), %rdi
callq 0x5160
movq %rax, %rdi
leaq 0x62b4e(%rip), %rax     # 0x72370
movl (%rax), %esi
callq 0xa6c0
movl $0x1, -0x10c(%rbp)
leaq -0x130(%rbp), %rdi
callq 0x56c0
jmp 0xf8f2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x150(%rbp), %rdi
callq 0x56c0
jmp 0xf907
movq -0x160(%rbp), %rdi
movl $0x1, 0x98(%rdi)
addq $0x70, %rdi
leaq -0xc8(%rbp), %rsi
callq 0x5050
jmp 0xf884
jmp 0xf8d6
jmp 0xf888
cmpq $0x0, -0x10(%rbp)
je 0xf8d4
movq -0x10(%rbp), %rdi
movq (%rdi), %rax
movq 0x18(%rax), %rax
callq *%rax
jmp 0xf89e
movq -0x10(%rbp), %rdi
movq (%rdi), %rax
movq 0x10(%rax), %rax
callq *%rax
jmp 0xf8ad
movq -0x160(%rbp), %rdi
addq $0xa0, %rdi
leaq -0x10(%rbp), %rsi
callq 0x135c0
jmp 0xf8c6
movq -0x10(%rbp), %rax
movq 0x40(%rax), %rax
movq %rax, -0x10(%rbp)
jmp 0xf888
jmp 0xf8d6
movq -0x160(%rbp), %rdi
movq (%rdi), %rax
movq 0x18(%rax), %rax
callq *%rax
jmp 0xf8e8
movl $0x0, -0x10c(%rbp)
leaq -0xc8(%rbp), %rdi
callq 0x13530
addq $0x180, %rsp            # imm = 0x180
popq %rbp
retq
leaq -0xc8(%rbp), %rdi
callq 0x13530
movq -0x168(%rbp), %rdi
callq 0x56c0
movq -0x170(%rbp), %rdi
callq 0x12ea0
movq -0x160(%rbp), %rdi
callq 0x14050
movq -0x48(%rbp), %rdi
callq 0x5610