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

```asm
<invert_poorly>:
  endbr64
  push   %r15
  xor    %edx,%edx
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  xor    %ebp,%ebp
  push   %rbx
  mov    %rdi,%rbx
  sub    $0x108,%rsp
  mov    %rdi,0x18(%rsp)
  mov    %edx,%edi
  lea    0x30(%rsp),%r12
  mov    %rsi,0x28(%rsp)
  mov    $0xc8,%esi
  mov    %fs:0x28,%rax
  mov    %rax,0xf8(%rsp)
  xor    %eax,%eax
  mov    %edx,(%rsp)
  call   <mpfr_init2@plt>
  mov    $0xc8,%esi
  mov    %ebp,%edi
  call   <mpfr_init2@plt>
  mov    (%rsp),%edi
  mov    %rbx,%rsi
  call   <determinant_poorly@plt>
  mov    %r12,0x20(%rsp)
  mov    D6(%rip),%r13
L169:
  mov    (%r12),%edi
  mov    $0xc8,%esi
  mov    %r12,%r15
  call   <mpfr_init2@plt>
  cmp    $0x6,%ebp
  sete   %bl
  xor    %r14d,%r14d
  xor    %eax,%eax
L152:
  test   %al,%al
  jne    L126
L57:
  test   %bl,%bl
  jne    L126
  add    $0x1,%r14d
  cmp    $0x7,%r14d
  je     L130
  mov    0x4(%r15),%edi
  mov    $0xc8,%esi
  call   <mpfr_init2@plt>
  cmp    $0x6,%r14d
  sete   %al
  add    $0x4,%r15
  test   %al,%al
  je     L57
L126:
  mov    0x0(%r13),%edx
  mov    (%r15),%edi
  xor    %esi,%esi
  add    $0x1,%r14d
  call   <mpfr_set_si@plt>
  cmp    $0x7,%r14d
  je     L130
  mov    0x4(%r15),%edi
  mov    $0xc8,%esi
  call   <mpfr_init2@plt>
  cmp    $0x6,%r14d
  sete   %al
  add    $0x4,%r15
  test   %al,%al
  je     L57
  test   %bl,%bl
  je     L152
  mov    0x0(%r13),%edx
  mov    0xf0(%rsp),%edi
  mov    $0x1,%esi
  call   <mpfr_set_si@plt>
L130:
  add    $0x1,%ebp
  add    $0x1c,%r12
  cmp    $0x7,%ebp
  jne    L169
  movq   $0x0,(%rsp)
L23:
  mov    (%rsp),%rax
  mov    0x28(%rsp),%rcx
  xor    %ebx,%ebx
  mov    %eax,0x14(%rsp)
  lea    (%rcx,%rax,4),%rax
  mov    %rax,0x8(%rsp)
  nopl   0x0(%rax)
L168:
  mov    0x18(%rsp),%r15
  xor    %r12d,%r12d
  nopl   0x0(%rax,%rax,1)
L15:
  cmp    (%rsp),%r12d
  je     L153
  setg   %dl
  mov    %r12d,%eax
  xor    %r14d,%r14d
  movzbl %dl,%edx
  sub    %edx,%eax
  cltq
  lea    0x0(,%rax,8),%rbp
  sub    %rax,%rbp
  nopl   0x0(%rax)
L104:
  mov    %r14d,%eax
  cmp    %ebx,%r14d
  je     L7
  xor    %edx,%edx
  cmp    %r14d,%ebx
  mov    (%r15,%r14,4),%esi
  setl   %dl
  sub    %edx,%eax
  mov    0x0(%r13),%edx
  cltq
  add    %rbp,%rax
  mov    0x30(%rsp,%rax,4),%edi
  call   <mpfr_set@plt>
L7:
  add    $0x1,%r14
  cmp    $0x7,%r14
  jne    L104
L153:
  add    $0x1,%r12d
  add    $0x1c,%r15
  cmp    $0x7,%r12d
  jne    L15
  mov    0x20(%rsp),%rsi
  xor    %ebp,%ebp
  mov    %ebp,%edi
  call   <determinant_poorly@plt>
  mov    0x8(%rsp),%rax
  mov    0x0(%r13),%ecx
  xor    %edx,%edx
  mov    %ebp,%esi
  mov    (%rax),%edi
  call   <mpfr_div@plt>
  mov    0x14(%rsp),%eax
  add    %ebx,%eax
  test   $0x1,%al
  jne    L11
L77:
  add    $0x1,%ebx
  addq   $0x1c,0x8(%rsp)
  cmp    $0x7,%ebx
  jne    L168
  addq   $0x1,(%rsp)
  mov    (%rsp),%rax
  cmp    $0x7,%rax
  jne    L23
  mov    0xf8(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L31
  add    $0x108,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L11:
  mov    0x8(%rsp),%rax
  mov    0x0(%r13),%ecx
  mov    $0xffffffff,%edx
  mov    (%rax),%edi
  mov    %edi,%esi
  call   <mpfr_mul_si@plt>
  jmp    L77
L31:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
void invert_poorly(mpfr_t A[][5 + 2], mpfr_t Ainv[][5 + 2]) {
  mpfr_t Mij[5 + 2][5 + 2];
  mpfr_t det;
  mpfr_t Mijdet;
  mpfr_init2(det, 200);
  mpfr_init2(Mijdet, 200);
  determinant_poorly(det, A);
  for (int i = 0; i < 5 + 2; ++i) {
    for (int j = 0; j < 5 + 2; ++j) {
      mpfr_init2(Mij[i][j], 200);
      if (i == (5 + 1) && j == (5 + 1)) {
        mpfr_set_si(Mij[i][j], 1, MPFR_RNDN);
      } else if (i == (5 + 1) || j == (5 + 1)) {
        mpfr_set_si(Mij[i][j], 0, MPFR_RNDN);
      }
    }
  }
  for (int i = 0; i < 5 + 2; ++i) {
    for (int j = 0; j < 5 + 2; ++j) {
      for (int ii = 0; ii < 5 + 2; ii++) {
        if (ii == i) {
          continue;
        }
        int ri = ii > i ? ii - 1 : ii;
        for (int jj = 0; jj < 5 + 2; jj++) {
          if (jj == j) {
            continue;
          }
          int rj = jj > j ? jj - 1 : jj;
          mpfr_set(Mij[ri][rj], A[ii][jj], MPFR_RNDN);
        }
      }
      determinant_poorly(Mijdet, Mij);
      mpfr_div(Ainv[j][i], Mijdet, det, MPFR_RNDN);
      if ((i + j) % 2) {
        mpfr_mul_si(Ainv[j][i], Ainv[j][i], -1, MPFR_RNDN);
      }
    }
  }
}
```