user: 请将这段汇编代码片段转换成等效的C代码：

```asm
<cmd_exec>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbx
  sub    $0x98,%rsp
  mov    %rdi,-0x98(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x38(%rbp)
  xor    %eax,%eax
  mov    -0x98(%rbp),%rax
  mov    %rax,%rdi
  call   <detect_out_direction@plt>
  mov    %eax,-0x88(%rbp)
  mov    -0x98(%rbp),%rax
  mov    %rax,%rdi
  call   <detect_in_direction@plt>
  mov    %eax,-0x84(%rbp)
  cmpl   $0xffffffff,-0x88(%rbp)
  je     L117
  mov    %rsp,%rax
  mov    %rax,%rbx
  mov    -0x88(%rbp),%eax
  add    $0x1,%eax
  movslq %eax,%rdx
  sub    $0x1,%rdx
  mov    %rdx,-0x50(%rbp)
  movslq %eax,%rdx
  mov    %rdx,-0xb0(%rbp)
  movq   $0x0,-0xa8(%rbp)
  movslq %eax,%rdx
  mov    %rdx,-0xc0(%rbp)
  movq   $0x0,-0xb8(%rbp)
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    $0x10,%eax
  sub    $0x1,%rax
  add    %rdx,%rax
  mov    $0x10,%esi
  mov    $0x0,%edx
  div    %rsi
  imul   $0x10,%rax,%rax
  mov    %rax,%rcx
  and    $0xfffffffffffff000,%rcx
  mov    %rsp,%rdx
  sub    %rcx,%rdx
L71:
  cmp    %rdx,%rsp
  je     L53
  sub    $0x1000,%rsp
  orq    $0x0,0xff8(%rsp)
  jmp    L71
L53:
  mov    %rax,%rdx
  and    $0xfff,%edx
  sub    %rdx,%rsp
  mov    %rax,%rdx
  and    $0xfff,%edx
  test   %rdx,%rdx
  je     L98
  and    $0xfff,%eax
  sub    $0x8,%rax
  add    %rsp,%rax
  orq    $0x0,(%rax)
L98:
  mov    %rsp,%rax
  add    $0x7,%rax
  shr    $0x3,%rax
  shl    $0x3,%rax
  mov    %rax,-0x48(%rbp)
  movl   $0x0,-0x90(%rbp)
  jmp    L153
L120:
  mov    -0x90(%rbp),%edx
  mov    -0x98(%rbp),%rax
  mov    %edx,%esi
  mov    %rax,%rdi
  call   <tokens_get_token@plt>
  mov    -0x48(%rbp),%rdx
  mov    -0x90(%rbp),%ecx
  movslq %ecx,%rcx
  mov    %rax,(%rdx,%rcx,8)
  addl   $0x1,-0x90(%rbp)
L153:
  mov    -0x90(%rbp),%eax
  cmp    -0x88(%rbp),%eax
  jl     L120
  mov    -0x48(%rbp),%rax
  mov    -0x88(%rbp),%edx
  movslq %edx,%rdx
  movq   $0x0,(%rax,%rdx,8)
  mov    -0x88(%rbp),%eax
  lea    0x1(%rax),%edx
  mov    -0x98(%rbp),%rax
  mov    %edx,%esi
  mov    %rax,%rdi
  call   <tokens_get_token@plt>
  mov    %rax,-0x40(%rbp)
  mov    -0x40(%rbp),%rdx
  mov    -0x48(%rbp),%rax
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <cmd_output_direction@plt>
  mov    %rbx,%rsp
  jmp    L101
L117:
  cmpl   $0xffffffff,-0x84(%rbp)
  je     L151
  mov    %rsp,%rax
  mov    %rax,%rbx
  mov    -0x84(%rbp),%eax
  add    $0x1,%eax
  movslq %eax,%rdx
  sub    $0x1,%rdx
  mov    %rdx,-0x68(%rbp)
  movslq %eax,%rdx
  mov    %rdx,%r14
  mov    $0x0,%r15d
  movslq %eax,%rdx
  mov    %rdx,%r12
  mov    $0x0,%r13d
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    $0x10,%eax
  sub    $0x1,%rax
  add    %rdx,%rax
  mov    $0x10,%esi
  mov    $0x0,%edx
  div    %rsi
  imul   $0x10,%rax,%rax
  mov    %rax,%rcx
  and    $0xfffffffffffff000,%rcx
  mov    %rsp,%rdx
  sub    %rcx,%rdx
L167:
  cmp    %rdx,%rsp
  je     L118
  sub    $0x1000,%rsp
  orq    $0x0,0xff8(%rsp)
  jmp    L167
L118:
  mov    %rax,%rdx
  and    $0xfff,%edx
  sub    %rdx,%rsp
  mov    %rax,%rdx
  and    $0xfff,%edx
  test   %rdx,%rdx
  je     L102
  and    $0xfff,%eax
  sub    $0x8,%rax
  add    %rsp,%rax
  orq    $0x0,(%rax)
L102:
  mov    %rsp,%rax
  add    $0x7,%rax
  shr    $0x3,%rax
  shl    $0x3,%rax
  mov    %rax,-0x60(%rbp)
  movl   $0x0,-0x8c(%rbp)
  jmp    L138
L159:
  mov    -0x8c(%rbp),%edx
  mov    -0x98(%rbp),%rax
  mov    %edx,%esi
  mov    %rax,%rdi
  call   <tokens_get_token@plt>
  mov    -0x60(%rbp),%rdx
  mov    -0x8c(%rbp),%ecx
  movslq %ecx,%rcx
  mov    %rax,(%rdx,%rcx,8)
  addl   $0x1,-0x8c(%rbp)
L138:
  mov    -0x8c(%rbp),%eax
  cmp    -0x84(%rbp),%eax
  jl     L159
  mov    -0x60(%rbp),%rax
  mov    -0x84(%rbp),%edx
  movslq %edx,%rdx
  movq   $0x0,(%rax,%rdx,8)
  mov    -0x84(%rbp),%eax
  lea    0x1(%rax),%edx
  mov    -0x98(%rbp),%rax
  mov    %edx,%esi
  mov    %rax,%rdi
  call   <tokens_get_token@plt>
  mov    %rax,-0x58(%rbp)
  mov    -0x58(%rbp),%rdx
  mov    -0x60(%rbp),%rax
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <cmd_input_direction@plt>
  mov    %rbx,%rsp
  jmp    L101
L151:
  mov    -0x98(%rbp),%rax
  mov    $0x0,%esi
  mov    %rax,%rdi
  call   <tokens_get_token@plt>
  mov    %rax,%rdx
  mov    -0x98(%rbp),%rax
  mov    %rax,%rsi
  mov    %rdx,%rdi
  call   <cmd_exec_helper@plt>
  lea    D6(%rip),%rax
  mov    %rax,%rdi
  call   <getenv@plt>
  mov    %rax,-0x78(%rbp)
  mov    -0x78(%rbp),%rax
  lea    D4(%rip),%rdx
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <strtok@plt>
  mov    %rax,-0x80(%rbp)
  jmp    L139
L149:
  mov    $0x64,%edi
  call   <malloc@plt>
  mov    %rax,-0x70(%rbp)
  mov    -0x80(%rbp),%rdx
  mov    -0x70(%rbp),%rax
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <strcat@plt>
  mov    -0x70(%rbp),%rax
  lea    D7(%rip),%rdx
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <strcat@plt>
  mov    -0x98(%rbp),%rax
  mov    $0x0,%esi
  mov    %rax,%rdi
  call   <tokens_get_token@plt>
  mov    %rax,%rdx
  mov    -0x70(%rbp),%rax
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <strcat@plt>
  lea    D4(%rip),%rax
  mov    %rax,%rsi
  mov    $0x0,%edi
  call   <strtok@plt>
  mov    %rax,-0x80(%rbp)
  mov    -0x98(%rbp),%rdx
  mov    -0x70(%rbp),%rax
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <cmd_exec_helper@plt>
L139:
  cmpq   $0x0,-0x80(%rbp)
  jne    L149
L101:
  mov    $0x1,%eax
  mov    -0x38(%rbp),%rdx
  sub    %fs:0x28,%rdx
  je     L59
  call   <__stack_chk_fail@plt>
L59:
  lea    -0x28(%rbp),%rsp
  pop    %rbx
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  pop    %rbp
  ret
```

tool_calls: name: parse_data
arguments: data_label: D6
type_infered: string
name: parse_data
arguments: data_label: D4
type_infered: string
name: parse_data
arguments: data_label: D7
type_infered: string

tool: D6: PATH

tool: D4: :

tool: D7: /

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;
}
```