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

```asm
<balance>:
  endbr64
  push   %r15
  lea    -0x1(%rsi),%eax
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x78,%rsp
  mov    %rdx,0x58(%rsp)
  mov    %rcx,0x60(%rsp)
  mov    %r8,0x20(%rsp)
  mov    %eax,0x2c(%rsp)
  test   %eax,%eax
  js     L328
  movslq %eax,%r14
  mov    %rdi,%rbx
  mov    %esi,%r12d
  lea    0x0(,%r14,8),%rax
  mov    %r14,%rcx
  imul   %esi,%ecx
  lea    (%rdi,%rax,1),%rdi
  add    $0x8,%rax
  mov    %rax,0x50(%rsp)
  mov    %esi,%eax
  shr    %eax
  mov    %rdi,0x18(%rsp)
  sub    $0x1,%eax
  mov    %ecx,0x8(%rsp)
  add    $0x1,%rax
  mov    %ecx,0x14(%rsp)
  shl    $0x4,%rax
  mov    %rax,0x30(%rsp)
  mov    %esi,%eax
  and    $0xfffffffe,%eax
  mov    %eax,0x40(%rsp)
  lea    0x8(%rbx),%rax
  mov    %rax,0x38(%rsp)
L296:
  mov    %r14d,0x28(%rsp)
  mov    0x14(%rsp),%r15d
  mov    %r14d,%r13d
  mov    %r14d,(%rsp)
  nopl   0x0(%rax,%rax,1)
L572:
  xor    %ebp,%ebp
  nopw   0x0(%rax,%rax,1)
L211:
  cmp    %r13d,%ebp
  je     L476
  lea    0x0(%rbp,%r15,1),%eax
  cltq
  movsd  (%rbx,%rax,8),%xmm0
  call   <fabs@plt>
  test   %rax,%rax
  jne    L51
L476:
  add    $0x1,%ebp
  cmp    %r14d,%ebp
  jle    L211
L280:
  pxor   %xmm0,%xmm0
  mov    0x20(%rsp),%rax
  mov    %r14d,%esi
  cvtsi2sd %r13d,%xmm0
  movsd  %xmm0,(%rax,%r14,8)
  cmp    %r14d,%r13d
  jne    L310
L39:
  mov    0x28(%rsp),%eax
  sub    $0x1,%r14
  sub    %r12d,0x8(%rsp)
  subq   $0x8,0x18(%rsp)
  sub    $0x1,%eax
  sub    %r12d,0x14(%rsp)
  mov    %eax,(%rsp)
  test   %r14d,%r14d
  jns    L296
L328:
  mov    %eax,%ebp
  xor    %eax,%eax
L200:
  mov    0x60(%rsp),%rsi
  mov    0x58(%rsp),%rdi
  mov    %ebp,(%rsi)
  mov    %eax,(%rdi)
L562:
  add    $0x78,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopl   0x0(%rax,%rax,1)
L51:
  cmp    %r14d,%ebp
  jg     L280
  sub    $0x1,%r13d
  sub    %r12d,%r15d
  cmp    $0xffffffff,%r13d
  jne    L572
  mov    (%rsp),%ebp
  mov    0x2c(%rsp),%eax
  mov    %rbx,0x38(%rsp)
  movl   $0x0,0x8(%rsp)
  mov    %eax,0x44(%rsp)
  xor    %eax,%eax
  test   %ebp,%ebp
  cmovns %ebp,%eax
  movq   $0x0,(%rsp)
  lea    0x1(%rax),%edi
  mov    %eax,0x2c(%rsp)
  mov    %edi,%eax
  mov    %edi,0x40(%rsp)
  and    $0xfffffffe,%edi
  shr    %eax
  mov    %edi,0x30(%rsp)
  sub    $0x1,%eax
  add    $0x1,%rax
  shl    $0x4,%rax
  mov    %rax,0x48(%rsp)
  lea    0x8(%rbx),%rax
  mov    %rax,0x68(%rsp)
L133:
  mov    (%rsp),%rax
  mov    %eax,0x14(%rsp)
  mov    %eax,%r15d
  mov    %eax,0x18(%rsp)
  nopl   0x0(%rax,%rax,1)
L275:
  mov    0x8(%rsp),%eax
  mov    0x18(%rsp),%r14d
  lea    (%r15,%rax,1),%r13d
  nopl   (%rax)
L349:
  cmp    %r15d,%r14d
  je     L471
  movslq %r13d,%rax
  movsd  (%rbx,%rax,8),%xmm0
  call   <fabs@plt>
  test   %rax,%rax
  jne    L25
L471:
  add    $0x1,%r14d
  add    %r12d,%r13d
  cmp    %r14d,%ebp
  jge    L349
L346:
  pxor   %xmm0,%xmm0
  mov    0x20(%rsp),%rdi
  mov    (%rsp),%rax
  cvtsi2sd %r15d,%xmm0
  movsd  %xmm0,(%rdi,%rax,8)
  mov    %eax,%edi
  cmp    %eax,%r15d
  jne    L35
L606:
  cmp    %r15d,%ebp
  jl     L597
  addq   $0x1,(%rsp)
  mov    0x14(%rsp),%eax
  mov    (%rsp),%rdi
  add    %r12d,0x8(%rsp)
  subl   $0x1,0x44(%rsp)
  add    $0x1,%eax
  addq   $0x8,0x38(%rsp)
  cmp    %edi,%ebp
  jge    L133
  jmp    L200
  nop
L25:
  cmp    %r14d,%ebp
  jl     L346
  add    $0x1,%r15d
  cmp    %r15d,%ebp
  jge    L275
L597:
  mov    0x60(%rsp),%rax
  mov    0x18(%rsp),%edi
  mov    %ebp,(%rax)
  mov    0x58(%rsp),%rax
  mov    %edi,(%rax)
  cmp    %edi,%ebp
  jl     L562
  mov    0x28(%rsp),%eax
  add    $0x1,%eax
  mov    %eax,%esi
  mov    %eax,0x44(%rsp)
  sub    0x14(%rsp),%esi
  cmp    %edi,%ebp
  je     L345
  movslq %edi,%rax
  mov    0x20(%rsp),%rdi
  movapd D76(%rip),%xmm0
  mov    %rax,0x38(%rsp)
  lea    (%rdi,%rax,8),%rcx
  mov    %esi,%eax
  shr    %eax
  movups %xmm0,(%rcx)
  lea    -0x1(%rax),%edx
  lea    0x10(%rcx),%rax
  shl    $0x4,%rdx
  mov    %rax,%rcx
  add    %rax,%rdx
  cmp    %rdx,%rax
  je     L52
L259:
  add    $0x10,%rax
  movups %xmm0,(%rcx)
  mov    %rax,%rcx
  cmp    %rdx,%rax
  jne    L259
L52:
  mov    0x18(%rsp),%eax
  mov    %esi,%edx
  and    $0xfffffffe,%edx
  add    %edx,%eax
  cmp    %esi,%edx
  je     L30
L745:
  mov    0x20(%rsp),%rcx
  mov    D76(%rip),%rsi
  cltq
  mov    %rsi,(%rcx,%rax,8)
L30:
  mov    0x14(%rsp),%eax
  mov    %r12d,%ecx
  mov    %eax,%edi
  sub    %eax,%ecx
  imul   %r12d,%edi
  mov    %ecx,%esi
  mov    %ecx,0x48(%rsp)
  and    $0xfffffffe,%esi
  mov    %esi,0x58(%rsp)
  mov    %edi,0x2c(%rsp)
  mov    %eax,%edi
  mov    %ecx,%eax
  shr    %eax
  lea    -0x1(%rax),%edx
  mov    %edi,%eax
  add    %esi,%eax
  cmp    $0x1,%ecx
  cmove  0x18(%rsp),%eax
  mov    %eax,0x40(%rsp)
  lea    0x1(%rdx),%rax
  shl    $0x4,%rax
  mov    %rax,0x60(%rsp)
L702:
  mov    0x2c(%rsp),%eax
  movl   $0x1,0x30(%rsp)
  mov    0x38(%rsp),%r15
  mov    %eax,0x14(%rsp)
  mov    %eax,0x28(%rsp)
  nopw   0x0(%rax,%rax,1)
L522:
  mov    0x2c(%rsp),%eax
  pxor   %xmm2,%xmm2
  mov    0x18(%rsp),%r14d
  movsd  %xmm2,(%rsp)
  lea    (%rax,%r15,1),%r13d
  cs nopw 0x0(%rax,%rax,1)
L237:
  cmp    %r15d,%r14d
  je     L202
  movslq %r13d,%rax
  movsd  %xmm2,0x8(%rsp)
  add    %r12d,%r13d
  movsd  (%rbx,%rax,8),%xmm0
  call   <fabs@plt>
  pxor   %xmm0,%xmm0
  cvtsi2sd %rax,%xmm0
  mov    0x14(%rsp),%eax
  addsd  (%rsp),%xmm0
  add    %r14d,%eax
  add    $0x1,%r14d
  cltq
  movsd  %xmm0,(%rsp)
  movsd  (%rbx,%rax,8),%xmm0
  call   <fabs@plt>
  pxor   %xmm0,%xmm0
  movsd  0x8(%rsp),%xmm2
  cvtsi2sd %rax,%xmm0
  addsd  %xmm0,%xmm2
  cmp    %r14d,%ebp
  jge    L237
L163:
  movsd  (%rsp),%xmm1
  pxor   %xmm4,%xmm4
  mov    $0x1,%edx
  ucomisd %xmm4,%xmm1
  setp   %al
  cmovne %edx,%eax
  test   %al,%al
  je     L322
  ucomisd %xmm4,%xmm2
  setp   %al
  cmovne %edx,%eax
  test   %al,%al
  jne    L657
L322:
  add    $0x1,%r15
  add    %r12d,0x28(%rsp)
  add    %r12d,0x14(%rsp)
  cmp    %r15d,%ebp
  jge    L522
  mov    0x30(%rsp),%eax
  test   %eax,%eax
  je     L702
  add    $0x78,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopl   0x0(%rax)
L202:
  add    $0x1,%r14d
  add    %r12d,%r13d
  cmp    %r14d,%ebp
  jge    L237
  jmp    L163
  nopw   0x0(%rax,%rax,1)
L35:
  cmp    $0x1,%r12d
  jne    L315
  mov    %rax,%rsi
  movslq %r15d,%rax
  shl    $0x3,%rax
  lea    0x10(,%rsi,8),%rcx
  shl    $0x3,%rsi
  lea    0x10(%rax),%r8
  cmp    %rsi,%r8
  setle  %r8b
  cmp    %rax,%rcx
  setle  %cl
  add    %rbx,%rax
  or     %cl,%r8b
  je     L262
  cmpl   $0x1,0x2c(%rsp)
  jbe    L262
  add    %rbx,%rsi
  xor    %ecx,%ecx
L191:
  movupd (%rax,%rcx,1),%xmm0
  movupd (%rsi,%rcx,1),%xmm6
  movups %xmm6,(%rax,%rcx,1)
  movups %xmm0,(%rsi,%rcx,1)
  add    $0x10,%rcx
  cmp    0x48(%rsp),%rcx
  jne    L191
  mov    0x30(%rsp),%esi
  cmp    %esi,0x40(%rsp)
  je     L116
  lea    (%r15,%rsi,1),%eax
  cltq
  lea    (%rbx,%rax,8),%rcx
  mov    0x18(%rsp),%eax
  movsd  (%rcx),%xmm0
  add    %esi,%eax
  cltq
  lea    (%rbx,%rax,8),%rax
  movsd  (%rax),%xmm1
  movsd  %xmm1,(%rcx)
  movsd  %xmm0,(%rax)
L116:
  cmp    %edi,%r12d
  jle    L606
  mov    %r12d,%eax
  mov    (%rsp),%rcx
  movslq 0x8(%rsp),%rsi
  mov    %r12d,%r9d
  imul   %r15d,%eax
  sub    0x14(%rsp),%r9d
  movslq %eax,%rdi
  lea    (%rcx,%rdi,1),%r8
  add    %rsi,%rcx
  shl    $0x3,%rcx
  lea    0x0(,%r8,8),%rdx
  lea    0x10(,%r8,8),%r11
  lea    0x10(%rcx),%r10
  cmp    %r10,%rdx
  setge  %r13b
  cmp    %r11,%rcx
  setge  %r10b
  or     %r13b,%r10b
  je     L500
  cmpl   $0x1,0x44(%rsp)
  jbe    L500
  mov    %r9d,%r8d
  lea    (%rbx,%rdx,1),%rdi
  add    %rbx,%rcx
  xor    %esi,%esi
  shr    %r8d
  shl    $0x4,%r8
L540:
  movupd (%rdi,%rsi,1),%xmm0
  movupd (%rcx,%rsi,1),%xmm5
  movups %xmm5,(%rdi,%rsi,1)
  movups %xmm0,(%rcx,%rsi,1)
  add    $0x10,%rsi
  cmp    %rsi,%r8
  jne    L540
  mov    0x18(%rsp),%edi
  mov    %r9d,%esi
  and    $0xfffffffe,%esi
  lea    (%rsi,%rdi,1),%ecx
  cmp    %r9d,%esi
  je     L606
  add    %ecx,%eax
  cltq
  lea    (%rbx,%rax,8),%rsi
  mov    0x8(%rsp),%eax
  movsd  (%rsi),%xmm0
  add    %ecx,%eax
  cltq
  lea    (%rbx,%rax,8),%rax
  movsd  (%rax),%xmm1
  movsd  %xmm1,(%rsi)
  movsd  %xmm0,(%rax)
  jmp    L606
  nopl   0x0(%rax)
L310:
  cmp    $0x1,%r12d
  jne    L568
  mov    (%rsp),%eax
  xor    %edi,%edi
  lea    0x0(,%r14,8),%rcx
  lea    0x10(,%r14,8),%rdx
  test   %eax,%eax
  cmovns %eax,%edi
  movslq %r13d,%rax
  shl    $0x3,%rax
  lea    0x10(%rax),%r8
  cmp    %rcx,%r8
  setle  %r8b
  cmp    %rdx,%rax
  setge  %dl
  or     %dl,%r8b
  je     L330
  cmp    $0x1,%edi
  jbe    L330
  add    $0x1,%edi
  add    %rbx,%rax
  add    %rbx,%rcx
  mov    %edi,%edx
  shr    %edx
  mov    %rdx,%rsi
  xor    %edx,%edx
  shl    $0x4,%rsi
L680:
  movupd (%rax,%rdx,1),%xmm0
  movupd (%rcx,%rdx,1),%xmm5
  movups %xmm5,(%rax,%rdx,1)
  movups %xmm0,(%rcx,%rdx,1)
  add    $0x10,%rdx
  cmp    %rsi,%rdx
  jne    L680
  mov    %edi,%eax
  and    $0xfffffffe,%eax
  and    $0x1,%edi
  je     L693
  lea    0x0(%r13,%rax,1),%edx
  add    (%rsp),%eax
  movslq %edx,%rdx
  cltq
  lea    (%rbx,%rdx,8),%rdx
  lea    (%rbx,%rax,8),%rax
  movsd  (%rdx),%xmm0
  movsd  (%rax),%xmm1
  movsd  %xmm1,(%rdx)
  movsd  %xmm0,(%rax)
L693:
  imul   %r12d,%r13d
  movslq 0x8(%rsp),%rsi
  lea    0x0(,%rsi,8),%rdx
  movslq %r13d,%rdi
  lea    0x10(%rdx),%rax
  lea    0x0(,%rdi,8),%rcx
  lea    0x10(,%rdi,8),%r8
  cmp    %rcx,%rax
  setle  %al
  cmp    %rdx,%r8
  setle  %r8b
  or     %r8b,%al
  je     L470
  cmpl   $0x1,0x2c(%rsp)
  jbe    L470
  mov    0x30(%rsp),%rsi
  add    %rbx,%rcx
  add    %rbx,%rdx
  xor    %eax,%eax
L285:
  movupd (%rcx,%rax,1),%xmm0
  movupd (%rdx,%rax,1),%xmm6
  movups %xmm6,(%rcx,%rax,1)
  movups %xmm0,(%rdx,%rax,1)
  add    $0x10,%rax
  cmp    %rsi,%rax
  jne    L285
  mov    0x40(%rsp),%edi
  cmp    %edi,%r12d
  je     L39
  lea    0x0(%r13,%rdi,1),%eax
  cltq
  lea    (%rbx,%rax,8),%rdx
  mov    0x8(%rsp),%eax
  movsd  (%rdx),%xmm0
  add    %edi,%eax
  cltq
  lea    (%rbx,%rax,8),%rax
  movsd  (%rax),%xmm1
  movsd  %xmm1,(%rdx)
  movsd  %xmm0,(%rax)
  jmp    L39
  nopl   0x0(%rax,%rax,1)
L657:
  movsd  D18(%rip),%xmm3
  movsd  D76(%rip),%xmm5
  movapd %xmm2,%xmm6
  addsd  %xmm1,%xmm6
  mulsd  %xmm2,%xmm3
  movapd %xmm5,%xmm0
  comisd %xmm1,%xmm3
  jbe    L88
  movsd  D7(%rip),%xmm4
  xchg   %ax,%ax
L23:
  mulsd  %xmm4,%xmm1
  addsd  %xmm0,%xmm0
  comisd %xmm1,%xmm3
  ja     L23
L88:
  movapd %xmm2,%xmm3
  addsd  %xmm2,%xmm3
  comisd %xmm3,%xmm1
  jb     L472
  nopl   0x0(%rax)
L248:
  mulsd  D62(%rip),%xmm1
  mulsd  D18(%rip),%xmm0
  comisd %xmm3,%xmm1
  jae    L248
L472:
  addsd  %xmm1,%xmm2
  mulsd  D0(%rip),%xmm6
  divsd  %xmm0,%xmm2
  comisd %xmm2,%xmm6
  jbe    L322
  divsd  %xmm0,%xmm5
  mov    0x20(%rsp),%rax
  movsd  (%rax,%r15,8),%xmm2
  mulsd  %xmm0,%xmm2
  movsd  %xmm2,(%rax,%r15,8)
  movapd %xmm5,%xmm1
  cmp    %r12d,0x18(%rsp)
  jge    L21
  cmpl   $0x1,0x48(%rsp)
  je     L678
  movslq 0x28(%rsp),%rax
  mov    0x60(%rsp),%rcx
  movapd %xmm5,%xmm3
  add    0x38(%rsp),%rax
  unpcklpd %xmm3,%xmm3
  lea    (%rbx,%rax,8),%rax
  lea    (%rcx,%rax,1),%rdx
  nopw   0x0(%rax,%rax,1)
L120:
  movupd (%rax),%xmm2
  add    $0x10,%rax
  mulpd  %xmm3,%xmm2
  movups %xmm2,-0x10(%rax)
  cmp    %rdx,%rax
  jne    L120
  mov    0x48(%rsp),%esi
  cmp    %esi,0x58(%rsp)
  je     L21
L678:
  mov    0x28(%rsp),%eax
  add    0x40(%rsp),%eax
  cltq
  lea    (%rbx,%rax,8),%rax
  mulsd  (%rax),%xmm1
  movsd  %xmm1,(%rax)
L21:
  mov    0x44(%rsp),%ecx
  mov    0x50(%rsp),%rsi
  lea    (%rbx,%r15,8),%rax
  xor    %edx,%edx
  nopl   0x0(%rax)
L241:
  movsd  (%rax),%xmm1
  add    $0x1,%edx
  mulsd  %xmm0,%xmm1
  movsd  %xmm1,(%rax)
  add    %rsi,%rax
  cmp    %ecx,%edx
  jne    L241
  movl   $0x0,0x30(%rsp)
  jmp    L322
L568:
  movslq %r13d,%rcx
  mov    %r14,%rdi
  xor    %edx,%edx
  lea    (%rbx,%rcx,8),%rax
  sub    %rcx,%rdi
L236:
  movsd  (%rax),%xmm0
  movsd  (%rax,%rdi,8),%xmm1
  add    $0x1,%edx
  movsd  %xmm1,(%rax)
  movsd  %xmm0,(%rax,%rdi,8)
  add    0x50(%rsp),%rax
  cmp    %esi,%edx
  jle    L236
  test   %r12d,%r12d
  jle    L39
  jmp    L693
  cs nopw 0x0(%rax,%rax,1)
L315:
  mov    %rax,%r8
  movslq %r15d,%rsi
  xor    %ecx,%ecx
  lea    (%rbx,%rsi,8),%rax
  sub    %rsi,%r8
L336:
  movsd  (%rax),%xmm0
  movsd  (%rax,%r8,8),%xmm1
  add    $0x1,%ecx
  movsd  %xmm1,(%rax)
  movsd  %xmm0,(%rax,%r8,8)
  add    0x50(%rsp),%rax
  cmp    %ecx,%ebp
  jge    L336
  jmp    L116
L330:
  mov    0x18(%rsp),%rcx
  add    %rbx,%rax
  xor    %edx,%edx
L219:
  movsd  (%rax,%rdx,8),%xmm0
  movsd  (%rcx,%rdx,8),%xmm1
  movsd  %xmm1,(%rax,%rdx,8)
  movsd  %xmm0,(%rcx,%rdx,8)
  add    $0x1,%rdx
  cmp    %edx,%esi
  jge    L219
  jmp    L693
  nop
L262:
  mov    0x38(%rsp),%rdx
  xor    %ecx,%ecx
L646:
  movsd  (%rax,%rcx,8),%xmm0
  movsd  (%rdx,%rcx,8),%xmm1
  movsd  %xmm1,(%rax,%rcx,8)
  movsd  %xmm0,(%rdx,%rcx,8)
  add    $0x1,%rcx
  cmp    %ecx,%ebp
  jge    L646
  jmp    L116
L345:
  movslq %ebp,%rsi
  mov    %ebp,%eax
  mov    %rsi,0x38(%rsp)
  jmp    L745
L470:
  mov    0x2c(%rsp),%edx
  mov    0x38(%rsp),%rcx
  sub    %rdi,%rsi
  lea    (%rbx,%rdi,8),%rax
  add    %rdi,%rdx
  lea    (%rcx,%rdx,8),%rcx
  mov    %rsi,%rdx
L324:
  movsd  (%rax),%xmm0
  movsd  (%rax,%rdx,8),%xmm1
  movsd  %xmm1,(%rax)
  movsd  %xmm0,(%rax,%rdx,8)
  add    $0x8,%rax
  cmp    %rcx,%rax
  jne    L324
  jmp    L39
L500:
  mov    0x44(%rsp),%ecx
  mov    0x68(%rsp),%rdx
  lea    (%rbx,%r8,8),%rax
  sub    %rdi,%rsi
  add    (%rsp),%rcx
  add    %rdi,%rcx
  lea    (%rdx,%rcx,8),%rcx
L403:
  movsd  (%rax),%xmm0
  movsd  (%rax,%rsi,8),%xmm1
  movsd  %xmm1,(%rax)
  movsd  %xmm0,(%rax,%rsi,8)
  add    $0x8,%rax
  cmp    %rax,%rcx
  jne    L403
  jmp    L606
```

