user: 请将这段汇编代码片段转换成等效的C代码：

```asm
<main>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x78,%rsp
  mov    %rsi,0x58(%rsp)
  mov    %fs:0x28,%rax
  mov    %rax,0x68(%rsp)
  xor    %eax,%eax
  cmp    $0x5,%edi
  jne    L150
L18:
  mov    0x58(%rsp),%rax
  mov    0x8(%rax),%rdi
  lea    D126(%rip),%rsi
  call   <fopen@plt>
  mov    %rax,0x20(%rsp)
  test   %rax,%rax
  je     L100
L134:
  mov    0x58(%rsp),%rbx
  mov    0x10(%rbx),%rdi
  call   <atol@plt>
  mov    %rax,%r15
  mov    0x18(%rbx),%rdi
  call   <atol@plt>
  mov    %rax,%r14
  mov    %rax,0x10(%rsp)
  mov    %rax,%rdx
  mov    %r15,%rsi
  lea    D52(%rip),%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  lea    0x0(,%r15,4),%edi
  call   <malloc@plt>
  mov    %rax,%rbx
  mov    %r14d,%ebp
  imul   %r15d,%ebp
  shl    $0x2,%ebp
  mov    %ebp,%edi
  call   <malloc@plt>
  mov    %rax,%r13
  mov    %rax,0x28(%rsp)
  mov    %ebp,%edi
  call   <malloc@plt>
  mov    %rax,%rbp
  mov    %rax,0x30(%rsp)
  lea    0x0(,%r14,8),%edi
  call   <malloc@plt>
  mov    %rax,%r14
  test   %r13,%r13
  sete   %al
  test   %rbp,%rbp
  sete   %dl
  or     %dl,%al
  jne    L28
  test   %rbx,%rbx
  jne    L202
L28:
  lea    D37(%rip),%rdi
  call   <puts@plt>
  mov    $0x1,%edi
  call   <exit@plt>
L202:
  mov    $0x0,%ebp
  mov    0x20(%rsp),%r12
  jmp    L224
L150:
  mov    (%rsi),%rsi
  lea    D100(%rip),%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  mov    $0x1,%edi
  call   <exit@plt>
  jmp    L18
L100:
  mov    0x58(%rsp),%rax
  mov    0x8(%rax),%rsi
  lea    D91(%rip),%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  mov    $0x1,%edi
  call   <exit@plt>
  jmp    L134
L241:
  add    $0x1,%rbp
L224:
  mov    %r12,%rcx
  mov    %r15,%rdx
  mov    $0x4,%esi
  mov    %rbx,%rdi
  call   <fread@plt>
  cmp    %r15,%rax
  je     L241
  mov    %rbp,%rsi
  mov    %rbp,0x18(%rsp)
  lea    D70(%rip),%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  mov    0x20(%rsp),%rbp
  mov    %rbp,%rdi
  call   <rewind@plt>
  mov    0x10(%rsp),%rdx
  imul   %r15,%rdx
  mov    %rbp,%rcx
  mov    $0x4,%esi
  mov    0x28(%rsp),%rbp
  mov    %rbp,%rdi
  call   <fread@plt>
  lea    0x0(,%r15,4),%rax
  mov    %rax,0x8(%rsp)
  movss  D137(%rip),%xmm7
  movss  %xmm7,0x40(%rsp)
  movq   $0x1,0x38(%rsp)
  sub    0x30(%rsp),%rbp
  mov    %rbp,0x50(%rsp)
  mov    %rbx,0x48(%rsp)
  jmp    L193
L215:
  mov    0x10(%rsp),%rbx
  test   %rbx,%rbx
  jle    L116
  mov    %r14,%r12
  mov    0x30(%rsp),%r13
  mov    $0x0,%ebp
  jmp    L217
L4:
  add    $0x1,%rbp
  add    $0x8,%r12
  add    0x8(%rsp),%r13
  cmp    %rbp,%rbx
  je     L116
L217:
  mov    (%r12),%rdx
  test   %rdx,%rdx
  je     L4
  mov    %r15,%rsi
  mov    %r13,%rdi
  call   <norm@plt>
  mov    0x50(%rsp),%rax
  lea    (%rax,%r13,1),%rdi
  mov    0x8(%rsp),%rdx
  mov    %r13,%rsi
  call   <memcpy@plt>
  jmp    L4
L116:
  movss  0x44(%rsp),%xmm5
  movss  %xmm5,0x40(%rsp)
L193:
  mov    0x10(%rsp),%rbx
  test   %rbx,%rbx
  jle    L84
  mov    0x30(%rsp),%r13
  mov    %r14,%r12
  mov    $0x0,%ebp
L105:
  mov    %r15,%rsi
  mov    %r13,%rdi
  call   <zero@plt>
  movq   $0x0,(%r12)
  add    $0x1,%rbp
  add    0x8(%rsp),%r13
  add    $0x8,%r12
  cmp    %rbp,%rbx
  jne    L105
L84:
  movl   $0x0,0x64(%rsp)
  mov    0x20(%rsp),%rdi
  call   <rewind@plt>
  cmpq   $0x0,0x18(%rsp)
  jle    L176
  mov    $0x0,%ebp
  lea    0x64(%rsp),%r12
  mov    0x48(%rsp),%rbx
  mov    0x30(%rsp),%r13
L160:
  mov    0x20(%rsp),%rcx
  mov    %r15,%rdx
  mov    $0x4,%esi
  mov    %rbx,%rdi
  call   <fread@plt>
  mov    %r12,%r8
  mov    0x10(%rsp),%rcx
  mov    %r15,%rdx
  mov    %rbx,%rsi
  mov    0x28(%rsp),%rdi
  call   <quantise@plt>
  addq   $0x1,(%r14,%rax,8)
  imul   %r15,%rax
  lea    0x0(%r13,%rax,4),%rdi
  mov    %r15,%rdx
  mov    %rbx,%rsi
  call   <acc@plt>
  add    $0x1,%rbp
  cmp    %rbp,0x18(%rsp)
  jne    L160
L176:
  pxor   %xmm0,%xmm0
  cvtsi2ssq 0x18(%rsp),%xmm0
  movss  0x64(%rsp),%xmm1
  movaps %xmm1,%xmm2
  divss  %xmm0,%xmm2
  movss  %xmm2,0x44(%rsp)
  movss  0x40(%rsp),%xmm0
  subss  %xmm2,%xmm0
  divss  %xmm2,%xmm0
  pxor   %xmm3,%xmm3
  cvtss2sd %xmm0,%xmm3
  movq   %xmm3,%rbp
  pxor   %xmm0,%xmm0
  cvtss2sd %xmm2,%xmm0
  movapd %xmm3,%xmm1
  mov    0x38(%rsp),%rbx
  mov    %rbx,%rsi
  lea    D27(%rip),%rdi
  mov    $0x2,%eax
  call   <printf@plt>
  mov    %rbx,%rax
  add    $0x1,%rax
  mov    %rax,0x38(%rsp)
  movq   %rbp,%xmm4
  comisd D45(%rip),%xmm4
  ja     L215
  comisd D45(%rip),%xmm4
  ja     L116
  mov    0x58(%rsp),%rax
  mov    0x20(%rax),%rdi
  lea    D49(%rip),%rsi
  call   <fopen@plt>
  mov    %rax,%r12
  test   %rax,%rax
  je     L237
L133:
  mov    0x10(%rsp),%rbx
  mov    %rbx,%rcx
  mov    %r15,%rdx
  lea    D59(%rip),%rsi
  mov    %r12,%rdi
  mov    $0x0,%eax
  call   <fprintf@plt>
  movq   $0x0,0x8(%rsp)
  mov    $0x0,%r14d
  lea    D112(%rip),%r13
  test   %rbx,%rbx
  jg     L24
L27:
  mov    %r12,%rdi
  call   <fclose@plt>
  mov    0x68(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L2
  mov    $0x0,%eax
  add    $0x78,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L237:
  mov    0x58(%rsp),%rax
  mov    0x20(%rax),%rsi
  lea    D15(%rip),%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  mov    $0x1,%edi
  call   <exit@plt>
  jmp    L133
L151:
  pxor   %xmm0,%xmm0
  cvtss2sd 0x0(%rbp),%xmm0
  mov    %r13,%rsi
  mov    %r12,%rdi
  mov    $0x1,%eax
  call   <fprintf@plt>
  add    $0x1,%rbx
  add    $0x4,%rbp
  cmp    %rbx,%r15
  jne    L151
L121:
  mov    %r12,%rsi
  mov    $0xa,%edi
  call   <fputc@plt>
  add    $0x1,%r14
  add    %r15,0x8(%rsp)
  cmp    %r14,0x10(%rsp)
  je     L27
L24:
  mov    0x28(%rsp),%rax
  mov    0x8(%rsp),%rcx
  lea    (%rax,%rcx,4),%rbp
  mov    $0x0,%ebx
  test   %r15,%r15
  jg     L151
  jmp    L121
L2:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: retrieve_data
arguments: data_label: D126
type_guessed: string
name: retrieve_data
arguments: data_label: D52
type_guessed: string
name: retrieve_data
arguments: data_label: D37
type_guessed: string
name: retrieve_data
arguments: data_label: D100
type_guessed: string
name: retrieve_data
arguments: data_label: D91
type_guessed: string
name: retrieve_data
arguments: data_label: D70
type_guessed: string
name: retrieve_data
arguments: data_label: D137
type_guessed: f32
name: retrieve_data
arguments: data_label: D27
type_guessed: string
name: retrieve_data
arguments: data_label: D45
type_guessed: f64
name: retrieve_data
arguments: data_label: D49
type_guessed: string
name: retrieve_data
arguments: data_label: D59
type_guessed: string
name: retrieve_data
arguments: data_label: D112
type_guessed: string
name: retrieve_data
arguments: data_label: D15
type_guessed: string

tool: D126: rb

tool: D52: dimension K=%ld  number of entries M=%ld


tool: D37: Error in malloc.

tool: D100: usage: %s TrainFile K(dimension) M(codebook size) VQFile


tool: D91: Error opening training database file: %s


tool: D70: J=%ld entries in training set


tool: D137: 1e+32

tool: D27:   Iteration %ld, Dn = %f, Delta = %e


tool: D45: 0.01

tool: D49: wt

tool: D59: %ld %ld


tool: D112: %f  

tool: D15: Error opening VQ file: %s


assistant: ```c
int main(int argc, char *argv[]) {
  long k, m;
  float *vec;
  float *cb;
  float *cent;
  long *n;
  long J;
  long i, j;
  long ind;
  float se;
  float Dn, Dn_1;
  float delta;
  FILE *ftrain;
  FILE *fvq;
  if (argc != 5) {
    printf("usage: %s TrainFile K(dimension) M(codebook size) VQFile\n", argv[0]);
    exit(1);
  }
  ftrain = fopen(argv[1], "rb");
  if (ftrain == NULL) {
    printf("Error opening training database file: %s\n", argv[1]);
    exit(1);
  }
  k = atol(argv[2]);
  m = atol(argv[3]);
  printf("dimension K=%ld  number of entries M=%ld\n", k, m);
  vec = (float *)malloc(sizeof(float) * k);
  cb = (float *)malloc(sizeof(float) * k * m);
  cent = (float *)malloc(sizeof(float) * k * m);
  n = (long *)malloc(sizeof(long) * m);
  if (cb == NULL || cb == NULL || cent == NULL || vec == NULL) {
    printf("Error in malloc.\n");
    exit(1);
  }
  J = 0;
  while (fread(vec, sizeof(float), k, ftrain) == (size_t)k)
    J++;
  printf("J=%ld entries in training set\n", J);
  rewind(ftrain);
  fread(cb, sizeof(float), k * m, ftrain);
  Dn = 1E32;
  j = 1;
  do {
    Dn_1 = Dn;
    for (i = 0; i < m; i++) {
      zero(&cent[i * k], k);
      n[i] = 0;
    }
    se = 0.0;
    rewind(ftrain);
    for (i = 0; i < J; i++) {
      fread(vec, sizeof(float), k, ftrain);
      ind = quantise(cb, vec, k, m, &se);
      n[ind]++;
      acc(&cent[ind * k], vec, k);
    }
    Dn = se / J;
    delta = (Dn_1 - Dn) / Dn;
    printf("\r  Iteration %ld, Dn = %f, Delta = %e\n", j, Dn, delta);
    j++;
    if (delta > 0.01)
      for (i = 0; i < m; i++) {
        if (n[i] != 0) {
          norm(&cent[i * k], k, n[i]);
          memcpy(&cb[i * k], &cent[i * k], k * sizeof(float));
        }
      }
  } while (delta > 0.01);
  fvq = fopen(argv[4], "wt");
  if (fvq == NULL) {
    printf("Error opening VQ file: %s\n", argv[4]);
    exit(1);
  }
  fprintf(fvq, "%ld %ld\n", k, m);
  for (j = 0; j < m; j++) {
    for (i = 0; i < k; i++)
      fprintf(fvq, "%f  ", cb[j * k + i]);
    fprintf(fvq, "\n");
  }
  fclose(fvq);
  return 0;
}
```