// File: attractivechaos[P]udb2/khashlpp/./khashl.hpp
// Function: klib::KHashSet<klib::KHashMapBucket<unsigned int, int>, klib::KHashMapHash<klib::KHashMapBucket<unsigned int, int>, aux_hash, unsigned int>, klib::KHashMapEq<klib::KHashMapBucket<unsigned int, int>, std::equal_to<unsigned int>>, unsigned int>::resize(unsigned int)
int resize(khint_t new_nb) {
		uint32_t *new_used = 0;
		khint_t j = 0, x = new_nb, nb, new_bits, new_mask;
		while ((x >>= khint_t(1)) != 0) ++j;
		if (new_nb & (new_nb - 1)) ++j;
		new_bits = j > 2? j : 2;
		new_nb = khint_t(1) << new_bits;
		if (count > (new_nb>>1) + (new_nb>>2)) return 0; /* requested size is too small */
		new_used = (uint32_t*)std::malloc(__kh_fsize(new_nb) * sizeof(uint32_t));
		memset(new_used, 0, __kh_fsize(new_nb) * sizeof(uint32_t));
		if (!new_used) return -1; /* not enough memory */
		nb = n_buckets();
		if (nb < new_nb) { /* expand */
			T *new_keys = (T*)std::realloc(keys, new_nb * sizeof(T));
			if (!new_keys) { std::free(new_used); return -1; }
			keys = new_keys;
		} /* otherwise shrink */
		new_mask = new_nb - 1;
		for (j = 0; j != nb; ++j) {
			if (!__kh_used(used, j)) continue;
			T key = keys[j];
			__kh_set_unused(used, j);
			while (1) { /* kick-out process; sort of like in Cuckoo hashing */
				khint_t i;
				i = __kh_h2b(Hash()(key), new_bits);
				while (__kh_used(new_used, i)) i = (i + khint_t(1)) & new_mask;
				__kh_set_used(new_used, i);
				if (i < nb && __kh_used(used, i)) { /* kick out the existing element */
					{ T tmp = keys[i]; keys[i] = key; key = tmp; }
					__kh_set_unused(used, i); /* mark it as deleted in the old hash table */
				} else { /* write the element and jump out of the loop */
					keys[i] = key;
					break;
				}
			}
		}
		if (nb > new_nb) /* shrink the hash table */
			keys = (T*)std::realloc(keys, new_nb * sizeof(T));
		std::free(used); /* free the working space */
		used = new_used, bits = new_bits;
		return 0;
	}

