// File: /workspace/github_c_makefile_star2_O2/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 %r12
pushq %rbx
pushq %rax
movq %rsi, %rbx
movq %rdi, %r14
movq %rdi, %r15
shrq $0x20, %r15
movslq %r14d, %r12
leaq (,%r12,8), %rdi
leaq 0x5eb3f(%rip), %rsi     # 0x99f56
pushq $0x3
popq %rdx
callq 0x34f59
xorl %ecx, %ecx
testl %r12d, %r12d
cmovlel %ecx, %r12d
movabsq $0x3ff0000000000000, %rdx # imm = 0x3FF0000000000000
cmpq %rcx, %r12
je 0x3b440
movq %rdx, (%rax,%rcx,8)
incq %rcx
jmp 0x3b432
xorl %edi, %edi
testl %r15d, %r15d
cmovlel %edi, %r15d
movl %r14d, %ecx
pushq $0x1
popq %rdx
xorpd %xmm0, %xmm0
movsd 0x5a8c5(%rip), %xmm1    # 0x95d20
movapd 0x5e9ed(%rip), %xmm2    # 0x99e50
movapd 0x5e9d5(%rip), %xmm3    # 0x99e40
movsd 0x5e99d(%rip), %xmm4    # 0x99e10
movsd 0x5a0a5(%rip), %xmm5    # 0x95520
movapd 0x5ad5d(%rip), %xmm6    # 0x961e0
testl %edi, %edi
jne 0x3b5b7
xorl %esi, %esi
movl %edx, %edi
cmpq %r12, %rsi
je 0x3b483
xorpd %xmm8, %xmm8
xorl %r8d, %r8d
cmpq %r8, %r15
je 0x3b4c8
cmpq %r8, %rsi
je 0x3b4c3
movq (%rbx,%r8,8), %r9
movq (%rbx,%rsi,8), %r10
movsd (%r9,%rsi,8), %xmm7
movhpd (%r10,%r8,8), %xmm7     # xmm7 = xmm7[0],mem[0]
andpd %xmm6, %xmm7
addpd %xmm7, %xmm8
incq %r8
jmp 0x3b49c
ucomisd %xmm0, %xmm8
jne 0x3b4d5
jnp 0x3b5af
movapd %xmm8, %xmm9
unpckhpd %xmm8, %xmm9            # xmm9 = xmm9[1],xmm8[1]
ucomisd %xmm0, %xmm9
jne 0x3b4ec
jnp 0x3b5af
movapd %xmm9, %xmm10
mulsd %xmm1, %xmm10
movapd %xmm8, %xmm7
movhpd 0x5a01d(%rip), %xmm7    # xmm7 = xmm7[0],mem[0]
ucomisd %xmm7, %xmm10
jbe 0x3b510
mulpd %xmm2, %xmm7
jmp 0x3b503
movapd %xmm9, %xmm10
addsd %xmm9, %xmm10
ucomisd %xmm10, %xmm7
jbe 0x3b527
mulpd %xmm3, %xmm7
jmp 0x3b51a
movapd %xmm9, %xmm10
addsd %xmm8, %xmm10
movapd %xmm7, %xmm8
addsd %xmm9, %xmm8
unpckhpd %xmm7, %xmm7            # xmm7 = xmm7[1,1]
divsd %xmm7, %xmm8
mulsd %xmm4, %xmm10
ucomisd %xmm8, %xmm10
jbe 0x3b5af
movapd %xmm5, %xmm8
divsd %xmm7, %xmm8
movsd (%rax,%rsi,8), %xmm9
mulsd %xmm7, %xmm9
movsd %xmm9, (%rax,%rsi,8)
xorl %edi, %edi
cmpq %rdi, %rcx
je 0x3b58c
movq (%rbx,%rsi,8), %r8
movsd (%r8,%rdi,8), %xmm9
mulsd %xmm8, %xmm9
movsd %xmm9, (%r8,%rdi,8)
incq %rdi
jmp 0x3b56d
xorl %edi, %edi
cmpq %rdi, %rcx
je 0x3b5ad
movq (%rbx,%rdi,8), %r8
movsd (%r8,%rsi,8), %xmm8
mulsd %xmm7, %xmm8
movsd %xmm8, (%r8,%rsi,8)
incq %rdi
jmp 0x3b58e
xorl %edi, %edi
incq %rsi
jmp 0x3b48f
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq