// File: /workspace/github_cpp_makefile_star2_O1/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 0x410246
movl 0x54(%r15), %ebx
movq %r15, %rdi
callq 0x4101fe
cmpl $-0x1, %ebx
je 0x412e9c
movq %r15, %rdi
callq 0x410246
cmpb $0x1, 0xb9(%r15)
jne 0x412ea8
movq %r15, %rdi
callq 0x4101fe
xorl %ebx, %ebx
jmp 0x4134a9
movq $-0x1, %rbx
jmp 0x4134a9
movb $0x1, 0xb9(%r15)
movq (%r12), %rax
movq %r12, %rdi
callq *0x28(%rax)
movq %rax, %r13
movq %r12, %rdi
callq 0x40bc32
movq %rax, %rbx
movq %rax, %rdi
callq 0x427f40
movq %rax, %rbp
movq %r12, %rdi
movq %rax, %rsi
movq %rbx, %rdx
xorl %ecx, %ecx
callq 0x40b790
movl 0x34(%r15), %edi
movq %rbp, %rsi
movq %rax, 0x100(%rsp)
movq %rax, %rdx
movl $0x4000, %ecx           # imm = 0x4000
callq 0x560980
movq %rax, %rbx
cmpq $-0x1, %rax
je 0x412f10
addq %rbx, %r13
jmp 0x41304b
movq $0x653b20, %rdi         # imm = 0x653B20
leaq 0x1bb235(%rip), %rsi    # 0x5ce153
movl $0x7, %edx
callq 0x490a00
movq (%r15), %rax
leaq 0x108(%rsp), %rdi
movq %r15, %rsi
callq *0x8(%rax)
leaq 0x140(%rsp), %rdi
leaq 0x1bbe2e(%rip), %rsi    # 0x5ced76
callq 0x4a25e0
leaq 0xb8(%rsp), %rsi
movq %rsi, -0x10(%rsi)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x412f7d
movq %rdx, 0xa8(%rsp)
movq (%rcx), %rdx
movq %rdx, 0xb8(%rsp)
jmp 0x412f83
movups (%rcx), %xmm0
movups %xmm0, (%rsi)
movq 0x8(%rax), %rdx
movq %rdx, 0xb0(%rsp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
movq 0xa8(%rsp), %rsi
movq 0xb0(%rsp), %rdx
movq $0x653b20, %rdi         # imm = 0x653B20
callq 0x490a00
movq %rax, %r14
leaq 0x1bb0e7(%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 0xa8(%rsp), %rdi
leaq 0xb8(%rsp), %rax
cmpq %rax, %rdi
je 0x41301d
movq 0xb8(%rsp), %rsi
incq %rsi
callq 0x426f20
leaq 0x150(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x41303e
movq 0x150(%rsp), %rsi
incq %rsi
callq 0x426f20
leaq 0x108(%rsp), %rdi
callq 0x410354
movq (%r12), %rax
movq %r12, %rdi
movq %r13, %rsi
callq *0x20(%rax)
movq %rbp, %rdi
callq 0x426f30
movb $0x0, 0xb9(%r15)
movq %r15, %rdi
callq 0x4101fe
movq $0x653c40, %rdi         # imm = 0x653C40
leaq 0x1bb013(%rip), %rsi    # 0x5ce091
movl $0x4, %edx
callq 0x490a00
movq (%r15), %rax
leaq 0x108(%rsp), %rdi
movq %r15, %rsi
callq *0x8(%rax)
leaq 0x140(%rsp), %rdi
leaq 0x1bbce6(%rip), %rsi    # 0x5ced8e
callq 0x4a25e0
leaq 0x18(%rsp), %r14
movq %r14, -0x10(%r14)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x4130d4
movq %rdx, 0x8(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x18(%rsp)
jmp 0x4130db
movups (%rcx), %xmm0
movups %xmm0, (%r14)
movq 0x8(%rax), %rdx
movq %rdx, 0x10(%rsp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
leaq 0xa8(%rsp), %rdi
movl %ebx, %esi
callq 0x410522
movq 0x8(%rsp), %rcx
movq 0x10(%rsp), %r8
movq 0xe8(%rsp), %rdx
leaq (%rdx,%r8), %rax
movl $0xf, %esi
cmpq %r14, %rcx
je 0x413127
movq 0x18(%rsp), %rsi
leaq 0xf0(%rsp), %r15
cmpq %rsi, %rax
jbe 0x413150
movl $0xf, %esi
cmpq %r15, 0xe0(%rsp)
je 0x41314b
movq 0xf0(%rsp), %rsi
cmpq %rsi, %rax
jbe 0x413164
movq 0xe0(%rsp), %rsi
leaq 0x8(%rsp), %rdi
callq 0x4a24a0
jmp 0x413175
leaq 0xe0(%rsp), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x4a1e20
leaq 0x38(%rsp), %rdx
movq %rdx, -0x10(%rdx)
movq (%rax), %rsi
leaq 0x10(%rax), %rcx
cmpq %rcx, %rsi
je 0x413199
movq %rsi, 0x28(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x38(%rsp)
jmp 0x41319f
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 0x1bbbd9(%rip), %rsi    # 0x5ced9c
leaq 0x28(%rsp), %rdi
callq 0x4a25e0
leaq 0x78(%rsp), %rbp
movq %rbp, -0x10(%rbp)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x4131f4
movq %rdx, 0x68(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x78(%rsp)
jmp 0x4131fb
movups (%rcx), %xmm0
movups %xmm0, (%rbp)
movq 0x8(%rax), %rdx
movq %rdx, 0x70(%rsp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
leaq 0x160(%rsp), %rdi
movq 0x100(%rsp), %rsi
callq 0x410522
movq 0x68(%rsp), %rcx
movq 0x70(%rsp), %r8
movq 0x1a0(%rsp), %rdx
leaq (%rdx,%r8), %rax
movl $0xf, %esi
cmpq %rbp, %rcx
je 0x41324d
movq 0x78(%rsp), %rsi
leaq 0x1a8(%rsp), %r13
cmpq %rsi, %rax
jbe 0x413276
movl $0xf, %esi
cmpq %r13, 0x198(%rsp)
je 0x413271
movq 0x1a8(%rsp), %rsi
cmpq %rsi, %rax
jbe 0x41328a
movq 0x198(%rsp), %rsi
leaq 0x68(%rsp), %rdi
callq 0x4a24a0
jmp 0x41329b
leaq 0x198(%rsp), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x4a1e20
leaq 0x58(%rsp), %rdx
movq %rdx, -0x10(%rdx)
movq (%rax), %rsi
leaq 0x10(%rax), %rcx
cmpq %rcx, %rsi
je 0x4132bf
movq %rsi, 0x48(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x58(%rsp)
jmp 0x4132c5
movups (%rcx), %xmm0
movups %xmm0, (%rdx)
movq %rax, %rdx
addq $0x8, %rdx
movq 0x8(%rax), %rsi
movq %rsi, 0x50(%rsp)
movq %rcx, (%rax)
movq $0x0, (%rdx)
movb $0x0, (%rcx)
leaq 0x1bbabe(%rip), %rsi    # 0x5ceda7
leaq 0x48(%rsp), %rdi
callq 0x4a25e0
leaq 0x98(%rsp), %r12
movq %r12, -0x10(%r12)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x413324
movq %rdx, 0x88(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x98(%rsp)
jmp 0x41332c
movups (%rcx), %xmm0
movups %xmm0, (%r12)
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 0x490a00
movq %rax, %r14
leaq 0x1bad3e(%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 0x88(%rsp), %rdi
cmpq %r12, %rdi
je 0x4133be
movq 0x98(%rsp), %rsi
incq %rsi
callq 0x426f20
leaq 0x58(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x4133d9
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x426f20
movq 0x198(%rsp), %rdi
cmpq %r13, %rdi
je 0x4133f6
movq 0x1a8(%rsp), %rsi
incq %rsi
callq 0x426f20
leaq 0x160(%rsp), %rdi
callq 0x410354
movq 0x68(%rsp), %rdi
cmpq %rbp, %rdi
je 0x41341a
movq 0x78(%rsp), %rsi
incq %rsi
callq 0x426f20
leaq 0x38(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x413435
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x426f20
movq 0xe0(%rsp), %rdi
cmpq %r15, %rdi
je 0x413452
movq 0xf0(%rsp), %rsi
incq %rsi
callq 0x426f20
leaq 0xa8(%rsp), %rdi
callq 0x410354
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x41347b
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x426f20
leaq 0x150(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x41349c
movq 0x150(%rsp), %rsi
incq %rsi
callq 0x426f20
leaq 0x108(%rsp), %rdi
callq 0x410354
movq %rbx, %rax
addq $0x1b8, %rsp            # imm = 0x1B8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x4134ed
movq %rax, %rbx
jmp 0x41353e
movq %rax, %rbx
jmp 0x413559
movq %rax, %rbx
jmp 0x413566
movq %rax, %rbx
jmp 0x41357d
movq %rax, %rbx
jmp 0x413598
movq %rax, %rbx
jmp 0x4135a5
movq %rax, %rbx
jmp 0x4135c1
movq %rax, %rbx
movq 0xa8(%rsp), %rdi
leaq 0xb8(%rsp), %rax
cmpq %rax, %rdi
je 0x4135c1
movq 0xb8(%rsp), %rsi
jmp 0x4135b9
movq %rax, %rbx
movq 0x88(%rsp), %rdi
cmpq %r12, %rdi
je 0x41353e
movq 0x98(%rsp), %rsi
incq %rsi
callq 0x426f20
leaq 0x58(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x413559
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x426f20
leaq 0x160(%rsp), %rdi
callq 0x40512a
movq 0x68(%rsp), %rdi
cmpq %rbp, %rdi
je 0x41357d
movq 0x78(%rsp), %rsi
incq %rsi
callq 0x426f20
leaq 0x38(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x413598
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x426f20
leaq 0xa8(%rsp), %rdi
callq 0x40512a
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x4135c1
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x426f20
leaq 0x108(%rsp), %rdi
callq 0x40512a
movq %rbx, %rdi
callq 0x4d11b0