// File: /workspace/github_cpp_makefile_star2_O3/enbock[P]Warp10Server/ulib/src/Socket.cpp
// Function: u::Socket::send(u::ByteArray*)
int64 u::Socket::send(ByteArray *data)
{
	int64 len				// ammount of byte to send
		, ret					// number of sent bytes
		, pos					// position of the array pointer before send
	;
	char *buffer;		// send buffer

	if(!isConnected()) return -1;
	lock();
	if(_isSending == true) {
		unlock();
		return 0;
	}
	_isSending = true;

	pos = data->position();
	len = data->bytesAvailable();
	buffer = new char[len];
	len = data->readBytes(buffer, len);
	// MSG_NOSIGNAL protected an illegal memory exception on interupted sockets
	ret = ::send(_descriptor, buffer, len, MSG_NOSIGNAL);

	if(ret == -1)
	{
		error(className()+"::send: Sending failed.");
		data->position(pos);
	}
	else
	{
		data->position(pos+ret);
	}

	delete[] buffer;
	_isSending = false;
	unlock();

	trace(
		className() + "::send: Sent " + int2string(ret) + " bytes of "
		+ int2string(len) + " bytes."
	);
	return ret;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1b8, %rsp            # imm = 0x1B8
movq %rsi, %r12
movq %rdi, %r15
callq 0x410226
movl 0x54(%r15), %ebx
movq %r15, %rdi
callq 0x4101de
cmpl $-0x1, %ebx
je 0x412e5c
movq %r15, %rdi
callq 0x410226
cmpb $0x1, 0xb9(%r15)
jne 0x412e68
movq %r15, %rdi
callq 0x4101de
xorl %ebx, %ebx
jmp 0x41345a
movq $-0x1, %rbx
jmp 0x41345a
movb $0x1, 0xb9(%r15)
movq (%r12), %rax
movq %r12, %rdi
callq *0x28(%rax)
movq %rax, %r13
movq %r12, %rdi
callq 0x40bbb6
movq %rax, %rbx
movq %rax, %rdi
callq 0x427e50
movq %rax, %rbp
movq %r12, %rdi
movq %rax, %rsi
movq %rbx, %rdx
xorl %ecx, %ecx
callq 0x40b726
movl 0x34(%r15), %edi
movq %rbp, %rsi
movq %rax, 0xa8(%rsp)
movq %rax, %rdx
movl $0x4000, %ecx           # imm = 0x4000
callq 0x5608c0
movq %rax, %rbx
cmpq $-0x1, %rax
je 0x412ed0
addq %rbx, %r13
jmp 0x41300b
movq $0x653b20, %rdi         # imm = 0x653B20
leaq 0x1bb275(%rip), %rsi    # 0x5ce153
movl $0x7, %edx
callq 0x490910
movq (%r15), %rax
leaq 0x108(%rsp), %rdi
movq %r15, %rsi
callq *0x8(%rax)
leaq 0x140(%rsp), %rdi
leaq 0x1bbe6e(%rip), %rsi    # 0x5ced76
callq 0x4a24f0
leaq 0xc0(%rsp), %rsi
movq %rsi, -0x10(%rsi)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x412f3d
movq %rdx, 0xb0(%rsp)
movq (%rcx), %rdx
movq %rdx, 0xc0(%rsp)
jmp 0x412f43
movups (%rcx), %xmm0
movups %xmm0, (%rsi)
movq 0x8(%rax), %rdx
movq %rdx, 0xb8(%rsp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
movq 0xb0(%rsp), %rsi
movq 0xb8(%rsp), %rdx
movq $0x653b20, %rdi         # imm = 0x653B20
callq 0x490910
movq %rax, %r14
leaq 0x1bb127(%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 0xb0(%rsp), %rdi
leaq 0xc0(%rsp), %rax
cmpq %rax, %rdi
je 0x412fdd
movq 0xc0(%rsp), %rsi
incq %rsi
callq 0x426e30
leaq 0x150(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x412ffe
movq 0x150(%rsp), %rsi
incq %rsi
callq 0x426e30
leaq 0x108(%rsp), %rdi
callq 0x410332
movq (%r12), %rax
movq %r12, %rdi
movq %r13, %rsi
callq *0x20(%rax)
movq %rbp, %rdi
callq 0x426e40
movb $0x0, 0xb9(%r15)
movq %r15, %rdi
callq 0x4101de
movq $0x653c40, %rdi         # imm = 0x653C40
leaq 0x1bb053(%rip), %rsi    # 0x5ce091
movl $0x4, %edx
callq 0x490910
movq (%r15), %rax
leaq 0x108(%rsp), %rdi
movq %r15, %rsi
callq *0x8(%rax)
leaq 0x140(%rsp), %rdi
leaq 0x1bbd26(%rip), %rsi    # 0x5ced8e
callq 0x4a24f0
leaq 0x78(%rsp), %r14
movq %r14, -0x10(%r14)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x413094
movq %rdx, 0x68(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x78(%rsp)
jmp 0x41309b
movups (%rcx), %xmm0
movups %xmm0, (%r14)
movq 0x8(%rax), %rdx
movq %rdx, 0x70(%rsp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
leaq 0xb0(%rsp), %rdi
movl %ebx, %esi
callq 0x410514
movq 0x68(%rsp), %rcx
movq 0x70(%rsp), %r8
movq 0xf0(%rsp), %rdx
leaq (%rdx,%r8), %rax
movl $0xf, %edi
cmpq %r14, %rcx
je 0x4130e7
movq 0x78(%rsp), %rdi
leaq 0xf8(%rsp), %rbp
movq -0x10(%rbp), %rsi
cmpq %rdi, %rax
jbe 0x41310f
movl $0xf, %edi
cmpq %rbp, %rsi
je 0x41310a
movq 0xf8(%rsp), %rdi
cmpq %rdi, %rax
jbe 0x41311b
leaq 0x68(%rsp), %rdi
callq 0x4a23b0
jmp 0x41312c
leaq 0xe8(%rsp), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x4a1d30
leaq 0x38(%rsp), %rdx
movq %rdx, -0x10(%rdx)
movq (%rax), %rsi
leaq 0x10(%rax), %rcx
cmpq %rcx, %rsi
je 0x413150
movq %rsi, 0x28(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x38(%rsp)
jmp 0x413156
movups (%rcx), %xmm0
movups %xmm0, (%rdx)
movq %rax, %rdx
addq $0x8, %rdx
movq 0x8(%rax), %rsi
movq %rsi, 0x30(%rsp)
movq %rcx, (%rax)
movq $0x0, (%rdx)
movb $0x0, (%rcx)
leaq 0x1bbc22(%rip), %rsi    # 0x5ced9c
leaq 0x28(%rsp), %rdi
callq 0x4a24f0
leaq 0x18(%rsp), %r12
movq %r12, -0x10(%r12)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x4131ac
movq %rdx, 0x8(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x18(%rsp)
jmp 0x4131b4
movups (%rcx), %xmm0
movups %xmm0, (%r12)
movq 0x8(%rax), %rdx
movq %rdx, 0x10(%rsp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
leaq 0x160(%rsp), %rdi
movq 0xa8(%rsp), %rsi
callq 0x410514
movq 0x8(%rsp), %rcx
movq 0x10(%rsp), %r8
movq 0x1a0(%rsp), %rdx
leaq (%rdx,%r8), %rax
movl $0xf, %edi
cmpq %r12, %rcx
je 0x413206
movq 0x18(%rsp), %rdi
leaq 0x1a8(%rsp), %r13
movq -0x10(%r13), %rsi
cmpq %rdi, %rax
jbe 0x41322e
movl $0xf, %edi
cmpq %r13, %rsi
je 0x413229
movq 0x1a8(%rsp), %rdi
cmpq %rdi, %rax
jbe 0x41323a
leaq 0x8(%rsp), %rdi
callq 0x4a23b0
jmp 0x41324b
leaq 0x198(%rsp), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x4a1d30
leaq 0x58(%rsp), %rdx
movq %rdx, -0x10(%rdx)
movq (%rax), %rsi
leaq 0x10(%rax), %rcx
cmpq %rcx, %rsi
je 0x41326f
movq %rsi, 0x48(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x58(%rsp)
jmp 0x413275
movups (%rcx), %xmm0
movups %xmm0, (%rdx)
movq %rax, %rdx
addq $0x8, %rdx
movq 0x8(%rax), %rsi
movq %rsi, 0x50(%rsp)
movq %rcx, (%rax)
movq %r14, %r12
movq $0x0, (%rdx)
movb $0x0, (%rcx)
leaq 0x1bbb0b(%rip), %rsi    # 0x5ceda7
leaq 0x48(%rsp), %rdi
callq 0x4a24f0
leaq 0x98(%rsp), %r15
movq %r15, -0x10(%r15)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x4132d6
movq %rdx, 0x88(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x98(%rsp)
jmp 0x4132dd
movups (%rcx), %xmm0
movups %xmm0, (%r15)
movq 0x8(%rax), %rdx
movq %rdx, 0x90(%rsp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
movq 0x88(%rsp), %rsi
movq 0x90(%rsp), %rdx
movq $0x653c40, %rdi         # imm = 0x653C40
callq 0x490910
movq %rax, %r14
leaq 0x1bad8d(%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 0x88(%rsp), %rdi
cmpq %r15, %rdi
je 0x41336f
movq 0x98(%rsp), %rsi
incq %rsi
callq 0x426e30
leaq 0x58(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x41338a
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x426e30
movq 0x198(%rsp), %rdi
cmpq %r13, %rdi
je 0x4133a7
movq 0x1a8(%rsp), %rsi
incq %rsi
callq 0x426e30
leaq 0x160(%rsp), %rdi
callq 0x410332
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x4133d0
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x426e30
leaq 0x38(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x4133eb
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x426e30
movq 0xe8(%rsp), %rdi
cmpq %rbp, %rdi
je 0x413408
movq 0xf8(%rsp), %rsi
incq %rsi
callq 0x426e30
leaq 0xb0(%rsp), %rdi
callq 0x410332
movq 0x68(%rsp), %rdi
cmpq %r12, %rdi
je 0x41342c
movq 0x78(%rsp), %rsi
incq %rsi
callq 0x426e30
leaq 0x150(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x41344d
movq 0x150(%rsp), %rsi
incq %rsi
callq 0x426e30
leaq 0x108(%rsp), %rdi
callq 0x410332
movq %rbx, %rax
addq $0x1b8, %rsp            # imm = 0x1B8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x4134b0
movq %rax, %rbx
jmp 0x413501
movq %r14, %r12
movq %rax, %rbx
jmp 0x41351c
movq %r14, %r12
movq %rax, %rbx
jmp 0x413529
movq %r14, %r12
movq %rax, %rbx
jmp 0x413545
movq %r14, %r12
movq %rax, %rbx
jmp 0x413560
movq %r14, %r12
movq %rax, %rbx
jmp 0x41356d
movq %rax, %rbx
jmp 0x413584
movq %rax, %rbx
movq 0xb0(%rsp), %rdi
leaq 0xc0(%rsp), %rax
cmpq %rax, %rdi
je 0x413584
movq 0xc0(%rsp), %rsi
jmp 0x41357c
movq %rax, %rbx
movq 0x88(%rsp), %rdi
cmpq %r15, %rdi
je 0x413501
movq 0x98(%rsp), %rsi
incq %rsi
callq 0x426e30
leaq 0x58(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x41351c
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x426e30
leaq 0x160(%rsp), %rdi
callq 0x40512c
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x413545
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x426e30
leaq 0x38(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x413560
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x426e30
leaq 0xb0(%rsp), %rdi
callq 0x40512c
movq 0x68(%rsp), %rdi
cmpq %r12, %rdi
je 0x413584
movq 0x78(%rsp), %rsi
incq %rsi
callq 0x426e30
leaq 0x108(%rsp), %rdi
callq 0x40512c
movq %rbx, %rdi
callq 0x4d10c0
nop