// File: 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:
subq $0x108, %rsp            # imm = 0x108
movq %rdi, 0xf8(%rsp)
movq %rsi, 0xf0(%rsp)
movl %edx, 0xec(%rsp)
movq 0xf8(%rsp), %rax
movq %rax, 0x38(%rsp)
cmpl $0x0, 0xec(%rsp)
je 0xd8ccc
movq 0x38(%rsp), %rdi
movq 0xf0(%rsp), %rsi
movl 0xec(%rsp), %edx
callq 0x776d0
andb $0x1, %al
movb %al, 0x107(%rsp)
jmp 0xd9019
movq 0xf0(%rsp), %rdi
callq 0x7aba0
testb $0x1, %al
jne 0xd8cdf
jmp 0xd8cec
movb $0x0, 0x107(%rsp)
jmp 0xd9019
movq 0xf0(%rsp), %rdi
movl $0x20, %esi
xorl %eax, %eax
movl %eax, %edx
callq 0x75fb0
movq %rax, 0xe0(%rsp)
cmpq $-0x1, 0xe0(%rsp)
jne 0xd8d22
movb $0x0, 0x107(%rsp)
jmp 0xd9019
movq 0xf0(%rsp), %rdi
movq 0xe0(%rsp), %rdx
addq $0x1, %rdx
movl $0x20, %esi
callq 0x787f0
movq %rax, 0xd8(%rsp)
cmpq $-0x1, 0xd8(%rsp)
jne 0xd8d60
movb $0x0, 0x107(%rsp)
jmp 0xd9019
movq 0xf0(%rsp), %rdi
movq 0xd8(%rsp), %rdx
addq $0x1, %rdx
movl $0x20, %esi
callq 0x75fb0
movq %rax, 0xd0(%rsp)
cmpq $-0x1, 0xd0(%rsp)
jne 0xd8d9e
movb $0x0, 0x107(%rsp)
jmp 0xd9019
movq 0xf0(%rsp), %rdi
movq 0xd0(%rsp), %rdx
addq $0x1, %rdx
movl $0x20, %esi
callq 0x787f0
movq %rax, 0xc8(%rsp)
cmpq $-0x1, 0xc8(%rsp)
jne 0xd8ddc
movb $0x0, 0x107(%rsp)
jmp 0xd9019
movq 0xf0(%rsp), %rdi
movq 0xc8(%rsp), %rdx
addq $0x1, %rdx
movl $0x20, %esi
callq 0x75fb0
movq %rax, 0xc0(%rsp)
cmpq $-0x1, 0xc0(%rsp)
jne 0xd8e1a
movb $0x0, 0x107(%rsp)
jmp 0xd9019
movq 0xf0(%rsp), %rsi
movq 0xe0(%rsp), %rdx
movq 0xd8(%rsp), %rcx
subq %rdx, %rcx
leaq 0xa0(%rsp), %rdi
movq %rdi, 0x30(%rsp)
callq 0x76c50
movq 0x38(%rsp), %rdi
movq 0x30(%rsp), %rsi
addq $0x48, %rdi
callq 0x71240
jmp 0xd8e5c
leaq 0xa0(%rsp), %rdi
callq 0x7cce8
movq 0xf0(%rsp), %rsi
movq 0xd0(%rsp), %rdx
movq 0xc8(%rsp), %rcx
subq %rdx, %rcx
leaq 0x70(%rsp), %rdi
movq %rdi, 0x28(%rsp)
callq 0x76c50
movq 0x38(%rsp), %rdi
movq 0x28(%rsp), %rsi
addq $0x68, %rdi
callq 0x71240
jmp 0xd8ea8
leaq 0x70(%rsp), %rdi
callq 0x7cce8
movq 0xf0(%rsp), %rsi
movq 0xc0(%rsp), %rdx
leaq 0x50(%rsp), %rdi
movq %rdi, 0x18(%rsp)
movq $-0x1, %rcx
callq 0x76c50
movq 0x18(%rsp), %rdi
leaq 0x3ffbc(%rip), %rsi     # 0x118ea0
xorl %eax, %eax
movl %eax, %edx
callq 0x7cb90
movq %rax, 0x20(%rsp)
jmp 0xd8ef4
movq 0x20(%rsp), %rax
cmpq $0x0, %rax
jne 0xd8f1f
leaq 0x50(%rsp), %rdi
callq 0x74cd0
movq %rax, 0x10(%rsp)
jmp 0xd8f10
movq 0x10(%rsp), %rax
cmpq $0x8, %rax
je 0xd8fa1
movb $0x0, 0x107(%rsp)
movl $0x1, 0x4c(%rsp)
jmp 0xd900b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x98(%rsp)
movl %eax, 0x94(%rsp)
leaq 0xa0(%rsp), %rdi
callq 0x7cce8
jmp 0xd8f57
jmp 0xd902a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x98(%rsp)
movl %eax, 0x94(%rsp)
leaq 0x70(%rsp), %rdi
callq 0x7cce8
jmp 0xd8f7c
jmp 0xd902a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x98(%rsp)
movl %eax, 0x94(%rsp)
leaq 0x50(%rsp), %rdi
callq 0x7cce8
jmp 0xd9017
leaq 0x50(%rsp), %rdi
movl $0x5, %esi
callq 0x77cf0
movq %rax, 0x8(%rsp)
jmp 0xd8fb7
movq 0x8(%rsp), %rax
movsbl (%rax), %eax
addl $-0x30, %eax
movl %eax, 0x48(%rsp)
leaq 0x50(%rsp), %rdi
movl $0x7, %esi
callq 0x77cf0
movq %rax, (%rsp)
jmp 0xd8fdb
movq 0x38(%rsp), %rdi
movq (%rsp), %rax
movsbl (%rax), %eax
subl $0x30, %eax
movl %eax, 0x44(%rsp)
movl 0x48(%rsp), %esi
movl 0x44(%rsp), %edx
callq 0x728f0
movb $0x1, 0x107(%rsp)
movl $0x1, 0x4c(%rsp)
leaq 0x50(%rsp), %rdi
callq 0x7cce8
jmp 0xd9019
jmp 0xd902a
movb 0x107(%rsp), %al
andb $0x1, %al
addq $0x108, %rsp            # imm = 0x108
retq
movq 0x98(%rsp), %rdi
callq 0x7b550
movq %rax, %rdi
callq 0x88ef0
nop