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

```asm
<calculate_glszm>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0xb0,%rsp
  mov    %rdi,-0x88(%rbp)
  mov    %rsi,-0x90(%rbp)
  mov    %rdx,-0x98(%rbp)
  mov    %rcx,-0xa0(%rbp)
  mov    %r8,-0xa8(%rbp)
  mov    %r9,-0xb0(%rbp)
  mov    0x18(%rbp),%eax
  cltq
  shl    $0x3,%eax
  mov    %eax,%edi
  call   <malloc@plt>
  mov    %rax,-0x20(%rbp)
  movq   $0x0,-0x50(%rbp)
  movq   $0x0,-0x48(%rbp)
  movq   $0x0,-0x40(%rbp)
  movl   $0x0,-0x70(%rbp)
  movq   $0x0,-0x28(%rbp)
  mov    0x30(%rbp),%eax
  add    %eax,%eax
  cltq
  mov    %rax,-0x18(%rbp)
  mov    0x30(%rbp),%eax
  cltq
  shl    $0x3,%eax
  mov    %eax,%edi
  call   <malloc@plt>
  mov    %rax,-0x10(%rbp)
  cmpl   $0x1,0x38(%rbp)
  jle    L64
  mov    0x30(%rbp),%eax
  cltq
  shl    $0x3,%eax
  mov    %eax,%edi
  call   <malloc@plt>
  mov    %rax,-0x48(%rbp)
L64:
  mov    -0x98(%rbp),%rax
  mov    (%rax),%eax
  cltq
  mov    %rax,-0x68(%rbp)
  mov    -0xa0(%rbp),%rax
  mov    (%rax),%edx
  mov    -0xa8(%rbp),%rax
  mov    (%rax),%eax
  imul   %edx,%eax
  cltq
  mov    %rax,-0x60(%rbp)
  movq   $0x1,-0x30(%rbp)
  jmp    L14
L160:
  mov    -0x30(%rbp),%rax
  lea    0x0(,%rax,4),%rdx
  mov    -0xa0(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%edx
  mov    -0x30(%rbp),%rax
  lea    0x0(,%rax,4),%rcx
  mov    -0xa8(%rbp),%rax
  add    %rcx,%rax
  mov    (%rax),%eax
  imul   %edx,%eax
  cltq
  add    %rax,-0x60(%rbp)
  mov    -0x30(%rbp),%rax
  lea    0x0(,%rax,4),%rdx
  mov    -0x98(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%eax
  cltq
  mov    -0x68(%rbp),%rdx
  imul   %rdx,%rax
  mov    %rax,-0x68(%rbp)
  addq   $0x1,-0x30(%rbp)
L14:
  mov    0x18(%rbp),%eax
  cltq
  cmp    %rax,-0x30(%rbp)
  jb     L160
  jmp    L1
L227:
  mov    0x18(%rbp),%eax
  sub    $0x1,%eax
  cltq
  mov    %rax,-0x30(%rbp)
  jmp    L368
L316:
  mov    -0x30(%rbp),%rax
  shl    $0x2,%rax
  lea    -0x4(%rax),%rdx
  mov    -0xa8(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%eax
  movslq %eax,%rcx
  mov    -0x60(%rbp),%rax
  mov    $0x0,%edx
  div    %rcx
  mov    %rdx,%rsi
  mov    -0x30(%rbp),%rax
  lea    0x0(,%rax,4),%rdx
  mov    -0xa8(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%eax
  movslq %eax,%rdi
  mov    -0x30(%rbp),%rax
  lea    0x0(,%rax,8),%rcx
  mov    -0x20(%rbp),%rax
  add    %rax,%rcx
  mov    %rsi,%rax
  mov    $0x0,%edx
  div    %rdi
  mov    %rax,(%rcx)
  mov    -0x30(%rbp),%rax
  lea    0x0(,%rax,8),%rdx
  mov    -0x20(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%rdx
  mov    0x18(%rbp),%eax
  movslq %eax,%rcx
  mov    -0x30(%rbp),%rax
  add    %rcx,%rax
  lea    0x0(,%rax,4),%rcx
  mov    -0xa0(%rbp),%rax
  add    %rcx,%rax
  mov    (%rax),%eax
  cltq
  cmp    %rax,%rdx
  jbe    L110
  mov    -0x30(%rbp),%rax
  lea    0x0(,%rax,4),%rdx
  mov    -0x98(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%eax
  cltq
  mov    -0x30(%rbp),%rdx
  lea    0x0(,%rdx,8),%rcx
  mov    -0x20(%rbp),%rdx
  add    %rcx,%rdx
  mov    (%rdx),%rdx
  sub    %rdx,%rax
  mov    %rax,%rcx
  mov    -0x30(%rbp),%rax
  lea    0x0(,%rax,4),%rdx
  mov    -0xa0(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%eax
  cltq
  lea    (%rcx,%rax,1),%rdx
  mov    -0x30(%rbp),%rax
  lea    0x0(,%rax,4),%rcx
  mov    -0xa8(%rbp),%rax
  add    %rcx,%rax
  mov    (%rax),%eax
  cltq
  imul   %rdx,%rax
  add    %rax,-0x60(%rbp)
  jmp    L298
L110:
  mov    -0x30(%rbp),%rax
  lea    0x0(,%rax,8),%rdx
  mov    -0x20(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%rdx
  mov    -0x30(%rbp),%rax
  lea    0x0(,%rax,4),%rcx
  mov    -0xa0(%rbp),%rax
  add    %rcx,%rax
  mov    (%rax),%eax
  cltq
  cmp    %rax,%rdx
  jae    L298
  mov    -0x30(%rbp),%rax
  lea    0x0(,%rax,4),%rdx
  mov    -0xa0(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%eax
  cltq
  mov    -0x30(%rbp),%rdx
  lea    0x0(,%rdx,8),%rcx
  mov    -0x20(%rbp),%rdx
  add    %rcx,%rdx
  mov    (%rdx),%rcx
  sub    %rcx,%rax
  mov    %rax,%rdx
  mov    -0x30(%rbp),%rax
  lea    0x0(,%rax,4),%rcx
  mov    -0xa8(%rbp),%rax
  add    %rcx,%rax
  mov    (%rax),%eax
  cltq
  imul   %rdx,%rax
  add    %rax,-0x60(%rbp)
L298:
  subq   $0x1,-0x30(%rbp)
L368:
  cmpq   $0x0,-0x30(%rbp)
  jne    L316
  mov    -0xa8(%rbp),%rax
  mov    (%rax),%eax
  movslq %eax,%rsi
  mov    -0x60(%rbp),%rax
  mov    $0x0,%edx
  div    %rsi
  mov    %rax,%rdx
  mov    0x18(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rcx
  mov    -0xa0(%rbp),%rax
  add    %rcx,%rax
  mov    (%rax),%eax
  cltq
  cmp    %rax,%rdx
  ja     L68
  mov    -0x90(%rbp),%rdx
  mov    -0x60(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%eax
  test   %al,%al
  je     L350
  mov    -0x60(%rbp),%rax
  lea    0x0(,%rax,4),%rdx
  mov    -0x88(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%eax
  mov    %eax,-0x6c(%rbp)
  movl   $0x0,-0x74(%rbp)
  cmpq   $0x0,-0x48(%rbp)
  je     L138
  mov    0x30(%rbp),%eax
  cltq
  cmp    %rax,-0x40(%rbp)
  jb     L149
  mov    -0x20(%rbp),%rax
  mov    %rax,%rdi
  call   <free@plt>
  mov    -0x10(%rbp),%rax
  mov    %rax,%rdi
  call   <free@plt>
  mov    $0xffffffff,%eax
  jmp    L334
L149:
  mov    -0x40(%rbp),%rax
  lea    0x1(%rax),%rdx
  mov    %rdx,-0x40(%rbp)
  lea    0x0(,%rax,8),%rdx
  mov    -0x48(%rbp),%rax
  add    %rax,%rdx
  mov    -0x60(%rbp),%rax
  mov    %rax,(%rdx)
L138:
  mov    -0x50(%rbp),%rax
  lea    0x1(%rax),%rdx
  mov    %rdx,-0x50(%rbp)
  lea    0x0(,%rax,8),%rdx
  mov    -0x10(%rbp),%rax
  add    %rax,%rdx
  mov    -0x60(%rbp),%rax
  mov    %rax,(%rdx)
  mov    -0x90(%rbp),%rdx
  mov    -0x60(%rbp),%rax
  add    %rdx,%rax
  movb   $0x0,(%rax)
  jmp    L171
L250:
  subq   $0x1,-0x50(%rbp)
  mov    -0x50(%rbp),%rax
  lea    0x0(,%rax,8),%rdx
  mov    -0x10(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%rax
  mov    %rax,-0x8(%rbp)
  addl   $0x1,-0x74(%rbp)
  mov    -0xa8(%rbp),%rax
  mov    (%rax),%eax
  movslq %eax,%rsi
  mov    -0x8(%rbp),%rax
  mov    $0x0,%edx
  div    %rsi
  mov    %rax,%rdx
  mov    -0x20(%rbp),%rax
  mov    %rdx,(%rax)
  movq   $0x1,-0x30(%rbp)
  jmp    L402
L151:
  mov    -0x30(%rbp),%rax
  shl    $0x2,%rax
  lea    -0x4(%rax),%rdx
  mov    -0xa8(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%eax
  movslq %eax,%rcx
  mov    -0x8(%rbp),%rax
  mov    $0x0,%edx
  div    %rcx
  mov    %rdx,%rsi
  mov    -0x30(%rbp),%rax
  lea    0x0(,%rax,4),%rdx
  mov    -0xa8(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%eax
  movslq %eax,%rdi
  mov    -0x30(%rbp),%rax
  lea    0x0(,%rax,8),%rcx
  mov    -0x20(%rbp),%rax
  add    %rax,%rcx
  mov    %rsi,%rax
  mov    $0x0,%edx
  div    %rdi
  mov    %rax,(%rcx)
  addq   $0x1,-0x30(%rbp)
L402:
  mov    0x18(%rbp),%eax
  cltq
  cmp    %rax,-0x30(%rbp)
  jb     L151
  movq   $0x0,-0x38(%rbp)
  jmp    L134
L97:
  mov    -0x8(%rbp),%rax
  mov    %rax,-0x58(%rbp)
  movq   $0x0,-0x30(%rbp)
  jmp    L225
L71:
  mov    -0x30(%rbp),%rax
  lea    0x0(,%rax,8),%rdx
  mov    -0x20(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%rdx
  mov    0x18(%rbp),%eax
  cltq
  imul   -0x38(%rbp),%rax
  mov    %rax,%rcx
  mov    -0x30(%rbp),%rax
  add    %rcx,%rax
  lea    0x0(,%rax,4),%rcx
  mov    -0xb0(%rbp),%rax
  add    %rcx,%rax
  mov    (%rax),%eax
  cltq
  add    %rax,%rdx
  mov    -0x30(%rbp),%rax
  lea    0x0(,%rax,4),%rcx
  mov    -0xa0(%rbp),%rax
  add    %rcx,%rax
  mov    (%rax),%eax
  cltq
  cmp    %rax,%rdx
  jb     L247
  mov    -0x30(%rbp),%rax
  lea    0x0(,%rax,8),%rdx
  mov    -0x20(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%rdx
  mov    0x18(%rbp),%eax
  cltq
  imul   -0x38(%rbp),%rax
  mov    %rax,%rcx
  mov    -0x30(%rbp),%rax
  add    %rcx,%rax
  lea    0x0(,%rax,4),%rcx
  mov    -0xb0(%rbp),%rax
  add    %rcx,%rax
  mov    (%rax),%eax
  cltq
  add    %rax,%rdx
  mov    0x18(%rbp),%eax
  movslq %eax,%rcx
  mov    -0x30(%rbp),%rax
  add    %rcx,%rax
  lea    0x0(,%rax,4),%rcx
  mov    -0xa0(%rbp),%rax
  add    %rcx,%rax
  mov    (%rax),%eax
  cltq
  cmp    %rax,%rdx
  jbe    L294
L247:
  mov    -0x8(%rbp),%rax
  mov    %rax,-0x58(%rbp)
  jmp    L380
L294:
  mov    0x18(%rbp),%eax
  cltq
  imul   -0x38(%rbp),%rax
  mov    %rax,%rdx
  mov    -0x30(%rbp),%rax
  add    %rdx,%rax
  lea    0x0(,%rax,4),%rdx
  mov    -0xb0(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%edx
  mov    -0x30(%rbp),%rax
  lea    0x0(,%rax,4),%rcx
  mov    -0xa8(%rbp),%rax
  add    %rcx,%rax
  mov    (%rax),%eax
  imul   %edx,%eax
  cltq
  add    %rax,-0x58(%rbp)
  addq   $0x1,-0x30(%rbp)
L225:
  mov    0x18(%rbp),%eax
  cltq
  cmp    %rax,-0x30(%rbp)
  jb     L71
L380:
  mov    -0x58(%rbp),%rax
  cmp    -0x8(%rbp),%rax
  je     L188
  mov    -0x90(%rbp),%rdx
  mov    -0x58(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%eax
  test   %al,%al
  je     L188
  mov    -0x58(%rbp),%rax
  lea    0x0(,%rax,4),%rdx
  mov    -0x88(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%eax
  cmp    %eax,-0x6c(%rbp)
  jne    L188
  cmpq   $0x0,-0x48(%rbp)
  je     L153
  mov    0x30(%rbp),%eax
  cltq
  cmp    %rax,-0x40(%rbp)
  jb     L229
  mov    -0x20(%rbp),%rax
  mov    %rax,%rdi
  call   <free@plt>
  mov    -0x10(%rbp),%rax
  mov    %rax,%rdi
  call   <free@plt>
  mov    $0xffffffff,%eax
  jmp    L334
L229:
  mov    -0x40(%rbp),%rax
  lea    0x1(%rax),%rdx
  mov    %rdx,-0x40(%rbp)
  lea    0x0(,%rax,8),%rdx
  mov    -0x48(%rbp),%rax
  add    %rax,%rdx
  mov    -0x58(%rbp),%rax
  mov    %rax,(%rdx)
L153:
  mov    -0x50(%rbp),%rax
  lea    0x1(%rax),%rdx
  mov    %rdx,-0x50(%rbp)
  lea    0x0(,%rax,8),%rdx
  mov    -0x10(%rbp),%rax
  add    %rax,%rdx
  mov    -0x58(%rbp),%rax
  mov    %rax,(%rdx)
  mov    -0x90(%rbp),%rdx
  mov    -0x58(%rbp),%rax
  add    %rdx,%rax
  movb   $0x0,(%rax)
L188:
  addq   $0x1,-0x38(%rbp)
L134:
  mov    0x10(%rbp),%eax
  cltq
  cmp    %rax,-0x38(%rbp)
  jb     L97
L171:
  cmpq   $0x0,-0x50(%rbp)
  jne    L250
  mov    -0x28(%rbp),%rax
  cmp    -0x18(%rbp),%rax
  jb     L388
  mov    -0x20(%rbp),%rax
  mov    %rax,%rdi
  call   <free@plt>
  mov    -0x10(%rbp),%rax
  mov    %rax,%rdi
  call   <free@plt>
  mov    $0xffffffff,%eax
  jmp    L334
L388:
  mov    -0x74(%rbp),%eax
  cmp    -0x70(%rbp),%eax
  jle    L0
  mov    -0x74(%rbp),%eax
  mov    %eax,-0x70(%rbp)
L0:
  mov    -0x28(%rbp),%rax
  lea    0x0(,%rax,8),%rdx
  mov    0x20(%rbp),%rax
  add    %rax,%rdx
  mov    -0x6c(%rbp),%eax
  mov    %eax,(%rdx)
  mov    -0x28(%rbp),%rax
  shl    $0x3,%rax
  lea    0x4(%rax),%rdx
  mov    0x20(%rbp),%rax
  add    %rax,%rdx
  mov    -0x74(%rbp),%eax
  mov    %eax,(%rdx)
  addq   $0x1,-0x28(%rbp)
L350:
  addq   $0x1,-0x60(%rbp)
L1:
  mov    -0x60(%rbp),%rax
  cmp    -0x68(%rbp),%rax
  jb     L227
  jmp    L203
L68:
  nop
L203:
  mov    -0x20(%rbp),%rax
  mov    %rax,%rdi
  call   <free@plt>
  mov    -0x10(%rbp),%rax
  mov    %rax,%rdi
  call   <free@plt>
  cmpq   $0x0,-0x48(%rbp)
  je     L266
  jmp    L239
L178:
  subq   $0x1,-0x40(%rbp)
  mov    -0x40(%rbp),%rax
  lea    0x0(,%rax,8),%rdx
  mov    -0x48(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%rdx
  mov    -0x90(%rbp),%rax
  add    %rdx,%rax
  movb   $0x1,(%rax)
L239:
  cmpq   $0x0,-0x40(%rbp)
  jne    L178
  mov    -0x48(%rbp),%rax
  mov    %rax,%rdi
  call   <free@plt>
L266:
  mov    -0x28(%rbp),%rax
  cmp    -0x18(%rbp),%rax
  jb     L269
  mov    $0xffffffff,%eax
  jmp    L334
L269:
  mov    -0x28(%rbp),%rax
  lea    0x0(,%rax,8),%rdx
  mov    0x20(%rbp),%rax
  add    %rdx,%rax
  movl   $0xffffffff,(%rax)
  mov    -0x70(%rbp),%eax
L334:
  leave
  ret
```

assistant: ```c
int calculate_glszm(int *image, char *mask, int *size, int *bb, int *strides, int *angles, int Na, int Nd, int *tempData, int Ng, int Ns, int Nvox) {
  size_t Ni;
  size_t i, j, k;
  size_t *cur_idx = (size_t *)malloc(sizeof *cur_idx * Nd);
  size_t *regionStack;
  size_t stackTop = 0;
  size_t *processedStack = NULL;
  size_t processed_idx = 0;
  size_t a, d;
  int gl, region;
  int maxSize = 0;
  size_t temp_idx = 0;
  size_t temp_idx_max = Ns * 2;
  regionStack = (size_t *)malloc(sizeof *regionStack * Ns);
  if (Nvox > 1)
    processedStack = (size_t *)malloc(sizeof *processedStack * Ns);
  Ni = size[0];
  i = bb[0] * strides[0];
  for (d = 1; d < Nd; d++) {
    i += bb[d] * strides[d];
    Ni *= size[d];
  }
  for (; i < Ni; i++) {
    for (d = Nd - 1; d > 0; d--) {
      cur_idx[d] = (i % strides[d - 1]) / strides[d];
      if (cur_idx[d] > bb[Nd + d])
        i += (size[d] - cur_idx[d] + bb[d]) * strides[d];
      else if (cur_idx[d] < bb[d])
        i += (bb[d] - cur_idx[d]) * strides[d];
    }
    if (i / strides[0] > bb[Nd])
      break;
    if (mask[i]) {
      gl = image[i];
      region = 0;
      if (processedStack) {
        if (processed_idx >= Ns) {
          free(cur_idx);
          free(regionStack);
          return -1;
        }
        processedStack[processed_idx++] = i;
      }
      regionStack[stackTop++] = i;
      mask[i] = 0;
      while (stackTop > 0) {
        k = regionStack[--stackTop];
        region++;
        cur_idx[0] = k / strides[0];
        for (d = 1; d < Nd; d++)
          cur_idx[d] = (k % strides[d - 1]) / strides[d];
        for (a = 0; a < Na; a++) {
          j = k;
          for (d = 0; d < Nd; d++) {
            if (cur_idx[d] + angles[a * Nd + d] < bb[d] || cur_idx[d] + angles[a * Nd + d] > bb[Nd + d]) {
              j = k;
              break;
            }
            j += angles[a * Nd + d] * strides[d];
          }
          if (j != k && mask[j] && (image[j] == gl)) {
            if (processedStack) {
              if (processed_idx >= Ns) {
                free(cur_idx);
                free(regionStack);
                return -1;
              }
              processedStack[processed_idx++] = j;
            }
            regionStack[stackTop++] = j;
            mask[j] = 0;
          }
        }
      }
      if (temp_idx >= temp_idx_max) {
        free(cur_idx);
        free(regionStack);
        return -1;
      }
      if (region > maxSize)
        maxSize = region;
      tempData[(temp_idx * 2)] = gl;
      tempData[((temp_idx * 2) + 1)] = region;
      temp_idx++;
    }
  }
  free(cur_idx);
  free(regionStack);
  if (processedStack) {
    while (processed_idx > 0)
      mask[processedStack[--processed_idx]] = 1;
    free(processedStack);
  }
  if (temp_idx >= temp_idx_max)
    return -1;
  tempData[(temp_idx * 2)] = -1;
  return maxSize;
}
```