// File: /workspace/github_c_makefile_star2_O1/zhou-yuxin[P]redis-aof-no-cow/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 0x2eabd
movq %rdi, %r12
shrl $0xf, %eax
andl $-0x2, %eax
cmpl %eax, 0x18(%rdi)
jb 0x2eabd
movq %rsi, %r15
movq (%r12), %r14
movq 0x8(%r12), %rbx
xorl %ebp, %ebp
cmpl $0x10000, 0x1c(%r12)    # imm = 0x10000
jae 0x2e9cf
movb $0x1, %al
jmp 0x2ea50
movl $0x30000, %ecx          # imm = 0x30000
xorl %r13d, %r13d
testq %r14, %r14
je 0x2e9f6
movl 0x1c(%r14), %eax
andl %ecx, %eax
cmpl $0x20000, %eax          # imm = 0x20000
jne 0x2e9f6
movq %r14, %rdi
callq 0x2e916
movl $0x30000, %ecx          # imm = 0x30000
testq %rbx, %rbx
je 0x2ea14
movl 0x1c(%rbx), %eax
andl %ecx, %eax
cmpl $0x20000, %eax          # imm = 0x20000
jne 0x2ea14
movq %rbx, %rdi
callq 0x2e916
movl $0x30000, %ecx          # imm = 0x30000
cmpq %rbx, %r14
je 0x2eabd
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 0x2e9d7
testl %r13d, %r13d
sete %al
cmpl $0x2, %ebp
setae %bpl
testq %r15, %r15
je 0x2ea71
testb %al, %al
je 0x2ea71
movl $0x30000, %eax          # imm = 0x30000
andl 0x1c(%r15), %eax
cmpl $0x10000, %eax          # imm = 0x10000
jne 0x2ea71
movq %r15, %rdi
callq 0x2e893
testb %bpl, %bpl
je 0x2eabd
testq %r14, %r14
je 0x2ea93
movl $0x30000, %eax          # imm = 0x30000
andl 0x1c(%r14), %eax
cmpl $0x10000, %eax          # imm = 0x10000
jne 0x2ea93
movq %r14, %rdi
callq 0x2e893
testq %rbx, %rbx
je 0x2eabd
movl $0x30000, %eax          # imm = 0x30000
andl 0x1c(%rbx), %eax
cmpl $0x10000, %eax          # imm = 0x10000
jne 0x2eabd
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x2e893
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq