user: 请将以下的汇编代码转换成C语言代码：

```asm
<emalg>:
  endbr64
  push   %r15
  push   %r14
  mov    %r8,%r14
  push   %r13
  push   %r12
  mov    %rcx,%r12
  push   %rbp
  push   %rbx
  sub    $0x88,%rsp
  mov    %edi,0x58(%rsp)
  mov    0xc8(%rsp),%rdi
  mov    0xc0(%rsp),%eax
  mov    %esi,0x70(%rsp)
  mov    %rdi,0x78(%rsp)
  mov    0xd0(%rsp),%rdi
  mov    %edx,0x74(%rsp)
  mov    0xe8(%rsp),%r13
  mov    %rdi,0x30(%rsp)
  mov    0xd8(%rsp),%rdi
  mov    %r9,0x28(%rsp)
  mov    %rdi,0x38(%rsp)
  mov    0xe0(%rsp),%rdi
  mov    %eax,0x1c(%rsp)
  mov    %rdi,0x20(%rsp)
  test   %eax,%eax
  jne    L91
  mov    %esi,0x5c(%rsp)
  mov    %edx,0x4c(%rsp)
L9:
  mov    0x58(%rsp),%edi
  mov    $0x4,%esi
  call   <calloc@plt>
  mov    0x5c(%rsp),%ebx
  mov    %rax,%rbp
  lea    0x0(,%rbx,4),%edi
  call   <malloc@plt>
  mov    %rax,0x60(%rsp)
  test   %ebx,%ebx
  jle    L101
  mov    0x38(%rsp),%rdi
  lea    -0x1(%rbx),%edx
  mov    %rdi,%rax
  lea    0x4(%rdi,%rdx,4),%rcx
  nopl   (%rax)
L87:
  movslq (%rax),%rdx
  add    $0x4,%rax
  addl   $0x1,0x0(%rbp,%rdx,4)
  cmp    %rax,%rcx
  jne    L87
L101:
  movslq 0x5c(%rsp),%rax
  movl   $0xa,0x6c(%rsp)
  movl   $0x0,0x68(%rsp)
  mov    %rax,0x50(%rsp)
  nopl   0x0(%rax,%rax,1)
L92:
  mov    0x68(%rsp),%eax
  cltd
  idivl  0x6c(%rsp)
  test   %edx,%edx
  je     L16
L162:
  addl   $0x1,0x68(%rsp)
  sub    $0x8,%rsp
  mov    %r12,%rcx
  mov    %r14,%r8
  mov    0x24(%rsp),%eax
  push   %rax
  push   %r13
  push   0x38(%rsp)
  mov    0x78(%rsp),%ebx
  mov    0x58(%rsp),%r9
  mov    0x94(%rsp),%edx
  mov    0x90(%rsp),%esi
  mov    %ebx,%edi
  mov    0x98(%rsp),%rax
  call   *%rax
  mov    0x7c(%rsp),%ecx
  add    $0x20,%rsp
  test   %ecx,%ecx
  jle    L115
  movslq %ebx,%rax
  movl   $0x0,0x48(%rsp)
  xor    %r15d,%r15d
  mov    %rbp,%rbx
  mov    %rax,0x10(%rsp)
  mov    %r15,%rbp
  nopw   0x0(%rax,%rax,1)
L129:
  mov    0x38(%rsp),%rax
  mov    %ebp,0x18(%rsp)
  movslq (%rax,%rbp,4),%rax
  cmpl   $0x1,(%rbx,%rax,4)
  mov    %eax,0xc(%rsp)
  mov    %rax,%rcx
  je     L52
  sub    $0x8,%rsp
  mov    %r13,%r8
  mov    %r12,%rsi
  mov    0x24(%rsp),%eax
  push   %rax
  push   %rcx
  mov    %r14,%rcx
  push   %rbp
  mov    0x48(%rsp),%r9
  mov    0x40(%rsp),%rdx
  mov    0x6c(%rsp),%edi
  mov    0x50(%rsp),%rax
  call   *%rax
  movsd  %xmm0,0x20(%rsp)
  mov    0x78(%rsp),%edx
  add    $0x20,%rsp
  test   %edx,%edx
  jle    L52
  xor    %r15d,%r15d
  mov    %rbp,0x40(%rsp)
  mov    %r13,%rbp
  mov    %rbx,%r13
  mov    %r15,%rbx
  mov    0x4c(%rsp),%r15d
  nopl   0x0(%rax,%rax,1)
L10:
  cmp    %ebx,0xc(%rsp)
  je     L140
  sub    $0x8,%rsp
  mov    %rbp,%r8
  mov    %r14,%rcx
  mov    %r12,%rsi
  mov    0x24(%rsp),%eax
  mov    %r15d,%edi
  push   %rax
  push   %rbx
  mov    0x30(%rsp),%eax
  push   %rax
  mov    0x48(%rsp),%r9
  mov    0x40(%rsp),%rdx
  mov    0x50(%rsp),%rax
  call   *%rax
  movsd  0x20(%rsp),%xmm1
  add    $0x20,%rsp
  comisd %xmm0,%xmm1
  jbe    L140
  mov    0x38(%rsp),%rax
  mov    0x40(%rsp),%rsi
  movsd  %xmm0,(%rsp)
  movl   $0x1,0x48(%rsp)
  movslq (%rax,%rsi,4),%rdx
  subl   $0x1,0x0(%r13,%rdx,4)
  mov    %ebx,(%rax,%rsi,4)
  addl   $0x1,0x0(%r13,%rbx,4)
L140:
  add    $0x1,%rbx
  cmp    %rbx,0x10(%rsp)
  jne    L10
  mov    %r13,%rbx
  mov    %rbp,%r13
  mov    0x40(%rsp),%rbp
L52:
  add    $0x1,%rbp
  cmp    %rbp,0x50(%rsp)
  jne    L129
  mov    0x48(%rsp),%eax
  mov    %rbx,%rbp
  test   %eax,%eax
  je     L115
  mov    0x38(%rsp),%rdx
  mov    0x60(%rsp),%rsi
  mov    0x5c(%rsp),%edi
  call   <equal_clusters@plt>
  test   %eax,%eax
  je     L92
L115:
  mov    0x60(%rsp),%rdi
  call   <free@plt>
  add    $0x88,%rsp
  mov    %rbp,%rdi
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  jmp    1080 <free@plt>
L16:
  mov    0x5c(%rsp),%esi
  test   %esi,%esi
  jle    L121
  mov    0x60(%rsp),%rcx
  mov    0x38(%rsp),%rsi
  xor    %eax,%eax
  mov    0x50(%rsp),%rdi
  nopl   0x0(%rax,%rax,1)
L62:
  mov    (%rsi,%rax,4),%edx
  mov    %edx,(%rcx,%rax,4)
  add    $0x1,%rax
  cmp    %rax,%rdi
  jne    L62
L121:
  shll   0x6c(%rsp)
  jmp    L162
L91:
  mov    0x74(%rsp),%eax
  mov    %eax,0x5c(%rsp)
  mov    0x70(%rsp),%eax
  mov    %eax,0x4c(%rsp)
  jmp    L9
```

assistant: ```c
void emalg(int nclusters, int nrows, int ncolumns, double **data, int **mask, double weight[], int transpose, void getclustercenter(int, int, int, double **, int **, int[], double **, int **, int), double metric(int, double **, double **, int **, int **, const double[], int, int, int), int clusterid[], double **cdata, int **cmask) {
  const int nitems = (transpose == 0) ? nrows : ncolumns;
  const int ndata = (transpose == 0) ? ncolumns : nrows;
  int *cn = calloc(nclusters, sizeof(int));
  int *savedids = malloc(nitems * sizeof(int));
  int changed;
  int iteration = 0;
  int period = 10;
  int i, j;
  for (i = 0; i < nitems; i++)
    cn[clusterid[i]]++;
  do {
    if (iteration % period == 0) {
      for (i = 0; i < nitems; i++)
        savedids[i] = clusterid[i];
      period *= 2;
    }
    iteration++;
    getclustercenter(nclusters, nrows, ncolumns, data, mask, clusterid, cdata, cmask, transpose);
    changed = 0;
    for (i = 0; i < nitems; i++) {
      double distance;
      int jnow = clusterid[i];
      if (cn[jnow] == 1)
        continue;
      distance = metric(ndata, data, cdata, mask, cmask, weight, i, jnow, transpose);
      for (j = 0; j < nclusters; j++) {
        double tdistance;
        if (j == jnow)
          continue;
        tdistance = metric(ndata, data, cdata, mask, cmask, weight, i, j, transpose);
        if (tdistance < distance) {
          distance = tdistance;
          cn[clusterid[i]]--;
          clusterid[i] = j;
          cn[j]++;
          changed = 1;
        }
      }
    }
  } while (changed && !equal_clusters(nitems, savedids, clusterid));
  free(savedids);
  free(cn);
  return;
}
```