// File: /workspace/github_c_makefile_star2_O0/wahern[P]cqueues/src/socket.c
// Function: lso_recv3
static lso_nargs_t lso_recv3(lua_State *L) {
	struct luasocket *S = lso_checkself(L, 1);
	struct lso_rcvop op;
	struct iovec iov;
	size_t count;
	int error;

	if ((error = lso_preprcv(L, S)))
		goto error;

	lua_settop(L, 3);

	op = lso_checkrcvop(L, 2, lso_imode(luaL_optstring(L, 3, ""), S->ibuf.mode));

	switch (op.type) {
	case LSO_NUMBER:
		return luaL_argerror(L, op.index, "*n not implemented yet");
	case LSO_SLURP:
		error = lso_fill(S, (size_t)-1);

		if (!(S->ibuf.eom || S->ibuf.eof))
			goto error;

		fifo_rvec(&S->ibuf.fifo, &iov, 1);

		if ((count = iov.iov_len)) {
			if (op.mode & LSO_TEXT)
				iov_trimcr(&iov, 0);

			lua_pushlstring(L, iov.iov_base, iov.iov_len);
			fifo_discard(&S->ibuf.fifo, count);
		} else {
			lua_pushnil(L);
		}

		break;
	case LSO_CHOMP:
		if ((error = lso_getline(S, &iov)))
			goto error;

		count = iov.iov_len;

		if (op.mode & LSO_TEXT)
			iov_trimcr(&iov, 1);

		if (iov_lc(&iov) == '\n')
			--iov.iov_len;

		lua_pushlstring(L, iov.iov_base, iov.iov_len);
		fifo_discard(&S->ibuf.fifo, count);

		break;
	case LSO_LINE:
		if ((error = lso_getline(S, &iov)))
			goto error;

		count = iov.iov_len;

		if (op.mode & LSO_TEXT)
			iov_trimcr(&iov, 1);

		lua_pushlstring(L, iov.iov_base, iov.iov_len);
		fifo_discard(&S->ibuf.fifo, count);

		break;
	case LSO_FIELD:
		if ((error = lso_getheader(S, &iov)))
			goto error;

		if ((count = iov.iov_len)) {
			iov_trimcrlf(&iov, 0);

			lua_pushlstring(L, iov.iov_base, iov.iov_len);
			fifo_discard(&S->ibuf.fifo, count);
		} else {
			lua_pushnil(L);
		}

		break;
	case LSO_HEADER:
		if ((error = lso_getheader(S, &iov)))
			goto error;

		if ((count = iov.iov_len)) {
			if (op.mode & LSO_TEXT)
				iov_trimcr(&iov, 0);

			lua_pushlstring(L, iov.iov_base, iov.iov_len);
			fifo_discard(&S->ibuf.fifo, count);
		} else {
			lua_pushnil(L);
		}

		break;
	case LSO_BODY: {
		int eom = 0; /* it would be confusing to overload ibuf.eom */

		if ((error = lso_getbody(S, &iov, &eom, op.body.eob, op.body.eoblen, op.mode)))
			goto error;

		if ((count = iov.iov_len)) {
			if (eom) {
				/* trim any \r\n preceding the boundary */
				iov_trimcrlf(&iov, 1);

				if (op.mode & LSO_TEXT)
					iov_trimcr(&iov, 0);

				if (iov.iov_len)
					lua_pushlstring(L, iov.iov_base, iov.iov_len);
				else
					lua_pushnil(L);
			} else {
				if (op.mode & LSO_TEXT)
					iov_trimcr(&iov, 0);

				lua_pushlstring(L, iov.iov_base, iov.iov_len);
			}

			fifo_discard(&S->ibuf.fifo, count);
		} else {
			lua_pushnil(L);
		}

		break;
	}
	case LSO_BLOCK:
		if (op.size == 0) {
			lua_pushlstring(L, "", 0);

			break;
		}

		if ((error = lso_getblock(S, &iov, op.size, op.size, op.mode)))
			goto error;

		if ((count = iov.iov_len)) {
			if (op.mode & LSO_TEXT)
				iov_trimcr(&iov, 0);

			lua_pushlstring(L, iov.iov_base, iov.iov_len);
			fifo_discard(&S->ibuf.fifo, count);
		} else {
			lua_pushnil(L);
		}

		break;
	case LSO_LIMIT:
		if (op.size == 0) {
			lua_pushlstring(L, "", 0);

			break;
		}

		if ((error = lso_getblock(S, &iov, 1, op.size, op.mode)))
			goto error;

		if ((count = iov.iov_len)) {
			if (op.mode & LSO_TEXT)
				iov_trimcr(&iov, 0);

			lua_pushlstring(L, iov.iov_base, iov.iov_len);
			fifo_discard(&S->ibuf.fifo, count);
		} else {
			lua_pushnil(L);
		}

		break;
	default:
		error = EFAULT;

		goto error;
	} /* switch(op) */

	if (!fifo_rlen(&S->ibuf.fifo))
		S->ibuf.eom = 0;

	return 1;
error:
	lua_pushnil(L);
	lua_pushinteger(L, lso_asserterror(error));

	return 2;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xb0, %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 0x1cf90
movl %eax, -0x5c(%rbp)
cmpl $0x0, %eax
je 0x19ddb
jmp 0x1a351
movq -0x10(%rbp), %rdi
movl $0x3, %esi
movl %esi, -0x9c(%rbp)
callq 0x107f0
movl -0x9c(%rbp), %esi
movq -0x10(%rbp), %rdi
movq %rdi, -0x98(%rbp)
leaq 0x33764(%rip), %rdx     # 0x4d56b
xorl %eax, %eax
movl %eax, %ecx
callq 0xf940
movq %rax, %rdi
movq -0x18(%rbp), %rax
movl 0x40(%rax), %esi
callq 0x1c8c0
movq -0x98(%rbp), %rsi
movl %eax, %ecx
leaq -0x80(%rbp), %rdi
movl $0x2, %edx
callq 0x1d040
movups -0x80(%rbp), %xmm0
movups -0x70(%rbp), %xmm1
movaps %xmm1, -0x30(%rbp)
movaps %xmm0, -0x40(%rbp)
movl -0x3c(%rbp), %eax
decl %eax
movl %eax, %ecx
movq %rcx, -0x90(%rbp)
subl $0x8, %eax
ja 0x1a31d
movq -0x90(%rbp), %rax
leaq 0x2e70d(%rip), %rcx     # 0x48578
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq -0x10(%rbp), %rdi
movl -0x40(%rbp), %esi
leaq 0x2ea62(%rip), %rdx     # 0x488e4
callq 0xf440
movl %eax, -0x4(%rbp)
jmp 0x1a383
movq -0x18(%rbp), %rdi
movq $-0x1, %rsi
callq 0x1d280
movl %eax, -0x5c(%rbp)
movq -0x18(%rbp), %rax
testb $0x1, 0x91(%rax)
jne 0x19ec1
movq -0x18(%rbp), %rax
testb $0x1, 0x90(%rax)
jne 0x19ec1
jmp 0x1a351
movq -0x18(%rbp), %rdi
addq $0x40, %rdi
addq $0x18, %rdi
leaq -0x50(%rbp), %rsi
movl $0x1, %edx
callq 0x1c110
movq -0x48(%rbp), %rax
movq %rax, -0x58(%rbp)
cmpq $0x0, %rax
je 0x19f27
movl -0x38(%rbp), %eax
andl $0x8, %eax
cmpl $0x0, %eax
je 0x19eff
leaq -0x50(%rbp), %rdi
xorl %esi, %esi
callq 0x1d3f0
movq -0x10(%rbp), %rdi
movq -0x50(%rbp), %rsi
movq -0x48(%rbp), %rdx
callq 0xf510
movq -0x18(%rbp), %rdi
addq $0x40, %rdi
addq $0x18, %rdi
movq -0x58(%rbp), %rsi
callq 0x1c340
jmp 0x19f30
movq -0x10(%rbp), %rdi
callq 0xfa10
jmp 0x1a326
movq -0x18(%rbp), %rdi
leaq -0x50(%rbp), %rsi
callq 0x1d520
movl %eax, -0x5c(%rbp)
cmpl $0x0, %eax
je 0x19f4f
jmp 0x1a351
movq -0x48(%rbp), %rax
movq %rax, -0x58(%rbp)
movl -0x38(%rbp), %eax
andl $0x8, %eax
cmpl $0x0, %eax
je 0x19f70
leaq -0x50(%rbp), %rdi
movl $0x1, %esi
callq 0x1d3f0
leaq -0x50(%rbp), %rdi
callq 0x1d630
cmpl $0xa, %eax
jne 0x19f8a
movq -0x48(%rbp), %rax
addq $-0x1, %rax
movq %rax, -0x48(%rbp)
movq -0x10(%rbp), %rdi
movq -0x50(%rbp), %rsi
movq -0x48(%rbp), %rdx
callq 0xf510
movq -0x18(%rbp), %rdi
addq $0x40, %rdi
addq $0x18, %rdi
movq -0x58(%rbp), %rsi
callq 0x1c340
jmp 0x1a326
movq -0x18(%rbp), %rdi
leaq -0x50(%rbp), %rsi
callq 0x1d520
movl %eax, -0x5c(%rbp)
cmpl $0x0, %eax
je 0x19fcf
jmp 0x1a351
movq -0x48(%rbp), %rax
movq %rax, -0x58(%rbp)
movl -0x38(%rbp), %eax
andl $0x8, %eax
cmpl $0x0, %eax
je 0x19ff0
leaq -0x50(%rbp), %rdi
movl $0x1, %esi
callq 0x1d3f0
movq -0x10(%rbp), %rdi
movq -0x50(%rbp), %rsi
movq -0x48(%rbp), %rdx
callq 0xf510
movq -0x18(%rbp), %rdi
addq $0x40, %rdi
addq $0x18, %rdi
movq -0x58(%rbp), %rsi
callq 0x1c340
jmp 0x1a326
movq -0x18(%rbp), %rdi
leaq -0x50(%rbp), %rsi
callq 0x1d680
movl %eax, -0x5c(%rbp)
cmpl $0x0, %eax
je 0x1a035
jmp 0x1a351
movq -0x48(%rbp), %rax
movq %rax, -0x58(%rbp)
cmpq $0x0, %rax
je 0x1a076
leaq -0x50(%rbp), %rdi
xorl %esi, %esi
callq 0x1d7f0
movq -0x10(%rbp), %rdi
movq -0x50(%rbp), %rsi
movq -0x48(%rbp), %rdx
callq 0xf510
movq -0x18(%rbp), %rdi
addq $0x40, %rdi
addq $0x18, %rdi
movq -0x58(%rbp), %rsi
callq 0x1c340
jmp 0x1a07f
movq -0x10(%rbp), %rdi
callq 0xfa10
jmp 0x1a326
movq -0x18(%rbp), %rdi
leaq -0x50(%rbp), %rsi
callq 0x1d680
movl %eax, -0x5c(%rbp)
cmpl $0x0, %eax
je 0x1a09e
jmp 0x1a351
movq -0x48(%rbp), %rax
movq %rax, -0x58(%rbp)
cmpq $0x0, %rax
je 0x1a0ea
movl -0x38(%rbp), %eax
andl $0x8, %eax
cmpl $0x0, %eax
je 0x1a0c2
leaq -0x50(%rbp), %rdi
xorl %esi, %esi
callq 0x1d3f0
movq -0x10(%rbp), %rdi
movq -0x50(%rbp), %rsi
movq -0x48(%rbp), %rdx
callq 0xf510
movq -0x18(%rbp), %rdi
addq $0x40, %rdi
addq $0x18, %rdi
movq -0x58(%rbp), %rsi
callq 0x1c340
jmp 0x1a0f3
movq -0x10(%rbp), %rdi
callq 0xfa10
jmp 0x1a326
movl $0x0, -0x84(%rbp)
movq -0x18(%rbp), %rdi
movq -0x30(%rbp), %rcx
movq -0x28(%rbp), %r8
movl -0x38(%rbp), %r9d
leaq -0x50(%rbp), %rsi
leaq -0x84(%rbp), %rdx
callq 0x1d960
movl %eax, -0x5c(%rbp)
cmpl $0x0, %eax
je 0x1a12f
jmp 0x1a351
movq -0x48(%rbp), %rax
movq %rax, -0x58(%rbp)
cmpq $0x0, %rax
je 0x1a1d1
cmpl $0x0, -0x84(%rbp)
je 0x1a193
leaq -0x50(%rbp), %rdi
movl $0x1, %esi
callq 0x1d7f0
movl -0x38(%rbp), %eax
andl $0x8, %eax
cmpl $0x0, %eax
je 0x1a16e
leaq -0x50(%rbp), %rdi
xorl %esi, %esi
callq 0x1d3f0
cmpq $0x0, -0x48(%rbp)
je 0x1a188
movq -0x10(%rbp), %rdi
movq -0x50(%rbp), %rsi
movq -0x48(%rbp), %rdx
callq 0xf510
jmp 0x1a191
movq -0x10(%rbp), %rdi
callq 0xfa10
jmp 0x1a1ba
movl -0x38(%rbp), %eax
andl $0x8, %eax
cmpl $0x0, %eax
je 0x1a1a9
leaq -0x50(%rbp), %rdi
xorl %esi, %esi
callq 0x1d3f0
movq -0x10(%rbp), %rdi
movq -0x50(%rbp), %rsi
movq -0x48(%rbp), %rdx
callq 0xf510
movq -0x18(%rbp), %rdi
addq $0x40, %rdi
addq $0x18, %rdi
movq -0x58(%rbp), %rsi
callq 0x1c340
jmp 0x1a1da
movq -0x10(%rbp), %rdi
callq 0xfa10
jmp 0x1a326
cmpq $0x0, -0x30(%rbp)
jne 0x1a1ff
movq -0x10(%rbp), %rdi
leaq 0x3337a(%rip), %rsi     # 0x4d56b
xorl %eax, %eax
movl %eax, %edx
callq 0xf510
jmp 0x1a326
movq -0x18(%rbp), %rdi
movq -0x30(%rbp), %rdx
movq -0x30(%rbp), %rcx
movl -0x38(%rbp), %r8d
leaq -0x50(%rbp), %rsi
callq 0x1db20
movl %eax, -0x5c(%rbp)
cmpl $0x0, %eax
je 0x1a225
jmp 0x1a351
movq -0x48(%rbp), %rax
movq %rax, -0x58(%rbp)
cmpq $0x0, %rax
je 0x1a271
movl -0x38(%rbp), %eax
andl $0x8, %eax
cmpl $0x0, %eax
je 0x1a249
leaq -0x50(%rbp), %rdi
xorl %esi, %esi
callq 0x1d3f0
movq -0x10(%rbp), %rdi
movq -0x50(%rbp), %rsi
movq -0x48(%rbp), %rdx
callq 0xf510
movq -0x18(%rbp), %rdi
addq $0x40, %rdi
addq $0x18, %rdi
movq -0x58(%rbp), %rsi
callq 0x1c340
jmp 0x1a27a
movq -0x10(%rbp), %rdi
callq 0xfa10
jmp 0x1a326
cmpq $0x0, -0x30(%rbp)
jne 0x1a29f
movq -0x10(%rbp), %rdi
leaq 0x332da(%rip), %rsi     # 0x4d56b
xorl %eax, %eax
movl %eax, %edx
callq 0xf510
jmp 0x1a326
movq -0x18(%rbp), %rdi
movq -0x30(%rbp), %rcx
movl -0x38(%rbp), %r8d
leaq -0x50(%rbp), %rsi
movl $0x1, %edx
callq 0x1db20
movl %eax, -0x5c(%rbp)
cmpl $0x0, %eax
je 0x1a2c6
jmp 0x1a351
movq -0x48(%rbp), %rax
movq %rax, -0x58(%rbp)
cmpq $0x0, %rax
je 0x1a312
movl -0x38(%rbp), %eax
andl $0x8, %eax
cmpl $0x0, %eax
je 0x1a2ea
leaq -0x50(%rbp), %rdi
xorl %esi, %esi
callq 0x1d3f0
movq -0x10(%rbp), %rdi
movq -0x50(%rbp), %rsi
movq -0x48(%rbp), %rdx
callq 0xf510
movq -0x18(%rbp), %rdi
addq $0x40, %rdi
addq $0x18, %rdi
movq -0x58(%rbp), %rsi
callq 0x1c340
jmp 0x1a31b
movq -0x10(%rbp), %rdi
callq 0xfa10
jmp 0x1a326
movl $0xe, -0x5c(%rbp)
jmp 0x1a351
movq -0x18(%rbp), %rdi
addq $0x40, %rdi
addq $0x18, %rdi
callq 0x1c210
cmpq $0x0, %rax
jne 0x1a348
movq -0x18(%rbp), %rax
movb $0x0, 0x91(%rax)
movl $0x1, -0x4(%rbp)
jmp 0x1a383
movq -0x10(%rbp), %rdi
callq 0xfa10
movq -0x10(%rbp), %rax
movq %rax, -0xa8(%rbp)
movl -0x5c(%rbp), %edi
callq 0x1dcd0
movq -0xa8(%rbp), %rdi
movslq %eax, %rsi
callq 0xf9a0
movl $0x2, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0xb0, %rsp
popq %rbp
retq
nop