user: 请从给定的汇编指令推导出C源代码:

```asm
<obj_func_ar_ls>:
  endbr64
  push   %r15
  mov    %rdx,%r15
  push   %r14
  push   %r13
  push   %r12
  mov    %ecx,%r12d
  push   %rbp
  mov    %r9d,%ebp
  push   %rbx
  mov    %r8d,%ebx
  sub    $0x58,%rsp
  movslq 0xa0(%rsp),%rax
  mov    %rdi,0x38(%rsp)
  mov    0x98(%rsp),%r14
  test   %eax,%eax
  jle    L28
  lea    0x0(,%rax,8),%rdx
  xor    %esi,%esi
  mov    %r14,%rdi
  call   <memset@plt>
L28:
  mov    %r12d,%eax
  lea    0x0(,%rbp,8),%edi
  movslq %ebp,%r12
  cltd
  idiv   %ebp
  mov    %eax,0x34(%rsp)
  call   <malloc@plt>
  cmpl   $0x1,0x90(%rsp)
  mov    %rax,%r9
  je     L120
  cmp    %ebx,0x34(%rsp)
  jle    L42
  mov    %ebp,%r8d
  mov    %ebp,%r13d
  mov    %r15,0x40(%rsp)
  shl    $0x3,%r12
  imul   %ebx,%r8d
  neg    %r13d
  pxor   %xmm3,%xmm3
  sub    %r9,%r14
  movslq %r13d,%r13
  shl    $0x3,%r13
  movslq %r8d,%r10
  shl    $0x3,%r10
  sub    %rax,%r10
  lea    -0x1(%rbx),%eax
  imul   %ebp,%eax
  add    %r15,%r10
  mov    %eax,0x8(%rsp)
  mov    %r15,%rax
  mov    %r10,%r15
  mov    %ebx,%r10d
  sub    %r9,%rax
  mov    %rax,0x48(%rsp)
  nopl   0x0(%rax)
L56:
  mov    0x40(%rsp),%rsi
  mov    0x38(%rsp),%rdi
  mov    %ebp,%ecx
  mov    %ebx,%edx
  mov    %r10d,0x28(%rsp)
  mov    %r9,0x18(%rsp)
  mov    %r8d,0x10(%rsp)
  movsd  %xmm3,0x20(%rsp)
  call   <ar_unbias@plt>
  test   %ebp,%ebp
  mov    0x10(%rsp),%r8d
  mov    0x18(%rsp),%r9
  movsd  0x20(%rsp),%xmm3
  mov    0x28(%rsp),%r10d
  jle    L12
  mov    0x48(%rsp),%rdi
  movslq 0x8(%rsp),%rax
  mov    %r9,%rsi
  lea    (%rdi,%rax,8),%r11
  xor    %edi,%edi
  nopl   0x0(%rax)
L65:
  movsd  (%r15,%rsi,1),%xmm2
  subsd  (%rsi),%xmm2
  movapd %xmm2,%xmm0
  mulsd  %xmm2,%xmm0
  addsd  %xmm0,%xmm3
  test   %ebx,%ebx
  jle    L55
  addsd  %xmm2,%xmm2
  lea    (%r14,%rsi,1),%rax
  xor    %edx,%edx
  lea    (%r11,%rsi,1),%rcx
L118:
  movsd  (%rcx),%xmm1
  movsd  (%rax),%xmm0
  add    $0x1,%edx
  add    %r13,%rcx
  mulsd  %xmm2,%xmm1
  subsd  %xmm1,%xmm0
  movsd  %xmm0,(%rax)
  add    %r12,%rax
  cmp    %edx,%ebx
  jne    L118
L55:
  add    $0x1,%edi
  add    $0x8,%rsi
  cmp    %edi,%ebp
  jne    L65
L12:
  add    %ebp,0x8(%rsp)
  add    $0x1,%r10d
  add    %ebp,%r8d
  add    %r12,%r15
  cmp    %r10d,0x34(%rsp)
  jne    L56
L57:
  mov    %r9,%rdi
  movsd  %xmm3,0x8(%rsp)
  call   <free@plt>
  movsd  0x8(%rsp),%xmm3
  add    $0x58,%rsp
  pop    %rbx
  pop    %rbp
  movapd %xmm3,%xmm0
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L120:
  lea    -0x1(%rbx),%eax
  mov    %eax,0x20(%rsp)
  cmp    %eax,0x34(%rsp)
  jle    L42
  mov    %eax,%r13d
  mov    %eax,0x8(%rsp)
  lea    -0x1(%rbp),%eax
  pxor   %xmm3,%xmm3
  imul   %ebp,%r13d
  lea    0x0(,%r12,8),%rdi
  mov    %eax,0x40(%rsp)
  mov    %rdi,0x28(%rsp)
  mov    %r9,0x10(%rsp)
  movslq %r13d,%r12
  shl    $0x3,%r12
  sub    %r9,%r12
  add    %r15,%r12
L29:
  mov    0x10(%rsp),%r9
  mov    0x20(%rsp),%edx
  mov    %r13d,%r8d
  mov    %ebp,%ecx
  mov    0x38(%rsp),%rdi
  mov    %r15,%rsi
  movsd  %xmm3,0x18(%rsp)
  call   <ar_bias@plt>
  test   %ebp,%ebp
  movsd  0x18(%rsp),%xmm3
  jle    L181
  mov    0x40(%rsp),%r11d
  mov    0x10(%rsp),%r9
  mov    %r13d,%r10d
  xor    %r8d,%r8d
  nopl   0x0(%rax)
L64:
  movsd  (%r12,%r9,1),%xmm1
  subsd  (%r9),%xmm1
  movapd %xmm1,%xmm0
  mulsd  %xmm1,%xmm0
  addsd  %xmm0,%xmm3
  test   %ebx,%ebx
  jle    L74
  addsd  %xmm1,%xmm1
  mov    %r8d,%ecx
  mov    %r10d,%edx
  xor    %eax,%eax
  nop
L71:
  test   %eax,%eax
  jne    L18
  movsd  (%r14,%r8,8),%xmm0
  add    %ebp,%ecx
  sub    %ebp,%edx
  subsd  %xmm1,%xmm0
  movsd  %xmm0,(%r14,%r8,8)
  cmp    $0x1,%ebx
  je     L74
  mov    $0x1,%eax
L18:
  movslq %edx,%rdi
  movslq %ecx,%rsi
  add    $0x1,%eax
  add    %ebp,%ecx
  movsd  (%r15,%rdi,8),%xmm2
  lea    (%r14,%rsi,8),%rsi
  sub    %ebp,%edx
  movsd  (%rsi),%xmm0
  mulsd  %xmm1,%xmm2
  subsd  %xmm2,%xmm0
  movsd  %xmm0,(%rsi)
  cmp    %eax,%ebx
  jne    L71
L74:
  lea    0x1(%r8),%rax
  add    $0x8,%r9
  add    $0x1,%r10d
  cmp    %r8,%r11
  je     L181
  mov    %rax,%r8
  jmp    L64
L181:
  addl   $0x1,0x8(%rsp)
  add    %ebp,%r13d
  mov    0x8(%rsp),%eax
  add    0x28(%rsp),%r12
  cmp    %eax,0x34(%rsp)
  jg     L29
  mov    0x10(%rsp),%r9
  jmp    L57
L42:
  pxor   %xmm3,%xmm3
  jmp    L57
```

assistant: ```c
double obj_func_ar_ls(double *p, int np, double *cans, int nc, int n_coef, int dim2, int intercept, double *grad, int ng) {
  int i, j, k, order, n_cans;
  double error, r;
  double *ar;
  for (j = 0; j < ng; j++)
    grad[j] = 0.0;
  n_cans = (int)(nc / dim2);
  ar = (double *)malloc(dim2 * sizeof(double));
  order = n_coef;
  if (intercept == 1)
    order = n_coef - 1;
  error = 0.0;
  if (intercept == 1) {
    for (i = order; i < n_cans; i++) {
      ar_bias(p, cans, order, dim2, i * dim2, ar);
      for (j = 0; j < dim2; j++) {
        r = cans[i * dim2 + j] - ar[j];
        error += r * r;
        for (k = 0; k < n_coef; k++) {
          if (k == 0) {
            grad[k * dim2 + j] -= 2.0 * r;
          } else {
            grad[k * dim2 + j] -= 2.0 * r * cans[(i - k) * dim2 + j];
          }
        }
      }
    }
  } else {
    for (i = order; i < n_cans; i++) {
      ar_unbias(p, cans, order, dim2, i * dim2, ar);
      for (j = 0; j < dim2; j++) {
        r = cans[i * dim2 + j] - ar[j];
        error += r * r;
        for (k = 0; k < n_coef; k++) {
          grad[k * dim2 + j] -= 2.0 * r * cans[(i - k - 1) * dim2 + j];
        }
      }
    }
  }
  free(ar);
  return error;
}
```