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

```asm
<create_codebook_text_file>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  mov    %rdi,%r13
  push   %r12
  mov    %rsi,%r12
  lea    D27(%rip),%rsi
  push   %rbp
  push   %rbx
  mov    %ecx,%ebx
  sub    $0x58,%rsp
  mov    %edx,0xc(%rsp)
  mov    %fs:0x28,%rax
  mov    %rax,0x48(%rsp)
  xor    %eax,%eax
  call   <fopen@plt>
  mov    %rax,%rbp
  test   %rax,%rax
  je     L114
  mov    0xc(%rsp),%esi
  test   %esi,%esi
  jle    L249
L230:
  movslq 0xc(%rsp),%rdx
  lea    0x20(%rsp),%rdi
  xor    %esi,%esi
  mov    %rdi,0x18(%rsp)
  shl    $0x2,%rdx
  call   <memset@plt>
L16:
  mov    0xc(%rsp),%r15d
  mov    %ebx,%edi
  lea    D36(%rip),%r13
  mov    %r15d,%esi
  call   <pow@plt>
  mov    %r15d,%edx
  lea    D1(%rip),%rsi
  mov    %rbp,%rdi
  mov    %eax,%ecx
  xor    %eax,%eax
  call   <fprintf@plt>
  lea    -0x1(%r15),%eax
  mov    %rax,%rdx
  mov    %eax,0x8(%rsp)
  lea    0x24(%rsp,%rax,4),%rax
  mov    %rax,(%rsp)
  movslq %edx,%rax
  mov    %rax,0x10(%rsp)
  nopl   0x0(%rax)
L256:
  mov    0xc(%rsp),%ecx
  mov    0x18(%rsp),%r14
  xor    %r15d,%r15d
  test   %ecx,%ecx
  jle    L207
  nopl   0x0(%rax,%rax,1)
L58:
  mov    (%r14),%eax
  pxor   %xmm0,%xmm0
  mov    %r13,%rsi
  mov    %rbp,%rdi
  add    $0x4,%r14
  add    %r15d,%eax
  add    %ebx,%r15d
  cltq
  cvtss2sd (%r12,%rax,4),%xmm0
  mov    $0x1,%eax
  call   <fprintf@plt>
  cmp    (%rsp),%r14
  jne    L58
L207:
  mov    %rbp,%rsi
  mov    $0xa,%edi
  call   <fputc@plt>
  mov    0x20(%rsp),%eax
  mov    0x8(%rsp),%edx
  add    $0x1,%eax
  mov    %eax,0x20(%rsp)
  test   %edx,%edx
  jle    L49
  cmp    %ebx,%eax
  jne    L125
  addl   $0x1,0x24(%rsp)
  movl   $0x0,0x20(%rsp)
L125:
  cmpl   $0x1,0x8(%rsp)
  je     L49
  cmp    0x24(%rsp),%ebx
  jne    L28
  addl   $0x1,0x28(%rsp)
  movl   $0x0,0x24(%rsp)
L28:
  cmpl   $0x2,0x8(%rsp)
  je     L49
  cmp    %ebx,0x28(%rsp)
  jne    L189
  addl   $0x1,0x2c(%rsp)
  movl   $0x0,0x28(%rsp)
L189:
  cmpl   $0x3,0x8(%rsp)
  je     L49
  cmp    %ebx,0x2c(%rsp)
  jne    L7
  addl   $0x1,0x30(%rsp)
  movl   $0x0,0x2c(%rsp)
L7:
  cmpl   $0x4,0x8(%rsp)
  je     L49
  cmp    0x30(%rsp),%ebx
  jne    L196
  addl   $0x1,0x34(%rsp)
  movl   $0x0,0x30(%rsp)
L196:
  cmpl   $0x5,0x8(%rsp)
  je     L49
  cmp    0x34(%rsp),%ebx
  jne    L115
  addl   $0x1,0x38(%rsp)
  movl   $0x0,0x34(%rsp)
L115:
  cmpl   $0x6,0x8(%rsp)
  je     L49
  cmp    0x38(%rsp),%ebx
  jne    L158
  addl   $0x1,0x3c(%rsp)
  movl   $0x0,0x38(%rsp)
L158:
  cmpl   $0x7,0x8(%rsp)
  je     L49
  cmp    0x3c(%rsp),%ebx
  jne    L11
  addl   $0x1,0x40(%rsp)
  movl   $0x0,0x3c(%rsp)
L11:
  cmpl   $0x8,0x8(%rsp)
  je     L49
  cmp    0x40(%rsp),%ebx
  jne    L49
  addl   $0x1,0x44(%rsp)
  movl   $0x0,0x40(%rsp)
L49:
  mov    0x10(%rsp),%rax
  cmp    %ebx,0x20(%rsp,%rax,4)
  jne    L256
  mov    0x48(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L109
  add    $0x58,%rsp
  mov    %rbp,%rdi
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  jmp    10d0 <fclose@plt>
L114:
  mov    %r13,%rsi
  lea    D0(%rip),%rdi
  call   <printf@plt>
  xor    %edi,%edi
  call   <exit@plt>
  mov    0xc(%rsp),%esi
  test   %esi,%esi
  jg     L230
L249:
  lea    0x20(%rsp),%rax
  mov    %rax,0x18(%rsp)
  jmp    L16
L109:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: retrieve_data
arguments: label: D27
type: string
name: retrieve_data
arguments: label: D36
type: string
name: retrieve_data
arguments: label: D1
type: string
name: retrieve_data
arguments: label: D0
type: string

tool: D27: wt

tool: D36: %4.0f 

tool: D1: %d %d


tool: D0: Can't open codebook text file %s


assistant: ```c
void create_codebook_text_file(char filename[], float lsp[], int rows, int cols) {
  FILE *f;
  int i, digits[10];
  f = fopen(filename, "wt");
  if (f == NULL) {
    printf("Can't open codebook text file %s\n", filename);
    exit(0);
  }
  for (i = 0; i < rows; i++)
    digits[i] = 0;
  fprintf(f, "%d %d\n", rows, (int)pow(cols, rows));
  do {
    for (i = 0; i < rows; i++)
      fprintf(f, "%4.0f ", lsp[cols * i + digits[i]]);
    fprintf(f, "\n");
    digits[0]++;
    for (i = 0; i < rows - 1; i++)
      if (digits[i] == cols) {
        digits[i] = 0;
        digits[i + 1]++;
      }
  } while (digits[rows - 1] != cols);
  fclose(f);
}
```