// File: /workspace/github_c_makefile_star2_O0/gplessis[P]dotdeb-redis/src/ziplist.c
// Function: _ziplistCascadeUpdate
unsigned char *__ziplistCascadeUpdate(unsigned char *zl, unsigned char *p) {
    size_t curlen = intrev32ifbe(ZIPLIST_BYTES(zl)), rawlen, rawlensize;
    size_t offset, noffset, extra;
    unsigned char *np;
    zlentry cur, next;

    while (p[0] != ZIP_END) {
        zipEntry(p, &cur);
        rawlen = cur.headersize + cur.len;
        rawlensize = zipPrevEncodeLength(NULL,rawlen);

        /* Abort if there is no next entry. */
        if (p[rawlen] == ZIP_END) break;
        zipEntry(p+rawlen, &next);

        /* Abort when "prevlen" has not changed. */
        if (next.prevrawlen == rawlen) break;

        if (next.prevrawlensize < rawlensize) {
            /* The "prevlen" field of "next" needs more bytes to hold
             * the raw length of "cur". */
            offset = p-zl;
            extra = rawlensize-next.prevrawlensize;
            zl = ziplistResize(zl,curlen+extra);
            p = zl+offset;

            /* Current pointer and offset for next element. */
            np = p+rawlen;
            noffset = np-zl;

            /* Update tail offset when next element is not the tail element. */
            if ((zl+intrev32ifbe(ZIPLIST_TAIL_OFFSET(zl))) != np) {
                ZIPLIST_TAIL_OFFSET(zl) =
                    intrev32ifbe(intrev32ifbe(ZIPLIST_TAIL_OFFSET(zl))+extra);
            }

            /* Move the tail to the back. */
            memmove(np+rawlensize,
                np+next.prevrawlensize,
                curlen-noffset-next.prevrawlensize-1);
            zipPrevEncodeLength(np,rawlen);

            /* Advance the cursor */
            p += rawlen;
            curlen += extra;
        } else {
            if (next.prevrawlensize > rawlensize) {
                /* This would result in shrinking, which we want to avoid.
                 * So, set "rawlen" in the available bytes. */
                zipPrevEncodeLengthForceLarge(p+rawlen,rawlen);
            } else {
                zipPrevEncodeLength(p+rawlen,rawlen);
            }

            /* Stop here, as the raw length of "next" has not changed. */
            break;
        }
    }
    return zl;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x90, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rax
movl (%rax), %eax
movq %rax, -0x18(%rbp)
movq -0x10(%rbp), %rax
movzbl (%rax), %eax
cmpl $0xff, %eax
je 0x408a3
movq -0x10(%rbp), %rdi
leaq -0x68(%rbp), %rsi
callq 0x40400
movl -0x58(%rbp), %eax
addl -0x5c(%rbp), %eax
movl %eax, %eax
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rax
movl %eax, %esi
xorl %eax, %eax
movl %eax, %edi
callq 0x3fe30
movl %eax, %eax
movq %rax, -0x28(%rbp)
movq -0x10(%rbp), %rax
movq -0x20(%rbp), %rcx
movzbl (%rax,%rcx), %eax
cmpl $0xff, %eax
jne 0x40755
jmp 0x408a3
movq -0x10(%rbp), %rdi
addq -0x20(%rbp), %rdi
leaq -0x88(%rbp), %rsi
callq 0x40400
movl -0x84(%rbp), %eax
cmpq -0x20(%rbp), %rax
jne 0x4077a
jmp 0x408a3
movl -0x88(%rbp), %eax
cmpq -0x28(%rbp), %rax
jae 0x40868
movq -0x10(%rbp), %rax
movq -0x8(%rbp), %rcx
subq %rcx, %rax
movq %rax, -0x30(%rbp)
movq -0x28(%rbp), %rax
movl -0x88(%rbp), %ecx
subq %rcx, %rax
movq %rax, -0x40(%rbp)
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rax
addq -0x40(%rbp), %rax
movl %eax, %esi
callq 0x40690
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq -0x30(%rbp), %rax
movq %rax, -0x10(%rbp)
movq -0x10(%rbp), %rax
addq -0x20(%rbp), %rax
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rax
movq -0x8(%rbp), %rcx
subq %rcx, %rax
movq %rax, -0x38(%rbp)
movq -0x8(%rbp), %rax
movq -0x8(%rbp), %rcx
movl 0x4(%rcx), %ecx
addq %rcx, %rax
cmpq -0x48(%rbp), %rax
je 0x40810
movq -0x8(%rbp), %rax
movl 0x4(%rax), %eax
addq -0x40(%rbp), %rax
movl %eax, %ecx
movq -0x8(%rbp), %rax
movl %ecx, 0x4(%rax)
movq -0x48(%rbp), %rdi
addq -0x28(%rbp), %rdi
movq -0x48(%rbp), %rsi
movl -0x88(%rbp), %eax
addq %rax, %rsi
movq -0x18(%rbp), %rdx
subq -0x38(%rbp), %rdx
movl -0x88(%rbp), %eax
subq %rax, %rdx
subq $0x1, %rdx
callq 0x267e0
movq -0x48(%rbp), %rdi
movq -0x20(%rbp), %rax
movl %eax, %esi
callq 0x3fe30
movq -0x20(%rbp), %rax
addq -0x10(%rbp), %rax
movq %rax, -0x10(%rbp)
movq -0x40(%rbp), %rax
addq -0x18(%rbp), %rax
movq %rax, -0x18(%rbp)
jmp 0x4089e
movl -0x88(%rbp), %eax
cmpq -0x28(%rbp), %rax
jbe 0x40889
movq -0x10(%rbp), %rdi
addq -0x20(%rbp), %rdi
movq -0x20(%rbp), %rax
movl %eax, %esi
callq 0x3fea0
jmp 0x4089c
movq -0x10(%rbp), %rdi
addq -0x20(%rbp), %rdi
movq -0x20(%rbp), %rax
movl %eax, %esi
callq 0x3fe30
jmp 0x408a3
jmp 0x406fd
movq -0x8(%rbp), %rax
addq $0x90, %rsp
popq %rbp
retq