// File: /workspace/github_c_makefile_star2_O0/ugobas[P]tnm/d_diagonalize.c
// Function: Select_modes_coll
void Select_modes_coll(int *selected, double *eigen_va, double **eigen_vt,
		       float E_MIN, float COLL_THR, int N)
{
  /* printf("Discarding modes with e_val/<e_val> < %.2g ", E_MIN*0.001);
     printf(" or e_val/<e_val> < %.2g, coll < %.f\n",E_MIN, COLL_THR);
     int n=0; */
  float E_THR=E_MIN; int i, j;
  double e=0; for(j=1; j<=N; j++)e+=eigen_va[j];
  if(e<0){e=-e;} E_THR*=(e/N);
  float E_THR2=E_THR*0.001;
  for(i=1; i<=N; i++){
    selected[i]=1;
    if(eigen_va[i]<E_THR){
      if(eigen_va[i]<E_THR2){
	selected[i]=0;
      }else{
	double sum=0, Entropy=0;
	for(j=1; j<=N; j++){
	  float v=eigen_vt[j][i];
	  if(v){v*=v; sum+=v; Entropy-=v*log(v);}
	}
	float c=sum*exp(Entropy/sum);
	if(c<COLL_THR){
	  selected[i]=0;
	  //printf("%.1f %f\n", c, eigen_va[i]); n++;
	}
      }
    }
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movss %xmm0, -0x1c(%rbp)
movss %xmm1, -0x20(%rbp)
movl %ecx, -0x24(%rbp)
movss -0x1c(%rbp), %xmm0
movss %xmm0, -0x28(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0x38(%rbp)
movl $0x1, -0x30(%rbp)
movl -0x30(%rbp), %eax
cmpl -0x24(%rbp), %eax
jg 0x6b804
movq -0x10(%rbp), %rax
movslq -0x30(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
addsd -0x38(%rbp), %xmm0
movsd %xmm0, -0x38(%rbp)
movl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
jmp 0x6b7da
xorps %xmm0, %xmm0
ucomisd -0x38(%rbp), %xmm0
jbe 0x6b82f
movsd -0x38(%rbp), %xmm0
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
movsd %xmm0, -0x38(%rbp)
movsd -0x38(%rbp), %xmm1
cvtsi2sdl -0x24(%rbp), %xmm0
divsd %xmm0, %xmm1
movss -0x28(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
mulsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, -0x28(%rbp)
movss -0x28(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
movsd 0x10bfc(%rip), %xmm1    # 0x7c460
mulsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, -0x3c(%rbp)
movl $0x1, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
cmpl -0x24(%rbp), %eax
jg 0x6ba14
movq -0x8(%rbp), %rax
movslq -0x2c(%rbp), %rcx
movl $0x1, (%rax,%rcx,4)
movq -0x10(%rbp), %rax
movslq -0x2c(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm1
movss -0x28(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
ucomisd %xmm1, %xmm0
jbe 0x6ba04
movq -0x10(%rbp), %rax
movslq -0x2c(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm1
movss -0x3c(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
ucomisd %xmm1, %xmm0
jbe 0x6b8e3
movq -0x8(%rbp), %rax
movslq -0x2c(%rbp), %rcx
movl $0x0, (%rax,%rcx,4)
jmp 0x6ba02
xorps %xmm0, %xmm0
movsd %xmm0, -0x48(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0x50(%rbp)
movl $0x1, -0x30(%rbp)
movl -0x30(%rbp), %eax
cmpl -0x24(%rbp), %eax
jg 0x6b9b4
movq -0x18(%rbp), %rax
movslq -0x30(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x2c(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, -0x54(%rbp)
movss -0x54(%rbp), %xmm0
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jne 0x6b935
jp 0x6b935
jmp 0x6b9a4
movss -0x54(%rbp), %xmm0
mulss -0x54(%rbp), %xmm0
movss %xmm0, -0x54(%rbp)
movss -0x54(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
addsd -0x48(%rbp), %xmm0
movsd %xmm0, -0x48(%rbp)
movss -0x54(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
movsd %xmm0, -0x60(%rbp)
movss -0x54(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
callq 0x10f0
movaps %xmm0, %xmm2
movsd -0x60(%rbp), %xmm0
movsd -0x50(%rbp), %xmm1
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x50(%rbp)
jmp 0x6b9a6
movl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
jmp 0x6b8fa
movsd -0x48(%rbp), %xmm0
movsd %xmm0, -0x68(%rbp)
movsd -0x50(%rbp), %xmm0
divsd -0x48(%rbp), %xmm0
callq 0x1230
movaps %xmm0, %xmm1
movsd -0x68(%rbp), %xmm0
mulsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, -0x58(%rbp)
movss -0x58(%rbp), %xmm1
movss -0x20(%rbp), %xmm0
ucomiss %xmm1, %xmm0
jbe 0x6ba00
movq -0x8(%rbp), %rax
movslq -0x2c(%rbp), %rcx
movl $0x0, (%rax,%rcx,4)
jmp 0x6ba02
jmp 0x6ba04
jmp 0x6ba06
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x6b878
addq $0x70, %rsp
popq %rbp
retq
nopw (%rax,%rax)