// File: /workspace/github_cpp_makefile_star2_O2/aalto-speech[P]ftk/util/str.hh
// Function: str::split(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, char const*, bool, unsigned int)
inline std::vector<std::string>
split(const std::string &str, const char *delims, bool group,
      unsigned int num_fields = 0)
{
    std::vector<std::string> fields;
    size_t begin = 0;
    size_t end = 0;

    fields.clear();
    bool delim_pending = false;
    while (begin < str.length()) {
        // If 'fields' fields was requested and, this is the last field,
        // include the rest.
        if (num_fields > 0 && fields.size() == num_fields - 1) {
            delim_pending = false;
            fields.push_back(str.substr(begin));
            break;
        }

        // Find the string before the next delim
        delim_pending = false;
        while (end < str.length()) {
            if (strchr(delims, str[end])) {
                delim_pending = true;
                break;
            }
            end++;
        }
        fields.push_back(str.substr(begin, end - begin));

        // Eat the delim or group of delims
        end++;
        if (group)
            while (end < str.length() && strchr(delims, str[end]))
                end++;

        begin = end;
    }

    if (delim_pending)
        fields.push_back("");

    return fields;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movl %r8d, %r14d
movl %ecx, -0x44(%rbp)
movq %rdx, %r13
movq %rsi, %rbx
xorps %xmm0, %xmm0
movups %xmm0, (%rdi)
andq $0x0, 0x10(%rdi)
movq %rdi, -0x38(%rbp)
callq 0x7532
movq %r14, -0x80(%rbp)
leal -0x1(%r14), %eax
movq %rax, -0x78(%rbp)
xorl %r12d, %r12d
movq $0x0, -0x50(%rbp)
movq %rbx, -0x40(%rbp)
movq 0x8(%rbx), %r14
cmpq %r14, %r12
jae 0x6f5f
cmpl $0x0, -0x80(%rbp)
je 0x6eb2
movq -0x38(%rbp), %rcx
movq 0x8(%rcx), %rax
subq (%rcx), %rax
sarq $0x5, %rax
cmpq -0x78(%rbp), %rax
je 0x6f88
movq (%rbx), %r15
movq %r12, %rbx
cmpq %rbx, %r14
je 0x6ed4
movsbl (%r15,%rbx), %esi
movq %r13, %rdi
callq 0x4120
testq %rax, %rax
jne 0x6ed9
incq %rbx
jmp 0x6eb8
movq %r14, %r15
jmp 0x6edc
movq %rbx, %r15
cmpq %r14, %rbx
setb %al
movq %rax, -0x50(%rbp)
movq %r15, %rcx
subq %r12, %rcx
leaq -0x70(%rbp), %r14
movq %r14, %rdi
movq -0x40(%rbp), %rbx
movq %rbx, %rsi
movq %r12, %rdx
callq 0x4360
movq -0x38(%rbp), %rdi
movq %r14, %rsi
callq 0x7570
movq %r14, %rdi
callq 0x46b8
incq %r15
movq %r15, %r12
cmpb $0x0, -0x44(%rbp)
je 0x6e86
movq (%rbx), %r14
movq 0x8(%rbx), %rbx
cmpq %r15, %rbx
movq %r15, %r12
cmovaq %rbx, %r12
cmpq %rbx, %r15
jae 0x6f56
movsbl (%r14,%r15), %esi
movq %r13, %rdi
callq 0x4120
testq %rax, %rax
je 0x6f53
incq %r15
jmp 0x6f37
movq %r15, %r12
movq -0x40(%rbp), %rbx
jmp 0x6e86
testb $0x1, -0x50(%rbp)
je 0x6fb0
leaq 0x1c5bb(%rip), %rsi     # 0x23527
leaq -0x70(%rbp), %rdi
leaq -0x29(%rbp), %rdx
callq 0x4140
leaq -0x70(%rbp), %rsi
movq -0x38(%rbp), %rdi
callq 0x7570
jmp 0x6fa7
leaq -0x70(%rbp), %rdi
pushq $-0x1
popq %rcx
movq %rbx, %rsi
movq %r12, %rdx
callq 0x4360
leaq -0x70(%rbp), %rsi
movq -0x38(%rbp), %rdi
callq 0x7570
leaq -0x70(%rbp), %rdi
callq 0x46b8
movq -0x38(%rbp), %rax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x6fcb
jmp 0x6fd9
jmp 0x6fcb
jmp 0x6fd9
movq %rax, %r14
leaq -0x70(%rbp), %rdi
callq 0x46b8
jmp 0x6fdc
movq %rax, %r14
movq -0x38(%rbp), %rdi
callq 0x54b6
movq %r14, %rdi
callq 0x45f0