// File: /workspace/github_c_makefile_star2_O3/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 %al
testl %edx, %edx
setle %dl
xorl %ecx, %ecx
testb %dl, %al
jne 0x8cfc
movq %rsi, %r14
movq %rdi, %r15
xorl %r12d, %r12d
callq 0x37a0
xorl %esi, %esi
xorl %edx, %edx
movq (%rax), %rcx
leaq 0x1(%r15), %r9
movq %r15, %r8
movq %r9, %r15
movsbq (%r8), %rdi
incq %r8
incq %r9
testb $0x20, 0x1(%rcx,%rdi,2)
jne 0x8c2a
testb %dil, %dil
je 0x8cfa
testq %r14, %r14
je 0x8c71
leaq -0x1(%r8), %rcx
movq %rcx, (%r14,%rsi,8)
movb -0x1(%r8), %dil
cmpb $0x22, %dil
cmovneq %r12, %r8
leaq 0x1(%rsi), %rcx
movq %r8, %rdx
testb %dil, %dil
jne 0x8c75
jmp 0x8cfc
leaq 0x1(%rsi), %rcx
xorl %r8d, %r8d
testl %r8d, %r8d
je 0x8ca0
cmpb $0x22, %dil
setne %r8b
jne 0x8cb7
testq %rdx, %rdx
je 0x8cb7
cmpb $0x0, (%r15)
je 0x8cc8
movq (%rax), %rdi
testb $0x20, 0x1(%rdi)
jne 0x8cc8
xorl %r8d, %r8d
jmp 0x8cb7
cmpb $0x22, %dil
sete %r8b
movq (%rax), %r9
movsbq %dil, %rdi
testb $0x20, 0x1(%r9,%rdi,2)
jne 0x8cd7
movzbl %r8b, %r8d
movb (%r15), %dil
incq %r15
testb %dil, %dil
jne 0x8c78
jmp 0x8cfc
movq %rdx, (%r14,%rsi,8)
cmpb $0x0, -0x1(%r15)
je 0x8cfc
xorl %edx, %edx
jmp 0x8cdc
testq %r14, %r14
je 0x8ce1
movb $0x0, -0x1(%r15)
movq %rcx, %rsi
testq %r14, %r14
je 0x8c20
movq %rcx, %rsi
cmpl %ebx, %ecx
jl 0x8c20
jmp 0x8cfc
movl %esi, %ecx
movl %ecx, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq