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

```asm
<matinv>:
  endbr64
  push   %r15
  movslq %edi,%r15
  push   %r14
  mov    %r15,%rdi
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  mov    %rsi,%rbx
  mov    $0x4,%esi
  sub    $0xd8,%rsp
  mov    %rdx,0xb0(%rsp)
  call   <calloc@plt>
  mov    %rax,0x90(%rsp)
  test   %rax,%rax
  je     L12
  mov    $0x4,%esi
  mov    %r15,%rdi
  call   <calloc@plt>
  mov    %rax,0x60(%rsp)
  test   %rax,%rax
  je     L285
  mov    $0x8,%esi
  mov    %r15,%rdi
  call   <calloc@plt>
  mov    %rax,0x48(%rsp)
  test   %rax,%rax
  je     L208
  mov    %r15d,%edi
  mov    $0x8,%esi
  mov    %r15,%r12
  imul   %r15d,%edi
  movslq %edi,%rdi
  call   <calloc@plt>
  mov    %rax,%r14
  test   %rax,%rax
  je     L420
  test   %r15d,%r15d
  jle    L327
  lea    -0x1(%r15),%eax
  mov    %r15d,%r8d
  mov    0x48(%rsp),%rdi
  xor    %ecx,%ecx
  mov    %eax,0x40(%rsp)
  xor    %esi,%esi
  pxor   %xmm4,%xmm4
  movq   D2(%rip),%xmm3
  mov    %rax,0x78(%rsp)
  mov    0x90(%rsp),%r9
  mov    %r8,0x68(%rsp)
  nopl   (%rax)
L344:
  movslq %esi,%rdx
  mov    %ecx,(%r9,%rcx,4)
  movapd %xmm4,%xmm2
  movq   $0x0,(%rdi,%rcx,8)
  lea    0x0(,%rdx,8),%rax
  add    %r8,%rdx
  shl    $0x3,%rdx
  nopw   0x0(%rax,%rax,1)
L76:
  movsd  (%rbx,%rax,1),%xmm1
  movapd %xmm1,%xmm0
  andpd  %xmm3,%xmm0
  comisd %xmm2,%xmm0
  jbe    L281
  movsd  %xmm1,(%r14,%rax,1)
  add    $0x8,%rax
  movapd %xmm0,%xmm2
  movsd  %xmm0,(%rdi,%rcx,8)
  cmp    %rdx,%rax
  jne    L76
L486:
  add    %r12d,%esi
  ucomisd %xmm4,%xmm2
  jp     L353
  je     L36
L353:
  add    $0x1,%rcx
  cmp    %r8,%rcx
  jne    L344
  lea    0x1(%r12),%eax
  lea    0x8(%r14),%rdi
  xor    %ecx,%ecx
  xor    %ebp,%ebp
  mov    %eax,0xb8(%rsp)
  lea    -0x3(%r12),%eax
  lea    0x0(,%r15,8),%r13
  mov    %eax,0x58(%rsp)
  lea    -0x2(%r12),%eax
  mov    %eax,0x30(%rsp)
  lea    0x8(,%r15,8),%rax
  mov    %rax,0x98(%rsp)
  lea    0x10(%r14),%rax
  mov    %rax,0x38(%rsp)
  mov    %rax,%rbx
  mov    %r12d,%eax
  shr    %eax
  movl   $0x2,(%rsp)
  sub    $0x1,%eax
  movl   $0x1,0x50(%rsp)
  add    $0x1,%rax
  mov    %rdi,0xc8(%rsp)
  movq   $0x0,0x70(%rsp)
  shl    $0x4,%rax
  mov    %rax,0xc0(%rsp)
  mov    %r12d,%eax
  and    $0xfffffffe,%eax
  mov    %eax,0xbc(%rsp)
  mov    %r13,%rax
  sub    %r14,%rax
  mov    %rax,0xa0(%rsp)
  mov    $0x8,%eax
  sub    %r14,%rax
  mov    %rax,0xa8(%rsp)
  mov    %ecx,%eax
  cs nopw 0x0(%rax,%rax,1)
L278:
  mov    0x48(%rsp),%r9
  movsd  -0x10(%rbx),%xmm1
  lea    0x1(%rbp),%edi
  mov    %ebp,%r8d
  mov    %ebp,0x34(%rsp)
  mov    %edi,%esi
  movsd  (%r9,%rbp,8),%xmm2
  andpd  %xmm3,%xmm1
  mov    %edi,0x8(%rsp)
  divsd  %xmm2,%xmm1
  cmp    %edi,%r12d
  jle    L391
  lea    (%rax,%r12,1),%edx
  lea    0x1(%rbp),%rcx
  movslq %edx,%rdx
  add    %rbp,%rdx
  lea    (%r14,%rdx,8),%rdi
  nop
L251:
  movsd  (%rdi),%xmm0
  mov    %r8d,%edx
  andpd  %xmm3,%xmm0
  divsd  (%r9,%rcx,8),%xmm0
  comisd %xmm1,%xmm0
  maxsd  %xmm1,%xmm0
  cmova  %ecx,%edx
  add    $0x1,%rcx
  movapd %xmm0,%xmm1
  add    %r13,%rdi
  mov    %edx,%r8d
  cmp    %ecx,%r12d
  jg     L251
  cmp    %ebp,%edx
  jg     L5
L391:
  cmp    0x78(%rsp),%rbp
  je     L65
L464:
  movslq 0x50(%rsp),%rcx
  movslq (%rsp),%r8
  lea    (%rax,%r12,1),%edi
  mov    0xa0(%rsp),%rdx
  mov    %edi,0x20(%rsp)
  mov    %r15,%rdi
  lea    (%r14,%rcx,8),%r11
  mov    0x30(%rsp),%ecx
  add    %r15,0x70(%rsp)
  neg    %rdi
  mov    %r11,0x10(%rsp)
  add    %rbx,%rdx
  mov    %rcx,%r11
  lea    0x0(,%rcx,8),%r10
  shr    %ecx
  and    $0xfffffffe,%r11d
  mov    %r10,0x18(%rsp)
  lea    -0x1(%rcx),%r9d
  mov    0x20(%rsp),%ecx
  mov    %r11d,%r10d
  mov    %r11d,0x44(%rsp)
  add    $0x1,%r9
  add    %r8d,%r10d
  sub    %rbp,%r8
  shl    $0x4,%r9
  add    %r10d,%eax
  lea    -0x10(%r14,%r8,8),%r8
  cltq
  mov    %r8,0x80(%rsp)
  lea    (%r14,%rax,8),%r11
  mov    0x58(%rsp),%eax
  lea    0x8(%r14,%rax,8),%rax
  mov    %rax,0x88(%rsp)
  mov    0xa8(%rsp),%rax
  add    %rbx,%rax
  mov    %rax,0x28(%rsp)
  mov    %r12d,%eax
  sub    0x34(%rsp),%eax
  mov    %eax,0x34(%rsp)
  jmp    L423
  xchg   %ax,%ax
L438:
  add    $0x1,%esi
  add    %r12d,%ecx
  sub    %r15,%rdi
  add    %r13,%rdx
  cmp    %esi,%r12d
  je     L352
L423:
  movsd  -0x10(%r14,%rdx,1),%xmm0
  ucomisd %xmm4,%xmm0
  jp     L398
  je     L438
L398:
  mov    0x8(%rsp),%eax
  mov    0x10(%rsp),%r8
  divsd  -0x10(%rbx),%xmm0
  movsd  %xmm0,-0x10(%r14,%rdx,1)
  mulsd  (%r8),%xmm0
  add    %ecx,%eax
  cltq
  lea    (%r14,%rax,8),%rax
  movsd  (%rax),%xmm1
  subsd  %xmm0,%xmm1
  movsd  %xmm1,(%rax)
  cmp    %r12d,(%rsp)
  jge    L438
  mov    0x18(%rsp),%rax
  lea    -0x10(%rdx),%r8
  add    %rdx,%rax
  cmp    %rax,%r8
  lea    -0x8(%rdx),%rax
  setge  %r8b
  cmp    %rax,%rdx
  setge  %al
  or     %r8b,%al
  je     L52
  cmp    %rdx,0x28(%rsp)
  setne  %r8b
  cmpl   $0x3,0x34(%rsp)
  setne  %al
  test   %al,%r8b
  je     L52
  movsd  -0x10(%r14,%rdx,1),%xmm2
  lea    (%r14,%rdx,1),%r8
  xor    %eax,%eax
  unpcklpd %xmm2,%xmm2
  nopl   0x0(%rax)
L179:
  movupd (%rbx,%rax,1),%xmm1
  movupd (%r8,%rax,1),%xmm0
  mulpd  %xmm2,%xmm1
  subpd  %xmm1,%xmm0
  movups %xmm0,(%r8,%rax,1)
  add    $0x10,%rax
  cmp    %r9,%rax
  jne    L179
  mov    0x30(%rsp),%r8d
  cmp    %r8d,0x44(%rsp)
  je     L438
  movsd  (%r11),%xmm1
  lea    (%rcx,%r10,1),%eax
  mulsd  -0x10(%r14,%rdx,1),%xmm1
  cltq
  lea    (%r14,%rax,8),%rax
  movsd  (%rax),%xmm0
  subsd  %xmm1,%xmm0
  movsd  %xmm0,(%rax)
  jmp    L438
  nopl   0x0(%rax,%rax,1)
L281:
  movsd  %xmm1,(%r14,%rax,1)
  add    $0x8,%rax
  cmp    %rdx,%rax
  jne    L76
  jmp    L486
  nopl   0x0(%rax,%rax,1)
L320:
  mov    0x58(%rsp),%rbx
  mov    0x44(%rsp),%r11d
  mov    %r12d,%edi
  mov    0x70(%rsp),%r8
  mov    0x78(%rsp),%r10d
  mov    0x50(%rsp),%r9
  nopl   0x0(%rax)
L489:
  cmp    0x30(%rsp),%edi
  jge    L502
  mov    0x34(%rsp),%eax
  mov    0x28(%rsp),%rsi
  movslq %r11d,%rdx
  add    %r15,%rdx
  add    %r10d,%eax
  lea    (%r14,%rdx,8),%rdx
  cltq
  lea    (%r14,%rax,8),%rcx
  movslq %edi,%rax
  add    %r8,%rax
  movsd  (%rcx),%xmm1
  lea    (%rsi,%rax,8),%rax
  mov    0x40(%rsp),%esi
  mov    %rax,(%rsp)
  mov    0x38(%rsp),%rax
  sub    %edi,%esi
  add    %rbx,%rsi
  lea    (%rax,%rsi,8),%rsi
  mov    (%rsp),%rax
  nopw   0x0(%rax,%rax,1)
L48:
  movsd  (%rax),%xmm0
  mulsd  (%rdx),%xmm0
  add    $0x8,%rax
  add    %r13,%rdx
  subsd  %xmm0,%xmm1
  movsd  %xmm1,(%rcx)
  cmp    %rsi,%rax
  jne    L48
L502:
  movsd  0x0(%rbp,%r8,8),%xmm0
  add    0x10(%rsp),%r10d
  divsd  (%r9),%xmm0
  sub    %r12d,%r11d
  movsd  %xmm0,0x0(%rbp,%r8,8)
  add    0x8(%rsp),%r9
  add    0x18(%rsp),%r8
  add    0x20(%rsp),%rbx
  sub    $0x1,%edi
  jne    L489
  add    $0x1,%r15
  add    $0x8,%rbp
  cmp    0x68(%rsp),%r15
  jne    L232
  mov    0x28(%rsp),%r14
L327:
  mov    0x90(%rsp),%rdi
  call   <free@plt>
  mov    0x60(%rsp),%rdi
  call   <free@plt>
  mov    0x48(%rsp),%rdi
  call   <free@plt>
  mov    %r14,%rdi
  call   <free@plt>
  xor    %eax,%eax
L187:
  add    $0xd8,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopl   0x0(%rax)
L352:
  mov    0xb8(%rsp),%edi
  addl   $0x1,(%rsp)
  add    $0x1,%rbp
  add    %edi,0x50(%rsp)
  mov    0x20(%rsp),%eax
  subl   $0x1,0x58(%rsp)
  add    0x98(%rsp),%rbx
  subl   $0x1,0x30(%rsp)
  jmp    L278
L52:
  mov    0x80(%rsp),%rax
  mov    0x88(%rsp),%r8
  add    %rdx,%rax
  add    %rdx,%r8
  nopl   0x0(%rax)
L262:
  movsd  (%rax,%rdi,8),%xmm1
  mulsd  -0x10(%r14,%rdx,1),%xmm1
  add    $0x8,%rax
  movsd  -0x8(%rax),%xmm0
  subsd  %xmm1,%xmm0
  movsd  %xmm0,-0x8(%rax)
  cmp    %r8,%rax
  jne    L262
  jmp    L438
L5:
  mov    %edx,%r11d
  mov    0x70(%rsp),%rdi
  imul   %r12d,%r11d
  lea    0x10(,%rdi,8),%r8
  shl    $0x3,%rdi
  movslq %r11d,%r9
  lea    0x0(,%r9,8),%rcx
  lea    0x10(%rcx),%r10
  cmp    %rdi,%r10
  setle  %r10b
  cmp    %r8,%rcx
  setge  %r8b
  add    %r14,%rcx
  or     %r10b,%r8b
  je     L375
  cmpl   $0x1,0x40(%rsp)
  jbe    L375
  mov    0xc0(%rsp),%r9
  add    %r14,%rdi
  xor    %r8d,%r8d
  nopw   0x0(%rax,%rax,1)
L474:
  movupd (%rcx,%r8,1),%xmm0
  movupd (%rdi,%r8,1),%xmm5
  movups %xmm5,(%rcx,%r8,1)
  movups %xmm0,(%rdi,%r8,1)
  add    $0x10,%r8
  cmp    %r9,%r8
  jne    L474
  mov    0xbc(%rsp),%r10d
  lea    (%rax,%r10,1),%edi
  lea    (%r10,%r11,1),%ecx
  cmp    %r12d,%r10d
  je     L356
  movslq %ecx,%rcx
  movslq %edi,%rdi
  lea    (%r14,%rcx,8),%rcx
  lea    (%r14,%rdi,8),%rdi
  movsd  (%rcx),%xmm0
  movsd  (%rdi),%xmm1
  movsd  %xmm1,(%rcx)
  movsd  %xmm0,(%rdi)
L356:
  mov    0x48(%rsp),%rdi
  movslq %edx,%rdx
  mov    0x90(%rsp),%r11
  lea    (%rdi,%rdx,8),%rcx
  lea    (%r11,%rdx,4),%rdx
  movsd  (%rcx),%xmm0
  movsd  %xmm2,(%rcx)
  mov    (%rdx),%ecx
  movsd  %xmm0,(%rdi,%rbp,8)
  mov    (%r11,%rbp,4),%edi
  mov    %edi,(%rdx)
  mov    %ecx,(%r11,%rbp,4)
  cmp    0x78(%rsp),%rbp
  jne    L464
L65:
  mov    0x90(%rsp),%rcx
  mov    0x60(%rsp),%rsi
  xor    %eax,%eax
  mov    0x68(%rsp),%rdi
  nopw   0x0(%rax,%rax,1)
L245:
  movslq (%rcx,%rax,4),%rdx
  mov    %eax,(%rsi,%rdx,4)
  add    $0x1,%rax
  cmp    %rdi,%rax
  jne    L245
  xor    %ebp,%ebp
  mov    0x68(%rsp),%rax
  mov    %r13,(%rsp)
  xor    %r15d,%r15d
  mov    %ebp,%r13d
  mov    0xb0(%rsp),%rbp
  lea    0x0(,%rax,8),%rbx
  nopl   0x0(%rax)
L268:
  movslq %r13d,%rax
  mov    %rbx,%rdx
  xor    %esi,%esi
  add    %r12d,%r13d
  lea    0x0(%rbp,%rax,8),%rdi
  call   <memset@plt>
  mov    %r15d,%eax
  add    $0x1,%r15d
  cmp    %r15d,%r12d
  jne    L268
  mov    %eax,%ebx
  mov    %eax,0x80(%rsp)
  mov    %r12d,%eax
  mov    0xb0(%rsp),%rcx
  not    %eax
  mov    (%rsp),%r13
  mov    %r14,0x28(%rsp)
  cltq
  movsd  D3(%rip),%xmm2
  mov    %r15d,0x30(%rsp)
  mov    %rcx,%rbp
  shl    $0x3,%rax
  mov    %rax,0x8(%rsp)
  mov    0x40(%rsp),%eax
  imul   %r12d,%eax
  movslq %eax,%rdi
  mov    %eax,0x78(%rsp)
  movslq %ebx,%rax
  not    %ebx
  add    %rdi,%rax
  mov    %ebx,0x10(%rsp)
  mov    %rax,0x58(%rsp)
  lea    (%r14,%rax,8),%rax
  mov    %rcx,%r14
  mov    %rax,0x50(%rsp)
  mov    %r12d,%eax
  imul   %r12d,%eax
  mov    %rdi,0x70(%rsp)
  xor    %edi,%edi
  mov    %rdi,%r15
  mov    %eax,0x44(%rsp)
  movslq %ebx,%rax
  mov    %rax,0x18(%rsp)
  sub    $0x1,%rax
  mov    %rax,0x20(%rsp)
  nopl   (%rax)
L232:
  mov    0x60(%rsp),%rax
  mov    0x30(%rsp),%ebx
  mov    %r15d,0x34(%rsp)
  mov    0x80(%rsp),%r10d
  movslq (%rax,%r15,4),%r8
  mov    %ebx,%eax
  imul   %r8d,%eax
  lea    0x1(%r8),%esi
  lea    (%rax,%r15,1),%edx
  movslq %edx,%rdx
  movsd  %xmm2,(%r14,%rdx,8)
  cmp    %r10d,%r8d
  jge    L320
  imul   %esi,%ebx
  cltq
  add    %r15,%rax
  lea    (%r14,%rax,8),%r9
  movslq %ebx,%rdx
  mov    0x28(%rsp),%rbx
  lea    (%rdx,%r15,1),%rcx
  lea    (%r14,%rcx,8),%rcx
  lea    (%rbx,%rdx,8),%rdi
  nopw   0x0(%rax,%rax,1)
L39:
  movsd  (%rcx),%xmm1
  mov    %r8,%rax
  mov    %r9,%rdx
  nopw   0x0(%rax,%rax,1)
L490:
  movsd  (%rdx),%xmm0
  mulsd  (%rdi,%rax,8),%xmm0
  add    $0x1,%rax
  add    %r13,%rdx
  subsd  %xmm0,%xmm1
  movsd  %xmm1,(%rcx)
  cmp    %eax,%esi
  jg     L490
  lea    0x1(%rsi),%eax
  add    %r13,%rcx
  add    %r13,%rdi
  cmp    %esi,%r10d
  jle    L320
  mov    %eax,%esi
  jmp    L39
L36:
  mov    0x90(%rsp),%rdi
  call   <free@plt>
  mov    0x60(%rsp),%rdi
  call   <free@plt>
  mov    0x48(%rsp),%rdi
  call   <free@plt>
  mov    %r14,%rdi
  call   <free@plt>
  mov    $0x3,%eax
  jmp    L187
L375:
  mov    0x78(%rsp),%rdi
  mov    0xc8(%rsp),%r11
  add    %r9,%rdi
  lea    (%r11,%rdi,8),%r8
  mov    0x70(%rsp),%rdi
  sub    %r9,%rdi
L392:
  movsd  (%rcx),%xmm0
  movsd  (%rcx,%rdi,8),%xmm1
  movsd  %xmm1,(%rcx)
  movsd  %xmm0,(%rcx,%rdi,8)
  add    $0x8,%rcx
  cmp    %r8,%rcx
  jne    L392
  jmp    L356
L420:
  mov    0x90(%rsp),%rdi
  call   <free@plt>
  mov    0x60(%rsp),%rdi
  call   <free@plt>
  mov    0x48(%rsp),%rdi
  call   <free@plt>
  mov    $0x2,%eax
  jmp    L187
L208:
  mov    0x90(%rsp),%rdi
  call   <free@plt>
  mov    0x60(%rsp),%rdi
  call   <free@plt>
  mov    $0x2,%eax
  jmp    L187
L285:
  mov    0x90(%rsp),%rdi
  call   <free@plt>
  mov    $0x2,%eax
  jmp    L187
L12:
  mov    $0x2,%eax
  jmp    L187
```

tool_calls: name: unpack_data
arguments: data_tag: D2
type_infered: qword
name: unpack_data
arguments: data_tag: D3
type_infered: f64

tool: D2: 9223372036854775807

tool: D3: 1

assistant: ```c
int matinv(n, mat, inv)
int n;
const double mat[];
double inv[];
{
  register int i, ij, ik, j, k, kj, pj;
  int itemp, *mxl, *lxm, pivot;
  double colmax, *lu, *rowmax, dtemp;
  if (!(mxl = calloc(n, sizeof(int))))
    return 2;
  if (!(lxm = calloc(n, sizeof(int)))) {
    free(mxl);
    return 2;
  }
  if (!(rowmax = calloc(n, sizeof(double)))) {
    free(mxl);
    free(lxm);
    return 2;
  }
  if (!(lu = calloc(n * n, sizeof(double)))) {
    free(mxl);
    free(lxm);
    free(rowmax);
    return 2;
  }
  for (i = 0, ij = 0; i < n; i++) {
    mxl[i] = i;
    rowmax[i] = 0.0;
    for (j = 0; j < n; j++, ij++) {
      dtemp = fabs(mat[ij]);
      if (dtemp > rowmax[i])
        rowmax[i] = dtemp;
      lu[ij] = mat[ij];
    }
    if (rowmax[i] == 0.0) {
      free(mxl);
      free(lxm);
      free(rowmax);
      free(lu);
      return 3;
    }
  }
  for (k = 0; k < n; k++) {
    colmax = fabs(lu[k * n + k]) / rowmax[k];
    pivot = k;
    for (i = k + 1; i < n; i++) {
      ik = i * n + k;
      dtemp = fabs(lu[ik]) / rowmax[i];
      if (dtemp > colmax) {
        colmax = dtemp;
        pivot = i;
      }
    }
    if (pivot > k) {
      for (j = 0, pj = pivot * n, kj = k * n; j < n; j++, pj++, kj++) {
        dtemp = lu[pj];
        lu[pj] = lu[kj];
        lu[kj] = dtemp;
      }
      dtemp = rowmax[pivot];
      rowmax[pivot] = rowmax[k];
      rowmax[k] = dtemp;
      itemp = mxl[pivot];
      mxl[pivot] = mxl[k];
      mxl[k] = itemp;
    }
    for (i = k + 1; i < n; i++) {
      ik = i * n + k;
      if (lu[ik] != 0.0) {
        lu[ik] /= lu[k * n + k];
        for (j = k + 1; j < n; j++) {
          lu[i * n + j] -= lu[ik] * lu[k * n + j];
        }
      }
    }
  }
  for (i = 0; i < n; i++) {
    lxm[mxl[i]] = i;
  }
  for (i = 0, ij = 0; i < n; i++) {
    for (j = 0; j < n; j++, ij++) {
      inv[ij] = 0.0;
    }
  }
  for (k = 0; k < n; k++) {
    inv[lxm[k] * n + k] = 1.0;
    for (i = lxm[k] + 1; i < n; i++) {
      for (j = lxm[k]; j < i; j++) {
        inv[i * n + k] -= lu[i * n + j] * inv[j * n + k];
      }
    }
    for (i = n - 1; i >= 0; i--) {
      for (j = i + 1; j < n; j++) {
        inv[i * n + k] -= lu[i * n + j] * inv[j * n + k];
      }
      inv[i * n + k] /= lu[i * n + i];
    }
  }
  free(mxl);
  free(lxm);
  free(rowmax);
  free(lu);
  return 0;
}
```