// File: /workspace/github_c_makefile_star2_O2/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 $0x48, %rsp
movq %r8, %rbx
movl %ecx, %r15d
movq %rdx, 0x30(%rsp)
movl %esi, %r14d
movq %rdi, 0x28(%rsp)
pushq $0x28
popq %rdi
callq 0x2300
movq %rax, %rbp
movq %r15, 0x18(%rsp)
testl %r15d, %r15d
setle %al
testl %r14d, %r14d
sets %cl
orb %al, %cl
testq %rbp, %rbp
sete %al
orb %cl, %al
jne 0x4c94
testl %r14d, %r14d
je 0x4c35
movq %rbx, 0x38(%rsp)
movl %r14d, 0x20(%rsp)
movq 0x18(%rsp), %rax
subl %eax, %r14d
incl %r14d
movl %r14d, 0x24(%rsp)
movl %eax, %eax
movq %rax, 0x40(%rsp)
pushq $0x5
popq %r14
xorl %r13d, %r13d
xorl %ecx, %ecx
xorl %r15d, %r15d
movl %ecx, %ebx
movslq %r13d, %r12
cmpl 0x24(%rsp), %r15d
movq %r13, 0x10(%rsp)
jge 0x4c3a
movl %ecx, 0xc(%rsp)
leal 0x2(%r13), %eax
cmpl %eax, %r14d
jge 0x4baf
addl %r14d, %r14d
movslq %r14d, %rsi
shlq $0x3, %rsi
movq %rbp, %rdi
callq 0x2350
movq %rax, %r13
testq %rax, %rax
jne 0x4bb2
jmp 0x4c6a
movq %rbp, %r13
movl %r15d, %edi
cmpl $0x1, 0x18(%rsp)
movq 0x28(%rsp), %rbp
jne 0x4bce
movb (%rbp,%rdi), %al
movq 0x30(%rsp), %rcx
cmpb (%rcx), %al
je 0x4bea
addq %rbp, %rdi
movq 0x30(%rsp), %rsi
movq 0x40(%rsp), %rdx
callq 0x2320
testl %eax, %eax
je 0x4bea
movl 0xc(%rsp), %ecx
jmp 0x4c25
addq %rbp, %rbx
movl %r15d, %eax
subl 0xc(%rsp), %eax
movslq %eax, %rsi
movq %rbx, %rdi
callq 0x22a0
movq %rax, (%r13,%r12,8)
testq %rax, %rax
je 0x4c67
movq 0x10(%rsp), %rax
incl %eax
movq %rax, 0x10(%rsp)
movl %r15d, %ecx
movq 0x18(%rsp), %rax
addl %eax, %ecx
addl %eax, %r15d
decl %r15d
incl %r15d
movq %r13, %rbp
movq 0x10(%rsp), %r13
jmp 0x4b6e
andl $0x0, (%rbx)
jmp 0x4c96
movq 0x28(%rsp), %rdi
addq %rbx, %rdi
movl 0x20(%rsp), %eax
subl %ecx, %eax
movslq %eax, %rsi
callq 0x22a0
movq %rax, (%rbp,%r12,8)
testq %rax, %rax
je 0x4c6a
incl %r13d
movq 0x38(%rsp), %rax
movl %r13d, (%rax)
jmp 0x4c96
movq %r13, %rbp
xorl %ebx, %ebx
movq 0x10(%rsp), %r14
testl %r14d, %r14d
cmovlel %ebx, %r14d
cmpq %rbx, %r14
je 0x4c8c
movq (%rbp,%rbx,8), %rdi
callq 0x2260
incq %rbx
jmp 0x4c78
movq %rbp, %rdi
callq 0x2060
xorl %ebp, %ebp
movq %rbp, %rax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq