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

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

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

    // walk through status line, storing positions
    //    HTTP/1.1 200 OK
    //    ^       ^^  ^^

    const size_t foundVersion = line.find_first_not_of(Constants::SPACE_CHAR); // skip any leading whitespace
    if ( foundVersion == string::npos ) return false;
    const size_t foundFirstSpace = line.find(Constants::SPACE_CHAR, foundVersion+1);
    if ( foundFirstSpace == string::npos ) return false;
    const size_t foundStatusCode = line.find_first_not_of(Constants::SPACE_CHAR, foundFirstSpace+1);
    if ( foundStatusCode == string::npos ) return false;
    const size_t foundSecondSpace = line.find(Constants::SPACE_CHAR, foundStatusCode+1);
    if ( foundSecondSpace == string::npos ) return false;
    const size_t foundReason= line.find_first_not_of(Constants::SPACE_CHAR, foundSecondSpace+1);
    if ( foundReason == string::npos ) return false;

    // parse version numbers
    string temp = line.substr(foundVersion, foundFirstSpace - 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);

    // parse status code
    temp = line.substr(foundStatusCode, foundSecondSpace - foundStatusCode);
    if ( temp.size() != 3 ) return false;
    m_statusCode = atoi( temp.c_str() );

    // reason phrase should be everything else left
    m_reason = line.substr(foundReason);

    // 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, 0x40(%rsp)
cmpl $0x0, 0xec(%rsp)
je 0xd959c
movq 0x40(%rsp), %rdi
movq 0xf0(%rsp), %rsi
movl 0xec(%rsp), %edx
callq 0x776d0
andb $0x1, %al
movb %al, 0x107(%rsp)
jmp 0xd9962
movq 0xf0(%rsp), %rdi
callq 0x7aba0
testb $0x1, %al
jne 0xd95af
jmp 0xd95bc
movb $0x0, 0x107(%rsp)
jmp 0xd9962
movq 0xf0(%rsp), %rdi
movl $0x20, %esi
xorl %eax, %eax
movl %eax, %edx
callq 0x75fb0
movq %rax, 0xe0(%rsp)
cmpq $-0x1, 0xe0(%rsp)
jne 0xd95f2
movb $0x0, 0x107(%rsp)
jmp 0xd9962
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 0xd9630
movb $0x0, 0x107(%rsp)
jmp 0xd9962
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 0xd966e
movb $0x0, 0x107(%rsp)
jmp 0xd9962
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 0xd96ac
movb $0x0, 0x107(%rsp)
jmp 0xd9962
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 0xd96ea
movb $0x0, 0x107(%rsp)
jmp 0xd9962
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 0x30(%rsp), %rdi
leaq 0x3f77d(%rip), %rsi     # 0x118ea0
xorl %eax, %eax
movl %eax, %edx
callq 0x7cb90
movq %rax, 0x38(%rsp)
jmp 0xd9733
movq 0x38(%rsp), %rax
cmpq $0x0, %rax
jne 0xd975d
leaq 0xa0(%rsp), %rdi
callq 0x74cd0
movq %rax, 0x28(%rsp)
jmp 0xd9752
movq 0x28(%rsp), %rax
cmpq $0x8, %rax
je 0xd978e
movb $0x0, 0x107(%rsp)
movl $0x1, 0x90(%rsp)
jmp 0xd9942
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x98(%rsp)
movl %eax, 0x94(%rsp)
jmp 0xd9951
leaq 0xa0(%rsp), %rdi
movl $0x5, %esi
callq 0x7c610
movq %rax, 0x20(%rsp)
jmp 0xd97a7
movq 0x20(%rsp), %rax
movsbl (%rax), %eax
addl $-0x30, %eax
movl %eax, 0x8c(%rsp)
leaq 0xa0(%rsp), %rdi
movl $0x7, %esi
callq 0x7c610
movq %rax, 0x18(%rsp)
jmp 0xd97d2
movq 0x40(%rsp), %rdi
movq 0x18(%rsp), %rax
movsbl (%rax), %eax
addl $-0x30, %eax
movl %eax, 0x88(%rsp)
movl 0x8c(%rsp), %esi
movl 0x88(%rsp), %edx
callq 0x728f0
movq 0xf0(%rsp), %rsi
movq 0xd0(%rsp), %rdx
movq 0xc8(%rsp), %rcx
subq %rdx, %rcx
leaq 0x68(%rsp), %rdi
callq 0x76c50
jmp 0xd9823
leaq 0xa0(%rsp), %rdi
leaq 0x68(%rsp), %rsi
callq 0x71240
jmp 0xd9837
leaq 0x68(%rsp), %rdi
callq 0x7cce8
jmp 0xd9843
leaq 0xa0(%rsp), %rdi
callq 0x74cd0
movq %rax, 0x10(%rsp)
jmp 0xd9857
movq 0x10(%rsp), %rax
cmpq $0x3, %rax
je 0xd989f
movb $0x0, 0x107(%rsp)
movl $0x1, 0x90(%rsp)
jmp 0xd9942
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x98(%rsp)
movl %eax, 0x94(%rsp)
leaq 0x68(%rsp), %rdi
callq 0x7cce8
jmp 0xd989a
jmp 0xd9951
leaq 0xa0(%rsp), %rdi
callq 0x73020
movq %rax, 0x8(%rsp)
jmp 0xd98b3
movq 0x8(%rsp), %rdi
callq 0x7a180
movl %eax, %ecx
movq 0x40(%rsp), %rax
movl %ecx, 0x44(%rax)
movq 0xf0(%rsp), %rsi
movq 0xc0(%rsp), %rdx
leaq 0x48(%rsp), %rdi
movq $-0x1, %rcx
callq 0x76c50
jmp 0xd98ea
movq 0x40(%rsp), %rdi
addq $0x48, %rdi
leaq 0x48(%rsp), %rsi
callq 0x71240
jmp 0xd98ff
leaq 0x48(%rsp), %rdi
callq 0x7cce8
jmp 0xd990b
movb $0x1, 0x107(%rsp)
movl $0x1, 0x90(%rsp)
jmp 0xd9942
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x98(%rsp)
movl %eax, 0x94(%rsp)
leaq 0x48(%rsp), %rdi
callq 0x7cce8
jmp 0xd9940
jmp 0xd9951
leaq 0xa0(%rsp), %rdi
callq 0x7cce8
jmp 0xd9962
leaq 0xa0(%rsp), %rdi
callq 0x7cce8
jmp 0xd9960
jmp 0xd9973
movb 0x107(%rsp), %al
andb $0x1, %al
addq $0x108, %rsp            # imm = 0x108
retq
movq 0x98(%rsp), %rdi
callq 0x7b550
movq %rax, %rdi
callq 0x88ef0
nopl (%rax,%rax)