user: Converte this assembly snippet into its equivalent C code:

```asm
<reject_cr_psf>:
  endbr64
  push   %r15
  mov    %edx,%r15d
  push   %r14
  mov    %rsi,%r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  mov    %ecx,%ebx
  sub    $0xd8,%rsp
  mov    %rdi,(%rsp)
  mov    $0x10,%edi
  mov    %edx,0x58(%rsp)
  mov    %r8,0x98(%rsp)
  mov    %r9,0x20(%rsp)
  movss  %xmm0,0x50(%rsp)
  movss  %xmm1,0xa0(%rsp)
  movss  %xmm2,0xcc(%rsp)
  call   <malloc@plt>
  mov    $0x10,%edi
  mov    %rax,0x70(%rsp)
  call   <malloc@plt>
  mov    %rax,0x8(%rsp)
  lea    -0x1(%rbx),%eax
  mov    %eax,0x54(%rsp)
  cmp    $0x1,%eax
  jle    L252
  mov    %r15d,%edx
  cmp    $0x2,%r15d
  jle    L252
  movslq %edx,%rax
  lea    (%r15,%r15,2),%r15d
  mov    %edx,0x1c(%rsp)
  pxor   %xmm1,%xmm1
  shl    $0x2,%rax
  movl   $0x1,0x18(%rsp)
  mov    %r15d,%ebp
  mov    0x110(%rsp),%r12
  mov    %rax,0x60(%rsp)
  add    $0x4,%rax
  mov    %r14,%r15
  mov    0x20(%rsp),%r14
  mov    %rax,0x10(%rsp)
  mov    $0x2,%eax
  sub    %edx,%eax
  mov    %eax,0x5c(%rsp)
  nopl   0x0(%rax)
L224:
  mov    0x5c(%rsp),%eax
  mov    0x1c(%rsp),%edi
  mov    %r12,%rdx
  mov    0x10(%rsp),%rbx
  lea    (%rax,%rbp,1),%r10d
  add    %edi,%eax
  lea    0x2(%rdi),%r9d
  mov    %eax,%r13d
  mov    %r9d,%r12d
  mov    %ebp,%eax
  mov    %r13d,%ebp
  mov    %r10d,%r13d
  nopl   0x0(%rax,%rax,1)
L22:
  movss  (%r15,%rbx,1),%xmm0
  movl   $0x0,(%r14,%rbx,1)
  comiss %xmm1,%xmm0
  jbe    L144
  mov    (%rdx,%rbx,1),%ecx
  test   %ecx,%ecx
  je     L153
L144:
  add    $0x1,%r13d
  add    $0x1,%r12d
  add    $0x1,%ebp
  add    $0x4,%rbx
  cmp    %r13d,%eax
  jne    L22
  mov    0x58(%rsp),%esi
  mov    %eax,%ebp
  addl   $0x1,0x18(%rsp)
  mov    %rdx,%r12
  add    %esi,0x1c(%rsp)
  mov    0x60(%rsp),%rdx
  mov    0x18(%rsp),%eax
  add    %rdx,0x10(%rsp)
  add    %esi,%ebp
  cmp    0x54(%rsp),%eax
  jne    L224
L252:
  cmpq   $0x0,0x70(%rsp)
  jne    L125
L247:
  cmpq   $0x0,0x8(%rsp)
  jne    L24
L186:
  add    $0xd8,%rsp
  xor    %eax,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  cs nopw 0x0(%rax,%rax,1)
L153:
  mov    %rdx,0x110(%rsp)
  mov    %eax,0x20(%rsp)
  call   <sqrt@plt>
  mov    (%rsp),%rax
  lea    -0x2(%rbp),%ecx
  pxor   %xmm1,%xmm1
  movaps %xmm0,%xmm7
  mov    0x110(%rsp),%rdx
  movss  (%rax,%rbx,1),%xmm11
  movslq %ecx,%rax
  mov    %rax,0x38(%rsp)
  lea    (%r15,%rax,4),%rax
  mulss  %xmm0,%xmm11
  movss  (%rax),%xmm0
  mov    %rax,0x78(%rsp)
  mov    0x20(%rsp),%eax
  comiss %xmm1,%xmm0
  jbe    L200
  movss  D30(%rip),%xmm2
  movss  D108(%rip),%xmm9
  movaps %xmm2,%xmm12
L141:
  lea    -0x2(%r12),%ecx
  movaps %xmm1,%xmm0
  movaps %xmm2,%xmm10
  movslq %ecx,%rcx
  movaps %xmm1,%xmm13
  lea    (%r15,%rcx,4),%rsi
  cmpltss (%rsi),%xmm0
  mov    %rsi,0x28(%rsp)
  lea    -0x2(%r13),%esi
  movslq %esi,%rdi
  lea    (%r15,%rdi,4),%rsi
  mov    %rdi,0x40(%rsp)
  movss  (%rsi),%xmm3
  mov    %rsi,0x88(%rsp)
  andps  %xmm2,%xmm0
  comiss %xmm1,%xmm3
  jbe    L278
  movss  D108(%rip),%xmm10
  movaps %xmm2,%xmm13
L278:
  lea    -0x1(%rbp),%edi
  movaps %xmm1,%xmm5
  movss  D108(%rip),%xmm3
  lea    -0x1(%r13),%esi
  movslq %edi,%rdi
  movslq %esi,%rsi
  movaps %xmm2,%xmm4
  lea    (%r15,%rdi,4),%r11
  lea    (%r15,%rsi,4),%r8
  movss  (%r11),%xmm6
  mov    %r8,0x68(%rsp)
  cmpltss %xmm6,%xmm5
  andps  %xmm5,%xmm3
  andnps %xmm2,%xmm5
  orps   %xmm5,%xmm3
  movaps %xmm1,%xmm5
  cmpltss %xmm6,%xmm5
  movaps %xmm1,%xmm6
  cmpltss (%r8),%xmm6
  movslq %ebp,%r8
  lea    (%r15,%r8,4),%r10
  mov    %r8,0x48(%rsp)
  movslq %r12d,%r8
  andps  %xmm5,%xmm4
  andnps %xmm1,%xmm5
  mov    %r10,0x90(%rsp)
  orps   %xmm5,%xmm4
  movaps %xmm6,%xmm5
  andps  %xmm6,%xmm3
  andnps %xmm4,%xmm5
  andps  %xmm2,%xmm6
  orps   %xmm5,%xmm3
  movaps %xmm1,%xmm5
  cmpltss (%r10),%xmm5
  lea    (%r15,%r8,4),%r10
  mov    %r10,0x30(%rsp)
  andps  %xmm5,%xmm10
  movaps %xmm5,%xmm8
  andps  %xmm2,%xmm5
  movss  %xmm5,0x20(%rsp)
  movaps %xmm1,%xmm5
  andnps %xmm13,%xmm8
  cmpltss (%r10),%xmm5
  movslq %r13d,%r10
  orps   %xmm8,%xmm10
  lea    (%r15,%r10,4),%r9
  movaps %xmm1,%xmm8
  cmpltss (%r9),%xmm8
  mov    %r9,0x80(%rsp)
  andps  %xmm2,%xmm5
  movaps %xmm8,%xmm14
  andps  %xmm8,%xmm9
  andps  %xmm8,%xmm2
  andnps %xmm12,%xmm14
  orps   %xmm14,%xmm9
  movaps %xmm0,%xmm14
  addss  %xmm5,%xmm14
  comiss %xmm1,%xmm14
  jbe    L131
  mov    (%rsp),%r9
  movss  (%r9,%rcx,4),%xmm8
  movss  (%r9,%r8,4),%xmm15
  mov    0x8(%rsp),%rcx
  mulss  %xmm0,%xmm8
  mulss  %xmm5,%xmm15
  addss  %xmm15,%xmm8
  divss  %xmm14,%xmm8
  movss  %xmm8,(%rcx)
  mulss  %xmm7,%xmm8
  addss  0x50(%rsp),%xmm8
  comiss %xmm11,%xmm8
  ja     L144
L131:
  comiss %xmm1,%xmm3
  jbe    L199
  mov    (%rsp),%rcx
  movss  (%rcx,%rdi,4),%xmm8
  movss  (%rcx,%rsi,4),%xmm15
  mov    0x8(%rsp),%rdi
  mulss  %xmm4,%xmm8
  mulss  %xmm6,%xmm15
  addss  %xmm15,%xmm8
  divss  %xmm3,%xmm8
  movss  %xmm8,0x4(%rdi)
  mulss  %xmm7,%xmm8
  addss  0x50(%rsp),%xmm8
  comiss %xmm11,%xmm8
  ja     L144
L199:
  comiss %xmm1,%xmm9
  jbe    L150
  mov    (%rsp),%rcx
  mov    0x38(%rsp),%rdi
  movss  (%rcx,%r10,4),%xmm15
  movss  (%rcx,%rdi,4),%xmm8
  mov    0x8(%rsp),%rcx
  mulss  %xmm12,%xmm8
  mulss  %xmm2,%xmm15
  addss  %xmm15,%xmm8
  divss  %xmm9,%xmm8
  movss  %xmm8,0x8(%rcx)
  mulss  %xmm7,%xmm8
  addss  0x50(%rsp),%xmm8
  comiss %xmm11,%xmm8
  ja     L144
L150:
  comiss %xmm1,%xmm10
  jbe    L161
  mov    (%rsp),%rcx
  mov    0x40(%rsp),%rdi
  movss  0x20(%rsp),%xmm15
  movss  (%rcx,%rdi,4),%xmm8
  mov    0x48(%rsp),%rdi
  mulss  %xmm13,%xmm8
  mulss  (%rcx,%rdi,4),%xmm15
  mov    0x8(%rsp),%rcx
  addss  %xmm15,%xmm8
  divss  %xmm10,%xmm8
  movss  %xmm8,0xc(%rcx)
  mulss  %xmm7,%xmm8
  addss  0x50(%rsp),%xmm8
  comiss %xmm11,%xmm8
  ja     L144
L161:
  mov    %eax,0x48(%rsp)
  mov    0x28(%rsp),%rax
  cvtss2sd %xmm0,%xmm0
  pxor   %xmm8,%xmm8
  cvtss2sd %xmm5,%xmm5
  cvtss2sd %xmm14,%xmm14
  mov    %rdx,0x110(%rsp)
  cvtss2sd (%rax),%xmm8
  mov    0x30(%rsp),%rax
  addsd  D2(%rip),%xmm8
  movss  %xmm11,0x40(%rsp)
  movss  %xmm7,0x38(%rsp)
  mov    %r11,0xb8(%rsp)
  movss  %xmm2,0xc8(%rsp)
  subsd  %xmm0,%xmm8
  movss  %xmm6,0xc4(%rsp)
  movss  %xmm4,0xc0(%rsp)
  movss  %xmm13,0xb4(%rsp)
  divsd  %xmm8,%xmm0
  pxor   %xmm8,%xmm8
  movss  %xmm12,0xb0(%rsp)
  cvtss2sd (%rax),%xmm8
  addsd  D2(%rip),%xmm8
  movss  %xmm3,0xac(%rsp)
  movss  %xmm10,0xa8(%rsp)
  movss  %xmm9,0xa4(%rsp)
  subsd  %xmm5,%xmm8
  divsd  %xmm8,%xmm5
  addsd  %xmm5,%xmm0
  divsd  %xmm14,%xmm0
  cvtsd2ss %xmm0,%xmm0
  call   <sqrt@plt>
  mov    0x70(%rsp),%rax
  movss  0xa0(%rsp),%xmm7
  movss  0x40(%rsp),%xmm11
  mov    0x110(%rsp),%rdx
  pxor   %xmm1,%xmm1
  movss  %xmm0,(%rax)
  mov    0x98(%rsp),%rax
  mulss  %xmm7,%xmm0
  subss  %xmm7,%xmm11
  movss  0x38(%rsp),%xmm7
  mulss  0xcc(%rsp),%xmm11
  movss  (%rax),%xmm5
  mov    0x8(%rsp),%rax
  movss  (%rax),%xmm8
  mov    0x48(%rsp),%eax
  addss  %xmm8,%xmm0
  mulss  %xmm11,%xmm5
  mulss  %xmm7,%xmm0
  comiss %xmm0,%xmm5
  jbe    L23
  mov    (%rsp),%rdi
  movl   $0x1,(%r14,%rbx,1)
  movss  %xmm8,(%rdi,%rbx,1)
  jmp    L144
L200:
  movss  D30(%rip),%xmm2
  movaps %xmm1,%xmm12
  movaps %xmm2,%xmm9
  jmp    L141
  nopl   (%rax)
L23:
  mov    0xb8(%rsp),%r11
  pxor   %xmm0,%xmm0
  movss  0xc0(%rsp),%xmm4
  mov    %rdx,0x110(%rsp)
  movss  0xb0(%rsp),%xmm12
  movss  %xmm5,0x48(%rsp)
  movss  0xc4(%rsp),%xmm6
  cvtss2sd (%r11),%xmm0
  cvtss2sd %xmm4,%xmm4
  addsd  D2(%rip),%xmm0
  mov    %eax,0xb0(%rsp)
  mov    0x68(%rsp),%rax
  cvtss2sd %xmm6,%xmm6
  movss  0xac(%rsp),%xmm3
  movss  %xmm7,0x40(%rsp)
  movss  0xc8(%rsp),%xmm2
  movss  %xmm11,0x28(%rsp)
  movss  0xa4(%rsp),%xmm9
  subsd  %xmm4,%xmm0
  cvtss2sd %xmm3,%xmm3
  movss  0xa8(%rsp),%xmm10
  movss  0xb4(%rsp),%xmm13
  movss  %xmm2,0xac(%rsp)
  movss  %xmm13,0xa8(%rsp)
  divsd  %xmm0,%xmm4
  pxor   %xmm0,%xmm0
  movss  %xmm12,0xa4(%rsp)
  cvtss2sd (%rax),%xmm0
  addsd  D2(%rip),%xmm0
  movss  %xmm10,0x38(%rsp)
  movss  %xmm9,0x30(%rsp)
  subsd  %xmm6,%xmm0
  divsd  %xmm0,%xmm6
  pxor   %xmm0,%xmm0
  addsd  %xmm6,%xmm4
  divsd  %xmm3,%xmm4
  cvtsd2ss %xmm4,%xmm0
  call   <sqrt@plt>
  mov    0x70(%rsp),%rax
  movss  0x40(%rsp),%xmm7
  movss  0x48(%rsp),%xmm5
  movss  0x28(%rsp),%xmm11
  pxor   %xmm1,%xmm1
  movss  %xmm0,0x4(%rax)
  mov    0x8(%rsp),%rax
  mulss  0xa0(%rsp),%xmm0
  movss  0x30(%rsp),%xmm9
  movss  0x38(%rsp),%xmm10
  movss  0x4(%rax),%xmm3
  mov    0xb0(%rsp),%eax
  movss  0xa4(%rsp),%xmm12
  mov    0x110(%rsp),%rdx
  movss  0xa8(%rsp),%xmm13
  movss  0xac(%rsp),%xmm2
  addss  %xmm3,%xmm0
  mulss  %xmm7,%xmm0
  comiss %xmm0,%xmm5
  jbe    L250
  mov    (%rsp),%rcx
  movl   $0x1,(%r14,%rbx,1)
  movss  %xmm3,(%rcx,%rbx,1)
  jmp    L144
L250:
  mov    %eax,0x48(%rsp)
  mov    0x78(%rsp),%rax
  pxor   %xmm0,%xmm0
  cvtss2sd %xmm12,%xmm12
  cvtss2sd %xmm2,%xmm2
  cvtss2sd %xmm9,%xmm9
  mov    %rdx,0x110(%rsp)
  cvtss2sd (%rax),%xmm0
  addsd  D2(%rip),%xmm0
  mov    0x80(%rsp),%rax
  movss  %xmm13,0x40(%rsp)
  movss  %xmm7,0x38(%rsp)
  movss  %xmm10,0x30(%rsp)
  subsd  %xmm12,%xmm0
  movss  %xmm11,0x28(%rsp)
  divsd  %xmm0,%xmm12
  pxor   %xmm0,%xmm0
  cvtss2sd (%rax),%xmm0
  addsd  D2(%rip),%xmm0
  subsd  %xmm2,%xmm0
  divsd  %xmm0,%xmm2
  pxor   %xmm0,%xmm0
  addsd  %xmm12,%xmm2
  divsd  %xmm9,%xmm2
  cvtsd2ss %xmm2,%xmm0
  call   <sqrt@plt>
  mov    0x70(%rsp),%rax
  movss  0x28(%rsp),%xmm11
  movss  0x38(%rsp),%xmm7
  movss  0x30(%rsp),%xmm10
  pxor   %xmm1,%xmm1
  movss  %xmm0,0x8(%rax)
  mov    0x98(%rsp),%rax
  mulss  0xa0(%rsp),%xmm0
  movss  0x40(%rsp),%xmm13
  mov    0x110(%rsp),%rdx
  mulss  0x4(%rax),%xmm11
  mov    0x8(%rsp),%rax
  movss  0x8(%rax),%xmm2
  mov    0x48(%rsp),%eax
  addss  %xmm2,%xmm0
  mulss  %xmm7,%xmm0
  comiss %xmm0,%xmm11
  jbe    L27
L265:
  mov    (%rsp),%rcx
  movl   $0x1,(%r14,%rbx,1)
  movss  %xmm2,(%rcx,%rbx,1)
  jmp    L144
L27:
  mov    %eax,0x38(%rsp)
  mov    0x88(%rsp),%rax
  pxor   %xmm2,%xmm2
  pxor   %xmm0,%xmm0
  cvtss2sd %xmm13,%xmm13
  cvtss2sd 0x20(%rsp),%xmm0
  cvtss2sd %xmm10,%xmm10
  mov    %rdx,0x110(%rsp)
  cvtss2sd (%rax),%xmm2
  addsd  D2(%rip),%xmm2
  mov    0x90(%rsp),%rax
  movss  %xmm11,0x30(%rsp)
  movss  %xmm7,0x28(%rsp)
  subsd  %xmm13,%xmm2
  divsd  %xmm2,%xmm13
  pxor   %xmm2,%xmm2
  cvtss2sd (%rax),%xmm2
  addsd  D2(%rip),%xmm2
  subsd  %xmm0,%xmm2
  divsd  %xmm2,%xmm0
  addsd  %xmm13,%xmm0
  divsd  %xmm10,%xmm0
  cvtsd2ss %xmm0,%xmm0
  call   <sqrt@plt>
  mov    0x70(%rsp),%rax
  movss  0x28(%rsp),%xmm7
  movss  0x30(%rsp),%xmm11
  mov    0x110(%rsp),%rdx
  pxor   %xmm1,%xmm1
  movss  %xmm0,0xc(%rax)
  mov    0x8(%rsp),%rax
  mulss  0xa0(%rsp),%xmm0
  movss  0xc(%rax),%xmm2
  mov    0x38(%rsp),%eax
  addss  %xmm2,%xmm0
  mulss  %xmm7,%xmm0
  comiss %xmm0,%xmm11
  jbe    L144
  jmp    L265
L24:
  mov    0x8(%rsp),%rdi
  call   <free@plt>
  jmp    L186
L125:
  mov    0x70(%rsp),%rdi
  call   <free@plt>
  jmp    L247
```

tool_calls: name: retrieve_data
arguments: data_label: D30
datatype: f32
name: retrieve_data
arguments: data_label: D108
datatype: byte[4]
name: retrieve_data
arguments: data_label: D2
datatype: f32[2]

tool: D30: 1

tool: {"D108": [0x00,0x00,0x00,0x40]}

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

assistant: ```c
int reject_cr_psf(float *image, float *image_ivar, int xnpix, int ynpix, float nsig, float *psfvals, float cfudge, float c2fudge, int *rejected, int *ignoremask) {
  float *sigmaback, *back, imcurr, ival, lval, invsigma, goodback[3][3];
  int i, j, ip, jp;
  sigmaback = (float *)malloc(4 * sizeof(float));
  back = (float *)malloc(4 * sizeof(float));
  for (j = 1; j < ynpix - 1; j++) {
    for (i = 1; i < xnpix - 1; i++) {
      rejected[j * xnpix + i] = 0;
      if (image_ivar[j * xnpix + i] > 0. && ignoremask[j * xnpix + i] == 0) {
        invsigma = sqrt(image_ivar[j * xnpix + i]);
        imcurr = image[j * xnpix + i];
        ival = invsigma * imcurr;
        for (ip = -1; ip <= 1; ip++)
          for (jp = -1; jp <= 1; jp++)
            goodback[jp + 1][ip + 1] = (float)(image_ivar[(j + jp) * xnpix + (i + ip)] > 0.);
        if ((goodback[1][0] + goodback[1][2]) > 0) {
          back[0] = (image[j * xnpix + (i - 1)] * goodback[1][0] + image[j * xnpix + (i + 1)] * goodback[1][2]) / (goodback[1][0] + goodback[1][2]);
          if (ival < back[0] * invsigma + nsig)
            continue;
        }
        if ((goodback[0][1] + goodback[2][1]) > 0) {
          back[1] = (image[(j - 1) * xnpix + i] * goodback[0][1] + image[(j + 1) * xnpix + i] * goodback[2][1]) / (goodback[0][1] + goodback[2][1]);
          if (ival < back[1] * invsigma + nsig)
            continue;
        }
        if ((goodback[0][0] + goodback[2][2]) > 0) {
          back[2] = (image[(j - 1) * xnpix + (i - 1)] * goodback[0][0] + image[(j + 1) * xnpix + (i + 1)] * goodback[2][2]) / (goodback[0][0] + goodback[2][2]);
          if (ival < back[2] * invsigma + nsig)
            continue;
        }
        if ((goodback[2][0] + goodback[0][2]) > 0) {
          back[3] = (image[(j + 1) * xnpix + (i - 1)] * goodback[2][0] + image[(j - 1) * xnpix + (i + 1)] * goodback[0][2]) / (goodback[2][0] + goodback[0][2]);
          if (ival < back[3] * invsigma + nsig)
            continue;
          ival = invsigma * imcurr;
        }
        sigmaback[0] = sqrt((goodback[1][0] / (image_ivar[j * xnpix + (i - 1)] + 1. - goodback[1][0]) + goodback[1][2] / (image_ivar[j * xnpix + (i + 1)] + 1. - goodback[1][2])) / (goodback[1][0] + goodback[1][2]));
        lval = (ival - cfudge) * c2fudge * psfvals[0];
        if (lval > invsigma * (back[0] + cfudge * sigmaback[0])) {
          rejected[j * xnpix + i] = 1;
          image[j * xnpix + i] = back[0];
          continue;
        }
        sigmaback[1] = sqrt((goodback[0][1] / (image_ivar[(j - 1) * xnpix + i] + 1. - goodback[0][1]) + goodback[2][1] / (image_ivar[(j + 1) * xnpix + i] + 1. - goodback[2][1])) / (goodback[0][1] + goodback[2][1]));
        if (lval > invsigma * (back[1] + cfudge * sigmaback[1])) {
          rejected[j * xnpix + i] = 1;
          image[j * xnpix + i] = back[1];
          continue;
        }
        sigmaback[2] = sqrt((goodback[0][0] / (image_ivar[(j - 1) * xnpix + (i - 1)] + 1. - goodback[0][0]) + goodback[2][2] / (image_ivar[(j + 1) * xnpix + (i + 1)] + 1. - goodback[2][2])) / (goodback[0][0] + goodback[2][2]));
        lval = (ival - cfudge) * c2fudge * psfvals[1];
        if (lval > invsigma * (back[2] + cfudge * sigmaback[2])) {
          rejected[j * xnpix + i] = 1;
          image[j * xnpix + i] = back[2];
          continue;
        }
        sigmaback[3] = sqrt((goodback[2][0] / (image_ivar[(j + 1) * xnpix + (i - 1)] + 1. - goodback[2][0]) + goodback[0][2] / (image_ivar[(j - 1) * xnpix + (i + 1)] + 1. - goodback[0][2])) / (goodback[2][0] + goodback[0][2]));
        if (lval > invsigma * (back[3] + cfudge * sigmaback[3])) {
          rejected[j * xnpix + i] = 1;
          image[j * xnpix + i] = back[3];
          continue;
        }
      }
    }
  }
  {
    if ((sigmaback) != NULL)
      free((char *)(sigmaback));
    (sigmaback) = NULL;
  };
  {
    if ((back) != NULL)
      free((char *)(back));
    (back) = NULL;
  };
  return (0);
}
```