// File: /workspace/github_cpp_makefile_star2_O1/zeeev[P]DASVC/bamtools/src/api/internal/io/HttpHeader_p.cpp
// Function: BamTools::Internal::HttpRequestHeader::ParseLine(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, int)
bool HttpRequestHeader::ParseLine(const string& line, int lineNumber) {

    // if not 'request line', just let base class parse
    if ( lineNumber != 0 )
        return HttpHeader::ParseLine(line, lineNumber);

    // fail if empty line
    if ( line.empty() )
        return false;

    // walk through request line, storing positions
    //    GET /path/to/resource HTTP/1.1
    //    ^  ^^                ^^
    const size_t foundMethod = line.find_first_not_of(Constants::SPACE_CHAR); // skip any leading whitespace
    if ( foundMethod == string::npos ) return false;
    const size_t foundFirstSpace = line.find(Constants::SPACE_CHAR, foundMethod+1);
    if ( foundFirstSpace == string::npos ) return false;
    const size_t foundResource = line.find_first_not_of(Constants::SPACE_CHAR, foundFirstSpace+1);
    if ( foundResource == string::npos ) return false;
    const size_t foundSecondSpace = line.find(Constants::SPACE_CHAR, foundResource+1);
    if ( foundSecondSpace == string::npos ) return false;
    const size_t foundVersion= line.find_first_not_of(Constants::SPACE_CHAR, foundSecondSpace+1);
    if ( foundVersion == string::npos ) return false;

    // parse out method & resource
    m_method   = line.substr(foundMethod,   foundFirstSpace  - foundMethod);
    m_resource = line.substr(foundResource, foundSecondSpace - foundResource);

    // parse out version numbers
    const string temp = line.substr(foundVersion);
    if ( (temp.find(Constants::HTTP_STRING) != 0) || (temp.size() != 8) )
        return false;
    const int major = static_cast<int>(temp.at(5) - '0');
    const int minor = static_cast<int>(temp.at(7) - '0');
    SetVersion(major, minor);

    // if we get here, return success
    return true;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rsi, %r14
movq %rdi, %rbx
testl %edx, %edx
je 0x4cc3d
movq %rbx, %rdi
movq %r14, %rsi
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x27a60
cmpq $0x0, 0x8(%r14)
je 0x4cdb1
xorl %r15d, %r15d
movq %r14, %rdi
movl $0x20, %esi
xorl %edx, %edx
callq 0x27440
cmpq $-0x1, %rax
je 0x4cdb4
movq %rax, %r13
leaq 0x1(%rax), %rdx
movq %r14, %rdi
movl $0x20, %esi
callq 0x27f00
cmpq $-0x1, %rax
je 0x4cdb1
movq %rax, %r15
leaq 0x1(%rax), %rdx
movq %r14, %rdi
movl $0x20, %esi
callq 0x27440
cmpq $-0x1, %rax
je 0x4cdb1
movq %rax, %r12
leaq 0x1(%rax), %rdx
movq %r14, %rdi
movl $0x20, %esi
callq 0x27f00
cmpq $-0x1, %rax
je 0x4cdb1
movq %rax, %rbp
leaq 0x1(%rax), %rdx
movq %r14, %rdi
movl $0x20, %esi
callq 0x27440
cmpq $-0x1, %rax
je 0x4cdb1
movq %rax, 0x20(%rsp)
subq %r13, %r15
movq %rsp, %rdi
movq %r14, %rsi
movq %r13, %rdx
movq %r15, %rcx
callq 0x277f0
leaq 0x48(%rbx), %rdi
movq %rsp, %rsi
callq 0x26b80
leaq 0x10(%rsp), %r13
movq -0x10(%r13), %rdi
cmpq %r13, %rdi
je 0x4cd14
callq 0x27560
subq %r12, %rbp
movq %rsp, %r15
movq %r15, %rdi
movq %r14, %rsi
movq %r12, %rdx
movq %rbp, %rcx
callq 0x277f0
leaq 0x68(%rbx), %rdi
movq %r15, %rsi
callq 0x26b80
movq (%rsp), %rdi
cmpq %r13, %rdi
je 0x4cd45
callq 0x27560
movq %rsp, %r15
movq %r15, %rdi
movq %r14, %rsi
movq 0x20(%rsp), %rdx
movq $-0x1, %rcx
callq 0x277f0
movq 0x20c02(%rip), %rsi     # 0x6d968
movq 0x20c03(%rip), %rcx     # 0x6d970
movq %r15, %rdi
xorl %edx, %edx
callq 0x28b00
movq 0x8(%rsp), %rcx
xorq $0x8, %rcx
orq %rcx, %rax
sete %r15b
jne 0x4cda1
movq (%rsp), %rax
movsbl 0x5(%rax), %ecx
addl $-0x30, %ecx
movsbl 0x7(%rax), %eax
addl $-0x30, %eax
movl %ecx, 0x3c(%rbx)
movl %eax, 0x40(%rbx)
movq (%rsp), %rdi
cmpq %r13, %rdi
je 0x4cdb4
callq 0x27560
jmp 0x4cdb4
xorl %r15d, %r15d
movl %r15d, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x4cdc8
movq %rax, %rbx
movq (%rsp), %rdi
cmpq %r13, %rdi
je 0x4cdd9
callq 0x27560
movq %rbx, %rdi
callq 0x28c20
movq %rax, %rbx
leaq 0x10(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
jne 0x4cdd4
jmp 0x4cdd9