// File: /workspace/github_c_makefile_star2_O0/dapogon[P]cellcoal/src/eigen.c
// Function: balance
void balance(double mat[], int n,int *low, int *hi, double scale[])
{
/* Balance a matrix for calculation of eigenvalues and eigenvectors
*/
    double c,f,g,r,s;
    int i,j,k,l,done;
        /* search for rows isolating an eigenvalue and push them down */
    for (k = n - 1; k >= 0; k--) {
        for (j = k; j >= 0; j--) {
            for (i = 0; i <= k; i++) {
                if (i != j && fabs(mat[pos(j,i,n)]) != 0) break;
            }

            if (i > k) {
                scale[k] = j;

                if (j != k) {
                    for (i = 0; i <= k; i++) {
                       c = mat[pos(i,j,n)];
                       mat[pos(i,j,n)] = mat[pos(i,k,n)];
                       mat[pos(i,k,n)] = c;
                    }

                    for (i = 0; i < n; i++) {
                       c = mat[pos(j,i,n)];
                       mat[pos(j,i,n)] = mat[pos(k,i,n)];
                       mat[pos(k,i,n)] = c;
                    }
                }
                break;
            }
        }
        if (j < 0) break;
    }

    /* search for columns isolating an eigenvalue and push them left */

    for (l = 0; l <= k; l++) {
        for (j = l; j <= k; j++) {
            for (i = l; i <= k; i++) {
                if (i != j && fabs(mat[pos(i,j,n)]) != 0) break;
            }
            if (i > k) {
                scale[l] = j;
                if (j != l) {
                    for (i = 0; i <= k; i++) {
                       c = mat[pos(i,j,n)];
                       mat[pos(i,j,n)] = mat[pos(i,l,n)];
                       mat[pos(i,l,n)] = c;
                    }

                    for (i = l; i < n; i++) {
                       c = mat[pos(j,i,n)];
                       mat[pos(j,i,n)] = mat[pos(l,i,n)];
                       mat[pos(l,i,n)] = c;
                    }
                }

                break;
            }
        }

        if (j > k) break;
    }

    *hi = k;
    *low = l;

    /* balance the submatrix in rows l through k */

    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[pos(j,i,n)]);
                    r += fabs(mat[pos(i,j,n)]);
                }
            }

            if (c != 0 && r != 0) {
                g = r / BASE;
                f = 1;
                s = c + r;

                while (c < g) {
                    f *= BASE;
                    c *= BASE * BASE;
                }

                g = r * BASE;

                while (c >= g) {
                    f /= BASE;
                    c /= BASE * BASE;
                }

                if ((c + r) / f < 0.95 * s) {
                    done = 0;
                    g = 1 / f;
                    scale[i] *= f;

                    for (j = l; j < n; j++) {
                        mat[pos(i,j,n)] *= g;
                    }

                    for (j = 0; j <= k; j++) {
                        mat[pos(j,i,n)] *= f;
                    }
                }
            }
        }
    } while (!done);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
movl -0xc(%rbp), %eax
subl $0x1, %eax
movl %eax, -0x5c(%rbp)
cmpl $0x0, -0x5c(%rbp)
jl 0x22cdc
movl -0x5c(%rbp), %eax
movl %eax, -0x58(%rbp)
cmpl $0x0, -0x58(%rbp)
jl 0x22cc4
movl $0x0, -0x54(%rbp)
movl -0x54(%rbp), %eax
cmpl -0x5c(%rbp), %eax
jg 0x22b8e
movl -0x54(%rbp), %eax
cmpl -0x58(%rbp), %eax
je 0x22b81
movq -0x8(%rbp), %rax
movl -0x58(%rbp), %ecx
imull -0xc(%rbp), %ecx
addl -0x54(%rbp), %ecx
movslq %ecx, %rcx
movsd (%rax,%rcx,8), %xmm0
movaps 0x1c832(%rip), %xmm1    # 0x3f3a0
pand %xmm1, %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0x22b7f
jp 0x22b7f
jmp 0x22b81
jmp 0x22b8e
jmp 0x22b83
movl -0x54(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x54(%rbp)
jmp 0x22b41
movl -0x54(%rbp), %eax
cmpl -0x5c(%rbp), %eax
jle 0x22cb4
cvtsi2sdl -0x58(%rbp), %xmm0
movq -0x28(%rbp), %rax
movslq -0x5c(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movl -0x58(%rbp), %eax
cmpl -0x5c(%rbp), %eax
je 0x22cb2
movl $0x0, -0x54(%rbp)
movl -0x54(%rbp), %eax
cmpl -0x5c(%rbp), %eax
jg 0x22c34
movq -0x8(%rbp), %rax
movl -0x54(%rbp), %ecx
imull -0xc(%rbp), %ecx
addl -0x58(%rbp), %ecx
movslq %ecx, %rcx
movsd (%rax,%rcx,8), %xmm0
movsd %xmm0, -0x30(%rbp)
movq -0x8(%rbp), %rax
movl -0x54(%rbp), %ecx
imull -0xc(%rbp), %ecx
addl -0x5c(%rbp), %ecx
movslq %ecx, %rcx
movsd (%rax,%rcx,8), %xmm0
movq -0x8(%rbp), %rax
movl -0x54(%rbp), %ecx
imull -0xc(%rbp), %ecx
addl -0x58(%rbp), %ecx
movslq %ecx, %rcx
movsd %xmm0, (%rax,%rcx,8)
movsd -0x30(%rbp), %xmm0
movq -0x8(%rbp), %rax
movl -0x54(%rbp), %ecx
imull -0xc(%rbp), %ecx
addl -0x5c(%rbp), %ecx
movslq %ecx, %rcx
movsd %xmm0, (%rax,%rcx,8)
movl -0x54(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x54(%rbp)
jmp 0x22bbf
movl $0x0, -0x54(%rbp)
movl -0x54(%rbp), %eax
cmpl -0xc(%rbp), %eax
jge 0x22cb0
movq -0x8(%rbp), %rax
movl -0x58(%rbp), %ecx
imull -0xc(%rbp), %ecx
addl -0x54(%rbp), %ecx
movslq %ecx, %rcx
movsd (%rax,%rcx,8), %xmm0
movsd %xmm0, -0x30(%rbp)
movq -0x8(%rbp), %rax
movl -0x5c(%rbp), %ecx
imull -0xc(%rbp), %ecx
addl -0x54(%rbp), %ecx
movslq %ecx, %rcx
movsd (%rax,%rcx,8), %xmm0
movq -0x8(%rbp), %rax
movl -0x58(%rbp), %ecx
imull -0xc(%rbp), %ecx
addl -0x54(%rbp), %ecx
movslq %ecx, %rcx
movsd %xmm0, (%rax,%rcx,8)
movsd -0x30(%rbp), %xmm0
movq -0x8(%rbp), %rax
movl -0x5c(%rbp), %ecx
imull -0xc(%rbp), %ecx
addl -0x54(%rbp), %ecx
movslq %ecx, %rcx
movsd %xmm0, (%rax,%rcx,8)
movl -0x54(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x54(%rbp)
jmp 0x22c3b
jmp 0x22cb2
jmp 0x22cc4
jmp 0x22cb6
movl -0x58(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x58(%rbp)
jmp 0x22b30
cmpl $0x0, -0x58(%rbp)
jge 0x22ccc
jmp 0x22cdc
jmp 0x22cce
movl -0x5c(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x5c(%rbp)
jmp 0x22b20
movl $0x0, -0x60(%rbp)
movl -0x60(%rbp), %eax
cmpl -0x5c(%rbp), %eax
jg 0x22ea3
movl -0x60(%rbp), %eax
movl %eax, -0x58(%rbp)
movl -0x58(%rbp), %eax
cmpl -0x5c(%rbp), %eax
jg 0x22e89
movl -0x60(%rbp), %eax
movl %eax, -0x54(%rbp)
movl -0x54(%rbp), %eax
cmpl -0x5c(%rbp), %eax
jg 0x22d54
movl -0x54(%rbp), %eax
cmpl -0x58(%rbp), %eax
je 0x22d47
movq -0x8(%rbp), %rax
movl -0x54(%rbp), %ecx
imull -0xc(%rbp), %ecx
addl -0x58(%rbp), %ecx
movslq %ecx, %rcx
movsd (%rax,%rcx,8), %xmm0
movaps 0x1c66c(%rip), %xmm1    # 0x3f3a0
pand %xmm1, %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0x22d45
jp 0x22d45
jmp 0x22d47
jmp 0x22d54
jmp 0x22d49
movl -0x54(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x54(%rbp)
jmp 0x22d07
movl -0x54(%rbp), %eax
cmpl -0x5c(%rbp), %eax
jle 0x22e79
cvtsi2sdl -0x58(%rbp), %xmm0
movq -0x28(%rbp), %rax
movslq -0x60(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movl -0x58(%rbp), %eax
cmpl -0x60(%rbp), %eax
je 0x22e77
movl $0x0, -0x54(%rbp)
movl -0x54(%rbp), %eax
cmpl -0x5c(%rbp), %eax
jg 0x22dfa
movq -0x8(%rbp), %rax
movl -0x54(%rbp), %ecx
imull -0xc(%rbp), %ecx
addl -0x58(%rbp), %ecx
movslq %ecx, %rcx
movsd (%rax,%rcx,8), %xmm0
movsd %xmm0, -0x30(%rbp)
movq -0x8(%rbp), %rax
movl -0x54(%rbp), %ecx
imull -0xc(%rbp), %ecx
addl -0x60(%rbp), %ecx
movslq %ecx, %rcx
movsd (%rax,%rcx,8), %xmm0
movq -0x8(%rbp), %rax
movl -0x54(%rbp), %ecx
imull -0xc(%rbp), %ecx
addl -0x58(%rbp), %ecx
movslq %ecx, %rcx
movsd %xmm0, (%rax,%rcx,8)
movsd -0x30(%rbp), %xmm0
movq -0x8(%rbp), %rax
movl -0x54(%rbp), %ecx
imull -0xc(%rbp), %ecx
addl -0x60(%rbp), %ecx
movslq %ecx, %rcx
movsd %xmm0, (%rax,%rcx,8)
movl -0x54(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x54(%rbp)
jmp 0x22d85
movl -0x60(%rbp), %eax
movl %eax, -0x54(%rbp)
movl -0x54(%rbp), %eax
cmpl -0xc(%rbp), %eax
jge 0x22e75
movq -0x8(%rbp), %rax
movl -0x58(%rbp), %ecx
imull -0xc(%rbp), %ecx
addl -0x54(%rbp), %ecx
movslq %ecx, %rcx
movsd (%rax,%rcx,8), %xmm0
movsd %xmm0, -0x30(%rbp)
movq -0x8(%rbp), %rax
movl -0x60(%rbp), %ecx
imull -0xc(%rbp), %ecx
addl -0x54(%rbp), %ecx
movslq %ecx, %rcx
movsd (%rax,%rcx,8), %xmm0
movq -0x8(%rbp), %rax
movl -0x58(%rbp), %ecx
imull -0xc(%rbp), %ecx
addl -0x54(%rbp), %ecx
movslq %ecx, %rcx
movsd %xmm0, (%rax,%rcx,8)
movsd -0x30(%rbp), %xmm0
movq -0x8(%rbp), %rax
movl -0x60(%rbp), %ecx
imull -0xc(%rbp), %ecx
addl -0x54(%rbp), %ecx
movslq %ecx, %rcx
movsd %xmm0, (%rax,%rcx,8)
movl -0x54(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x54(%rbp)
jmp 0x22e00
jmp 0x22e77
jmp 0x22e89
jmp 0x22e7b
movl -0x58(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x58(%rbp)
jmp 0x22cf5
movl -0x58(%rbp), %eax
cmpl -0x5c(%rbp), %eax
jle 0x22e93
jmp 0x22ea3
jmp 0x22e95
movl -0x60(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x60(%rbp)
jmp 0x22ce3
movl -0x5c(%rbp), %ecx
movq -0x20(%rbp), %rax
movl %ecx, (%rax)
movl -0x60(%rbp), %ecx
movq -0x18(%rbp), %rax
movl %ecx, (%rax)
movl -0x60(%rbp), %eax
movl %eax, -0x54(%rbp)
movl -0x54(%rbp), %eax
cmpl -0x5c(%rbp), %eax
jg 0x22ee3
movq -0x28(%rbp), %rax
movslq -0x54(%rbp), %rcx
movsd 0x1c14d(%rip), %xmm0    # 0x3f020
movsd %xmm0, (%rax,%rcx,8)
movl -0x54(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x54(%rbp)
jmp 0x22ebb
jmp 0x22ee5
movl $0x1, -0x64(%rbp)
movl -0x60(%rbp), %eax
movl %eax, -0x54(%rbp)
movl -0x54(%rbp), %eax
cmpl -0x5c(%rbp), %eax
jg 0x23142
xorps %xmm0, %xmm0
movsd %xmm0, -0x30(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0x48(%rbp)
movl -0x60(%rbp), %eax
movl %eax, -0x58(%rbp)
movl -0x58(%rbp), %eax
cmpl -0x5c(%rbp), %eax
jg 0x22f87
movl -0x58(%rbp), %eax
cmpl -0x54(%rbp), %eax
je 0x22f7a
movq -0x8(%rbp), %rax
movl -0x58(%rbp), %ecx
imull -0xc(%rbp), %ecx
addl -0x54(%rbp), %ecx
movslq %ecx, %rcx
movsd (%rax,%rcx,8), %xmm0
movaps 0x1c45f(%rip), %xmm1    # 0x3f3a0
pand %xmm1, %xmm0
addsd -0x30(%rbp), %xmm0
movsd %xmm0, -0x30(%rbp)
movq -0x8(%rbp), %rax
movl -0x54(%rbp), %ecx
imull -0xc(%rbp), %ecx
addl -0x58(%rbp), %ecx
movslq %ecx, %rcx
movsd (%rax,%rcx,8), %xmm0
movaps 0x1c434(%rip), %xmm1    # 0x3f3a0
pand %xmm1, %xmm0
addsd -0x48(%rbp), %xmm0
movsd %xmm0, -0x48(%rbp)
jmp 0x22f7c
movl -0x58(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x58(%rbp)
jmp 0x22f14
movsd -0x30(%rbp), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0x22f9c
jp 0x22f9c
jmp 0x23132
movsd -0x48(%rbp), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0x22fb1
jp 0x22fb1
jmp 0x23132
movsd -0x48(%rbp), %xmm0
movsd 0x1c08a(%rip), %xmm1    # 0x3f048
divsd %xmm1, %xmm0
movsd %xmm0, -0x40(%rbp)
movsd 0x1c051(%rip), %xmm0    # 0x3f020
movsd %xmm0, -0x38(%rbp)
movsd -0x30(%rbp), %xmm0
addsd -0x48(%rbp), %xmm0
movsd %xmm0, -0x50(%rbp)
movsd -0x30(%rbp), %xmm1
movsd -0x40(%rbp), %xmm0
ucomisd %xmm1, %xmm0
jbe 0x23019
movsd 0x1c04d(%rip), %xmm0    # 0x3f048
mulsd -0x38(%rbp), %xmm0
movsd %xmm0, -0x38(%rbp)
movsd 0x1c04b(%rip), %xmm0    # 0x3f058
mulsd -0x30(%rbp), %xmm0
movsd %xmm0, -0x30(%rbp)
jmp 0x22fe3
movsd 0x1c027(%rip), %xmm0    # 0x3f048
mulsd -0x48(%rbp), %xmm0
movsd %xmm0, -0x40(%rbp)
movsd -0x30(%rbp), %xmm0
ucomisd -0x40(%rbp), %xmm0
jb 0x23065
movsd -0x38(%rbp), %xmm0
movsd 0x1c004(%rip), %xmm1    # 0x3f048
divsd %xmm1, %xmm0
movsd %xmm0, -0x38(%rbp)
movsd -0x30(%rbp), %xmm0
movsd 0x1bffe(%rip), %xmm1    # 0x3f058
divsd %xmm1, %xmm0
movsd %xmm0, -0x30(%rbp)
jmp 0x2302b
movsd -0x30(%rbp), %xmm1
addsd -0x48(%rbp), %xmm1
divsd -0x38(%rbp), %xmm1
movsd 0x23f54(%rip), %xmm0    # 0x46fd0
mulsd -0x50(%rbp), %xmm0
ucomisd %xmm1, %xmm0
jbe 0x23130
movl $0x0, -0x64(%rbp)
movsd 0x1bf86(%rip), %xmm0    # 0x3f020
divsd -0x38(%rbp), %xmm0
movsd %xmm0, -0x40(%rbp)
movsd -0x38(%rbp), %xmm0
movq -0x28(%rbp), %rax
movslq -0x54(%rbp), %rcx
mulsd (%rax,%rcx,8), %xmm0
movsd %xmm0, (%rax,%rcx,8)
movl -0x60(%rbp), %eax
movl %eax, -0x58(%rbp)
movl -0x58(%rbp), %eax
cmpl -0xc(%rbp), %eax
jge 0x230f4
movsd -0x40(%rbp), %xmm0
movq -0x8(%rbp), %rax
movl -0x54(%rbp), %ecx
imull -0xc(%rbp), %ecx
addl -0x58(%rbp), %ecx
movslq %ecx, %rcx
mulsd (%rax,%rcx,8), %xmm0
movsd %xmm0, (%rax,%rcx,8)
movl -0x58(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x58(%rbp)
jmp 0x230c1
movl $0x0, -0x58(%rbp)
movl -0x58(%rbp), %eax
cmpl -0x5c(%rbp), %eax
jg 0x2312e
movsd -0x38(%rbp), %xmm0
movq -0x8(%rbp), %rax
movl -0x58(%rbp), %ecx
imull -0xc(%rbp), %ecx
addl -0x54(%rbp), %ecx
movslq %ecx, %rcx
mulsd (%rax,%rcx,8), %xmm0
movsd %xmm0, (%rax,%rcx,8)
movl -0x58(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x58(%rbp)
jmp 0x230fb
jmp 0x23130
jmp 0x23132
jmp 0x23134
movl -0x54(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x54(%rbp)
jmp 0x22ef2
jmp 0x23144
cmpl $0x0, -0x64(%rbp)
setne %al
xorb $-0x1, %al
testb $0x1, %al
jne 0x22ee5
popq %rbp
retq
nopw (%rax,%rax)