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

```asm
<cmd_add>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x48,%rsp
  mov    %rdx,0x8(%rsp)
  mov    %fs:0x28,%rax
  mov    %rax,0x38(%rsp)
  xor    %eax,%eax
  movl   $0xffffffff,0x24(%rsp)
  movl   $0xffffffff,0x28(%rsp)
  movl   $0xffffffff,0x2c(%rsp)
  movl   $0xffffffff,0x30(%rsp)
  movl   $0xffffffff,0x34(%rsp)
  test   %edi,%edi
  js     L12
  lea    0x2c(%rsp),%r14
  lea    0x28(%rsp),%r15
  mov    %rsi,%r12
  lea    0x24(%rsp),%rbx
  sub    $0x8,%rsp
  mov    %r14,%r8
  mov    %r15,%rcx
  lea    0x3c(%rsp),%rax
  mov    %rbx,%rdx
  push   %rax
  lea    0x40(%rsp),%r9
  call   <check_option_add@plt>
  pop    %rsi
  pop    %rdi
  mov    0x30(%rsp),%r8d
  mov    %eax,%ebp
  test   %r8d,%r8d
  jns    L165
  mov    0x2c(%rsp),%eax
  mov    0x34(%rsp),%edx
  not    %eax
  not    %edx
  shr    $0x1f,%eax
  shr    $0x1f,%edx
  add    %edx,%eax
  cmp    %ebp,%eax
  jl     L69
  xor    %r13d,%r13d
L32:
  mov    %rbx,%r8
  mov    %r15,%rcx
  mov    %r14,%rdx
  mov    %r12,%rsi
  mov    %ebp,%edi
  call   <check_args@plt>
  test   %rax,%rax
  jne    L150
  push   0x8(%rsp)
  mov    %r12,%rsi
  mov    %ebp,%edi
  push   %r13
  mov    0x44(%rsp),%r9d
  mov    0x34(%rsp),%r8d
  mov    0x3c(%rsp),%ecx
  mov    0x38(%rsp),%edx
  call   <action_add@plt>
  pop    %rdx
  pop    %rcx
  mov    %eax,%r12d
  cmp    $0xffffffff,%eax
  je     L56
  mov    0x30(%rsp),%eax
  xor    %r12d,%r12d
  test   %eax,%eax
  js     L13
  mov    %r13,%rdi
  call   <free@plt>
L13:
  mov    0x38(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L147
  add    $0x48,%rsp
  mov    %r12d,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopl   0x0(%rax)
L165:
  mov    %eax,%edi
  call   <malloc@plt>
  lea    -0x1(%rbp),%r8d
  mov    %rax,%r13
  movslq 0x30(%rsp),%rax
  mov    %rax,%rcx
  shl    $0x3,%rax
  lea    (%r12,%rax,1),%rdi
  mov    (%rdi),%r9
  cmp    %r8d,%ecx
  jl     L74
  mov    0x2c(%rsp),%r11d
L97:
  mov    %r8d,%edi
  mov    %r11d,%ecx
  mov    %r9,%rdx
  mov    %r13,%rsi
  mov    %r8d,0x10(%rsp)
  call   <check_type_args@plt>
  mov    0x10(%rsp),%r8d
  test   %rax,%rax
  js     L11
  mov    %r8d,%ebp
  jmp    L32
  nopw   0x0(%rax,%rax,1)
L74:
  lea    0x1(%rcx),%edx
  cmp    %edx,%ebp
  jle    L146
  sub    %ecx,%ebp
  lea    0x8(%r12,%rax,1),%rsi
  mov    %r9,0x18(%rsp)
  lea    -0x2(%rbp),%edx
  mov    %r8d,0x14(%rsp)
  lea    0x8(,%rdx,8),%rdx
  mov    %ecx,0x10(%rsp)
  call   <memmove@plt>
  mov    0x10(%rsp),%ecx
  mov    0x14(%rsp),%r8d
  mov    0x18(%rsp),%r9
L146:
  mov    0x24(%rsp),%eax
  xor    %edx,%edx
  mov    0x2c(%rsp),%r11d
  cmp    %eax,%ecx
  setl   %dl
  sub    %edx,%eax
  xor    %edx,%edx
  mov    %eax,0x24(%rsp)
  mov    0x28(%rsp),%eax
  cmp    %eax,%ecx
  setl   %dl
  sub    %edx,%eax
  xor    %edx,%edx
  mov    %eax,0x28(%rsp)
  mov    0x34(%rsp),%eax
  cmp    %eax,%ecx
  setl   %dl
  sub    %edx,%eax
  mov    %eax,0x34(%rsp)
  xor    %eax,%eax
  cmp    %r11d,%ecx
  setl   %al
  sub    %eax,%r11d
  mov    %r11d,0x2c(%rsp)
  jmp    L97
L150:
  lea    D25(%rip),%rdi
  mov    $0xffffffff,%r12d
  call   <printf@plt>
  jmp    L13
L12:
  lea    D6(%rip),%rdi
  mov    $0xffffffff,%r12d
  call   <printf@plt>
  jmp    L13
L69:
  lea    D22(%rip),%rdi
  mov    $0xffffffff,%r12d
  call   <printf@plt>
  jmp    L13
L56:
  lea    D20(%rip),%rdi
  call   <printf@plt>
  jmp    L13
L11:
  lea    D43(%rip),%rdi
  mov    $0xffffffff,%r12d
  call   <printf@plt>
  mov    %r13,%rdi
  call   <free@plt>
  jmp    L13
L147:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: retrieve_data
arguments: tag: D25
datatype: string
name: retrieve_data
arguments: tag: D6
datatype: string
name: retrieve_data
arguments: tag: D22
datatype: string
name: retrieve_data
arguments: tag: D20
datatype: string
name: retrieve_data
arguments: tag: D43
datatype: string

tool: D25: check path args failed


tool: D6: error no args for add


tool: D22: check_type_args failed


tool: D20: error action add


tool: D43: check_args_no_op failed


assistant: ```c
int cmd_add(int argc, char **argv, char *daz) {
  int f_date = -1, f_compound = -1, f_dz = -1, f_type = -1, f_input = -1;
  char *type_args = NULL;
  if (argc < 0) {
    printf("error no args for add\n");
    return -1;
  }
  argc = check_option_add(argc, argv, &f_date, &f_compound, &f_dz, &f_type, &f_input);
  if (f_type >= 0) {
    type_args = (char *)malloc(sizeof(*type_args) * argc);
    char *tmp = argv[f_type];
    if (f_type < (argc - 1)) {
      int i;
      for (i = (f_type + 1); i < (argc); i++) {
        argv[i - 1] = argv[i];
      }
      f_date = (f_date > f_type ? f_date - 1 : f_date);
      f_compound = (f_compound > f_type ? f_compound - 1 : f_compound);
      f_input = (f_input > f_type ? f_input - 1 : f_input);
      f_dz = (f_dz > f_type ? f_dz - 1 : f_dz);
    }
    argc--;
    if (check_type_args(argc, type_args, tmp, f_dz) < 0) {
      printf("check_args_no_op failed\n");
      free(type_args);
      return -1;
    }
  } else if (argc > (f_dz >= 0 ? 1 : 0) + (f_input >= 0 ? 1 : 0)) {
    printf("check_type_args failed\n");
    return -1;
  }
  if (check_args(argc, argv, &f_dz, &f_compound, &f_date)) {
    printf("check path args failed\n");
    return -1;
  }
  if (action_add(argc, argv, f_compound, f_dz, f_date, f_input, type_args, daz) == -1) {
    printf("error action add\n");
    return -1;
  }
  if (f_type >= 0) {
    free(type_args);
  }
  return 0;
}
```