// File: /workspace/github_cpp_makefile_star2_O1/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 0x410246
movl 0x54(%r14), %ebx
movq %r14, %rdi
callq 0x4101fe
cmpl $-0x1, %ebx
je 0x4136ed
movq %r14, %rdi
callq 0x4139c0
testb %al, %al
je 0x4136f9
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 0x410246
movq 0xc0(%r14), %rbx
movq %rbx, %rdi
callq 0x427f40
movq %rax, %r12
movl 0x34(%r14), %edi
movq %rax, %rsi
movq %rbx, %rdx
xorl %ecx, %ecx
callq 0x5608c0
movq %rax, %rbx
movq %r14, %rdi
callq 0x4101fe
testq %rbx, %rbx
jle 0x413676
movq %r15, %rdi
movq %r12, %rsi
movq %rbx, %rdx
xorl %ecx, %ecx
callq 0x40afca
movq %r12, %rdi
callq 0x426f30
movq (%r15), %rax
movq %r15, %rdi
xorl %esi, %esi
callq *0x20(%rax)
movq $0x653c40, %rdi         # imm = 0x653C40
leaq 0x1ba9fa(%rip), %rsi    # 0x5ce091
movl $0x4, %edx
callq 0x490a00
movq (%r14), %rax
leaq 0xb8(%rsp), %rdi
movq %r14, %rsi
callq *0x8(%rax)
leaq 0xf0(%rsp), %rdi
leaq 0x1bb6ee(%rip), %rsi    # 0x5cedaf
callq 0x4a25e0
leaq 0x30(%rsp), %r15
movq %r15, -0x10(%r15)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x413700
movq %rdx, 0x20(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x30(%rsp)
jmp 0x413707
movq $-0x1, %rbx
jmp 0x41392c
xorl %ebx, %ebx
jmp 0x41392c
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 0x410522
movq 0x20(%rsp), %rcx
movq 0x28(%rsp), %r8
movq 0xa0(%rsp), %rdx
leaq (%rdx,%r8), %rax
movl $0xf, %esi
cmpq %r15, %rcx
je 0x413750
movq 0x30(%rsp), %rsi
leaq 0xa8(%rsp), %r12
cmpq %rsi, %rax
jbe 0x413779
movl $0xf, %esi
cmpq %r12, 0x98(%rsp)
je 0x413774
movq 0xa8(%rsp), %rsi
cmpq %rsi, %rax
jbe 0x41378d
movq 0x98(%rsp), %rsi
leaq 0x20(%rsp), %rdi
callq 0x4a24a0
jmp 0x41379e
leaq 0x98(%rsp), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x4a1e20
leaq 0x10(%rsp), %rdx
movq %rdx, -0x10(%rdx)
movq (%rax), %rsi
leaq 0x10(%rax), %rcx
cmpq %rcx, %rsi
je 0x4137c1
movq %rsi, (%rsp)
movq (%rcx), %rdx
movq %rdx, 0x10(%rsp)
jmp 0x4137c7
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 0x1bb5bc(%rip), %rsi    # 0x5ceda7
movq %rsp, %rdi
callq 0x4a25e0
leaq 0x50(%rsp), %r13
movq %r13, -0x10(%r13)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x41381a
movq %rdx, 0x40(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x50(%rsp)
jmp 0x413822
movups (%rcx), %xmm0
movups %xmm0, (%r13)
movq 0x8(%rax), %rdx
movq %rdx, 0x48(%rsp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
movq 0x40(%rsp), %rsi
movq 0x48(%rsp), %rdx
movq $0x653c40, %rdi         # imm = 0x653C40
callq 0x490a00
movq %rax, %r14
leaq 0x1ba851(%rip), %rsi    # 0x5ce0ab
movl $0x4, %edx
movq %rax, %rdi
callq 0x490a00
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x471b50
movsbl %al, %esi
movq %r14, %rdi
callq 0x490500
movq %rax, %rdi
callq 0x48fad0
movq 0x40(%rsp), %rdi
cmpq %r13, %rdi
je 0x4138a5
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x426f20
leaq 0x10(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x4138c0
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x426f20
movq 0x98(%rsp), %rdi
cmpq %r12, %rdi
je 0x4138dd
movq 0xa8(%rsp), %rsi
incq %rsi
callq 0x426f20
leaq 0x60(%rsp), %rdi
callq 0x410354
movq 0x20(%rsp), %rdi
cmpq %r15, %rdi
je 0x4138fe
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x426f20
leaq 0x100(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x41391f
movq 0x100(%rsp), %rsi
incq %rsi
callq 0x426f20
leaq 0xb8(%rsp), %rdi
callq 0x410354
movq %rbx, %rax
addq $0x110, %rsp            # imm = 0x110
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
movq %rax, %rbx
jmp 0x41396e
movq %rax, %rbx
jmp 0x413989
movq %rax, %rbx
jmp 0x413993
movq %rax, %rbx
jmp 0x4139aa
movq %rax, %rbx
movq 0x40(%rsp), %rdi
cmpq %r13, %rdi
je 0x41396e
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x426f20
leaq 0x10(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x413989
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x426f20
leaq 0x60(%rsp), %rdi
callq 0x40512a
movq 0x20(%rsp), %rdi
cmpq %r15, %rdi
je 0x4139aa
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x426f20
leaq 0xb8(%rsp), %rdi
callq 0x40512a
movq %rbx, %rdi
callq 0x4d11b0
nop