// File: /workspace/github_c_makefile_star2_O1/winton[P]redis_parse/hiredis/sds.c
// Function: sdssplitlen
sds *sdssplitlen(char *s, int len, char *sep, int seplen, int *count) {
    int elements = 0, slots = 5, start = 0, j;

    sds *tokens = malloc(sizeof(sds)*slots);
#ifdef SDS_ABORT_ON_OOM
    if (tokens == NULL) sdsOomAbort();
#endif
    if (seplen < 1 || len < 0 || tokens == NULL) return NULL;
    if (len == 0) {
        *count = 0;
        return tokens;
    }
    for (j = 0; j < (len-(seplen-1)); j++) {
        /* make sure there is room for the next element and the final one */
        if (slots < elements+2) {
            sds *newtokens;

            slots *= 2;
            newtokens = realloc(tokens,sizeof(sds)*slots);
            if (newtokens == NULL) {
#ifdef SDS_ABORT_ON_OOM
                sdsOomAbort();
#else
                goto cleanup;
#endif
            }
            tokens = newtokens;
        }
        /* search the separator */
        if ((seplen == 1 && *(s+j) == sep[0]) || (memcmp(s+j,sep,seplen) == 0)) {
            tokens[elements] = sdsnewlen(s+start,j-start);
            if (tokens[elements] == NULL) {
#ifdef SDS_ABORT_ON_OOM
                sdsOomAbort();
#else
                goto cleanup;
#endif
            }
            elements++;
            start = j+seplen;
            j = j+seplen-1; /* skip the separator */
        }
    }
    /* Add the final element. We are sure there is room in the tokens array. */
    tokens[elements] = sdsnewlen(s+start,len-start);
    if (tokens[elements] == NULL) {
#ifdef SDS_ABORT_ON_OOM
                sdsOomAbort();
#else
                goto cleanup;
#endif
    }
    elements++;
    *count = elements;
    return tokens;

#ifndef SDS_ABORT_ON_OOM
cleanup:
    {
        int i;
        for (i = 0; i < elements; i++) sdsfree(tokens[i]);
        free(tokens);
        return NULL;
    }
#endif
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %r8, %r14
movl %ecx, %r12d
movq %rdx, 0x20(%rsp)
movl %esi, %ebp
movq %rdi, %r15
movl $0x28, %edi
callq 0x2300
movq %rax, %rbx
testl %r12d, %r12d
setle %al
testl %ebp, %ebp
sets %cl
orb %al, %cl
testq %rbx, %rbx
sete %al
orb %cl, %al
jne 0x5098
testl %ebp, %ebp
je 0x5022
movq %r15, 0x18(%rsp)
movq %r14, 0x28(%rsp)
movl %ebp, 0x10(%rsp)
subl %r12d, %ebp
incl %ebp
movl %ebp, 0x14(%rsp)
testl %ebp, %ebp
jle 0x502b
movl %r12d, %eax
movq %rax, 0x30(%rsp)
movl $0x5, %r13d
xorl %ebp, %ebp
xorl %r15d, %r15d
xorl %edx, %edx
movq %rdx, 0x8(%rsp)
leal 0x2(%rdx), %eax
cmpl %eax, %r13d
jge 0x4fa3
addl %r13d, %r13d
movslq %r13d, %rsi
shlq $0x3, %rsi
movq %rbx, %rdi
callq 0x2350
testq %rax, %rax
cmovneq %rax, %rbx
je 0x5067
movl %ebp, %edi
movq %r12, %r14
cmpl $0x1, %r12d
movq 0x18(%rsp), %r12
jne 0x4fc0
movb (%r12,%rdi), %al
movq 0x20(%rsp), %rcx
cmpb (%rcx), %al
je 0x4fe0
addq %r12, %rdi
movq 0x20(%rsp), %rsi
movq 0x30(%rsp), %rdx
callq 0x2320
testl %eax, %eax
je 0x4fe0
movq %r14, %r12
movq 0x8(%rsp), %rdx
jmp 0x5014
movl %r15d, %edi
addq %r12, %rdi
movl %ebp, %eax
subl %r15d, %eax
movslq %eax, %rsi
callq 0x22a0
movq 0x8(%rsp), %rdx
movslq %edx, %rcx
movq %rax, (%rbx,%rcx,8)
testq %rax, %rax
je 0x506c
incl %edx
movl %ebp, %r15d
movq %r14, %r12
addl %r12d, %r15d
addl %r14d, %ebp
decl %ebp
incl %ebp
cmpl 0x14(%rsp), %ebp
jl 0x4f77
jmp 0x5030
movl $0x0, (%r14)
jmp 0x509a
xorl %edx, %edx
xorl %r15d, %r15d
movl %r15d, %eax
movq 0x18(%rsp), %rdi
addq %rax, %rdi
movl 0x10(%rsp), %eax
subl %r15d, %eax
movslq %eax, %rsi
movq %rdx, %r14
callq 0x22a0
movq %r14, %rdx
movslq %edx, %rcx
movq %rax, (%rbx,%rcx,8)
testq %rax, %rax
je 0x506c
incl %edx
movq 0x28(%rsp), %rax
movl %edx, (%rax)
jmp 0x509a
movq 0x8(%rsp), %rdx
testl %edx, %edx
jle 0x5090
movl %edx, %r14d
xorl %r15d, %r15d
movq (%rbx,%r15,8), %rdi
testq %rdi, %rdi
je 0x5088
addq $-0x8, %rdi
callq 0x2060
incq %r15
cmpq %r15, %r14
jne 0x5076
movq %rbx, %rdi
callq 0x2060
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq