user: Converte this assembly snippet into its equivalent C code:

```asm
<jerasure_smart_bitmatrix_to_schedule>:
  endbr64
  mov    %edi,%eax
  push   %r15
  imul   %esi,%eax
  push   %r14
  push   %r13
  mov    %edi,%r13d
  push   %r12
  mov    %edx,%r12d
  imul   %edx,%eax
  push   %rbp
  mov    %esi,%ebp
  push   %rbx
  imul   %r12d,%ebp
  imul   %edx,%eax
  sub    $0x68,%rsp
  lea    0x0(,%rbp,4),%r14d
  mov    %r8d,0x2c(%rsp)
  lea    0x8(,%rax,8),%edi
  mov    %rcx,0x20(%rsp)
  call   <malloc@plt>
  movslq %ebp,%rsi
  mov    %r14d,%edi
  mov    %rsi,(%rsp)
  mov    %rax,0x18(%rsp)
  call   <malloc@plt>
  mov    %r14d,%edi
  mov    %rax,0x40(%rsp)
  mov    %rax,%r15
  call   <malloc@plt>
  mov    %r14d,%edi
  mov    %rax,0x8(%rsp)
  call   <malloc@plt>
  mov    %r14d,%edi
  mov    %rax,0x10(%rsp)
  call   <malloc@plt>
  mov    %r13d,%esi
  mov    0x10(%rsp),%r9
  mov    0x2c(%rsp),%r8d
  imul   %r12d,%esi
  test   %ebp,%ebp
  mov    %rax,0x38(%rsp)
  lea    0x1(%rsi),%ebx
  mov    %ebx,0x4c(%rsp)
  jle    L74
  mov    %r15,%rdi
  mov    %rax,%rdx
  mov    %r15,%rcx
  mov    0x8(%rsp),%r15
  lea    -0x1(%rsi),%eax
  mov    %r9,%r11
  sub    %rdi,%rdx
  mov    %r13d,0x2c(%rsp)
  xor    %r10d,%r10d
  sub    %rdi,%r15
  sub    %rdi,%r11
  mov    %rdx,%r13
  lea    0x4(,%rax,4),%r14
  mov    0x20(%rsp),%rax
  nop
L211:
  lea    (%rax,%r14,1),%rdi
  xor    %edx,%edx
  test   %esi,%esi
  jle    L47
  nopw   0x0(%rax,%rax,1)
L57:
  add    (%rax),%edx
  add    $0x4,%rax
  cmp    %rdi,%rax
  jne    L57
L47:
  lea    0x1(%r10),%edi
  lea    -0x1(%r10),%r9d
  mov    %edx,(%rcx)
  movl   $0xffffffff,(%r15,%rcx,1)
  mov    %edi,(%r11,%rcx,1)
  mov    %r9d,0x0(%r13,%rcx,1)
  cmp    %edx,%ebx
  jle    L133
  mov    %edx,%ebx
  mov    %r10d,%r8d
L133:
  add    $0x4,%rcx
  cmp    %edi,%ebp
  je     L162
  mov    %edi,%r10d
  jmp    L211
L162:
  mov    0x10(%rsp),%r9
  mov    0x2c(%rsp),%r13d
L74:
  mov    (%rsp),%rax
  xor    %ecx,%ecx
  movslq %esi,%rbp
  mov    %r8d,%r14d
  movl   $0x0,0x48(%rsp)
  movl   $0xffffffff,-0x4(%r9,%rax,4)
  mov    %ecx,0x30(%rsp)
  nopw   0x0(%rax,%rax,1)
L277:
  movslq %r14d,%rax
  mov    0x38(%rsp),%rbx
  lea    0x0(,%rax,4),%r8
  movslq (%r9,%rax,4),%rax
  lea    (%rbx,%r8,1),%rdi
  movslq (%rdi),%rdx
  cmp    $0xffffffff,%edx
  je     L252
  mov    %eax,(%r9,%rdx,4)
  cmp    $0xffffffff,%eax
  je     L62
  mov    (%rdi),%edx
  mov    0x38(%rsp),%rbx
  mov    %edx,(%rbx,%rax,4)
L62:
  mov    %r13d,%eax
  mov    0x20(%rsp),%rbx
  imul   %r14d,%eax
  imul   %r12d,%eax
  cltq
  lea    (%rbx,%rax,4),%rbx
  mov    0x8(%rsp),%rax
  lea    (%rax,%r8,1),%r15
  cmpl   $0xffffffff,(%r15)
  jne    L92
  test   %esi,%esi
  jle    L142
  xor    %r8d,%r8d
  mov    %r14d,0x10(%rsp)
  xor    %r15d,%r15d
  mov    %r12d,%r14d
  mov    %r13d,0x2c(%rsp)
  mov    %rbx,%r12
  mov    %rbp,%r13
  mov    0x30(%rsp),%ebx
  mov    %r9,0x50(%rsp)
  mov    %r8d,%ebp
  mov    %esi,0x58(%rsp)
  jmp    L185
  nopl   0x0(%rax,%rax,1)
L105:
  add    $0x1,%r15
  cmp    %r15,%r13
  je     L64
L185:
  mov    (%r12,%r15,4),%eax
  test   %eax,%eax
  je     L105
  mov    $0x14,%edi
  mov    %r15d,(%rsp)
  add    $0x1,%r15
  call   <malloc@plt>
  mov    0x18(%rsp),%rcx
  mov    %rax,%rsi
  movslq %ebx,%rax
  add    $0x1,%ebx
  mov    %rsi,(%rcx,%rax,8)
  mov    (%rsp),%eax
  mov    %ebp,0x10(%rsi)
  mov    $0x1,%ebp
  cltd
  idiv   %r14d
  mov    %eax,(%rsi)
  mov    0x10(%rsp),%eax
  mov    %edx,0x4(%rsi)
  cltd
  idiv   %r14d
  add    0x2c(%rsp),%eax
  mov    %eax,0x8(%rsi)
  mov    %edx,0xc(%rsi)
  cmp    %r15,%r13
  jne    L185
L64:
  mov    %r13,%rbp
  mov    0x50(%rsp),%r9
  mov    0x58(%rsp),%esi
  mov    %ebx,0x30(%rsp)
  mov    0x2c(%rsp),%r13d
  mov    %r12,%rbx
  mov    %r14d,%r12d
  mov    0x10(%rsp),%r14d
L142:
  mov    0x48(%rsp),%r10d
  cmp    $0xffffffff,%r10d
  je     L214
L89:
  mov    %rbx,(%rsp)
  mov    %r14d,%r15d
  mov    0x4c(%rsp),%r11d
  mov    %r14d,0x10(%rsp)
  mov    0x40(%rsp),%r8
  mov    0x20(%rsp),%r14
  nopw   0x0(%rax,%rax,1)
L147:
  mov    %r13d,%eax
  imul   %r10d,%eax
  imul   %r12d,%eax
  cltq
  test   %esi,%esi
  jle    L63
  mov    (%rsp),%rbx
  lea    (%r14,%rax,4),%rdi
  mov    $0x1,%ecx
  xor    %eax,%eax
  nopl   0x0(%rax,%rax,1)
L260:
  mov    (%rbx,%rax,4),%edx
  xor    (%rdi,%rax,4),%edx
  add    $0x1,%rax
  add    %edx,%ecx
  cmp    %rax,%rbp
  jne    L260
  mov    %rbx,(%rsp)
L70:
  movslq %r10d,%rdx
  lea    (%r8,%rdx,4),%rdi
  mov    (%rdi),%eax
  cmp    %ecx,%eax
  jle    L15
  mov    0x8(%rsp),%rax
  mov    0x10(%rsp),%ebx
  mov    %ebx,(%rax,%rdx,4)
  mov    %ecx,%eax
  mov    %ecx,(%rdi)
L15:
  cmp    %eax,%r11d
  jle    L189
  mov    %eax,%r11d
  mov    %r10d,%r15d
L189:
  mov    (%r9,%rdx,4),%r10d
  cmp    $0xffffffff,%r10d
  jne    L147
  mov    %r15d,%r14d
  jmp    L277
  nop
L63:
  mov    $0x1,%ecx
  jmp    L70
L92:
  mov    $0x14,%edi
  mov    %esi,0x50(%rsp)
  mov    %r9,(%rsp)
  call   <malloc@plt>
  mov    0x18(%rsp),%rsi
  mov    (%rsp),%r9
  mov    %rax,%rdi
  movslq 0x30(%rsp),%rax
  mov    %rdi,(%rsi,%rax,8)
  mov    %rax,%rcx
  mov    0x50(%rsp),%esi
  movl   $0x0,0x10(%rdi)
  mov    (%r15),%eax
  add    $0x1,%ecx
  mov    %ecx,0x30(%rsp)
  cltd
  idiv   %r12d
  add    %r13d,%eax
  mov    %eax,(%rdi)
  mov    (%r15),%eax
  cltd
  idiv   %r12d
  mov    %r14d,%eax
  mov    %edx,0x4(%rdi)
  cltd
  idiv   %r12d
  add    %r13d,%eax
  mov    %edx,0xc(%rdi)
  mov    %eax,0x10(%rsp)
  mov    %eax,0x8(%rdi)
  mov    (%r15),%eax
  mov    %edx,0x2c(%rsp)
  imul   %r13d,%eax
  imul   %r12d,%eax
  test   %esi,%esi
  cltq
  jle    L142
  mov    0x20(%rsp),%rdi
  mov    %r9,0x30(%rsp)
  xor    %r15d,%r15d
  mov    %r12d,(%rsp)
  lea    (%rdi,%rax,4),%r10
  mov    %r14d,0x58(%rsp)
  mov    %r13d,0x5c(%rsp)
  mov    %r10,%r14
  mov    %rbx,%r13
  mov    %r15,%rbx
  mov    %rbp,%r15
  mov    %ecx,%ebp
  nopl   0x0(%rax,%rax,1)
L91:
  mov    (%r14,%rbx,4),%eax
  cmp    %eax,0x0(%r13,%rbx,4)
  je     L45
  mov    $0x14,%edi
  call   <malloc@plt>
  mov    0x18(%rsp),%rsi
  mov    %rax,%rdi
  movslq %ebp,%rax
  add    $0x1,%ebp
  mov    %rdi,(%rsi,%rax,8)
  mov    %ebx,%eax
  cltd
  movl   $0x1,0x10(%rdi)
  idivl  (%rsp)
  mov    %eax,(%rdi)
  mov    0x10(%rsp),%eax
  mov    %edx,0x4(%rdi)
  mov    %eax,0x8(%rdi)
  mov    0x2c(%rsp),%eax
  mov    %eax,0xc(%rdi)
L45:
  add    $0x1,%rbx
  cmp    %rbx,%r15
  jne    L91
  mov    0x48(%rsp),%r10d
  mov    0x30(%rsp),%r9
  mov    %r13,%rbx
  mov    %ebp,0x30(%rsp)
  mov    0x50(%rsp),%esi
  mov    0x58(%rsp),%r14d
  mov    %r15,%rbp
  mov    0x5c(%rsp),%r13d
  mov    (%rsp),%r12d
  cmp    $0xffffffff,%r10d
  jne    L89
L214:
  mov    0x30(%rsp),%ecx
  mov    $0x14,%edi
  mov    %r9,0x10(%rsp)
  mov    %ecx,(%rsp)
  call   <malloc@plt>
  movslq (%rsp),%rcx
  mov    0x18(%rsp),%rbx
  mov    0x8(%rsp),%rdi
  mov    %rax,(%rbx,%rcx,8)
  movl   $0xffffffff,(%rax)
  call   <free@plt>
  mov    0x40(%rsp),%rdi
  call   <free@plt>
  mov    0x38(%rsp),%rdi
  call   <free@plt>
  mov    0x10(%rsp),%rdi
  call   <free@plt>
  add    $0x68,%rsp
  mov    %rbx,%rax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L252:
  movl   $0xffffffff,0x48(%rsp)
  cmp    $0xffffffff,%eax
  je     L62
  movslq %eax,%rdx
  mov    %eax,0x48(%rsp)
  movl   $0xffffffff,(%rbx,%rdx,4)
  jmp    L62
```

assistant: ```c
int **jerasure_smart_bitmatrix_to_schedule(int k, int m, int w, int *bitmatrix) {
  int **operations;
  int op;
  int i, j;
  int *diff, *from, *b1, *flink, *blink;
  int *ptr, no, row;
  int optodo;
  int bestrow, bestdiff, top;
  operations = (int **)malloc(sizeof(int *) * (k * m * w * w + 1));
  op = 0;
  diff = (int *)malloc(sizeof(int) * (m * w));
  from = (int *)malloc(sizeof(int) * (m * w));
  flink = (int *)malloc(sizeof(int) * (m * w));
  blink = (int *)malloc(sizeof(int) * (m * w));
  ptr = bitmatrix;
  bestdiff = k * w + 1;
  top = 0;
  for (i = 0; i < m * w; i++) {
    no = 0;
    for (j = 0; j < k * w; j++) {
      no += *ptr;
      ptr++;
    }
    diff[i] = no;
    from[i] = -1;
    flink[i] = i + 1;
    blink[i] = i - 1;
    if (no < bestdiff) {
      bestdiff = no;
      bestrow = i;
    }
  }
  flink[m * w - 1] = -1;
  while (top != -1) {
    row = bestrow;
    if (blink[row] == -1) {
      top = flink[row];
      if (top != -1)
        blink[top] = -1;
    } else {
      flink[blink[row]] = flink[row];
      if (flink[row] != -1) {
        blink[flink[row]] = blink[row];
      }
    }
    ptr = bitmatrix + row * k * w;
    if (from[row] == -1) {
      optodo = 0;
      for (j = 0; j < k * w; j++) {
        if (ptr[j]) {
          operations[op] = (int *)malloc(sizeof(int) * (5));
          operations[op][4] = optodo;
          operations[op][0] = j / w;
          operations[op][1] = j % w;
          operations[op][2] = k + row / w;
          operations[op][3] = row % w;
          optodo = 1;
          op++;
        }
      }
    } else {
      operations[op] = (int *)malloc(sizeof(int) * (5));
      operations[op][4] = 0;
      operations[op][0] = k + from[row] / w;
      operations[op][1] = from[row] % w;
      operations[op][2] = k + row / w;
      operations[op][3] = row % w;
      op++;
      b1 = bitmatrix + from[row] * k * w;
      for (j = 0; j < k * w; j++) {
        if (ptr[j] ^ b1[j]) {
          operations[op] = (int *)malloc(sizeof(int) * (5));
          operations[op][4] = 1;
          operations[op][0] = j / w;
          operations[op][1] = j % w;
          operations[op][2] = k + row / w;
          operations[op][3] = row % w;
          optodo = 1;
          op++;
        }
      }
    }
    bestdiff = k * w + 1;
    for (i = top; i != -1; i = flink[i]) {
      no = 1;
      b1 = bitmatrix + i * k * w;
      for (j = 0; j < k * w; j++)
        no += (ptr[j] ^ b1[j]);
      if (no < diff[i]) {
        from[i] = row;
        diff[i] = no;
      }
      if (diff[i] < bestdiff) {
        bestdiff = diff[i];
        bestrow = i;
      }
    }
  }
  operations[op] = (int *)malloc(sizeof(int) * (5));
  operations[op][0] = -1;
  free(from);
  free(diff);
  free(blink);
  free(flink);
  return operations;
}
```