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

```asm
<simq>:
  endbr64
  push   %r15
  lea    -0x1(%rcx),%eax
  mov    %rdi,%r10
  mov    %rdx,%r11
  push   %r14
  mov    %ecx,%edi
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x28,%rsp
  mov    %rsi,0x18(%rsp)
  mov    %eax,0x14(%rsp)
  test   %r8d,%r8d
  js     L245
  test   %ecx,%ecx
  jle    L64
  mov    0x14(%rsp),%ebx
  movq   D21(%rip),%xmm3
  mov    %ecx,%ebp
  xor    %esi,%esi
  movsd  D28(%rip),%xmm4
  xor    %ecx,%ecx
  lea    0x8(%r10),%r8
  pxor   %xmm2,%xmm2
  nopl   0x0(%rax)
L244:
  movslq %esi,%rdx
  mov    %ecx,(%r9,%rcx,4)
  movapd %xmm2,%xmm1
  lea    (%r10,%rdx,8),%rax
  add    %rbx,%rdx
  lea    (%r8,%rdx,8),%rdx
  cs nopw 0x0(%rax,%rax,1)
L63:
  movsd  (%rax),%xmm0
  comisd %xmm0,%xmm2
  jbe    L201
  xorpd  %xmm3,%xmm0
L201:
  maxsd  %xmm1,%xmm0
  add    $0x8,%rax
  movapd %xmm0,%xmm1
  cmp    %rax,%rdx
  jne    L63
  add    %edi,%esi
  ucomisd %xmm2,%xmm0
  jp     L195
  je     L125
L195:
  movapd %xmm4,%xmm0
  divsd  %xmm1,%xmm0
  movsd  %xmm0,(%r11,%rcx,8)
  add    $0x1,%rcx
  cmp    %rcx,%rbp
  jne    L244
L64:
  mov    0x14(%rsp),%eax
  pxor   %xmm2,%xmm2
  test   %eax,%eax
  jle    L253
  movq   D21(%rip),%xmm6
  lea    -0x2(%rdi),%eax
  xor    %ebx,%ebx
  xor    %r15d,%r15d
  mov    %eax,0x10(%rsp)
  mov    $0x1,%r13d
  pxor   %xmm4,%xmm4
  lea    0x10(%r10),%r14
  movapd %xmm6,%xmm3
  cmp    %ebx,%edi
  je     L72
  nopw   0x0(%rax,%rax,1)
L141:
  mov    %r15,%rdx
  movapd %xmm4,%xmm2
  movapd %xmm4,%xmm1
  xor    %esi,%esi
  nopl   (%rax)
L255:
  movslq (%r9,%rdx,4),%r8
  mov    %edi,%eax
  movslq %edx,%rcx
  imul   %r8d,%eax
  add    %ebx,%eax
  cltq
  movsd  (%r10,%rax,8),%xmm0
  comisd %xmm0,%xmm4
  jbe    L44
  xorpd  %xmm6,%xmm0
L44:
  mulsd  (%r11,%r8,8),%xmm0
  comisd %xmm1,%xmm0
  maxsd  %xmm1,%xmm0
  cmovbe %rsi,%rcx
  add    $0x1,%rdx
  movapd %xmm0,%xmm1
  movslq %ecx,%rsi
  cmp    %edx,%edi
  jg     L255
  ucomisd %xmm4,%xmm0
  jp     L246
  je     L72
L246:
  cmp    %ebx,%ecx
  je     L184
  lea    (%r9,%rcx,4),%rax
  mov    (%r9,%r15,4),%edx
  mov    (%rax),%ecx
  mov    %ecx,(%r9,%r15,4)
  mov    %edx,(%rax)
L184:
  mov    (%r9,%r15,4),%r12d
  imul   %edi,%r12d
  lea    (%r12,%rbx,1),%eax
  cltq
  movsd  (%r10,%rax,8),%xmm5
  lea    0x1(%rbx),%eax
  mov    %eax,0xc(%rsp)
  cmp    %eax,%edi
  jle    L76
  mov    0x10(%rsp),%ebp
  mov    %r13,%r8
  movslq %r12d,%r12
  add    %r15,%rbp
  nopw   0x0(%rax,%rax,1)
L175:
  mov    (%r9,%r8,4),%esi
  imul   %edi,%esi
  lea    (%rsi,%rbx,1),%eax
  movslq %esi,%rsi
  cltq
  lea    0x0(%rbp,%rsi,1),%rdx
  lea    (%r10,%rax,8),%rax
  lea    (%r14,%rdx,8),%rcx
  mov    %r12,%rdx
  movsd  (%rax),%xmm1
  sub    %rsi,%rdx
  xorpd  %xmm3,%xmm1
  divsd  %xmm5,%xmm1
  movapd %xmm1,%xmm0
  xorpd  %xmm3,%xmm0
  movsd  %xmm0,(%rax)
  lea    0x0(%r13,%rsi,1),%rax
  lea    (%r10,%rax,8),%rax
  nopl   0x0(%rax,%rax,1)
L149:
  movsd  (%rax,%rdx,8),%xmm0
  add    $0x8,%rax
  mulsd  %xmm1,%xmm0
  addsd  -0x8(%rax),%xmm0
  movsd  %xmm0,-0x8(%rax)
  cmp    %rax,%rcx
  jne    L149
  add    $0x1,%r8
  cmp    %r8d,%edi
  jg     L175
L76:
  subl   $0x1,0x10(%rsp)
  mov    0xc(%rsp),%ebx
  add    $0x1,%r15
  add    $0x1,%r13
  cmp    %ebx,0x14(%rsp)
  je     L253
  mov    0xc(%rsp),%ebx
  cmp    %ebx,%edi
  jne    L141
L72:
  lea    D58(%rip),%rdi
  call   <puts@plt>
  add    $0x28,%rsp
  mov    $0x2,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L125:
  lea    D38(%rip),%rdi
  call   <puts@plt>
  mov    $0x1,%eax
L152:
  add    $0x28,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L245:
  movslq %ecx,%rbp
  mov    -0x4(%r9,%rbp,4),%eax
  imul   %ecx,%eax
  lea    -0x1(%rcx,%rax,1),%eax
  cltq
  lea    (%r10,%rax,8),%r12
L196:
  movslq (%r9),%rax
  mov    0x18(%rsp),%r13
  movsd  0x0(%r13,%rax,8),%xmm0
  movsd  %xmm0,(%r11)
  cmp    $0x1,%edi
  jle    L5
  lea    -0x2(%rdi),%ebx
  lea    0x4(%r9),%r8
  pxor   %xmm2,%xmm2
  xor    %edx,%edx
  shl    $0x3,%rbx
  nopw   0x0(%rax,%rax,1)
L110:
  movslq (%r8),%rsi
  mov    %edi,%eax
  movapd %xmm2,%xmm1
  imul   %esi,%eax
  cltq
  lea    (%r10,%rax,8),%rcx
  xor    %eax,%eax
  jmp    L66
  cs nopw 0x0(%rax,%rax,1)
L33:
  movsd  0x8(%r11,%rax,1),%xmm0
  add    $0x8,%rax
L66:
  mulsd  (%rcx,%rax,1),%xmm0
  addsd  %xmm0,%xmm1
  cmp    %rax,%rdx
  jne    L33
  movsd  0x0(%r13,%rsi,8),%xmm0
  add    $0x4,%r8
  subsd  %xmm1,%xmm0
  movsd  %xmm0,0x8(%r11,%rdx,1)
  cmp    %rdx,%rbx
  je     L224
  movsd  (%r11),%xmm0
  add    $0x8,%rdx
  jmp    L110
L224:
  lea    -0x8(%r11,%rbp,8),%rax
  movsd  (%rax),%xmm0
  divsd  (%r12),%xmm0
  movsd  %xmm0,(%rax)
  movslq 0x14(%rsp),%rax
  mov    %rax,%rsi
  sub    $0x1,%rax
  lea    (%r9,%rax,4),%r9
  lea    (%r11,%rax,8),%r8
  cs nopw 0x0(%rax,%rax,1)
L96:
  mov    (%r9),%ecx
  movslq %esi,%rax
  sub    $0x1,%esi
  imul   %edi,%ecx
  cmp    %eax,%edi
  jle    L134
  movslq %ecx,%rdx
  movapd %xmm2,%xmm1
  lea    (%r10,%rdx,8),%rdx
  nopl   0x0(%rax,%rax,1)
L262:
  movsd  (%rdx,%rax,8),%xmm0
  mulsd  (%r11,%rax,8),%xmm0
  add    $0x1,%rax
  addsd  %xmm0,%xmm1
  cmp    %eax,%edi
  jg     L262
L283:
  movsd  (%r8),%xmm0
  lea    (%rcx,%rsi,1),%eax
  sub    $0x4,%r9
  sub    $0x8,%r8
  cltq
  subsd  %xmm1,%xmm0
  divsd  (%r10,%rax,8),%xmm0
  movsd  %xmm0,0x8(%r8)
  test   %esi,%esi
  jne    L96
  xor    %eax,%eax
L214:
  add    $0x28,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L134:
  movapd %xmm2,%xmm1
  jmp    L283
L253:
  movslq %edi,%rbp
  mov    -0x4(%r9,%rbp,4),%eax
  imul   %edi,%eax
  lea    -0x1(%rdi,%rax,1),%eax
  cltq
  lea    (%r10,%rax,8),%r12
  ucomisd (%r12),%xmm2
  jp     L196
  jne    L196
  lea    D25(%rip),%rdi
  call   <puts@plt>
  mov    $0x3,%eax
  jmp    L152
L5:
  lea    -0x8(%r11,%rbp,8),%rax
  movsd  (%rax),%xmm0
  divsd  (%r12),%xmm0
  movsd  %xmm0,(%rax)
  xor    %eax,%eax
  jmp    L214
```

