// File: ShootMe[P]Klondike-Solver/./HashMap.h
// Function: HashMap<int>::Add(HashKey const&, int const&)
KeyValue<T> * HashMap<T>::Add(HashKey const& key, T const& value) {
	int hash = key.ComputeHash();
	int i = hash;
	i ^= (hash >> 16);
	i &= capacity;
	KeyValue<T> * node = &table[i];

	int length = 1;
	while (node != NULL && node->Key[0] != 0) {
		if (node->Hash == hash && key == node->Key) { return node; }
		node = node->Next;
		length++;
	}

	++size;
	node = &table[i];
	if (node->Key[0] != 0) {
		node->Next = new KeyValue<T>(node->Hash, node->Key, node->Value, node->Next);
	}
	node->Hash = hash;
	node->Key = key;
	node->Value = value;

	if (length > maxLength) { maxLength = length; }
	if (length == 1) { slotsUsed++; }
	return NULL;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x50(%rbp)
movq -0x18(%rbp), %rdi
callq 0x11800
movl %eax, %ecx
movq -0x50(%rbp), %rax
movl %ecx, -0x24(%rbp)
movl -0x24(%rbp), %ecx
movl %ecx, -0x28(%rbp)
movl -0x24(%rbp), %ecx
sarl $0x10, %ecx
xorl -0x28(%rbp), %ecx
movl %ecx, -0x28(%rbp)
movl 0xc(%rax), %ecx
andl -0x28(%rbp), %ecx
movl %ecx, -0x28(%rbp)
movq (%rax), %rax
movslq -0x28(%rbp), %rcx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x30(%rbp)
movl $0x1, -0x34(%rbp)
xorl %eax, %eax
cmpq $0x0, -0x30(%rbp)
movb %al, -0x51(%rbp)
je 0xf149
movq -0x30(%rbp), %rdi
addq $0x8, %rdi
xorl %esi, %esi
callq 0xf7b0
movsbl (%rax), %eax
cmpl $0x0, %eax
setne %al
movb %al, -0x51(%rbp)
movb -0x51(%rbp), %al
testb $0x1, %al
jne 0xf152
jmp 0xf198
movq -0x30(%rbp), %rax
movl 0x24(%rax), %eax
cmpl -0x24(%rbp), %eax
jne 0xf182
movq -0x18(%rbp), %rdi
movq -0x30(%rbp), %rsi
addq $0x8, %rsi
callq 0x11870
testb $0x1, %al
jne 0xf175
jmp 0xf182
movq -0x30(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0xf295
movq -0x30(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x30(%rbp)
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0xf122
movq -0x50(%rbp), %rax
movl 0x8(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x8(%rax)
movq (%rax), %rax
movslq -0x28(%rbp), %rcx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rdi
addq $0x8, %rdi
xorl %esi, %esi
callq 0xf7b0
movsbl (%rax), %eax
cmpl $0x0, %eax
je 0xf22a
movl $0x28, %edi
callq 0x3240
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x60(%rbp)
movq -0x30(%rbp), %rax
movl 0x24(%rax), %esi
movq %rax, %rdx
addq $0x8, %rdx
movq %rax, %rcx
addq $0x20, %rcx
movq (%rax), %r8
callq 0x118f0
jmp 0xf201
movq -0x60(%rbp), %rcx
movq -0x30(%rbp), %rax
movq %rcx, (%rax)
jmp 0xf22a
movq -0x60(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
movl $0x28, %esi
callq 0x3250
jmp 0xf29f
movq -0x50(%rbp), %rcx
movl -0x24(%rbp), %edx
movq -0x30(%rbp), %rax
movl %edx, 0x24(%rax)
movq -0x18(%rbp), %rdx
movq -0x30(%rbp), %rax
movq (%rdx), %rsi
movq %rsi, 0x8(%rax)
movq 0x8(%rdx), %rsi
movq %rsi, 0x10(%rax)
movl 0x10(%rdx), %esi
movl %esi, 0x18(%rax)
movb 0x14(%rdx), %dl
movb %dl, 0x1c(%rax)
movq -0x20(%rbp), %rax
movl (%rax), %edx
movq -0x30(%rbp), %rax
movl %edx, 0x20(%rax)
movl -0x34(%rbp), %eax
cmpl 0x14(%rcx), %eax
jle 0xf27a
movq -0x50(%rbp), %rax
movl -0x34(%rbp), %ecx
movl %ecx, 0x14(%rax)
cmpl $0x1, -0x34(%rbp)
jne 0xf28d
movq -0x50(%rbp), %rax
movl 0x18(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x18(%rax)
movq $0x0, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x60, %rsp
popq %rbp
retq
movq -0x40(%rbp), %rdi
callq 0x33d0
nopl (%rax,%rax)