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

```asm
<extract_quotes>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x5d8,%rsp
  mov    %rdi,0x18(%rsp)
  mov    %fs:0x28,%rax
  mov    %rax,0x5c8(%rsp)
  xor    %eax,%eax
  test   %rdi,%rdi
  je     L129
  lea    D34(%rip),%rsi
  call   <strstr@plt>
  test   %rax,%rax
  jne    L205
  mov    0x18(%rsp),%rbx
  lea    D99(%rip),%rdi
  mov    %rbx,%rsi
  call   <printf@plt>
  lea    D58(%rip),%rsi
  mov    %rbx,%rdi
  call   <fopen@plt>
  mov    %rax,%r12
  test   %rax,%rax
  je     L100
  mov    0x18(%rsp),%rsi
  xor    %r13d,%r13d
  xor    %r14d,%r14d
  lea    0x30(%rsp),%rbx
  lea    D46(%rip),%rdi
  call   <str_unite@plt>
  lea    D4(%rip),%rsi
  mov    %rax,%rdi
  mov    %rax,0x20(%rsp)
  call   <fopen@plt>
  mov    %rax,0x28(%rsp)
  test   %rax,%rax
  je     L307
  nopl   0x0(%rax,%rax,1)
L271:
  mov    %r12,%rdx
  mov    $0x2c7,%esi
  mov    %rbx,%rdi
  call   <fgets@plt>
  test   %rax,%rax
  je     L152
  mov    %rbx,%rdi
  call   <strlen@plt>
  movslq %eax,%r15
  add    %rbx,%r15
  jb     L271
  movzbl 0x30(%rsp),%edx
  test   %dl,%dl
  je     L271
  cmp    %rbx,%r15
  jbe    L271
  lea    0x300(%rsp),%rax
  mov    %rbx,0x10(%rsp)
  mov    %rbx,%rbp
  mov    %r15,%rbx
  mov    %rax,(%rsp)
  mov    %r14d,%r15d
  mov    %r12,0x8(%rsp)
  jmp    L284
  nopl   0x0(%rax,%rax,1)
L286:
  mov    %rbp,%r14
  xor    %r15d,%r15d
  cmp    $0x22,%dl
  je     L301
L2:
  movzbl 0x1(%r14),%edx
  add    $0x1,%rbp
  test   %dl,%dl
  je     L207
L290:
  cmp    %rbp,%rbx
  jbe    L207
L284:
  cmp    $0x1,%r15d
  jne    L286
  lea    0x1(%r13),%r12d
  cmp    $0xa,%dl
  je     L137
  mov    %dl,0x300(%rsp,%r13,1)
  cmp    $0x22,%dl
  je     L326
L150:
  movslq %r12d,%r13
  mov    %rbp,%r14
  cmp    $0x2c8,%r13d
  jle    L2
  mov    (%rsp),%rdi
  mov    $0x2c8,%edx
  xor    %esi,%esi
  lea    0x1(%rbp),%r14
  call   <_memset@plt>
  movzbl 0x1(%rbp),%edx
  test   %dl,%dl
  je     L243
  cmp    %r14,%rbx
  jbe    L243
  mov    %r14,%rbp
  xor    %r15d,%r15d
  mov    %rbp,%r14
  cmp    $0x22,%dl
  jne    L2
  nopw   0x0(%rax,%rax,1)
L301:
  movsbl -0x1(%rbp),%edi
  call   <isalnum@plt>
  test   %eax,%eax
  jne    L2
  mov    $0x1,%r13d
  lea    D15(%rip),%rdi
  mov    $0x1,%r15d
  add    $0x1,%rbp
  call   <puts@plt>
  mov    (%rsp),%rdi
  mov    $0x2c8,%edx
  xor    %esi,%esi
  call   <_memset@plt>
  movzbl -0x1(%rbp),%eax
  movzbl 0x1(%r14),%edx
  mov    %al,0x300(%rsp)
  test   %dl,%dl
  jne    L290
  nopl   (%rax)
L207:
  mov    0x8(%rsp),%r12
  mov    0x10(%rsp),%rbx
  mov    %r15d,%r14d
  jmp    L271
  nopw   0x0(%rax,%rax,1)
L152:
  mov    %r12,%rdi
  call   <fclose@plt>
  mov    0x28(%rsp),%rdi
  call   <fclose@plt>
L277:
  mov    0x20(%rsp),%rax
  test   %rax,%rax
  je     L129
  mov    %rax,%rdi
  call   <free@plt>
L129:
  mov    0x5c8(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L236
  add    $0x5d8,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopl   (%rax)
L205:
  mov    0x5c8(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L236
  mov    0x18(%rsp),%rsi
  add    $0x5d8,%rsp
  lea    D74(%rip),%rdi
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  jmp    11a0 <printf@plt>
  nopl   0x0(%rax)
L326:
  movsbl 0x1(%rbp),%edi
  call   <isalnum@plt>
  movslq %eax,%r13
  test   %r13d,%r13d
  jne    L150
  mov    (%rsp),%r15
  mov    %r15,%rdi
  call   <clean_quote@plt>
  mov    %r15,%rdi
  mov    %rax,%r14
  call   <count_words@plt>
  test   %eax,%eax
  jne    L134
L333:
  mov    (%rsp),%rdi
  mov    $0x2c8,%edx
  xor    %esi,%esi
  call   <_memset@plt>
  lea    0x1(%rbp),%rax
  movzbl 0x1(%rbp),%edx
  cmp    %rax,%rbx
  jbe    L340
  test   %dl,%dl
  je     L340
  mov    %rax,%rbp
  jmp    L286
  nopl   (%rax)
L137:
  movb   $0x20,0x300(%rsp,%r13,1)
  mov    %r12d,%r9d
  mov    0x10(%rsp),%rbx
  mov    %r15d,%r14d
  mov    0x8(%rsp),%r12
L130:
  movslq %r9d,%r13
  jmp    L271
L100:
  mov    0x5c8(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L236
  add    $0x5d8,%rsp
  lea    D80(%rip),%rdi
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  jmp    1200 <perror@plt>
L243:
  mov    %r12d,%r9d
  mov    0x10(%rsp),%rbx
  mov    0x8(%rsp),%r12
  xor    %r14d,%r14d
  jmp    L130
L134:
  mov    0x18(%rsp),%rcx
  mov    0x28(%rsp),%rdi
  mov    %r14,%r8
  mov    %eax,%edx
  lea    D88(%rip),%rsi
  call   <fprintf@plt>
  jmp    L333
L307:
  lea    D1(%rip),%rdi
  call   <perror@plt>
  mov    %r12,%rdi
  call   <fclose@plt>
  jmp    L277
L340:
  mov    0x8(%rsp),%r12
  mov    0x10(%rsp),%rbx
  xor    %r9d,%r9d
  xor    %r14d,%r14d
  jmp    L130
L236:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: disassemble_data
arguments: tag: D34
data_type: string
name: disassemble_data
arguments: tag: D99
data_type: string
name: disassemble_data
arguments: tag: D58
data_type: string
name: disassemble_data
arguments: tag: D46
data_type: string
name: disassemble_data
arguments: tag: D4
data_type: string
name: disassemble_data
arguments: tag: D15
data_type: string
name: disassemble_data
arguments: tag: D74
data_type: string
name: disassemble_data
arguments: tag: D80
data_type: string
name: disassemble_data
arguments: tag: D88
data_type: string
name: disassemble_data
arguments: tag: D1
data_type: string

tool: D34: .eq

tool: D99: extract_quotes: Extracting quotes from %s


tool: D58: r

tool: D46: %s.eq

tool: D4: w

tool: D15: FOUND QUOTE

tool: D74: extract_quotes: Already extracted %s


tool: D80: fopen

tool: D88: %i %s %s


tool: D1: fopen(2) 

assistant: ```c
void extract_quotes(char *filename) {
  FILE *fp, *fp_out;
  char *ptr;
  char buf[712], *buf_ptr, *buf_end;
  char quote[712], *quote_ptr;
  int quote_begin, quote_end, quote_index, quote_word_count;
  int i, buf_index, buf_len;
  if (!filename)
    return;
  if (strstr(filename, ".eq")) {
    printf("extract_quotes: Already extracted %s\n", filename);
    return;
  }
  printf("extract_quotes: Extracting quotes from %s\n", filename);
  fp = fopen(filename, "r");
  if (!fp) {
    perror("fopen");
    return;
  }
  ptr = str_unite("%s.eq", filename);
  fp_out = fopen(ptr, "w");
  if (!fp_out) {
    perror("fopen(2) ");
    goto cleanup;
  }
  quote_begin = quote_end = quote_index = 0;
  while (1) {
  begin:
    if (fgets(buf, sizeof(buf) - 1, fp) == NULL)
      break;
    buf_ptr = buf;
    buf_len = strlen(buf_ptr);
    buf_end = buf_ptr + buf_len;
    if (buf_ptr > buf_end) {
      continue;
    }
    while (*buf_ptr && buf_ptr < buf_end) {
      if (quote_begin == 1) {
        if (*buf_ptr == '\n') {
          quote[quote_index] = ' ';
          quote_index++;
          buf_ptr++;
          break;
        }
        if (*buf_ptr != '\n') {
          quote[quote_index] = *buf_ptr;
          quote_index++;
        }
        if (*buf_ptr == '\"' && !isalnum(*(buf_ptr + 1))) {
          quote_ptr = clean_quote(quote);
          quote_word_count = count_words(quote);
          if (quote_word_count)
            fprintf(fp_out, "%i %s %s\n", quote_word_count, filename, quote_ptr);
          _memset(quote, 0, sizeof(quote));
          quote_begin = 0;
          quote_index = 0;
          buf_ptr++;
          continue;
        }
        if (quote_index > sizeof(quote)) {
          _memset(quote, 0, sizeof(quote));
          quote_begin = 0;
          buf_ptr++;
          continue;
        }
      } else if (quote_begin == 0) {
        if (*buf_ptr == '\"' && !isalnum(*(buf_ptr - 1))) {
          puts("FOUND QUOTE");
          quote_begin = 1;
          _memset(quote, 0, sizeof(quote));
          quote_index = 0;
          quote[quote_index] = *buf_ptr;
          quote_index++;
        }
      }
      buf_ptr++;
    }
  }
cleanup:
  if (fp)
    fclose(fp);
  if (fp_out)
    fclose(fp_out);
  if (ptr)
    free(ptr);
  return;
}
```