// File: /workspace/github_cpp_makefile_star2_O1/aalto-speech[P]ftk/util/str.hh
// Function: str::split_with_quotes(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, char const*, bool, std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>>*)
inline void
split_with_quotes(std::string *str, const char *delims, bool group,
                  std::vector<std::string> *fields)
{
    enum { NONE, BACKSLASH, SINGLE, DOUBLE } mode = NONE;
    size_t begin = 0;
    size_t src = 0;
    size_t tgt = 0;

    fields->clear();
    while (src < str->length()) {

        // Find the string before the next delim while processing
        // quotes.
        while (src < str->length()) {

            switch ((*str)[src]) {

            case '\\':
                if (mode == NONE)
                    mode = BACKSLASH;
                else
                    (*str)[tgt++] = '\\';
                break;

            case '\'':
                if (mode == NONE)
                    mode = SINGLE;
                else if (mode == SINGLE)
                    mode = NONE;
                else
                    (*str)[tgt++] = '\'';
                break;

            case '"':
                if (mode == NONE)
                    mode = DOUBLE;
                else if (mode == DOUBLE)
                    mode = NONE;
                else
                    (*str)[tgt++] = '"';
                break;

            default:
                (*str)[tgt++] = (*str)[src];
                if (mode == NONE && strchr(delims, (*str)[src])) {
                    src++;
                    tgt--;
                    goto end_of_field;
                }
                break;
            }
            if (mode == BACKSLASH && (*str)[src] != '\\')
                mode = NONE;
            src++;
        }

end_of_field:
        fields->push_back(str->substr(begin, tgt - begin));
        tgt++;

        // Eat the delim or group of delims
        if (group)
            while (src < str->length() && strchr(delims, (*str)[src]))
                src++;
        begin = tgt;
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movl %edx, -0x34(%rbp)
movq %rsi, -0x40(%rbp)
movq %rdi, %rbx
movq %rcx, -0x48(%rbp)
movq %rcx, %rdi
callq 0x82e8
cmpq $0x0, 0x8(%rbx)
je 0x82bc
movq %rbx, %rsi
xorl %ebx, %ebx
xorl %r15d, %r15d
xorl %r13d, %r13d
movq %rsi, -0x30(%rbp)
cmpq 0x8(%rsi), %r13
movq %r15, -0x50(%rbp)
jae 0x8233
movl %ebx, %r12d
movq %r15, %r14
movq (%rsi), %rax
movzbl (%rax,%r13), %ecx
cmpl $0x22, %ecx
je 0x81ab
cmpl $0x27, %ecx
je 0x8199
cmpl $0x5c, %ecx
jne 0x81ba
testl %r12d, %r12d
je 0x81e8
movb $0x5c, (%rax,%r14)
jmp 0x8205
testl %r12d, %r12d
je 0x81ef
cmpl $0x2, %r12d
je 0x81b6
movb $0x27, (%rax,%r14)
jmp 0x8205
testl %r12d, %r12d
je 0x81f6
cmpl $0x3, %r12d
jne 0x8200
xorl %ebx, %ebx
jmp 0x81fb
leaq 0x1(%r14), %r15
movb %cl, (%rax,%r14)
testl %r12d, %r12d
jne 0x820b
movq (%rsi), %rax
movsbl (%rax,%r13), %esi
movq -0x40(%rbp), %rdi
callq 0x4130
movq -0x30(%rbp), %rsi
xorl %ebx, %ebx
testq %rax, %rax
je 0x820e
jmp 0x82ae
movl $0x1, %ebx
jmp 0x81fb
movl $0x2, %ebx
jmp 0x81fb
movl $0x3, %ebx
movq %r14, %r15
jmp 0x820e
movb $0x22, (%rax,%r14)
incq %r14
movq %r14, %r15
movl %r12d, %ebx
cmpl $0x1, %ebx
jne 0x8220
movq (%rsi), %rax
xorl %ebx, %ebx
cmpb $0x5c, (%rax,%r13)
sete %bl
incq %r13
movl %ebx, %r12d
movq %r15, %r14
cmpq 0x8(%rsi), %r13
jb 0x8176
movq %r15, %rcx
movq -0x50(%rbp), %rdx
subq %rdx, %rcx
leaq -0x70(%rbp), %r14
movq %r14, %rdi
callq 0x43b0
movq -0x48(%rbp), %rdi
movq %r14, %rsi
callq 0x832e
movq -0x70(%rbp), %rdi
leaq -0x60(%rbp), %rax
cmpq %rax, %rdi
je 0x8267
callq 0x4350
cmpb $0x0, -0x34(%rbp)
je 0x829b
movq -0x30(%rbp), %rsi
movq 0x8(%rsi), %r14
cmpq %r14, %r13
jae 0x829f
movq (%rsi), %r12
movsbl (%r12,%r13), %esi
movq -0x40(%rbp), %rdi
callq 0x4130
testq %rax, %rax
je 0x829b
incq %r13
cmpq %r13, %r14
jne 0x827d
movq %r14, %r13
movq -0x30(%rbp), %rsi
incq %r15
cmpq 0x8(%rsi), %r13
jb 0x8162
jmp 0x82bc
incq %r13
movq %r14, %r15
movl %r12d, %ebx
jmp 0x8233
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
movq -0x70(%rbp), %rdi
leaq -0x60(%rbp), %rax
cmpq %rax, %rdi
je 0x82e0
callq 0x4350
movq %rbx, %rdi
callq 0x4650