user: What is the c source code of the assembly code below?

```asm
<redirect>:
  endbr64
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  mov    (%rdi),%rbx
  test   %rbx,%rbx
  je     L53
  mov    %rdi,%rbp
  xor    %r13d,%r13d
  jmp    L198
  nopl   0x0(%rax)
L127:
  cmp    $0x3e,%dil
  je     L119
  call   <isdigit@plt>
  test   %rax,%rax
  je     L63
  cmpb   $0x3e,0x1(%rbx)
  je     L71
L63:
  mov    0x8(%rbp),%rbx
  add    $0x8,%rbp
  test   %rbx,%rbx
  je     L53
L198:
  movsbl (%rbx),%edi
  cmp    $0x3c,%dil
  jne    L127
  mov    D9(%rip),%rax
  lea    0x1(%rbx),%rdi
  xor    %r14d,%r14d
  mov    (%rax),%esi
  xor    %eax,%eax
  call   <open@plt>
  mov    %eax,%r12d
L91:
  test   %r12d,%r12d
  jne    L191
L123:
  mov    0x0(%rbp),%rdi
  add    $0x8,%rbp
  call   <free@plt>
  movq   $0x0,-0x8(%rbp)
  mov    0x0(%rbp),%rbx
  test   %rbx,%rbx
  jne    L198
L53:
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  ret
  cs nopw 0x0(%rax,%rax,1)
L119:
  movzbl 0x1(%rbx),%eax
  lea    0x1(%rbx),%r12
  mov    $0x1,%r14d
  cmp    $0x3e,%al
  je     L200
L40:
  cmp    $0x26,%al
  je     L130
L83:
  mov    D41(%rip),%rax
  mov    %r12,%rdi
  mov    $0x1a4,%edx
  mov    (%rax),%esi
  mov    D40(%rip),%rax
  or     (%rax),%esi
  mov    D26(%rip),%rax
  or     (%rax),%esi
  xor    %eax,%eax
  call   <open@plt>
  mov    %eax,%r12d
  test   %r12d,%r12d
  je     L123
L191:
  mov    %r14d,%esi
  mov    %r12d,%edi
  call   <dup2@plt>
  test   %r13d,%r13d
  je     L73
L107:
  mov    $0x1,%r13d
  jmp    L123
  nopw   0x0(%rax,%rax,1)
L200:
  mov    D41(%rip),%rax
  lea    0x2(%rbx),%rdi
  mov    $0x1a4,%edx
  mov    (%rax),%esi
  mov    D40(%rip),%rax
  or     (%rax),%esi
  mov    D16(%rip),%rax
  or     (%rax),%esi
  xor    %eax,%eax
  call   <open@plt>
  mov    %eax,%r12d
  jmp    L91
  nopl   0x0(%rax,%rax,1)
L73:
  mov    %r12d,%edi
  call   <close@plt>
  jmp    L123
  nopl   (%rax)
L71:
  movsbl (%rbx),%r14d
  sub    $0x30,%r14d
  js     L63
  movzbl 0x2(%rbx),%eax
  lea    0x2(%rbx),%r12
  jmp    L40
  nopl   0x0(%rax,%rax,1)
L130:
  movsbl 0x1(%r12),%edi
  call   <isdigit@plt>
  test   %rax,%rax
  je     L83
  cmpb   $0x0,0x2(%r12)
  jne    L83
  movsbl 0x1(%r12),%edi
  sub    $0x30,%edi
  je     L107
  mov    %r14d,%esi
  call   <dup2@plt>
  jmp    L107
```

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