user: Please show me the C implementation that matches the assembly code listed below:

```asm
<newton_min_func>:
  endbr64
  push   %r15
  mov    %rcx,%r15
  push   %r14
  mov    %rdi,%r14
  push   %r13
  mov    %r8,%r13
  push   %r12
  push   %rbp
  lea    0x0(,%rdx,8),%ebp
  push   %rbx
  mov    %ebp,%edi
  mov    %edx,%ebx
  sub    $0x68,%rsp
  mov    %rsi,0x20(%rsp)
  movsd  %xmm0,0x30(%rsp)
  call   <malloc@plt>
  mov    %ebp,%edi
  mov    %rax,%r12
  call   <malloc@plt>
  mov    %ebp,%edi
  mov    %rax,0x50(%rsp)
  call   <malloc@plt>
  mov    %ebp,%edi
  mov    %ebx,%ebp
  imul   %ebx,%ebp
  mov    %rax,0x58(%rsp)
  call   <malloc@plt>
  mov    %rax,0x10(%rsp)
  shl    $0x3,%ebp
  mov    %ebp,%edi
  call   <malloc@plt>
  mov    %ebp,%edi
  mov    %rax,0x8(%rsp)
  call   <malloc@plt>
  mov    0x20(%rsp),%rdi
  mov    %ebx,%esi
  mov    %rax,0x18(%rsp)
  call   *%r14
  mov    0x20(%rsp),%rsi
  mov    %r12,%rcx
  mov    %ebx,%edx
  mov    %r14,%rdi
  movsd  %xmm0,0x28(%rsp)
  call   <jacobian_fd@plt>
  movq   D35(%rip),%xmm3
  movsd  0x30(%rsp),%xmm5
  test   %ebx,%ebx
  mov    0x20(%rsp),%r9
  andpd  %xmm3,%xmm5
  jle    L41
  lea    -0x1(%rbx),%edx
  movsd  D69(%rip),%xmm4
  mov    %r15,%rax
  mov    %rdx,%rbp
  lea    0x8(%r15,%rdx,8),%rdx
  nopl   0x0(%rax)
L69:
  movapd %xmm4,%xmm0
  add    $0x8,%rax
  divsd  -0x8(%rax),%xmm0
  movsd  %xmm0,-0x8(%rax)
  cmp    %rdx,%rax
  jne    L69
  movsd  0x28(%rsp),%xmm0
  mov    0x50(%rsp),%rcx
  mov    %r12,%rdx
  xor    %eax,%eax
  andpd  %xmm3,%xmm0
  sub    %r12,%rcx
  maxsd  %xmm5,%xmm0
  movapd %xmm0,%xmm5
  xchg   %ax,%ax
L62:
  movsd  (%r15,%rax,8),%xmm0
  movapd %xmm4,%xmm1
  movsd  (%r9,%rax,8),%xmm2
  add    $0x1,%rax
  andpd  %xmm3,%xmm0
  andpd  %xmm3,%xmm2
  divsd  %xmm0,%xmm1
  maxsd  %xmm1,%xmm2
  movsd  (%rdx),%xmm1
  andpd  %xmm3,%xmm1
  movapd %xmm1,%xmm0
  mulsd  %xmm2,%xmm0
  divsd  %xmm5,%xmm0
  movsd  %xmm0,(%rcx,%rdx,1)
  add    $0x8,%rdx
  cmp    %eax,%ebx
  jg     L62
  mov    0x50(%rsp),%rdi
  mov    %ebx,%esi
  mov    %r9,0x20(%rsp)
  movsd  %xmm4,0x28(%rsp)
  call   <array_max_abs@plt>
  movsd  D74(%rip),%xmm1
  xor    %eax,%eax
  mov    0x20(%rsp),%r9
  comisd %xmm0,%xmm1
  jb     L66
  nopl   0x0(%rax)
L60:
  movsd  (%r9,%rax,8),%xmm0
  movsd  %xmm0,0x0(%r13,%rax,8)
  add    $0x1,%rax
  cmp    %eax,%ebx
  jg     L60
L28:
  mov    $0x1,%r8d
L12:
  add    $0x68,%rsp
  mov    %r8d,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopl   (%rax)
L66:
  mov    0x8(%rsp),%rcx
  mov    %r9,%rsi
  mov    %ebx,%edx
  mov    %r14,%rdi
  call   <hessian_fd@plt>
  mov    0x58(%rsp),%rsi
  mov    0x20(%rsp),%r9
  mov    %ebx,%eax
  movsd  0x28(%rsp),%xmm4
  lea    (%rsi,%rax,8),%rdx
  sub    %rsi,%r9
  mov    %rsi,%rax
  cs nopw 0x0(%rax,%rax,1)
L111:
  movsd  (%r9,%rax,1),%xmm0
  add    $0x8,%rax
  movsd  %xmm0,-0x8(%rax)
  cmp    %rax,%rdx
  jne    L111
L1:
  mov    0x58(%rsp),%rcx
  mov    %ebp,%eax
  mov    %r13,%rbp
  movsd  %xmm4,0x38(%rsp)
  lea    0x8(%rcx,%rax,8),%r10
  sub    %rcx,%rbp
  mov    %r10,0x40(%rsp)
  mov    %rbp,0x48(%rsp)
  mov    %rcx,%rbp
  nopl   0x0(%rax)
L6:
  mov    0x18(%rsp),%rcx
  mov    0x8(%rsp),%rdi
  mov    %r15,%rdx
  mov    %ebx,%esi
  call   <modelhess@plt>
  mov    %ebx,%edx
  mov    $0x1,%esi
  mov    %r12,%rdi
  mov    D79(%rip),%rax
  movq   %rax,%xmm0
  call   <scale@plt>
  mov    0x10(%rsp),%rcx
  mov    %r12,%rdx
  mov    %ebx,%esi
  mov    0x18(%rsp),%rdi
  call   <linsolve_lower@plt>
  mov    %ebx,%edx
  mov    $0x1,%esi
  mov    %r12,%rdi
  mov    D79(%rip),%rax
  movq   %rax,%xmm0
  call   <scale@plt>
  sub    $0x8,%rsp
  mov    %r15,%r9
  mov    %ebx,%r8d
  push   %r13
  mov    D40(%rip),%rax
  mov    %r12,%rdx
  mov    %rbp,%rsi
  mov    0x20(%rsp),%rcx
  movsd  0x48(%rsp),%xmm0
  mov    %r14,%rdi
  movq   %rax,%xmm1
  call   <lnsrch@plt>
  mov    %ebx,%esi
  mov    %r13,%rdi
  mov    %eax,0x38(%rsp)
  call   *%r14
  mov    %r12,%rcx
  mov    %ebx,%edx
  mov    %r13,%rsi
  mov    %r14,%rdi
  movsd  %xmm0,0x30(%rsp)
  call   <jacobian_fd@plt>
  mov    0x38(%rsp),%r9d
  mov    %r15,%r8
  mov    %r12,%rcx
  mov    D40(%rip),%rax
  mov    %r13,%rdx
  mov    %rbp,%rsi
  mov    %ebx,%edi
  movsd  0x40(%rsp),%xmm1
  movsd  0x30(%rsp),%xmm0
  movq   %rax,%xmm3
  mov    D10(%rip),%rax
  movq   %rax,%xmm2
  call   <stopcheck@plt>
  mov    0x18(%rsp),%rcx
  mov    %ebx,%edx
  mov    %r13,%rsi
  mov    %r14,%rdi
  mov    %eax,0x30(%rsp)
  call   <hessian_fd@plt>
  test   %ebx,%ebx
  pop    %rax
  pop    %rdx
  mov    %rbp,%rdx
  mov    0x20(%rsp),%r8d
  jle    L30
  mov    0x40(%rsp),%r10
  mov    0x48(%rsp),%r11
  nopl   0x0(%rax,%rax,1)
L29:
  movsd  (%r11,%rdx,1),%xmm0
  add    $0x8,%rdx
  movsd  %xmm0,-0x8(%rdx)
  cmp    %rdx,%r10
  jne    L29
L30:
  test   %r8d,%r8d
  je     L6
  mov    %r12,%rdi
  mov    %r8d,0x20(%rsp)
  call   <free@plt>
  mov    0x8(%rsp),%rdi
  call   <free@plt>
  mov    0x50(%rsp),%rdi
  call   <free@plt>
  mov    0x58(%rsp),%rdi
  call   <free@plt>
  mov    0x18(%rsp),%rdi
  call   <free@plt>
  mov    0x10(%rsp),%rdi
  call   <free@plt>
  mov    0x20(%rsp),%r8d
  jmp    L12
L41:
  mov    0x50(%rsp),%rdi
  mov    %ebx,%esi
  mov    %r9,0x20(%rsp)
  call   <array_max_abs@plt>
  movsd  D74(%rip),%xmm1
  mov    0x20(%rsp),%r9
  comisd %xmm0,%xmm1
  jae    L28
  mov    0x8(%rsp),%rcx
  mov    %ebx,%edx
  mov    %r9,%rsi
  mov    %r14,%rdi
  lea    -0x1(%rbx),%ebp
  call   <hessian_fd@plt>
  movsd  D69(%rip),%xmm4
  jmp    L1
```

