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

```asm
<lm_qrsolv>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x88,%rsp
  mov    %rsi,0x28(%rsp)
  mov    %edx,0x10(%rsp)
  mov    %rcx,0x48(%rsp)
  mov    %r8,0x50(%rsp)
  mov    0xd0(%rsp),%rbx
  test   %edi,%edi
  jle    L5
  mov    %edi,%r13d
  mov    %rsi,%r14
  movslq %edx,%rdi
  lea    0x8(,%rdi,8),%rax
  mov    %rax,0x40(%rsp)
  mov    %rsi,0x38(%rsp)
  lea    -0x1(%r13),%r12d
  mov    %r12d,0x7c(%rsp)
  mov    %r13d,%ecx
  mov    %rcx,0x68(%rsp)
  shl    $0x3,%rdi
  mov    %rsi,%r8
  mov    $0x0,%r10d
  mov    $0x0,%esi
  lea    0x8(%r14),%r11
  mov    0xc0(%rsp),%rbp
  mov    %rcx,%r15
  jmp    L207
L147:
  movslq %r10d,%rax
  add    %rsi,%rax
  lea    (%r14,%rax,8),%rdx
  mov    %r12d,%ecx
  sub    %esi,%ecx
  add    %rcx,%rax
  lea    (%r11,%rax,8),%rcx
  mov    %rdx,%rax
L170:
  movsd  (%rdx),%xmm0
  movsd  %xmm0,(%rax)
  add    %rdi,%rdx
  add    $0x8,%rax
  cmp    %rcx,%rax
  jne    L170
L142:
  movsd  (%r8),%xmm0
  movsd  %xmm0,0x0(%rbp,%rsi,8)
  movsd  (%r9,%rsi,8),%xmm0
  movsd  %xmm0,(%rbx,%rsi,8)
  add    $0x1,%rsi
  add    0x40(%rsp),%r8
  add    0x10(%rsp),%r10d
  cmp    %r15,%rsi
  je     L243
L207:
  cmp    %esi,%r13d
  jg     L147
  jmp    L142
L243:
  mov    0xc8(%rsp),%r15
  mov    0x10(%rsp),%eax
  add    $0x1,%eax
  mov    %eax,0x14(%rsp)
  movl   $0x0,0x78(%rsp)
  movl   $0x0,0x5c(%rsp)
  mov    $0x0,%r14d
  mov    %r14,%r12
  mov    %rbx,0xd0(%rsp)
  jmp    L24
L369:
  mov    %ebx,0x58(%rsp)
  movslq %r14d,%rax
  mov    0x28(%rsp),%rdi
  lea    (%rdi,%rax,8),%rax
  mov    %rax,0x30(%rsp)
  movsd  (%rax),%xmm6
  movsd  %xmm6,0x18(%rsp)
  movapd %xmm6,%xmm0
  andpd  D21(%rip),%xmm0
  movsd  0x8(%rsp),%xmm5
  movapd %xmm5,%xmm1
  andpd  D21(%rip),%xmm1
  comisd %xmm0,%xmm1
  jbe    L82
  divsd  %xmm5,%xmm6
  movsd  %xmm6,0x60(%rsp)
  movapd %xmm6,%xmm0
  mulsd  %xmm6,%xmm0
  addsd  D23(%rip),%xmm0
  pxor   %xmm1,%xmm1
  ucomisd %xmm0,%xmm1
  ja     L53
  sqrtsd %xmm0,%xmm0
L337:
  movsd  D23(%rip),%xmm5
  divsd  %xmm0,%xmm5
  movsd  0x60(%rsp),%xmm3
  mulsd  %xmm5,%xmm3
L99:
  movsd  0x18(%rsp),%xmm1
  mulsd  %xmm3,%xmm1
  movsd  0x8(%rsp),%xmm0
  mulsd  %xmm5,%xmm0
  addsd  %xmm1,%xmm0
  mov    0x30(%rsp),%rax
  movsd  %xmm0,(%rax)
  mov    0xd0(%rsp),%rax
  movsd  (%rax,%rbp,1),%xmm0
  movapd %xmm0,%xmm1
  mulsd  %xmm3,%xmm1
  movsd  0x20(%rsp),%xmm7
  movapd %xmm7,%xmm2
  mulsd  %xmm5,%xmm2
  addsd  %xmm2,%xmm1
  movapd %xmm5,%xmm6
  xorpd  D42(%rip),%xmm6
  mulsd  %xmm3,%xmm7
  mulsd  %xmm6,%xmm0
  addsd  %xmm7,%xmm0
  movsd  %xmm0,0x20(%rsp)
  movsd  %xmm1,(%rax,%rbp,1)
  cmp    %r12d,%r13d
  jle    L151
  movslq %r12d,%rax
  movslq 0x58(%rsp),%rdx
  mov    0x28(%rsp),%rsi
  lea    (%rsi,%rdx,8),%rdx
L114:
  movsd  (%rdx,%rax,8),%xmm0
  movsd  (%r15,%rax,8),%xmm1
  movapd %xmm6,%xmm2
  mulsd  %xmm0,%xmm2
  movapd %xmm1,%xmm4
  mulsd  %xmm3,%xmm4
  addsd  %xmm4,%xmm2
  movsd  %xmm2,(%r15,%rax,8)
  mulsd  %xmm3,%xmm0
  mulsd  %xmm5,%xmm1
  addsd  %xmm1,%xmm0
  movsd  %xmm0,(%rdx,%rax,8)
  add    $0x1,%rax
  cmp    %eax,%r13d
  jg     L114
L234:
  add    $0x1,%r12d
  add    0x10(%rsp),%ebx
  add    0x14(%rsp),%r14d
  add    $0x8,%rbp
L64:
  movsd  (%r15,%rbp,1),%xmm7
  movsd  %xmm7,0x8(%rsp)
  pxor   %xmm5,%xmm5
  ucomisd %xmm5,%xmm7
  jp     L369
  jne    L369
  cmp    %r12d,%r13d
  jg     L234
  mov    0x70(%rsp),%r12
L336:
  mov    0x38(%rsp),%rax
  movsd  (%rax),%xmm0
  movsd  %xmm0,(%r15,%r12,8)
  mov    0xc0(%rsp),%rsi
  movsd  (%rsi,%r12,8),%xmm0
  movsd  %xmm0,(%rax)
  add    $0x1,%r12
  mov    0x40(%rsp),%rdi
  add    %rdi,%rax
  mov    %rax,0x38(%rsp)
  mov    0x10(%rsp),%esi
  add    %esi,0x5c(%rsp)
  mov    0x14(%rsp),%edi
  add    %edi,0x78(%rsp)
  cmp    0x68(%rsp),%r12
  je     L146
L24:
  mov    %r12d,%ecx
  mov    0x48(%rsp),%rax
  movslq (%rax,%r12,4),%rax
  mov    0x50(%rsp),%rdi
  movsd  (%rdi,%rax,8),%xmm0
  pxor   %xmm5,%xmm5
  ucomisd %xmm5,%xmm0
  jp     L217
  je     L336
L217:
  cmp    %r12d,%r13d
  jle    L295
  lea    0x0(,%r12,8),%rbp
  lea    (%r15,%rbp,1),%rax
  mov    0x7c(%rsp),%edx
  sub    %ecx,%edx
  add    %r12,%rdx
  lea    0x8(%r15,%rdx,8),%rdx
L35:
  movq   $0x0,(%rax)
  add    $0x8,%rax
  cmp    %rdx,%rax
  jne    L35
  mov    0x48(%rsp),%rax
  movslq (%rax,%r12,4),%rax
  mov    0x50(%rsp),%rsi
  movsd  (%rsi,%rax,8),%xmm0
  movsd  %xmm0,(%r15,%r12,8)
  lea    0x1(%rcx),%ebx
  mov    0x78(%rsp),%eax
  mov    0x5c(%rsp),%r14d
  pxor   %xmm5,%xmm5
  movsd  %xmm5,0x20(%rsp)
  mov    %r12,0x70(%rsp)
  mov    %ebx,%r12d
  mov    %r14d,%ebx
  mov    %eax,%r14d
  jmp    L64
L53:
  call   <sqrt@plt>
  jmp    L337
L82:
  movsd  0x8(%rsp),%xmm0
  divsd  0x18(%rsp),%xmm0
  movsd  %xmm0,0x60(%rsp)
  mulsd  %xmm0,%xmm0
  addsd  D23(%rip),%xmm0
  pxor   %xmm1,%xmm1
  ucomisd %xmm0,%xmm1
  ja     L185
  sqrtsd %xmm0,%xmm0
L259:
  movsd  D23(%rip),%xmm3
  divsd  %xmm0,%xmm3
  movsd  0x60(%rsp),%xmm5
  mulsd  %xmm3,%xmm5
  jmp    L99
L185:
  call   <sqrt@plt>
  jmp    L259
L151:
  mov    0x70(%rsp),%r12
  jmp    L336
L146:
  mov    0xd0(%rsp),%rbx
  mov    %r13d,%edx
  mov    $0x0,%eax
  pxor   %xmm0,%xmm0
  mov    $0x0,%edi
  mov    0x68(%rsp),%r8
  jmp    L108
L162:
  add    $0x1,%rax
  cmp    %r8,%rax
  je     L290
L108:
  ucomisd (%r15,%rax,8),%xmm0
  setnp  %cl
  cmovne %edi,%ecx
  test   %cl,%cl
  je     L128
  cmp    %edx,%r13d
  cmove  %eax,%edx
L128:
  cmp    %r13d,%edx
  jge    L162
  movq   $0x0,(%rbx,%rax,8)
  jmp    L162
L177:
  pxor   %xmm1,%xmm1
  jmp    L258
L290:
  mov    %edx,%r8d
  sub    $0x1,%r8d
  js     L59
  movslq %r8d,%rsi
  mov    %edx,%edi
  mov    0x10(%rsp),%r9d
  imul   %r9d,%r8d
  mov    0x28(%rsp),%r10
L221:
  cmp    %edi,%edx
  jle    L177
  movslq %edi,%rax
  movslq %r8d,%rcx
  lea    (%r10,%rcx,8),%rcx
  pxor   %xmm1,%xmm1
L32:
  movsd  (%rcx,%rax,8),%xmm0
  mulsd  (%rbx,%rax,8),%xmm0
  addsd  %xmm0,%xmm1
  add    $0x1,%rax
  cmp    %eax,%edx
  jg     L32
L258:
  movsd  (%rbx,%rsi,8),%xmm0
  subsd  %xmm1,%xmm0
  divsd  (%r15,%rsi,8),%xmm0
  movsd  %xmm0,(%rbx,%rsi,8)
  sub    $0x1,%rsi
  sub    $0x1,%edi
  sub    %r9d,%r8d
  test   %esi,%esi
  jns    L221
  test   %r13d,%r13d
  jle    L5
L59:
  mov    $0x0,%eax
  mov    0x48(%rsp),%rcx
  mov    0xc0(%rsp),%rsi
L338:
  movsd  (%rbx,%rax,8),%xmm0
  movslq (%rcx,%rax,4),%rdx
  movsd  %xmm0,(%rsi,%rdx,8)
  add    $0x1,%rax
  cmp    %eax,%r13d
  jg     L338
L5:
  add    $0x88,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L295:
  movsd  %xmm0,(%r15,%r12,8)
  jmp    L336
```

