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

```asm
<calculate_glszm>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  mov    %r8,%rbp
  push   %rbx
  mov    %rcx,%rbx
  sub    $0xa8,%rsp
  movslq 0xe8(%rsp),%r12
  mov    0x100(%rsp),%r15d
  mov    %rdi,0x28(%rsp)
  mov    %rsi,0x10(%rsp)
  lea    0x0(,%r12,8),%edi
  mov    %rdx,0x80(%rsp)
  mov    %r12,%r14
  mov    %r9,0x70(%rsp)
  call   <malloc@plt>
  mov    %rax,%r13
  lea    (%r15,%r15,1),%eax
  cltq
  mov    %rax,0x88(%rsp)
  movslq %r15d,%rax
  shl    $0x3,%r15d
  mov    %r15d,%edi
  mov    %rax,0x58(%rsp)
  call   <malloc@plt>
  cmpl   $0x1,0x108(%rsp)
  movq   $0x0,0x40(%rsp)
  mov    %rax,0x48(%rsp)
  jle    L400
  mov    %r15d,%edi
  call   <malloc@plt>
  mov    %rax,0x40(%rsp)
L400:
  mov    0x80(%rsp),%rsi
  mov    0x0(%rbp),%r10d
  movslq (%rsi),%rax
  mov    %rax,0x50(%rsp)
  mov    (%rbx),%eax
  imul   %r10d,%eax
  cltq
  mov    %rax,0x38(%rsp)
  cmp    $0x1,%r12
  jbe    L10
  lea    -0x2(%r12),%rax
  lea    -0x1(%r12),%rcx
  cmp    $0xb,%rax
  jbe    L341
  mov    %rcx,%rax
  movdqa D7(%rip),%xmm0
  pxor   %xmm3,%xmm3
  pxor   %xmm4,%xmm4
  shr    $0x2,%rax
  shl    $0x4,%rax
  lea    0x4(%rax),%rdx
  mov    $0x4,%eax
L217:
  movdqu 0x0(%rbp,%rax,1),%xmm2
  movdqu (%rbx,%rax,1),%xmm5
  movdqu (%rbx,%rax,1),%xmm7
  movdqu 0x0(%rbp,%rax,1),%xmm1
  psrlq  $0x20,%xmm5
  psrlq  $0x20,%xmm2
  pmuludq %xmm7,%xmm1
  pmuludq %xmm5,%xmm2
  pshufd $0x8,%xmm1,%xmm1
  pshufd $0x8,%xmm2,%xmm2
  punpckldq %xmm2,%xmm1
  movdqa %xmm4,%xmm2
  pcmpgtd %xmm1,%xmm2
  movdqa %xmm1,%xmm5
  punpckhdq %xmm2,%xmm5
  punpckldq %xmm2,%xmm1
  movdqu (%rsi,%rax,1),%xmm2
  add    $0x10,%rax
  paddq  %xmm5,%xmm1
  paddq  %xmm1,%xmm3
  movdqa %xmm4,%xmm1
  movdqa %xmm2,%xmm7
  pcmpgtd %xmm2,%xmm1
  punpckldq %xmm1,%xmm2
  punpckhdq %xmm1,%xmm7
  movdqa %xmm2,%xmm6
  movdqa %xmm7,%xmm1
  movdqa %xmm7,%xmm5
  psrlq  $0x20,%xmm1
  psrlq  $0x20,%xmm6
  pmuludq %xmm2,%xmm1
  pmuludq %xmm7,%xmm6
  pmuludq %xmm2,%xmm5
  paddq  %xmm6,%xmm1
  psllq  $0x20,%xmm1
  paddq  %xmm1,%xmm5
  movdqa %xmm5,%xmm2
  movdqa %xmm5,%xmm6
  movdqa %xmm5,%xmm1
  psrlq  $0x20,%xmm1
  pmuludq %xmm0,%xmm6
  movdqa %xmm0,%xmm5
  psrlq  $0x20,%xmm5
  pmuludq %xmm1,%xmm0
  pmuludq %xmm2,%xmm5
  paddq  %xmm5,%xmm0
  psllq  $0x20,%xmm0
  paddq  %xmm6,%xmm0
  cmp    %rax,%rdx
  jne    L217
  movdqa %xmm0,%xmm5
  movdqa %xmm0,%xmm4
  psrldq $0x8,%xmm5
  psrlq  $0x20,%xmm4
  movdqa %xmm5,%xmm1
  pmuludq %xmm5,%xmm4
  movdqa %xmm5,%xmm2
  psrlq  $0x20,%xmm1
  pmuludq %xmm0,%xmm2
  pmuludq %xmm1,%xmm0
  paddq  %xmm4,%xmm0
  psllq  $0x20,%xmm0
  paddq  %xmm2,%xmm0
  movq   %xmm0,%rax
  imul   0x50(%rsp),%rax
  movdqa %xmm3,%xmm0
  psrldq $0x8,%xmm0
  paddq  %xmm0,%xmm3
  mov    %rax,0x50(%rsp)
  movq   %xmm3,%rax
  add    %rax,0x38(%rsp)
  mov    %rcx,%rax
  and    $0xfffffffffffffffc,%rax
  lea    0x1(%rax),%rdx
  cmp    %rcx,%rax
  je     L10
L407:
  mov    (%rbx,%rdx,4),%ecx
  imul   0x0(%rbp,%rdx,4),%ecx
  lea    0x0(,%rdx,4),%rax
  mov    0x80(%rsp),%rsi
  movslq %ecx,%rcx
  add    %rcx,0x38(%rsp)
  movslq (%rsi,%rdx,4),%rcx
  imul   0x50(%rsp),%rcx
  mov    0x38(%rsp),%rdi
  mov    %rcx,0x50(%rsp)
  mov    %rcx,%r11
  lea    0x1(%rdx),%rcx
  cmp    %rcx,%r12
  jbe    L10
  mov    0x4(%rbp,%rax,1),%ecx
  imul   0x4(%rbx,%rax,1),%ecx
  movslq %ecx,%rcx
  add    %rcx,%rdi
  movslq 0x4(%rsi,%rax,1),%rcx
  mov    %rdi,0x38(%rsp)
  imul   %r11,%rcx
  mov    %rcx,0x50(%rsp)
  mov    %rcx,%r11
  lea    0x2(%rdx),%rcx
  cmp    %rcx,%r12
  jbe    L10
  mov    0x8(%rbp,%rax,1),%ecx
  imul   0x8(%rbx,%rax,1),%ecx
  movslq %ecx,%rcx
  add    %rcx,%rdi
  movslq 0x8(%rsi,%rax,1),%rcx
  mov    %rdi,0x38(%rsp)
  imul   %r11,%rcx
  mov    %rcx,0x50(%rsp)
  mov    %rcx,%r11
  lea    0x3(%rdx),%rcx
  cmp    %rcx,%r12
  jbe    L10
  mov    0xc(%rbp,%rax,1),%ecx
  imul   0xc(%rbx,%rax,1),%ecx
  movslq %ecx,%rcx
  add    %rcx,%rdi
  movslq 0xc(%rsi,%rax,1),%rcx
  mov    %rdi,0x38(%rsp)
  imul   %r11,%rcx
  mov    %rcx,0x50(%rsp)
  mov    %rcx,%r11
  lea    0x4(%rdx),%rcx
  cmp    %rcx,%r12
  jbe    L10
  mov    0x10(%rbp,%rax,1),%ecx
  imul   0x10(%rbx,%rax,1),%ecx
  movslq %ecx,%rcx
  add    %rcx,%rdi
  movslq 0x10(%rsi,%rax,1),%rcx
  mov    %rdi,0x38(%rsp)
  imul   %r11,%rcx
  mov    %rcx,0x50(%rsp)
  mov    %rcx,%r11
  lea    0x5(%rdx),%rcx
  cmp    %rcx,%r12
  jbe    L10
  mov    0x14(%rbp,%rax,1),%ecx
  imul   0x14(%rbx,%rax,1),%ecx
  movslq %ecx,%rcx
  add    %rcx,%rdi
  movslq 0x14(%rsi,%rax,1),%rcx
  mov    %rdi,0x38(%rsp)
  imul   %r11,%rcx
  mov    %rcx,0x50(%rsp)
  mov    %rcx,%r11
  lea    0x6(%rdx),%rcx
  cmp    %rcx,%r12
  jbe    L10
  mov    0x18(%rbp,%rax,1),%ecx
  imul   0x18(%rbx,%rax,1),%ecx
  movslq %ecx,%rcx
  add    %rcx,%rdi
  movslq 0x18(%rsi,%rax,1),%rcx
  mov    %rdi,0x38(%rsp)
  imul   %r11,%rcx
  mov    %rcx,0x50(%rsp)
  mov    %rcx,%r11
  lea    0x7(%rdx),%rcx
  cmp    %rcx,%r12
  jbe    L10
  mov    0x1c(%rbp,%rax,1),%ecx
  imul   0x1c(%rbx,%rax,1),%ecx
  movslq %ecx,%rcx
  add    %rcx,%rdi
  movslq 0x1c(%rsi,%rax,1),%rcx
  mov    %rdi,0x38(%rsp)
  imul   %r11,%rcx
  mov    %rcx,0x50(%rsp)
  mov    %rcx,%r11
  lea    0x8(%rdx),%rcx
  cmp    %rcx,%r12
  jbe    L10
  mov    0x20(%rbp,%rax,1),%ecx
  imul   0x20(%rbx,%rax,1),%ecx
  movslq %ecx,%rcx
  add    %rcx,%rdi
  movslq 0x20(%rsi,%rax,1),%rcx
  mov    %rdi,0x38(%rsp)
  imul   %r11,%rcx
  mov    %rcx,0x50(%rsp)
  mov    %rcx,%r11
  lea    0x9(%rdx),%rcx
  cmp    %rcx,%r12
  jbe    L10
  mov    0x24(%rbp,%rax,1),%ecx
  imul   0x24(%rbx,%rax,1),%ecx
  movslq %ecx,%rcx
  add    %rcx,%rdi
  movslq 0x24(%rsi,%rax,1),%rcx
  mov    %rdi,0x38(%rsp)
  imul   %r11,%rcx
  mov    %rcx,0x50(%rsp)
  mov    %rcx,%r11
  lea    0xa(%rdx),%rcx
  cmp    %rcx,%r12
  jbe    L10
  mov    0x28(%rbp,%rax,1),%ecx
  imul   0x28(%rbx,%rax,1),%ecx
  add    $0xb,%rdx
  movslq %ecx,%rcx
  add    %rcx,%rdi
  movslq 0x28(%rsi,%rax,1),%rcx
  mov    %rdi,0x38(%rsp)
  imul   %r11,%rcx
  mov    %rcx,0x50(%rsp)
  cmp    %rdx,%r12
  jbe    L10
  mov    0x2c(%rbp,%rax,1),%edx
  imul   0x2c(%rbx,%rax,1),%edx
  movslq 0x2c(%rsi,%rax,1),%rax
  imul   %rcx,%rax
  movslq %edx,%rdx
  add    %rdx,%rdi
  mov    %rdi,0x38(%rsp)
  mov    %rax,0x50(%rsp)
L10:
  mov    0x50(%rsp),%rdi
  cmp    %rdi,0x38(%rsp)
  jae    L182
  lea    -0x1(%r14),%eax
  lea    0x0(,%r12,4),%r11
  movslq 0xe0(%rsp),%rdi
  movq   $0x0,0x68(%rsp)
  cltq
  movl   $0x0,0x60(%rsp)
  lea    (%rbx,%r11,1),%r9
  mov    %rax,0x90(%rsp)
  lea    0x0(%r13,%rax,8),%rax
  mov    %rax,0x98(%rsp)
  lea    0x0(%rbp,%r11,1),%rax
  mov    %rdi,0x8(%rsp)
  mov    %rax,0x78(%rsp)
  movq   $0x0,0x30(%rsp)
L28:
  mov    0x90(%rsp),%rcx
  test   %rcx,%rcx
  je     L194
  mov    0x98(%rsp),%rdi
  mov    0x38(%rsp),%r8
  mov    0x80(%rsp),%r14
  jmp    L68
L267:
  movslq (%r14,%rcx,4),%rdx
  add    %r15,%rdx
  sub    %rax,%rdx
  imul   %rsi,%rdx
  add    %rdx,%r8
L363:
  sub    $0x8,%rdi
  sub    $0x1,%rcx
  je     L415
L68:
  movslq -0x4(%rbp,%rcx,4),%r15
  mov    %r8,%rax
  xor    %edx,%edx
  movslq 0x0(%rbp,%rcx,4),%rsi
  div    %r15
  movslq (%rbx,%rcx,4),%r15
  mov    %rdx,%rax
  xor    %edx,%edx
  div    %rsi
  movslq (%r9,%rcx,4),%rdx
  mov    %rax,(%rdi)
  cmp    %rdx,%rax
  ja     L267
  cmp    %r15,%rax
  jae    L363
  sub    %rax,%r15
  sub    $0x8,%rdi
  imul   %rsi,%r15
  add    %r15,%r8
  sub    $0x1,%rcx
  jne    L68
L415:
  mov    %r8,0x38(%rsp)
L194:
  mov    0x38(%rsp),%rax
  movslq %r10d,%rcx
  xor    %edx,%edx
  div    %rcx
  movslq (%r9),%rdx
  cmp    %rdx,%rax
  ja     L222
  mov    0x10(%rsp),%rdi
  mov    0x38(%rsp),%rsi
  add    %rsi,%rdi
  cmpb   $0x0,(%rdi)
  mov    %rdi,%rax
  je     L100
  mov    0x28(%rsp),%rdi
  cmpq   $0x0,0x40(%rsp)
  mov    (%rdi,%rsi,4),%edi
  mov    %edi,0x24(%rsp)
  je     L261
  mov    0x30(%rsp),%rsi
  cmp    %rsi,0x58(%rsp)
  jbe    L517
  mov    %rsi,%rdi
  mov    0x38(%rsp),%rcx
  mov    0x40(%rsp),%rsi
  mov    %rcx,(%rsi,%rdi,8)
  add    $0x1,%rdi
  mov    %rdi,0x30(%rsp)
L261:
  mov    0x48(%rsp),%rdi
  mov    0x38(%rsp),%rsi
  movl   $0x0,0x64(%rsp)
  movq   $0x1,0x18(%rsp)
  mov    %rsi,(%rdi)
  movb   $0x0,(%rax)
L111:
  subq   $0x1,0x18(%rsp)
  movslq 0x0(%rbp),%rcx
  xor    %edx,%edx
  lea    0x8(%r13),%rsi
  mov    0x18(%rsp),%rax
  mov    0x48(%rsp),%rdi
  addl   $0x1,0x64(%rsp)
  mov    0x78(%rsp),%r8
  mov    (%rdi,%rax,8),%r10
  mov    %r10,%rax
  div    %rcx
  lea    0x4(%rbp),%rcx
  mov    %rax,0x0(%r13)
  cmp    $0x1,%r12
  jbe    L19
  nopl   0x0(%rax,%rax,1)
L294:
  movslq -0x4(%rcx),%rdi
  mov    %r10,%rax
  xor    %edx,%edx
  add    $0x4,%rcx
  add    $0x8,%rsi
  div    %rdi
  movslq -0x4(%rcx),%rdi
  mov    %rdx,%rax
  xor    %edx,%edx
  div    %rdi
  mov    %rax,-0x8(%rsi)
  cmp    %rcx,%r8
  jne    L294
L19:
  cmpq   $0x0,0x8(%rsp)
  je     L83
  mov    0x70(%rsp),%r14
  xor    %r15d,%r15d
  nopl   0x0(%rax)
L389:
  mov    %r13,%rsi
  mov    %r10,%rdi
  xor    %eax,%eax
  test   %r12,%r12
  jne    L215
  jmp    L255
  nopw   0x0(%rax,%rax,1)
L27:
  movslq (%r9,%rax,4),%r8
  cmp    %r8,%rcx
  ja     L255
  imul   0x0(%rbp,%rax,4),%edx
  add    $0x1,%rax
  add    $0x8,%rsi
  movslq %edx,%rdx
  add    %rdx,%rdi
  cmp    %rax,%r12
  je     L456
L215:
  movslq (%r14,%rax,4),%rcx
  movslq (%rbx,%rax,4),%r8
  mov    %rcx,%rdx
  add    (%rsi),%rcx
  cmp    %r8,%rcx
  jae    L27
L255:
  add    $0x1,%r15
  add    %r11,%r14
  cmp    0x8(%rsp),%r15
  jne    L389
L83:
  cmpq   $0x0,0x18(%rsp)
  jne    L111
  movd   0x24(%rsp),%xmm0
  movd   0x64(%rsp),%xmm3
  mov    0x68(%rsp),%rdi
  punpckldq %xmm3,%xmm0
  cmp    %rdi,0x88(%rsp)
  jbe    L517
  mov    0x60(%rsp),%edi
  movd   %xmm3,%eax
  cmp    %eax,%edi
  cmovge %edi,%eax
  mov    0xf0(%rsp),%rdi
  mov    %eax,0x60(%rsp)
  mov    0x68(%rsp),%rax
  movq   %xmm0,(%rdi,%rax,8)
  add    $0x1,%rax
  mov    %rax,0x68(%rsp)
L100:
  addq   $0x1,0x38(%rsp)
  mov    0x38(%rsp),%rax
  cmp    0x50(%rsp),%rax
  jae    L222
  mov    0x0(%rbp),%r10d
  jmp    L28
L456:
  cmp    %rdi,%r10
  je     L255
  mov    0x10(%rsp),%rax
  add    %rdi,%rax
  cmpb   $0x0,(%rax)
  je     L255
  mov    0x28(%rsp),%rsi
  mov    0x24(%rsp),%ecx
  cmp    %ecx,(%rsi,%rdi,4)
  jne    L255
  cmpq   $0x0,0x40(%rsp)
  je     L249
  mov    0x30(%rsp),%rcx
  cmp    %rcx,0x58(%rsp)
  jbe    L517
  mov    %rcx,%rsi
  mov    0x40(%rsp),%rcx
  mov    %rdi,(%rcx,%rsi,8)
  add    $0x1,%rsi
  mov    %rsi,0x30(%rsp)
L249:
  mov    0x18(%rsp),%rsi
  mov    0x48(%rsp),%rcx
  add    $0x1,%r15
  add    %r11,%r14
  mov    %rdi,(%rcx,%rsi,8)
  movb   $0x0,(%rax)
  lea    0x1(%rsi),%rax
  mov    %rax,0x18(%rsp)
  cmp    0x8(%rsp),%r15
  jne    L389
  jmp    L83
L517:
  mov    %r13,%rdi
  call   <free@plt>
  mov    0x48(%rsp),%rdi
  call   <free@plt>
  movl   $0xffffffff,0x60(%rsp)
L445:
  mov    0x60(%rsp),%eax
  add    $0xa8,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L222:
  mov    %r13,%rdi
  call   <free@plt>
  mov    0x48(%rsp),%rdi
  call   <free@plt>
  mov    0x40(%rsp),%rcx
  test   %rcx,%rcx
  je     L124
  mov    0x30(%rsp),%rax
  test   %rax,%rax
  je     L229
L416:
  sub    $0x1,%rax
  mov    0x10(%rsp),%rbx
  mov    (%rcx,%rax,8),%rdx
  movb   $0x1,(%rbx,%rdx,1)
  jne    L416
L229:
  mov    0x40(%rsp),%rdi
  call   <free@plt>
L124:
  mov    0x68(%rsp),%rax
  mov    0x88(%rsp),%rbx
  cmp    %rbx,%rax
  jae    L195
  mov    0xf0(%rsp),%rbx
  movl   $0xffffffff,(%rbx,%rax,8)
  jmp    L445
L341:
  mov    $0x1,%edx
  jmp    L407
L195:
  movl   $0xffffffff,0x60(%rsp)
  jmp    L445
  nopl   0x0(%rax,%rax,1)
L182:
  mov    %r13,%rdi
  call   <free@plt>
  mov    0x48(%rsp),%rdi
  call   <free@plt>
  cmpq   $0x0,0x40(%rsp)
  movq   $0x0,0x68(%rsp)
  movl   $0x0,0x60(%rsp)
  je     L124
  jmp    L229
```

tool_calls: name: read_data
arguments: label: D7
data_type: byte[16]

tool: {"D7": [0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00]}

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