// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x70, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movq 0xb2b9(%rip), %rax      # 0x10188
movq %rax, -0x38(%rbp)
movq 0xb2b6(%rip), %rax      # 0x10190
movq %rax, -0x30(%rbp)
cmpq $0x0, -0x20(%rbp)
je 0x4eef
movq -0x20(%rbp), %rax
movl $0x0, (%rax)
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x5f, %eax
jne 0x4f6a
cmpl $0x0, 0xb26a(%rip)      # 0x10178
jne 0x4f2e
movq -0x10(%rbp), %rdi
leaq 0x62b2(%rip), %rsi      # 0xb1cd
movb $0x0, %al
callq 0x3310
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x5088
movq 0xb243(%rip), %rax      # 0x10178
movq %rax, -0x38(%rbp)
movq 0xb240(%rip), %rax      # 0x10180
movq %rax, -0x30(%rbp)
movq -0x40(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x2e, %eax
jne 0x4f68
movq -0x40(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x40(%rbp)
jmp 0x4f6a
jmp 0x4f6c
movq -0x40(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x0, %eax
je 0x506e
movq -0x40(%rbp), %rdi
movq -0x28(%rbp), %rdx
leaq -0x58(%rbp), %rsi
callq 0x50a0
movq %rax, -0x48(%rbp)
cmpq $0x0, -0x48(%rbp)
jne 0x4fa4
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x5088
cmpq $0x0, -0x20(%rbp)
je 0x4fcf
movq -0x48(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x0, %eax
jne 0x4fcf
movq -0x20(%rbp), %rax
movq -0x58(%rbp), %rcx
movq %rcx, (%rax)
movq -0x50(%rbp), %rcx
movq %rcx, 0x8(%rax)
jmp 0x506e
movl -0x38(%rbp), %eax
movl %eax, -0x60(%rbp)
subl $0x3, %eax
je 0x4fe6
jmp 0x4fdc
movl -0x60(%rbp), %eax
subl $0x4, %eax
je 0x4ffc
jmp 0x5012
movq -0x10(%rbp), %rdi
leaq -0x38(%rbp), %rsi
leaq -0x58(%rbp), %rdx
callq 0x5d10
movl %eax, -0x5c(%rbp)
jmp 0x503e
movq -0x10(%rbp), %rdi
leaq -0x38(%rbp), %rsi
leaq -0x58(%rbp), %rdx
callq 0x6850
movl %eax, -0x5c(%rbp)
jmp 0x503e
movq -0x10(%rbp), %rax
movq %rax, -0x68(%rbp)
movl -0x38(%rbp), %edi
callq 0x3400
movq -0x68(%rbp), %rdi
movq %rax, %rdx
leaq 0x61bb(%rip), %rsi      # 0xb1eb
movb $0x0, %al
callq 0x3310
movl $0xffffffff, -0x5c(%rbp) # imm = 0xFFFFFFFF
cmpl $0x0, -0x5c(%rbp)
jg 0x504d
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x5088
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rcx
movq %rcx, -0x38(%rbp)
movq 0x20(%rax), %rax
movq %rax, -0x30(%rbp)
movq -0x48(%rbp), %rax
movq %rax, -0x40(%rbp)
jmp 0x4f6c
movq -0x18(%rbp), %rax
movq -0x38(%rbp), %rcx
movq %rcx, (%rax)
movq -0x30(%rbp), %rcx
movq %rcx, 0x8(%rax)
movl $0x1, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x70, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)