// File: /workspace/github_c_makefile_star2_O2/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 0x274ba
movq %rdi, %r12
movl %eax, %ecx
shrl $0xf, %ecx
andl $-0x2, %ecx
cmpl %ecx, 0x18(%rdi)
jb 0x274ba
movq %rsi, %r14
leaq 0x8(%r12), %rbx
xorl %ebp, %ebp
movl $0x30000, %ecx          # imm = 0x30000
movq %r12, %r15
xorl %r13d, %r13d
movq (%rbx), %rbx
movq (%r15), %r15
shrl $0x10, %eax
cmpl %eax, %ebp
jae 0x2744c
testq %r15, %r15
je 0x27407
movl 0x1c(%r15), %eax
andl %ecx, %eax
cmpl $0x20000, %eax          # imm = 0x20000
jne 0x27407
movq %r15, %rdi
callq 0x2732d
movl $0x30000, %ecx          # imm = 0x30000
testq %rbx, %rbx
je 0x27425
movl 0x1c(%rbx), %eax
andl %ecx, %eax
cmpl $0x20000, %eax          # imm = 0x20000
jne 0x27425
movq %rbx, %rdi
callq 0x2732d
movl $0x30000, %ecx          # imm = 0x30000
cmpq %rbx, %r15
je 0x274ba
cmpq %r14, %rbx
pushq $0x1
popq %rax
cmovel %eax, %r13d
cmpq %r14, %r15
cmovel %eax, %r13d
addq $0x8, %r15
movl 0x1c(%r12), %eax
incl %ebp
jmp 0x273db
testq %r14, %r14
je 0x2746e
testl %r13d, %r13d
jne 0x2746e
movl $0x30000, %eax          # imm = 0x30000
andl 0x1c(%r14), %eax
cmpl $0x10000, %eax          # imm = 0x10000
jne 0x2746e
movq %r14, %rdi
callq 0x272ac
cmpl $0x2, %ebp
jb 0x274ba
testq %r15, %r15
je 0x27490
movl $0x30000, %eax          # imm = 0x30000
andl 0x1c(%r15), %eax
cmpl $0x10000, %eax          # imm = 0x10000
jne 0x27490
movq %r15, %rdi
callq 0x272ac
testq %rbx, %rbx
je 0x274ba
movl $0x30000, %eax          # imm = 0x30000
andl 0x1c(%rbx), %eax
cmpl $0x10000, %eax          # imm = 0x10000
jne 0x274ba
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x272ac
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq