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

```asm
<genericMemcachedCommand>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x40,%rsp
  mov    %edi,-0x14(%rbp)
  mov    %rsi,-0x20(%rbp)
  mov    %edx,-0x18(%rbp)
  mov    %ecx,-0x24(%rbp)
  mov    %r8,-0x30(%rbp)
  mov    %r9,-0x38(%rbp)
  movl   $0x0,-0xc(%rbp)
  cmpl   $0x2,-0x14(%rbp)
  jg     L74
  cmpl   $0x0,-0x14(%rbp)
  jg     L43
  jmp    L112
L74:
  mov    -0x14(%rbp),%eax
  sub    $0x3,%eax
  cmp    $0x2,%eax
  ja     L112
  jmp    L269
L43:
  movl   $0x0,-0x10(%rbp)
  jmp    L108
L201:
  cmpl   $0x0,-0x18(%rbp)
  jne    L192
  mov    -0x10(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x30(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%rax
  mov    %rax,%rdi
  call   <sdslen@plt>
  jmp    L25
L192:
  cmpq   $0x0,-0x38(%rbp)
  jne    L200
  mov    -0x10(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x30(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%rax
  mov    %rax,%rdi
  call   <strlen@plt>
  jmp    L25
L200:
  mov    -0x10(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x38(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%rax
L25:
  mov    %rax,-0x8(%rbp)
  mov    -0x10(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x30(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%rax
  mov    -0xc(%rbp),%edx
  movslq %edx,%rcx
  mov    -0x20(%rbp),%rdx
  add    %rdx,%rcx
  mov    -0x8(%rbp),%rdx
  mov    %rax,%rsi
  mov    %rcx,%rdi
  call   <memcpy@plt>
  mov    -0x8(%rbp),%rax
  add    %eax,-0xc(%rbp)
  mov    -0xc(%rbp),%eax
  lea    0x1(%rax),%edx
  mov    %edx,-0xc(%rbp)
  movslq %eax,%rdx
  mov    -0x20(%rbp),%rax
  add    %rdx,%rax
  movb   $0x20,(%rax)
  addl   $0x1,-0x10(%rbp)
L108:
  mov    -0x24(%rbp),%eax
  sub    $0x1,%eax
  cmp    %eax,-0x10(%rbp)
  jl     L201
  mov    -0xc(%rbp),%eax
  lea    0x1(%rax),%edx
  mov    %edx,-0xc(%rbp)
  movslq %eax,%rdx
  mov    -0x20(%rbp),%rax
  add    %rdx,%rax
  movb   $0xd,(%rax)
  mov    -0xc(%rbp),%eax
  lea    0x1(%rax),%edx
  mov    %edx,-0xc(%rbp)
  movslq %eax,%rdx
  mov    -0x20(%rbp),%rax
  add    %rdx,%rax
  movb   $0xa,(%rax)
  cmpl   $0x0,-0x18(%rbp)
  jne    L205
  mov    -0x24(%rbp),%eax
  cltq
  shl    $0x3,%rax
  lea    -0x8(%rax),%rdx
  mov    -0x30(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%rax
  mov    %rax,%rdi
  call   <sdslen@plt>
  jmp    L87
L205:
  cmpq   $0x0,-0x38(%rbp)
  jne    L58
  mov    -0x24(%rbp),%eax
  cltq
  shl    $0x3,%rax
  lea    -0x8(%rax),%rdx
  mov    -0x30(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%rax
  mov    %rax,%rdi
  call   <strlen@plt>
  jmp    L87
L58:
  mov    -0x24(%rbp),%eax
  cltq
  shl    $0x3,%rax
  lea    -0x8(%rax),%rdx
  mov    -0x38(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%rax
L87:
  mov    %rax,-0x8(%rbp)
  mov    -0x24(%rbp),%eax
  cltq
  shl    $0x3,%rax
  lea    -0x8(%rax),%rdx
  mov    -0x30(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%rax
  mov    -0xc(%rbp),%edx
  movslq %edx,%rcx
  mov    -0x20(%rbp),%rdx
  add    %rdx,%rcx
  mov    -0x8(%rbp),%rdx
  mov    %rax,%rsi
  mov    %rcx,%rdi
  call   <memcpy@plt>
  mov    -0x8(%rbp),%rax
  add    %eax,-0xc(%rbp)
  mov    -0xc(%rbp),%eax
  lea    0x1(%rax),%edx
  mov    %edx,-0xc(%rbp)
  movslq %eax,%rdx
  mov    -0x20(%rbp),%rax
  add    %rdx,%rax
  movb   $0xd,(%rax)
  mov    -0xc(%rbp),%eax
  lea    0x1(%rax),%edx
  mov    %edx,-0xc(%rbp)
  movslq %eax,%rdx
  mov    -0x20(%rbp),%rax
  add    %rdx,%rax
  movb   $0xa,(%rax)
  jmp    L170
L269:
  movl   $0x0,-0x10(%rbp)
  jmp    L37
L11:
  cmpl   $0x0,-0x18(%rbp)
  jne    L220
  mov    -0x10(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x30(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%rax
  mov    %rax,%rdi
  call   <sdslen@plt>
  jmp    L70
L220:
  cmpq   $0x0,-0x38(%rbp)
  jne    L224
  mov    -0x10(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x30(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%rax
  mov    %rax,%rdi
  call   <strlen@plt>
  jmp    L70
L224:
  mov    -0x10(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x38(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%rax
L70:
  mov    %rax,-0x8(%rbp)
  mov    -0x10(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x30(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%rax
  mov    -0xc(%rbp),%edx
  movslq %edx,%rcx
  mov    -0x20(%rbp),%rdx
  add    %rdx,%rcx
  mov    -0x8(%rbp),%rdx
  mov    %rax,%rsi
  mov    %rcx,%rdi
  call   <memcpy@plt>
  mov    -0x8(%rbp),%rax
  mov    %eax,%edx
  mov    -0xc(%rbp),%eax
  add    %edx,%eax
  mov    %eax,-0xc(%rbp)
  mov    -0xc(%rbp),%eax
  lea    0x1(%rax),%edx
  mov    %edx,-0xc(%rbp)
  movslq %eax,%rdx
  mov    -0x20(%rbp),%rax
  add    %rdx,%rax
  movb   $0x20,(%rax)
  addl   $0x1,-0x10(%rbp)
L37:
  mov    -0x24(%rbp),%eax
  sub    $0x1,%eax
  cmp    %eax,-0x10(%rbp)
  jl     L11
  cmpl   $0x0,-0x18(%rbp)
  jne    L167
  mov    -0x24(%rbp),%eax
  cltq
  shl    $0x3,%rax
  lea    -0x8(%rax),%rdx
  mov    -0x30(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%rax
  mov    %rax,%rdi
  call   <sdslen@plt>
  jmp    L132
L167:
  cmpq   $0x0,-0x38(%rbp)
  jne    L246
  mov    -0x24(%rbp),%eax
  cltq
  shl    $0x3,%rax
  lea    -0x8(%rax),%rdx
  mov    -0x30(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%rax
  mov    %rax,%rdi
  call   <strlen@plt>
  jmp    L132
L246:
  mov    -0x24(%rbp),%eax
  cltq
  shl    $0x3,%rax
  lea    -0x8(%rax),%rdx
  mov    -0x38(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%rax
L132:
  mov    %rax,-0x8(%rbp)
  mov    -0x24(%rbp),%eax
  cltq
  shl    $0x3,%rax
  lea    -0x8(%rax),%rdx
  mov    -0x30(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%rax
  mov    -0xc(%rbp),%edx
  movslq %edx,%rcx
  mov    -0x20(%rbp),%rdx
  add    %rdx,%rcx
  mov    -0x8(%rbp),%rdx
  mov    %rax,%rsi
  mov    %rcx,%rdi
  call   <memcpy@plt>
  mov    -0x8(%rbp),%rax
  add    %eax,-0xc(%rbp)
  mov    -0xc(%rbp),%eax
  lea    0x1(%rax),%edx
  mov    %edx,-0xc(%rbp)
  movslq %eax,%rdx
  mov    -0x20(%rbp),%rax
  add    %rdx,%rax
  movb   $0xd,(%rax)
  mov    -0xc(%rbp),%eax
  lea    0x1(%rax),%edx
  mov    %edx,-0xc(%rbp)
  movslq %eax,%rdx
  mov    -0x20(%rbp),%rax
  add    %rdx,%rax
  movb   $0xa,(%rax)
  jmp    L170
L112:
  movl   $0xffffffff,-0xc(%rbp)
  nop
L170:
  mov    -0xc(%rbp),%eax
  leave
  ret
```

assistant: ```c
int genericMemcachedCommand(int cmdtype, char *cmd, int argtype, int argc, char **argv, size_t *argvlen) {
  int j;
  size_t len;
  int pos = 0;
  switch (cmdtype) {
  case 1:
  case 2:
    for (j = 0; j < argc - 1; j++) {
      len = (argtype == 0 ? sdslen(argv[j]) : (argvlen == NULL ? strlen(argv[j]) : argvlen[j]));
      memcpy(cmd + pos, argv[j], len);
      pos += (int)len;
      cmd[pos++] = ' ';
    }
    cmd[pos++] = '\r';
    cmd[pos++] = '\n';
    len = (argtype == 0 ? sdslen(argv[argc - 1]) : (argvlen == NULL ? strlen(argv[argc - 1]) : argvlen[argc - 1]));
    memcpy(cmd + pos, argv[argc - 1], len);
    pos += (int)len;
    cmd[pos++] = '\r';
    cmd[pos++] = '\n';
    break;
  case 4:
  case 3:
  case 5:
    for (j = 0; j < argc - 1; j++) {
      len = (argtype == 0 ? sdslen(argv[j]) : (argvlen == NULL ? strlen(argv[j]) : argvlen[j]));
      memcpy(cmd + pos, argv[j], len);
      pos += len;
      cmd[pos++] = ' ';
    }
    len = (argtype == 0 ? sdslen(argv[argc - 1]) : (argvlen == NULL ? strlen(argv[argc - 1]) : argvlen[argc - 1]));
    memcpy(cmd + pos, argv[argc - 1], len);
    pos += (int)len;
    cmd[pos++] = '\r';
    cmd[pos++] = '\n';
    break;
  default:
    pos = -1;
    break;
  }
  return pos;
}
```