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

```asm
<main>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  lea    -0x8c000(%rsp),%r11
L46:
  sub    $0x1000,%rsp
  orq    $0x0,(%rsp)
  cmp    %r11,%rsp
  jne    L46
  sub    $0xa48,%rsp
  mov    %rsi,%r13
  mov    %fs:0x28,%rax
  mov    %rax,0x8ca38(%rsp)
  xor    %eax,%eax
  movabs $0x7220742d20636572,%rax
  movabs $0x363120622d207761,%rdx
  mov    %rax,0x8ca10(%rsp)
  mov    %rdx,0x8ca18(%rsp)
  movabs $0x652d203120632d20,%rax
  movabs $0x383420722d207320,%rdx
  mov    %rax,0x8ca20(%rsp)
  mov    %rdx,0x8ca28(%rsp)
  movl   $0x20303030,0x8ca30(%rsp)
  movw   $0x2d,0x8ca34(%rsp)
  lea    0x8ca10(%rsp),%rdi
  lea    D67(%rip),%rsi
  call   <popen@plt>
  mov    %rax,%rbx
  test   %rax,%rax
  je     L15
L12:
  mov    $0x0,%ebp
  mov    $0x23280,%r12d
L77:
  mov    %r12d,%edx
  sub    %ebp,%edx
  movslq %ebp,%rax
  lea    0x10(%rsp,%rax,4),%rdi
  mov    %rbx,%rcx
  mov    $0x4,%esi
  call   <fread@plt>
  add    %ebp,%eax
  mov    %eax,%ebp
  cmp    $0x2327f,%eax
  jle    L77
  lea    D53(%rip),%r14
  mov    %r14,%rdi
  call   <strlen@plt>
  mov    %eax,%ebp
  mov    0x8(%r13),%rdi
  call   <strlen@plt>
  add    %eax,%ebp
  lea    D101(%rip),%r15
  mov    %r15,%rdi
  call   <strlen@plt>
  mov    %eax,%r12d
  mov    %r14,%rdi
  call   <strlen@plt>
  mov    %eax,0x8(%rsp)
  mov    0x8(%r13),%rdi
  call   <strlen@plt>
  mov    %eax,%ecx
  add    0x8(%rsp),%ecx
  mov    %ecx,0x8(%rsp)
  lea    D7(%rip),%rdi
  call   <strlen@plt>
  mov    %eax,0xc(%rsp)
  lea    0x1(%rbp,%r12,1),%edi
  call   <malloc@plt>
  mov    %rax,%r12
  mov    0x8(%rsp),%ecx
  mov    0xc(%rsp),%eax
  lea    0x1(%rcx,%rax,1),%edi
  call   <malloc@plt>
  mov    %rax,%rbp
  mov    %r14,%rsi
  mov    %r12,%rdi
  call   <strcpy@plt>
  mov    %r14,%rsi
  mov    %rbp,%rdi
  call   <strcpy@plt>
  mov    0x8(%r13),%rsi
  mov    %r12,%rdi
  call   <strcat@plt>
  mov    0x8(%r13),%rsi
  mov    %rbp,%rdi
  call   <strcat@plt>
  mov    %r15,%rsi
  mov    %r12,%rdi
  call   <strcat@plt>
  lea    D7(%rip),%rsi
  mov    %rbp,%rdi
  call   <strcat@plt>
  lea    D80(%rip),%rsi
  mov    %r12,%rdi
  call   <fopen@plt>
  mov    %rax,%r14
  test   %rax,%rax
  je     L17
L35:
  lea    D80(%rip),%rsi
  mov    %rbp,%rdi
  call   <fopen@plt>
  mov    %rax,%r13
  test   %rax,%rax
  je     L79
L64:
  lea    0x10(%rsp),%r12
  mov    $0x0,%ebp
  lea    D92(%rip),%r15
L27:
  mov    (%r12),%ecx
  mov    %ebp,%edx
  mov    %r15,%rsi
  mov    %r14,%rdi
  call   <fprintf@plt>
  mov    %r13,%rcx
  mov    $0x1,%edx
  mov    $0x4,%esi
  mov    %r12,%rdi
  call   <fwrite@plt>
  add    $0x1,%ebp
  add    $0x4,%r12
  cmp    $0x23280,%ebp
  jne    L27
  mov    %r14,%rdi
  call   <fclose@plt>
  mov    %r13,%rdi
  call   <fclose@plt>
  mov    %rbx,%rdi
  call   <pclose@plt>
  mov    0x8ca38(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L20
  mov    $0x0,%eax
  add    $0x8ca48,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L15:
  lea    D86(%rip),%rdi
  call   <perror@plt>
  jmp    L12
L17:
  lea    D17(%rip),%rdi
  call   <perror@plt>
  mov    $0x1,%edi
  call   <exit@plt>
  jmp    L35
L79:
  lea    D17(%rip),%rdi
  call   <perror@plt>
  mov    $0x1,%edi
  call   <exit@plt>
  jmp    L64
L20:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: read_data
arguments: label: D67
type_guessed: string
name: read_data
arguments: label: D53
type_guessed: string
name: read_data
arguments: label: D101
type_guessed: string
name: read_data
arguments: label: D7
type_guessed: string
name: read_data
arguments: label: D80
type_guessed: string
name: read_data
arguments: label: D92
type_guessed: string
name: read_data
arguments: label: D86
type_guessed: string
name: read_data
arguments: label: D17
type_guessed: string

tool: D67: r

tool: D53: data/

tool: D101: .txt

tool: D7: .raw

tool: D80: w

tool: D92: %d %d


tool: D86: rec

tool: D17: fopen

assistant: ```c
int main(int ARGC, char *ARGV[]) {
  FILE *rec;
  char cmd[] = "rec -t raw -b 16 -c 1 -e s -r 48000 -";
  if ((rec = popen(cmd, "r")) == NULL) {
    perror("rec");
  }
  int n = 0;
  int16_t buf[144000];
  while (1) {
    n += fread(buf + n, sizeof(int16_t), 144000 - n, rec);
    if (n >= 144000) {
      break;
    }
  }
  char *text_file_name, *raw_file_name;
  int text_file_name_len = strlen("data/") + strlen(ARGV[1]) + strlen(".txt") + 1;
  int raw_file_name_len = strlen("data/") + strlen(ARGV[1]) + strlen(".raw") + 1;
  text_file_name = (char *)malloc(sizeof(char) * text_file_name_len);
  raw_file_name = (char *)malloc(sizeof(char) * raw_file_name_len);
  strcpy(text_file_name, "data/");
  strcpy(raw_file_name, "data/");
  strcat(text_file_name, ARGV[1]);
  strcat(raw_file_name, ARGV[1]);
  strcat(text_file_name, ".txt");
  strcat(raw_file_name, ".raw");
  FILE *text, *raw;
  if ((text = fopen(text_file_name, "w")) == NULL) {
    perror("fopen");
    exit(1);
  }
  if ((raw = fopen(raw_file_name, "w")) == NULL) {
    perror("fopen");
    exit(1);
  }
  for (int i = 0; i < 144000; i++) {
    fprintf(text, "%d %d\n", i, buf[i]);
    fwrite(&buf[i], sizeof(int16_t), 1, raw);
  }
  fclose(text);
  fclose(raw);
  pclose(rec);
  return 0;
}
```