tool_calls: name: unpack_data
arguments: tag: D76
type_infered: byte[16]
name: unpack_data
arguments: tag: D18
type_infered: byte[8]
name: unpack_data
arguments: tag: D7
type_infered: byte[8]
name: unpack_data
arguments: tag: D62
type_infered: byte[8]
name: unpack_data
arguments: tag: D0
type_infered: f64

tool: {"D76": [0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0x3f,0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0x3f]}

tool: {"D18": [0x00,0x00,0x00,0x00,0x00,0x00,0xe0,0x3f]}

tool: {"D7": [0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x40]}

tool: {"D62": [0x00,0x00,0x00,0x00,0x00,0x00,0xd0,0x3f]}

tool: D0: 0.95

assistant: ```c
void balance(double *mat, int n, int *low, int *hi, double *scale) {
  double c, f, g, r, s;
  int i, j, k, l, done;
  for (k = n - 1; k >= 0; k--) {
    for (j = k; j >= 0; j--) {
      for (i = 0; i <= k; i++) {
        if (i != j && fabs(mat[((j) * (n) + (i))]) != 0)
          break;
      }
      if (i > k) {
        scale[k] = j;
        if (j != k) {
          for (i = 0; i <= k; i++) {
            c = mat[((i) * (n) + (j))];
            mat[((i) * (n) + (j))] = mat[((i) * (n) + (k))];
            mat[((i) * (n) + (k))] = c;
          }
          for (i = 0; i < n; i++) {
            c = mat[((j) * (n) + (i))];
            mat[((j) * (n) + (i))] = mat[((k) * (n) + (i))];
            mat[((k) * (n) + (i))] = c;
          }
        }
        break;
      }
    }
    if (j < 0)
      break;
  }
  for (l = 0; l <= k; l++) {
    for (j = l; j <= k; j++) {
      for (i = l; i <= k; i++) {
        if (i != j && fabs(mat[((i) * (n) + (j))]) != 0)
          break;
      }
      if (i > k) {
        scale[l] = j;
        if (j != l) {
          for (i = 0; i <= k; i++) {
            c = mat[((i) * (n) + (j))];
            mat[((i) * (n) + (j))] = mat[((i) * (n) + (l))];
            mat[((i) * (n) + (l))] = c;
          }
          for (i = l; i < n; i++) {
            c = mat[((j) * (n) + (i))];
            mat[((j) * (n) + (i))] = mat[((l) * (n) + (i))];
            mat[((l) * (n) + (i))] = c;
          }
        }
        break;
      }
    }
    if (j > k)
      break;
  }
  *hi = k;
  *low = l;
  for (i = l; i <= k; i++) {
    scale[i] = 1;
  }
  do {
    for (done = 1, i = l; i <= k; i++) {
      for (c = 0, r = 0, j = l; j <= k; j++) {
        if (j != i) {
          c += fabs(mat[((j) * (n) + (i))]);
          r += fabs(mat[((i) * (n) + (j))]);
        }
      }
      if (c != 0 && r != 0) {
        g = r / 2;
        f = 1;
        s = c + r;
        while (c < g) {
          f *= 2;
          c *= 2 * 2;
        }
        g = r * 2;
        while (c >= g) {
          f /= 2;
          c /= 2 * 2;
        }
        if ((c + r) / f < 0.95 * s) {
          done = 0;
          g = 1 / f;
          scale[i] *= f;
          for (j = l; j < n; j++) {
            mat[((i) * (n) + (j))] *= g;
          }
          for (j = 0; j <= k; j++) {
            mat[((j) * (n) + (i))] *= f;
          }
        }
      }
    }
  } while (!done);
}
```