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

```asm
<redirect>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x30,%rsp
  mov    %rdi,-0x28(%rbp)
  movl   $0x0,-0xc(%rbp)
  jmp    L105
L213:
  movl   $0x1,-0x10(%rbp)
  movl   $0xffffffff,-0x18(%rbp)
  mov    -0x8(%rbp),%rax
  movzbl (%rax),%eax
  cmp    $0x3c,%al
  jne    L102
  movl   $0x0,-0x18(%rbp)
  movl   $0x0,-0x10(%rbp)
  addq   $0x1,-0x8(%rbp)
  jmp    L84
L102:
  mov    -0x8(%rbp),%rax
  movzbl (%rax),%eax
  cmp    $0x3e,%al
  jne    L14
  mov    -0x8(%rbp),%rax
  add    $0x1,%rax
  movzbl (%rax),%eax
  cmp    $0x3e,%al
  jne    L14
  movl   $0x1,-0x18(%rbp)
  movl   $0x2,-0x10(%rbp)
  addq   $0x2,-0x8(%rbp)
  jmp    L84
L14:
  mov    -0x8(%rbp),%rax
  movzbl (%rax),%eax
  cmp    $0x3e,%al
  jne    L126
  movl   $0x1,-0x18(%rbp)
  addq   $0x1,-0x8(%rbp)
  jmp    L84
L126:
  mov    -0x8(%rbp),%rax
  movzbl (%rax),%eax
  movsbl %al,%eax
  mov    %eax,%edi
  call   <isdigit@plt>
  test   %rax,%rax
  je     L84
  mov    -0x8(%rbp),%rax
  add    $0x1,%rax
  movzbl (%rax),%eax
  cmp    $0x3e,%al
  jne    L84
  mov    -0x8(%rbp),%rax
  movzbl (%rax),%eax
  movsbl %al,%eax
  sub    $0x30,%eax
  mov    %eax,-0x18(%rbp)
  addq   $0x2,-0x8(%rbp)
L84:
  cmpl   $0x0,-0x18(%rbp)
  js     L3
  cmpl   $0x1,-0x10(%rbp)
  jne    L229
  mov    -0x8(%rbp),%rax
  movzbl (%rax),%eax
  cmp    $0x26,%al
  jne    L229
  mov    -0x8(%rbp),%rax
  add    $0x1,%rax
  movzbl (%rax),%eax
  movsbl %al,%eax
  mov    %eax,%edi
  call   <isdigit@plt>
  test   %rax,%rax
  je     L229
  mov    -0x8(%rbp),%rax
  add    $0x2,%rax
  movzbl (%rax),%eax
  test   %al,%al
  jne    L229
  mov    -0x8(%rbp),%rax
  add    $0x1,%rax
  movzbl (%rax),%eax
  movsbl %al,%eax
  sub    $0x30,%eax
  mov    %eax,-0x14(%rbp)
  movl   $0x1,-0xc(%rbp)
  jmp    L72
L229:
  cmpl   $0x2,-0x10(%rbp)
  jne    L2
  mov    D68(%rip),%rax
  mov    (%rax),%edx
  mov    D55(%rip),%rax
  mov    (%rax),%eax
  or     %eax,%edx
  mov    D22(%rip),%rax
  mov    (%rax),%eax
  mov    %edx,%ecx
  or     %eax,%ecx
  mov    -0x8(%rbp),%rax
  mov    $0x1a4,%edx
  mov    %ecx,%esi
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <open@plt>
  mov    %eax,-0x14(%rbp)
  jmp    L72
L2:
  cmpl   $0x0,-0x10(%rbp)
  je     L36
  mov    D68(%rip),%rax
  mov    (%rax),%edx
  mov    D55(%rip),%rax
  mov    (%rax),%eax
  or     %eax,%edx
  mov    D46(%rip),%rax
  mov    (%rax),%eax
  mov    %edx,%ecx
  or     %eax,%ecx
  mov    -0x8(%rbp),%rax
  mov    $0x1a4,%edx
  mov    %ecx,%esi
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <open@plt>
  jmp    L58
L36:
  mov    D63(%rip),%rax
  mov    (%rax),%edx
  mov    -0x8(%rbp),%rax
  mov    %edx,%esi
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <open@plt>
L58:
  mov    %eax,-0x14(%rbp)
L72:
  cmpl   $0x0,-0x14(%rbp)
  je     L16
  mov    -0x18(%rbp),%edx
  mov    -0x14(%rbp),%eax
  mov    %edx,%esi
  mov    %eax,%edi
  call   <dup2@plt>
  cmpl   $0x0,-0xc(%rbp)
  jne    L16
  mov    -0x14(%rbp),%eax
  mov    %eax,%edi
  call   <close@plt>
L16:
  mov    -0x28(%rbp),%rax
  mov    (%rax),%rax
  mov    %rax,%rdi
  call   <free@plt>
  mov    -0x28(%rbp),%rax
  movq   $0x0,(%rax)
L3:
  addq   $0x8,-0x28(%rbp)
L105:
  mov    -0x28(%rbp),%rax
  mov    (%rax),%rax
  mov    %rax,-0x8(%rbp)
  cmpq   $0x0,-0x8(%rbp)
  jne    L213
  nop
  nop
  leave
  ret
```

assistant: ```c
void redirect(char **args) {
  char *s;
  int fd, new_fd, io;
  int noclose = 0;
  for (; (s = *args); args++) {
    io = 1;
    fd = -1;
    if (*s == '<') {
      fd = 0;
      io = 0;
      s++;
    } else if (*s == '>' && s[1] == '>') {
      fd = 1;
      io = 2;
      s += 2;
    } else if (*s == '>') {
      fd = 1;
      s++;
    } else if (isdigit(*s) && s[1] == '>') {
      fd = *s - '0';
      s += 2;
    }
    if (fd >= 0) {
      if (io == 1 && *s == '&' && isdigit(s[1]) && !s[2]) {
        new_fd = s[1] - '0';
        noclose = 1;
      } else {
        if (io == 2) {
          new_fd = open(s, O_CREAT | O_WRONLY | O_APPEND, 0644);
        } else {
          new_fd = io ? open(s, O_CREAT | O_WRONLY | O_TRUNC, 0644) : open(s, O_RDONLY);
        }
      }
      if (new_fd) {
        dup2(new_fd, fd);
        if (!noclose)
          close(new_fd);
      }
      free(*args);
      *args = NULL;
    }
  }
}
```