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

```asm
<doalarm>:
  endbr64
  mov    %rsi,%rcx
  mov    %rdx,%rsi
  test   %edi,%edi
  jle    L5
  mov    %edi,%edx
  mov    $0x0,%eax
  fldz
  fld    %st(0)
  pxor   %xmm2,%xmm2
  movsd  D0(%rip),%xmm3
  jmp    L107
L29:
  add    $0x1,%rax
  cmp    %rax,%rdx
  je     L108
L107:
  movsd  (%rcx,%rax,8),%xmm1
  ucomisd %xmm1,%xmm1
  jp     L29
  movsd  (%rsi,%rax,8),%xmm0
  ucomisd %xmm0,%xmm0
  jp     L29
  comisd %xmm2,%xmm0
  jbe    L29
  fxch   %st(1)
  mulsd  %xmm0,%xmm0
  divsd  %xmm0,%xmm1
  movsd  %xmm1,-0x18(%rsp)
  faddl  -0x18(%rsp)
  fxch   %st(1)
  movapd %xmm3,%xmm5
  divsd  %xmm0,%xmm5
  movsd  %xmm5,-0x18(%rsp)
  faddl  -0x18(%rsp)
  jmp    L29
L118:
  movapd %xmm0,%xmm7
  divsd  (%rsi,%rax,8),%xmm7
  movsd  %xmm7,-0x18(%rsp)
  faddl  -0x18(%rsp)
  fxch   %st(1)
L38:
  movsd  (%rsi,%rax,8),%xmm1
  mulsd  %xmm0,%xmm0
  mulsd  %xmm1,%xmm1
  divsd  %xmm1,%xmm0
  movsd  %xmm0,-0x18(%rsp)
  faddl  -0x18(%rsp)
  jmp    L77
L0:
  fxch   %st(1)
L77:
  add    $0x1,%rax
  cmp    %rax,%rdi
  je     L125
  fxch   %st(1)
L21:
  movsd  (%rcx,%rax,8),%xmm0
  ucomisd %xmm0,%xmm0
  jp     L0
  subsd  %xmm2,%xmm0
  movsd  %xmm0,(%rcx,%rax,8)
  comisd %xmm3,%xmm0
  sbb    %edx,%edx
  or     $0x1,%edx
  cmp    %r8d,%edx
  je     L118
  fmul   %st(0),%st
  faddl  -0x10(%rsp)
  fstpl  -0x10(%rsp)
  movapd %xmm0,%xmm6
  divsd  (%rsi,%rax,8),%xmm6
  movsd  %xmm6,-0x18(%rsp)
  fldl   -0x18(%rsp)
  fxch   %st(1)
  mov    %edx,%r8d
  jmp    L38
L46:
  pxor   %xmm4,%xmm4
  movsd  %xmm4,-0x10(%rsp)
  jmp    L65
L125:
  fxch   %st(1)
L65:
  fmul   %st(0),%st
  faddl  -0x10(%rsp)
  fstpl  -0x18(%rsp)
  fldl   -0x18(%rsp)
  fdivp  %st,%st(1)
  fsubl  0xdf0(%rip)        # 2010 <_fini+0xd60>
  fstpl  -0x18(%rsp)
  movsd  -0x18(%rsp),%xmm0
  ret
L5:
  pxor   %xmm0,%xmm0
  ret
L108:
  fdivrp %st,%st(1)
  fstpl  -0x18(%rsp)
  movsd  -0x18(%rsp),%xmm2
  movsd  (%rcx),%xmm0
  subsd  %xmm2,%xmm0
  movsd  %xmm0,(%rcx)
  movsd  (%rsi),%xmm1
  movapd %xmm0,%xmm4
  mulsd  %xmm0,%xmm4
  movapd %xmm1,%xmm3
  mulsd  %xmm1,%xmm3
  divsd  %xmm3,%xmm4
  movsd  %xmm4,-0x18(%rsp)
  fldl   -0x18(%rsp)
  movapd %xmm0,%xmm7
  divsd  %xmm1,%xmm7
  movsd  %xmm7,-0x18(%rsp)
  fldl   -0x18(%rsp)
  comisd D3(%rip),%xmm0
  sbb    %r8d,%r8d
  or     $0x1,%r8d
  cmp    $0x1,%edi
  jle    L46
  mov    %edi,%edi
  mov    $0x1,%eax
  pxor   %xmm4,%xmm4
  movsd  %xmm4,-0x10(%rsp)
  movapd %xmm4,%xmm3
  jmp    L21
```

tool_calls: name: read_data
arguments: label: D0
datatype: f64
name: read_data
arguments: label: D3
datatype: f64[2]

tool: D0: 1

tool: {"D3": [0.0,1.0]}

assistant: ```c
double doalarm(int N, double *resid, double *err) {
  double a, ave;
  long double sum1, sum2;
  int sign, i, n;
  sum1 = 0.;
  sum2 = 0.;
  for (i = 0; i < N; i++) {
    if (!isnan(resid[i]) && !isnan(err[i]) && err[i] > 0.) {
      sum1 += (long double)(resid[i] / (err[i] * err[i]));
      sum2 += (long double)(1. / (err[i] * err[i]));
    }
  }
  a = 0.;
  if (N > 0) {
    ave = sum1 / sum2;
    resid[0] -= ave;
    sum1 = resid[0] * resid[0] / (err[0] * err[0]);
    sum2 = resid[0] / err[0];
    n = 1;
    sign = ((resid[0]) >= 0 ? (1) : (-1));
    for (i = 1; i < N; i++) {
      if (!isnan(resid[i])) {
        resid[i] -= ave;
        if (((resid[i]) >= 0 ? (1) : (-1)) != sign) {
          a += (sum2 * sum2);
          sum2 = resid[i] / err[i];
          n = 1;
          sign = ((resid[i]) >= 0 ? (1) : (-1));
        } else {
          sum2 += resid[i] / err[i];
          n++;
        }
        sum1 += resid[i] * resid[i] / (err[i] * err[i]);
      }
    }
    a += (sum2 * sum2);
    a = (a / sum1) - 2.2732395;
  }
  return (a);
}
```