// File: /workspace/github_c_makefile_star2_O2/andyfighting[P]hiredis_timer_cmpt/sds.c
// Function: sdssplitlen
sds *sdssplitlen(const char *s, int len, const char *sep, int seplen, int *count) {
    int elements = 0, slots = 5, start = 0, j;
    sds *tokens;

    if (seplen < 1 || len < 0) return NULL;

    tokens = malloc(sizeof(sds)*slots);
    if (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) goto cleanup;
            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) goto cleanup;
            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) goto cleanup;
    elements++;
    *count = elements;
    return tokens;

cleanup:
    {
        int i;
        for (i = 0; i < elements; i++) sdsfree(tokens[i]);
        free(tokens);
        *count = 0;
        return NULL;
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rdx, 0x38(%rsp)
movq %rcx, 0x18(%rsp)
testl %ecx, %ecx
setle %al
testl %esi, %esi
sets %cl
orb %al, %cl
jne 0x5ede
movq %r8, %rbx
movl %esi, %r14d
movq %rdi, 0x30(%rsp)
pushq $0x28
popq %rdi
callq 0x3350
xorl %r13d, %r13d
testq %rax, %rax
je 0x5ede
movq %rax, %rbp
testl %r14d, %r14d
je 0x5f3e
movq %rbx, 0x28(%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 0x5ee2
movl %ecx, 0xc(%rsp)
leal 0x2(%r13), %eax
cmpl %eax, %r14d
jge 0x5e58
addl %r14d, %r14d
movslq %r14d, %rsi
shlq $0x3, %rsi
movq %rbp, %rdi
callq 0x33b0
movq %rax, %r13
testq %rax, %rax
jne 0x5e5b
jmp 0x5f0a
movq %rbp, %r13
movl %r15d, %edi
cmpl $0x1, 0x18(%rsp)
movq 0x30(%rsp), %rbp
jne 0x5e77
movb (%rbp,%rdi), %al
movq 0x38(%rsp), %rcx
cmpb (%rcx), %al
je 0x5e93
addq %rbp, %rdi
movq 0x38(%rsp), %rsi
movq 0x40(%rsp), %rdx
callq 0x3380
testl %eax, %eax
je 0x5e93
movl 0xc(%rsp), %ecx
jmp 0x5ece
addq %rbp, %rbx
movl %r15d, %eax
subl 0xc(%rsp), %eax
movslq %eax, %rsi
movq %rbx, %rdi
callq 0x32d0
movq %rax, (%r13,%r12,8)
testq %rax, %rax
je 0x5f07
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 0x5e17
xorl %ebp, %ebp
jmp 0x5f41
movq 0x30(%rsp), %rdi
addq %rbx, %rdi
movl 0x20(%rsp), %eax
subl %ecx, %eax
movslq %eax, %rsi
callq 0x32d0
movq %rax, (%rbp,%r12,8)
testq %rax, %rax
je 0x5f0a
incl %r13d
jmp 0x5f39
movq %r13, %rbp
xorl %ebx, %ebx
movq 0x10(%rsp), %r14
testl %r14d, %r14d
cmovlel %ebx, %r14d
cmpq %rbx, %r14
je 0x5f2c
movq (%rbp,%rbx,8), %rdi
callq 0x3290
incq %rbx
jmp 0x5f18
movq %rbp, %rdi
callq 0x3050
xorl %r13d, %r13d
xorl %ebp, %ebp
movq 0x28(%rsp), %rbx
movl %r13d, (%rbx)
movq %rbp, %rax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq