// File: /workspace/github_c_makefile_star2_O0/dapogon[P]cellcoal/src/eigen.c
// Function: eigen
int eigen(int job, double AA[], int n, double rr[], double ri[], double vr[], double vi[], double work[])
{
/*  double work[n*2]: working space
*/
    int low,hi,i,j,k, it, istate=0;
    double tiny=sqrt(pow((double)BASE,(double)(1-DIGITS))), t;

    balance(AA,n,&low,&hi,work);
    elemhess(job,AA,n,low,hi,vr,vi, (int*)(work+n));
    if (-1 == realeig(job,AA,n,low,hi,rr,ri,vr,vi)) return (-1);
    if (job) unbalance(n,vr,vi,low,hi,work);

/* sort, added by Z. Yang */
   for (i=0; i<n; i++) {
       for (j=i+1,it=i,t=rr[i]; j<n; j++)
           if (t<rr[j]) { t=rr[j]; it=j; }
       rr[it]=rr[i];   rr[i]=t;
       t=ri[it];       ri[it]=ri[i];  ri[i]=t;
       for (k=0; k<n; k++) {
          t=vr[k*n+it];  vr[k*n+it]=vr[k*n+i];  vr[k*n+i]=t;
          t=vi[k*n+it];  vi[k*n+it]=vi[k*n+i];  vi[k*n+i]=t;
       }
       if (fabs(ri[i])>tiny) istate=1;
   }

    return (istate) ;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x80, %rsp
movq 0x18(%rbp), %rax
movq 0x10(%rbp), %rax
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
movq %r9, -0x30(%rbp)
movl $0x0, -0x4c(%rbp)
movsd 0x1cc90(%rip), %xmm0    # 0x3f048
movsd 0x24c00(%rip), %xmm1    # 0x46fc0
callq 0x20c0
callq 0x22a0
movsd %xmm0, -0x58(%rbp)
movq -0x10(%rbp), %rdi
movl -0x14(%rbp), %esi
movq 0x18(%rbp), %r8
leaq -0x34(%rbp), %rdx
leaq -0x38(%rbp), %rcx
callq 0x22b00
movl -0x8(%rbp), %edi
movq -0x10(%rbp), %rsi
movl -0x14(%rbp), %edx
movl -0x34(%rbp), %ecx
movl -0x38(%rbp), %r8d
movq -0x30(%rbp), %r9
movq 0x10(%rbp), %r10
movq 0x18(%rbp), %rax
movslq -0x14(%rbp), %r11
shlq $0x3, %r11
addq %r11, %rax
movq %r10, (%rsp)
movq %rax, 0x8(%rsp)
callq 0x23160
movl -0x8(%rbp), %edi
movq -0x10(%rbp), %rsi
movl -0x14(%rbp), %edx
movl -0x34(%rbp), %ecx
movl -0x38(%rbp), %r8d
movq -0x20(%rbp), %r9
movq -0x28(%rbp), %r11
movq -0x30(%rbp), %r10
movq 0x10(%rbp), %rax
movq %r11, (%rsp)
movq %r10, 0x8(%rsp)
movq %rax, 0x10(%rsp)
callq 0x23640
movl %eax, %ecx
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
cmpl %ecx, %eax
jne 0x22468
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x2268d
cmpl $0x0, -0x8(%rbp)
je 0x22489
movl -0x14(%rbp), %edi
movq -0x30(%rbp), %rsi
movq 0x10(%rbp), %rdx
movl -0x34(%rbp), %ecx
movl -0x38(%rbp), %r8d
movq 0x18(%rbp), %r9
callq 0x260c0
movl $0x0, -0x3c(%rbp)
movl -0x3c(%rbp), %eax
cmpl -0x14(%rbp), %eax
jge 0x22687
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x40(%rbp)
movl -0x3c(%rbp), %eax
movl %eax, -0x48(%rbp)
movq -0x20(%rbp), %rax
movslq -0x3c(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movsd %xmm0, -0x60(%rbp)
movl -0x40(%rbp), %eax
cmpl -0x14(%rbp), %eax
jge 0x22502
movsd -0x60(%rbp), %xmm1
movq -0x20(%rbp), %rax
movslq -0x40(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
ucomisd %xmm1, %xmm0
jbe 0x224f5
movq -0x20(%rbp), %rax
movslq -0x40(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movsd %xmm0, -0x60(%rbp)
movl -0x40(%rbp), %eax
movl %eax, -0x48(%rbp)
jmp 0x224f7
movl -0x40(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x40(%rbp)
jmp 0x224bd
movq -0x20(%rbp), %rax
movslq -0x3c(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movq -0x20(%rbp), %rax
movslq -0x48(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movsd -0x60(%rbp), %xmm0
movq -0x20(%rbp), %rax
movslq -0x3c(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movq -0x28(%rbp), %rax
movslq -0x48(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movsd %xmm0, -0x60(%rbp)
movq -0x28(%rbp), %rax
movslq -0x3c(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movq -0x28(%rbp), %rax
movslq -0x48(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movsd -0x60(%rbp), %xmm0
movq -0x28(%rbp), %rax
movslq -0x3c(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movl $0x0, -0x44(%rbp)
movl -0x44(%rbp), %eax
cmpl -0x14(%rbp), %eax
jge 0x22651
movq -0x30(%rbp), %rax
movl -0x44(%rbp), %ecx
imull -0x14(%rbp), %ecx
addl -0x48(%rbp), %ecx
movslq %ecx, %rcx
movsd (%rax,%rcx,8), %xmm0
movsd %xmm0, -0x60(%rbp)
movq -0x30(%rbp), %rax
movl -0x44(%rbp), %ecx
imull -0x14(%rbp), %ecx
addl -0x3c(%rbp), %ecx
movslq %ecx, %rcx
movsd (%rax,%rcx,8), %xmm0
movq -0x30(%rbp), %rax
movl -0x44(%rbp), %ecx
imull -0x14(%rbp), %ecx
addl -0x48(%rbp), %ecx
movslq %ecx, %rcx
movsd %xmm0, (%rax,%rcx,8)
movsd -0x60(%rbp), %xmm0
movq -0x30(%rbp), %rax
movl -0x44(%rbp), %ecx
imull -0x14(%rbp), %ecx
addl -0x3c(%rbp), %ecx
movslq %ecx, %rcx
movsd %xmm0, (%rax,%rcx,8)
movq 0x10(%rbp), %rax
movl -0x44(%rbp), %ecx
imull -0x14(%rbp), %ecx
addl -0x48(%rbp), %ecx
movslq %ecx, %rcx
movsd (%rax,%rcx,8), %xmm0
movsd %xmm0, -0x60(%rbp)
movq 0x10(%rbp), %rax
movl -0x44(%rbp), %ecx
imull -0x14(%rbp), %ecx
addl -0x3c(%rbp), %ecx
movslq %ecx, %rcx
movsd (%rax,%rcx,8), %xmm0
movq 0x10(%rbp), %rax
movl -0x44(%rbp), %ecx
imull -0x14(%rbp), %ecx
addl -0x48(%rbp), %ecx
movslq %ecx, %rcx
movsd %xmm0, (%rax,%rcx,8)
movsd -0x60(%rbp), %xmm0
movq 0x10(%rbp), %rax
movl -0x44(%rbp), %ecx
imull -0x14(%rbp), %ecx
addl -0x3c(%rbp), %ecx
movslq %ecx, %rcx
movsd %xmm0, (%rax,%rcx,8)
movl -0x44(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x44(%rbp)
jmp 0x22573
movq -0x28(%rbp), %rax
movslq -0x3c(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movaps 0x1cd3b(%rip), %xmm1    # 0x3f3a0
pand %xmm1, %xmm0
ucomisd -0x58(%rbp), %xmm0
jbe 0x22677
movl $0x1, -0x4c(%rbp)
jmp 0x22679
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x22490
movl -0x4c(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x80, %rsp
popq %rbp
retq
nopl (%rax)