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

```asm
<reject_cr_psf>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0xd8,%rsp
  mov    %rdi,0x38(%rsp)
  mov    %rsi,%r15
  mov    %edx,%r14d
  mov    %edx,0x2c(%rsp)
  mov    %ecx,%ebx
  movss  %xmm0,0x58(%rsp)
  mov    %r8,0x80(%rsp)
  movss  %xmm1,0x74(%rsp)
  movss  %xmm2,0x98(%rsp)
  mov    %r9,0x10(%rsp)
  mov    0x110(%rsp),%rax
  mov    %rax,0x20(%rsp)
  mov    %fs:0x28,%rax
  mov    %rax,0xc8(%rsp)
  xor    %eax,%eax
  mov    $0x10,%edi
  call   <malloc@plt>
  mov    %rax,0x60(%rsp)
  mov    $0x10,%edi
  call   <malloc@plt>
  mov    %rax,0x48(%rsp)
  cmp    $0x2,%ebx
  jle    L267
  lea    (%r14,%r14,1),%eax
  mov    %eax,0x30(%rsp)
  lea    -0x1(%rbx),%eax
  mov    %eax,0x5c(%rsp)
  movslq %r14d,%rax
  shl    $0x2,%rax
  mov    %rax,0x18(%rsp)
  movl   $0x0,0x34(%rsp)
  movl   $0x1,0x28(%rsp)
  mov    %r15,%rbp
  jmp    L96
L123:
  pxor   %xmm0,%xmm0
  cvtss2sd 0x68(%rsp),%xmm0
  pxor   %xmm1,%xmm1
  cvtss2sd 0x6c(%rsp),%xmm1
  lea    -0x1(%r12),%eax
  cltq
  pxor   %xmm2,%xmm2
  cvtss2sd 0x0(%rbp,%rax,4),%xmm2
  movsd  D28(%rip),%xmm3
  addsd  %xmm3,%xmm2
  subsd  %xmm0,%xmm2
  divsd  %xmm2,%xmm0
  lea    0x1(%r15),%eax
  cltq
  pxor   %xmm2,%xmm2
  cvtss2sd 0x0(%rbp,%rax,4),%xmm2
  addsd  %xmm3,%xmm2
  subsd  %xmm1,%xmm2
  divsd  %xmm2,%xmm1
  addsd  %xmm1,%xmm0
  pxor   %xmm1,%xmm1
  cvtss2sd 0x70(%rsp),%xmm1
  divsd  %xmm1,%xmm0
  cvtsd2ss %xmm0,%xmm0
  call   <sqrt@plt>
  mov    0x60(%rsp),%rax
  movss  %xmm0,0x4(%rax)
  mulss  0x74(%rsp),%xmm0
  mov    0x48(%rsp),%rax
  addss  0x4(%rax),%xmm0
  mulss  0x40(%rsp),%xmm0
  movss  0x44(%rsp),%xmm3
  comiss %xmm0,%xmm3
  jbe    L283
  mov    0x10(%rsp),%rdx
  movl   $0x1,(%rdx,%rbx,1)
  movss  0x4(%rax),%xmm0
  mov    0x38(%rsp),%rax
  movss  %xmm0,(%rax,%rbx,1)
L285:
  add    $0x1,%r13
  add    $0x1,%r14d
  add    $0x1,%r15d
  add    $0x1,%r12d
  add    $0x4,%rbx
  cmp    0x8(%rsp),%r13
  je     L43
L204:
  mov    0x10(%rsp),%rax
  movl   $0x0,(%rax,%rbx,1)
  movss  0x0(%rbp,%rbx,1),%xmm0
  pxor   %xmm5,%xmm5
  comiss %xmm5,%xmm0
  jbe    L285
  mov    0x20(%rsp),%rax
  cmpl   $0x0,(%rax,%rbx,1)
  jne    L285
  call   <sqrt@plt>
  movaps %xmm0,%xmm6
  movss  %xmm0,0x40(%rsp)
  mov    0x38(%rsp),%rax
  mulss  (%rax,%rbx,1),%xmm6
  movss  %xmm6,0x44(%rsp)
  lea    0xc0(%rsp),%rcx
  mov    0x50(%rsp),%rax
  lea    -0x4(%rbx,%rax,1),%rdi
  mov    %r13d,%r8d
  lea    -0x1(%r13),%esi
  pxor   %xmm2,%xmm2
  movaps %xmm2,%xmm3
  lea    0x2(%r13),%r9d
L33:
  lea    -0x24(%rcx),%rax
  mov    %rdi,%rdx
L226:
  movss  (%rdx),%xmm1
  movaps %xmm2,%xmm0
  cmpltss %xmm1,%xmm0
  movss  D83(%rip),%xmm1
  andps  %xmm0,%xmm1
  andnps %xmm3,%xmm0
  orps   %xmm1,%xmm0
  movss  %xmm0,0x4(%rax)
  add    0x18(%rsp),%rdx
  add    $0xc,%rax
  cmp    %rcx,%rax
  jne    L226
  add    $0x4,%rcx
  add    $0x4,%rdi
  add    $0x1,%esi
  cmp    %r9d,%esi
  jne    L33
  movss  0xac(%rsp),%xmm0
  movss  0xb4(%rsp),%xmm2
  movaps %xmm0,%xmm3
  addss  %xmm2,%xmm3
  comiss D28(%rip),%xmm3
  jbe    L200
  lea    -0x2(%r14),%eax
  cltq
  mov    0x38(%rsp),%rsi
  movaps %xmm0,%xmm1
  mulss  (%rsi,%rax,4),%xmm1
  movslq %r14d,%rax
  movaps %xmm2,%xmm4
  mulss  (%rsi,%rax,4),%xmm4
  addss  %xmm4,%xmm1
  divss  %xmm3,%xmm1
  mov    0x48(%rsp),%rax
  movss  %xmm1,(%rax)
  mulss  0x40(%rsp),%xmm1
  addss  0x58(%rsp),%xmm1
  comiss 0x44(%rsp),%xmm1
  ja     L285
L200:
  movss  0xa4(%rsp),%xmm7
  movss  %xmm7,0x68(%rsp)
  movss  0xbc(%rsp),%xmm4
  movss  %xmm4,0x6c(%rsp)
  movaps %xmm7,%xmm6
  addss  %xmm4,%xmm6
  movss  %xmm6,0x70(%rsp)
  comiss D28(%rip),%xmm6
  jbe    L124
  mov    0x34(%rsp),%eax
  add    %r8d,%eax
  cltq
  mov    0x38(%rsp),%rcx
  mulss  (%rcx,%rax,4),%xmm7
  movaps %xmm7,%xmm1
  mov    0x30(%rsp),%eax
  add    %r8d,%eax
  cltq
  mulss  (%rcx,%rax,4),%xmm4
  addss  %xmm4,%xmm1
  divss  %xmm6,%xmm1
  mov    0x48(%rsp),%rax
  movss  %xmm1,0x4(%rax)
  mulss  0x40(%rsp),%xmm1
  addss  0x58(%rsp),%xmm1
  comiss 0x44(%rsp),%xmm1
  ja     L285
L124:
  movss  0xa0(%rsp),%xmm4
  movss  %xmm4,0x78(%rsp)
  movss  0xc0(%rsp),%xmm6
  movss  %xmm6,0x7c(%rsp)
  movaps %xmm4,%xmm7
  addss  %xmm6,%xmm7
  movss  %xmm7,0x88(%rsp)
  comiss D28(%rip),%xmm7
  jbe    L252
  mov    0x34(%rsp),%eax
  lea    -0x1(%r8,%rax,1),%eax
  cltq
  mov    0x38(%rsp),%rdx
  mulss  (%rdx,%rax,4),%xmm4
  movaps %xmm4,%xmm1
  mov    0x30(%rsp),%eax
  lea    0x1(%r8,%rax,1),%eax
  cltq
  mulss  (%rdx,%rax,4),%xmm6
  addss  %xmm6,%xmm1
  divss  %xmm7,%xmm1
  mov    0x48(%rsp),%rax
  movss  %xmm1,0x8(%rax)
  mulss  0x40(%rsp),%xmm1
  addss  0x58(%rsp),%xmm1
  comiss 0x44(%rsp),%xmm1
  ja     L285
L252:
  movss  0xb8(%rsp),%xmm4
  movss  %xmm4,0x8c(%rsp)
  movss  0xa8(%rsp),%xmm5
  movss  %xmm5,0x90(%rsp)
  movaps %xmm4,%xmm7
  addss  %xmm5,%xmm7
  movss  %xmm7,0x94(%rsp)
  comiss D28(%rip),%xmm7
  jbe    L173
  mov    0x30(%rsp),%eax
  lea    -0x1(%r8,%rax,1),%eax
  cltq
  mov    0x38(%rsp),%rdi
  mulss  (%rdi,%rax,4),%xmm4
  movaps %xmm4,%xmm1
  mov    0x34(%rsp),%eax
  lea    0x1(%r8,%rax,1),%eax
  cltq
  movaps %xmm5,%xmm4
  mulss  (%rdi,%rax,4),%xmm4
  addss  %xmm4,%xmm1
  divss  %xmm7,%xmm1
  mov    0x48(%rsp),%rax
  movss  %xmm1,0xc(%rax)
  mulss  0x40(%rsp),%xmm1
  addss  0x58(%rsp),%xmm1
  comiss 0x44(%rsp),%xmm1
  ja     L285
L173:
  cvtss2sd %xmm0,%xmm0
  cvtss2sd %xmm2,%xmm2
  lea    -0x2(%r14),%eax
  cltq
  pxor   %xmm1,%xmm1
  cvtss2sd 0x0(%rbp,%rax,4),%xmm1
  movsd  D28(%rip),%xmm4
  addsd  %xmm4,%xmm1
  subsd  %xmm0,%xmm1
  divsd  %xmm1,%xmm0
  movslq %r14d,%rax
  pxor   %xmm1,%xmm1
  cvtss2sd 0x0(%rbp,%rax,4),%xmm1
  addsd  %xmm4,%xmm1
  subsd  %xmm2,%xmm1
  divsd  %xmm1,%xmm2
  addsd  %xmm2,%xmm0
  cvtss2sd %xmm3,%xmm3
  divsd  %xmm3,%xmm0
  cvtsd2ss %xmm0,%xmm0
  call   <sqrt@plt>
  mov    0x60(%rsp),%rax
  movss  %xmm0,(%rax)
  movss  0x44(%rsp),%xmm1
  movss  0x74(%rsp),%xmm7
  subss  %xmm7,%xmm1
  mulss  0x98(%rsp),%xmm1
  movaps %xmm1,%xmm3
  movss  %xmm1,0x9c(%rsp)
  mov    0x80(%rsp),%rax
  mulss  (%rax),%xmm3
  movss  %xmm3,0x44(%rsp)
  mulss  %xmm7,%xmm0
  mov    0x48(%rsp),%rax
  addss  (%rax),%xmm0
  mulss  0x40(%rsp),%xmm0
  comiss %xmm0,%xmm3
  jbe    L123
  mov    0x10(%rsp),%rsi
  movl   $0x1,(%rsi,%rbx,1)
  movss  (%rax),%xmm0
  mov    0x38(%rsp),%rax
  movss  %xmm0,(%rax,%rbx,1)
  jmp    L285
L283:
  pxor   %xmm0,%xmm0
  cvtss2sd 0x78(%rsp),%xmm0
  pxor   %xmm1,%xmm1
  cvtss2sd 0x7c(%rsp),%xmm1
  lea    -0x2(%r12),%eax
  cltq
  pxor   %xmm2,%xmm2
  cvtss2sd 0x0(%rbp,%rax,4),%xmm2
  movsd  D28(%rip),%xmm3
  addsd  %xmm3,%xmm2
  subsd  %xmm0,%xmm2
  divsd  %xmm2,%xmm0
  lea    0x2(%r15),%eax
  cltq
  pxor   %xmm2,%xmm2
  cvtss2sd 0x0(%rbp,%rax,4),%xmm2
  addsd  %xmm3,%xmm2
  subsd  %xmm1,%xmm2
  divsd  %xmm2,%xmm1
  addsd  %xmm1,%xmm0
  pxor   %xmm1,%xmm1
  cvtss2sd 0x88(%rsp),%xmm1
  divsd  %xmm1,%xmm0
  cvtsd2ss %xmm0,%xmm0
  call   <sqrt@plt>
  mov    0x60(%rsp),%rax
  movss  %xmm0,0x8(%rax)
  mov    0x80(%rsp),%rax
  movss  0x9c(%rsp),%xmm3
  mulss  0x4(%rax),%xmm3
  movss  %xmm3,0x44(%rsp)
  mulss  0x74(%rsp),%xmm0
  mov    0x48(%rsp),%rax
  addss  0x8(%rax),%xmm0
  mulss  0x40(%rsp),%xmm0
  comiss %xmm0,%xmm3
  jbe    L273
  mov    0x10(%rsp),%rsi
  movl   $0x1,(%rsi,%rbx,1)
  movss  0x8(%rax),%xmm0
  mov    0x38(%rsp),%rax
  movss  %xmm0,(%rax,%rbx,1)
  jmp    L285
L273:
  pxor   %xmm0,%xmm0
  cvtss2sd 0x8c(%rsp),%xmm0
  pxor   %xmm1,%xmm1
  cvtss2sd 0x90(%rsp),%xmm1
  movslq %r15d,%rax
  pxor   %xmm2,%xmm2
  cvtss2sd 0x0(%rbp,%rax,4),%xmm2
  movsd  D28(%rip),%xmm3
  addsd  %xmm3,%xmm2
  subsd  %xmm0,%xmm2
  divsd  %xmm2,%xmm0
  movslq %r12d,%rax
  pxor   %xmm2,%xmm2
  cvtss2sd 0x0(%rbp,%rax,4),%xmm2
  addsd  %xmm3,%xmm2
  subsd  %xmm1,%xmm2
  divsd  %xmm2,%xmm1
  addsd  %xmm1,%xmm0
  pxor   %xmm1,%xmm1
  cvtss2sd 0x94(%rsp),%xmm1
  divsd  %xmm1,%xmm0
  cvtsd2ss %xmm0,%xmm0
  call   <sqrt@plt>
  mov    0x60(%rsp),%rax
  movss  %xmm0,0xc(%rax)
  mulss  0x74(%rsp),%xmm0
  mov    0x48(%rsp),%rax
  addss  0xc(%rax),%xmm0
  mulss  0x40(%rsp),%xmm0
  movss  0x44(%rsp),%xmm3
  comiss %xmm0,%xmm3
  jbe    L285
  mov    0x10(%rsp),%rax
  movl   $0x1,(%rax,%rbx,1)
  mov    0x48(%rsp),%rax
  movss  0xc(%rax),%xmm0
  mov    0x38(%rsp),%rax
  movss  %xmm0,(%rax,%rbx,1)
  jmp    L285
L43:
  addl   $0x1,0x28(%rsp)
  mov    0x28(%rsp),%eax
  mov    0x2c(%rsp),%edi
  add    %edi,0x30(%rsp)
  add    %edi,0x34(%rsp)
  cmp    0x5c(%rsp),%eax
  je     L267
L96:
  cmpl   $0x2,0x2c(%rsp)
  jle    L43
  mov    0x34(%rsp),%esi
  mov    0x2c(%rsp),%edi
  lea    0x2(%rsi,%rdi,1),%r14d
  lea    0x2(%rsi),%r12d
  mov    %edi,%eax
  add    %esi,%eax
  cltq
  lea    0x4(,%rax,4),%rbx
  lea    -0x3(%rdi),%edx
  lea    0x2(%rdx),%rcx
  mov    %rcx,0x8(%rsp)
  movslq %esi,%rdx
  lea    0x0(%rbp,%rdx,4),%rdx
  shl    $0x2,%rax
  sub    %rax,%rdx
  mov    %rdx,0x50(%rsp)
  mov    0x30(%rsp),%r15d
  mov    $0x1,%r13d
  jmp    L204
L267:
  cmpq   $0x0,0x60(%rsp)
  jne    L89
L178:
  cmpq   $0x0,0x48(%rsp)
  jne    L152
L259:
  mov    0xc8(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L31
  mov    $0x0,%eax
  add    $0xd8,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L89:
  mov    0x60(%rsp),%rdi
  call   <free@plt>
  jmp    L178
L152:
  mov    0x48(%rsp),%rdi
  call   <free@plt>
  jmp    L259
L31:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: read_data
arguments: label: D28
type_infered: f64
name: read_data
arguments: label: D83
type_infered: byte[4]

tool: D28: 1

tool: {"D83": [0x00,0x00,0x80,0x3f]}

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