// File: /workspace/github_cpp_makefile_star2_O2/Nallantli[P]Rossa/main/rossa/value/value.cpp
// Function: value_t::hash() const
const unsigned int value_t::hash() const
{
	switch (type)
	{
	case NIL:
		return 0x00000000;
	case BOOLEAN_D:
		return std::get<bool>(value) ? 0x10000001 : 0x10000000;
	case NUMBER:
		return 0x20000000 | (std::get<number_t>(value).type == number_t::LONG_NUM ? 0x00000000 : 0x0100000) | (std::get<number_t>(value).getLong() % 0x00FFFFFF);
	case ARRAY:
	{
		int h = 0;
		int i = 0;
		for (auto &e : std::get<std::vector<symbol_t>>(value))
		{
			h = (h + (e.hash() << i++)) % 0x0FFFFFFF;
		}
		return 0x30000000 | h;
	}
	case STRING:
	{
		int h = 0;
		int i = 0;
		for (auto &c : std::get<std::string>(value))
		{
			h = (h + ((int)c << i++)) % 0x0FFFFFFF;
		}
		return 0x40000000 | h;
	}
	case OBJECT:
		return 0x50000000 | (std::get<object_t>(value).hash() % 0x0FFFFFFF);
	case DICTIONARY:
	{
		int h = 0;
		int i = 0;
		for (auto &e : std::get<std::map<const std::string, const symbol_t>>(value))
		{
			h = (h + (e.second.hash() << i++)) % 0x0FFFFFFF;
		}
		return 0x60000000 | h;
	}
	case FUNCTION:
		return 0x70000000 | (std::get<wrapper_t>(value).hash() % 0x0FFFFFFF);
	case TYPE_NAME:
		return 0x80000000 | (std::get<parameter_t>(value).hash() % 0x0FFFFFFF);
	default:
		return 0;
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl (%rdi), %eax
addl $0x9, %eax
cmpl $0x7, %eax
ja 0x3e6fe
movq %rdi, %r14
leaq 0x39449(%rip), %rcx     # 0x77988
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
addq $0x8, %r14
movq %r14, %rdi
callq 0x3e916
movq %rax, %rdi
callq 0x36fda
movl $0xfffffff, %ecx        # imm = 0xFFFFFFF
xorl %edx, %edx
divl %ecx
movl %edx, %ebx
orl $0x80000000, %ebx       # imm = 0x80000000
jmp 0x3e700
addq $0x8, %r14
movq %r14, %rdi
callq 0x3e885
movq (%rax), %r14
movq 0x8(%rax), %r12
xorl %r15d, %r15d
movl $0xfffffff, %ebp        # imm = 0xFFFFFFF
xorl %ebx, %ebx
cmpq %r12, %r14
je 0x3e5b6
movq %r14, %rdi
callq 0x39160
movl %r15d, %ecx
shll %cl, %eax
leal 0x1(%r15), %ecx
addl %ebx, %eax
xorl %edx, %edx
divl %ebp
addq $0x10, %r14
movl %ecx, %r15d
movl %edx, %ebx
jmp 0x3e58f
orl $0x30000000, %ebx       # imm = 0x30000000
jmp 0x3e700
addq $0x8, %r14
movq %r14, %rdi
callq 0x3e8dc
movq %rax, %r14
movq 0x18(%rax), %r15
addq $0x8, %r14
xorl %ebx, %ebx
movl $0xfffffff, %ebp        # imm = 0xFFFFFFF
xorl %r12d, %r12d
cmpq %r14, %r15
je 0x3e612
leaq 0x40(%r15), %rdi
callq 0x39160
leal 0x1(%r12), %r13d
movl %r12d, %ecx
shll %cl, %eax
addl %ebx, %eax
xorl %edx, %edx
divl %ebp
movl %edx, %ebx
movq %r15, %rdi
callq 0x104a0
movq %rax, %r15
movl %r13d, %r12d
jmp 0x3e5e2
orl $0x60000000, %ebx       # imm = 0x60000000
jmp 0x3e700
addq $0x8, %r14
movq %r14, %rdi
callq 0x3e8f9
movq %rax, %rdi
callq 0x3eb32
movl $0xfffffff, %ecx        # imm = 0xFFFFFFF
xorl %edx, %edx
divl %ecx
movl %edx, %ebx
orl $0x70000000, %ebx       # imm = 0x70000000
jmp 0x3e700
addq $0x8, %r14
movq %r14, %rdi
callq 0x3e868
xorl %ebx, %ebx
cmpl $0x1, 0x8(%rax)
setne %bl
movq %r14, %rdi
callq 0x3e868
movq %rax, %rdi
callq 0x3edf8
movl $0xffffff, %ecx         # imm = 0xFFFFFF
cqto
idivq %rcx
shll $0x14, %ebx
orl %edx, %ebx
orl $0x20000000, %ebx       # imm = 0x20000000
jmp 0x3e700
addq $0x8, %r14
movq %r14, %rdi
callq 0x3e8bf
movq %rax, %rdi
callq 0x366dc
movl $0xfffffff, %ecx        # imm = 0xFFFFFFF
xorl %edx, %edx
divl %ecx
movl %edx, %ebx
orl $0x50000000, %ebx       # imm = 0x50000000
jmp 0x3e700
addq $0x8, %r14
movq %r14, %rdi
callq 0x3e8a2
movq (%rax), %rsi
movq 0x8(%rax), %rdi
xorl %ecx, %ecx
movl $0xfffffff, %r8d        # imm = 0xFFFFFFF
xorl %ebx, %ebx
cmpq %rcx, %rdi
je 0x3e6df
movsbl (%rsi,%rcx), %eax
shll %cl, %eax
addl %ebx, %eax
cltd
idivl %r8d
incq %rcx
movl %edx, %ebx
jmp 0x3e6c7
orl $0x40000000, %ebx       # imm = 0x40000000
jmp 0x3e700
addq $0x8, %r14
movq %r14, %rdi
callq 0x3e84b
movzbl (%rax), %ebx
orl $0x10000000, %ebx       # imm = 0x10000000
jmp 0x3e700
xorl %ebx, %ebx
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop