// File: /workspace/github_c_makefile_star2_O2/xemul[P]cylang/declare.c
// Function: dereference
static int dereference(struct cy_token *t, struct cy_value *into, struct cy_value *last, char *buf)
{
	struct cy_value sv = symbols;
	const char *aux;

	if (last)
		last->t = CY_V_NOVALUE;
	aux = t->v.v_sym;
	if (aux[0] == '_') {
		if (cursor.t == CY_V_NOVALUE) {
			show_token_err(t, "Use of cursor outside of loop");
			return -1;
		}

		sv = cursor;
		aux++;
		if (*aux == '.')
			aux++;
	}

	while (*aux != '\0') {
		const char *nxt;
		struct cy_value kv;
		int ret;

		nxt = nest_get_key(aux, &kv, buf);
		if (nxt == NULL)
			return -1;

		if (last != NULL && *nxt == '\0') {
			*last = kv;
			break;
		}

		switch (sv.t) {
		case CY_V_LIST:
			ret = dereference_list_elem(t, &sv, &kv);
			break;
		case CY_V_MAP:
			ret = dereference_map_elem(t, &sv, &kv);
			break;
		default:
			show_token_err(t, "Unknown symbol (%s) for nesting", vtype2s(sv.t));
			ret = -1;
			break;
		}

		if (ret <= 0)
			return -1;

		sv = t->v;
		aux = nxt;
	}

	*into = sv;
	return 1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movq %rcx, 0x50(%rsp)
movq %rdx, %r14
movq %rdi, 0x8(%rsp)
movups 0x7f87(%rip), %xmm0     # 0xc138
movaps %xmm0, 0x10(%rsp)
testq %rdx, %rdx
je 0x41bf
andl $0x0, (%r14)
movq 0x8(%rsp), %rax
movq 0x20(%rax), %rbp
cmpb $0x5f, (%rbp)
jne 0x41fe
cmpl $0x0, 0x7f53(%rip)      # 0xc128
je 0x42fc
movq %rsi, 0x28(%rsp)
movups 0x7f41(%rip), %xmm0     # 0xc128
movaps %xmm0, 0x10(%rsp)
leaq 0x2(%rbp), %rax
cmpb $0x2e, 0x1(%rbp)
leaq 0x1(%rbp), %rbp
cmoveq %rax, %rbp
jmp 0x4203
movq %rsi, 0x28(%rsp)
movq 0x8(%rsp), %rax
leaq 0x18(%rax), %r15
pushq $0x1
popq %r12
movq %r14, 0x48(%rsp)
movq %r15, 0x40(%rsp)
movb (%rbp), %bl
testb %bl, %bl
je 0x431a
xorl %eax, %eax
cmpb $0x2e, %bl
sete %al
addq %rax, %rbp
movq %rbp, %rdi
pushq $0x2e
popq %rsi
callq 0x3080
movq %rax, %r13
cmpb $0x2e, (%rax)
jne 0x4279
movq %r13, %r14
subq %rbp, %r14
movl %r12d, %r15d
movq 0x50(%rsp), %r12
movq %r12, %rdi
movq %rbp, %rsi
movq %r14, %rdx
callq 0x3040
movb $0x0, (%r12,%r14)
movq 0x48(%rsp), %r14
incq %r13
movq %r12, %rdi
movl %r15d, %r12d
movq 0x40(%rsp), %r15
jmp 0x427c
movq %rbp, %rdi
movq %r13, %rbp
cmpb $0x2e, %bl
jne 0x429a
leaq 0x30(%rsp), %rsi
movl %r12d, %edx
callq 0x40cd
testl %eax, %eax
jns 0x42a7
jmp 0x4344
movl $0x2, 0x30(%rsp)
movq %rdi, 0x38(%rsp)
testq %r14, %r14
je 0x42b2
cmpb $0x0, (%rbp)
je 0x4311
movl 0x10(%rsp), %edi
cmpl $0x4, %edi
je 0x42d6
cmpl $0x3, %edi
jne 0x4329
movq 0x8(%rsp), %rdi
leaq 0x10(%rsp), %rsi
leaq 0x30(%rsp), %rdx
callq 0x49ac
jmp 0x42ea
movq 0x8(%rsp), %rdi
leaq 0x10(%rsp), %rsi
leaq 0x30(%rsp), %rdx
callq 0x4f2a
testl %eax, %eax
jle 0x4344
movups (%r15), %xmm0
movaps %xmm0, 0x10(%rsp)
jmp 0x421a
leaq 0x2edd(%rip), %rsi      # 0x71e0
movq 0x8(%rsp), %rdi
xorl %eax, %eax
callq 0x332c
jmp 0x4344
movups 0x30(%rsp), %xmm0
movups %xmm0, (%r14)
movaps 0x10(%rsp), %xmm0
movq 0x28(%rsp), %rax
movups %xmm0, (%rax)
jmp 0x4348
callq 0x33ef
leaq 0x2ec9(%rip), %rsi      # 0x71fe
movq 0x8(%rsp), %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x332c
pushq $-0x1
popq %r12
movl %r12d, %eax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq