// File: /workspace/github_c_makefile_star2_O1/wahern[P]cqueues/src/socket.c
// Function: lso_send5
static lso_nargs_t lso_send5(lua_State *L) {
	struct luasocket *S = lso_checkself(L, 1);
	const unsigned char *src, *lf;
	size_t tp, p, pe, end, n;
	int mode, byline, error;

	if ((error = lso_prepsnd(L, S))) {
		lua_pushinteger(L, 0);
		lua_pushinteger(L, error);

		return 2;
	}

	lua_settop(L, 5);

	src = (const void *)luaL_checklstring(L, 2, &end);
	tp = lso_checksize(L, 3) - 1;
	pe = lso_checksize(L, 4);
	mode = lso_imode(luaL_optstring(L, 5, ""), S->obuf.mode);
	byline = (mode & (LSO_TEXT|LSO_LINEBUF)) || (S->obuf.mode & LSO_LINEBUF);

	luaL_argcheck(L, tp <= end, 3, "start index beyond object boundary");
	luaL_argcheck(L, pe <= end, 4, "end index beyond object boundary");

	p = tp;

	so_clear(S->socket);

	while (p < pe) {
		if (byline) {
			n = MIN(pe - p, S->obuf.maxline);

			if ((lf = memchr(&src[p], '\n', n))) {
				n = lf - &src[p];

				if ((error = fifo_write(&S->obuf.fifo, &src[p], n)))
					goto error;

				if ((mode & LSO_TEXT) && (error = fifo_putc(&S->obuf.fifo, '\r')))
					goto error;

				if ((error = fifo_putc(&S->obuf.fifo, '\n')))
					goto error;

				p += n + 1;

				S->obuf.eol = fifo_rlen(&S->obuf.fifo);
			} else {
				if ((error = fifo_write(&S->obuf.fifo, &src[p], n)))
					goto error;

				p += n;
			}
		} else {
			n = MIN(pe - p, LSO_BUFSIZ);

			if ((error = fifo_write(&S->obuf.fifo, &src[p], n)))
				goto error;

			p += n;
		}

		if (fifo_rlen(&S->obuf.fifo) > S->obuf.bufsiz) {
			if ((error = lso_doflush(S, mode)))
				goto error;
		}
	}

	if ((error = lso_doflush(S, mode)))
		goto error;

	lua_pushinteger(L, p - tp);

	return 1;
error:
	lua_pushinteger(L, p - tp);
	lua_pushinteger(L, error);

	return 2;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rdi, %r13
callq 0x18609
movq %rax, %r14
movq %r13, %rdi
movq %rax, %rsi
callq 0x19b72
testl %eax, %eax
je 0x1732b
movl %eax, %ebx
movq %r13, %rdi
xorl %esi, %esi
callq 0xf910
movslq %ebx, %r12
jmp 0x1764d
movq %r13, %rdi
movl $0x5, %esi
callq 0x10640
leaq 0x40(%rsp), %rdx
movq %r13, %rdi
movl $0x2, %esi
callq 0xf620
movq %rax, 0x38(%rsp)
movq %r13, %rdi
movl $0x3, %esi
callq 0x10920
movdqa %xmm0, 0x10(%rsp)
movq %r13, %rdi
movl $0x4, %esi
callq 0x10920
movq %xmm0, %r8
movq %r8, %rax
btrq $0x3f, %rax
movabsq $-0x10000000000000, %rdx # imm = 0xFFF0000000000000
leaq (%rax,%rdx), %rdi
shrq $0x35, %rdi
cvttsd2si %xmm0, %rcx
movq %rcx, %rsi
movsd 0x1dc92(%rip), %xmm1    # 0x35030
subsd %xmm1, %xmm0
cvttsd2si %xmm0, %r9
sarq $0x3f, %rsi
andq %rsi, %r9
orq %rcx, %r9
testq %r8, %r8
movq $-0x1, %r15
movq %r9, %rcx
cmovsq %r15, %rcx
movl $0x3ff, %esi            # imm = 0x3FF
cmpl %esi, %edi
cmovaeq %r9, %rcx
movabsq $0x7ff0000000000000, %rdi # imm = 0x7FF0000000000000
cmpq %rdi, %rax
cmoveq %r15, %rcx
testq %r8, %r8
cmovnsq %rcx, %r15
movdqa 0x10(%rsp), %xmm0
movq %xmm0, %r9
movq %r9, %r8
btrq $0x3f, %r8
addq %r8, %rdx
shrq $0x35, %rdx
cvttsd2si %xmm0, %r10
subsd %xmm1, %xmm0
cvttsd2si %xmm0, %r11
movq %r10, %r12
sarq $0x3f, %r12
andq %r11, %r12
orq %r10, %r12
decq %r12
testq %r9, %r9
movq $-0x2, %rbp
movq %r12, %r10
cmovsq %rbp, %r10
cmpl %esi, %edx
cmovaeq %r12, %r10
cmpq %rdi, %r8
cmoveq %rbp, %r10
testq %r9, %r9
cmovnsq %r10, %rbp
decq %r8
movabsq $0xfffffffffffff, %rdx  # imm = 0xFFFFFFFFFFFFF
cmpq %rdx, %r8
cmovaeq %r10, %rbp
decq %rax
cmpq %rdx, %rax
cmovaeq %rcx, %r15
leaq 0x21be4(%rip), %rdx     # 0x3904b
movq %r13, %rdi
movl $0x5, %esi
xorl %ecx, %ecx
callq 0xf8b0
movl 0xa8(%r14), %esi
movq %rax, %rdi
movl %esi, %ebx
callq 0x18ca2
movl %eax, 0x4(%rsp)
movq %rbp, 0x8(%rsp)
leaq 0x40(%rsp), %rax
cmpq (%rax), %rbp
jbe 0x174ae
leaq 0x1e2e7(%rip), %rdx     # 0x35788
movq %r13, %rdi
movl $0x3, %esi
callq 0xf3f0
cmpq 0x40(%rsp), %r15
jbe 0x174c9
leaq 0x1e2ef(%rip), %rdx     # 0x357ab
movq %r13, %rdi
movl $0x4, %esi
callq 0xf3f0
movq %r13, 0x30(%rsp)
movq 0x128(%r14), %rdi
callq 0xf840
movq 0x8(%rsp), %rax
movq %rax, %r12
cmpq %r15, %rax
jae 0x1761f
movl 0x4(%rsp), %eax
andl $0x9, %eax
andl $0x1, %ebx
orl %eax, %ebx
movl %ebx, 0x2c(%rsp)
movq %r14, %rax
addq $0xc0, %rax
movq %rax, 0x10(%rsp)
movq 0x8(%rsp), %r12
movq %r15, %rbp
subq %r12, %rbp
cmpl $0x0, 0x2c(%rsp)
je 0x175b8
movq 0xb0(%r14), %rbx
cmpq %rbx, %rbp
cmovbq %rbp, %rbx
movq 0x38(%rsp), %rax
leaq (%rax,%r12), %r13
movq %r13, %rdi
movl $0xa, %esi
movq %rbx, %rdx
callq 0xfe90
testq %rax, %rax
je 0x175df
movq %rax, %rbp
subq %r13, %rbp
movq 0x10(%rsp), %rdi
movq %r13, %rsi
movq %rbp, %rdx
callq 0x19c0a
testl %eax, %eax
jne 0x1762f
testb $0x8, 0x4(%rsp)
je 0x1758b
movq 0x10(%rsp), %rdi
movl $0xd, %esi
callq 0x19cd5
testl %eax, %eax
jne 0x1762f
movq 0x10(%rsp), %rdi
movl $0xa, %esi
callq 0x19cd5
testl %eax, %eax
jne 0x1762f
incq %rbp
movq 0xe8(%r14), %rax
movq %rax, 0x100(%r14)
movq %rbp, %rbx
jmp 0x175f3
movl $0x1000, %eax           # imm = 0x1000
cmpq %rax, %rbp
cmovaeq %rax, %rbp
movq 0x38(%rsp), %rax
leaq (%rax,%r12), %rsi
movq 0x10(%rsp), %rdi
movq %rbp, %rdx
callq 0x19c0a
movq %rbp, %rbx
jmp 0x175ef
movq 0x10(%rsp), %rdi
movq %r13, %rsi
movq %rbx, %rdx
callq 0x19c0a
testl %eax, %eax
jne 0x1762f
addq %rbx, %r12
movq 0xe8(%r14), %rax
cmpq 0xb8(%r14), %rax
jbe 0x17616
movq %r14, %rdi
movl 0x4(%rsp), %esi
callq 0x187b1
testl %eax, %eax
jne 0x1762f
cmpq %r15, %r12
jb 0x1750e
movq %r14, %rdi
movl 0x4(%rsp), %esi
callq 0x187b1
testl %eax, %eax
je 0x1766e
movl %eax, %r13d
subq 0x8(%rsp), %r12
movq 0x30(%rsp), %rbx
movq %rbx, %rdi
movq %r12, %rsi
callq 0xf910
movslq %r13d, %r12
movq %rbx, %r13
movl $0x2, %ebx
movq %r13, %rdi
movq %r12, %rsi
callq 0xf910
movl %ebx, %eax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
subq 0x8(%rsp), %r12
movl $0x1, %ebx
movq 0x30(%rsp), %r13
jmp 0x17652