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

```asm
<jerasure_invert_bitmatrix>:
  endbr64
  test   %edx,%edx
  jle    L515
  mov    %edx,%eax
  push   %r15
  mov    %edx,%r9d
  lea    -0x1(%rdx),%r10d
  push   %r14
  shr    $0x2,%eax
  mov    %rdi,%r14
  and    $0xfffffffc,%r9d
  push   %r13
  sub    $0x1,%eax
  mov    %edx,%r15d
  xor    %r8d,%r8d
  push   %r12
  add    $0x1,%rax
  mov    %rsi,%r12
  xor    %esi,%esi
  push   %rbp
  mov    %rax,%rdi
  push   %rbx
  shl    $0x4,%rdi
  sub    $0x50,%rsp
  movdqa D27(%rip),%xmm4
  movdqa D18(%rip),%xmm3
  mov    %r10d,0x8(%rsp)
  mov    %r9d,0xc(%rsp)
  cmp    $0x2,%r10d
  jbe    L588
  nopw   0x0(%rax,%rax,1)
L443:
  movslq %esi,%rdx
  movd   %r8d,%xmm2
  movdqa D28(%rip),%xmm1
  lea    (%r12,%rdx,4),%rdx
  pshufd $0x0,%xmm2,%xmm2
  lea    (%rdi,%rdx,1),%rcx
  nopl   (%rax)
L316:
  movdqa %xmm1,%xmm0
  add    $0x10,%rdx
  paddd  %xmm4,%xmm1
  pcmpeqd %xmm2,%xmm0
  pand   %xmm3,%xmm0
  movups %xmm0,-0x10(%rdx)
  cmp    %rcx,%rdx
  jne    L316
  lea    (%rsi,%r9,1),%ecx
  mov    %r9d,%edx
  cmp    %r9d,%r15d
  je     L102
L359:
  xor    %ebx,%ebx
  cmp    %edx,%r8d
  movslq %ecx,%rcx
  sete   %bl
  lea    0x0(,%rcx,4),%r11
  mov    %ebx,(%r12,%rcx,4)
  lea    0x1(%rdx),%ecx
  cmp    %ecx,%r15d
  jle    L102
  cmp    %r8d,%ecx
  sete   %cl
  add    $0x2,%edx
  movzbl %cl,%ecx
  mov    %ecx,0x4(%r12,%r11,1)
  cmp    %r15d,%edx
  jge    L102
  cmp    %r8d,%edx
  sete   %dl
  movzbl %dl,%edx
  mov    %edx,0x8(%r12,%r11,1)
L102:
  lea    0x1(%r8),%edx
  add    %r15d,%esi
  cmp    %edx,%r15d
  je     L553
  mov    %edx,%r8d
  cmp    $0x2,%r10d
  ja     L443
L588:
  mov    %esi,%ecx
  xor    %edx,%edx
  jmp    L359
L553:
  movslq %r15d,%rbp
  shl    $0x4,%rax
  mov    %edx,-0x34(%rsp)
  mov    %r15d,%ebx
  lea    0x4(,%rbp,4),%rsi
  mov    %rax,(%rsp)
  mov    %r12,%r13
  mov    %rsi,0x30(%rsp)
  lea    0x0(,%rbp,4),%rsi
  mov    %rsi,0x20(%rsp)
  lea    0x10(%r12),%rsi
  mov    %rsi,-0x30(%rsp)
  mov    %rsi,-0x40(%rsp)
  mov    0x8(%rsp),%esi
  mov    %r8d,-0x70(%rsp)
  lea    -0xc(%r14,%rsi,4),%rax
  mov    %rsi,0x18(%rsp)
  mov    %rax,0x40(%rsp)
  lea    0x10(%r14),%rax
  mov    %rax,-0x18(%rsp)
  lea    0x4(%r14),%rax
  mov    %r14,-0x78(%rsp)
  mov    %r14,-0x10(%rsp)
  movq   $0x10,0x10(%rsp)
  movq   $0x0,-0x58(%rsp)
  movl   $0x0,-0x50(%rsp)
  movq   $0x0,-0x60(%rsp)
  mov    %rax,0x38(%rsp)
  mov    %rbp,%rax
  mov    %r15d,%ebp
  mov    %rbx,0x28(%rsp)
  mov    %rax,%r15
  mov    %r14,%rbx
  nopl   0x0(%rax)
L76:
  mov    -0x50(%rsp),%eax
  mov    -0x60(%rsp),%esi
  mov    %eax,-0x38(%rsp)
  mov    -0x10(%rsp),%rax
  add    $0x1,%esi
  mov    (%rax),%eax
  test   %eax,%eax
  je     L127
L90:
  mov    -0x60(%rsp),%rdi
  cmp    %rdi,0x18(%rsp)
  je     L441
  cs nopw 0x0(%rax,%rax,1)
L204:
  mov    -0x58(%rsp),%rax
  mov    %r15,%r8
  add    %ebp,-0x50(%rsp)
  neg    %r8
  mov    -0x50(%rsp),%edi
  lea    (%rax,%r15,1),%rcx
  not    %rax
  shl    $0x2,%rax
  mov    %rcx,-0x8(%rsp)
  mov    %rax,-0x28(%rsp)
  lea    0x4(%rbx),%rax
  mov    %rax,-0x20(%rsp)
  jmp    L114
  nopl   0x0(%rax,%rax,1)
L518:
  lea    0x1(%rsi),%eax
  add    %ebp,%edi
  sub    %r15,%r8
  add    %r15,%rcx
  cmp    -0x70(%rsp),%esi
  je     L66
  mov    %eax,%esi
L114:
  mov    -0x78(%rsp),%rax
  mov    (%rax,%rcx,4),%r9d
  test   %r9d,%r9d
  je     L518
  mov    -0x28(%rsp),%r11
  lea    0x0(,%rcx,4),%r9
  mov    -0x18(%rsp),%rax
  lea    (%r12,%r9,1),%rdx
  lea    (%r11,%r9,1),%r10
  add    %r9,%rax
  cmp    $0x8,%r10
  mov    %rax,-0x68(%rsp)
  lea    (%r14,%r9,1),%rax
  seta   %r11b
  cmpl   $0x1,-0x34(%rsp)
  setne  %r10b
  and    %r10d,%r11d
  cmp    -0x68(%rsp),%r13
  setae  %r10b
  cmp    -0x40(%rsp),%rax
  setae  -0x48(%rsp)
  add    -0x30(%rsp),%r9
  or     -0x48(%rsp),%r10b
  and    %r11d,%r10d
  cmp    %r9,%rax
  setae  %r9b
  cmp    %rdx,-0x68(%rsp)
  setbe  %r11b
  or     %r11d,%r9d
  test   %r9b,%r10b
  je     L302
  mov    %rdx,%r9
  sub    -0x20(%rsp),%r9
  cmp    $0x8,%r9
  jbe    L302
  cmpl   $0x2,0x8(%rsp)
  jbe    L29
  mov    (%rsp),%r10
  xor    %r9d,%r9d
  nopw   0x0(%rax,%rax,1)
L69:
  movdqu (%rax,%r9,1),%xmm0
  movdqu (%rbx,%r9,1),%xmm5
  pxor   %xmm5,%xmm0
  movups %xmm0,(%rax,%r9,1)
  movdqu (%rdx,%r9,1),%xmm0
  movdqu 0x0(%r13,%r9,1),%xmm6
  pxor   %xmm6,%xmm0
  movups %xmm0,(%rdx,%r9,1)
  add    $0x10,%r9
  cmp    %r9,%r10
  jne    L69
  mov    0xc(%rsp),%eax
  mov    %eax,%edx
  cmp    %eax,%ebp
  je     L518
L312:
  mov    %ebp,%r10d
  sub    %edx,%r10d
  cmp    $0x1,%r10d
  je     L88
  lea    (%rdx,%rcx,1),%r9
  add    -0x58(%rsp),%rdx
  shl    $0x2,%r9
  movq   (%r14,%rdx,4),%xmm0
  lea    (%r14,%r9,1),%r11
  add    %r12,%r9
  movq   (%r11),%xmm1
  pxor   %xmm1,%xmm0
  movq   %xmm0,(%r11)
  movq   (%r12,%rdx,4),%xmm0
  movq   (%r9),%xmm1
  mov    %r10d,%edx
  and    $0xfffffffe,%edx
  pxor   %xmm1,%xmm0
  add    %edx,%eax
  movq   %xmm0,(%r9)
  cmp    %edx,%r10d
  je     L518
L88:
  lea    (%rdi,%rax,1),%edx
  add    -0x38(%rsp),%eax
  movslq %edx,%rdx
  cltq
  shl    $0x2,%rdx
  mov    (%r14,%rax,4),%r9d
  xor    %r9d,(%r14,%rdx,1)
  mov    (%r12,%rax,4),%eax
  xor    %eax,(%r12,%rdx,1)
  jmp    L518
L66:
  mov    0x20(%rsp),%rax
  addq   $0x1,-0x60(%rsp)
  mov    0x30(%rsp),%rdi
  addq   $0x4,-0x78(%rsp)
  add    %rdi,-0x10(%rsp)
  mov    -0x60(%rsp),%rsi
  add    %rax,%rbx
  add    %rax,%r13
  add    %rax,-0x40(%rsp)
  add    %rax,0x10(%rsp)
  cmp    %rsi,0x28(%rsp)
  je     L441
  mov    -0x8(%rsp),%rax
  mov    %rax,-0x58(%rsp)
  jmp    L76
  nopw   0x0(%rax,%rax,1)
L302:
  mov    0x18(%rsp),%r11
  lea    (%r11,%rcx,1),%r9
  mov    0x38(%rsp),%r11
  lea    (%r11,%r9,4),%r9
  nopw   0x0(%rax,%rax,1)
L259:
  mov    (%rax,%r8,4),%r10d
  xor    %r10d,(%rax)
  add    $0x4,%rax
  mov    (%rdx,%r8,4),%r10d
  xor    %r10d,(%rdx)
  add    $0x4,%rdx
  cmp    %r9,%rax
  jne    L259
  jmp    L518
  nopl   0x0(%rax,%rax,1)
L127:
  cmp    %esi,-0x34(%rsp)
  jle    L556
  mov    -0x50(%rsp),%edi
  mov    -0x70(%rsp),%r8d
  mov    0x20(%rsp),%r9
  lea    (%rdi,%rbp,1),%edx
  movslq %edx,%rdx
  add    -0x60(%rsp),%rdx
  lea    (%r14,%rdx,4),%rcx
  mov    %esi,%edx
  jmp    L466
  nopl   0x0(%rax,%rax,1)
L6:
  lea    0x1(%rdx),%edi
  add    %r9,%rcx
  cmp    %r8d,%edx
  je     L273
  mov    %edi,%edx
L466:
  mov    (%rcx),%r10d
  test   %r10d,%r10d
  je     L6
L20:
  mov    -0x34(%rsp),%edi
  cmp    %edx,%edi
  je     L273
  imul   %edi,%edx
  mov    0x10(%rsp),%rcx
  lea    (%r14,%rcx,1),%r10
  mov    %edx,%r11d
  movslq %edx,%rdx
  cmp    %r10,%r13
  mov    %r10,-0x20(%rsp)
  lea    0x0(,%rdx,4),%rdi
  mov    %rdx,-0x28(%rsp)
  lea    0x10(%rdi),%r9
  lea    (%r12,%rdi,1),%rdx
  lea    (%r14,%r9,1),%r8
  lea    (%r12,%r9,1),%rcx
  mov    %r8,-0x48(%rsp)
  setae  %r8b
  cmp    -0x40(%rsp),%rbx
  setae  %r10b
  mov    %rcx,-0x68(%rsp)
  lea    (%r14,%rdi,1),%rcx
  or     %r8d,%r10d
  cmpl   $0x1,-0x34(%rsp)
  setne  %r8b
  and    %r10d,%r8d
  mov    -0x58(%rsp),%r10
  shl    $0x2,%r10
  cmp    %r10,%r9
  setle  %r9b
  cmp    0x10(%rsp),%rdi
  setge  %dil
  or     %edi,%r9d
  and    %r9d,%r8d
  cmp    -0x20(%rsp),%rdx
  setae  %dil
  cmp    -0x68(%rsp),%rbx
  setae  %r9b
  or     %r9d,%edi
  and    %r8d,%edi
  cmp    -0x48(%rsp),%r13
  setae  %r8b
  cmp    -0x40(%rsp),%rcx
  setae  %r9b
  or     %r9d,%r8d
  test   %r8b,%dil
  je     L388
  cmp    -0x48(%rsp),%rdx
  setae  %r8b
  cmp    %rcx,-0x68(%rsp)
  setbe  %dil
  or     %r8b,%dil
  je     L388
  cmpl   $0x2,0x8(%rsp)
  jbe    L438
  mov    (%rsp),%rdi
  xor    %eax,%eax
  nopw   0x0(%rax,%rax,1)
L67:
  movdqu (%rbx,%rax,1),%xmm0
  movdqu (%rcx,%rax,1),%xmm4
  movups %xmm4,(%rbx,%rax,1)
  movups %xmm0,(%rcx,%rax,1)
  movdqu 0x0(%r13,%rax,1),%xmm0
  movdqu (%rdx,%rax,1),%xmm2
  movups %xmm2,0x0(%r13,%rax,1)
  movups %xmm0,(%rdx,%rax,1)
  add    $0x10,%rax
  cmp    %rdi,%rax
  jne    L67
  mov    0xc(%rsp),%eax
  mov    %eax,%edx
  cmp    %eax,%ebp
  je     L90
L324:
  mov    %ebp,%r9d
  sub    %edx,%r9d
  cmp    $0x1,%r9d
  je     L356
  mov    -0x58(%rsp),%rdi
  lea    (%rdi,%rdx,1),%rcx
  add    -0x28(%rsp),%rdx
  shl    $0x2,%rcx
  shl    $0x2,%rdx
  lea    (%r14,%rcx,1),%r8
  lea    (%r14,%rdx,1),%rdi
  add    %r12,%rcx
  add    %r12,%rdx
  mov    (%r8),%r10
  movq   (%rdi),%xmm0
  movq   %xmm0,(%r8)
  mov    %r10,(%rdi)
  mov    (%rdx),%r8
  mov    (%rcx),%rdi
  mov    %r8,(%rcx)
  mov    %rdi,(%rdx)
  mov    %r9d,%edx
  and    $0xfffffffe,%edx
  add    %edx,%eax
  cmp    %edx,%r9d
  je     L90
L356:
  mov    -0x50(%rsp),%edi
  lea    (%rdi,%rax,1),%edx
  add    %r11d,%eax
  movslq %edx,%rdx
  cltq
  shl    $0x2,%rdx
  shl    $0x2,%rax
  lea    (%r14,%rdx,1),%rcx
  lea    (%r14,%rax,1),%r8
  add    %r12,%rdx
  add    %r12,%rax
  mov    (%rcx),%edi
  mov    (%r8),%r9d
  mov    %r9d,(%rcx)
  mov    %edi,(%r8)
  mov    (%rax),%edi
  mov    (%rdx),%ecx
  mov    %edi,(%rdx)
  mov    -0x60(%rsp),%rdi
  mov    %ecx,(%rax)
  cmp    %rdi,0x18(%rsp)
  jne    L204
L441:
  mov    %r15,%rax
  mov    %ebp,%r15d
  mov    %rax,%rbp
  movslq -0x70(%rsp),%rax
  mov    %eax,-0x78(%rsp)
  mov    %rax,%rbx
  lea    (%r14,%rax,4),%rax
  mov    %rax,-0x70(%rsp)
  mov    %r15d,%eax
  imul   %r15d,%ebx
  shr    $0x2,%eax
  sub    $0x1,%eax
  add    $0x1,%rax
  mov    %ebx,-0x38(%rsp)
  shl    $0x4,%rax
  mov    %rax,-0x28(%rsp)
  mov    %r15d,%eax
  and    $0xfffffffc,%eax
  mov    %eax,-0x34(%rsp)
  lea    0x10(%r14),%rax
  mov    %rax,-0x40(%rsp)
  lea    0x4(%r14),%rax
  mov    %rax,-0x10(%rsp)
  mov    %r15d,%eax
  and    $0x3,%eax
  mov    %eax,-0x18(%rsp)
  mov    -0x78(%rsp),%eax
  test   %eax,%eax
  jle    L606
L354:
  movslq -0x38(%rsp),%r8
  xor    %ecx,%ecx
  xor    %edi,%edi
  xor    %esi,%esi
  lea    0x1(%r8),%rax
  mov    %r8,-0x60(%rsp)
  lea    0x0(,%rax,4),%rdx
  neg    %rax
  shl    $0x2,%rax
  lea    0xc(%r12,%rdx,1),%rbx
  lea    -0x4(%rdx),%r10
  mov    %rax,-0x50(%rsp)
  mov    0x8(%rsp),%eax
  lea    (%r12,%r10,1),%r11
  add    %r14,%r10
  mov    %rbx,-0x58(%rsp)
  lea    (%r14,%rdx,1),%rbx
  mov    %rbx,-0x48(%rsp)
  mov    %rax,-0x20(%rsp)
  jmp    L87
  nopw   0x0(%rax,%rax,1)
L382:
  add    $0x1,%esi
  add    %r15d,%edi
  sub    %rbp,%r8
  add    %rbp,%rcx
  cmp    -0x78(%rsp),%esi
  je     L338
L87:
  mov    -0x70(%rsp),%rax
  mov    (%rax,%rcx,4),%edx
  test   %edx,%edx
  je     L382
  mov    -0x50(%rsp),%rbx
  lea    0x0(,%rcx,4),%r9
  mov    -0x40(%rsp),%rax
  lea    (%r12,%r9,1),%rdx
  add    %r9,%rbx
  lea    (%rax,%r9,1),%r13
  lea    (%r14,%r9,1),%rax
  cmp    $0x8,%rbx
  seta   %bl
  cmp    $0x1,%r15d
  setne  -0x68(%rsp)
  add    -0x30(%rsp),%r9
  and    -0x68(%rsp),%bl
  cmp    %r9,%rax
  setae  %r9b
  cmp    %rdx,%r13
  setbe  -0x68(%rsp)
  or     -0x68(%rsp),%r9b
  and    %ebx,%r9d
  cmp    %rax,-0x58(%rsp)
  setbe  %bl
  cmp    %r13,%r11
  setae  %r13b
  or     %r13d,%ebx
  test   %bl,%r9b
  je     L93
  mov    %rdx,%r9
  sub    -0x48(%rsp),%r9
  cmp    $0x8,%r9
  jbe    L93
  cmpl   $0x2,0x8(%rsp)
  jbe    L407
  mov    -0x28(%rsp),%rbx
  xor    %r9d,%r9d
  nopl   0x0(%rax,%rax,1)
L152:
  movdqu (%rax,%r9,1),%xmm0
  movdqu (%r10,%r9,1),%xmm7
  pxor   %xmm7,%xmm0
  movups %xmm0,(%rax,%r9,1)
  movdqu (%rdx,%r9,1),%xmm0
  movdqu (%r11,%r9,1),%xmm3
  pxor   %xmm3,%xmm0
  movups %xmm0,(%rdx,%r9,1)
  add    $0x10,%r9
  cmp    %r9,%rbx
  jne    L152
  mov    -0x34(%rsp),%r9d
  mov    %r9d,%eax
  cmp    %r15d,%r9d
  je     L382
  mov    -0x18(%rsp),%ebx
  mov    %ebx,%r13d
  cmp    $0x1,%ebx
  je     L384
L129:
  lea    (%rcx,%r9,1),%rdx
  add    -0x60(%rsp),%r9
  shl    $0x2,%rdx
  movq   (%r14,%r9,4),%xmm0
  lea    (%r14,%rdx,1),%rbx
  add    %r12,%rdx
  movq   (%rbx),%xmm1
  pxor   %xmm1,%xmm0
  movq   %xmm0,(%rbx)
  movq   (%rdx),%xmm1
  movq   (%r12,%r9,4),%xmm0
  pxor   %xmm1,%xmm0
  movq   %xmm0,(%rdx)
  mov    %r13d,%edx
  and    $0xfffffffe,%edx
  add    %edx,%eax
  cmp    %edx,%r13d
  je     L382
L384:
  lea    (%rdi,%rax,1),%edx
  add    -0x38(%rsp),%eax
  movslq %edx,%rdx
  cltq
  shl    $0x2,%rdx
  mov    (%r14,%rax,4),%r9d
  xor    %r9d,(%r14,%rdx,1)
  mov    (%r12,%rax,4),%eax
  xor    %eax,(%r12,%rdx,1)
  jmp    L382
L29:
  xor    %edx,%edx
  xor    %eax,%eax
  jmp    L312
L273:
  add    $0x50,%rsp
  mov    $0xffffffff,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopl   0x0(%rax,%rax,1)
L338:
  lea    -0x1(%rsi),%eax
L449:
  mov    %eax,-0x78(%rsp)
  mov    -0x78(%rsp),%eax
  subq   $0x4,-0x70(%rsp)
  sub    %r15d,-0x38(%rsp)
  test   %eax,%eax
  jg     L354
L606:
  mov    -0x78(%rsp),%eax
  sub    $0x1,%eax
  jns    L449
  add    $0x50,%rsp
  xor    %eax,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L93:
  mov    -0x20(%rsp),%rbx
  lea    (%rbx,%rcx,1),%r9
  mov    -0x10(%rsp),%rbx
  lea    (%rbx,%r9,4),%r9
  nopw   0x0(%rax,%rax,1)
L268:
  mov    (%rax,%r8,4),%ebx
  xor    %ebx,(%rax)
  add    $0x4,%rax
  mov    (%rdx,%r8,4),%ebx
  xor    %ebx,(%rdx)
  add    $0x4,%rdx
  cmp    %rax,%r9
  jne    L268
  jmp    L382
L407:
  mov    %r15d,%r13d
  xor    %eax,%eax
  xor    %r9d,%r9d
  jmp    L129
L388:
  mov    0x40(%rsp),%r8
  mov    -0x28(%rsp),%rcx
  mov    %r13,%rdx
  mov    %rbx,%rax
  add    0x10(%rsp),%r8
  sub    -0x58(%rsp),%rcx
  nopl   (%rax)
L504:
  mov    (%rax),%edi
  mov    (%rax,%rcx,4),%r9d
  mov    %r9d,(%rax)
  mov    %edi,(%rax,%rcx,4)
  mov    (%rdx),%edi
  add    $0x4,%rax
  mov    (%rdx,%rcx,4),%r9d
  mov    %r9d,(%rdx)
  mov    %edi,(%rdx,%rcx,4)
  add    $0x4,%rdx
  cmp    %r8,%rax
  jne    L504
  jmp    L90
L438:
  xor    %edx,%edx
  jmp    L324
L556:
  mov    %esi,%edx
  jmp    L20
L515:
  xor    %eax,%eax
  ret
```

