def sys_receive(self, cpu, fd, buf, count, rx_bytes):
data = '<STR_LIT>'<EOL>if count != <NUM_LIT:0>:<EOL><INDENT>if not self._is_open(fd):<EOL><INDENT>logger.info("<STR_LIT>")<EOL>return Decree.CGC_EBADF<EOL><DEDENT>if buf not in cpu.memory:  <EOL><INDENT>logger.info("<STR_LIT>")<EOL>return Decree.CGC_EFAULT<EOL><DEDENT>if fd > <NUM_LIT:2> and self.files[fd].is_empty():<EOL><INDENT>cpu.PC -= cpu.instruction.size<EOL>self.wait([fd], [], None)<EOL>raise RestartSyscall()<EOL><DEDENT>data = self.files[fd].receive(count)<EOL>self.syscall_trace.append(("<STR_LIT>", fd, data))<EOL>cpu.write_bytes(buf, data)<EOL>self.signal_receive(fd)<EOL><DEDENT>if rx_bytes:<EOL><INDENT>if rx_bytes not in cpu.memory:<EOL><INDENT>logger.info("<STR_LIT>")<EOL>return Decree.CGC_EFAULT<EOL><DEDENT>cpu.write_int(rx_bytes, len(data), <NUM_LIT:32>)<EOL><DEDENT>logger.info("<STR_LIT>" % (fd, buf, count, rx_bytes, repr(data)[:min(count, <NUM_LIT:10>)], len(data)))<EOL>return <NUM_LIT:0><EOL>
receive - receive bytes from a file descriptor

            The receive system call reads up to count bytes from file descriptor fd to the
            buffer pointed to by buf. If count is zero, receive returns 0 and optionally
            sets *rx_bytes to zero.

            :param cpu: current CPU.
            :param fd: a valid file descriptor
            :param buf: a memory buffer
            :param count: max number of bytes to receive
            :param rx_bytes: if valid, points to the actual number of bytes received
            :return: 0            Success
                     EBADF        fd is not a valid file descriptor or is not open
                     EFAULT       buf or rx_bytes points to an invalid address.