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

```asm
<cmdline_length>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x40,%rsp
  mov    %edi,-0x24(%rbp)
  mov    %rsi,-0x30(%rbp)
  mov    %edx,-0x28(%rbp)
  mov    %ecx,-0x34(%rbp)
  cmpl   $0xffffffff,-0x28(%rbp)
  setne  %al
  movzbl %al,%eax
  mov    %eax,%edi
  call   <assert@plt>
  movl   $0x0,-0xc(%rbp)
  mov    -0x24(%rbp),%eax
  sub    -0x28(%rbp),%eax
  mov    %eax,-0x4(%rbp)
  movl   $0x0,-0x8(%rbp)
  movl   $0x0,-0x14(%rbp)
  jmp    L81
L109:
  movl   $0x0,-0x8(%rbp)
  movl   $0x0,-0x10(%rbp)
  jmp    L94
L5:
  mov    -0x28(%rbp),%edx
  mov    -0x14(%rbp),%eax
  add    %edx,%eax
  mov    %eax,%eax
  lea    0x0(,%rax,8),%rdx
  mov    -0x30(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%rdx
  mov    -0x10(%rbp),%eax
  add    %rdx,%rax
  movzbl (%rax),%eax
  cmp    $0x27,%al
  jne    L37
  cmpl   $0x0,-0x8(%rbp)
  je     L143
  addl   $0x1,-0xc(%rbp)
L143:
  cmpl   $0x0,-0x10(%rbp)
  je     L44
  mov    -0x28(%rbp),%edx
  mov    -0x14(%rbp),%eax
  add    %edx,%eax
  mov    %eax,%eax
  lea    0x0(,%rax,8),%rdx
  mov    -0x30(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%rdx
  mov    -0x10(%rbp),%eax
  sub    $0x1,%eax
  mov    %eax,%eax
  add    %rdx,%rax
  movzbl (%rax),%eax
  cmp    $0x27,%al
  jne    L44
  addl   $0x1,-0xc(%rbp)
  jmp    L99
L44:
  addl   $0x3,-0xc(%rbp)
L99:
  movl   $0x0,-0x8(%rbp)
  jmp    L105
L37:
  cmpl   $0x0,-0x8(%rbp)
  jne    L124
  cmpl   $0x0,-0x34(%rbp)
  je     L124
  addl   $0x1,-0xc(%rbp)
L124:
  addl   $0x1,-0xc(%rbp)
  cmpl   $0x0,-0x34(%rbp)
  je     L105
  movl   $0x1,-0x8(%rbp)
L105:
  addl   $0x1,-0x10(%rbp)
L94:
  mov    -0x28(%rbp),%edx
  mov    -0x14(%rbp),%eax
  add    %edx,%eax
  mov    %eax,%eax
  lea    0x0(,%rax,8),%rdx
  mov    -0x30(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%rax
  mov    %rax,%rdi
  call   <strlen@plt>
  cmp    %eax,-0x10(%rbp)
  jb     L5
  cmpl   $0x0,-0x8(%rbp)
  je     L103
  addl   $0x1,-0xc(%rbp)
L103:
  mov    -0x28(%rbp),%edx
  mov    -0x14(%rbp),%eax
  add    %edx,%eax
  mov    %eax,%eax
  lea    0x0(,%rax,8),%rdx
  mov    -0x30(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%rax
  mov    %rax,%rdi
  call   <strlen@plt>
  test   %eax,%eax
  jne    L69
  addl   $0x2,-0xc(%rbp)
L69:
  addl   $0x1,-0xc(%rbp)
  addl   $0x1,-0x14(%rbp)
L81:
  mov    -0x14(%rbp),%eax
  cmp    -0x4(%rbp),%eax
  jb     L109
  mov    -0xc(%rbp),%eax
  leave
  ret
```

assistant: ```c
int cmdline_length(int argc, char **argv, int index, bool want_extra_quotes) {
  assert(index != -1);
  unsigned i, j;
  int len = 0;
  unsigned argcnt = argc - index;
  bool in_quotes = false;
  for (i = 0; i < argcnt; i++) {
    in_quotes = false;
    for (j = 0; j < strlen(argv[i + index]); j++) {
      if (argv[i + index][j] == '\'') {
        if (in_quotes)
          len++;
        if (j > 0 && argv[i + index][j - 1] == '\'')
          len++;
        else
          len += 3;
        in_quotes = false;
      } else {
        if (!in_quotes && want_extra_quotes)
          len++;
        len++;
        if (want_extra_quotes)
          in_quotes = true;
      }
    }
    if (in_quotes) {
      len++;
    }
    if (strlen(argv[i + index]) == 0) {
      len += 2;
    }
    len++;
  }
  return len;
}
```