tool_calls: name: retrieve_data
arguments: tag: D27
datatype: byte[16]
name: retrieve_data
arguments: tag: D18
datatype: byte[16]
name: retrieve_data
arguments: tag: D28
datatype: byte[16]

tool: {"D27": [0x04,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x04,0x00,0x00,0x00]}

tool: {"D18": [0x01,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x01,0x00,0x00,0x00]}

tool: {"D28": [0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x03,0x00,0x00,0x00]}

assistant: ```c
int jerasure_invert_bitmatrix(int *mat, int *inv, int rows) {
  int cols, i, j, k;
  int tmp;
  cols = rows;
  k = 0;
  for (i = 0; i < rows; i++) {
    for (j = 0; j < cols; j++) {
      inv[k] = (i == j) ? 1 : 0;
      k++;
    }
  }
  for (i = 0; i < cols; i++) {
    if ((mat[i * cols + i]) == 0) {
      for (j = i + 1; j < rows && (mat[j * cols + i]) == 0; j++)
        ;
      if (j == rows)
        return -1;
      for (k = 0; k < cols; k++) {
        tmp = mat[i * cols + k];
        mat[i * cols + k] = mat[j * cols + k];
        mat[j * cols + k] = tmp;
        tmp = inv[i * cols + k];
        inv[i * cols + k] = inv[j * cols + k];
        inv[j * cols + k] = tmp;
      }
    }
    for (j = i + 1; j != rows; j++) {
      if (mat[j * cols + i] != 0) {
        for (k = 0; k < cols; k++) {
          mat[j * cols + k] ^= mat[i * cols + k];
          inv[j * cols + k] ^= inv[i * cols + k];
        }
      }
    }
  }
  for (i = rows - 1; i >= 0; i--) {
    for (j = 0; j < i; j++) {
      if (mat[j * cols + i]) {
        for (k = 0; k < cols; k++) {
          mat[j * cols + k] ^= mat[i * cols + k];
          inv[j * cols + k] ^= inv[i * cols + k];
        }
      }
    }
  }
  return 0;
}
```