// File: /workspace/github_c_makefile_star2_O0/gplessis[P]dotdeb-redis/src/dict.c
// Function: dictGetRandomKey
dictEntry *dictGetRandomKey(dict *d)
{
    dictEntry *he, *orighe;
    unsigned int h;
    int listlen, listele;

    if (dictSize(d) == 0) return NULL;
    if (dictIsRehashing(d)) _dictRehashStep(d);
    if (dictIsRehashing(d)) {
        do {
            /* We are sure there are no elements in indexes from 0
             * to rehashidx-1 */
            h = d->rehashidx + (random() % (d->ht[0].size +
                                            d->ht[1].size -
                                            d->rehashidx));
            he = (h >= d->ht[0].size) ? d->ht[1].table[h - d->ht[0].size] :
                                      d->ht[0].table[h];
        } while(he == NULL);
    } else {
        do {
            h = random() & d->ht[0].sizemask;
            he = d->ht[0].table[h];
        } while(he == NULL);
    }

    /* Now we found a non empty bucket, but it is a linked
     * list and we need to get a random element from the list.
     * The only sane way to do so is counting the elements and
     * select a random index. */
    listlen = 0;
    orighe = he;
    while(he) {
        he = he->next;
        listlen++;
    }
    listele = random() % listlen;
    he = orighe;
    while(listele--) he = he->next;
    return he;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x10(%rbp)
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rax
movq -0x10(%rbp), %rcx
addq 0x48(%rcx), %rax
cmpq $0x0, %rax
jne 0x2e6cf
movq $0x0, -0x8(%rbp)
jmp 0x2e81a
movq -0x10(%rbp), %rax
cmpq $-0x1, 0x50(%rax)
je 0x2e6e3
movq -0x10(%rbp), %rdi
callq 0x2da70
movq -0x10(%rbp), %rax
cmpq $-0x1, 0x50(%rax)
je 0x2e77e
jmp 0x2e6f4
movq -0x10(%rbp), %rax
movq 0x50(%rax), %rax
movq %rax, -0x38(%rbp)
callq 0x26a30
movq -0x10(%rbp), %rcx
movq 0x18(%rcx), %rcx
movq -0x10(%rbp), %rdx
addq 0x38(%rdx), %rcx
movq -0x10(%rbp), %rdx
subq 0x50(%rdx), %rcx
xorl %edx, %edx
divq %rcx
movq -0x38(%rbp), %rax
addq %rdx, %rax
movl %eax, -0x24(%rbp)
movl -0x24(%rbp), %eax
movq -0x10(%rbp), %rcx
cmpq 0x18(%rcx), %rax
jb 0x2e756
movq -0x10(%rbp), %rax
movq 0x30(%rax), %rax
movl -0x24(%rbp), %ecx
movq -0x10(%rbp), %rdx
subq 0x18(%rdx), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x40(%rbp)
jmp 0x2e769
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movl -0x24(%rbp), %ecx
movq (%rax,%rcx,8), %rax
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rax
movq %rax, -0x18(%rbp)
cmpq $0x0, -0x18(%rbp)
je 0x2e6f4
jmp 0x2e7ac
jmp 0x2e780
callq 0x26a30
movq -0x10(%rbp), %rcx
andq 0x20(%rcx), %rax
movl %eax, -0x24(%rbp)
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movl -0x24(%rbp), %ecx
movq (%rax,%rcx,8), %rax
movq %rax, -0x18(%rbp)
cmpq $0x0, -0x18(%rbp)
je 0x2e780
jmp 0x2e7ac
movl $0x0, -0x28(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x18(%rbp)
je 0x2e7d9
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x18(%rbp)
movl -0x28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x28(%rbp)
jmp 0x2e7bb
callq 0x26a30
movslq -0x28(%rbp), %rcx
cqto
idivq %rcx
movl %edx, %eax
movl %eax, -0x2c(%rbp)
movq -0x20(%rbp), %rax
movq %rax, -0x18(%rbp)
movl -0x2c(%rbp), %eax
movl %eax, %ecx
addl $-0x1, %ecx
movl %ecx, -0x2c(%rbp)
cmpl $0x0, %eax
je 0x2e812
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x18(%rbp)
jmp 0x2e7f4
movq -0x18(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x40, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)