// File: TTLIUJJ[P]acker_redis/dict.cpp
// Function: dictRehash(dict*, int)
int dictRehash(dict *d, int n)
{
	int empty_visits = n * 10;
	if (!dictIsRehashing(d))
		return 0;
	
	while (n-- && d->ht[0].used != 0) {
		dictEntry *de, *nextde;

		assert(d->ht[0].size > (unsigned long)d->rehashidx);
		while (d->ht[0].table[d->rehashidx] == NULL) {
			++d->rehashidx;
			if (--empty_visits == 0)
				return 1;
		}
		de = d->ht[0].table[d->rehashidx];
		while (de) {
			unsigned int h;
			nextde = de->next;

			h = dictHashKey(d, de->key) & d->ht[1].size_mask;
			de->next = d->ht[1].table[h];
			d->ht[1].table[h] = de;
			--d->ht[0].used;
			++d->ht[1].used;
			de = nextde;
		}
		d->ht[0].table[d->rehashidx] = NULL;
		++d->rehashidx;
	}
	if (d->ht[0].used == 0) {
		zfree(d->ht[0].table);
		d->ht[0] = d->ht[1];
		_dictReset(&d->ht[1]);
		d->rehashidx = -1;
		return 0;
	}

	return 1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
imull $0xa, -0x14(%rbp), %eax
movl %eax, -0x18(%rbp)
movq -0x10(%rbp), %rax
cmpl $-0x1, 0x50(%rax)
jne 0x37bc
movl $0x0, -0x4(%rbp)
jmp 0x39a2
jmp 0x37be
movl -0x14(%rbp), %ecx
movl %ecx, %eax
addl $-0x1, %eax
movl %eax, -0x14(%rbp)
xorl %eax, %eax
cmpl $0x0, %ecx
movb %al, -0x2d(%rbp)
je 0x37e2
movq -0x10(%rbp), %rax
cmpq $0x0, 0x18(%rax)
setne %al
movb %al, -0x2d(%rbp)
movb -0x2d(%rbp), %al
testb $0x1, %al
jne 0x37ee
jmp 0x3936
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rax
movq -0x10(%rbp), %rcx
movslq 0x50(%rcx), %rcx
cmpq %rcx, %rax
jbe 0x3805
jmp 0x3824
leaq 0x3a3e(%rip), %rdi      # 0x724a
leaq 0x3a63(%rip), %rsi      # 0x7276
movl $0xbb, %edx
leaq 0x3a60(%rip), %rcx      # 0x727f
callq 0x1100
jmp 0x3826
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x10(%rbp), %rcx
movslq 0x50(%rcx), %rcx
cmpq $0x0, (%rax,%rcx,8)
jne 0x3866
movq -0x10(%rbp), %rax
movl 0x50(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x50(%rax)
movl -0x18(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x18(%rbp)
cmpl $0x0, %eax
jne 0x3864
movl $0x1, -0x4(%rbp)
jmp 0x39a2
jmp 0x3826
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x10(%rbp), %rcx
movslq 0x50(%rcx), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
je 0x390c
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x28(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq (%rax), %rax
movq -0x20(%rbp), %rcx
movq (%rcx), %rdi
callq *%rax
movl %eax, %eax
movq -0x10(%rbp), %rcx
andq 0x48(%rcx), %rax
movl %eax, -0x2c(%rbp)
movq -0x10(%rbp), %rax
movq 0x30(%rax), %rax
movl -0x2c(%rbp), %ecx
movq (%rax,%rcx,8), %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x20(%rbp), %rdx
movq -0x10(%rbp), %rax
movq 0x30(%rax), %rax
movl -0x2c(%rbp), %ecx
movq %rdx, (%rax,%rcx,8)
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rcx
addq $-0x1, %rcx
movq %rcx, 0x18(%rax)
movq -0x10(%rbp), %rax
movq 0x38(%rax), %rcx
addq $0x1, %rcx
movq %rcx, 0x38(%rax)
movq -0x28(%rbp), %rax
movq %rax, -0x20(%rbp)
jmp 0x387e
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x10(%rbp), %rcx
movslq 0x50(%rcx), %rcx
movq $0x0, (%rax,%rcx,8)
movq -0x10(%rbp), %rax
movl 0x50(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x50(%rax)
jmp 0x37be
movq -0x10(%rbp), %rax
cmpq $0x0, 0x18(%rax)
jne 0x399b
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rdi
callq 0x5a10
movq -0x10(%rbp), %rcx
movq -0x10(%rbp), %rax
movq 0x30(%rcx), %rdx
movq %rdx, 0x10(%rax)
movq 0x38(%rcx), %rdx
movq %rdx, 0x18(%rax)
movq 0x40(%rcx), %rdx
movq %rdx, 0x20(%rax)
movq 0x48(%rcx), %rcx
movq %rcx, 0x28(%rax)
movq -0x10(%rbp), %rdi
addq $0x10, %rdi
addq $0x20, %rdi
callq 0x3d00
movq -0x10(%rbp), %rax
movl $0xffffffff, 0x50(%rax) # imm = 0xFFFFFFFF
movl $0x0, -0x4(%rbp)
jmp 0x39a2
movl $0x1, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x30, %rsp
popq %rbp
retq
nopl (%rax,%rax)