user: 请从给定的汇编指令推导出C源代码:

```asm
<dchisqr_sysrem>:
  endbr64
  mov    %rdi,%r11
  lea    (%rdx,%rcx,1),%edi
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  mov    0x30(%rsp),%r12
  test   %edi,%edi
  jle    L125
  movapd %xmm0,%xmm5
  pxor   %xmm2,%xmm2
  pxor   %xmm0,%xmm0
  mov    %edx,%r10d
  cvtsi2sd %edx,%xmm2
  mov    %rsi,%rbx
  mov    %ecx,%ebp
  mov    $0x1,%edx
  cvtsi2sd %ecx,%xmm0
  movq   D34(%rip),%xmm6
  movsd  D1(%rip),%xmm4
  lea    0x1(%rdi),%r13d
  movapd %xmm6,%xmm7
  mulsd  %xmm2,%xmm0
  movq   D30(%rip),%xmm2
  movapd %xmm2,%xmm3
  movsd  %xmm0,-0x8(%rsp)
  fldl   -0x8(%rsp)
  fldz
  nopl   0x0(%rax)
L155:
  cmp    %edx,%r10d
  jl     L136
  test   %ebp,%ebp
  jle    L153
  mov    -0x8(%r8,%rdx,8),%rsi
  mov    %r10d,%ecx
  xor    %eax,%eax
  pxor   %xmm10,%xmm10
  movsd  D1(%rip),%xmm9
  fld    %st(0)
  movsd  D18(%rip),%xmm11
  jmp    L191
  xchg   %ax,%ax
L175:
  comisd %xmm5,%xmm10
  ja     L235
  nopw   0x0(%rax,%rax,1)
L27:
  add    $0x1,%ecx
  add    $0x8,%rax
  cmp    %ecx,%edi
  je     L132
L191:
  movsd  (%rsi,%rax,1),%xmm0
  ucomisd %xmm0,%xmm0
  jp     L27
  movapd %xmm0,%xmm8
  andpd  %xmm3,%xmm8
  ucomisd %xmm9,%xmm8
  ja     L27
  comisd %xmm1,%xmm0
  jbe    L27
  subsd  -0x8(%r12,%rdx,8),%xmm0
  comisd %xmm10,%xmm0
  movapd %xmm0,%xmm12
  ja     L121
  xorpd  %xmm7,%xmm12
L121:
  mov    -0x8(%r9,%rdx,8),%r14
  movsd  (%r14,%rax,1),%xmm8
  divsd  %xmm8,%xmm12
  comisd %xmm12,%xmm5
  jbe    L175
L235:
  movslq %ecx,%r14
  movsd  (%r11,%rdx,8),%xmm13
  add    $0x1,%ecx
  add    $0x8,%rax
  movsd  0x8(%r11,%r14,8),%xmm12
  mulsd  %xmm8,%xmm8
  mulsd  %xmm12,%xmm13
  subsd  %xmm13,%xmm0
  mulsd  %xmm12,%xmm0
  divsd  %xmm8,%xmm0
  mulsd  %xmm11,%xmm0
  movsd  %xmm0,-0x8(%rsp)
  faddl  -0x8(%rsp)
  cmp    %ecx,%edi
  jne    L191
  nopw   0x0(%rax,%rax,1)
L132:
  fdiv   %st(2),%st
  fstpl  (%rbx,%rdx,8)
  add    $0x1,%rdx
  cmp    %r13,%rdx
  jne    L155
  fstp   %st(0)
  fstp   %st(0)
L125:
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  ret
  nop
L136:
  mov    %edx,%ecx
  sub    %r10d,%ecx
  sub    $0x1,%ecx
  test   %r10d,%r10d
  jle    L153
  movslq %ecx,%rcx
  lea    -0x1(%r10),%r14d
  pxor   %xmm9,%xmm9
  xor    %eax,%eax
  movsd  D18(%rip),%xmm10
  shl    $0x3,%rcx
  fld    %st(0)
  jmp    L105
L231:
  comisd %xmm5,%xmm9
  ja     L56
  nopw   0x0(%rax,%rax,1)
L173:
  lea    0x1(%rax),%rsi
  cmp    %rax,%r14
  je     L132
  mov    %rsi,%rax
L105:
  mov    (%r8,%rax,8),%rsi
  movsd  (%rsi,%rcx,1),%xmm0
  ucomisd %xmm0,%xmm0
  jp     L173
  movapd %xmm0,%xmm8
  andpd  %xmm2,%xmm8
  ucomisd %xmm4,%xmm8
  ja     L173
  comisd %xmm1,%xmm0
  jbe    L173
  subsd  (%r12,%rax,8),%xmm0
  comisd %xmm9,%xmm0
  movapd %xmm0,%xmm11
  ja     L218
  xorpd  %xmm6,%xmm11
L218:
  mov    (%r9,%rax,8),%rsi
  movsd  (%rsi,%rcx,1),%xmm8
  divsd  %xmm8,%xmm11
  comisd %xmm11,%xmm5
  jbe    L231
L56:
  movsd  0x8(%r11,%rax,8),%xmm11
  movsd  (%r11,%rdx,8),%xmm12
  mulsd  %xmm8,%xmm8
  mulsd  %xmm11,%xmm12
  subsd  %xmm12,%xmm0
  mulsd  %xmm11,%xmm0
  divsd  %xmm8,%xmm0
  mulsd  %xmm10,%xmm0
  movsd  %xmm0,-0x8(%rsp)
  faddl  -0x8(%rsp)
  jmp    L173
  nopl   0x0(%rax)
L153:
  fld    %st(0)
  fdiv   %st(2),%st
  fstpl  (%rbx,%rdx,8)
  add    $0x1,%rdx
  cmp    %r13,%rdx
  jne    L155
  fstp   %st(0)
  fstp   %st(0)
  jmp    L125
```

tool_calls: name: retrieve_data
arguments: tag: D34
type_guessed: byte[8]
name: retrieve_data
arguments: tag: D1
type_guessed: byte[8]
name: retrieve_data
arguments: tag: D30
type_guessed: byte[8]
name: retrieve_data
arguments: tag: D18
type_guessed: byte[8]

tool: {"D34": [0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80]}

tool: {"D1": [0xff,0xff,0xff,0xff,0xff,0xff,0xef,0x7f]}

tool: {"D30": [0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x7f]}

tool: {"D18": [0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc0]}

assistant: ```c
void dchisqr_sysrem(double p[], double xi[], int numlc, int numJD, double **mag, double **sig, double *mag_ave, double sigma_clip, double saturation) {
  int j, k;
  int n, num;
  long double S;
  num = 0;
  for (n = 1; n <= numlc + numJD; n++) {
    S = 0;
    if (n <= numlc) {
      j = n - 1;
      for (k = 0; k < numJD; k++) {
        if (!isnan(mag[j][k]) && !isinf(mag[j][k]) && mag[j][k] > saturation && (((mag[j][k] - mag_ave[j]) > 0 ? (mag[j][k] - mag_ave[j]) : (-(mag[j][k] - mag_ave[j]))) / sig[j][k] < sigma_clip || sigma_clip < 0))
          S += -2.0 * (p[numlc + k + 1] * (mag[j][k] - mag_ave[j] - p[n] * p[numlc + k + 1]) / (sig[j][k] * sig[j][k]));
      }
    } else {
      k = n - numlc - 1;
      for (j = 0; j < numlc; j++) {
        if (!isnan(mag[j][k]) && !isinf(mag[j][k]) && mag[j][k] > saturation && (((mag[j][k] - mag_ave[j]) > 0 ? (mag[j][k] - mag_ave[j]) : (-(mag[j][k] - mag_ave[j]))) / sig[j][k] < sigma_clip || sigma_clip < 0))
          S += -2.0 * (p[j + 1] * (mag[j][k] - mag_ave[j] - p[j + 1] * p[n]) / (sig[j][k] * sig[j][k]));
      }
    }
    xi[n] = (double)(S / ((double)numJD * numlc));
  }
}
```