// File: /workspace/github_cpp_makefile_star2_O1/zeeev[P]DASVC/bamtools/src/api/internal/io/BamHttp_p.cpp
// Function: BamTools::Internal::BamHttp::SendHeadRequest()
bool BamHttp::SendHeadRequest(void) {

    // ensure clean slate
    ClearResponse();
    if ( m_request )
        delete m_request;
    m_socket->ClearBuffer();

    // make sure we're connected
    if ( !EnsureSocketConnection() )
        return false;

    // create request
    m_request = new HttpRequestHeader(HEAD_METHOD, m_filename);
    m_request->SetField(HOST_HEADER, m_hostname);

    // send request
    const string requestHeader = m_request->ToString();
    const size_t headerSize    = requestHeader.size();
    if ( WriteToSocket(requestHeader.c_str(), headerSize) != headerSize ) {
        SetErrorString("BamHttp::SendHeadRequest", m_socket->GetErrorString());
        return false;
    }

    m_socket->ClearBuffer();

    // wait for response from server
    if ( !ReceiveResponse() ) {
        SetErrorString("BamHttp::SendHeadRequest", m_socket->GetErrorString());
        Close();
        return false;
    }
    BT_ASSERT_X(m_response, "BamHttp::SendHeadRequest : null HttpResponse");
    BT_ASSERT_X(m_response->IsValid(), "BamHttp::SendHeadRequest : invalid HttpResponse");

    // get content length if available
    if ( m_response->ContainsKey(CONTENT_LENGTH_HEADER) ) {
        const string contentLengthString = m_response->GetValue(CONTENT_LENGTH_HEADER);
        m_fileEndPosition = atoi( contentLengthString.c_str() ) - 1;
    }

    // return whether we found any errors
    return m_socket->GetError() == TcpSocket::NoError;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x60, %rsp
movq %rdi, %rbx
movq 0xa0(%rdi), %rdi
testq %rdi, %rdi
je 0x479ed
movq (%rdi), %rax
callq *0x8(%rax)
movq $0x0, 0xa0(%rbx)
movq 0x98(%rbx), %rdi
testq %rdi, %rdi
je 0x479ff
movq (%rdi), %rax
callq *0x8(%rax)
movq 0x30(%rbx), %rdi
callq 0x28c60
movq 0x30(%rbx), %rdi
callq 0x27370
testb %al, %al
jne 0x47a25
movq %rbx, %rdi
callq 0x28840
testb %al, %al
je 0x47b7d
movl $0x88, %edi
callq 0x276b0
movq %rax, %r14
leaq 0x78(%rbx), %rdx
leaq 0x25e43(%rip), %rsi     # 0x6d880
movq %rax, %rdi
movl $0x1, %ecx
movl $0x1, %r8d
callq 0x260c0
movq %r14, 0x98(%rbx)
leaq 0x38(%rbx), %rdx
leaq 0x25e3e(%rip), %rsi     # 0x6d8a0
movq %r14, %rdi
callq 0x27ea0
movq 0x98(%rbx), %rsi
movq (%rsi), %rax
leaq 0x40(%rsp), %r14
movq %r14, %rdi
callq *0x10(%rax)
movq (%r14), %rsi
movq 0x8(%r14), %r14
movq %rbx, %rdi
movl %r14d, %edx
callq 0x27010
cmpq %r14, %rax
jne 0x47b1d
movq 0x30(%rbx), %rdi
callq 0x28c60
movq %rbx, %rdi
callq 0x28fa0
testb %al, %al
je 0x47b81
movq 0xa0(%rbx), %rdi
leaq 0x25e3f(%rip), %rsi     # 0x6d900
callq 0x26170
testb %al, %al
je 0x47b09
movq 0xa0(%rbx), %rsi
leaq 0x25e28(%rip), %rdx     # 0x6d900
movq %rsp, %rdi
callq 0x26270
leaq 0x10(%rsp), %r15
movq -0x10(%r15), %r14
movq %r14, %rdi
callq 0x28650
decl %eax
cltq
movq %rax, 0xb8(%rbx)
cmpq %r15, %r14
je 0x47b09
movq %r14, %rdi
callq 0x27560
movq 0x30(%rbx), %rdi
callq 0x27700
cmpl $-0x2, %eax
sete %bl
jmp 0x47bea
leaq 0x10(%rsp), %r14
movq %r14, -0x10(%r14)
leaq 0xf0ec(%rip), %rsi      # 0x56c19
leaq 0xf0fd(%rip), %rdx      # 0x56c31
movq %rsp, %rdi
callq 0x26750
movq 0x30(%rbx), %rsi
leaq 0x20(%rsp), %rdi
callq 0x27b50
movq %rsp, %rsi
leaq 0x20(%rsp), %rdx
movq %rbx, %rdi
callq 0x288c0
leaq 0x30(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x47b6d
callq 0x27560
movq (%rsp), %rdi
cmpq %r14, %rdi
je 0x47be8
callq 0x27560
jmp 0x47be8
xorl %ebx, %ebx
jmp 0x47bfd
leaq 0x10(%rsp), %r14
movq %r14, -0x10(%r14)
leaq 0xf088(%rip), %rsi      # 0x56c19
leaq 0xf099(%rip), %rdx      # 0x56c31
movq %rsp, %rdi
callq 0x26750
movq 0x30(%rbx), %rsi
leaq 0x20(%rsp), %rdi
callq 0x27b50
movq %rsp, %rsi
leaq 0x20(%rsp), %rdx
movq %rbx, %rdi
callq 0x288c0
leaq 0x30(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x47bd1
callq 0x27560
movq (%rsp), %rdi
cmpq %r14, %rdi
je 0x47bdf
callq 0x27560
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x10(%rax)
xorl %ebx, %ebx
leaq 0x50(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x47bfd
callq 0x27560
movl %ebx, %eax
addq $0x60, %rsp
popq %rbx
popq %r14
popq %r15
retq
jmp 0x47c46
jmp 0x47c11
jmp 0x47c29
jmp 0x47c46
movq %rax, %rbx
leaq 0x30(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x47c2c
callq 0x27560
jmp 0x47c2c
movq %rax, %rbx
movq (%rsp), %rdi
cmpq %r14, %rdi
je 0x47c49
callq 0x27560
jmp 0x47c49
jmp 0x47c46
movq %rax, %rbx
movq %r14, %rdi
jmp 0x47c57
movq %rax, %rbx
leaq 0x50(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x47c5c
callq 0x27560
movq %rbx, %rdi
callq 0x28c20