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

```asm
<checkCmdValidAndGetTotalLen>:
  endbr64
  cmp    $0x5,%edi
  ja     L197
  push   %r15
  mov    %edi,%edi
  push   %r14
  mov    %rcx,%r14
  push   %r13
  mov    %esi,%r13d
  push   %r12
  movslq %edx,%r12
  lea    D35(%rip),%rdx
  push   %rbp
  mov    %r8,%rbp
  push   %rbx
  sub    $0x18,%rsp
  movslq (%rdx,%rdi,4),%rax
  add    %rdx,%rax
  notrack jmp *%rax
  nopw   0x0(%rax,%rax,1)
  lea    -0x2(%r12),%eax
  cmp    $0x1,%eax
  ja     L414
  test   %esi,%esi
  je     L134
  test   %r8,%r8
  je     L568
  mov    (%r8),%eax
  mov    0x8(%r8),%r15d
  lea    0x1(%rax),%ebx
L85:
  add    %ebx,%r15d
  mov    %r15d,%ebx
  cmp    $0x3,%r12d
  je     L462
L611:
  lea    0x2(%rbx),%eax
L604:
  add    $0x18,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopl   0x0(%rax,%rax,1)
  lea    -0x6(%r12),%eax
  cmp    $0x1,%eax
  ja     L414
  cmp    $0x7,%r12d
  je     L296
L553:
  xor    %ecx,%ecx
  cmp    $0x6,%r12d
  setne  %cl
  xor    %r15d,%r15d
  xor    %edx,%edx
  add    $0x5,%ecx
  jmp    L546
  nopl   0x0(%rax,%rax,1)
L490:
  test   %rbp,%rbp
  je     L475
  mov    0x0(%rbp,%r15,8),%rax
  lea    0x1(%rax),%rbx
L174:
  add    %edx,%ebx
  add    $0x1,%r15
  mov    %ebx,%edx
  cmp    %r15d,%ecx
  jle    L261
L546:
  test   %r13d,%r13d
  jne    L490
  mov    (%r14,%r15,8),%rdi
  mov    %ecx,0x8(%rsp)
  add    $0x1,%r15
  mov    %edx,(%rsp)
  call   <sdslen@plt>
  mov    (%rsp),%edx
  mov    0x8(%rsp),%ecx
  lea    0x1(%rax),%rbx
  add    %edx,%ebx
  mov    %ebx,%edx
  cmp    %r15d,%ecx
  jg     L546
  nopl   0x0(%rax)
L261:
  shl    $0x3,%r12
  test   %r13d,%r13d
  je     L344
  test   %rbp,%rbp
  je     L228
  mov    -0x8(%rbp,%r12,1),%rax
  add    $0x4,%rax
  add    %ebx,%eax
L128:
  add    $0x18,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  cmp    $0x1,%r12d
  jle    L414
  lea    -0x1(%r12),%eax
  xor    %edx,%edx
  xor    %r15d,%r15d
  mov    %rax,(%rsp)
  jmp    L315
  nopw   0x0(%rax,%rax,1)
L489:
  test   %rbp,%rbp
  je     L89
  mov    0x0(%rbp,%rdx,8),%rax
  lea    0x1(%rax),%rbx
L502:
  add    %r15d,%ebx
  add    $0x1,%rdx
  mov    %ebx,%r15d
  cmp    %rdx,(%rsp)
  je     L581
L315:
  test   %r13d,%r13d
  jne    L489
  mov    (%r14,%rdx,8),%rdi
  mov    %rdx,0x8(%rsp)
  call   <sdslen@plt>
  mov    0x8(%rsp),%rdx
  lea    0x1(%rax),%rbx
  add    %r15d,%ebx
  add    $0x1,%rdx
  mov    %ebx,%r15d
  cmp    %rdx,(%rsp)
  jne    L315
L581:
  shl    $0x3,%r12
  test   %r13d,%r13d
  je     L560
  test   %rbp,%rbp
  je     L384
  mov    -0x8(%rbp,%r12,1),%rax
  add    $0x2,%rax
  add    %ebx,%eax
  jmp    L128
  nopl   0x0(%rax)
  cmp    $0x3,%r12d
  jne    L414
  test   %esi,%esi
  je     L104
  test   %r8,%r8
  je     L599
  mov    0x8(%r8),%rbx
  mov    0x10(%r8),%eax
  add    (%r8),%ebx
  add    $0x1,%ebx
L6:
  add    $0x18,%rsp
  lea    0x3(%rax,%rbx,1),%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopl   0x0(%rax)
  lea    -0x7(%r12),%eax
  cmp    $0x1,%eax
  ja     L414
  cmp    $0x8,%r12d
  je     L511
L338:
  xor    %ecx,%ecx
  cmp    $0x7,%r12d
  setne  %cl
  xor    %r15d,%r15d
  xor    %edx,%edx
  add    $0x6,%ecx
  jmp    L25
  nopl   0x0(%rax,%rax,1)
L459:
  test   %rbp,%rbp
  je     L101
  mov    0x0(%rbp,%r15,8),%rax
  lea    0x1(%rax),%rbx
L103:
  add    %edx,%ebx
  add    $0x1,%r15
  mov    %ebx,%edx
  cmp    %r15d,%ecx
  jle    L261
L25:
  test   %r13d,%r13d
  jne    L459
  mov    (%r14,%r15,8),%rdi
  mov    %ecx,0x8(%rsp)
  mov    %edx,(%rsp)
  call   <sdslen@plt>
  mov    (%rsp),%edx
  mov    0x8(%rsp),%ecx
  lea    0x1(%rax),%rbx
  jmp    L103
  nopl   0x0(%rax)
L89:
  mov    (%r14,%rdx,8),%rdi
  mov    %rdx,0x8(%rsp)
  call   <strlen@plt>
  mov    0x8(%rsp),%rdx
  lea    0x1(%rax),%rbx
  jmp    L502
  nopl   0x0(%rax)
L101:
  mov    (%r14,%r15,8),%rdi
  mov    %ecx,0x8(%rsp)
  mov    %edx,(%rsp)
  call   <strlen@plt>
  mov    (%rsp),%edx
  mov    0x8(%rsp),%ecx
  lea    0x1(%rax),%rbx
  jmp    L103
  nopl   (%rax)
L475:
  mov    (%r14,%r15,8),%rdi
  mov    %ecx,0x8(%rsp)
  mov    %edx,(%rsp)
  call   <strlen@plt>
  mov    (%rsp),%edx
  mov    0x8(%rsp),%ecx
  lea    0x1(%rax),%rbx
  jmp    L174
L344:
  mov    -0x8(%r14,%r12,1),%rdi
  call   <sdslen@plt>
  add    $0x4,%rax
  add    %ebx,%eax
  jmp    L128
  nopl   (%rax)
L228:
  mov    -0x8(%r14,%r12,1),%rdi
  call   <strlen@plt>
  add    $0x4,%rax
  add    %ebx,%eax
  jmp    L128
  nopl   (%rax)
L511:
  test   %esi,%esi
  je     L305
  test   %r8,%r8
  je     L666
  cmpq   $0x7,0x30(%r8)
  jne    L414
L129:
  mov    0x30(%r14),%rdi
L545:
  mov    $0x7,%edx
  lea    D11(%rip),%rsi
  call   <strncasecmp@plt>
  test   %eax,%eax
  je     L338
  jmp    L414
  nopw   0x0(%rax,%rax,1)
L296:
  test   %esi,%esi
  je     L658
  test   %r8,%r8
  je     L570
  cmpq   $0x7,0x28(%r8)
  jne    L414
L190:
  mov    0x28(%r14),%rdi
L647:
  mov    $0x7,%edx
  lea    D11(%rip),%rsi
  call   <strncasecmp@plt>
  test   %eax,%eax
  je     L553
  nopl   (%rax)
L414:
  mov    $0xffffffff,%eax
  jmp    L604
  nopw   0x0(%rax,%rax,1)
L560:
  mov    -0x8(%r14,%r12,1),%rdi
  call   <sdslen@plt>
  add    $0x2,%rax
  add    %ebx,%eax
  jmp    L128
  nopl   (%rax)
L134:
  mov    (%rcx),%rdi
  call   <sdslen@plt>
  mov    0x8(%r14),%rdi
  lea    0x1(%rax),%ebx
  call   <sdslen@plt>
  mov    %eax,%r15d
  jmp    L85
  nopl   0x0(%rax)
L104:
  mov    (%rcx),%rdi
  call   <sdslen@plt>
  mov    0x8(%r14),%rdi
  mov    %rax,%rbx
  call   <sdslen@plt>
  mov    0x10(%r14),%rdi
  lea    0x1(%rbx,%rax,1),%ebx
  call   <sdslen@plt>
  jmp    L6
  cs nopw 0x0(%rax,%rax,1)
L658:
  mov    0x28(%rcx),%rdi
  call   <sdslen@plt>
  cmp    $0x7,%rax
  je     L190
  jmp    L414
  nopl   0x0(%rax,%rax,1)
L305:
  mov    0x30(%rcx),%rdi
  call   <sdslen@plt>
  cmp    $0x7,%rax
  je     L129
  jmp    L414
  nopl   0x0(%rax,%rax,1)
L462:
  mov    0x10(%r14),%rdi
  mov    $0x7,%edx
  lea    D11(%rip),%rsi
  call   <strncasecmp@plt>
  test   %eax,%eax
  jne    L414
  test   %r13d,%r13d
  je     L514
  test   %rbp,%rbp
  je     L453
  mov    0x10(%rbp),%rbx
  add    $0x1,%rbx
L260:
  add    %r15d,%ebx
  jmp    L611
  nop
L384:
  mov    -0x8(%r14,%r12,1),%rdi
  call   <strlen@plt>
  add    $0x2,%rax
  add    %ebx,%eax
  jmp    L128
  nopl   (%rax)
L568:
  mov    (%rcx),%rdi
  call   <strlen@plt>
  mov    0x8(%r14),%rdi
  lea    0x1(%rax),%ebx
  call   <strlen@plt>
  mov    %eax,%r15d
  jmp    L85
  nopl   0x0(%rax)
L599:
  mov    (%rcx),%rdi
  call   <strlen@plt>
  mov    0x8(%r14),%rdi
  mov    %rax,%rbx
  call   <strlen@plt>
  mov    0x10(%r14),%rdi
  lea    0x1(%rbx,%rax,1),%ebx
  call   <strlen@plt>
  jmp    L6
L570:
  mov    0x28(%rcx),%rdi
  mov    %rdi,(%rsp)
  call   <strlen@plt>
  mov    (%rsp),%rdi
  cmp    $0x7,%rax
  je     L647
  jmp    L414
  xchg   %ax,%ax
L666:
  mov    0x30(%rcx),%rdi
  mov    %rdi,(%rsp)
  call   <strlen@plt>
  mov    (%rsp),%rdi
  cmp    $0x7,%rax
  je     L545
  jmp    L414
L514:
  mov    0x10(%r14),%rdi
  call   <sdslen@plt>
  lea    0x1(%rax),%rbx
  jmp    L260
L453:
  mov    0x10(%r14),%rdi
  call   <strlen@plt>
  lea    0x1(%rax),%rbx
  jmp    L260
L197:
  or     $0xffffffff,%eax
  ret
```

tool_calls: name: retrieve_data
arguments: data_label: D11
type_infered: string

tool: D11: noreply

assistant: ```c
int checkCmdValidAndGetTotalLen(int cmdtype, int argtype, int argc, char **argv, size_t *argvlen) {
  size_t len;
  int totlen, j;
  switch (cmdtype) {
  case 1:
    if (argc != 6 && argc != 7) {
      return -1;
    }
    if (argc == 7 && ((argtype == 0 ? sdslen(argv[5]) : (argvlen == NULL ? strlen(argv[5]) : argvlen[5])) != 7 || strncasecmp(argv[5], "noreply", 7))) {
      return -1;
    }
    totlen = 0;
    for (j = 0; j < argc - 1; j++) {
      totlen += (argtype == 0 ? sdslen(argv[j]) : (argvlen == NULL ? strlen(argv[j]) : argvlen[j])) + 1;
    }
    totlen += 2 + (argtype == 0 ? sdslen(argv[argc - 1]) : (argvlen == NULL ? strlen(argv[argc - 1]) : argvlen[argc - 1])) + 2;
    break;
  case 2:
    if (argc != 7 && argc != 8) {
      return -1;
    }
    if (argc == 8 && ((argtype == 0 ? sdslen(argv[6]) : (argvlen == NULL ? strlen(argv[6]) : argvlen[6])) != 7 || strncasecmp(argv[6], "noreply", 7))) {
      return -1;
    }
    totlen = 0;
    for (j = 0; j < argc - 1; j++) {
      totlen += (argtype == 0 ? sdslen(argv[j]) : (argvlen == NULL ? strlen(argv[j]) : argvlen[j])) + 1;
    }
    totlen += 2 + (argtype == 0 ? sdslen(argv[argc - 1]) : (argvlen == NULL ? strlen(argv[argc - 1]) : argvlen[argc - 1])) + 2;
    break;
  case 4:
    if (argc != 3) {
      return -1;
    }
    totlen = (argtype == 0 ? sdslen(argv[0]) : (argvlen == NULL ? strlen(argv[0]) : argvlen[0])) + 1 + (argtype == 0 ? sdslen(argv[1]) : (argvlen == NULL ? strlen(argv[1]) : argvlen[1])) + 1 + (argtype == 0 ? sdslen(argv[2]) : (argvlen == NULL ? strlen(argv[2]) : argvlen[2])) + 2;
    break;
  case 3:
    if (argc <= 1) {
      return -1;
    }
    totlen = 0;
    for (j = 0; j < argc - 1; j++) {
      totlen += (argtype == 0 ? sdslen(argv[j]) : (argvlen == NULL ? strlen(argv[j]) : argvlen[j])) + 1;
    }
    totlen += (argtype == 0 ? sdslen(argv[argc - 1]) : (argvlen == NULL ? strlen(argv[argc - 1]) : argvlen[argc - 1])) + 2;
    break;
  case 5:
    if (argc != 2 && argc != 3) {
      return -1;
    }
    totlen = (argtype == 0 ? sdslen(argv[0]) : (argvlen == NULL ? strlen(argv[0]) : argvlen[0])) + 1 + (argtype == 0 ? sdslen(argv[1]) : (argvlen == NULL ? strlen(argv[1]) : argvlen[1]));
    if (argc == 3) {
      if (strncasecmp(argv[2], "noreply", 7)) {
        return -1;
      }
      totlen += 1 + (argtype == 0 ? sdslen(argv[2]) : (argvlen == NULL ? strlen(argv[2]) : argvlen[2]));
    }
    totlen += 2;
    break;
  default:
    totlen = -1;
    break;
  }
  return totlen;
}
```