// File: zeeev[P]DASVC/bamtools/src/utils/bamtools_fasta.cpp
// Function: BamTools::Fasta::FastaPrivate::GetNameFromHeader(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>&)
bool Fasta::FastaPrivate::GetNameFromHeader(const string& header, string& name) {

    // get rid of the leading greater than sign
    string s = header.substr(1);

    // extract the first non-whitespace segment
    char* pName = (char*)s.data();
    unsigned int nameLen = (unsigned int)s.size();

    unsigned int start = 0;
    while ( (pName[start] == 32) || (pName[start] == 9) || (pName[start] == 10) || (pName[start] == 13) ) {
        start++;
        if ( start == nameLen ) 
            break;
    }

    unsigned int stop  = start;
    if ( stop < nameLen ) {
        while( (pName[stop] != 32) && (pName[stop] != 9) && (pName[stop] != 10) && (pName[stop] != 13) ) {
            stop++;
            if ( stop == nameLen ) 
                break;
        }
    }

    if ( start == stop ) {
        cerr << "FASTA error : could not parse read name from FASTA header" << endl;
        return false;
    }

    name = s.substr(start, stop - start).c_str();
    return true;
}

// Assembly:
subq $0xb8, %rsp
movq %rdi, 0xa8(%rsp)
movq %rsi, 0xa0(%rsp)
movq %rdx, 0x98(%rsp)
movq 0xa0(%rsp), %rsi
leaq 0x78(%rsp), %rdi
movq %rdi, 0x20(%rsp)
movl $0x1, %edx
movq $-0x1, %rcx
callq 0x86750
movq 0x20(%rsp), %rdi
callq 0x86940
movq %rax, 0x28(%rsp)
jmp 0x10a703
movq 0x28(%rsp), %rax
movq %rax, 0x70(%rsp)
leaq 0x78(%rsp), %rdi
callq 0x86500
movq %rax, 0x18(%rsp)
jmp 0x10a71e
movq 0x18(%rsp), %rax
movl %eax, 0x60(%rsp)
movl $0x0, 0x5c(%rsp)
movq 0x70(%rsp), %rax
movl 0x5c(%rsp), %ecx
movsbl (%rax,%rcx), %ecx
movb $0x1, %al
cmpl $0x20, %ecx
movb %al, 0x17(%rsp)
je 0x10a78e
movq 0x70(%rsp), %rax
movl 0x5c(%rsp), %ecx
movsbl (%rax,%rcx), %ecx
movb $0x1, %al
cmpl $0x9, %ecx
movb %al, 0x17(%rsp)
je 0x10a78e
movq 0x70(%rsp), %rax
movl 0x5c(%rsp), %ecx
movsbl (%rax,%rcx), %ecx
movb $0x1, %al
cmpl $0xa, %ecx
movb %al, 0x17(%rsp)
je 0x10a78e
movq 0x70(%rsp), %rax
movl 0x5c(%rsp), %ecx
movsbl (%rax,%rcx), %eax
cmpl $0xd, %eax
sete %al
movb %al, 0x17(%rsp)
movb 0x17(%rsp), %al
testb $0x1, %al
jne 0x10a798
jmp 0x10a7c7
movl 0x5c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x5c(%rsp)
movl 0x5c(%rsp), %eax
cmpl 0x60(%rsp), %eax
jne 0x10a7c2
jmp 0x10a7c7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x68(%rsp)
movl %eax, 0x64(%rsp)
jmp 0x10a948
jmp 0x10a72f
movl 0x5c(%rsp), %eax
movl %eax, 0x58(%rsp)
movl 0x58(%rsp), %eax
cmpl 0x60(%rsp), %eax
jae 0x10a866
jmp 0x10a7df
movq 0x70(%rsp), %rax
movl 0x58(%rsp), %ecx
movsbl (%rax,%rcx), %ecx
xorl %eax, %eax
cmpl $0x20, %ecx
movb %al, 0x16(%rsp)
je 0x10a83e
movq 0x70(%rsp), %rax
movl 0x58(%rsp), %ecx
movsbl (%rax,%rcx), %ecx
xorl %eax, %eax
cmpl $0x9, %ecx
movb %al, 0x16(%rsp)
je 0x10a83e
movq 0x70(%rsp), %rax
movl 0x58(%rsp), %ecx
movsbl (%rax,%rcx), %ecx
xorl %eax, %eax
cmpl $0xa, %ecx
movb %al, 0x16(%rsp)
je 0x10a83e
movq 0x70(%rsp), %rax
movl 0x58(%rsp), %ecx
movsbl (%rax,%rcx), %eax
cmpl $0xd, %eax
setne %al
movb %al, 0x16(%rsp)
movb 0x16(%rsp), %al
testb $0x1, %al
jne 0x10a848
jmp 0x10a864
movl 0x58(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x58(%rsp)
movl 0x58(%rsp), %eax
cmpl 0x60(%rsp), %eax
jne 0x10a85f
jmp 0x10a864
jmp 0x10a7df
jmp 0x10a866
movl 0x5c(%rsp), %eax
cmpl 0x58(%rsp), %eax
jne 0x10a8af
movq 0x5a769(%rip), %rdi     # 0x164fe0
leaq 0x2954e(%rip), %rsi     # 0x133dcc
callq 0x86700
movq %rax, 0x8(%rsp)
jmp 0x10a88a
movq 0x8(%rsp), %rdi
movq 0x5a6da(%rip), %rsi     # 0x164f70
callq 0x86770
jmp 0x10a89d
movb $0x0, 0xb7(%rsp)
movl $0x1, 0x54(%rsp)
jmp 0x10a92d
movl 0x5c(%rsp), %eax
movl %eax, %edx
movl %edx, %ecx
movl 0x58(%rsp), %eax
subl %ecx, %eax
movl %eax, %ecx
leaq 0x30(%rsp), %rdi
leaq 0x78(%rsp), %rsi
callq 0x86750
jmp 0x10a8d0
leaq 0x30(%rsp), %rdi
callq 0x86320
movq %rax, (%rsp)
jmp 0x10a8e0
movq (%rsp), %rsi
movq 0x98(%rsp), %rdi
callq 0x869f0
jmp 0x10a8f3
leaq 0x30(%rsp), %rdi
callq 0x86f68
jmp 0x10a8ff
movb $0x1, 0xb7(%rsp)
movl $0x1, 0x54(%rsp)
jmp 0x10a92d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x68(%rsp)
movl %eax, 0x64(%rsp)
leaq 0x30(%rsp), %rdi
callq 0x86f68
jmp 0x10a92b
jmp 0x10a948
leaq 0x78(%rsp), %rdi
callq 0x86f68
movb 0xb7(%rsp), %al
andb $0x1, %al
addq $0xb8, %rsp
retq
leaq 0x78(%rsp), %rdi
callq 0x86f68
jmp 0x10a954
jmp 0x10a956
movq 0x68(%rsp), %rdi
callq 0x86d80
movq %rax, %rdi
callq 0x91290
nopl (%rax,%rax)