// File: /workspace/github_c_makefile_star2_O2/JimKent[P]linearSat/lib/common.c
// Function: chopByWhiteRespectDoubleQuotes
int chopByWhiteRespectDoubleQuotes(char *in, char *outArray[], int outSize)
/* Like chopString, but specialized for white space separators.
 * Further, any doubleQuotes (") are respected.
 * If doubleQuote is encloses whole string, then they are removed:
 *   "Fred and Ethyl" results in word [Fred and Ethyl]
 * If doubleQuotes exist inside string they are retained:
 *   Fred" and Ethyl" results in word [Fred" and Ethyl"]
 * Special note "" is a valid, though empty word. */
{
int recordCount = 0;
char c;
char *quoteBegins = NULL;
boolean quoting = FALSE;
for (;;)
    {
    if (outArray != NULL && recordCount >= outSize)
        break;

    /* Skip initial separators. */
    while (isspace(*in)) ++in;
    if (*in == 0)
        break;

    /* Store start of word and look for end of word. */
    if (outArray != NULL)
        {
        outArray[recordCount] = in;
        if ((*in == '"'))
            quoteBegins = (in+1);
        else
            quoteBegins = NULL;
        }
    recordCount += 1;
    quoting = FALSE;
    for (;;)
        {
        if ((c = *in) == 0)
            break;
        if (quoting)
            {
            if (c == '"')
                {
                quoting = FALSE;
                if (quoteBegins != NULL) // implies out array
                    {
                    if ((c = *(in+1) == 0 )|| isspace(c)) // whole word is quoted.
                        {
                        outArray[recordCount-1] = quoteBegins; // Fix beginning of word
                        quoteBegins = NULL;
                        break;
                        }
                    }
                }
            }
        else
            {
            quoting = (c == '"');
            if (isspace(c))
                break;
            }
        ++in;
        }
    if (*in == 0)
        break;

    /* Tag end of word with zero. */
    if (outArray != NULL)
        *in = 0;
    /* And skip over the zero. */
    in += 1;
    }
return recordCount;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %rbx
movq %rdi, %r14
movslq %edx, %r12
xorl %r13d, %r13d
xorl %r15d, %r15d
xorl %ebp, %ebp
testq %rbx, %rbx
sete %al
cmpq %r12, %r15
setl %cl
orb %al, %cl
cmpb $0x1, %cl
jne 0x81e0
callq 0x37a0
movq (%rax), %rsi
leaq 0x1(%r14), %rdi
movq %r14, %rcx
movq %rdi, %r14
movsbq (%rcx), %rdx
incq %rcx
incq %rdi
testb $0x20, 0x1(%rsi,%rdx,2)
jne 0x812f
testb %dl, %dl
je 0x81e0
testq %rbx, %rbx
je 0x8165
leaq -0x1(%rcx), %rdx
movq %rdx, (%rbx,%r15,8)
movb -0x1(%rcx), %dl
cmpb $0x22, %dl
cmovneq %r13, %rcx
movq %rcx, %rbp
leaq 0x1(%r15), %rcx
xorl %esi, %esi
testb %dl, %dl
je 0x81dd
testl %esi, %esi
je 0x8194
cmpb $0x22, %dl
setne %sil
jne 0x81a9
testq %rbp, %rbp
je 0x81a9
cmpb $0x0, (%r14)
je 0x81b5
movq (%rax), %rdx
testb $0x20, 0x1(%rdx)
jne 0x81b5
xorl %esi, %esi
jmp 0x81a9
cmpb $0x22, %dl
sete %sil
movq (%rax), %rdi
movsbq %dl, %rdx
testb $0x20, 0x1(%rdi,%rdx,2)
jne 0x81c4
movzbl %sil, %esi
movb (%r14), %dl
incq %r14
jmp 0x816b
movq %rbp, (%rbx,%r15,8)
cmpb $0x0, -0x1(%r14)
je 0x81dd
xorl %ebp, %ebp
jmp 0x81d0
movq %rcx, %r15
testq %rbx, %rbx
je 0x8109
movb $0x0, -0x1(%r14)
movq %rcx, %r15
jmp 0x8109
movq %rcx, %r15
movl %r15d, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq