// File: /workspace/github_c_makefile_star2_O0/ugobas[P]tnm/nma.c
// Function: Compare_modes
void Compare_modes(float **Cart_mode_ANM, float **Cart_mode_TNM, int N_Cart,
		   float **Tors_mode_ANM, float **Tors_mode_TNM, int N_tors,
		   float *mass_coord, char *prot_name, char *inter)
{
  // Compare torsional and cartesian normal modes
  int ia, i;
  float q;
  float *Ovlp_cart_max_TNM=malloc(N_tors*sizeof(float));
  float *Ovlp_tors_max_TNM=malloc(N_tors*sizeof(float));
  float *Ovlp_cart_max_ANM=malloc(N_Cart*sizeof(float));
  float *Ovlp_tors_max_ANM=malloc(N_Cart*sizeof(float));
  int *mode_cart_max_TNM=malloc(N_tors*sizeof(int));
  int *mode_tors_max_TNM=malloc(N_tors*sizeof(int));
  int *mode_cart_max_ANM=malloc(N_Cart*sizeof(int));
  int *mode_tors_max_ANM=malloc(N_Cart*sizeof(int));

  FILE *file_out; char outfile[200];

  sprintf(outfile, "%s_%s_compare.dat", prot_name, inter);
  file_out=fopen(outfile, "w");
  printf("Writing %s\n", outfile);

  for(i=0; i<N_tors; i++){
    Ovlp_cart_max_TNM[i]=0;
    Ovlp_tors_max_TNM[i]=0;
  }
  for(i=0; i<N_Cart; i++){
    Ovlp_cart_max_ANM[i]=0;
    Ovlp_tors_max_ANM[i]=0;
  }
  // Normalize
  for(i=0; i<N_tors; i++){
    Normalize_vector_weighted(Cart_mode_TNM[i], mass_coord, N_Cart);
    Normalize_vector(Tors_mode_TNM[i], N_tors);
  }
  for(i=0; i<N_Cart; i++){
    Normalize_vector_weighted(Cart_mode_ANM[i], mass_coord, N_Cart);
    Normalize_vector(Tors_mode_ANM[i], N_tors);
  }

  for(ia=0; ia<N_tors; ia++){
    float *Ca=Cart_mode_TNM[ia];
    for(i=0; i<N_Cart; i++){
      q=Scalar_product_weighted(Ca, Cart_mode_ANM[i], mass_coord, N_Cart);
      q*=q;
      if(q > Ovlp_cart_max_TNM[ia]){
	Ovlp_cart_max_TNM[ia]=q; mode_cart_max_TNM[ia]=i;
      }
      if(q > Ovlp_cart_max_ANM[i] ){
	Ovlp_cart_max_ANM[i]=q; mode_cart_max_ANM[i]=ia;
      }
    }
  }
  for(ia=0; ia<N_tors; ia++){
    float *Ta=Tors_mode_TNM[ia];
    for(i=0; i<N_Cart; i++){
      q=Scalar_product(Ta, Tors_mode_ANM[i],N_tors); q*=q;
      if(q > Ovlp_tors_max_TNM[ia]){
	Ovlp_tors_max_TNM[ia]=q; mode_tors_max_TNM[ia]=i;
      }
      if(q > Ovlp_tors_max_ANM[i] ){
	Ovlp_tors_max_ANM[i]=q; mode_tors_max_ANM[i]=ia;
      }
    }
  }

  fprintf(file_out, "# Max. coeff Cartesian TNM - ANM modes\n");
  fprintf(file_out, "# TNM_mode  Max.coeff^2 ANM_mode\n");
  for(i=0; i<N_tors; i++)
    fprintf(file_out, "%3d  %.3f %3d\n",
	    i, Ovlp_cart_max_TNM[i], mode_cart_max_TNM[i]);
  fprintf(file_out, "&\n");

  fprintf(file_out, "# Max. coeff Torsional TNM - ANM modes\n");
  fprintf(file_out, "# TNM_mode  Max.coeff^2 ANM_mode\n");
  for(i=0; i<N_tors; i++)
    fprintf(file_out, "%3d\t%.3f\t%3d\n",
	    i, Ovlp_tors_max_TNM[i], mode_tors_max_TNM[i]);
  fprintf(file_out, "&\n");

  fprintf(file_out, "# Max. coeff Cartesian ANM - TNM modes\n");
  fprintf(file_out, "# ANM_mode  Max.coeff^2  TNM_mode\n");
  for(i=0; i<N_Cart; i++)
    fprintf(file_out, "%3d\t%.3f\t%3d\n",
	    i, Ovlp_cart_max_ANM[i], mode_cart_max_ANM[i]);
  fprintf(file_out, "&\n");

  fprintf(file_out, "# Max. coeff Torsional ANM - TNM modes\n");
  fprintf(file_out, "# ANM_mode  Max.coeff^2  TNM_mode\n");
  for(i=0; i<N_Cart; i++)
    fprintf(file_out, "%3d\t%.3f\t%3d\n",
	    i, Ovlp_tors_max_ANM[i], mode_tors_max_ANM[i]);
  fprintf(file_out, "&\n");

  fclose(file_out);
  free(Ovlp_cart_max_TNM); free(mode_cart_max_TNM);
  free(Ovlp_tors_max_TNM); free(mode_tors_max_TNM);
  free(Ovlp_cart_max_ANM); free(mode_cart_max_ANM);
  free(Ovlp_tors_max_ANM); free(mode_tors_max_ANM);

}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x160, %rsp            # imm = 0x160
movq 0x20(%rbp), %rax
movq 0x18(%rbp), %rax
movq 0x10(%rbp), %rax
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
movl %r9d, -0x2c(%rbp)
movslq -0x2c(%rbp), %rdi
shlq $0x2, %rdi
callq 0x1180
movq %rax, -0x40(%rbp)
movslq -0x2c(%rbp), %rdi
shlq $0x2, %rdi
callq 0x1180
movq %rax, -0x48(%rbp)
movslq -0x14(%rbp), %rdi
shlq $0x2, %rdi
callq 0x1180
movq %rax, -0x50(%rbp)
movslq -0x14(%rbp), %rdi
shlq $0x2, %rdi
callq 0x1180
movq %rax, -0x58(%rbp)
movslq -0x2c(%rbp), %rdi
shlq $0x2, %rdi
callq 0x1180
movq %rax, -0x60(%rbp)
movslq -0x2c(%rbp), %rdi
shlq $0x2, %rdi
callq 0x1180
movq %rax, -0x68(%rbp)
movslq -0x14(%rbp), %rdi
shlq $0x2, %rdi
callq 0x1180
movq %rax, -0x70(%rbp)
movslq -0x14(%rbp), %rdi
shlq $0x2, %rdi
callq 0x1180
movq %rax, -0x78(%rbp)
leaq -0x150(%rbp), %rdi
movq 0x18(%rbp), %rdx
movq 0x20(%rbp), %rcx
leaq 0x4450f(%rip), %rsi     # 0x7e15b
movb $0x0, %al
callq 0x1200
leaq -0x150(%rbp), %rdi
leaq 0x42711(%rip), %rsi     # 0x7c372
callq 0x11b0
movq %rax, -0x80(%rbp)
leaq -0x150(%rbp), %rsi
leaq 0x3d876(%rip), %rdi     # 0x774ee
movb $0x0, %al
callq 0x10d0
movl $0x0, -0x34(%rbp)
movl -0x34(%rbp), %eax
cmpl -0x2c(%rbp), %eax
jge 0x39cb9
movq -0x40(%rbp), %rax
movslq -0x34(%rbp), %rcx
xorps %xmm0, %xmm0
movss %xmm0, (%rax,%rcx,4)
movq -0x48(%rbp), %rax
movslq -0x34(%rbp), %rcx
xorps %xmm0, %xmm0
movss %xmm0, (%rax,%rcx,4)
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x39c86
movl $0x0, -0x34(%rbp)
movl -0x34(%rbp), %eax
cmpl -0x14(%rbp), %eax
jge 0x39cf3
movq -0x50(%rbp), %rax
movslq -0x34(%rbp), %rcx
xorps %xmm0, %xmm0
movss %xmm0, (%rax,%rcx,4)
movq -0x58(%rbp), %rax
movslq -0x34(%rbp), %rcx
xorps %xmm0, %xmm0
movss %xmm0, (%rax,%rcx,4)
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x39cc0
movl $0x0, -0x34(%rbp)
movl -0x34(%rbp), %eax
cmpl -0x2c(%rbp), %eax
jge 0x39d39
movq -0x10(%rbp), %rax
movslq -0x34(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
movq 0x10(%rbp), %rsi
movl -0x14(%rbp), %edx
callq 0x15650
movq -0x28(%rbp), %rax
movslq -0x34(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
movl -0x2c(%rbp), %esi
callq 0x155c0
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x39cfa
movl $0x0, -0x34(%rbp)
movl -0x34(%rbp), %eax
cmpl -0x14(%rbp), %eax
jge 0x39d7f
movq -0x8(%rbp), %rax
movslq -0x34(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
movq 0x10(%rbp), %rsi
movl -0x14(%rbp), %edx
callq 0x15650
movq -0x20(%rbp), %rax
movslq -0x34(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
movl -0x2c(%rbp), %esi
callq 0x155c0
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x39d40
movl $0x0, -0x30(%rbp)
movl -0x30(%rbp), %eax
cmpl -0x2c(%rbp), %eax
jge 0x39e71
movq -0x10(%rbp), %rax
movslq -0x30(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x158(%rbp)
movl $0x0, -0x34(%rbp)
movl -0x34(%rbp), %eax
cmpl -0x14(%rbp), %eax
jge 0x39e61
movq -0x158(%rbp), %rdi
movq -0x8(%rbp), %rax
movslq -0x34(%rbp), %rcx
movq (%rax,%rcx,8), %rsi
movq 0x10(%rbp), %rdx
movl -0x14(%rbp), %ecx
callq 0x15510
movss %xmm0, -0x38(%rbp)
movss -0x38(%rbp), %xmm0
mulss -0x38(%rbp), %xmm0
movss %xmm0, -0x38(%rbp)
movss -0x38(%rbp), %xmm0
movq -0x40(%rbp), %rax
movslq -0x30(%rbp), %rcx
ucomiss (%rax,%rcx,4), %xmm0
jbe 0x39e1e
movss -0x38(%rbp), %xmm0
movq -0x40(%rbp), %rax
movslq -0x30(%rbp), %rcx
movss %xmm0, (%rax,%rcx,4)
movl -0x34(%rbp), %edx
movq -0x60(%rbp), %rax
movslq -0x30(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
movss -0x38(%rbp), %xmm0
movq -0x50(%rbp), %rax
movslq -0x34(%rbp), %rcx
ucomiss (%rax,%rcx,4), %xmm0
jbe 0x39e51
movss -0x38(%rbp), %xmm0
movq -0x50(%rbp), %rax
movslq -0x34(%rbp), %rcx
movss %xmm0, (%rax,%rcx,4)
movl -0x30(%rbp), %edx
movq -0x70(%rbp), %rax
movslq -0x34(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
jmp 0x39e53
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x39dac
jmp 0x39e63
movl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
jmp 0x39d86
movl $0x0, -0x30(%rbp)
movl -0x30(%rbp), %eax
cmpl -0x2c(%rbp), %eax
jge 0x39f5f
movq -0x28(%rbp), %rax
movslq -0x30(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x160(%rbp)
movl $0x0, -0x34(%rbp)
movl -0x34(%rbp), %eax
cmpl -0x14(%rbp), %eax
jge 0x39f4f
movq -0x160(%rbp), %rdi
movq -0x20(%rbp), %rax
movslq -0x34(%rbp), %rcx
movq (%rax,%rcx,8), %rsi
movl -0x2c(%rbp), %edx
callq 0x15480
movss %xmm0, -0x38(%rbp)
movss -0x38(%rbp), %xmm0
mulss -0x38(%rbp), %xmm0
movss %xmm0, -0x38(%rbp)
movss -0x38(%rbp), %xmm0
movq -0x48(%rbp), %rax
movslq -0x30(%rbp), %rcx
ucomiss (%rax,%rcx,4), %xmm0
jbe 0x39f0c
movss -0x38(%rbp), %xmm0
movq -0x48(%rbp), %rax
movslq -0x30(%rbp), %rcx
movss %xmm0, (%rax,%rcx,4)
movl -0x34(%rbp), %edx
movq -0x68(%rbp), %rax
movslq -0x30(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
movss -0x38(%rbp), %xmm0
movq -0x58(%rbp), %rax
movslq -0x34(%rbp), %rcx
ucomiss (%rax,%rcx,4), %xmm0
jbe 0x39f3f
movss -0x38(%rbp), %xmm0
movq -0x58(%rbp), %rax
movslq -0x34(%rbp), %rcx
movss %xmm0, (%rax,%rcx,4)
movl -0x30(%rbp), %edx
movq -0x78(%rbp), %rax
movslq -0x34(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
jmp 0x39f41
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x39e9e
jmp 0x39f51
movl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
jmp 0x39e78
movq -0x80(%rbp), %rdi
leaq 0x44203(%rip), %rsi     # 0x7e16d
movb $0x0, %al
callq 0x1150
movq -0x80(%rbp), %rdi
leaq 0x44219(%rip), %rsi     # 0x7e195
movb $0x0, %al
callq 0x1150
movl $0x0, -0x34(%rbp)
movl -0x34(%rbp), %eax
cmpl -0x2c(%rbp), %eax
jge 0x39fce
movq -0x80(%rbp), %rdi
movl -0x34(%rbp), %edx
movq -0x40(%rbp), %rax
movslq -0x34(%rbp), %rcx
movss (%rax,%rcx,4), %xmm0
cvtss2sd %xmm0, %xmm0
movq -0x60(%rbp), %rax
movslq -0x34(%rbp), %rcx
movl (%rax,%rcx,4), %ecx
leaq 0x441fb(%rip), %rsi     # 0x7e1b7
movb $0x1, %al
callq 0x1150
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x39f8a
movq -0x80(%rbp), %rdi
leaq 0x433bb(%rip), %rsi     # 0x7d394
movb $0x0, %al
callq 0x1150
movq -0x80(%rbp), %rdi
leaq 0x441db(%rip), %rsi     # 0x7e1c6
movb $0x0, %al
callq 0x1150
movq -0x80(%rbp), %rdi
leaq 0x44198(%rip), %rsi     # 0x7e195
movb $0x0, %al
callq 0x1150
movl $0x0, -0x34(%rbp)
movl -0x34(%rbp), %eax
cmpl -0x2c(%rbp), %eax
jge 0x3a04f
movq -0x80(%rbp), %rdi
movl -0x34(%rbp), %edx
movq -0x48(%rbp), %rax
movslq -0x34(%rbp), %rcx
movss (%rax,%rcx,4), %xmm0
cvtss2sd %xmm0, %xmm0
movq -0x68(%rbp), %rax
movslq -0x34(%rbp), %rcx
movl (%rax,%rcx,4), %ecx
leaq 0x441b1(%rip), %rsi     # 0x7e1ee
movb $0x1, %al
callq 0x1150
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x3a00b
movq -0x80(%rbp), %rdi
leaq 0x4333a(%rip), %rsi     # 0x7d394
movb $0x0, %al
callq 0x1150
movq -0x80(%rbp), %rdi
leaq 0x44190(%rip), %rsi     # 0x7e1fc
movb $0x0, %al
callq 0x1150
movq -0x80(%rbp), %rdi
leaq 0x441a6(%rip), %rsi     # 0x7e224
movb $0x0, %al
callq 0x1150
movl $0x0, -0x34(%rbp)
movl -0x34(%rbp), %eax
cmpl -0x14(%rbp), %eax
jge 0x3a0d0
movq -0x80(%rbp), %rdi
movl -0x34(%rbp), %edx
movq -0x50(%rbp), %rax
movslq -0x34(%rbp), %rcx
movss (%rax,%rcx,4), %xmm0
cvtss2sd %xmm0, %xmm0
movq -0x70(%rbp), %rax
movslq -0x34(%rbp), %rcx
movl (%rax,%rcx,4), %ecx
leaq 0x44130(%rip), %rsi     # 0x7e1ee
movb $0x1, %al
callq 0x1150
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x3a08c
movq -0x80(%rbp), %rdi
leaq 0x432b9(%rip), %rsi     # 0x7d394
movb $0x0, %al
callq 0x1150
movq -0x80(%rbp), %rdi
leaq 0x4415a(%rip), %rsi     # 0x7e247
movb $0x0, %al
callq 0x1150
movq -0x80(%rbp), %rdi
leaq 0x44125(%rip), %rsi     # 0x7e224
movb $0x0, %al
callq 0x1150
movl $0x0, -0x34(%rbp)
movl -0x34(%rbp), %eax
cmpl -0x14(%rbp), %eax
jge 0x3a151
movq -0x80(%rbp), %rdi
movl -0x34(%rbp), %edx
movq -0x58(%rbp), %rax
movslq -0x34(%rbp), %rcx
movss (%rax,%rcx,4), %xmm0
cvtss2sd %xmm0, %xmm0
movq -0x78(%rbp), %rax
movslq -0x34(%rbp), %rcx
movl (%rax,%rcx,4), %ecx
leaq 0x440af(%rip), %rsi     # 0x7e1ee
movb $0x1, %al
callq 0x1150
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x3a10d
movq -0x80(%rbp), %rdi
leaq 0x43238(%rip), %rsi     # 0x7d394
movb $0x0, %al
callq 0x1150
movq -0x80(%rbp), %rdi
callq 0x10a0
movq -0x40(%rbp), %rdi
callq 0x1040
movq -0x60(%rbp), %rdi
callq 0x1040
movq -0x48(%rbp), %rdi
callq 0x1040
movq -0x68(%rbp), %rdi
callq 0x1040
movq -0x50(%rbp), %rdi
callq 0x1040
movq -0x70(%rbp), %rdi
callq 0x1040
movq -0x58(%rbp), %rdi
callq 0x1040
movq -0x78(%rbp), %rdi
callq 0x1040
addq $0x160, %rsp            # imm = 0x160
popq %rbp
retq
nopl (%rax)