// File: /workspace/github_c_makefile_star2_O2/gplessis[P]dotdeb-redis/src/quicklist.c
// Function: quicklistNext
int quicklistNext(quicklistIter *iter, quicklistEntry *entry) {
    initEntry(entry);

    if (!iter) {
        D("Returning because no iter!");
        return 0;
    }

    entry->quicklist = iter->quicklist;
    entry->node = iter->current;

    if (!iter->current) {
        D("Returning because current node is NULL")
        return 0;
    }

    unsigned char *(*nextFn)(unsigned char *, unsigned char *) = NULL;
    int offset_update = 0;

    if (!iter->zi) {
        /* If !zi, use current index. */
        quicklistDecompressNodeForUse(iter->current);
        iter->zi = ziplistIndex(iter->current->zl, iter->offset);
    } else {
        /* else, use existing iterator offset and get prev/next as necessary. */
        if (iter->direction == AL_START_HEAD) {
            nextFn = ziplistNext;
            offset_update = 1;
        } else if (iter->direction == AL_START_TAIL) {
            nextFn = ziplistPrev;
            offset_update = -1;
        }
        iter->zi = nextFn(iter->current->zl, iter->zi);
        iter->offset += offset_update;
    }

    entry->zi = iter->zi;
    entry->offset = iter->offset;

    if (iter->zi) {
        /* Populate value from existing ziplist position */
        ziplistGet(entry->zi, &entry->value, &entry->sz, &entry->longval);
        return 1;
    } else {
        /* We ran out of ziplist entries.
         * Pick next node, update offset, then re-run retrieval. */
        quicklistCompress(iter->quicklist, iter->current);
        if (iter->direction == AL_START_HEAD) {
            /* Forward traversal */
            D("Jumping to start of next node");
            iter->current = iter->current->next;
            iter->offset = 0;
        } else if (iter->direction == AL_START_TAIL) {
            /* Reverse traversal */
            D("Jumping to end of previous node");
            iter->current = iter->current->prev;
            iter->offset = -1;
        }
        iter->zi = NULL;
        return quicklistNext(iter, entry);
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rsi, %r12
movq %rdi, %rbp
leaq 0x18(%rsi), %rax
movq %rax, 0x10(%rsp)
leaq 0x10(%rsi), %rbx
leaq 0x20(%rsi), %rax
movq %rax, 0x8(%rsp)
leaq 0x28(%rsi), %rax
movq %rax, (%rsp)
movabsq $0x75bcd1500000000, %r14 # imm = 0x75BCD1500000000
leaq 0xd721(%rip), %r15      # 0x35b86
xorps %xmm0, %xmm0
movups %xmm0, (%rbx)
movq $-0x75bcd15, 0x20(%r12) # imm = 0xF8A432EB
movups %xmm0, (%r12)
movq %r14, 0x28(%r12)
testq %rbp, %rbp
je 0x28586
movq (%rbp), %rax
movq %rax, (%r12)
movq 0x8(%rbp), %rdi
movq %rdi, 0x8(%r12)
testq %rdi, %rdi
je 0x28586
movq 0x10(%rbp), %rsi
testq %rsi, %rsi
je 0x284de
xorl %r13d, %r13d
cmpl $0x0, 0x20(%rbp)
sete %cl
movq %r15, %rax
jne 0x284c0
leaq 0xd6a0(%rip), %rax      # 0x35b60
movb %cl, %r13b
movq 0x10(%rdi), %rdi
callq *%rax
movq %rax, 0x10(%rbp)
movq 0x18(%rbp), %rcx
leaq (%rcx,%r13,2), %rcx
decq %rcx
movq %rcx, 0x18(%rbp)
jmp 0x28517
movl 0x1c(%rdi), %eax
movl $0x30000, %ecx          # imm = 0x30000
andl %ecx, %eax
cmpl $0x20000, %eax          # imm = 0x20000
jne 0x28503
callq 0x2732d
movq 0x8(%rbp), %rax
orl $0x100000, 0x1c(%rax)   # imm = 0x100000
movq 0x8(%rbp), %rdi
movq 0x10(%rdi), %rdi
movl 0x18(%rbp), %esi
callq 0x35aca
movq %rax, 0x10(%rbp)
movq 0x18(%rbp), %rcx
movq %rax, 0x10(%r12)
movl %ecx, 0x2c(%r12)
testq %rax, %rax
jne 0x2858a
movq 0x8(%rbp), %rsi
movl 0x1c(%rsi), %eax
btl $0x14, %eax
jb 0x2853e
movq (%rbp), %rdi
callq 0x27399
jmp 0x28552
andl $0x30000, %eax          # imm = 0x30000
cmpl $0x10000, %eax          # imm = 0x10000
jne 0x28552
movq %rsi, %rdi
callq 0x272ac
movl 0x20(%rbp), %eax
cmpl $0x1, %eax
je 0x2856a
testl %eax, %eax
jne 0x2857c
movq 0x8(%rbp), %rax
addq $0x8, %rax
xorl %ecx, %ecx
jmp 0x28571
movq 0x8(%rbp), %rax
pushq $-0x1
popq %rcx
movq (%rax), %rax
movq %rax, 0x8(%rbp)
movq %rcx, 0x18(%rbp)
andq $0x0, 0x10(%rbp)
jmp 0x28465
xorl %eax, %eax
jmp 0x285a3
movq %rax, %rdi
movq 0x10(%rsp), %rsi
movq (%rsp), %rdx
movq 0x8(%rsp), %rcx
callq 0x35be8
pushq $0x1
popq %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq