// File: /workspace/github_cpp_makefile_star2_O3/enbock[P]Warp10Server/ulib/src/Socket.cpp
// Function: u::Socket::read(u::ByteArray*)
int64 u::Socket::read(ByteArray *data)
{
	int64 ret				// ammount of received bytes.
		, len					// maximum of read bytes
	;
	char *buffer;		// read buffer

	if(!isConnected()) return -1;

	if(!hasIncomingData()) return 0;

	// set pointer to end for append
	data->position(data->length());

	lock();
	len = receiveBufferSize;
	buffer = new char[len];

	ret = ::recv(_descriptor, buffer, len, 0);
	unlock();

	if(ret > 0)
	{
		data->writeBytes(buffer, ret);
	}

	delete[] buffer;

	data->position(0); // set pointer to begin

	trace(className()+"::read: Received "+int2string(ret)+" bytes.");
	return ret;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x110, %rsp            # imm = 0x110
movq %rsi, %r15
movq %rdi, %r14
callq 0x410226
movl 0x54(%r14), %ebx
movq %r14, %rdi
callq 0x4101de
cmpl $-0x1, %ebx
je 0x4136b1
movq %r14, %rdi
callq 0x413974
testb %al, %al
je 0x4136bd
movq (%r15), %rax
movq %r15, %rdi
callq *0x38(%rax)
movq (%r15), %rcx
movq %r15, %rdi
movq %rax, %rsi
callq *0x20(%rcx)
movq %r14, %rdi
callq 0x410226
movq 0xc0(%r14), %rbx
movq %rbx, %rdi
callq 0x427e50
movq %rax, %r12
movl 0x34(%r14), %edi
movq %rax, %rsi
movq %rbx, %rdx
xorl %ecx, %ecx
callq 0x560800
movq %rax, %rbx
movq %r14, %rdi
callq 0x4101de
testq %rbx, %rbx
jle 0x41363a
movq %r15, %rdi
movq %r12, %rsi
movq %rbx, %rdx
xorl %ecx, %ecx
callq 0x40af4a
movq %r12, %rdi
callq 0x426e40
movq (%r15), %rax
movq %r15, %rdi
xorl %esi, %esi
callq *0x20(%rax)
movq $0x653c40, %rdi         # imm = 0x653C40
leaq 0x1baa36(%rip), %rsi    # 0x5ce091
movl $0x4, %edx
callq 0x490910
movq (%r14), %rax
leaq 0xb8(%rsp), %rdi
movq %r14, %rsi
callq *0x8(%rax)
leaq 0xf0(%rsp), %rdi
leaq 0x1bb72a(%rip), %rsi    # 0x5cedaf
callq 0x4a24f0
leaq 0x30(%rsp), %r15
movq %r15, -0x10(%r15)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x4136c4
movq %rdx, 0x20(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x30(%rsp)
jmp 0x4136cb
movq $-0x1, %rbx
jmp 0x4138e1
xorl %ebx, %ebx
jmp 0x4138e1
movups (%rcx), %xmm0
movups %xmm0, (%r15)
movq 0x8(%rax), %rdx
movq %rdx, 0x28(%rsp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
leaq 0x60(%rsp), %rdi
movl %ebx, %esi
callq 0x410514
movq 0x20(%rsp), %rcx
movq 0x28(%rsp), %r8
movq 0xa0(%rsp), %rdx
leaq (%rdx,%r8), %rax
movl $0xf, %edi
cmpq %r15, %rcx
je 0x413714
movq 0x30(%rsp), %rdi
leaq 0xa8(%rsp), %r12
movq -0x10(%r12), %rsi
cmpq %rdi, %rax
jbe 0x41373d
movl $0xf, %edi
cmpq %r12, %rsi
je 0x413738
movq 0xa8(%rsp), %rdi
cmpq %rdi, %rax
jbe 0x413749
leaq 0x20(%rsp), %rdi
callq 0x4a23b0
jmp 0x41375a
leaq 0x98(%rsp), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x4a1d30
leaq 0x10(%rsp), %rdx
movq %rdx, -0x10(%rdx)
movq (%rax), %rsi
leaq 0x10(%rax), %rcx
cmpq %rcx, %rsi
je 0x41377d
movq %rsi, (%rsp)
movq (%rcx), %rdx
movq %rdx, 0x10(%rsp)
jmp 0x413783
movups (%rcx), %xmm0
movups %xmm0, (%rdx)
movq %rax, %rdx
addq $0x8, %rdx
movq 0x8(%rax), %rsi
movq %rsi, 0x8(%rsp)
movq %rcx, (%rax)
movq $0x0, (%rdx)
movb $0x0, (%rcx)
leaq 0x1bb600(%rip), %rsi    # 0x5ceda7
movq %rsp, %rdi
callq 0x4a24f0
leaq 0x50(%rsp), %r13
movq %r13, -0x10(%r13)
movq (%rax), %rsi
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rsi
je 0x4137d6
movq %rsi, 0x40(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x50(%rsp)
jmp 0x4137e1
movups (%rcx), %xmm0
movups %xmm0, (%r13)
movq %r13, %rsi
movq 0x8(%rax), %rdx
movq %rdx, 0x48(%rsp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
movq $0x653c40, %rdi         # imm = 0x653C40
callq 0x490910
movq %rax, %r14
leaq 0x1ba89c(%rip), %rsi    # 0x5ce0ab
movl $0x4, %edx
movq %rax, %rdi
callq 0x490910
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x471a60
movsbl %al, %esi
movq %r14, %rdi
callq 0x490410
movq %rax, %rdi
callq 0x48f9e0
movq 0x40(%rsp), %rdi
cmpq %r13, %rdi
je 0x41385a
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x426e30
leaq 0x10(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x413875
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x426e30
movq 0x98(%rsp), %rdi
cmpq %r12, %rdi
je 0x413892
movq 0xa8(%rsp), %rsi
incq %rsi
callq 0x426e30
leaq 0x60(%rsp), %rdi
callq 0x410332
movq 0x20(%rsp), %rdi
cmpq %r15, %rdi
je 0x4138b3
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x426e30
leaq 0x100(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x4138d4
movq 0x100(%rsp), %rsi
incq %rsi
callq 0x426e30
leaq 0xb8(%rsp), %rdi
callq 0x410332
movq %rbx, %rax
addq $0x110, %rsp            # imm = 0x110
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
movq %rax, %rbx
jmp 0x413923
movq %rax, %rbx
jmp 0x41393e
movq %rax, %rbx
jmp 0x413948
movq %rax, %rbx
jmp 0x41395f
movq %rax, %rbx
movq 0x40(%rsp), %rdi
cmpq %r13, %rdi
je 0x413923
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x426e30
leaq 0x10(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x41393e
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x426e30
leaq 0x60(%rsp), %rdi
callq 0x40512c
movq 0x20(%rsp), %rdi
cmpq %r15, %rdi
je 0x41395f
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x426e30
leaq 0xb8(%rsp), %rdi
callq 0x40512c
movq %rbx, %rdi
callq 0x4d10c0