user: Converte this assembly snippet into its equivalent C code:

```asm
<main>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x240,%rsp
  mov    %edi,-0x234(%rbp)
  mov    %rsi,-0x240(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x8(%rbp)
  xor    %eax,%eax
  movl   $0x0,-0x220(%rbp)
  movl   $0x0,-0x21c(%rbp)
  cmpl   $0x2,-0x234(%rbp)
  jg     L142
  lea    D0(%rip),%rax
  mov    %rax,%rdi
  call   <puts@plt>
  lea    D31(%rip),%rax
  mov    %rax,%rdi
  call   <puts@plt>
  mov    $0x1,%eax
  jmp    L27
L142:
  mov    -0x234(%rbp),%eax
  cltq
  shl    $0x3,%rax
  lea    -0x8(%rax),%rdx
  mov    -0x240(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%rax
  lea    -0x224(%rbp),%rdx
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <stat@plt>
  test   %rax,%rax
  jne    L113
  movl   $0x1,-0x220(%rbp)
  mov    -0x224(%rbp),%eax
  and    $0x4000,%eax
  test   %eax,%eax
  je     L113
  movl   $0x1,-0x21c(%rbp)
L113:
  cmpl   $0x3,-0x234(%rbp)
  jle    L84
  cmpl   $0x0,-0x220(%rbp)
  je     L66
  cmpl   $0x0,-0x21c(%rbp)
  jne    L84
L66:
  mov    -0x234(%rbp),%eax
  cltq
  shl    $0x3,%rax
  lea    -0x8(%rax),%rdx
  mov    -0x240(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%rax
  mov    %rax,%rsi
  lea    D47(%rip),%rax
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  mov    $0x1,%eax
  jmp    L27
L84:
  movl   $0x1,-0x218(%rbp)
  jmp    L54
L52:
  mov    -0x218(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x240(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%rax
  lea    -0x224(%rbp),%rdx
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <stat@plt>
  test   %rax,%rax
  jns    L148
  mov    -0x218(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x240(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%rax
  mov    %rax,%rsi
  lea    D7(%rip),%rax
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  addl   $0x1,-0x214(%rbp)
  jmp    L99
L148:
  mov    -0x234(%rbp),%eax
  cltq
  shl    $0x3,%rax
  lea    -0x8(%rax),%rdx
  mov    -0x240(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%rcx
  lea    -0x210(%rbp),%rax
  mov    $0x1ff,%edx
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <strncpy@plt>
  cmpl   $0x0,-0x21c(%rbp)
  je     L26
  lea    -0x210(%rbp),%rax
  mov    %rax,%rdi
  call   <strlen@plt>
  mov    %eax,%edx
  mov    $0x1ff,%eax
  sub    %edx,%eax
  mov    %eax,%edx
  lea    -0x210(%rbp),%rax
  lea    D35(%rip),%rcx
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <strncat@plt>
  lea    -0x210(%rbp),%rax
  mov    %rax,%rdi
  call   <strlen@plt>
  mov    %eax,%edx
  mov    $0x1ff,%eax
  sub    %edx,%eax
  mov    %eax,%edx
  mov    -0x218(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rcx
  mov    -0x240(%rbp),%rax
  add    %rcx,%rax
  mov    (%rax),%rcx
  lea    -0x210(%rbp),%rax
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <strncat@plt>
L26:
  mov    -0x218(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x240(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%rax
  lea    -0x210(%rbp),%rdx
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <rename@plt>
  test   %rax,%rax
  jns    L99
  addl   $0x1,-0x214(%rbp)
L99:
  addl   $0x1,-0x218(%rbp)
L54:
  mov    -0x234(%rbp),%eax
  sub    $0x1,%eax
  cmp    %eax,-0x218(%rbp)
  jl     L52
  mov    -0x214(%rbp),%eax
L27:
  mov    -0x8(%rbp),%rdx
  sub    %fs:0x28,%rdx
  je     L149
  call   <__stack_chk_fail@plt>
L149:
  leave
  ret
```

tool_calls: name: read_data
arguments: tag: D0
type_infered: string
name: read_data
arguments: tag: D31
type_infered: string
name: read_data
arguments: tag: D47
type_infered: string
name: read_data
arguments: tag: D7
type_infered: string
name: read_data
arguments: tag: D35
type_infered: string

tool: D0: mv: file1 file.. dest dir

tool: D31: mv: file1 file2

tool: D47: mv: for multiple files, dest %s should be a directory


tool: D7: mv: cannot stat %s


tool: D35: /

assistant: ```c
int main(int argc, char *argv[]) {
  struct stat st;
  int dst_exists = 0, dst_isdir = 0;
  int i, err;
  char buf[512];
  if (argc < 3) {
    printf("mv: file1 file.. dest dir\n");
    printf("mv: file1 file2\n");
    return 1;
  }
  if (stat(argv[argc - 1], &st) == 0) {
    dst_exists = 1;
    if (st.st_mode & 0040000)
      dst_isdir = 1;
  }
  if (argc > 3 && (!dst_exists || !dst_isdir)) {
    printf("mv: for multiple files, dest %s should be a directory\n", argv[argc - 1]);
    return 1;
  }
  for (i = 1; i < argc - 1; i++) {
    if (stat(argv[i], &st) < 0) {
      printf("mv: cannot stat %s\n", argv[i]);
      err++;
      continue;
    }
    strncpy(buf, argv[argc - 1], sizeof(buf) - 1);
    if (dst_isdir) {
      strncat(buf, "/", sizeof(buf) - strlen(buf) - 1);
      strncat(buf, argv[i], sizeof(buf) - strlen(buf) - 1);
    }
    if (rename(argv[i], buf) < 0)
      err++;
  }
  return err;
}
```