user: Translate the below assembly code into C programming language:

```asm
<dchisqr_sysrem>:
  endbr64
  mov    %rsi,%r10
  lea    (%rdx,%rcx,1),%esi
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  mov    0x30(%rsp),%rbx
  test   %esi,%esi
  jle    L75
  movapd %xmm0,%xmm2
  pxor   %xmm3,%xmm3
  pxor   %xmm0,%xmm0
  mov    %edx,%r11d
  cvtsi2sd %ecx,%xmm0
  mov    %ecx,%ebp
  cvtsi2sd %edx,%xmm3
  mulsd  %xmm3,%xmm0
  movsd  %xmm0,-0x8(%rsp)
  fldl   -0x8(%rsp)
  test   %edx,%edx
  jle    L130
  movq   D99(%rip),%xmm4
  cmp    %esi,%edx
  fldz
  mov    %esi,%r13d
  cmovle %edx,%r13d
  movsd  D38(%rip),%xmm5
  movsd  D19(%rip),%xmm6
  mov    $0x1,%eax
  movq   D28(%rip),%xmm7
  movapd %xmm4,%xmm3
  nopw   0x0(%rax,%rax,1)
L243:
  test   %ebp,%ebp
  jle    L314
  pxor   %xmm10,%xmm10
  xor    %edx,%edx
  mov    -0x8(%r8,%rax,8),%r12
  mov    %r11d,%ecx
  comisd %xmm2,%xmm10
  fld    %st(0)
  ja     L188
  movsd  D38(%rip),%xmm9
  movsd  D19(%rip),%xmm11
  xchg   %ax,%ax
L221:
  movsd  (%r12,%rdx,1),%xmm0
  ucomisd %xmm0,%xmm0
  jp     L70
  movapd %xmm0,%xmm8
  andpd  %xmm3,%xmm8
  ucomisd %xmm9,%xmm8
  ja     L70
  comisd %xmm1,%xmm0
  jbe    L70
  subsd  -0x8(%rbx,%rax,8),%xmm0
  comisd %xmm10,%xmm0
  movapd %xmm0,%xmm12
  ja     L320
  xorpd  %xmm7,%xmm12
L320:
  mov    -0x8(%r9,%rax,8),%r14
  movsd  (%r14,%rdx,1),%xmm8
  divsd  %xmm8,%xmm12
  comisd %xmm12,%xmm2
  jbe    L70
  movsd  (%rdi,%rax,8),%xmm13
  mulsd  %xmm8,%xmm8
  movslq %ecx,%r14
  movsd  0x8(%rdi,%r14,8),%xmm12
  mulsd  %xmm12,%xmm13
  subsd  %xmm13,%xmm0
  mulsd  %xmm12,%xmm0
  divsd  %xmm8,%xmm0
  mulsd  %xmm11,%xmm0
  movsd  %xmm0,-0x8(%rsp)
  faddl  -0x8(%rsp)
  nopl   (%rax)
L70:
  add    $0x1,%ecx
  add    $0x8,%rdx
  cmp    %ecx,%esi
  jne    L221
L153:
  fdiv   %st(2),%st
  lea    0x1(%rax),%ecx
  fstpl  (%r10,%rax,8)
  add    $0x1,%rax
  cmp    %eax,%r13d
  jge    L243
  cmp    %ecx,%esi
  jl     L334
L210:
  movslq %ecx,%rcx
  movq   D99(%rip),%xmm3
  movslq %r11d,%rbp
  movsd  D38(%rip),%xmm4
  mov    %rcx,%rax
  movq   D28(%rip),%xmm7
  movsd  D19(%rip),%xmm6
  sub    %rbp,%rax
  movapd %xmm3,%xmm5
  lea    -0x8(,%rax,8),%rdx
  nopl   (%rax)
L34:
  test   %r11d,%r11d
  jle    L279
  pxor   %xmm9,%xmm9
  fld    %st(0)
  xor    %eax,%eax
  comisd %xmm2,%xmm9
  ja     L220
  nopl   (%rax)
L123:
  mov    (%r8,%rax,8),%r12
  movsd  (%r12,%rdx,1),%xmm0
  ucomisd %xmm0,%xmm0
  jp     L183
  movapd %xmm0,%xmm8
  andpd  %xmm3,%xmm8
  ucomisd %xmm4,%xmm8
  ja     L183
  comisd %xmm1,%xmm0
  jbe    L183
  subsd  (%rbx,%rax,8),%xmm0
  comisd %xmm9,%xmm0
  movapd %xmm0,%xmm10
  ja     L101
  xorpd  %xmm7,%xmm10
L101:
  mov    (%r9,%rax,8),%r12
  movsd  (%r12,%rdx,1),%xmm8
  divsd  %xmm8,%xmm10
  comisd %xmm10,%xmm2
  jbe    L183
  movsd  0x8(%rdi,%rax,8),%xmm10
  movsd  (%rdi,%rcx,8),%xmm11
  mulsd  %xmm8,%xmm8
  mulsd  %xmm10,%xmm11
  subsd  %xmm11,%xmm0
  mulsd  %xmm10,%xmm0
  divsd  %xmm8,%xmm0
  mulsd  %xmm6,%xmm0
  movsd  %xmm0,-0x8(%rsp)
  faddl  -0x8(%rsp)
  nop
L183:
  add    $0x1,%rax
  cmp    %rax,%rbp
  jne    L123
L115:
  fdiv   %st(2),%st
  add    $0x8,%rdx
  fstpl  (%r10,%rcx,8)
  add    $0x1,%rcx
  cmp    %ecx,%esi
  jge    L34
  fstp   %st(0)
  fstp   %st(0)
  jmp    L75
L334:
  fstp   %st(0)
  fstp   %st(0)
L75:
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  ret
  cs nopw 0x0(%rax,%rax,1)
L188:
  movsd  (%r12,%rdx,1),%xmm0
  ucomisd %xmm0,%xmm0
  jp     L106
  movapd %xmm0,%xmm8
  andpd  %xmm4,%xmm8
  ucomisd %xmm5,%xmm8
  ja     L106
  comisd %xmm1,%xmm0
  jbe    L106
  mov    -0x8(%r9,%rax,8),%r14
  movsd  (%rdi,%rax,8),%xmm10
  subsd  -0x8(%rbx,%rax,8),%xmm0
  movsd  (%r14,%rdx,1),%xmm8
  movslq %ecx,%r14
  movsd  0x8(%rdi,%r14,8),%xmm9
  mulsd  %xmm8,%xmm8
  mulsd  %xmm9,%xmm10
  subsd  %xmm10,%xmm0
  mulsd  %xmm9,%xmm0
  divsd  %xmm8,%xmm0
  mulsd  %xmm6,%xmm0
  movsd  %xmm0,-0x8(%rsp)
  faddl  -0x8(%rsp)
L106:
  add    $0x1,%ecx
  add    $0x8,%rdx
  cmp    %ecx,%esi
  jne    L188
  jmp    L153
  nopl   0x0(%rax,%rax,1)
L220:
  movsd  D38(%rip),%xmm9
  movsd  D19(%rip),%xmm10
  nopw   0x0(%rax,%rax,1)
L55:
  mov    (%r8,%rax,8),%r12
  movsd  (%r12,%rdx,1),%xmm0
  ucomisd %xmm0,%xmm0
  jp     L339
  movapd %xmm0,%xmm8
  andpd  %xmm5,%xmm8
  ucomisd %xmm9,%xmm8
  ja     L339
  comisd %xmm1,%xmm0
  jbe    L339
  movsd  0x8(%rdi,%rax,8),%xmm11
  movsd  (%rdi,%rcx,8),%xmm12
  subsd  (%rbx,%rax,8),%xmm0
  mov    (%r9,%rax,8),%r12
  mulsd  %xmm11,%xmm12
  movsd  (%r12,%rdx,1),%xmm8
  mulsd  %xmm8,%xmm8
  subsd  %xmm12,%xmm0
  mulsd  %xmm11,%xmm0
  divsd  %xmm8,%xmm0
  mulsd  %xmm10,%xmm0
  movsd  %xmm0,-0x8(%rsp)
  faddl  -0x8(%rsp)
L339:
  add    $0x1,%rax
  cmp    %rax,%rbp
  jne    L55
  jmp    L115
  nopl   0x0(%rax)
L130:
  mov    $0x1,%ecx
  fldz
  jmp    L210
  nopl   0x0(%rax)
L279:
  fld    %st(0)
  jmp    L115
  nop
L314:
  fld    %st(0)
  jmp    L153
```

tool_calls: name: retrieve_data
arguments: data_label: D99
data_type: byte[8]
name: retrieve_data
arguments: data_label: D38
data_type: byte[8]
name: retrieve_data
arguments: data_label: D19
data_type: byte[8]
name: retrieve_data
arguments: data_label: D28
data_type: byte[8]

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

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

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

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

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