// File: /workspace/github_cpp_makefile_star2_O2/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 0x33ba0
movl $0xffffffff, %r15d      # imm = 0xFFFFFFFF
cmpq %r15, %r12
cmovlq %r12, %r15
movq %r13, %rdi
movq %r15, %rsi
callq 0x323d0
movq %rsp, %rdi
callq 0x32b70
testq %rax, %rax
je 0x56c8c
movq %rsp, %rdi
callq 0x34220
movq %rax, %r15
movq %rsp, %rdi
callq 0x32b70
movq %r14, %rdi
movq %r15, %rsi
movq %rax, %rdx
callq 0x33150
movq %rax, %r12
jmp 0x56d20
testq %r12, %r12
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
cmoveq %rax, %r15
movq %rsp, %rdi
pushq $0x1
popq %rsi
callq 0x323d0
xorl %r12d, %r12d
movq %rsp, %r13
movq %r13, %rdi
callq 0x32b70
addq $0x10000, %rax          # imm = 0x10000
cmpq %r15, %rax
cmovaeq %r15, %rax
movq %r13, %rdi
movq %rax, %rsi
callq 0x323d0
movq %r13, %rdi
callq 0x34220
movq %rax, %rbp
movq %r13, %rdi
callq 0x32b70
addq %r12, %rbp
subq %r12, %rax
movq %r14, %rdi
movq %rbp, %rsi
movq %rax, %rdx
callq 0x33150
testq %r12, %r12
movl $0x0, %ecx
cmoveq %rax, %rcx
testq %rax, %rax
cmovgq %rax, %rcx
addq %rcx, %r12
cmpq $0x10000, %rax          # imm = 0x10000
jne 0x56d20
leaq -0x1(%r12), %rsi
movq %r13, %rdi
callq 0x351a0
cmpb $0xa, (%rax)
jne 0x56ca9
testq %r12, %r12
jle 0x56d32
movq %rsp, %rdi
movq %r12, %rsi
callq 0x323d0
jmp 0x56d3a
movq %rsp, %rdi
callq 0x31e20
movq %rsp, %rdi
callq 0x31570
movq %rax, %r14
movq %rsp, %rdi
callq 0x32b70
leaq 0x10(%rbx), %rcx
movq %rcx, (%rbx)
addq %r14, %rax
movq %rbx, %rdi
movq %r14, %rsi
movq %rax, %rdx
callq 0x31b10
movq %rsp, %rdi
callq 0x32e40
movq %rbx, %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x56d87
jmp 0x56d87
jmp 0x56d87
jmp 0x56d87
movq %rax, %rbx
movq %rsp, %rdi
callq 0x32e40
movq %rbx, %rdi
callq 0x34ed0
movq %rax, %rdi
callq 0x39b2f