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

```asm
<is_input_valid>:
  endbr64
  test   %esi,%esi
  jle    L235
  mov    %rdi,%rcx
  movslq %esi,%r9
  xor    %eax,%eax
  xor    %r10d,%r10d
  xor    %r11d,%r11d
  xor    %edi,%edi
  xor    %r8d,%r8d
  sub    $0x1,%esi
L153:
  movzbl (%rcx,%rax,1),%edx
  cmp    $0x3e,%dl
  je     L35
  cmp    $0x3c,%dl
  je     L140
  push   %rbx
L182:
  cmp    $0x7c,%dl
  je     L139
  cmp    %eax,%esi
  je     L205
L129:
  add    $0x1,%rax
  cmp    %r9,%rax
  je     L263
  movzbl (%rcx,%rax,1),%edx
  cmp    $0x3e,%dl
  je     L56
  cmp    $0x3c,%dl
  jne    L182
  add    $0x1,%edi
  jmp    L129
  xchg   %ax,%ax
L140:
  add    $0x1,%edi
L22:
  add    $0x1,%rax
  cmp    %r9,%rax
  jne    L153
L235:
  mov    $0x1,%r8d
  jmp    L154
  nopl   0x0(%rax)
L56:
  test   %rax,%rax
  jne    L247
L309:
  xor    %r8d,%r8d
L200:
  mov    %r8d,%eax
  pop    %rbx
  ret
  nopl   0x0(%rax)
L139:
  add    $0x1,%r8d
  cmp    $0x1,%r10d
  setg   %dl
  cmp    $0x1,%r8d
  je     L1
  or     %r11d,%edi
  jne    L309
  test   %dl,%dl
  jne    L309
  xor    %r10d,%r10d
  xor    %r11d,%r11d
  xor    %edi,%edi
  jmp    L129
  nopl   0x0(%rax)
L35:
  test   %rax,%rax
  jne    L96
  xor    %r8d,%r8d
L154:
  mov    %r8d,%eax
  ret
  nopl   0x0(%rax)
L205:
  cmp    $0x1,%r10d
  setg   %bl
  cmp    $0x1,%r11d
  setg   %dl
  test   %r8d,%r8d
  je     L293
  or     %bl,%dl
  jne    L309
  test   %edi,%edi
  je     L129
  jmp    L309
  nopl   0x0(%rax)
L293:
  cmp    $0x1,%edi
  jg     L200
  or     %bl,%dl
  je     L129
  jmp    L200
  nop
L1:
  cmp    $0x1,%edi
  setg   %dil
  or     %dl,%dil
  jne    L309
  test   %r11d,%r11d
  jne    L309
  xor    %r10d,%r10d
  xor    %edi,%edi
  jmp    L129
L263:
  mov    $0x1,%r8d
  jmp    L200
L96:
  cmpb   $0x32,-0x1(%rcx,%rax,1)
  je     L226
  add    $0x1,%r11d
  jmp    L22
L247:
  cmpb   $0x32,-0x1(%rcx,%rax,1)
  je     L283
  add    $0x1,%r11d
  jmp    L129
L226:
  add    $0x1,%r10d
  jmp    L22
L283:
  add    $0x1,%r10d
  jmp    L129
```

assistant: ```c
int is_input_valid(char *buffer, int len_buffer) {
  int i = 0;
  int num_pipe = 0;
  int num_in = 0;
  int num_out = 0;
  int num_err = 0;
  for (i = 0; i < len_buffer; i++) {
    if (buffer[i] == '>') {
      if (i - 1 < 0) {
        return 0;
      }
      if (buffer[i - 1] == '2') {
        num_err++;
      } else {
        num_out++;
      }
    } else if (buffer[i] == '<') {
      num_in++;
    } else if (buffer[i] == '|') {
      num_pipe++;
      if (num_pipe == 1) {
        if (num_out)
          return 0;
        if (num_in > 1)
          return 0;
        if (num_err > 1)
          return 0;
      } else {
        if (num_out)
          return 0;
        if (num_in)
          return 0;
        if (num_err > 1)
          return 0;
      }
      num_out = 0;
      num_in = 0;
      num_err = 0;
    } else if (i == len_buffer - 1) {
      if (num_pipe) {
        if (num_out > 1)
          return 0;
        if (num_in)
          return 0;
        if (num_err > 1)
          return 0;
      } else {
        if (num_out > 1)
          return 0;
        if (num_in > 1)
          return 0;
        if (num_err > 1)
          return 0;
      }
    }
  }
  return 1;
}
```