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

```asm
<brent>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x58,%rsp
  movsd  %xmm1,0x38(%rsp)
  mov    %rdi,%r15
  movsd  %xmm3,0x40(%rsp)
  mov    %rsi,0x48(%rsp)
  movapd %xmm0,%xmm5
  minsd  %xmm2,%xmm5
  movsd  %xmm5,0x18(%rsp)
  maxsd  %xmm2,%xmm0
  movsd  %xmm0,0x20(%rsp)
  movapd %xmm1,%xmm0
  call   *%rdi
  movsd  %xmm0,0x30(%rsp)
  movsd  0x38(%rsp),%xmm5
  movsd  %xmm5,0x8(%rsp)
  movq   %xmm5,%r13
  movq   %xmm0,%rbp
  movq   %xmm0,%r14
  mov    $0x64,%r12d
  pxor   %xmm6,%xmm6
  movsd  %xmm6,0x10(%rsp)
  jmp    L284
L262:
  movsd  0x20(%rsp),%xmm7
  subsd  0x8(%rsp),%xmm7
  movsd  %xmm7,0x10(%rsp)
  jmp    L322
L273:
  divsd  %xmm1,%xmm2
  movsd  0x8(%rsp),%xmm1
  addsd  %xmm2,%xmm1
  movapd %xmm1,%xmm4
  subsd  0x18(%rsp),%xmm4
  comisd %xmm4,%xmm6
  ja     L24
  movsd  0x20(%rsp),%xmm4
  subsd  %xmm1,%xmm4
  comisd %xmm4,%xmm6
  jbe    L286
L24:
  subsd  0x8(%rsp),%xmm3
  comisd D181(%rip),%xmm3
  jb     L38
  movapd %xmm0,%xmm1
  andpd  D183(%rip),%xmm1
  movsd  0x28(%rsp),%xmm5
  movsd  %xmm5,0x10(%rsp)
  movsd  %xmm1,0x28(%rsp)
  jmp    L313
L38:
  movsd  0x28(%rsp),%xmm7
  movsd  %xmm7,0x10(%rsp)
  movapd %xmm0,%xmm7
  orpd   D61(%rip),%xmm7
  movsd  %xmm7,0x28(%rsp)
  jmp    L313
L308:
  movsd  0x8(%rsp),%xmm6
  comisd %xmm3,%xmm6
  jb     L15
  movsd  0x18(%rsp),%xmm3
  subsd  %xmm6,%xmm3
  movsd  %xmm3,0x10(%rsp)
L351:
  movsd  0x10(%rsp),%xmm7
  mulsd  D171(%rip),%xmm7
  movsd  %xmm7,0x28(%rsp)
L313:
  movsd  0x28(%rsp),%xmm6
  movapd %xmm6,%xmm1
  andpd  D183(%rip),%xmm1
  comisd %xmm0,%xmm1
  jb     L279
  addsd  0x8(%rsp),%xmm6
  movq   %xmm6,%rbx
L140:
  movq   %rbx,%xmm0
  call   *%r15
  movq   %rbp,%xmm3
  comisd %xmm0,%xmm3
  jb     L287
  movq   %rbx,%xmm6
  movsd  0x8(%rsp),%xmm7
  comisd %xmm7,%xmm6
  jae    L171
  mov    %r13,0x38(%rsp)
  movq   %xmm7,%r13
  mov    %r14,0x30(%rsp)
  mov    %rbp,%r14
  movq   %xmm0,%rbp
  movsd  %xmm7,0x20(%rsp)
  mov    %rbx,0x8(%rsp)
L312:
  sub    $0x1,%r12d
  je     L241
L284:
  movsd  D24(%rip),%xmm4
  movsd  0x18(%rsp),%xmm5
  movapd %xmm5,%xmm3
  movsd  0x20(%rsp),%xmm2
  addsd  %xmm2,%xmm3
  mulsd  %xmm4,%xmm3
  movsd  0x8(%rsp),%xmm7
  movapd %xmm7,%xmm0
  andpd  D183(%rip),%xmm0
  mulsd  0x40(%rsp),%xmm0
  addsd  D26(%rip),%xmm0
  movapd %xmm0,%xmm6
  addsd  %xmm0,%xmm6
  movapd %xmm7,%xmm1
  subsd  %xmm3,%xmm1
  andpd  D183(%rip),%xmm1
  subsd  %xmm5,%xmm2
  mulsd  %xmm4,%xmm2
  movapd %xmm6,%xmm4
  subsd  %xmm2,%xmm4
  comisd %xmm1,%xmm4
  jae    L333
  movsd  0x10(%rsp),%xmm1
  andpd  D183(%rip),%xmm1
  comisd %xmm0,%xmm1
  jbe    L308
  movq   %rbp,%xmm5
  subsd  0x30(%rsp),%xmm5
  movapd %xmm7,%xmm4
  movq   %r13,%xmm2
  subsd  %xmm2,%xmm4
  mulsd  %xmm4,%xmm5
  movq   %rbp,%xmm1
  movq   %r14,%xmm2
  subsd  %xmm2,%xmm1
  subsd  0x38(%rsp),%xmm7
  movapd %xmm7,%xmm2
  mulsd  %xmm7,%xmm1
  mulsd  %xmm1,%xmm2
  mulsd  %xmm5,%xmm4
  subsd  %xmm4,%xmm2
  subsd  %xmm5,%xmm1
  addsd  %xmm1,%xmm1
  comisd D181(%rip),%xmm1
  jbe    L111
  xorpd  D61(%rip),%xmm2
L111:
  movapd %xmm2,%xmm5
  andpd  D183(%rip),%xmm5
  movapd %xmm1,%xmm4
  mulsd  D24(%rip),%xmm4
  mulsd  0x10(%rsp),%xmm4
  andpd  D183(%rip),%xmm4
  comisd %xmm4,%xmm5
  jae    L251
  andpd  D183(%rip),%xmm1
  movsd  0x18(%rsp),%xmm4
  movsd  0x8(%rsp),%xmm7
  subsd  %xmm7,%xmm4
  mulsd  %xmm1,%xmm4
  comisd %xmm2,%xmm4
  jae    L251
  movsd  0x20(%rsp),%xmm4
  subsd  %xmm7,%xmm4
  mulsd  %xmm1,%xmm4
  comisd %xmm4,%xmm2
  jb     L273
L251:
  movsd  0x8(%rsp),%xmm7
  comisd %xmm3,%xmm7
  jb     L262
  movsd  0x18(%rsp),%xmm3
  subsd  %xmm7,%xmm3
  movsd  %xmm3,0x10(%rsp)
L322:
  movsd  0x10(%rsp),%xmm3
  mulsd  D171(%rip),%xmm3
  movsd  %xmm3,0x28(%rsp)
  jmp    L313
L15:
  movsd  0x20(%rsp),%xmm6
  subsd  0x8(%rsp),%xmm6
  movsd  %xmm6,0x10(%rsp)
  jmp    L351
L286:
  movsd  0x28(%rsp),%xmm5
  movsd  %xmm5,0x10(%rsp)
  movsd  %xmm2,0x28(%rsp)
  jmp    L313
L279:
  movapd %xmm0,%xmm1
  andpd  D183(%rip),%xmm1
  movsd  0x28(%rsp),%xmm3
  comisd D181(%rip),%xmm3
  jb     L300
L338:
  addsd  0x8(%rsp),%xmm1
  movq   %xmm1,%rbx
  jmp    L140
L300:
  orpd   D61(%rip),%xmm0
  movapd %xmm0,%xmm1
  jmp    L338
L287:
  movq   %rbx,%xmm1
  movsd  0x8(%rsp),%xmm5
  cmpltsd %xmm5,%xmm1
  movsd  0x20(%rsp),%xmm2
  andpd  %xmm1,%xmm2
  movq   %rbx,%xmm3
  andnpd %xmm3,%xmm1
  orpd   %xmm2,%xmm1
  movsd  %xmm1,0x20(%rsp)
  movq   %rbx,%xmm1
  cmpltsd %xmm5,%xmm1
  movq   %rbx,%xmm2
  andpd  %xmm1,%xmm2
  movsd  0x18(%rsp),%xmm6
  andnpd %xmm6,%xmm1
  orpd   %xmm2,%xmm1
  movsd  %xmm1,0x18(%rsp)
  movq   %r14,%xmm3
  comisd %xmm0,%xmm3
  jae    L311
  movq   %r13,%xmm6
  ucomisd %xmm5,%xmm6
  jp     L281
  jne    L281
  mov    %r13,0x38(%rsp)
  mov    %rbx,%r13
  mov    %r14,0x30(%rsp)
  movq   %xmm0,%r14
  jmp    L312
L281:
  movsd  0x30(%rsp),%xmm3
  comisd %xmm0,%xmm3
  jae    L258
  movsd  0x38(%rsp),%xmm3
  ucomisd 0x8(%rsp),%xmm3
  setnp  %al
  mov    $0x0,%edx
  cmovne %edx,%eax
  test   %al,%al
  jne    L259
  movq   %r13,%xmm6
  ucomisd %xmm6,%xmm3
  setnp  %al
  cmovne %edx,%eax
  test   %al,%al
  je     L312
L259:
  mov    %rbx,0x38(%rsp)
  movsd  %xmm0,0x30(%rsp)
  jmp    L312
L171:
  mov    %r13,0x38(%rsp)
  movsd  0x8(%rsp),%xmm6
  movq   %xmm6,%r13
  mov    %r14,0x30(%rsp)
  mov    %rbp,%r14
  movq   %xmm0,%rbp
  movsd  %xmm6,0x18(%rsp)
  mov    %rbx,0x8(%rsp)
  jmp    L312
L311:
  mov    %r13,0x38(%rsp)
  mov    %rbx,%r13
  mov    %r14,0x30(%rsp)
  movq   %xmm0,%r14
  jmp    L312
L258:
  mov    %rbx,0x38(%rsp)
  movsd  %xmm0,0x30(%rsp)
  jmp    L312
L241:
  lea    D50(%rip),%rdi
  call   <nrerror@plt>
L333:
  mov    0x48(%rsp),%rax
  movsd  0x8(%rsp),%xmm7
  movsd  %xmm7,(%rax)
  movq   %rbp,%xmm0
  add    $0x58,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
```

