// File: /workspace/github_c_makefile_star2_O2/winton[P]redis_parse/hiredis/sds.c
// Function: sdssplitargs
sds *sdssplitargs(char *line, int *argc) {
    char *p = line;
    char *current = NULL;
    char **vector = NULL, **_vector = NULL;

    *argc = 0;
    while(1) {
        /* skip blanks */
        while(*p && isspace(*p)) p++;
        if (*p) {
            /* get a token */
            int inq=0; /* set to 1 if we are in "quotes" */
            int done=0;

            if (current == NULL) {
                current = sdsempty();
                if (current == NULL) goto err;
            }

            while(!done) {
                if (inq) {
                    if (*p == '\\' && *(p+1)) {
                        char c;

                        p++;
                        switch(*p) {
                        case 'n': c = '\n'; break;
                        case 'r': c = '\r'; break;
                        case 't': c = '\t'; break;
                        case 'b': c = '\b'; break;
                        case 'a': c = '\a'; break;
                        default: c = *p; break;
                        }
                        current = sdscatlen(current,&c,1);
                    } else if (*p == '"') {
                        /* closing quote must be followed by a space */
                        if (*(p+1) && !isspace(*(p+1))) goto err;
                        done=1;
                    } else if (!*p) {
                        /* unterminated quotes */
                        goto err;
                    } else {
                        current = sdscatlen(current,p,1);
                    }
                } else {
                    switch(*p) {
                    case ' ':
                    case '\n':
                    case '\r':
                    case '\t':
                    case '\0':
                        done=1;
                        break;
                    case '"':
                        inq=1;
                        break;
                    default:
                        current = sdscatlen(current,p,1);
                        break;
                    }
                }
                if (*p) p++;
                if (current == NULL) goto err;
            }
            /* add the token to the vector */
            _vector = realloc(vector,((*argc)+1)*sizeof(char*));
            if (_vector == NULL) goto err;

            vector = _vector;
            vector[*argc] = current;
            (*argc)++;
            current = NULL;
        } else {
            return vector;
        }
    }

err:
    while((*argc)--)
        sdsfree(vector[*argc]);
    if (vector != NULL) free(vector);
    if (current != NULL) sdsfree(current);
    return NULL;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %r14
movq %rdi, %r15
xorl %ebx, %ebx
pushq $0x1
popq %r12
xorl %ecx, %ecx
movl %ecx, (%r14)
movsbq (%r15), %rbp
testq %rbp, %rbp
je 0x501c
callq 0x2470
movq %rax, %r13
movq (%rax), %rax
testb $0x20, 0x1(%rax,%rbp,2)
je 0x4ea2
incq %r15
jmp 0x4e7e
callq 0x2400
testq %rax, %rax
je 0x4fe7
movq %rax, %rbp
xorl %eax, %eax
xorl %ecx, %ecx
testl %ecx, %ecx
jne 0x4fbe
movzbl (%r15), %ecx
testl %eax, %eax
je 0x4eda
cmpl $0x22, %ecx
je 0x4f48
cmpl $0x5c, %ecx
je 0x4f17
testl %ecx, %ecx
jne 0x4f40
jmp 0x4ff6
cmpl $0x22, %ecx
ja 0x4efd
xorl %eax, %eax
movl %ecx, %ecx
movabsq $0x100002601, %rdx      # imm = 0x100002601
btq %rcx, %rdx
jb 0x4f6b
cmpq $0x22, %rcx
je 0x4fa6
movq %rbp, %rdi
movq %r15, %rsi
pushq $0x1
popq %rdx
callq 0x23b0
movq %rax, %rbp
xorl %eax, %eax
xorl %ecx, %ecx
jmp 0x4fab
movzbl 0x1(%r15), %eax
testl %eax, %eax
je 0x4f40
cmpl $0x61, %eax
je 0x4f8b
cmpl $0x62, %eax
je 0x4f70
cmpl $0x74, %eax
je 0x4f7e
cmpl $0x72, %eax
je 0x4f77
cmpl $0x6e, %eax
jne 0x4f85
movb $0xa, 0x7(%rsp)
jmp 0x4f90
movq %rbp, %rdi
movq %r15, %rsi
jmp 0x4f9b
movsbq 0x1(%r15), %rax
testq %rax, %rax
je 0x4f68
movq (%r13), %rcx
testb $0x20, 0x1(%rcx,%rax,2)
movl %r12d, %eax
movl %r12d, %ecx
jne 0x4fab
jmp 0x4ff6
movl %r12d, %eax
movl %r12d, %ecx
jmp 0x4fab
movb $0x8, 0x7(%rsp)
jmp 0x4f90
movb $0xd, 0x7(%rsp)
jmp 0x4f90
movb $0x9, 0x7(%rsp)
jmp 0x4f90
movb %al, 0x7(%rsp)
jmp 0x4f90
movb $0x7, 0x7(%rsp)
incq %r15
movq %rbp, %rdi
leaq 0x7(%rsp), %rsi
pushq $0x1
popq %rdx
callq 0x23b0
movq %rax, %rbp
xorl %ecx, %ecx
movl %r12d, %eax
cmpb $0x1, (%r15)
sbbq $-0x1, %r15
testq %rbp, %rbp
jne 0x4eb7
jmp 0x4fe7
movslq (%r14), %rax
leaq 0x8(,%rax,8), %rsi
movq %rbx, %rdi
callq 0x2350
testq %rax, %rax
je 0x4ff6
movslq (%r14), %rcx
movq %rbp, (%rax,%rcx,8)
incl %ecx
movq %rax, %rbx
jmp 0x4e7b
xorl %ebp, %ebp
jmp 0x4ff6
cltq
movq (%rbx,%rax,8), %rdi
callq 0x2260
movl (%r14), %eax
subl $0x1, %eax
movl %eax, (%r14)
jae 0x4feb
movq %rbx, %rdi
callq 0x2060
testq %rbp, %rbp
je 0x501a
addq $-0x8, %rbp
movq %rbp, %rdi
callq 0x2060
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop