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

```asm
<inconsistency_calculation_alt>:
  endbr64
  push   %r15
  movslq %edx,%rax
  pxor   %xmm0,%xmm0
  pxor   %xmm1,%xmm1
  push   %r14
  mov    %rax,%rdx
  cvtsi2sd %eax,%xmm0
  mov    %rdi,%r14
  push   %r13
  shr    $0x3,%rdx
  mov    %rsi,%r15
  push   %r12
  cvtsi2sd %rdx,%xmm1
  mov    %ecx,%r12d
  push   %rbp
  mov    %rax,%rbp
  push   %rbx
  sub    $0x38,%rsp
  mulsd  D2(%rip),%xmm0
  ucomisd %xmm1,%xmm0
  jp     L83
  mov    %edx,%ebx
  jne    L83
L121:
  movslq %ebx,%rbx
  lea    0x0(,%rax,4),%rdi
  sub    $0x1,%r12d
  call   <malloc@plt>
  mov    %rbx,%rdi
  mov    %rbx,0x20(%rsp)
  mov    %rax,%r13
  call   <malloc@plt>
  mov    %rbx,%rdi
  mov    %rax,0x8(%rsp)
  call   <malloc@plt>
  xor    %r8d,%r8d
  mov    %rax,0x10(%rsp)
  lea    -0x1(%rbp),%eax
  mov    %eax,0x28(%rsp)
  test   %eax,%eax
  jle    L31
  nopl   0x0(%rax,%rax,1)
L14:
  mov    0x20(%rsp),%rbx
  mov    0x8(%rsp),%rdi
  xor    %esi,%esi
  mov    %r8d,0x18(%rsp)
  mov    %rbx,%rdx
  call   <memset@plt>
  mov    0x10(%rsp),%rdi
  mov    %rbx,%rdx
  xor    %esi,%esi
  call   <memset@plt>
  mov    0x18(%rsp),%r8d
  pxor   %xmm4,%xmm4
  xor    %esi,%esi
  movapd %xmm4,%xmm1
  movapd %xmm4,%xmm2
  xor    %eax,%eax
  mov    %r8d,0x0(%r13)
  mov    %r8d,%edx
  nopl   0x0(%rax)
L107:
  lea    0x0(,%rdx,4),%edi
  movslq %edi,%rdi
  lea    (%r14,%rdi,8),%rbx
  movsd  (%rbx),%xmm0
  movsd  0x8(%rbx),%xmm3
  cmp    %r12d,%eax
  jge    L68
  cvttsd2si %xmm0,%r9d
  cmp    %r9d,%ebp
  jg     L50
  movslq %edx,%rdi
  mov    %edx,%ecx
  shr    $0x3,%rdi
  add    0x8(%rsp),%rdi
  not    %ecx
  movzbl (%rdi),%r11d
  and    $0x7,%ecx
  bt     %ecx,%r11d
  mov    %r11d,%r10d
  jae    L12
L50:
  cvttsd2si %xmm3,%r9d
  cmp    %r9d,%ebp
  jg     L68
  movslq %edx,%rdi
  not    %edx
  shr    $0x3,%rdi
  add    0x10(%rsp),%rdi
  and    $0x7,%edx
  movzbl (%rdi),%ecx
  bt     %edx,%ecx
  mov    %ecx,%r10d
  jae    L206
  nopl   0x0(%rax)
L68:
  movsd  0x10(%rbx),%xmm0
  lea    0x1(%rsi),%ecx
  addsd  %xmm0,%xmm2
  mulsd  %xmm0,%xmm0
  addsd  %xmm0,%xmm1
  sub    $0x1,%eax
  jb     L54
  movslq %eax,%rdx
  mov    %ecx,%esi
  mov    0x0(%r13,%rdx,4),%edx
  jmp    L107
  nopl   0x0(%rax,%rax,1)
L54:
  pxor   %xmm0,%xmm0
  movapd %xmm2,%xmm3
  cvtsi2sd %ecx,%xmm0
  mulsd  %xmm2,%xmm2
  divsd  %xmm0,%xmm3
  movsd  %xmm0,0x10(%r15)
  movsd  %xmm3,(%r15)
  cmp    $0x1,%ecx
  je     L137
  divsd  %xmm0,%xmm2
  pxor   %xmm0,%xmm0
  cvtsi2sd %esi,%xmm0
  subsd  %xmm2,%xmm1
  divsd  %xmm0,%xmm1
L117:
  comisd %xmm1,%xmm4
  ja     L61
  ucomisd %xmm1,%xmm4
  ja     L92
  sqrtsd %xmm1,%xmm1
L46:
  comisd %xmm4,%xmm1
  movsd  %xmm1,0x8(%r15)
  jbe    L122
  movsd  0x10(%rbx),%xmm0
  subsd  %xmm3,%xmm0
  divsd  %xmm1,%xmm0
  movsd  %xmm0,0x18(%r15)
L122:
  add    $0x1,%r8d
  add    $0x20,%r15
  cmp    %r8d,0x28(%rsp)
  jne    L14
L31:
  mov    %r13,%rdi
  call   <free@plt>
  mov    0x8(%rsp),%rdi
  call   <free@plt>
  mov    0x10(%rsp),%rdi
  add    $0x38,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  jmp    1080 <free@plt>
L12:
  mov    $0x1,%edx
  shl    %cl,%edx
L150:
  or     %edx,%r10d
  add    $0x1,%eax
  mov    %r9d,%edx
  sub    %ebp,%edx
  movslq %eax,%rcx
  mov    %r10b,(%rdi)
  mov    %edx,0x0(%r13,%rcx,4)
  jmp    L107
  nopw   0x0(%rax,%rax,1)
L206:
  mov    %edx,%ecx
  mov    $0x1,%ebx
  shl    %cl,%ebx
  mov    %ebx,%edx
  jmp    L150
  nopl   (%rax)
L61:
  movq   $0x0,0x8(%r15)
  jmp    L122
  nopl   (%rax)
L137:
  subsd  %xmm2,%xmm1
  divsd  %xmm0,%xmm1
  jmp    L117
L83:
  lea    0x1(%rdx),%ebx
  jmp    L121
L92:
  movapd %xmm1,%xmm0
  mov    %r8d,0x2c(%rsp)
  movsd  %xmm3,0x18(%rsp)
  call   <sqrt@plt>
  mov    0x2c(%rsp),%r8d
  movsd  0x18(%rsp),%xmm3
  pxor   %xmm4,%xmm4
  movapd %xmm0,%xmm1
  jmp    L46
```