tool_calls: name: retrieve_data
arguments: data_label: D21
type_guessed: f32[2]
name: retrieve_data
arguments: data_label: D28
type_guessed: f64
name: retrieve_data
arguments: data_label: D58
type_guessed: string
name: retrieve_data
arguments: data_label: D38
type_guessed: string
name: retrieve_data
arguments: data_label: D25
type_guessed: string

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

tool: D28: 1

tool: D58: SIMQ BIG=0

tool: D38: SIMQ ROWNRM=0

tool: D25: SIMQ A[kpn]=0

assistant: ```c
int simq(A, B, X, n, flag, IPS)
double A[], B[], X[];
int n, flag;
int IPS[];
{
  int i, j, ij, ip, ipj, ipk, ipn;
  int idxpiv, iback;
  int k, kp, kp1, kpk, kpn;
  int nip, nkp, nm1;
  double em, q, rownrm, big, size, pivot, sum;
  nm1 = n - 1;
  if (flag < 0)
    goto solve;
  ij = 0;
  for (i = 0; i < n; i++) {
    IPS[i] = i;
    rownrm = 0.0;
    for (j = 0; j < n; j++) {
      q = ((A[ij]) < 0 ? -(A[ij]) : (A[ij]));
      if (rownrm < q)
        rownrm = q;
      ++ij;
    }
    if (rownrm == 0.0) {
      puts("SIMQ ROWNRM=0");
      return (1);
    }
    X[i] = 1.0 / rownrm;
  }
  for (k = 0; k < nm1; k++) {
    big = 0.0;
    idxpiv = 0;
    for (i = k; i < n; i++) {
      ip = IPS[i];
      ipk = n * ip + k;
      size = ((A[ipk]) < 0 ? -(A[ipk]) : (A[ipk])) * X[ip];
      if (size > big) {
        big = size;
        idxpiv = i;
      }
    }
    if (big == 0.0) {
      puts("SIMQ BIG=0");
      return (2);
    }
    if (idxpiv != k) {
      j = IPS[k];
      IPS[k] = IPS[idxpiv];
      IPS[idxpiv] = j;
    }
    kp = IPS[k];
    kpk = n * kp + k;
    pivot = A[kpk];
    kp1 = k + 1;
    for (i = kp1; i < n; i++) {
      ip = IPS[i];
      ipk = n * ip + k;
      em = -A[ipk] / pivot;
      A[ipk] = -em;
      nip = n * ip;
      nkp = n * kp;
      for (j = kp1; j < n; j++) {
        ipj = nip + j;
        A[ipj] = A[ipj] + em * A[nkp + j];
      }
    }
  }
  kpn = n * IPS[n - 1] + n - 1;
  if (A[kpn] == 0.0) {
    puts("SIMQ A[kpn]=0");
    return (3);
  }
solve:
  ip = IPS[0];
  X[0] = B[ip];
  for (i = 1; i < n; i++) {
    ip = IPS[i];
    ipj = n * ip;
    sum = 0.0;
    for (j = 0; j < i; j++) {
      sum += A[ipj] * X[j];
      ++ipj;
    }
    X[i] = B[ip] - sum;
  }
  ipn = n * IPS[n - 1] + n - 1;
  X[n - 1] = X[n - 1] / A[ipn];
  for (iback = 1; iback < n; iback++) {
    i = nm1 - iback;
    ip = IPS[i];
    nip = n * ip;
    sum = 0.0;
    for (j = i + 1; j < n; j++)
      sum += A[nip + j] * X[j];
    X[i] = (X[i] - sum) / A[nip + i];
  }
  return (0);
}
```