user: Please show me the C implementation that matches the assembly code listed below:

```asm
<main>:
  endbr64
  push   %r15
  push   %r14
  mov    %rsi,%r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x28,%rsp
  cmp    $0x1,%edi
  jle    L172
  movb   $0x0,0x1f(%rsp)
  mov    %edi,%ebx
  mov    $0x1,%ebp
  xor    %r15d,%r15d
  movq   $0x0,0x10(%rsp)
  jmp    L39
  nopl   0x0(%rax,%rax,1)
L30:
  mov    (%r14),%rdi
  lea    0x1(%rbp),%r12d
  call   <print_usage@plt>
L123:
  mov    %r12d,%ebp
  cmp    %r12d,%ebx
  jle    L63
L39:
  movslq %ebp,%rcx
  shl    $0x3,%rcx
  lea    (%r14,%rcx,1),%r13
  mov    0x0(%r13),%rdi
  cmpb   $0x2d,(%rdi)
  je     L98
  test   %r15,%r15
  jne    L30
  lea    0x1(%rbp),%r12d
  mov    %rdi,%r15
  mov    %r12d,%ebp
  cmp    %r12d,%ebx
  jg     L39
L63:
  test   %r15,%r15
  je     L46
L144:
  mov    %r15,%rdi
  call   <strlen@plt>
  cltq
  cmpb   $0x2f,-0x1(%r15,%rax,1)
  je     L6
L45:
  movsbl 0x1f(%rsp),%edx
  mov    0x10(%rsp),%rsi
  mov    %r15,%rdi
  call   <searchdir@plt>
  add    $0x28,%rsp
  xor    %eax,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  xchg   %ax,%ax
L98:
  lea    D12(%rip),%rsi
  mov    %rcx,0x8(%rsp)
  lea    0x1(%rbp),%r12d
  call   <strcmp@plt>
  mov    0x8(%rsp),%rcx
  test   %rax,%rax
  jne    L102
  lea    -0x1(%rbx),%eax
  cmp    %ebp,%eax
  jle    L48
  mov    0x8(%r14,%rcx,1),%rax
  lea    0x2(%rbp),%r12d
  mov    %rax,0x10(%rsp)
  jmp    L123
L102:
  mov    0x0(%r13),%rdi
  lea    D26(%rip),%rsi
  mov    %rcx,0x8(%rsp)
  call   <strcmp@plt>
  test   %rax,%rax
  jne    L20
  lea    -0x1(%rbx),%eax
  cmp    %ebp,%eax
  jg     L66
L48:
  mov    0x0(%r13),%rsi
  lea    D40(%rip),%rdi
  call   <usage_error@plt>
  jmp    L123
L6:
  mov    %r15,%rdi
  call   <strlen@plt>
  cltq
  movb   $0x0,-0x1(%r15,%rax,1)
  jmp    L45
L66:
  mov    0x8(%rsp),%rcx
  lea    0x8(%r14,%rcx,1),%r12
  mov    (%r12),%rdi
  call   <validate_type@plt>
  test   %rax,%rax
  je     L171
  mov    (%r12),%rax
  lea    0x2(%rbp),%r12d
  movzbl (%rax),%eax
  mov    %al,0x1f(%rsp)
  jmp    L123
L20:
  mov    0x0(%r13),%rsi
  lea    D42(%rip),%rdi
  call   <usage_error@plt>
  jmp    L123
L172:
  movb   $0x0,0x1f(%rsp)
  movq   $0x0,0x10(%rsp)
L46:
  mov    (%r14),%rdi
  xor    %r15d,%r15d
  call   <print_usage@plt>
  jmp    L144
L171:
  mov    (%r12),%rsi
  lea    D34(%rip),%rdi
  lea    0x2(%rbp),%r12d
  call   <usage_error@plt>
  jmp    L123
```

tool_calls: name: read_data
arguments: tag: D12
data_type: string
name: read_data
arguments: tag: D26
data_type: string
name: read_data
arguments: tag: D40
data_type: string
name: read_data
arguments: tag: D42
data_type: string
name: read_data
arguments: tag: D34
data_type: string

tool: D12: -name

tool: D26: -type

tool: D40: missing argument to `%s'

tool: D42: invalid predicate `%s'

tool: D34: invalid argument `%s' to `-type'

assistant: ```c
int main(int argc, char *argv[]) {
  char *dirname = NULL;
  char *findme = NULL;
  char type = '\0';
  for (int i = 1; i < argc; i++) {
    if (argv[i][0] == '-') {
      if (strcmp(argv[i], "-name") == 0) {
        if (i + 1 <= argc - 1) {
          i++;
          findme = argv[i];
        } else
          usage_error("missing argument to `%s'", argv[i]);
      } else if (strcmp(argv[i], "-type") == 0) {
        if (i + 1 <= argc - 1) {
          i++;
          if (validate_type(argv[i]))
            type = argv[i][0];
          else
            usage_error("invalid argument `%s' to `-type'", argv[i]);
        } else
          usage_error("missing argument to `%s'", argv[i]);
      } else
        usage_error("invalid predicate `%s'", argv[i]);
    } else {
      if (dirname)
        print_usage(argv[0]);
      else
        dirname = argv[i];
    }
  }
  if (!dirname)
    print_usage(argv[0]);
  if (dirname[strlen(dirname) - 1] == '/')
    dirname[strlen(dirname) - 1] = '\0';
  searchdir(dirname, findme, type);
}
```