// File: /workspace/github_c_makefile_star2_O3/gplessis[P]dotdeb-redis/src/quicklist.c
// Function: _quicklistCompress
REDIS_STATIC void __quicklistCompress(const quicklist *quicklist,
                                      quicklistNode *node) {
    /* If length is less than our compress depth (from both sides),
     * we can't compress anything. */
    if (!quicklistAllowsCompression(quicklist) ||
        quicklist->len < (unsigned int)(quicklist->compress * 2))
        return;

#if 0
    /* Optimized cases for small depth counts */
    if (quicklist->compress == 1) {
        quicklistNode *h = quicklist->head, *t = quicklist->tail;
        quicklistDecompressNode(h);
        quicklistDecompressNode(t);
        if (h != node && t != node)
            quicklistCompressNode(node);
        return;
    } else if (quicklist->compress == 2) {
        quicklistNode *h = quicklist->head, *hn = h->next, *hnn = hn->next;
        quicklistNode *t = quicklist->tail, *tp = t->prev, *tpp = tp->prev;
        quicklistDecompressNode(h);
        quicklistDecompressNode(hn);
        quicklistDecompressNode(t);
        quicklistDecompressNode(tp);
        if (h != node && hn != node && t != node && tp != node) {
            quicklistCompressNode(node);
        }
        if (hnn != t) {
            quicklistCompressNode(hnn);
        }
        if (tpp != h) {
            quicklistCompressNode(tpp);
        }
        return;
    }
#endif

    /* Iterate until we reach compress depth for both sides of the list.a
     * Note: because we do length checks at the *top* of this function,
     *       we can skip explicit null checks below. Everything exists. */
    quicklistNode *forward = quicklist->head;
    quicklistNode *reverse = quicklist->tail;
    int depth = 0;
    int in_depth = 0;
    while (depth++ < quicklist->compress) {
        quicklistDecompressNode(forward);
        quicklistDecompressNode(reverse);

        if (forward == node || reverse == node)
            in_depth = 1;

        if (forward == reverse)
            return;

        forward = forward->next;
        reverse = reverse->prev;
    }

    if (!in_depth)
        quicklistCompressNode(node);

    if (depth > 2) {
        /* At this point, forward and reverse are one node beyond depth */
        quicklistCompressNode(forward);
        quicklistCompressNode(reverse);
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl 0x1c(%rdi), %eax
cmpl $0x10000, %eax          # imm = 0x10000
jb 0x2b7bf
movq %rdi, %r12
shrl $0xf, %eax
andl $-0x2, %eax
cmpl %eax, 0x18(%rdi)
jae 0x2b7ce
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rsi, %r15
movq (%r12), %r14
movq 0x8(%r12), %rbx
xorl %ebp, %ebp
movl $0x30000, %ecx          # imm = 0x30000
xorl %r13d, %r13d
testq %r14, %r14
je 0x2b803
movl 0x1c(%r14), %eax
andl %ecx, %eax
cmpl $0x20000, %eax          # imm = 0x20000
jne 0x2b803
movq %r14, %rdi
callq 0x2b72e
movl $0x30000, %ecx          # imm = 0x30000
testq %rbx, %rbx
je 0x2b821
movl 0x1c(%rbx), %eax
andl %ecx, %eax
cmpl $0x20000, %eax          # imm = 0x20000
jne 0x2b821
movq %rbx, %rdi
callq 0x2b72e
movl $0x30000, %ecx          # imm = 0x30000
cmpq %rbx, %r14
je 0x2b7bf
cmpq %r15, %rbx
movl $0x1, %eax
cmovel %eax, %r13d
cmpq %r15, %r14
cmovel %eax, %r13d
movq (%rbx), %rbx
movq 0x8(%r14), %r14
movzwl 0x1e(%r12), %eax
incl %ebp
cmpl %eax, %ebp
jb 0x2b7e4
testq %r15, %r15
je 0x2b86e
testl %r13d, %r13d
jne 0x2b86e
movl $0x30000, %eax          # imm = 0x30000
andl 0x1c(%r15), %eax
cmpl $0x10000, %eax          # imm = 0x10000
jne 0x2b86e
movq %r15, %rdi
callq 0x2b6ab
cmpl $0x2, %ebp
jb 0x2b7bf
testq %r14, %r14
je 0x2b894
movl $0x30000, %eax          # imm = 0x30000
andl 0x1c(%r14), %eax
cmpl $0x10000, %eax          # imm = 0x10000
jne 0x2b894
movq %r14, %rdi
callq 0x2b6ab
testq %rbx, %rbx
je 0x2b7bf
movl $0x30000, %eax          # imm = 0x30000
andl 0x1c(%rbx), %eax
cmpl $0x10000, %eax          # imm = 0x10000
jne 0x2b7bf
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x2b6ab