// File: /workspace/github_cpp_makefile_star2_O3/zeeev[P]DASVC/bamtools/src/api/internal/io/TcpSocket_p.cpp
// Function: BamTools::Internal::TcpSocket::ReadLine[abi:cxx11](long)
string TcpSocket::ReadLine(int64_t max) {

    // prep result byte buffer
    ByteArray result;
    size_t bufferMax = ((max > static_cast<int64_t>(UINT_MAX))
                        ? UINT_MAX : static_cast<size_t>(max));
    result.Resize(bufferMax);

    // read data
    int64_t readBytes(0);
    if ( result.Size() == 0 ) {

        if ( bufferMax == 0 )
            bufferMax = UINT_MAX;

        result.Resize(1);

        int64_t readResult;
        do {
            result.Resize( static_cast<size_t>(min(bufferMax, result.Size() + DEFAULT_BUFFER_SIZE)) );
            readResult = ReadLine(result.Data()+readBytes, result.Size()-readBytes);
            if ( readResult > 0 || readBytes == 0 )
                readBytes += readResult;
        } while ( readResult == DEFAULT_BUFFER_SIZE && result[static_cast<size_t>(readBytes-1)] != '\n' );

    } else
        readBytes = ReadLine(result.Data(), result.Size());

    // clean up byte buffer
    if ( readBytes <= 0 )
        result.Clear();
    else
        result.Resize(static_cast<size_t>(readBytes));

    // return byte buffer as string
    return string( result.ConstData(), result.Size() );
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdx, %r12
movq %rsi, %r14
movq %rdi, %rbx
movq %rsp, %r13
movq %r13, %rdi
callq 0x27dd0
movl $0xffffffff, %r15d      # imm = 0xFFFFFFFF
cmpq %r15, %r12
cmovlq %r12, %r15
movq %r13, %rdi
movq %r15, %rsi
callq 0x26d90
movq %rsp, %rdi
callq 0x27270
testq %rax, %rax
je 0x503fe
movq %rsp, %rdi
callq 0x28240
movq %rax, %r15
movq %rsp, %rdi
callq 0x27270
movq %r14, %rdi
movq %r15, %rsi
movq %rax, %rdx
callq 0x276d0
movq %rax, %r12
jmp 0x50494
testq %r12, %r12
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
cmoveq %rax, %r15
movq %rsp, %rdi
movl $0x1, %esi
callq 0x26d90
xorl %r12d, %r12d
movq %rsp, %r13
movq %r13, %rdi
callq 0x27270
addq $0x10000, %rax          # imm = 0x10000
cmpq %r15, %rax
cmovaeq %r15, %rax
movq %r13, %rdi
movq %rax, %rsi
callq 0x26d90
movq %r13, %rdi
callq 0x28240
movq %rax, %rbp
movq %r13, %rdi
callq 0x27270
addq %r12, %rbp
subq %r12, %rax
movq %r14, %rdi
movq %rbp, %rsi
movq %rax, %rdx
callq 0x276d0
testq %r12, %r12
movl $0x0, %ecx
cmoveq %rax, %rcx
testq %rax, %rax
cmovgq %rax, %rcx
addq %rcx, %r12
cmpq $0x10000, %rax          # imm = 0x10000
jne 0x50494
leaq -0x1(%r12), %rsi
movq %r13, %rdi
callq 0x28e30
cmpb $0xa, (%rax)
jne 0x5041d
testq %r12, %r12
jle 0x504a6
movq %rsp, %rdi
movq %r12, %rsi
callq 0x26d90
jmp 0x504ae
movq %rsp, %rdi
callq 0x26980
movq %rsp, %rdi
callq 0x263c0
movq %rax, %r14
movq %rsp, %rdi
callq 0x27270
leaq 0x10(%rbx), %rcx
movq %rcx, (%rbx)
addq %r14, %rax
movq %rbx, %rdi
movq %r14, %rsi
movq %rax, %rdx
callq 0x26750
movq %rsp, %rdi
callq 0x27470
movq %rbx, %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x504fb
jmp 0x504fb
jmp 0x504fb
jmp 0x504fb
movq %rax, %rbx
movq %rsp, %rdi
callq 0x27470
movq %rbx, %rdi
callq 0x28c10
movq %rax, %rdi
callq 0x2f047