// Assembly:
subq $0x78, %rsp
movq %rdi, 0x68(%rsp)
movl %esi, 0x64(%rsp)
movq 0x68(%rsp), %rax
movq %rax, 0x18(%rsp)
movq $0x0, 0x58(%rsp)
movl $0x0, 0x54(%rsp)
movl 0x64(%rsp), %eax
movl %eax, 0x50(%rsp)
movl 0x50(%rsp), %eax
shrl %eax
movl %eax, 0x50(%rsp)
cmpl $0x0, %eax
je 0x1aac
movl 0x54(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x54(%rsp)
jmp 0x1a90
movl 0x64(%rsp), %eax
movl 0x64(%rsp), %ecx
subl $0x1, %ecx
andl %ecx, %eax
cmpl $0x0, %eax
je 0x1ac9
movl 0x54(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x54(%rsp)
cmpl $0x2, 0x54(%rsp)
jbe 0x1ada
movl 0x54(%rsp), %eax
movl %eax, 0x14(%rsp)
jmp 0x1ae5
movl $0x2, %eax
movl %eax, 0x14(%rsp)
jmp 0x1ae5
movq 0x18(%rsp), %rax
movl 0x14(%rsp), %ecx
movl %ecx, 0x48(%rsp)
movl 0x48(%rsp), %ecx
movl $0x1, %edx
shll %cl, %edx
movl %edx, %ecx
movl %ecx, 0x64(%rsp)
movl 0x4(%rax), %eax
movl 0x64(%rsp), %ecx
shrl %ecx
movl 0x64(%rsp), %edx
shrl $0x2, %edx
addl %edx, %ecx
cmpl %ecx, %eax
jbe 0x1b26
movl $0x0, 0x74(%rsp)
jmp 0x1d77
movl 0x64(%rsp), %edi
callq 0x1e60
movl %eax, %eax
movl %eax, %edi
shlq $0x2, %rdi
callq 0x1090
movq %rax, 0x58(%rsp)
movq 0x58(%rsp), %rax
movq %rax, 0x8(%rsp)
movl 0x64(%rsp), %edi
callq 0x1e60
movq 0x8(%rsp), %rdi
movl %eax, %eax
movl %eax, %edx
shlq $0x2, %rdx
xorl %esi, %esi
callq 0x1050
cmpq $0x0, 0x58(%rsp)
jne 0x1b7d
movl $0xffffffff, 0x74(%rsp) # imm = 0xFFFFFFFF
jmp 0x1d77
movq 0x18(%rsp), %rdi
callq 0x1800
movl %eax, 0x4c(%rsp)
movl 0x4c(%rsp), %eax
cmpl 0x64(%rsp), %eax
jae 0x1bdf
movq 0x18(%rsp), %rax
movq 0x10(%rax), %rdi
movl 0x64(%rsp), %eax
movl %eax, %esi
shlq $0x3, %rsi
callq 0x10c0
movq %rax, 0x38(%rsp)
cmpq $0x0, 0x38(%rsp)
jne 0x1bd1
movq 0x58(%rsp), %rdi
callq 0x1070
movl $0xffffffff, 0x74(%rsp) # imm = 0xFFFFFFFF
jmp 0x1d77
movq 0x18(%rsp), %rax
movq 0x38(%rsp), %rcx
movq %rcx, 0x10(%rax)
movl 0x64(%rsp), %eax
subl $0x1, %eax
movl %eax, 0x44(%rsp)
movl $0x0, 0x54(%rsp)
movl 0x54(%rsp), %eax
cmpl 0x4c(%rsp), %eax
je 0x1d1f
movq 0x18(%rsp), %rax
movq 0x8(%rax), %rdi
movl 0x54(%rsp), %esi
callq 0x1dd0
cmpl $0x0, %eax
jne 0x1c1c
jmp 0x1d0f
movq 0x18(%rsp), %rax
movq 0x10(%rax), %rcx
movl 0x54(%rsp), %edx
movq (%rcx,%rdx,8), %rcx
movq %rcx, 0x30(%rsp)
movq 0x8(%rax), %rdi
movl 0x54(%rsp), %esi
callq 0x1e90
leaq 0x2b(%rsp), %rdi
leaq 0x30(%rsp), %rsi
callq 0x1da0
movl %eax, %edi
movl 0x48(%rsp), %esi
callq 0x1d80
movl %eax, 0x2c(%rsp)
movq 0x58(%rsp), %rdi
movl 0x2c(%rsp), %esi
callq 0x1dd0
cmpl $0x0, %eax
je 0x1c81
movl 0x2c(%rsp), %eax
addl $0x1, %eax
andl 0x44(%rsp), %eax
movl %eax, 0x2c(%rsp)
jmp 0x1c5d
movq 0x58(%rsp), %rdi
movl 0x2c(%rsp), %esi
callq 0x1e30
movl 0x2c(%rsp), %eax
cmpl 0x4c(%rsp), %eax
jae 0x1cf0
movq 0x18(%rsp), %rax
movq 0x8(%rax), %rdi
movl 0x2c(%rsp), %esi
callq 0x1dd0
cmpl $0x0, %eax
je 0x1cf0
movq 0x18(%rsp), %rax
movq 0x10(%rax), %rcx
movl 0x2c(%rsp), %edx
movq (%rcx,%rdx,8), %rcx
movq %rcx, 0x20(%rsp)
movq 0x10(%rax), %rcx
movl 0x2c(%rsp), %edx
movq 0x30(%rsp), %rsi
movq %rsi, (%rcx,%rdx,8)
movq 0x20(%rsp), %rcx
movq %rcx, 0x30(%rsp)
movq 0x8(%rax), %rdi
movl 0x2c(%rsp), %esi
callq 0x1e90
jmp 0x1d08
movq 0x18(%rsp), %rax
movq 0x10(%rax), %rax
movl 0x2c(%rsp), %ecx
movq 0x30(%rsp), %rdx
movq %rdx, (%rax,%rcx,8)
jmp 0x1d0d
jmp 0x1c3f
jmp 0x1d0f
movl 0x54(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x54(%rsp)
jmp 0x1bf2
movl 0x4c(%rsp), %eax
cmpl 0x64(%rsp), %eax
jbe 0x1d4d
movq 0x18(%rsp), %rax
movq 0x10(%rax), %rdi
movl 0x64(%rsp), %eax
movl %eax, %esi
shlq $0x3, %rsi
callq 0x10c0
movq %rax, %rcx
movq 0x18(%rsp), %rax
movq %rcx, 0x10(%rax)
movq 0x18(%rsp), %rax
movq 0x8(%rax), %rdi
callq 0x1070
movq 0x18(%rsp), %rax
movq 0x58(%rsp), %rcx
movq %rcx, 0x8(%rax)
movl 0x48(%rsp), %ecx
movl %ecx, (%rax)
movl $0x0, 0x74(%rsp)
movl 0x74(%rsp), %eax
addq $0x78, %rsp
retq