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

```asm
<amoeba>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x58,%rsp
  mov    %rdi,%r14
  mov    %rsi,%r15
  mov    %edx,%ebx
  mov    %edx,0x20(%rsp)
  movsd  %xmm0,0x30(%rsp)
  mov    %rcx,0x10(%rsp)
  mov    %r8,%rbp
  mov    %r8,(%rsp)
  lea    0x1(%rdx),%r13d
  mov    %r13d,0x24(%rsp)
  mov    %edx,%esi
  mov    $0x1,%edi
  mov    $0x0,%eax
  call   <vector@plt>
  mov    %rax,0x18(%rsp)
  movl   $0x0,0x0(%rbp)
  test   %ebx,%ebx
  jle    L168
  mov    %rax,%r9
  lea    0x1(%rbx),%edi
  shl    $0x3,%rdi
  mov    %ebx,%eax
  lea    0x10(%r14,%rax,8),%rsi
  mov    $0x8,%ecx
  mov    %r13d,%r8d
  jmp    L321
L167:
  mov    (%rax),%rdx
  addsd  (%rdx,%rcx,1),%xmm0
  add    $0x8,%rax
  cmp    %rsi,%rax
  jne    L167
L127:
  movsd  %xmm0,(%r9,%rcx,1)
  add    $0x8,%rcx
  cmp    %rdi,%rcx
  je     L168
L321:
  lea    0x8(%r14),%rax
  pxor   %xmm0,%xmm0
  test   %r8d,%r8d
  jg     L167
  jmp    L127
L168:
  mov    0x20(%rsp),%edi
  lea    -0x1(%rdi),%eax
  lea    0x10(,%rax,8),%rax
  mov    %rax,0x40(%rsp)
  mov    %edi,%eax
  mov    %rax,0x38(%rsp)
  lea    0x10(%r14,%rax,8),%rax
  mov    %rax,0x48(%rsp)
  jmp    L53
L303:
  mov    %ebp,%r12d
  mov    %eax,%ebp
L305:
  add    $0x1,%rax
  cmp    %rsi,%rax
  je     L131
L170:
  movsd  (%r15,%rax,8),%xmm0
  movslq %ebx,%rdx
  movsd  (%r15,%rdx,8),%xmm1
  ucomisd %xmm0,%xmm1
  cmova  %eax,%ebx
  movslq %ebp,%rdx
  comisd (%r15,%rdx,8),%xmm0
  ja     L303
  movslq %r12d,%rdx
  comisd (%r15,%rdx,8),%xmm0
  jbe    L305
  cmp    %eax,%ebp
  cmovne %eax,%r12d
  jmp    L305
L146:
  mov    $0x1,%ebx
L131:
  movslq %ebp,%rax
  lea    (%r15,%rax,8),%rax
  mov    %rax,0x28(%rsp)
  movsd  (%rax),%xmm1
  movslq %ebx,%rax
  lea    0x0(,%rax,8),%r13
  lea    (%r15,%r13,1),%rax
  mov    %rax,0x8(%rsp)
  movsd  (%rax),%xmm2
  movapd %xmm1,%xmm0
  subsd  %xmm2,%xmm0
  andpd  D79(%rip),%xmm0
  addsd  %xmm0,%xmm0
  andpd  D79(%rip),%xmm1
  andpd  D79(%rip),%xmm2
  addsd  %xmm2,%xmm1
  divsd  %xmm1,%xmm0
  movsd  0x30(%rsp),%xmm3
  comisd %xmm0,%xmm3
  ja     L238
  mov    (%rsp),%rax
  cmpl   $0x1387,(%rax)
  jg     L117
L296:
  sub    $0x8,%rsp
  push   0x8(%rsp)
  movsd  D0(%rip),%xmm0
  mov    %ebp,%r9d
  mov    0x20(%rsp),%r8
  mov    0x30(%rsp),%ecx
  mov    0x28(%rsp),%rdx
  mov    %r15,%rsi
  mov    %r14,%rdi
  mov    $0x1,%eax
  call   <amotry@plt>
  add    $0x10,%rsp
  mov    0x8(%rsp),%rax
  movsd  (%rax),%xmm1
  comisd %xmm0,%xmm1
  jae    L149
  movslq %r12d,%r12
  comisd (%r15,%r12,8),%xmm0
  jae    L109
L53:
  movsd  0x8(%r15),%xmm0
  comisd 0x10(%r15),%xmm0
  seta   %r12b
  movzbl %r12b,%r12d
  add    $0x1,%r12d
  comisd 0x10(%r15),%xmm0
  mov    $0x1,%ebp
  mov    $0x2,%eax
  cmovbe %eax,%ebp
  cmpl   $0x0,0x24(%rsp)
  jle    L146
  mov    0x38(%rsp),%rax
  lea    0x2(%rax),%rsi
  mov    $0x1,%eax
  mov    $0x1,%ebx
  jmp    L170
L117:
  lea    D54(%rip),%rdi
  mov    $0x0,%eax
  call   <nrerror@plt>
  jmp    L296
L149:
  sub    $0x8,%rsp
  push   0x8(%rsp)
  movsd  D72(%rip),%xmm0
  mov    %ebp,%r9d
  mov    0x20(%rsp),%r8
  mov    0x30(%rsp),%ecx
  mov    0x28(%rsp),%rdx
  mov    %r15,%rsi
  mov    %r14,%rdi
  mov    $0x1,%eax
  call   <amotry@plt>
  add    $0x10,%rsp
  jmp    L53
L109:
  mov    0x28(%rsp),%rax
  mov    (%rax),%r12
  sub    $0x8,%rsp
  push   0x8(%rsp)
  movsd  D44(%rip),%xmm0
  mov    %ebp,%r9d
  mov    0x20(%rsp),%r8
  mov    0x30(%rsp),%ecx
  mov    0x28(%rsp),%rdx
  mov    %r15,%rsi
  mov    %r14,%rdi
  mov    $0x1,%eax
  call   <amotry@plt>
  add    $0x10,%rsp
  movq   %r12,%xmm4
  comisd %xmm4,%xmm0
  jb     L53
  cmpl   $0x0,0x24(%rsp)
  jle    L29
  mov    $0x1,%ebp
  mov    %ebx,0x8(%rsp)
  mov    0x18(%rsp),%r12
  mov    %r15,0x28(%rsp)
  mov    0x40(%rsp),%r15
  mov    0x20(%rsp),%ebx
  jmp    L169
L79:
  mov    %r12,%rdi
  mov    $0x0,%eax
  mov    0x10(%rsp),%rsi
  call   *%rsi
  mov    0x28(%rsp),%rax
  movsd  %xmm0,(%rax,%rbp,8)
L308:
  add    $0x1,%rbp
  lea    -0x1(%rbp),%eax
  cmp    %eax,%ebx
  jl     L73
L169:
  cmp    %ebp,0x8(%rsp)
  je     L308
  test   %ebx,%ebx
  jle    L79
  mov    $0x8,%eax
L313:
  mov    (%r14,%r13,1),%rcx
  mov    (%r14,%rbp,8),%rdx
  movsd  (%rcx,%rax,1),%xmm0
  addsd  (%rdx,%rax,1),%xmm0
  mulsd  D44(%rip),%xmm0
  movsd  %xmm0,(%r12,%rax,1)
  mov    (%r14,%rbp,8),%rdx
  movsd  %xmm0,(%rdx,%rax,1)
  add    $0x8,%rax
  cmp    %r15,%rax
  jne    L313
  jmp    L79
L73:
  mov    0x28(%rsp),%r15
L29:
  mov    (%rsp),%rdi
  mov    0x20(%rsp),%eax
  add    %eax,(%rdi)
  mov    $0x8,%ecx
  test   %eax,%eax
  jle    L53
  mov    0x24(%rsp),%edi
  mov    0x18(%rsp),%r8
  mov    0x40(%rsp),%r9
  mov    0x48(%rsp),%rsi
  jmp    L75
L23:
  movsd  %xmm0,(%r8,%rcx,1)
  add    $0x8,%rcx
  cmp    %r9,%rcx
  je     L53
L75:
  lea    0x8(%r14),%rax
  pxor   %xmm0,%xmm0
  test   %edi,%edi
  jle    L23
L130:
  mov    (%rax),%rdx
  addsd  (%rdx,%rcx,1),%xmm0
  add    $0x8,%rax
  cmp    %rsi,%rax
  jne    L130
  jmp    L23
L238:
  mov    0x20(%rsp),%edx
  mov    $0x1,%esi
  mov    0x18(%rsp),%rdi
  mov    $0x0,%eax
  call   <free_vector@plt>
  add    $0x58,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
```

tool_calls: name: parse_data
arguments: label: D79
type: qword[2]
name: parse_data
arguments: label: D0
type: f32[2]
name: parse_data
arguments: label: D54
type: string
name: parse_data
arguments: label: D72
type: f64
name: parse_data
arguments: label: D44
type: f64

tool: {"D79": [0x7fffffffffffffff,0x0000000000000000]}

tool: {"D0": [0.0,-1.875]}

tool: D54: Too many iterations in AMOEBA

tool: D72: 2

tool: D44: 0.5

assistant: ```c
void amoeba(p, y, ndim, ftol, funk, nfunk) double **p, y[], ftol, (*funk)();
int ndim, *nfunk;
{
  int i, j, ilo, ihi, inhi, mpts = ndim + 1;
  double ytry, ysave, sum, rtol, amotry(), *psum, *vector();
  void nrerror(), free_vector();
  psum = vector(1, ndim);
  *nfunk = 0;
  for (j = 1; j <= ndim; j++) {
    for (i = 1, sum = 0.0; i <= mpts; i++)
      sum += p[i][j];
    psum[j] = sum;
  }
  for (;;) {
    ilo = 1;
    ihi = y[1] > y[2] ? (inhi = 2, 1) : (inhi = 1, 2);
    for (i = 1; i <= mpts; i++) {
      if (y[i] < y[ilo])
        ilo = i;
      if (y[i] > y[ihi]) {
        inhi = ihi;
        ihi = i;
      } else if (y[i] > y[inhi])
        if (i != ihi)
          inhi = i;
    }
    rtol = 2.0 * fabs(y[ihi] - y[ilo]) / (fabs(y[ihi]) + fabs(y[ilo]));
    if (rtol < ftol)
      break;
    if (*nfunk >= 5000)
      nrerror("Too many iterations in AMOEBA");
    ytry = amotry(p, y, psum, ndim, funk, ihi, nfunk, -1.0);
    if (ytry <= y[ilo])
      ytry = amotry(p, y, psum, ndim, funk, ihi, nfunk, 2.0);
    else if (ytry >= y[inhi]) {
      ysave = y[ihi];
      ytry = amotry(p, y, psum, ndim, funk, ihi, nfunk, 0.5);
      if (ytry >= ysave) {
        for (i = 1; i <= mpts; i++) {
          if (i != ilo) {
            for (j = 1; j <= ndim; j++) {
              psum[j] = 0.5 * (p[i][j] + p[ilo][j]);
              p[i][j] = psum[j];
            }
            y[i] = (*funk)(psum);
          }
        }
        *nfunk += ndim;
        for (j = 1; j <= ndim; j++) {
          for (i = 1, sum = 0.0; i <= mpts; i++)
            sum += p[i][j];
          psum[j] = sum;
        }
      }
    }
  }
  free_vector(psum, 1, ndim);
}
```