tool_calls: name: unpack_data
arguments: tag: D35
type: qword
name: unpack_data
arguments: tag: D69
type: f64
name: unpack_data
arguments: tag: D74
type: byte[8]
name: unpack_data
arguments: tag: D79
type: byte[8]
name: unpack_data
arguments: tag: D40
type: byte[8]
name: unpack_data
arguments: tag: D10
type: byte[8]

tool: D35: 9223372036854775807

tool: D69: 1

tool: {"D74": [0x3e,0x8c,0x30,0xe2,0x8e,0x79,0x45,0x3e]}

tool: {"D79": [0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0xbf]}

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

tool: {"D10": [0xf4,0x68,0xe3,0x88,0xb5,0xf8,0xe4,0x3e]}

assistant: ```c
int newton_min_func(double (*funcpt)(double *, int), double *xi, int N, double *dx, double fsval, double *xf) {
  int rcode, iter;
  int i, siter, retval;
  double gtol, stol;
  double fx, num, den, stop0, maxstep, fxf;
  double *jac, *hess, *scheck, *xc, *L, *step;
  jac = (double *)malloc(sizeof(double) * N);
  scheck = (double *)malloc(sizeof(double) * N);
  xc = (double *)malloc(sizeof(double) * N);
  step = (double *)malloc(sizeof(double) * N);
  hess = (double *)malloc(sizeof(double) * N * N);
  L = (double *)malloc(sizeof(double) * N * N);
  rcode = 0;
  iter = 0;
  siter = (int)100;
  gtol = pow((double)1e-15, 1.0 / 3.0);
  stol = gtol * gtol;
  fx = funcpt(xi, N);
  jacobian_fd(funcpt, xi, N, jac);
  maxstep = 1.0;
  for (i = 0; i < N; ++i) {
    dx[i] = 1.0 / dx[i];
  }
  if (fabs(fx) > fabs(fsval)) {
    den = fabs(fx);
  } else {
    den = fabs(fsval);
  }
  for (i = 0; i < N; ++i) {
    if (fabs(xi[i]) > 1.0 / fabs(dx[i])) {
      num = fabs(xi[i]);
    } else {
      num = 1.0 / fabs(dx[i]);
    }
    scheck[i] = fabs(jac[i]) * num / den;
  }
  stop0 = array_max_abs(scheck, N);
  if (stop0 <= gtol * 1e-03) {
    rcode = 1;
    for (i = 0; i < N; ++i) {
      xf[i] = xi[i];
    }
    return rcode;
  }
  hessian_fd(funcpt, xi, N, hess);
  for (i = 0; i < N; ++i) {
    xc[i] = xi[i];
  }
  while (rcode == 0 && iter < siter) {
    modelhess(hess, N, dx, L);
    scale(jac, 1, N, -1.0);
    linsolve_lower(L, N, jac, step);
    scale(jac, 1, N, -1.0);
    retval = lnsrch(funcpt, xc, jac, step, N, maxstep, dx, stol, xf);
    fxf = funcpt(xf, N);
    jacobian_fd(funcpt, xf, N, jac);
    rcode = stopcheck(fxf, N, xc, xf, jac, dx, fsval, gtol, stol, retval);
    hessian_fd(funcpt, xf, N, hess);
    for (i = 0; i < N; ++i) {
      xc[i] = xf[i];
    }
  }
  free(jac);
  free(hess);
  free(scheck);
  free(xc);
  free(L);
  free(step);
  return rcode;
}
```