// File: /workspace/github_c_makefile_star2_O0/xemul[P]cylang/declare.c
// Function: eval_declare
static int eval_declare(struct cy_token *t, struct cy_file *f)
{
	struct cy_token st, vt;
	struct cy_value in, last;
	char buf[MAX_SYM_LEN + 1];

	if (cy_next(f, &st) <= 0)
		return -1;

	if (!is_symbol_token(&st)) {
		show_token_err(t, "Declaration to non-symbol");
		return -1;
	}

	if (dereference(&st, &in, &last, buf) <= 0)
		return -1;

	if (last.t != CY_V_STRING) {
		show_token_err(t, "Last sym is not a string");
		return -1;
	}

	if (in.t != CY_V_MAP) {
		show_token_err(t, "Can't declare in non-map");
		return -1;
	}

	if (t->typ->priv) { /* swap */
		struct cy_map_value *mv;

		mv = find_in_map(&in.v_map->r, last.v_str, 0);
		if (mv == NULL)
			goto set;

		set_cursor(&mv->v);
		if (cy_eval_next(f, &vt) <= 0)
			return -1;

		set_cursor(NULL);
		t->v = mv->v;
		mv->v = vt.v;

		return 1;
	}

set:
	if (cy_eval_next(f, &vt) <= 0)
		return -1;

	if (map_add_value(strdup(last.v_str), &vt.v, &in.v_map->r, true) < 0)
		return -1;

	return 1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xe0, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x18(%rbp), %rdi
leaq -0x40(%rbp), %rsi
callq 0x3e30
cmpl $0x0, %eax
jg 0x51f1
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x538e
leaq -0x40(%rbp), %rdi
callq 0x4ae0
testb $0x1, %al
jne 0x521c
movq -0x10(%rbp), %rdi
leaq 0x603f(%rip), %rsi      # 0xb248
movb $0x0, %al
callq 0x3310
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x538e
leaq -0xd0(%rbp), %rcx
leaq -0x40(%rbp), %rdi
leaq -0x78(%rbp), %rsi
leaq -0x88(%rbp), %rdx
callq 0x4eb0
cmpl $0x0, %eax
jg 0x5248
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x538e
cmpl $0x2, -0x88(%rbp)
je 0x526f
movq -0x10(%rbp), %rdi
leaq 0x6006(%rip), %rsi      # 0xb262
movb $0x0, %al
callq 0x3310
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x538e
cmpl $0x4, -0x78(%rbp)
je 0x5293
movq -0x10(%rbp), %rdi
leaq 0x5ffb(%rip), %rsi      # 0xb27b
movb $0x0, %al
callq 0x3310
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x538e
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
cmpq $0x0, 0x10(%rax)
je 0x533a
movq -0x70(%rbp), %rdi
movq -0x80(%rbp), %rsi
xorl %edx, %edx
callq 0x6790
movq %rax, -0xd8(%rbp)
cmpq $0x0, -0xd8(%rbp)
jne 0x52c8
jmp 0x533c
movq -0xd8(%rbp), %rdi
addq $0x20, %rdi
callq 0x4aa0
movq -0x18(%rbp), %rdi
leaq -0x68(%rbp), %rsi
callq 0x54f0
cmpl $0x0, %eax
jg 0x52f6
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x538e
xorl %eax, %eax
movl %eax, %edi
callq 0x4aa0
movq -0x10(%rbp), %rax
movq -0xd8(%rbp), %rcx
movq 0x20(%rcx), %rdx
movq %rdx, 0x18(%rax)
movq 0x28(%rcx), %rcx
movq %rcx, 0x20(%rax)
movq -0xd8(%rbp), %rax
movq -0x50(%rbp), %rcx
movq %rcx, 0x20(%rax)
movq -0x48(%rbp), %rcx
movq %rcx, 0x28(%rax)
movl $0x1, -0x4(%rbp)
jmp 0x538e
jmp 0x533c
movq -0x18(%rbp), %rdi
leaq -0x68(%rbp), %rsi
callq 0x54f0
cmpl $0x0, %eax
jg 0x5357
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x538e
movq -0x80(%rbp), %rdi
callq 0x3200
movq %rax, %rdi
leaq -0x68(%rbp), %rsi
addq $0x18, %rsi
movq -0x70(%rbp), %rdx
movl $0x1, %ecx
callq 0x65f0
cmpl $0x0, %eax
jge 0x5387
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x538e
movl $0x1, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0xe0, %rsp
popq %rbp
retq
nopw (%rax,%rax)