// File: 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
movq %rsp, %rbp
subq $0xb0, %rsp
movq %rdi, -0x10(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x98(%rbp)
movl (%rax), %eax
addl $0x9, %eax
movl %eax, %ecx
movq %rcx, -0x90(%rbp)
subl $0x8, %eax
ja 0x9a0d7
movq -0x90(%rbp), %rax
leaq 0xb84e5(%rip), %rcx     # 0x152294
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movl $0x0, -0x4(%rbp)
jmp 0x9a0de
movq -0x98(%rbp), %rdi
addq $0x8, %rdi
callq 0x9a600
movb (%rax), %dl
movl $0x10000000, %eax       # imm = 0x10000000
movl $0x10000001, %ecx       # imm = 0x10000001
testb $0x1, %dl
cmovnel %ecx, %eax
movl %eax, -0x4(%rbp)
jmp 0x9a0de
movq -0x98(%rbp), %rdi
addq $0x8, %rdi
callq 0x9a620
movq -0x98(%rbp), %rdi
movl 0x8(%rax), %edx
movl $0x100000, %eax         # imm = 0x100000
xorl %ecx, %ecx
cmpl $0x1, %edx
cmovel %ecx, %eax
orl $0x20000000, %eax       # imm = 0x20000000
cltq
movq %rax, -0xa0(%rbp)
addq $0x8, %rdi
callq 0x9a620
movq %rax, %rdi
callq 0x9c780
movl $0xffffff, %ecx         # imm = 0xFFFFFF
cqto
idivq %rcx
movq -0xa0(%rbp), %rax
orq %rdx, %rax
movl %eax, -0x4(%rbp)
jmp 0x9a0de
movq -0x98(%rbp), %rdi
movl $0x0, -0x14(%rbp)
movl $0x0, -0x18(%rbp)
addq $0x8, %rdi
callq 0x9a640
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rdi
callq 0x24ba0
movq %rax, -0x28(%rbp)
movq -0x20(%rbp), %rdi
callq 0x24bd0
movq %rax, -0x30(%rbp)
leaq -0x28(%rbp), %rdi
leaq -0x30(%rbp), %rsi
callq 0x24c00
testb $0x1, %al
jne 0x99e9f
jmp 0x99eee
leaq -0x28(%rbp), %rdi
callq 0x24c40
movq %rax, -0x38(%rbp)
movl -0x14(%rbp), %eax
movl %eax, -0xa4(%rbp)
movq -0x38(%rbp), %rdi
callq 0x86eb0
movl %eax, %edx
movl -0xa4(%rbp), %eax
movl -0x18(%rbp), %ecx
movl %ecx, %esi
addl $0x1, %esi
movl %esi, -0x18(%rbp)
shll %cl, %edx
movl %edx, %ecx
addl %ecx, %eax
movl $0xfffffff, %ecx        # imm = 0xFFFFFFF
xorl %edx, %edx
divl %ecx
movl %edx, -0x14(%rbp)
leaq -0x28(%rbp), %rdi
callq 0x24e20
jmp 0x99e8c
movl -0x14(%rbp), %eax
orl $0x30000000, %eax       # imm = 0x30000000
movl %eax, -0x4(%rbp)
jmp 0x9a0de
movq -0x98(%rbp), %rdi
movl $0x0, -0x3c(%rbp)
movl $0x0, -0x40(%rbp)
addq $0x8, %rdi
callq 0x9a660
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rdi
callq 0x11530
movq %rax, -0x50(%rbp)
movq -0x48(%rbp), %rdi
callq 0x11a30
movq %rax, -0x58(%rbp)
leaq -0x50(%rbp), %rdi
leaq -0x58(%rbp), %rsi
callq 0x9a680
testb $0x1, %al
jne 0x99f4d
jmp 0x99f8b
leaq -0x50(%rbp), %rdi
callq 0x9a6c0
movq %rax, -0x60(%rbp)
movl -0x3c(%rbp), %eax
movq -0x60(%rbp), %rcx
movsbl (%rcx), %edx
movl -0x40(%rbp), %ecx
movl %ecx, %esi
addl $0x1, %esi
movl %esi, -0x40(%rbp)
shll %cl, %edx
movl %edx, %ecx
addl %ecx, %eax
movl $0xfffffff, %ecx        # imm = 0xFFFFFFF
cltd
idivl %ecx
movl %edx, -0x3c(%rbp)
leaq -0x50(%rbp), %rdi
callq 0x9a6e0
jmp 0x99f3a
movl -0x3c(%rbp), %eax
orl $0x40000000, %eax       # imm = 0x40000000
movl %eax, -0x4(%rbp)
jmp 0x9a0de
movq -0x98(%rbp), %rdi
addq $0x8, %rdi
callq 0x9a700
movq %rax, %rdi
callq 0x7dd90
movl $0xfffffff, %ecx        # imm = 0xFFFFFFF
xorl %edx, %edx
divl %ecx
orl $0x50000000, %edx       # imm = 0x50000000
movl %edx, -0x4(%rbp)
jmp 0x9a0de
movq -0x98(%rbp), %rdi
movl $0x0, -0x64(%rbp)
movl $0x0, -0x68(%rbp)
addq $0x8, %rdi
callq 0x9a720
movq %rax, -0x70(%rbp)
movq -0x70(%rbp), %rdi
callq 0x9a740
movq %rax, -0x78(%rbp)
movq -0x70(%rbp), %rdi
callq 0x9a770
movq %rax, -0x80(%rbp)
leaq -0x78(%rbp), %rdi
leaq -0x80(%rbp), %rsi
callq 0x9a7a0
testb $0x1, %al
jne 0x9a019
jmp 0x9a072
leaq -0x78(%rbp), %rdi
callq 0x9a7d0
movq %rax, -0x88(%rbp)
movl -0x64(%rbp), %eax
movl %eax, -0xa8(%rbp)
movq -0x88(%rbp), %rdi
addq $0x20, %rdi
callq 0x86eb0
movl %eax, %edx
movl -0xa8(%rbp), %eax
movl -0x68(%rbp), %ecx
movl %ecx, %esi
addl $0x1, %esi
movl %esi, -0x68(%rbp)
shll %cl, %edx
movl %edx, %ecx
addl %ecx, %eax
movl $0xfffffff, %ecx        # imm = 0xFFFFFFF
xorl %edx, %edx
divl %ecx
movl %edx, -0x64(%rbp)
leaq -0x78(%rbp), %rdi
callq 0x9a800
jmp 0x9a006
movl -0x64(%rbp), %eax
orl $0x60000000, %eax       # imm = 0x60000000
movl %eax, -0x4(%rbp)
jmp 0x9a0de
movq -0x98(%rbp), %rdi
addq $0x8, %rdi
callq 0x9a830
movq %rax, %rdi
callq 0x9c190
movl $0xfffffff, %ecx        # imm = 0xFFFFFFF
xorl %edx, %edx
divl %ecx
orl $0x70000000, %edx       # imm = 0x70000000
movl %edx, -0x4(%rbp)
jmp 0x9a0de
movq -0x98(%rbp), %rdi
addq $0x8, %rdi
callq 0x9a850
movq %rax, %rdi
callq 0x804a0
movl $0xfffffff, %ecx        # imm = 0xFFFFFFF
xorl %edx, %edx
divl %ecx
orl $0x80000000, %edx       # imm = 0x80000000
movl %edx, -0x4(%rbp)
jmp 0x9a0de
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0xb0, %rsp
popq %rbp
retq
nopw (%rax,%rax)