// File: /workspace/github_c_makefile_star2_O0/wahern[P]cqueues/src/lib/socket.c
// Function: so_recvmsg
int so_recvmsg(struct socket *so, struct msghdr *msg, int flags) {
	ssize_t count;
	int error;

	so_pipeign(so, 1);

	so->todo |= SO_S_SETREAD;

	if ((error = so_exec(so)))
		goto error;

	so->events &= ~POLLIN;
retry:
	if (-1 == (count = recvmsg(so->fd, msg, flags))) {
		goto syerr;
	} else if (!count) {
		so->st.rcvd.eof = 1;
		error = EPIPE;
		goto error;
	}

	st_update(&so->st.rcvd, count, &so->opts);

	/* RE .msg_iovlen type
	 *
	 * 	- Linux    : size_t
	 * 	- OS X     : int
	 * 	- OpenBSD  : unsigned int
	 * 	- Solaris  : int
	 * 	- FreeBSD  : int
	 * 	- NetBSD   : int
	 * 	- RFC 2292 : size_t
	 */
	for (size_t i = 0; i < (size_t)msg->msg_iovlen; i++) {
		if ((size_t)count < msg->msg_iov[i].iov_len) {
			msg->msg_iov[i].iov_len = count;

			break;
		} else {
			count -= (ssize_t)msg->msg_iov[i].iov_len;
		}
	}

	so_pipeok(so, 1);

	return 0;
syerr:
	error = errno;
error:
	switch (error) {
	case SO_EINTR:
		goto retry;
#if SO_EWOULDBLOCK != SO_EAGAIN
	case SO_EWOULDBLOCK:
		/* FALL THROUGH */
#endif
	case SO_EAGAIN:
		so->events |= POLLIN;

		break;
	} /* switch() */

	so_pipeok(so, 1);

	return error;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl %edx, -0x1c(%rbp)
movq -0x10(%rbp), %rdi
movl $0x1, %esi
callq 0x2e860
movq -0x10(%rbp), %rax
movl 0xb8(%rax), %ecx
orl $0x80, %ecx
movl %ecx, 0xb8(%rax)
movq -0x10(%rbp), %rdi
callq 0x2dbb0
movl %eax, -0x2c(%rbp)
cmpl $0x0, %eax
je 0x2fd8d
jmp 0x2fea9
movq -0x10(%rbp), %rax
movswl 0xb0(%rax), %ecx
andl $-0x2, %ecx
movw %cx, 0xb0(%rax)
movq -0x10(%rbp), %rax
movl 0x58(%rax), %edi
movq -0x18(%rbp), %rsi
movl -0x1c(%rbp), %edx
callq 0xf3c0
movq %rax, %rcx
movq %rcx, -0x28(%rbp)
movq $-0x1, %rax
cmpq %rcx, %rax
jne 0x2fdcd
jmp 0x2fe9f
cmpq $0x0, -0x28(%rbp)
jne 0x2fdeb
movq -0x10(%rbp), %rax
movb $0x1, 0x90(%rax)
movl $0x20, -0x2c(%rbp)
jmp 0x2fea9
jmp 0x2fded
movq -0x10(%rbp), %rdi
addq $0x70, %rdi
addq $0x18, %rdi
movq -0x28(%rbp), %rsi
movq -0x10(%rbp), %rdx
callq 0x2f450
movq $0x0, -0x38(%rbp)
movq -0x38(%rbp), %rax
movq -0x18(%rbp), %rcx
cmpq 0x18(%rcx), %rax
jae 0x2fe88
movq -0x28(%rbp), %rax
movq -0x18(%rbp), %rcx
movq 0x10(%rcx), %rcx
movq -0x38(%rbp), %rdx
shlq $0x4, %rdx
addq %rdx, %rcx
cmpq 0x8(%rcx), %rax
jae 0x2fe56
movq -0x28(%rbp), %rcx
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x38(%rbp), %rdx
shlq $0x4, %rdx
addq %rdx, %rax
movq %rcx, 0x8(%rax)
jmp 0x2fe88
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x38(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rcx
movq -0x28(%rbp), %rax
subq %rcx, %rax
movq %rax, -0x28(%rbp)
jmp 0x2fe7a
movq -0x38(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x38(%rbp)
jmp 0x2fe0e
movq -0x10(%rbp), %rdi
movl $0x1, %esi
callq 0x2f4a0
movl $0x0, -0x4(%rbp)
jmp 0x2feee
callq 0xf0a0
movl (%rax), %eax
movl %eax, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
movl %eax, -0x3c(%rbp)
subl $0x4, %eax
je 0x2fec0
jmp 0x2feb6
movl -0x3c(%rbp), %eax
subl $0xb, %eax
je 0x2fec5
jmp 0x2feda
jmp 0x2fda2
movq -0x10(%rbp), %rax
movswl 0xb0(%rax), %ecx
orl $0x1, %ecx
movw %cx, 0xb0(%rax)
movq -0x10(%rbp), %rdi
movl $0x1, %esi
callq 0x2f4a0
movl -0x2c(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x40, %rsp
popq %rbp
retq
nopw (%rax,%rax)