tool_calls: name: read_data
arguments: data_label: D2
type_guessed: f32[2]

tool: {"D2": [0.0,1.5]}

assistant: ```c
void inconsistency_calculation_alt(const double *Z, double *R, int n, int d) {
  int *curNode;
  int ndid, lid, rid, i, k;
  unsigned char *lvisited, *rvisited;
  const double *Zrow;
  double *Rrow;
  double levelSum, levelStdSum;
  int levelCnt;
  const int bff = (((((double)(n)) / (double)(sizeof(unsigned char) * 8)) == ((double)(((n)) / ((sizeof(unsigned char) * 8)))) ? (((n)) / ((sizeof(unsigned char) * 8))) : (((n)) / ((sizeof(unsigned char) * 8)) + 1)));
  k = 0;
  curNode = (int *)malloc(n * sizeof(int));
  lvisited = (unsigned char *)malloc(bff);
  rvisited = (unsigned char *)malloc(bff);
  for (i = 0; i < n - 1; i++) {
    k = 0;
    levelSum = 0.0;
    levelCnt = 0;
    levelStdSum = 0.0;
    bzero(lvisited, bff);
    bzero(rvisited, bff);
    curNode[0] = i;
    for (k = 0; k >= 0;) {
      ndid = curNode[k];
      Zrow = Z + ((ndid)*4);
      lid = (int)Zrow[0];
      rid = (int)Zrow[1];
      if (k < d - 1) {
        if (lid >= n && !(((lvisited)[(ndid) / (sizeof(unsigned char) * 8)] >> (((sizeof(unsigned char) * 8) - 1) - ((ndid) % (sizeof(unsigned char) * 8)))) & 0x1)) {
          ((lvisited)[(ndid) / (sizeof(unsigned char) * 8)] |= ((0x1) << (((sizeof(unsigned char) * 8) - 1) - ((ndid) % (sizeof(unsigned char) * 8)))));
          k++;
          curNode[k] = lid - n;
          continue;
        }
        if (rid >= n && !(((rvisited)[(ndid) / (sizeof(unsigned char) * 8)] >> (((sizeof(unsigned char) * 8) - 1) - ((ndid) % (sizeof(unsigned char) * 8)))) & 0x1)) {
          ((rvisited)[(ndid) / (sizeof(unsigned char) * 8)] |= ((0x1) << (((sizeof(unsigned char) * 8) - 1) - ((ndid) % (sizeof(unsigned char) * 8)))));
          k++;
          curNode[k] = rid - n;
          continue;
        }
      }
      levelCnt++;
      levelSum += Zrow[2];
      levelStdSum += Zrow[2] * Zrow[2];
      k--;
    }
    Rrow = R + (4 * i);
    Rrow[2] = (double)levelCnt;
    Rrow[0] = levelSum / levelCnt;
    if (levelCnt < 2) {
      Rrow[1] = (levelStdSum - (levelSum * levelSum)) / levelCnt;
    } else {
      Rrow[1] = (levelStdSum - ((levelSum * levelSum) / levelCnt)) / (levelCnt - 1);
    }
    Rrow[1] = sqrt(((0 > Rrow[1]) ? (0) : (Rrow[1])));
    if (Rrow[1] > 0) {
      Rrow[3] = (Zrow[2] - Rrow[0]) / Rrow[1];
    }
  }
  free(curNode);
  free(lvisited);
  free(rvisited);
}
```