// File: /workspace/github_c_makefile_star2_O1/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 $0x48, %rsp
movq %rcx, %rbp
movq %rdi, (%rsp)
movups 0x94d8(%rip), %xmm0     # 0xe138
movaps %xmm0, 0x10(%rsp)
testq %rdx, %rdx
je 0x4c70
movl $0x0, (%rdx)
movq (%rsp), %rax
movq 0x20(%rax), %r14
cmpb $0x5f, (%r14)
jne 0x4cb4
cmpl $0x0, 0x94a3(%rip)      # 0xe128
je 0x4e07
movq %rdx, 0x8(%rsp)
movq %rsi, 0x28(%rsp)
movups 0x948c(%rip), %xmm0     # 0xe128
movaps %xmm0, 0x10(%rsp)
leaq 0x2(%r14), %rax
cmpb $0x2e, 0x1(%r14)
leaq 0x1(%r14), %r14
cmoveq %rax, %r14
jmp 0x4cbe
movq %rdx, 0x8(%rsp)
movq %rsi, 0x28(%rsp)
movq (%rsp), %rax
addq $0x18, %rax
movq %rax, 0x40(%rsp)
cmpb $0x0, (%r14)
je 0x4df3
movb (%r14), %r12b
xorl %r15d, %r15d
cmpb $0x2e, %r12b
sete %r15b
addq %r14, %r15
movq %r15, %rdi
movl $0x2e, %esi
callq 0x3080
movq %rax, %r13
cmpb $0x2e, (%rax)
jne 0x4d1a
movq %r13, %rbx
subq %r15, %rbx
movq %rbp, %rdi
movq %r15, %rsi
movq %rbx, %rdx
callq 0x3040
movb $0x0, (%rbp,%rbx)
incq %r13
movq %rbp, %r15
cmpb $0x2e, %r12b
jne 0x4d3b
movq %r15, %rdi
leaq 0x30(%rsp), %rsi
movl $0x1, %edx
callq 0x4b95
testl %eax, %eax
jns 0x4d48
xorl %r13d, %r13d
jmp 0x4d48
movl $0x2, 0x30(%rsp)
movq %r15, 0x38(%rsp)
movl $0x1, %ebx
testq %r13, %r13
je 0x4de6
cmpq $0x0, 0x8(%rsp)
je 0x4d65
cmpb $0x0, (%r13)
je 0x4dd4
movl 0x10(%rsp), %edi
cmpl $0x4, %edi
je 0x4d88
cmpl $0x3, %edi
jne 0x4d9d
movq (%rsp), %rdi
leaq 0x10(%rsp), %rsi
leaq 0x30(%rsp), %rdx
callq 0x551e
jmp 0x4dbc
movq (%rsp), %rdi
leaq 0x10(%rsp), %rsi
leaq 0x30(%rsp), %rdx
callq 0x5d2e
jmp 0x4dbc
callq 0x3bfc
movq (%rsp), %rdi
leaq 0x445a(%rip), %rsi      # 0x9207
movq %rax, %rdx
xorl %eax, %eax
callq 0x3240
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
testl %eax, %eax
jle 0x4de6
movq 0x40(%rsp), %rax
movups (%rax), %xmm0
movaps %xmm0, 0x10(%rsp)
xorl %ebx, %ebx
movq %r13, %r14
jmp 0x4de6
movups 0x30(%rsp), %xmm0
movq 0x8(%rsp), %rax
movups %xmm0, (%rax)
movl $0x3, %ebx
testl %ebx, %ebx
je 0x4ccb
cmpl $0x3, %ebx
jne 0x4e19
movaps 0x10(%rsp), %xmm0
movq 0x28(%rsp), %rax
movups %xmm0, (%rax)
movl $0x1, %eax
jmp 0x4e1e
leaq 0x43db(%rip), %rsi      # 0x91e9
movq (%rsp), %rdi
xorl %eax, %eax
callq 0x3240
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq