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

```asm
<calculate_glszm>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x98,%rsp
  mov    %rdi,0x18(%rsp)
  mov    %rsi,0x8(%rsp)
  mov    %rdx,0x78(%rsp)
  mov    %rcx,%rbx
  mov    %r8,%rbp
  mov    %r9,0x58(%rsp)
  mov    0xd8(%rsp),%r14d
  mov    0xf0(%rsp),%r15d
  movslq %r14d,%r12
  lea    0x0(,%r14,8),%edi
  call   <malloc@plt>
  mov    %rax,%r13
  lea    (%r15,%r15,1),%eax
  cltq
  mov    %rax,0x70(%rsp)
  movslq %r15d,%rax
  mov    %rax,0x40(%rsp)
  shl    $0x3,%r15d
  mov    %r15d,%edi
  call   <malloc@plt>
  mov    %rax,0x30(%rsp)
  movq   $0x0,0x28(%rsp)
  cmpl   $0x1,0xf8(%rsp)
  jg     L160
L206:
  mov    0x78(%rsp),%rdi
  movslq (%rdi),%rsi
  mov    %rsi,0x68(%rsp)
  mov    (%rbx),%eax
  imul   0x0(%rbp),%eax
  movslq %eax,%rcx
  mov    %rcx,0x38(%rsp)
  cmp    $0x1,%r12
  jbe    L23
  mov    $0x1,%eax
L377:
  mov    (%rbx,%rax,4),%edx
  imul   0x0(%rbp,%rax,4),%edx
  movslq %edx,%rdx
  add    %rdx,%rcx
  movslq (%rdi,%rax,4),%rdx
  imul   %rdx,%rsi
  add    $0x1,%rax
  cmp    %rax,%r12
  jne    L377
  mov    %rcx,0x38(%rsp)
  mov    %rsi,0x68(%rsp)
L23:
  mov    0x38(%rsp),%rdi
  cmp    %rdi,0x68(%rsp)
  jbe    L330
  lea    0x0(,%r12,4),%rdi
  mov    %rdi,(%rsp)
  lea    (%rbx,%rdi,1),%r9
  lea    -0x1(%r14),%eax
  cltq
  lea    0x0(%r13,%rax,8),%rax
  mov    %rax,0x80(%rsp)
  lea    0x0(%rbp,%rdi,1),%rax
  mov    %rax,0x60(%rsp)
  movq   $0x0,0x50(%rsp)
  movl   $0x0,0x4c(%rsp)
  movq   $0x0,0x20(%rsp)
  lea    -0x1(%r14),%eax
  mov    %eax,0x8c(%rsp)
  movslq 0xd0(%rsp),%r11
  jmp    L251
L160:
  mov    %r15d,%edi
  call   <malloc@plt>
  mov    %rax,0x28(%rsp)
  jmp    L206
L404:
  movslq (%rbx,%rcx,4),%rdx
  cmp    %rdx,%rax
  jae    L246
  sub    %rax,%rdx
  movslq 0x0(%rbp,%rcx,4),%rax
  imul   %rax,%rdx
  add    %rdx,%rdi
L246:
  sub    $0x8,%rsi
  sub    $0x1,%rcx
  je     L270
L82:
  movslq -0x4(%rbp,%rcx,4),%r10
  mov    %rdi,%rax
  mov    $0x0,%edx
  div    %r10
  movslq 0x0(%rbp,%rcx,4),%r10
  mov    %rdx,%rax
  mov    $0x0,%edx
  div    %r10
  mov    %rax,(%rsi)
  movslq (%r9,%rcx,4),%rdx
  cmp    %rdx,%rax
  jbe    L404
  movslq (%r8,%rcx,4),%rdx
  movslq (%rbx,%rcx,4),%r10
  add    %r10,%rdx
  sub    %rax,%rdx
  movslq 0x0(%rbp,%rcx,4),%rax
  imul   %rax,%rdx
  add    %rdx,%rdi
  jmp    L246
L270:
  mov    %rdi,0x38(%rsp)
L321:
  movslq 0x0(%rbp),%rcx
  mov    0x38(%rsp),%rax
  mov    $0x0,%edx
  div    %rcx
  movslq (%r9),%rdx
  cmp    %rdx,%rax
  ja     L185
  mov    0x8(%rsp),%rdi
  mov    0x38(%rsp),%rsi
  add    %rsi,%rdi
  mov    %rdi,%rax
  cmpb   $0x0,(%rdi)
  je     L180
  mov    0x18(%rsp),%rdi
  mov    (%rdi,%rsi,4),%edi
  mov    %edi,0x48(%rsp)
  cmpq   $0x0,0x28(%rsp)
  je     L426
  mov    0x20(%rsp),%rsi
  cmp    %rsi,0x40(%rsp)
  jbe    L365
  mov    0x28(%rsp),%rsi
  mov    0x20(%rsp),%rdi
  mov    0x38(%rsp),%rcx
  mov    %rcx,(%rsi,%rdi,8)
  lea    0x1(%rdi),%rdi
  mov    %rdi,0x20(%rsp)
L426:
  mov    0x30(%rsp),%rdi
  mov    0x38(%rsp),%rsi
  mov    %rsi,(%rdi)
  movb   $0x0,(%rax)
  movl   $0x0,0x88(%rsp)
  movq   $0x1,0x10(%rsp)
  jmp    L205
L365:
  mov    %r13,%rdi
  call   <free@plt>
  mov    0x30(%rsp),%rdi
  call   <free@plt>
  movl   $0xffffffff,0x4c(%rsp)
  jmp    L433
L28:
  mov    %r13,%rdi
  call   <free@plt>
  mov    0x30(%rsp),%rdi
  call   <free@plt>
  movl   $0xffffffff,0x4c(%rsp)
L433:
  mov    0x4c(%rsp),%eax
  add    $0x98,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L55:
  mov    0x30(%rsp),%rcx
  mov    0x10(%rsp),%rsi
  mov    %rdi,(%rcx,%rsi,8)
  movb   $0x0,(%rax)
  lea    0x1(%rsi),%rax
  mov    %rax,0x10(%rsp)
L396:
  add    $0x1,%r15
  add    (%rsp),%r14
  cmp    %r11,%r15
  je     L449
L137:
  mov    %r13,%rsi
  mov    %r10,%rdi
  mov    $0x0,%eax
  test   %r12,%r12
  je     L396
L254:
  mov    (%r14,%rax,4),%edx
  movslq %edx,%rcx
  add    (%rsi),%rcx
  movslq (%rbx,%rax,4),%r8
  cmp    %r8,%rcx
  jb     L396
  movslq (%r9,%rax,4),%r8
  cmp    %r8,%rcx
  ja     L396
  imul   0x0(%rbp,%rax,4),%edx
  movslq %edx,%rdx
  add    %rdx,%rdi
  add    $0x1,%rax
  add    $0x8,%rsi
  cmp    %rax,%r12
  jne    L254
  cmp    %rdi,%r10
  je     L396
  mov    0x8(%rsp),%rax
  add    %rdi,%rax
  cmpb   $0x0,(%rax)
  je     L396
  mov    0x18(%rsp),%rsi
  mov    0x48(%rsp),%ecx
  cmp    %ecx,(%rsi,%rdi,4)
  jne    L396
  cmpq   $0x0,0x28(%rsp)
  je     L55
  mov    0x20(%rsp),%rcx
  cmp    %rcx,0x40(%rsp)
  jbe    L28
  mov    0x28(%rsp),%rcx
  mov    0x20(%rsp),%rsi
  mov    %rdi,(%rcx,%rsi,8)
  lea    0x1(%rsi),%rsi
  mov    %rsi,0x20(%rsp)
  jmp    L55
L449:
  cmpq   $0x0,0x10(%rsp)
  je     L250
L205:
  subq   $0x1,0x10(%rsp)
  mov    0x10(%rsp),%rax
  mov    0x30(%rsp),%rdi
  mov    (%rdi,%rax,8),%r10
  addl   $0x1,0x88(%rsp)
  movslq 0x0(%rbp),%rcx
  mov    %r10,%rax
  mov    $0x0,%edx
  div    %rcx
  mov    %rax,0x0(%r13)
  cmp    $0x1,%r12
  jbe    L165
  lea    0x8(%r13),%rsi
  lea    0x4(%rbp),%rcx
  mov    0x60(%rsp),%r8
L294:
  movslq -0x4(%rcx),%rdi
  mov    %r10,%rax
  mov    $0x0,%edx
  div    %rdi
  movslq (%rcx),%rdi
  mov    %rdx,%rax
  mov    $0x0,%edx
  div    %rdi
  mov    %rax,(%rsi)
  add    $0x8,%rsi
  add    $0x4,%rcx
  cmp    %r8,%rcx
  jne    L294
L165:
  test   %r11,%r11
  je     L449
  mov    0x58(%rsp),%r14
  mov    $0x0,%r15d
  jmp    L137
L250:
  mov    0x50(%rsp),%rdi
  cmp    %rdi,0x70(%rsp)
  jbe    L345
  mov    0x4c(%rsp),%eax
  mov    0x88(%rsp),%edi
  cmp    %edi,%eax
  cmovl  %edi,%eax
  mov    %eax,0x4c(%rsp)
  mov    0xe0(%rsp),%rsi
  mov    0x50(%rsp),%rax
  mov    0x48(%rsp),%ecx
  mov    %ecx,(%rsi,%rax,8)
  mov    %edi,0x4(%rsi,%rax,8)
  add    $0x1,%rax
  mov    %rax,0x50(%rsp)
L180:
  addq   $0x1,0x38(%rsp)
  mov    0x38(%rsp),%rax
  cmp    0x68(%rsp),%rax
  jae    L185
L251:
  movslq 0x8c(%rsp),%rcx
  test   %rcx,%rcx
  je     L321
  mov    0x80(%rsp),%rsi
  mov    0x38(%rsp),%rdi
  mov    0x78(%rsp),%r8
  jmp    L82
L345:
  mov    %r13,%rdi
  call   <free@plt>
  mov    0x30(%rsp),%rdi
  call   <free@plt>
  movl   $0xffffffff,0x4c(%rsp)
  jmp    L433
L185:
  mov    %r13,%rdi
  call   <free@plt>
  mov    0x30(%rsp),%rdi
  call   <free@plt>
  mov    0x28(%rsp),%rcx
  test   %rcx,%rcx
  je     L279
  mov    0x20(%rsp),%rax
  test   %rax,%rax
  je     L111
L83:
  sub    $0x1,%rax
  mov    (%rcx,%rax,8),%rdx
  mov    0x8(%rsp),%rbx
  movb   $0x1,(%rbx,%rdx,1)
  jne    L83
L111:
  mov    0x28(%rsp),%rdi
  call   <free@plt>
L279:
  mov    0x50(%rsp),%rax
  mov    0x70(%rsp),%rbx
  cmp    %rbx,%rax
  jae    L109
  mov    0xe0(%rsp),%rbx
  movl   $0xffffffff,(%rbx,%rax,8)
  jmp    L433
L86:
  movq   $0x0,0x50(%rsp)
  movl   $0x0,0x4c(%rsp)
  jmp    L111
L109:
  movl   $0xffffffff,0x4c(%rsp)
  jmp    L433
L330:
  mov    %r13,%rdi
  call   <free@plt>
  mov    0x30(%rsp),%rdi
  call   <free@plt>
  cmpq   $0x0,0x28(%rsp)
  jne    L86
  movq   $0x0,0x50(%rsp)
  movl   $0x0,0x4c(%rsp)
  jmp    L279
```

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;
}
```