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

```asm
<quote_cmdline>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x50,%rsp
  mov    %rdi,-0x28(%rbp)
  mov    %rsi,-0x30(%rbp)
  mov    %edx,-0x34(%rbp)
  mov    %ecx,-0x38(%rbp)
  mov    %r8,-0x40(%rbp)
  mov    %r9d,-0x44(%rbp)
  cmpl   $0xffffffff,-0x44(%rbp)
  setne  %al
  movzbl %al,%eax
  mov    %eax,%edi
  call   <assert@plt>
  mov    -0x38(%rbp),%eax
  sub    -0x44(%rbp),%eax
  mov    %eax,-0x14(%rbp)
  movl   $0x0,-0x18(%rbp)
  mov    -0x28(%rbp),%rax
  mov    %rax,-0x10(%rbp)
  mov    -0x30(%rbp),%rax
  mov    %rax,-0x8(%rbp)
  movl   $0x0,-0x20(%rbp)
  jmp    L120
L58:
  movl   $0x0,-0x18(%rbp)
  movl   $0x0,-0x1c(%rbp)
  jmp    L66
L9:
  mov    -0x44(%rbp),%edx
  mov    -0x20(%rbp),%eax
  add    %edx,%eax
  mov    %eax,%eax
  lea    0x0(,%rax,8),%rdx
  mov    -0x40(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%rdx
  mov    -0x1c(%rbp),%eax
  add    %rdx,%rax
  movzbl (%rax),%eax
  cmp    $0x27,%al
  jne    L128
  cmpl   $0x0,-0x18(%rbp)
  je     L76
  mov    -0x10(%rbp),%rax
  movb   $0x27,(%rax)
  addq   $0x1,-0x10(%rbp)
L76:
  cmpl   $0x0,-0x1c(%rbp)
  je     L97
  mov    -0x44(%rbp),%edx
  mov    -0x20(%rbp),%eax
  add    %edx,%eax
  mov    %eax,%eax
  lea    0x0(,%rax,8),%rdx
  mov    -0x40(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%rdx
  mov    -0x1c(%rbp),%eax
  sub    $0x1,%eax
  mov    %eax,%eax
  add    %rdx,%rax
  movzbl (%rax),%eax
  cmp    $0x27,%al
  jne    L97
  subq   $0x1,-0x10(%rbp)
  mov    -0x10(%rbp),%rax
  lea    D14(%rip),%rdx
  mov    %rdx,%rsi
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <sprintf@plt>
  jmp    L1
L97:
  mov    -0x10(%rbp),%rax
  lea    D43(%rip),%rdx
  mov    %rdx,%rsi
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <sprintf@plt>
L1:
  mov    -0x10(%rbp),%rax
  mov    %rax,%rdi
  call   <strlen@plt>
  mov    %eax,%eax
  add    %rax,-0x10(%rbp)
  movl   $0x0,-0x18(%rbp)
  jmp    L46
L128:
  cmpl   $0x0,-0x18(%rbp)
  jne    L122
  cmpl   $0x0,0x10(%rbp)
  je     L122
  mov    -0x10(%rbp),%rax
  movb   $0x27,(%rax)
  addq   $0x1,-0x10(%rbp)
L122:
  mov    -0x44(%rbp),%edx
  mov    -0x20(%rbp),%eax
  add    %edx,%eax
  mov    %eax,%eax
  lea    0x0(,%rax,8),%rdx
  mov    -0x40(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%rdx
  mov    -0x1c(%rbp),%eax
  add    %rdx,%rax
  movzbl (%rax),%edx
  mov    -0x10(%rbp),%rax
  mov    %dl,(%rax)
  addq   $0x1,-0x10(%rbp)
  cmpl   $0x0,0x10(%rbp)
  je     L46
  movl   $0x1,-0x18(%rbp)
L46:
  addl   $0x1,-0x1c(%rbp)
L66:
  mov    -0x44(%rbp),%edx
  mov    -0x20(%rbp),%eax
  add    %edx,%eax
  mov    %eax,%eax
  lea    0x0(,%rax,8),%rdx
  mov    -0x40(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%rax
  mov    %rax,%rdi
  call   <strlen@plt>
  cmp    %eax,-0x1c(%rbp)
  jb     L9
  cmpl   $0x0,-0x18(%rbp)
  je     L116
  mov    -0x10(%rbp),%rax
  movb   $0x27,(%rax)
  addq   $0x1,-0x10(%rbp)
L116:
  mov    -0x44(%rbp),%edx
  mov    -0x20(%rbp),%eax
  add    %edx,%eax
  mov    %eax,%eax
  lea    0x0(,%rax,8),%rdx
  mov    -0x40(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%rax
  mov    %rax,%rdi
  call   <strlen@plt>
  test   %eax,%eax
  jne    L59
  mov    -0x10(%rbp),%rax
  lea    D31(%rip),%rdx
  mov    %rdx,%rsi
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <sprintf@plt>
  mov    -0x10(%rbp),%rax
  mov    %rax,%rdi
  call   <strlen@plt>
  mov    %eax,%eax
  add    %rax,-0x10(%rbp)
L59:
  mov    -0x10(%rbp),%rax
  lea    D36(%rip),%rdx
  mov    %rdx,%rsi
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <sprintf@plt>
  mov    -0x10(%rbp),%rax
  mov    %rax,%rdi
  call   <strlen@plt>
  mov    %eax,%eax
  add    %rax,-0x10(%rbp)
  mov    -0x44(%rbp),%edx
  mov    -0x20(%rbp),%eax
  add    %edx,%eax
  mov    %eax,%eax
  lea    0x0(,%rax,8),%rdx
  mov    -0x40(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%rdx
  mov    -0x8(%rbp),%rax
  lea    D4(%rip),%rcx
  mov    %rcx,%rsi
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <sprintf@plt>
  mov    -0x8(%rbp),%rax
  mov    %rax,%rdi
  call   <strlen@plt>
  mov    %eax,%eax
  add    %rax,-0x8(%rbp)
  addl   $0x1,-0x20(%rbp)
L120:
  mov    -0x20(%rbp),%eax
  cmp    -0x14(%rbp),%eax
  jb     L58
  mov    -0x28(%rbp),%rax
  mov    %rax,%rdi
  call   <strlen@plt>
  mov    -0x34(%rbp),%edx
  cmp    %edx,%eax
  sete   %al
  movzbl %al,%eax
  mov    %eax,%edi
  call   <assert@plt>
  nop
  leave
  ret
```

tool_calls: name: unpack_data
arguments: data_tag: D14
type_infered: string
name: unpack_data
arguments: data_tag: D43
type_infered: string
name: unpack_data
arguments: data_tag: D31
type_infered: string
name: unpack_data
arguments: data_tag: D36
type_infered: string
name: unpack_data
arguments: data_tag: D4
type_infered: string

tool: D14: '"

tool: D43: "'"

tool: D31: ''

tool: D36:  

tool: D4: %s 

assistant: ```c
void quote_cmdline(char *command_line, char *window_title, int len, int argc, char **argv, int index, bool want_extra_quotes) {
  assert(index != -1);
  unsigned i, j;
  unsigned argcnt = argc - index;
  bool in_quotes = false;
  char *ptr1 = command_line;
  char *ptr2 = window_title;
  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) {
          ptr1[0] = '\'';
          ptr1++;
        }
        if (j > 0 && argv[i + index][j - 1] == '\'') {
          ptr1--;
          sprintf(ptr1, "\'\"");
        } else {
          sprintf(ptr1, "\"\'\"");
        }
        ptr1 += strlen(ptr1);
        in_quotes = false;
      } else {
        if (!in_quotes && want_extra_quotes) {
          ptr1[0] = '\'';
          ptr1++;
        }
        ptr1[0] = argv[i + index][j];
        ptr1++;
        if (want_extra_quotes)
          in_quotes = true;
      }
    }
    if (in_quotes) {
      ptr1[0] = '\'';
      ptr1++;
    }
    if (strlen(argv[i + index]) == 0) {
      sprintf(ptr1, "\'\'");
      ptr1 += strlen(ptr1);
    }
    sprintf(ptr1, " ");
    ptr1 += strlen(ptr1);
    sprintf(ptr2, "%s ", argv[i + index]);
    ptr2 += strlen(ptr2);
  }
  assert((unsigned)len == strlen(command_line));
}
```