user: 请显示与下面列出的汇编代码相匹配的C语言实现：

```asm
<cmd_exec>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  push   %r15
  push   %r14
  mov    %rdi,%r14
  push   %r13
  push   %r12
  push   %rbx
  sub    $0x28,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,-0x38(%rbp)
  xor    %eax,%eax
  call   <detect_out_direction@plt>
  mov    %r14,%rdi
  movslq %eax,%r12
  call   <detect_in_direction@plt>
  cmp    $0xffffffff,%r12d
  je     L149
  lea    0x1(%r12),%r15d
  mov    %rsp,%rcx
  mov    %rsp,-0x48(%rbp)
  movslq %r15d,%rax
  lea    0xf(,%rax,8),%rax
  mov    %rax,%rdx
  and    $0xfffffffffffff000,%rax
  sub    %rax,%rcx
  and    $0xfffffffffffffff0,%rdx
  cmp    %rcx,%rsp
  je     L2
L12:
  sub    $0x1000,%rsp
  orq    $0x0,0xff8(%rsp)
  cmp    %rcx,%rsp
  jne    L12
L2:
  and    $0xfff,%edx
  sub    %rdx,%rsp
  test   %rdx,%rdx
  je     L29
  orq    $0x0,-0x8(%rsp,%rdx,1)
L29:
  mov    %rsp,%r13
  test   %r12d,%r12d
  jle    L163
  xor    %ebx,%ebx
L129:
  mov    %ebx,%esi
  mov    %r14,%rdi
  call   <tokens_get_token@plt>
  mov    %rax,0x0(%r13,%rbx,8)
  add    $0x1,%rbx
  cmp    %rbx,%r12
  jne    L129
L163:
  movq   $0x0,0x0(%r13,%r12,8)
  mov    %r15d,%esi
  mov    %r14,%rdi
  call   <tokens_get_token@plt>
  mov    %r13,%rdi
  mov    %rax,%rsi
  call   <cmd_output_direction@plt>
  mov    -0x48(%rbp),%rsp
L41:
  mov    -0x38(%rbp),%rax
  sub    %fs:0x28,%rax
  jne    L173
  lea    -0x28(%rbp),%rsp
  mov    $0x1,%eax
  pop    %rbx
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  pop    %rbp
  ret
  nopw   0x0(%rax,%rax,1)
L149:
  cmp    $0xffffffff,%eax
  je     L107
  lea    0x1(%rax),%r13d
  mov    %rsp,-0x48(%rbp)
  mov    %rsp,%rsi
  movslq %r13d,%rdx
  lea    0xf(,%rdx,8),%rdx
  mov    %rdx,%rcx
  and    $0xfffffffffffff000,%rdx
  and    $0xfffffffffffffff0,%rcx
  sub    %rdx,%rsi
L34:
  cmp    %rsi,%rsp
  je     L123
  sub    $0x1000,%rsp
  orq    $0x0,0xff8(%rsp)
  jmp    L34
  nop
L123:
  and    $0xfff,%ecx
  sub    %rcx,%rsp
  test   %rcx,%rcx
  jne    L126
L79:
  mov    %rsp,%r12
  movslq %eax,%rbx
  xor    %r15d,%r15d
  test   %eax,%eax
  jle    L35
  nop
L42:
  mov    %r15d,%esi
  mov    %r14,%rdi
  call   <tokens_get_token@plt>
  mov    %rax,(%r12,%r15,8)
  add    $0x1,%r15
  cmp    %rbx,%r15
  jne    L42
L35:
  movq   $0x0,(%r12,%rbx,8)
  mov    %r13d,%esi
  mov    %r14,%rdi
  call   <tokens_get_token@plt>
  mov    %r12,%rdi
  mov    %rax,%rsi
  call   <cmd_input_direction@plt>
  mov    -0x48(%rbp),%rsp
  jmp    L41
  nop
L107:
  xor    %esi,%esi
  mov    %r14,%rdi
  lea    D1(%rip),%rbx
  call   <tokens_get_token@plt>
  mov    %r14,%rsi
  mov    %rax,%rdi
  call   <cmd_exec_helper@plt>
  lea    D28(%rip),%rdi
  call   <getenv@plt>
  mov    %rbx,%rsi
  mov    %rax,%rdi
  call   <strtok@plt>
  mov    %rax,%r13
  test   %rax,%rax
  je     L41
  lea    D12(%rip),%r15
  cs nopw 0x0(%rax,%rax,1)
L157:
  mov    $0x64,%edi
  call   <malloc@plt>
  mov    %r13,%rsi
  mov    %rax,%r12
  mov    %rax,%rdi
  call   <strcat@plt>
  mov    %r15,%rsi
  mov    %r12,%rdi
  call   <strcat@plt>
  xor    %esi,%esi
  mov    %r14,%rdi
  call   <tokens_get_token@plt>
  mov    %r12,%rdi
  mov    %rax,%rsi
  call   <strcat@plt>
  xor    %edi,%edi
  mov    %rbx,%rsi
  call   <strtok@plt>
  mov    %r14,%rsi
  mov    %r12,%rdi
  mov    %rax,%r13
  call   <cmd_exec_helper@plt>
  test   %r13,%r13
  jne    L157
  jmp    L41
L126:
  orq    $0x0,-0x8(%rsp,%rcx,1)
  jmp    L79
L173:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: parse_data
arguments: tag: D1
type_guessed: string
name: parse_data
arguments: tag: D28
type_guessed: string
name: parse_data
arguments: tag: D12
type_guessed: string

tool: D1: :

tool: D28: PATH

tool: D12: /

assistant: ```c
int cmd_exec(struct tokens *tokens) {
  int out = detect_out_direction(tokens);
  int in = detect_in_direction(tokens);
  if (out != -1) {
    char *argv[out + 1];
    int j;
    for (j = 0; j < out; j++) {
      argv[j] = tokens_get_token(tokens, j);
    }
    argv[out] = NULL;
    char *filename = tokens_get_token(tokens, out + 1);
    cmd_output_direction(argv, filename);
  } else if (in != -1) {
    char *argv[in + 1];
    int j;
    for (j = 0; j < in; j++) {
      argv[j] = tokens_get_token(tokens, j);
    }
    argv[in] = NULL;
    char *filename = tokens_get_token(tokens, in + 1);
    cmd_input_direction(argv, filename);
  } else {
    cmd_exec_helper(tokens_get_token(tokens, 0), tokens);
    char *path = getenv("PATH");
    char *pch;
    pch = strtok(path, ":");
    while (pch != NULL) {
      char *str = malloc(100);
      strcat(str, pch);
      strcat(str, "/");
      strcat(str, tokens_get_token(tokens, 0));
      pch = strtok(NULL, ":");
      cmd_exec_helper(str, tokens);
    }
  }
  return 1;
}
```