// File: /workspace/github_cpp_makefile_star2_O3/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 0x4798d
movq (%rdi), %rax
callq *0x8(%rax)
movq $0x0, 0xa0(%rbx)
movq 0x98(%rbx), %rdi
testq %rdi, %rdi
je 0x4799f
movq (%rdi), %rax
callq *0x8(%rax)
movq 0x30(%rbx), %rdi
callq 0x28c50
movq 0x30(%rbx), %rdi
callq 0x27370
testb %al, %al
jne 0x479c5
movq %rbx, %rdi
callq 0x28830
testb %al, %al
je 0x47b1d
movl $0x88, %edi
callq 0x276b0
movq %rax, %r14
leaq 0x78(%rbx), %rdx
leaq 0x25e9b(%rip), %rsi     # 0x6d878
movq %rax, %rdi
movl $0x1, %ecx
movl $0x1, %r8d
callq 0x260c0
movq %r14, 0x98(%rbx)
leaq 0x38(%rbx), %rdx
leaq 0x25e96(%rip), %rsi     # 0x6d898
movq %r14, %rdi
callq 0x27e90
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 0x47abd
movq 0x30(%rbx), %rdi
callq 0x28c50
movq %rbx, %rdi
callq 0x28f90
testb %al, %al
je 0x47b21
movq 0xa0(%rbx), %rdi
leaq 0x25e97(%rip), %rsi     # 0x6d8f8
callq 0x26170
testb %al, %al
je 0x47aa9
movq 0xa0(%rbx), %rsi
leaq 0x25e80(%rip), %rdx     # 0x6d8f8
movq %rsp, %rdi
callq 0x26270
leaq 0x10(%rsp), %r15
movq -0x10(%r15), %r14
movq %r14, %rdi
callq 0x28640
decl %eax
cltq
movq %rax, 0xb8(%rbx)
cmpq %r15, %r14
je 0x47aa9
movq %r14, %rdi
callq 0x27560
movq 0x30(%rbx), %rdi
callq 0x27700
cmpl $-0x2, %eax
sete %bl
jmp 0x47b8a
leaq 0x10(%rsp), %r14
movq %r14, -0x10(%r14)
leaq 0xf14c(%rip), %rsi      # 0x56c19
leaq 0xf15d(%rip), %rdx      # 0x56c31
movq %rsp, %rdi
callq 0x26750
movq 0x30(%rbx), %rsi
leaq 0x20(%rsp), %rdi
callq 0x27b40
movq %rsp, %rsi
leaq 0x20(%rsp), %rdx
movq %rbx, %rdi
callq 0x288b0
leaq 0x30(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x47b0d
callq 0x27560
movq (%rsp), %rdi
cmpq %r14, %rdi
je 0x47b88
callq 0x27560
jmp 0x47b88
xorl %ebx, %ebx
jmp 0x47b9d
leaq 0x10(%rsp), %r14
movq %r14, -0x10(%r14)
leaq 0xf0e8(%rip), %rsi      # 0x56c19
leaq 0xf0f9(%rip), %rdx      # 0x56c31
movq %rsp, %rdi
callq 0x26750
movq 0x30(%rbx), %rsi
leaq 0x20(%rsp), %rdi
callq 0x27b40
movq %rsp, %rsi
leaq 0x20(%rsp), %rdx
movq %rbx, %rdi
callq 0x288b0
leaq 0x30(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x47b71
callq 0x27560
movq (%rsp), %rdi
cmpq %r14, %rdi
je 0x47b7f
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 0x47b9d
callq 0x27560
movl %ebx, %eax
addq $0x60, %rsp
popq %rbx
popq %r14
popq %r15
retq
jmp 0x47be6
jmp 0x47bb1
jmp 0x47bc9
jmp 0x47be6
movq %rax, %rbx
leaq 0x30(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x47bcc
callq 0x27560
jmp 0x47bcc
movq %rax, %rbx
movq (%rsp), %rdi
cmpq %r14, %rdi
je 0x47be9
callq 0x27560
jmp 0x47be9
jmp 0x47be6
movq %rax, %rbx
movq %r14, %rdi
jmp 0x47bf7
movq %rax, %rbx
leaq 0x50(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x47bfc
callq 0x27560
movq %rbx, %rdi
callq 0x28c10