// File: /workspace/github_c_makefile_star2_O2/gplessis[P]dotdeb-redis/src/ziplist.c
// Function: ziplistFind
unsigned char *ziplistFind(unsigned char *p, unsigned char *vstr, unsigned int vlen, unsigned int skip) {
    int skipcnt = 0;
    unsigned char vencoding = 0;
    long long vll = 0;

    while (p[0] != ZIP_END) {
        unsigned int prevlensize, encoding, lensize, len;
        unsigned char *q;

        ZIP_DECODE_PREVLENSIZE(p, prevlensize);
        ZIP_DECODE_LENGTH(p + prevlensize, encoding, lensize, len);
        q = p + prevlensize + lensize;

        if (skipcnt == 0) {
            /* Compare current entry with specified entry */
            if (ZIP_IS_STR(encoding)) {
                if (len == vlen && memcmp(q, vstr, vlen) == 0) {
                    return p;
                }
            } else {
                /* Find out if the searched field can be encoded. Note that
                 * we do it only the first time, once done vencoding is set
                 * to non-zero and vll is set to the integer value. */
                if (vencoding == 0) {
                    if (!zipTryEncoding(vstr, vlen, &vll, &vencoding)) {
                        /* If the entry can't be encoded we set it to
                         * UCHAR_MAX so that we don't retry again the next
                         * time. */
                        vencoding = UCHAR_MAX;
                    }
                    /* Must be non-zero by now */
                    assert(vencoding);
                }

                /* Compare current entry with specified entry, do it only
                 * if vencoding != UCHAR_MAX because if there is no encoding
                 * possible for the field it can't be a valid integer. */
                if (vencoding != UCHAR_MAX) {
                    long long ll = zipLoadInteger(q, encoding);
                    if (ll == vll) {
                        return p;
                    }
                }
            }

            /* Reset skip count */
            skipcnt = skip;
        } else {
            /* Skip entry */
            skipcnt--;
        }

        /* Move to next entry */
        p = q + len;
    }

    return NULL;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movl %ecx, 0x8(%rsp)
movq %rsi, 0x10(%rsp)
movq %rdi, %r12
leaq 0x18(%rsp), %rax
andq $0x0, (%rax)
leaq 0x7(%rsp), %rax
movb $0x0, (%rax)
movl %edx, 0xc(%rsp)
movl %edx, %eax
movq %rax, 0x20(%rsp)
xorl %ebx, %ebx
xorl %r13d, %r13d
movzbl (%r12), %eax
cmpl $0xfe, %eax
je 0x35dbb
pushq $0x1
popq %rcx
cmpl $0xff, %eax
jne 0x35dbe
jmp 0x35ec2
pushq $0x5
popq %rcx
leaq (%r12,%rcx), %r15
movzbl (%r12,%rcx), %ebp
movl %ebp, %eax
andl $-0x40, %eax
cmpl $0xc0, %ebp
cmovael %ebp, %eax
movzbl %al, %r14d
cmpl $0xbf, %eax
ja 0x35dfe
cmpb $-0x80, %al
je 0x35e6b
cmpl $0x40, %r14d
je 0x35e5a
testl %r14d, %r14d
jne 0x35ed7
andl $0x3f, %ebp
pushq $0x1
jmp 0x35e73
movl %r14d, %edi
callq 0x35008
movl %eax, %ebp
incq %r15
testl %r13d, %r13d
jne 0x35e7c
testb %bl, %bl
jne 0x35e3c
movq 0x10(%rsp), %rdi
movl 0xc(%rsp), %esi
leaq 0x18(%rsp), %rdx
leaq 0x7(%rsp), %rcx
callq 0x351c0
testl %eax, %eax
je 0x35eab
movb 0x7(%rsp), %bl
testb %bl, %bl
je 0x35eec
cmpb $-0x1, %bl
je 0x35eb0
movq %r15, %rdi
movl %r14d, %esi
callq 0x352af
movl 0x8(%rsp), %r13d
cmpq 0x18(%rsp), %rax
jne 0x35eb7
jmp 0x35ec5
andl $0x3f, %ebp
shll $0x8, %ebp
movzbl 0x1(%r15), %eax
orl %eax, %ebp
pushq $0x2
jmp 0x35e73
movl 0x1(%r15), %ebp
bswapl %ebp
pushq $0x5
popq %rax
addq %rax, %r15
testl %r13d, %r13d
je 0x35e81
decl %r13d
jmp 0x35eb7
movl 0xc(%rsp), %r14d
cmpl %r14d, %ebp
jne 0x35eb2
movq %r15, %rdi
movq 0x10(%rsp), %rsi
movq 0x20(%rsp), %rdx
callq 0x266f0
movl %r14d, %ebp
movl 0x8(%rsp), %r13d
testl %eax, %eax
jne 0x35eb7
jmp 0x35ec5
movb $-0x1, 0x7(%rsp)
movb $-0x1, %bl
movl 0x8(%rsp), %r13d
movl %ebp, %r12d
addq %r15, %r12
jmp 0x35da0
xorl %r12d, %r12d
movq %r12, %rax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x7ed71(%rip), %rdi     # 0xb4c4f
leaq 0x7b8eb(%rip), %rsi     # 0xb17d0
movl $0x3c1, %edx            # imm = 0x3C1
jmp 0x35eff
leaq 0x7b8f3(%rip), %rdi     # 0xb17e6
leaq 0x7b8d6(%rip), %rsi     # 0xb17d0
movl $0x3d6, %edx            # imm = 0x3D6
callq 0x57ac8
pushq $0x1
popq %rdi
callq 0x263c0