tool_calls: name: extract_symbolic_data
arguments: label: D21
type: qword[2]
name: extract_symbolic_data
arguments: label: D23
type: f32[2]
name: extract_symbolic_data
arguments: label: D42
type: f32[4]

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

tool: {"D23": [0.0,1.875]}

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

assistant: ```c
void lm_qrsolv(int n, double *r, int ldr, int *ipvt, double *diag, double *qtb, double *x, double *sdiag, double *wa) {
  int i, kk, j, k, nsing;
  double qtbpj, sum, temp;
  double _sin, _cos, _tan, _cot;
  for (j = 0; j < n; j++) {
    for (i = j; i < n; i++)
      r[j * ldr + i] = r[i * ldr + j];
    x[j] = r[j * ldr + j];
    wa[j] = qtb[j];
  }
  for (j = 0; j < n; j++) {
    if (diag[ipvt[j]] == 0.)
      goto L90;
    for (k = j; k < n; k++)
      sdiag[k] = 0.;
    sdiag[j] = diag[ipvt[j]];
    qtbpj = 0.;
    for (k = j; k < n; k++) {
      if (sdiag[k] == 0.)
        continue;
      kk = k + ldr * k;
      if (fabs(r[kk]) < fabs(sdiag[k])) {
        _cot = r[kk] / sdiag[k];
        _sin = 1 / sqrt(1 + (_cot) * (_cot));
        _cos = _sin * _cot;
      } else {
        _tan = sdiag[k] / r[kk];
        _cos = 1 / sqrt(1 + (_tan) * (_tan));
        _sin = _cos * _tan;
      }
      r[kk] = _cos * r[kk] + _sin * sdiag[k];
      temp = _cos * wa[k] + _sin * qtbpj;
      qtbpj = -_sin * wa[k] + _cos * qtbpj;
      wa[k] = temp;
      for (i = k + 1; i < n; i++) {
        temp = _cos * r[k * ldr + i] + _sin * sdiag[i];
        sdiag[i] = -_sin * r[k * ldr + i] + _cos * sdiag[i];
        r[k * ldr + i] = temp;
      }
    }
  L90:
    sdiag[j] = r[j * ldr + j];
    r[j * ldr + j] = x[j];
  }
  nsing = n;
  for (j = 0; j < n; j++) {
    if (sdiag[j] == 0. && nsing == n)
      nsing = j;
    if (nsing < n)
      wa[j] = 0;
  }
  for (j = nsing - 1; j >= 0; j--) {
    sum = 0;
    for (i = j + 1; i < nsing; i++)
      sum += r[j * ldr + i] * wa[i];
    wa[j] = (wa[j] - sum) / sdiag[j];
  }
  for (j = 0; j < n; j++)
    x[ipvt[j]] = wa[j];
}
```