// File: /workspace/github_c_makefile_star2_O1/olcaytaner[P]Isell/matrix.c
// Function: balance
double* balance(matrix a)
{
 int i, j;
 BOOLEAN done = BOOLEAN_FALSE; 
 double sqrdx = 4, r, c, g, f, s, *scale;
 scale = safemalloc(a.row * sizeof(double), "balance", 3);
 for (i = 0; i < a.row; i++)
   scale[i] = 1.0;
 while (!done) 
  {
   done = BOOLEAN_TRUE; 
   for (i = 0; i < a.row; i++) 
    {
     r = 0.0;
     c = 0.0; 
     for (j = 0; j < a.col; j++)
       if (j != i) 
        { 
         c += fabs(a.values[j][i]); 
         r += fabs(a.values[i][j]);
        } 
     if (c != 0.0 && r != 0.0) 
      {
       g = r / 2; 
       f = 1.0; 
       s = c + r; 
       while (c < g) 
        {
         f *= 2; 
         c *= sqrdx;
        } 
       g = r * 2; 
       while (c > g) 
        {
         f /= 2; 
         c /= sqrdx;
        } 
       if ((c + r) / f < 0.95 * s) 
        {
         done = BOOLEAN_FALSE; 
         g = 1.0 / f; 
         scale[i] *= f; 
         for (j = 0; j < a.row; j++) 
           a.values[i][j] *= g; 
         for (j = 0; j < a.row; j++) 
           a.values[j][i] *= f;
        }
      }
    }
  }
 return scale;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rsi, %rbx
movq %rdi, %r14
movslq %r14d, %r15
leaq (,%r15,8), %rdi
leaq 0x66d61(%rip), %rsi     # 0xa6f86
movl $0x3, %edx
callq 0x390f5
testl %r15d, %r15d
jle 0x40255
movl %r14d, %ecx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
xorl %edx, %edx
movabsq $0x3ff0000000000000, %rsi # imm = 0x3FF0000000000000
movq %rsi, (%rax,%rdx,8)
incq %rdx
cmpq %rdx, %rcx
jne 0x40249
testl %r14d, %r14d
jle 0x403f3
movq %r14, %rcx
shrq $0x20, %rcx
movl %r14d, %edx
andl $0x7fffffff, %edx       # imm = 0x7FFFFFFF
movapd 0x62f6a(%rip), %xmm0    # 0xa31e0
xorpd %xmm1, %xmm1
movsd 0x62a96(%rip), %xmm2    # 0xa2d18
movsd 0x62296(%rip), %xmm3    # 0xa2520
movsd 0x62b56(%rip), %xmm4    # 0xa2de8
movsd 0x62a5e(%rip), %xmm5    # 0xa2cf8
movsd 0x66bd6(%rip), %xmm6    # 0xa6e78
movl $0x1, %edi
xorl %esi, %esi
testl %ecx, %ecx
jle 0x402f0
xorpd %xmm7, %xmm7
xorl %r8d, %r8d
xorpd %xmm8, %xmm8
cmpq %r8, %rsi
je 0x402e6
movq (%rbx,%r8,8), %r9
movsd (%r9,%rsi,8), %xmm9
andpd %xmm0, %xmm9
addsd %xmm9, %xmm7
movq (%rbx,%rsi,8), %r9
movsd (%r9,%r8,8), %xmm9
andpd %xmm0, %xmm9
addsd %xmm9, %xmm8
incq %r8
cmpq %r8, %rcx
jne 0x402b9
jmp 0x402f9
xorpd %xmm8, %xmm8
xorpd %xmm7, %xmm7
ucomisd %xmm1, %xmm7
jne 0x40305
jnp 0x403da
ucomisd %xmm1, %xmm8
jne 0x40312
jnp 0x403da
movapd %xmm8, %xmm11
mulsd %xmm2, %xmm11
ucomisd %xmm7, %xmm11
movapd %xmm7, %xmm10
movapd %xmm3, %xmm9
jbe 0x40348
movapd %xmm3, %xmm9
movapd %xmm7, %xmm10
addsd %xmm9, %xmm9
mulsd %xmm4, %xmm10
ucomisd %xmm10, %xmm11
ja 0x40337
movapd %xmm8, %xmm11
addsd %xmm8, %xmm11
ucomisd %xmm11, %xmm10
jbe 0x40365
mulsd %xmm2, %xmm9
mulsd %xmm5, %xmm10
jmp 0x40352
addsd %xmm8, %xmm7
addsd %xmm8, %xmm10
divsd %xmm9, %xmm10
mulsd %xmm6, %xmm7
ucomisd %xmm10, %xmm7
jbe 0x403da
movapd %xmm3, %xmm7
divsd %xmm9, %xmm7
movsd (%rax,%rsi,8), %xmm8
mulsd %xmm9, %xmm8
movsd %xmm8, (%rax,%rsi,8)
movq (%rbx,%rsi,8), %rdi
xorl %r8d, %r8d
movsd (%rdi,%r8,8), %xmm8
mulsd %xmm7, %xmm8
movsd %xmm8, (%rdi,%r8,8)
incq %r8
cmpq %r8, %rdx
jne 0x403a0
xorl %edi, %edi
movq (%rbx,%rdi,8), %r8
movsd (%r8,%rsi,8), %xmm7
mulsd %xmm9, %xmm7
movsd %xmm7, (%r8,%rsi,8)
incq %rdi
cmpq %rdi, %rdx
jne 0x403bb
xorl %edi, %edi
incq %rsi
cmpq %rdx, %rsi
jne 0x402a9
testl %edi, %edi
jne 0x403f3
testl %r14d, %r14d
jg 0x402a2
popq %rbx
popq %r14
popq %r15
retq