tool_calls: name: unpack_data
arguments: tag: D181
data_type: f64[2]
name: unpack_data
arguments: tag: D183
data_type: qword[2]
name: unpack_data
arguments: tag: D61
data_type: byte[16]
name: unpack_data
arguments: tag: D171
data_type: f64
name: unpack_data
arguments: tag: D24
data_type: f64
name: unpack_data
arguments: tag: D26
data_type: byte[8]
name: unpack_data
arguments: tag: D50
data_type: string

tool: {"D181": [0.0,-0.0]}

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

tool: {"D61": [0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00]}

tool: D171: 0.381966

tool: D24: 0.5

tool: {"D26": [0xbb,0xbd,0xd7,0xd9,0xdf,0x7c,0xdb,0x3d]}

tool: D50: Too many iterations in brent

assistant: ```c
double brent(double ax, double bx, double cx, double (*f)(double), double tol, double *xmin) {
  int iter;
  double a, b, d, etemp, fu, fv, fw, fx, p, q, r, tol1, tol2, u, v, w, x, xm;
  double e = 0.0;
  a = (ax < cx ? ax : cx);
  b = (ax > cx ? ax : cx);
  x = w = v = bx;
  fw = fv = fx = (*f)(x);
  for (iter = 1; iter <= 100; iter++) {
    xm = 0.5 * (a + b);
    tol2 = 2.0 * (tol1 = tol * fabs(x) + 1.0e-10);
    if (fabs(x - xm) <= (tol2 - 0.5 * (b - a))) {
      *xmin = x;
      return fx;
    }
    if (fabs(e) > tol1) {
      r = (x - w) * (fx - fv);
      q = (x - v) * (fx - fw);
      p = (x - v) * q - (x - w) * r;
      q = 2.0 * (q - r);
      if (q > 0.0)
        p = -p;
      q = fabs(q);
      etemp = e;
      e = d;
      if (fabs(p) >= fabs(0.5 * q * etemp) || p <= q * (a - x) || p >= q * (b - x))
        d = 0.3819660 * (e = (x >= xm ? a - x : b - x));
      else {
        d = p / q;
        u = x + d;
        if (u - a < tol2 || b - u < tol2)
          d = ((xm - x) >= 0.0 ? fabs(tol1) : -fabs(tol1));
      }
    } else {
      d = 0.3819660 * (e = (x >= xm ? a - x : b - x));
    }
    u = (fabs(d) >= tol1 ? x + d : x + ((d) >= 0.0 ? fabs(tol1) : -fabs(tol1)));
    fu = (*f)(u);
    if (fu <= fx) {
      if (u >= x)
        a = x;
      else
        b = x;
      (v) = (w);
      (w) = (x);
      (x) = (u);
      (fv) = (fw);
      (fw) = (fx);
      (fx) = (fu);
    } else {
      if (u < x)
        a = u;
      else
        b = u;
      if (fu <= fw || w == x) {
        v = w;
        w = u;
        fv = fw;
        fw = fu;
      } else if (fu <= fv || v == x || v == w) {
        v = u;
        fv = fu;
      }
    }
  }
  nrerror("Too many iterations in brent");
  *xmin = x;
  return fx;
}
```