// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x70, %rsp
movq %rdi, -0x10(%rbp)
movq -0x10(%rbp), %rdi
movl $0x1, %esi
callq 0x1bba0
movq %rax, -0x18(%rbp)
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x1e8d0
movl %eax, -0x5c(%rbp)
cmpl $0x0, %eax
je 0x1a4c9
movq -0x10(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0xf9a0
movq -0x10(%rbp), %rdi
movslq -0x5c(%rbp), %rsi
callq 0xf9a0
movl $0x2, -0x4(%rbp)
jmp 0x1a862
movq -0x10(%rbp), %rdi
movl $0x5, %esi
callq 0x107f0
movq -0x10(%rbp), %rdi
movl $0x2, %esi
leaq -0x48(%rbp), %rdx
callq 0xf6a0
movq %rax, -0x20(%rbp)
movq -0x10(%rbp), %rdi
movl $0x3, %esi
callq 0x1e920
subq $0x1, %rax
movq %rax, -0x30(%rbp)
movq -0x10(%rbp), %rdi
movl $0x4, %esi
callq 0x1e920
movq %rax, -0x40(%rbp)
movq -0x10(%rbp), %rdi
movl $0x5, %esi
leaq 0x33046(%rip), %rdx     # 0x4d56b
xorl %eax, %eax
movl %eax, %ecx
callq 0xf940
movq %rax, %rdi
movq -0x18(%rbp), %rax
movl 0xa8(%rax), %esi
callq 0x1c8c0
movl %eax, -0x54(%rbp)
movl -0x54(%rbp), %ecx
andl $0x9, %ecx
movb $0x1, %al
cmpl $0x0, %ecx
movb %al, -0x5d(%rbp)
jne 0x1a569
movq -0x18(%rbp), %rax
movl 0xa8(%rax), %eax
andl $0x1, %eax
cmpl $0x0, %eax
setne %al
movb %al, -0x5d(%rbp)
movb -0x5d(%rbp), %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x58(%rbp)
movq -0x30(%rbp), %rcx
movb $0x1, %al
cmpq -0x48(%rbp), %rcx
movb %al, -0x5e(%rbp)
jbe 0x1a5a1
movq -0x10(%rbp), %rdi
movl $0x3, %esi
leaq 0x2e3a1(%rip), %rdx     # 0x48934
callq 0xf440
cmpl $0x0, %eax
setne %al
movb %al, -0x5e(%rbp)
movb -0x5e(%rbp), %al
movq -0x40(%rbp), %rcx
movb $0x1, %al
cmpq -0x48(%rbp), %rcx
movb %al, -0x5f(%rbp)
jbe 0x1a5d1
movq -0x10(%rbp), %rdi
movl $0x4, %esi
leaq 0x2e394(%rip), %rdx     # 0x48957
callq 0xf440
cmpl $0x0, %eax
setne %al
movb %al, -0x5f(%rbp)
movb -0x5f(%rbp), %al
movq -0x30(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x18(%rbp), %rax
movq 0x128(%rax), %rdi
callq 0xf8d0
movq -0x38(%rbp), %rax
cmpq -0x40(%rbp), %rax
jae 0x1a80d
cmpl $0x0, -0x58(%rbp)
je 0x1a768
movq -0x40(%rbp), %rax
subq -0x38(%rbp), %rax
movq -0x18(%rbp), %rcx
cmpq 0xb0(%rcx), %rax
jae 0x1a627
movq -0x40(%rbp), %rax
subq -0x38(%rbp), %rax
movq %rax, -0x68(%rbp)
jmp 0x1a636
movq -0x18(%rbp), %rax
movq 0xb0(%rax), %rax
movq %rax, -0x68(%rbp)
movq -0x68(%rbp), %rax
movq %rax, -0x50(%rbp)
movq -0x20(%rbp), %rdi
addq -0x38(%rbp), %rdi
movq -0x50(%rbp), %rdx
movl $0xa, %esi
callq 0xffa0
movq %rax, -0x28(%rbp)
cmpq $0x0, %rax
je 0x1a72d
movq -0x28(%rbp), %rax
movq -0x20(%rbp), %rcx
addq -0x38(%rbp), %rcx
subq %rcx, %rax
movq %rax, -0x50(%rbp)
movq -0x18(%rbp), %rdi
addq $0xa8, %rdi
addq $0x18, %rdi
movq -0x20(%rbp), %rsi
addq -0x38(%rbp), %rsi
movq -0x50(%rbp), %rdx
callq 0x1e9e0
movl %eax, -0x5c(%rbp)
cmpl $0x0, %eax
je 0x1a6a2
jmp 0x1a83d
movl -0x54(%rbp), %eax
andl $0x8, %eax
cmpl $0x0, %eax
je 0x1a6d3
movq -0x18(%rbp), %rdi
addq $0xa8, %rdi
addq $0x18, %rdi
movl $0xd, %esi
callq 0x1eaf0
movl %eax, -0x5c(%rbp)
cmpl $0x0, %eax
je 0x1a6d3
jmp 0x1a83d
movq -0x18(%rbp), %rdi
addq $0xa8, %rdi
addq $0x18, %rdi
movl $0xa, %esi
callq 0x1eaf0
movl %eax, -0x5c(%rbp)
cmpl $0x0, %eax
je 0x1a6f9
jmp 0x1a83d
movq -0x50(%rbp), %rax
addq $0x1, %rax
addq -0x38(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x18(%rbp), %rdi
addq $0xa8, %rdi
addq $0x18, %rdi
callq 0x1c210
movq %rax, %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x100(%rax)
jmp 0x1a766
movq -0x18(%rbp), %rdi
addq $0xa8, %rdi
addq $0x18, %rdi
movq -0x20(%rbp), %rsi
addq -0x38(%rbp), %rsi
movq -0x50(%rbp), %rdx
callq 0x1e9e0
movl %eax, -0x5c(%rbp)
cmpl $0x0, %eax
je 0x1a75a
jmp 0x1a83d
movq -0x50(%rbp), %rax
addq -0x38(%rbp), %rax
movq %rax, -0x38(%rbp)
jmp 0x1a7cf
movq -0x40(%rbp), %rax
subq -0x38(%rbp), %rax
cmpq $0x1000, %rax           # imm = 0x1000
jae 0x1a786
movq -0x40(%rbp), %rax
subq -0x38(%rbp), %rax
movq %rax, -0x70(%rbp)
jmp 0x1a791
movl $0x1000, %eax           # imm = 0x1000
movq %rax, -0x70(%rbp)
jmp 0x1a791
movq -0x70(%rbp), %rax
movq %rax, -0x50(%rbp)
movq -0x18(%rbp), %rdi
addq $0xa8, %rdi
addq $0x18, %rdi
movq -0x20(%rbp), %rsi
addq -0x38(%rbp), %rsi
movq -0x50(%rbp), %rdx
callq 0x1e9e0
movl %eax, -0x5c(%rbp)
cmpl $0x0, %eax
je 0x1a7c3
jmp 0x1a83d
movq -0x50(%rbp), %rax
addq -0x38(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x18(%rbp), %rdi
addq $0xa8, %rdi
addq $0x18, %rdi
callq 0x1c210
movq -0x18(%rbp), %rcx
cmpq 0xb8(%rcx), %rax
jbe 0x1a808
movq -0x18(%rbp), %rdi
movl -0x54(%rbp), %esi
callq 0x1bf30
movl %eax, -0x5c(%rbp)
cmpl $0x0, %eax
je 0x1a806
jmp 0x1a83d
jmp 0x1a808
jmp 0x1a5ec
movq -0x18(%rbp), %rdi
movl -0x54(%rbp), %esi
callq 0x1bf30
movl %eax, -0x5c(%rbp)
cmpl $0x0, %eax
je 0x1a823
jmp 0x1a83d
movq -0x10(%rbp), %rdi
movq -0x38(%rbp), %rsi
subq -0x30(%rbp), %rsi
callq 0xf9a0
movl $0x1, -0x4(%rbp)
jmp 0x1a862
movq -0x10(%rbp), %rdi
movq -0x38(%rbp), %rsi
subq -0x30(%rbp), %rsi
callq 0xf9a0
movq -0x10(%rbp), %rdi
movslq -0x5c(%rbp), %rsi
callq 0xf9a0
movl $0x2, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x70, %rsp
popq %rbp
retq
nopl (%rax,%rax)