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

```asm
<gaussfit>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x518,%rsp
  mov    %rdi,%rbp
  mov    %rsi,(%rsp)
  mov    %edx,%r12d
  mov    %ecx,%r13d
  mov    %fs:0x28,%rax
  mov    %rax,0x508(%rsp)
  xor    %eax,%eax
  test   %edx,%edx
  jle    L107
  lea    0x1(%rdx),%r14d
  mov    $0x1,%ebx
  mov    D25(%rip),%r15
  jmp    L90
L123:
  call   <sqrt@plt>
  jmp    L66
L120:
  call   <sqrt@plt>
L96:
  movsd  D4(%rip),%xmm1
  divsd  %xmm0,%xmm1
L113:
  movsd  %xmm1,0x2a0(%rsp,%rbx,8)
  add    $0x1,%rbx
  cmp    %r14,%rbx
  je     L107
L90:
  pxor   %xmm0,%xmm0
  cvtsi2sd %ebx,%xmm0
  movsd  %xmm0,0x40(%rsp,%rbx,8)
  movsd  D26(%rip),%xmm0
  mulsd  0x0(%rbp,%rbx,8),%xmm0
  pxor   %xmm2,%xmm2
  ucomisd %xmm0,%xmm2
  ja     L123
  sqrtsd %xmm0,%xmm0
L66:
  movq   %r15,%xmm1
  pxor   %xmm3,%xmm3
  comisd %xmm0,%xmm3
  jae    L113
  ucomisd %xmm0,%xmm3
  ja     L120
  sqrtsd %xmm0,%xmm0
  jmp    L96
L107:
  movl   $0x0,0x34(%rsp)
  cmp    $0x1,%r13d
  jle    L2
  movl   $0x1,0x38(%rsp)
  cmp    $0x2,%r13d
  jle    L2
  movl   $0x1,0x3c(%rsp)
L2:
  movl   $0x2,0x1c(%rsp)
  lea    0x30(%rsp),%r15
  lea    0x2a0(%rsp),%rax
  mov    %rax,0x8(%rsp)
  lea    0x40(%rsp),%rax
  mov    %rax,0x10(%rsp)
  lea    0x20(%rsp),%r14
L39:
  mov    D29(%rip),%rax
  mov    %rax,0x20(%rsp)
  push   $0x1
  push   %r14
  lea    0x38(%rsp),%rax
  push   %rax
  push   %r13
  mov    %r15,%r9
  mov    0x20(%rsp),%r8
  mov    %r12d,%ecx
  mov    0x28(%rsp),%rdx
  mov    %rbp,%rsi
  mov    0x30(%rsp),%rdi
  call   <mrqmin@plt>
  add    $0x20,%rsp
  mov    $0x4,%ebx
L49:
  push   $0x0
  push   %r14
  lea    0x38(%rsp),%rax
  push   %rax
  push   %r13
  mov    %r15,%r9
  mov    0x20(%rsp),%r8
  mov    %r12d,%ecx
  mov    0x28(%rsp),%rdx
  mov    %rbp,%rsi
  mov    0x30(%rsp),%rdi
  call   <mrqmin@plt>
  add    $0x20,%rsp
  sub    $0x1,%ebx
  jne    L49
  movq   $0x0,0x20(%rsp)
  push   $0xffffffffffffffff
  push   %r14
  lea    0x38(%rsp),%rax
  push   %rax
  push   %r13
  mov    %r15,%r9
  mov    0x20(%rsp),%r8
  mov    %r12d,%ecx
  mov    0x28(%rsp),%rdx
  mov    %rbp,%rsi
  mov    0x30(%rsp),%rdi
  call   <mrqmin@plt>
  add    $0x20,%rsp
  subl   $0x1,0x1c(%rsp)
  jne    L39
  mov    0x508(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L127
  mov    $0x0,%eax
  add    $0x518,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L127:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: read_data
arguments: data_tag: D25
data_type: byte[8]
name: read_data
arguments: data_tag: D4
data_type: f64
name: read_data
arguments: data_tag: D26
data_type: f64
name: read_data
arguments: data_tag: D29
data_type: f32[2]

tool: {"D25": [0x33,0x33,0x33,0x33,0x33,0x33,0xd3,0x3f]}

tool: D4: 1

tool: D26: 0.001

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

assistant: ```c
int gaussfit(double *y, double *a, int nPts, int MA) {
  int i, iter, itst, k, mfit = MA;
  int getmem;
  double alamda, chisq, ochisq;
  double x[76], sig[76];
  int ia[4];
  for (i = 1; i <= nPts; i++) {
    x[i] = (double)(i);
    sig[i] = (sqrt(y[i] * 0.001));
    if (sig[i] <= 0.00)
      sig[i] = .3;
    else {
      sig[i] = 1.0 / sqrt((double)(sig[i]));
    }
  }
  ia[1] = 0;
  for (i = 2; i <= mfit; i++)
    ia[i] = 1;
  for (iter = 1; iter <= 2; iter++) {
    alamda = -1;
    getmem = 1;
    mrqmin(x, y, sig, nPts, a, ia, MA, &chisq, &alamda, getmem);
    k = 1;
    itst = 0;
    for (;;) {
      getmem = 0;
      k++;
      ochisq = chisq;
      mrqmin(x, y, sig, nPts, a, ia, MA, &chisq, &alamda, getmem);
      itst++;
      if (itst < 4)
        continue;
      alamda = 0.0;
      getmem = -1;
      mrqmin(x, y, sig, nPts, a, ia, MA, &chisq, &alamda, getmem);
      break;
    }
  }
  return 0;
}
```