// File: lhydave[P]SysYCompilerLab/front/node.cpp
// Function: sysY_AST::idx_open(std::vector<sysY_AST::exp_node*, std::allocator<sysY_AST::exp_node*>> const&, sysY_AST::var_entry const&)
static exp_node *idx_open(
	const vector<exp_node *> &idx, const var_entry &query_arr)
{
	if (idx.empty())
		return new exp_node(EXP_NUM, "", 0);
	auto ret = *idx.begin();
	auto size = idx.size();
	for (auto i = 1; i < size; i++)
	{
		auto scale = new exp_node(EXP_NUM, "", query_arr.dim[i]);
		dbg_printf("idx num: %d,\n", idx[i]->num);
		ret = new arith_exp_node(MUL, ret, scale);
		ret = new arith_exp_node(ADD, ret, idx[i]);
	}
	return ret;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xe0, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x10(%rbp), %rdi
callq 0x13270
testb $0x1, %al
jne 0x102a5
jmp 0x10373
movl $0xa0, %edi
callq 0x5300
movq %rax, -0xb0(%rbp)
movb $0x1, -0x4d(%rbp)
leaq -0x39(%rbp), %rdi
movq %rdi, -0xa8(%rbp)
callq 0x5620
movq -0xa8(%rbp), %rdx
leaq 0x3e988(%rip), %rsi     # 0x4ec60
leaq -0x38(%rbp), %rdi
callq 0x8780
jmp 0x102e3
movq -0xb0(%rbp), %rdi
xorl %r8d, %r8d
movl %r8d, %r9d
movl $0x2, %esi
leaq -0x38(%rbp), %rdx
movl %r8d, %ecx
callq 0xef50
jmp 0x10303
movq -0xb0(%rbp), %rax
movb $0x0, -0x4d(%rbp)
movq %rax, -0x8(%rbp)
leaq -0x38(%rbp), %rdi
callq 0x56c0
leaq -0x39(%rbp), %rdi
callq 0x5370
jmp 0x10588
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0x1034c
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
testb $0x1, -0x4d(%rbp)
jne 0x1035d
jmp 0x1036e
movq -0xb0(%rbp), %rdi
movl $0xa0, %esi
callq 0x5320
jmp 0x10595
movq -0x10(%rbp), %rdi
callq 0x14b70
movq %rax, -0x60(%rbp)
leaq -0x60(%rbp), %rdi
callq 0x14ba0
movq (%rax), %rax
movq %rax, -0x58(%rbp)
movq -0x10(%rbp), %rdi
callq 0x13320
movq %rax, -0x68(%rbp)
movl $0x1, -0x6c(%rbp)
movslq -0x6c(%rbp), %rax
cmpq -0x68(%rbp), %rax
jae 0x10580
movl $0xa0, %edi
callq 0x5300
movq %rax, -0xc0(%rbp)
movb $0x1, -0x9a(%rbp)
leaq -0x99(%rbp), %rdi
movq %rdi, -0xb8(%rbp)
callq 0x5620
movq -0xb8(%rbp), %rdx
leaq 0x3e875(%rip), %rsi     # 0x4ec60
leaq -0x98(%rbp), %rdi
callq 0x8780
jmp 0x103f9
movq -0x18(%rbp), %rdi
addq $0x48, %rdi
movslq -0x6c(%rbp), %rsi
callq 0x14bc0
movq -0xc0(%rbp), %rdi
movl (%rax), %ecx
xorl %r8d, %r8d
movl %r8d, %r9d
movl $0x2, %esi
leaq -0x98(%rbp), %rdx
callq 0xef50
jmp 0x1042c
movb $0x0, -0x9a(%rbp)
leaq -0x98(%rbp), %rdi
callq 0x56c0
leaq -0x99(%rbp), %rdi
callq 0x5370
movq -0xc0(%rbp), %rax
movq %rax, -0x78(%rbp)
movl $0xb0, %edi
callq 0x5300
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0xc8(%rbp)
movq -0x58(%rbp), %rdx
movq -0x78(%rbp), %rcx
movl $0xa, %esi
callq 0x105a0
jmp 0x10481
movq -0xc8(%rbp), %rax
movq %rax, -0x58(%rbp)
movl $0xb0, %edi
callq 0x5300
movq %rax, -0xd8(%rbp)
movq %rax, -0xe0(%rbp)
movq -0x58(%rbp), %rax
movq %rax, -0xd0(%rbp)
movq -0x10(%rbp), %rdi
movslq -0x6c(%rbp), %rsi
callq 0x14be0
movq -0xd8(%rbp), %rdi
movq -0xd0(%rbp), %rdx
movq (%rax), %rcx
movl $0x7, %esi
callq 0x105a0
jmp 0x104d9
movq -0xe0(%rbp), %rax
movq %rax, -0x58(%rbp)
movl -0x6c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x6c(%rbp)
jmp 0x103a4
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0x10518
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x98(%rbp), %rdi
callq 0x56c0
leaq -0x99(%rbp), %rdi
callq 0x5370
testb $0x1, -0x9a(%rbp)
jne 0x1052f
jmp 0x10540
movq -0xc0(%rbp), %rdi
movl $0xa0, %esi
callq 0x5320
jmp 0x10595
movq -0xc8(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
movl $0xb0, %esi
callq 0x5320
jmp 0x10595
movq -0xe0(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
movl $0xb0, %esi
callq 0x5320
jmp 0x10595
movq -0x58(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0xe0, %rsp
popq %rbp
retq
movq -0x48(%rbp), %rdi
callq 0x5610
nop