// File: /workspace/github_c_makefile_star2_O1/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 %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movl %edx, %ebx
testq %rsi, %rsi
setne %cl
testl %edx, %edx
setle %dl
xorl %eax, %eax
testb %dl, %cl
jne 0x8ecc
movq %rsi, %r14
movq %rdi, %r15
xorl %r12d, %r12d
callq 0x37a0
movq %rax, %rcx
xorl %eax, %eax
xorl %edx, %edx
movq (%rcx), %rdi
movq %r15, %rsi
movsbq (%rsi), %r8
incq %rsi
testb $0x20, 0x1(%rdi,%r8,2)
jne 0x8e11
testb %r8b, %r8b
je 0x8ecc
leaq -0x1(%rsi), %r15
testq %r14, %r14
je 0x8e41
movq %r15, (%r14,%rax,8)
cmpb $0x22, -0x1(%rsi)
cmovneq %r12, %rsi
movq %rsi, %rdx
movb (%r15), %sil
testb %sil, %sil
je 0x8ea1
xorl %edi, %edi
testl %edi, %edi
je 0x8e72
cmpb $0x22, %sil
setne %dil
jne 0x8e89
testq %rdx, %rdx
je 0x8e89
cmpb $0x0, 0x1(%r15)
je 0x8e9b
movq (%rcx), %rsi
testb $0x20, 0x1(%rsi)
jne 0x8e9b
xorl %edi, %edi
jmp 0x8e89
cmpb $0x22, %sil
sete %dil
movq (%rcx), %r8
movsbq %sil, %rsi
testb $0x20, 0x1(%r8,%rsi,2)
jne 0x8ea1
movzbl %dil, %edi
movb 0x1(%r15), %sil
incq %r15
testb %sil, %sil
jne 0x8e4b
jmp 0x8ea1
movq %rdx, (%r14,%rax,8)
xorl %edx, %edx
incq %rax
cmpb $0x0, (%r15)
je 0x8ecc
testq %r14, %r14
je 0x8eb3
movb $0x0, (%r15)
testq %r14, %r14
sete %sil
incq %r15
cmpl %ebx, %eax
setl %dil
orb %sil, %dil
jne 0x8e0b
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq