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

```asm
<simplx>:
  endbr64
  push   %r15
  mov    %rcx,%r15
  push   %r14
  mov    %rdi,%r14
  movslq %r8d,%rdi
  push   %r13
  mov    %r9,%r13
  push   %r12
  mov    %rsi,%r12
  push   %rbp
  push   %rbx
  mov    %edx,%ebx
  sub    $0x68,%rsp
  mov    %edi,0x34(%rsp)
  shl    $0x3,%rdi
  mov    %rdi,(%rsp)
  movsd  %xmm0,0x28(%rsp)
  movsd  %xmm1,0x38(%rsp)
  call   <malloc@plt>
  mov    (%rsp),%rdi
  mov    0xb8(%rsp),%r8
  test   %rax,%rax
  je     L375
  mov    %r8,0xb8(%rsp)
  mov    %rax,%rbp
  call   <malloc@plt>
  mov    %rax,0x8(%rsp)
  test   %rax,%rax
  je     L375
  lea    0x1(%rbx),%eax
  lea    -0x1(%rbx),%ecx
  mov    0xb8(%rsp),%r8
  mov    %eax,0x30(%rsp)
  mov    0xb0(%rsp),%rax
  movl   $0x0,(%rax)
  lea    0x8(,%rcx,8),%rax
  mov    %rax,0x48(%rsp)
  mov    %ebx,%eax
  shr    %eax
  sub    $0x1,%eax
  add    $0x1,%rax
  shl    $0x4,%rax
  mov    %rax,%r11
  mov    %ebx,%eax
  and    $0xfffffffe,%eax
  mov    %eax,(%rsp)
  mov    0x34(%rsp),%eax
  sub    $0x1,%eax
  lea    0x8(,%rax,8),%rax
  mov    %rax,0x40(%rsp)
  xchg   %ax,%ax
L591:
  movsd  (%r12),%xmm0
  xor    %eax,%eax
  comisd 0x8(%r12),%xmm0
  mov    $0x8,%edx
  mov    0xc0(%rsp),%rdi
  mov    0x30(%rsp),%r10d
  movl   $0x0,(%r8)
  cmovbe %rdx,%rax
  setbe  %dl
  seta   %r9b
  movzbl %dl,%edx
  movzbl %r9b,%r9d
  mov    %edx,(%rdi)
  test   %r10d,%r10d
  jle    L506
  movslq (%r8),%rax
  mov    %rbp,0x10(%rsp)
  mov    %ebx,%r10d
  mov    %rdi,%rbp
  movsd  (%r12,%rax,8),%xmm3
  xor    %eax,%eax
  jmp    L298
  nopl   (%rax)
L532:
  mov    %esi,0x0(%rbp)
  movslq (%r8),%rdi
  mov    %edx,%r9d
  movapd %xmm0,%xmm1
  mov    %esi,%edx
  movsd  (%r12,%rdi,8),%xmm3
L618:
  lea    0x1(%rax),%rsi
  cmp    %rax,%r10
  je     L104
L608:
  movsd  (%r12,%rsi,8),%xmm0
  mov    %rsi,%rax
L298:
  comisd %xmm0,%xmm3
  mov    %eax,%esi
  jbe    L449
  mov    %eax,(%r8)
  mov    0x0(%rbp),%edx
  movapd %xmm0,%xmm3
L449:
  movslq %edx,%rdi
  movsd  (%r12,%rdi,8),%xmm1
  comisd %xmm1,%xmm0
  ja     L532
  movslq %r9d,%rdi
  comisd (%r12,%rdi,8),%xmm0
  jbe    L618
  cmp    %eax,%edx
  cmovne %esi,%r9d
  lea    0x1(%rax),%rsi
  cmp    %rax,%r10
  jne    L608
L104:
  mov    0x10(%rsp),%rbp
L364:
  movapd %xmm1,%xmm0
  movapd %xmm3,%xmm4
  andpd  D13(%rip),%xmm1
  andpd  D13(%rip),%xmm4
  subsd  %xmm3,%xmm0
  andpd  D13(%rip),%xmm0
  addsd  %xmm4,%xmm1
  mulsd  0x28(%rsp),%xmm1
  addsd  %xmm0,%xmm0
  comisd %xmm0,%xmm1
  jae    L410
  movsd  0x38(%rsp),%xmm7
  comisd %xmm3,%xmm7
  ja     L480
  mov    0xb0(%rsp),%rax
  mov    (%rax),%eax
  cmp    0xa8(%rsp),%eax
  je     L482
  mov    0xb0(%rsp),%rdi
  add    $0x1,%eax
  mov    %eax,(%rdi)
  test   %ebx,%ebx
  jle    L397
  mov    0x48(%rsp),%rdx
  xor    %esi,%esi
  mov    %rbp,%rdi
  mov    %r11,0x20(%rsp)
  mov    %r8,0xb8(%rsp)
  mov    %rcx,0x18(%rsp)
  mov    %r9d,0x10(%rsp)
  call   <memset@plt>
  mov    0x30(%rsp),%edi
  mov    0x10(%rsp),%r9d
  mov    0xc0(%rsp),%rax
  mov    0x18(%rsp),%rcx
  test   %edi,%edi
  mov    0x20(%rsp),%r11
  mov    0xb8(%rsp),%r8
  mov    (%rax),%r10d
  jle    L117
L295:
  xor    %esi,%esi
  xor    %edi,%edi
  jmp    L143
L93:
  lea    0x1(%rdi),%eax
  add    %ebx,%esi
  cmp    %edi,%ebx
  jle    L82
  nopw   0x0(%rax,%rax,1)
L503:
  mov    %eax,%edi
L143:
  cmp    %edi,%r10d
  je     L93
  test   %ebx,%ebx
  jle    L58
  cmp    $0x1,%ebx
  je     L378
  movslq %esi,%rax
  lea    (%r14,%rax,8),%rdx
  xor    %eax,%eax
  nopl   0x0(%rax)
L328:
  movupd 0x0(%rbp,%rax,1),%xmm5
  movupd (%rdx,%rax,1),%xmm0
  addpd  %xmm5,%xmm0
  movups %xmm0,0x0(%rbp,%rax,1)
  add    $0x10,%rax
  cmp    %rax,%r11
  jne    L328
  mov    (%rsp),%eax
  cmp    %ebx,%eax
  je     L93
L470:
  movslq %eax,%rdx
  add    %esi,%eax
  add    %ebx,%esi
  lea    0x0(%rbp,%rdx,8),%rdx
  cltq
  movsd  (%rdx),%xmm0
  addsd  (%r14,%rax,8),%xmm0
  lea    0x1(%rdi),%eax
  movsd  %xmm0,(%rdx)
  cmp    %edi,%ebx
  jg     L503
L82:
  test   %ebx,%ebx
  jle    L58
L117:
  imul   %ebx,%r10d
  pxor   %xmm1,%xmm1
  xor    %eax,%eax
  cvtsi2sd %ebx,%xmm1
  movslq %r10d,%r10
  lea    (%r14,%r10,8),%rsi
L172:
  movsd  0x0(%rbp,%rax,8),%xmm0
  movslq 0x0(%r13,%rax,4),%rdx
  divsd  %xmm1,%xmm0
  movsd  %xmm0,0x0(%rbp,%rax,8)
  addsd  %xmm0,%xmm0
  subsd  (%rsi,%rax,8),%xmm0
  add    $0x1,%rax
  movsd  %xmm0,(%r15,%rdx,8)
  cmp    %eax,%ebx
  jg     L172
L58:
  mov    0x34(%rsp),%esi
  test   %esi,%esi
  jle    L597
  mov    0x40(%rsp),%rdx
  mov    0x8(%rsp),%rdi
  mov    %r15,%rsi
  mov    %r8,0xb8(%rsp)
  mov    %r11,0x20(%rsp)
  mov    %rcx,0x18(%rsp)
  mov    %r9d,0x10(%rsp)
  call   <memcpy@plt>
  mov    0x10(%rsp),%r9d
  mov    0x18(%rsp),%rcx
  mov    0x20(%rsp),%r11
  mov    0xb8(%rsp),%r8
L597:
  xor    %eax,%eax
  mov    %r8,0xb8(%rsp)
  mov    %r15,%rdi
  mov    %r11,0x20(%rsp)
  mov    %rcx,0x18(%rsp)
  mov    %r9d,0x10(%rsp)
  call   *0xa0(%rsp)
  mov    0xb8(%rsp),%r8
  movslq 0x10(%rsp),%r9
  movapd %xmm0,%xmm1
  mov    0x18(%rsp),%rcx
  mov    0x20(%rsp),%r11
  movslq (%r8),%rax
  movsd  (%r12,%rax,8),%xmm0
  mov    D9(%rip),%rax
  comisd %xmm1,%xmm0
  movq   %rax,%xmm2
  ja     L186
  mov    0xc0(%rsp),%rax
  comisd (%r12,%r9,8),%xmm1
  movslq (%rax),%rdx
  mov    %rdx,%rax
  lea    (%r12,%rdx,8),%rdi
  jae    L168
  test   %ebx,%ebx
  jle    L521
  imul   %ebx,%eax
  cltq
  lea    (%r14,%rax,8),%rsi
  xor    %eax,%eax
  nopw   0x0(%rax,%rax,1)
L581:
  movslq 0x0(%r13,%rax,4),%rdx
  movsd  (%r15,%rdx,8),%xmm0
  mov    %rax,%rdx
  movsd  %xmm0,(%rsi,%rax,8)
  add    $0x1,%rax
  cmp    %rdx,%rcx
  jne    L581
L521:
  movsd  %xmm1,(%rdi)
  jmp    L591
  nopl   (%rax)
L168:
  movsd  (%rdi),%xmm0
  comisd %xmm1,%xmm0
  ja     L310
L468:
  test   %ebx,%ebx
  jle    L280
  imul   %ebx,%eax
  mov    0x8(%rsp),%rdi
  cltq
  lea    (%r14,%rax,8),%rsi
  xor    %eax,%eax
  xchg   %ax,%ax
L357:
  movsd  (%rsi,%rax,8),%xmm0
  movsd  0x0(%rbp,%rax,8),%xmm1
  movslq 0x0(%r13,%rax,4),%rdx
  mulsd  %xmm2,%xmm0
  mulsd  %xmm2,%xmm1
  addsd  %xmm1,%xmm0
  movsd  %xmm0,(%rdi,%rdx,8)
  mov    %rax,%rdx
  add    $0x1,%rax
  cmp    %rdx,%rcx
  jne    L357
  xor    %eax,%eax
  mov    %r11,0x18(%rsp)
  mov    0x8(%rsp),%rdi
  mov    %r8,0xb8(%rsp)
  mov    %rcx,0x10(%rsp)
  call   *0xa0(%rsp)
  mov    0xc0(%rsp),%rax
  mov    D9(%rip),%rcx
  movapd %xmm0,%xmm1
  mov    0x18(%rsp),%r11
  mov    0xb8(%rsp),%r8
  movslq (%rax),%rdx
  movq   %rcx,%xmm2
  mov    0x10(%rsp),%rcx
  lea    (%r12,%rdx,8),%rdi
  mov    %rdx,%rax
  movsd  (%rdi),%xmm0
  comisd %xmm1,%xmm0
  jbe    L131
  imul   %ebx,%eax
  mov    0x8(%rsp),%r9
  cltq
  lea    (%r14,%rax,8),%rsi
  xor    %eax,%eax
  nop
L213:
  movslq 0x0(%r13,%rax,4),%rdx
  movsd  (%r9,%rdx,8),%xmm0
  mov    %rax,%rdx
  movsd  %xmm0,(%rsi,%rax,8)
  add    $0x1,%rax
  cmp    %rdx,%rcx
  jne    L213
  movsd  %xmm1,(%rdi)
  jmp    L591
L378:
  xor    %eax,%eax
  jmp    L470
L186:
  test   %ebx,%ebx
  jle    L195
  mov    0x8(%rsp),%rsi
  xor    %eax,%eax
  nopl   0x0(%rax,%rax,1)
L379:
  movslq 0x0(%r13,%rax,4),%rdx
  movsd  (%r15,%rdx,8),%xmm0
  addsd  %xmm0,%xmm0
  subsd  0x0(%rbp,%rax,8),%xmm0
  movsd  %xmm0,(%rsi,%rdx,8)
  mov    %rax,%rdx
  add    $0x1,%rax
  cmp    %rdx,%rcx
  jne    L379
  xor    %eax,%eax
  mov    %r11,0x18(%rsp)
  mov    0x8(%rsp),%rdi
  mov    %r8,0xb8(%rsp)
  mov    %rcx,0x10(%rsp)
  movsd  %xmm1,0x20(%rsp)
  call   *0xa0(%rsp)
  mov    0xb8(%rsp),%r8
  mov    0x10(%rsp),%rcx
  movapd %xmm0,%xmm3
  mov    0x18(%rsp),%r11
  movslq (%r8),%rax
  movsd  (%r12,%rax,8),%xmm0
  comisd %xmm3,%xmm0
  ja     L440
  mov    0xc0(%rsp),%rax
  movsd  0x20(%rsp),%xmm1
  movslq (%rax),%rdi
  mov    %ebx,%eax
  imul   %edi,%eax
  cltq
  lea    (%r14,%rax,8),%rsi
  xor    %eax,%eax
  nopl   0x0(%rax,%rax,1)
L431:
  movslq 0x0(%r13,%rax,4),%rdx
  movsd  (%r15,%rdx,8),%xmm0
  mov    %rax,%rdx
  movsd  %xmm0,(%rsi,%rax,8)
  add    $0x1,%rax
  cmp    %rcx,%rdx
  jne    L431
L355:
  movsd  %xmm1,(%r12,%rdi,8)
  jmp    L591
L280:
  xor    %eax,%eax
  mov    %r11,0x18(%rsp)
  mov    0x8(%rsp),%rdi
  mov    %r8,0xb8(%rsp)
  mov    %rcx,0x10(%rsp)
  call   *0xa0(%rsp)
  mov    0xc0(%rsp),%rax
  mov    0x10(%rsp),%rcx
  movapd %xmm0,%xmm1
  mov    0x18(%rsp),%r11
  mov    0xb8(%rsp),%r8
  movslq (%rax),%rax
  lea    (%r12,%rax,8),%rdi
  mov    D9(%rip),%rax
  movsd  (%rdi),%xmm0
  movq   %rax,%xmm2
  comisd %xmm1,%xmm0
  ja     L521
L131:
  mov    0x30(%rsp),%edx
  mov    %ebx,%eax
  xor    %r9d,%r9d
  xor    %esi,%esi
  mov    %rax,0x10(%rsp)
  test   %edx,%edx
  jle    L591
  mov    %rbp,0x50(%rsp)
  mov    %r15,%r10
  mov    %r9d,%ebp
  mov    %r13,%r15
  mov    %r12,0x20(%rsp)
  mov    %rsi,%r13
  mov    %r14,%r12
  mov    %rcx,%r14
  mov    %r11,0x58(%rsp)
  jmp    L474
  nopl   0x0(%rax)
L224:
  lea    0x1(%r13),%rax
  add    %ebx,%ebp
  cmp    %r13,0x10(%rsp)
  je     L436
L380:
  mov    %rax,%r13
L474:
  mov    (%r8),%eax
  cmp    %r13d,%eax
  je     L224
  test   %ebx,%ebx
  jle    L26
  imul   %ebx,%eax
  movslq %ebp,%rdx
  lea    (%r12,%rdx,8),%rdx
  cltq
  lea    (%r12,%rax,8),%r11
  xor    %eax,%eax
  nopw   0x0(%rax,%rax,1)
L12:
  movsd  (%rdx,%rax,8),%xmm0
  addsd  (%r11,%rax,8),%xmm0
  movslq (%r15,%rax,4),%rcx
  mulsd  %xmm2,%xmm0
  movsd  %xmm0,(%r10,%rcx,8)
  mov    %rax,%rcx
  movsd  %xmm0,(%rdx,%rax,8)
  add    $0x1,%rax
  cmp    %rcx,%r14
  jne    L12
L26:
  mov    %r8,0xb8(%rsp)
  mov    %r10,%rdi
  xor    %eax,%eax
  add    %ebx,%ebp
  mov    %r10,0x18(%rsp)
  call   *0xa0(%rsp)
  mov    0x20(%rsp),%rax
  mov    0x18(%rsp),%r10
  mov    0xb8(%rsp),%r8
  movsd  %xmm0,(%rax,%r13,8)
  mov    D9(%rip),%rax
  movq   %rax,%xmm2
  lea    0x1(%r13),%rax
  cmp    %r13,0x10(%rsp)
  jne    L380
L436:
  mov    %r14,%rcx
  mov    %r15,%r13
  mov    %r12,%r14
  mov    0x50(%rsp),%rbp
  mov    0x58(%rsp),%r11
  mov    0x20(%rsp),%r12
  mov    %r10,%r15
  jmp    L591
L506:
  movsd  (%r12,%rax,1),%xmm1
  movslq (%r8),%rax
  movsd  (%r12,%rax,8),%xmm3
  jmp    L364
L440:
  mov    0xc0(%rsp),%rax
  mov    0x8(%rsp),%r9
  movslq (%rax),%rdi
  mov    %edi,%eax
  imul   %ebx,%eax
  cltq
  lea    (%r14,%rax,8),%rsi
  xor    %eax,%eax
  nopl   0x0(%rax)
L135:
  movslq 0x0(%r13,%rax,4),%rdx
  movsd  (%r9,%rdx,8),%xmm0
  mov    %rax,%rdx
  movsd  %xmm0,(%rsi,%rax,8)
  add    $0x1,%rax
  cmp    %rcx,%rdx
  jne    L135
  movsd  %xmm3,(%r12,%rdi,8)
  jmp    L591
L397:
  mov    0x30(%rsp),%eax
  test   %eax,%eax
  jle    L58
  mov    0xc0(%rsp),%rax
  mov    (%rax),%r10d
  jmp    L295
L310:
  test   %ebx,%ebx
  jle    L43
  mov    %ebx,%edx
  imul   %eax,%edx
  movslq %edx,%rdx
  lea    (%r14,%rdx,8),%r9
  xor    %edx,%edx
  nopl   (%rax)
L327:
  movslq 0x0(%r13,%rdx,4),%rsi
  movsd  (%r15,%rsi,8),%xmm0
  mov    %rdx,%rsi
  movsd  %xmm0,(%r9,%rdx,8)
  add    $0x1,%rdx
  cmp    %rsi,%rcx
  jne    L327
L43:
  movsd  %xmm1,(%rdi)
  jmp    L468
L410:
  mov    %rbp,%rdi
  call   <free@plt>
  mov    0x8(%rsp),%rdi
  call   <free@plt>
  mov    $0x1,%eax
L118:
  add    $0x68,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L480:
  mov    %rbp,%rdi
  call   <free@plt>
  mov    0x8(%rsp),%rdi
  call   <free@plt>
  add    $0x68,%rsp
  mov    $0x2,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L482:
  mov    %rbp,%rdi
  call   <free@plt>
  mov    0x8(%rsp),%rdi
  call   <free@plt>
  add    $0x68,%rsp
  mov    $0x3,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L195:
  xor    %eax,%eax
  mov    %r11,0x20(%rsp)
  mov    0x8(%rsp),%rdi
  mov    %r8,0xb8(%rsp)
  mov    %rcx,0x18(%rsp)
  movsd  %xmm1,0x10(%rsp)
  call   *0xa0(%rsp)
  mov    0xb8(%rsp),%r8
  movsd  0x10(%rsp),%xmm1
  movapd %xmm0,%xmm3
  mov    0x18(%rsp),%rcx
  mov    0x20(%rsp),%r11
  movslq (%r8),%rax
  movsd  (%r12,%rax,8),%xmm0
  mov    0xc0(%rsp),%rax
  comisd %xmm3,%xmm0
  movslq (%rax),%rdi
  jbe    L355
  movsd  %xmm3,(%r12,%rdi,8)
  jmp    L591
L375:
  lea    D16(%rip),%rdi
  call   <puts@plt>
  xor    %eax,%eax
  jmp    L118
```

tool_calls: name: retrieve_data
arguments: data_label: D13
type: qword[2]
name: retrieve_data
arguments: data_label: D9
type: f64
name: retrieve_data
arguments: data_label: D16
type: string

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

tool: D9: 0.5

tool: D16: SIMPLX: Error - not enough memory

assistant: ```c
int simplx(double *p, double *y, int ndim, double *pr, int na, double ftol, double atol, int *lista, double (*funk)(), int itmax, int *iter, int *ilo, int *ihi) {
  static double alpha = 1.0, beta = 0.5, gamma = 2.0;
  double *pbar, *prr;
  double yprr, ypr;
  int inhi, mpts;
  int i, j;
  if (!(pbar = (double *)malloc(na * sizeof(double))) || !(prr = (double *)malloc(na * sizeof(double)))) {
    printf("SIMPLX: Error - not enough memory\n");
    return (0);
  }
  mpts = ndim + 1;
  *iter = 0;
  while (1) {
    *ilo = 0;
    if (y[0] > y[1]) {
      *ihi = 0;
      inhi = 1;
    } else {
      *ihi = 1;
      inhi = 0;
    }
    for (i = 0; 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;
        }
      }
    }
    if (fabs(y[*ihi] - y[*ilo]) * (double)2.0 <= ftol * (fabs(y[*ihi]) + fabs(y[*ilo]))) {
      free(pbar);
      free(prr);
      return (1);
    }
    if (y[*ilo] < atol) {
      free(pbar);
      free(prr);
      return (2);
    }
    if (*iter == itmax) {
      free(pbar);
      free(prr);
      return (3);
    }
    ++(*iter);
    for (j = 0; j < ndim; j++) {
      *(pbar + j) = (double)0.0;
    }
    for (i = 0; i < mpts; i++) {
      if (i != *ihi) {
        for (j = 0; j < ndim; j++) {
          *(pbar + j) += p[i * ndim + j];
        }
      }
    }
    for (j = 0; j < ndim; j++) {
      pbar[j] /= (double)ndim;
      pr[lista[j]] = *(pbar + j) * ((double)1.0 + alpha) - alpha * p[*ihi * ndim + j];
    }
    for (j = 0; j < na; j++) {
      *(prr + j) = pr[j];
    }
    ypr = (*funk)(pr);
    if (ypr < y[*ilo]) {
      for (j = 0; j < ndim; j++) {
        *(prr + lista[j]) = pr[lista[j]] * gamma + *(pbar + j) * ((double)1.0 - gamma);
      }
      yprr = (*funk)(prr);
      if (yprr < y[*ilo]) {
        for (j = 0; j < ndim; j++) {
          p[*ihi * ndim + j] = *(prr + lista[j]);
        }
        y[*ihi] = yprr;
      } else {
        for (j = 0; j < ndim; j++) {
          p[*ihi * ndim + j] = pr[lista[j]];
        }
        y[*ihi] = ypr;
      }
    } else if (ypr >= y[inhi]) {
      if (ypr < y[*ihi]) {
        for (j = 0; j < ndim; j++) {
          p[*ihi * ndim + j] = pr[lista[j]];
        }
        y[*ihi] = ypr;
      }
      for (j = 0; j < ndim; j++) {
        *(prr + lista[j]) = p[*ihi * ndim + j] * beta + *(pbar + j) * ((double)1.0 - beta);
      }
      yprr = (*funk)(prr);
      if (yprr < y[*ihi]) {
        for (j = 0; j < ndim; j++) {
          p[*ihi * ndim + j] = *(prr + lista[j]);
        }
        y[*ihi] = yprr;
      } else {
        for (i = 0; i < mpts; i++) {
          if (i != *ilo) {
            for (j = 0; j < ndim; j++) {
              pr[lista[j]] = (p[i * ndim + j] + p[*ilo * ndim + j]) * (double)0.5;
              p[i * ndim + j] = pr[lista[j]];
            }
            y[i] = (*funk)(pr);
          }
        }
      }
    } else {
      for (j = 0; j < ndim; j++) {
        p[*ihi * ndim + j] = pr[lista[j]];
      }
      y[*ihi] = ypr;
    }
  }
}
```