// File: /workspace/github_c_makefile_star2_O0/ugobas[P]tnm/nma.c
// Function: Transform_tors_modes
void Transform_tors_modes(float *Tors_mode, float *Masswtd_Tors_mode,
			  float **T_sqrt_tr, float **T_sqrt_inv_tr,
			  int N_modes, int N_axes)
{
  int ib, j;
  float *Mw_ev=Masswtd_Tors_mode;
  float *ev=Tors_mode;

  if(KINETIC==0){
    for(ib=0; ib<N_modes; ib++){
      *ev=*Mw_ev; ev++; Mw_ev++;
    }
  }else if(T_sqrt_inv_tr){
    // ev= T_sqrt_inv Masswtd_ev
    for(ib=0; ib<N_axes; ib++){
      double sum=0; float *t=T_sqrt_inv_tr[ib];
      Mw_ev=Masswtd_Tors_mode;
      for(j=0; j<N_modes; j++){
	sum+=(*Mw_ev)*(*t); Mw_ev++; t++;
      }
      *ev=sum; ev++;
    }
  }else{
    // Solve (L^t)EV = Mw_EV by backward_substitution
    // x_i =(v_i - sum_j>i L_ji x_j)/L_ii
    double x[N_modes];
    int nn=N_modes-1;
    double *x1=x+nn; Mw_ev=Masswtd_Tors_mode+nn; ev=Tors_mode+nn;
    for(ib=nn; ib>=0; ib--){
      *x1=*Mw_ev; double *x2=x1+1; float *t=T_sqrt_tr[ib]+ib+1;
      for(j=ib+1; j<N_modes; j++){*x1-= (*x2)*(*t); t++; x2++;}
      (*x1)/=T_sqrt_tr[ib][ib];
      *ev=*x1; ev--; Mw_ev--; x1--;
    }
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x80, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movl %r8d, -0x24(%rbp)
movl %r9d, -0x28(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x40(%rbp)
leaq 0x58c2a(%rip), %rax     # 0x8b5c4
cmpl $0x0, (%rax)
jne 0x329e6
movl $0x0, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
cmpl -0x24(%rbp), %eax
jge 0x329e1
movq -0x38(%rbp), %rax
movss (%rax), %xmm0
movq -0x40(%rbp), %rax
movss %xmm0, (%rax)
movq -0x40(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x40(%rbp)
movq -0x38(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x38(%rbp)
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x329a6
jmp 0x32c41
cmpq $0x0, -0x20(%rbp)
je 0x32aa4
movl $0x0, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
cmpl -0x28(%rbp), %eax
jge 0x32a9f
xorps %xmm0, %xmm0
movsd %xmm0, -0x48(%rbp)
movq -0x20(%rbp), %rax
movslq -0x2c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x50(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x38(%rbp)
movl $0x0, -0x30(%rbp)
movl -0x30(%rbp), %eax
cmpl -0x24(%rbp), %eax
jge 0x32a74
movq -0x38(%rbp), %rax
movss (%rax), %xmm0
movq -0x50(%rbp), %rax
mulss (%rax), %xmm0
cvtss2sd %xmm0, %xmm0
addsd -0x48(%rbp), %xmm0
movsd %xmm0, -0x48(%rbp)
movq -0x38(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x38(%rbp)
movq -0x50(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x50(%rbp)
movl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
jmp 0x32a2b
movsd -0x48(%rbp), %xmm0
cvtsd2ss %xmm0, %xmm0
movq -0x40(%rbp), %rax
movss %xmm0, (%rax)
movq -0x40(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x40(%rbp)
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x329f8
jmp 0x32c3f
movl -0x24(%rbp), %eax
movl %eax, %ecx
movq %rsp, %rax
movq %rax, -0x58(%rbp)
leaq 0xf(,%rcx,8), %rdx
andq $-0x10, %rdx
movq %rsp, %rax
subq %rdx, %rax
movq %rax, %rsp
movq %rcx, -0x60(%rbp)
movl -0x24(%rbp), %ecx
subl $0x1, %ecx
movl %ecx, -0x64(%rbp)
movslq -0x64(%rbp), %rcx
shlq $0x3, %rcx
addq %rcx, %rax
movq %rax, -0x70(%rbp)
movq -0x10(%rbp), %rax
movslq -0x64(%rbp), %rcx
shlq $0x2, %rcx
addq %rcx, %rax
movq %rax, -0x38(%rbp)
movq -0x8(%rbp), %rax
movslq -0x64(%rbp), %rcx
shlq $0x2, %rcx
addq %rcx, %rax
movq %rax, -0x40(%rbp)
movl -0x64(%rbp), %eax
movl %eax, -0x2c(%rbp)
cmpl $0x0, -0x2c(%rbp)
jl 0x32c38
movq -0x38(%rbp), %rax
movss (%rax), %xmm0
cvtss2sd %xmm0, %xmm0
movq -0x70(%rbp), %rax
movsd %xmm0, (%rax)
movq -0x70(%rbp), %rax
addq $0x8, %rax
movq %rax, -0x78(%rbp)
movq -0x18(%rbp), %rax
movslq -0x2c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x2c(%rbp), %rcx
shlq $0x2, %rcx
addq %rcx, %rax
addq $0x4, %rax
movq %rax, -0x80(%rbp)
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
movl -0x30(%rbp), %eax
cmpl -0x24(%rbp), %eax
jge 0x32bc9
movq -0x78(%rbp), %rax
movsd (%rax), %xmm0
movq -0x80(%rbp), %rax
movss (%rax), %xmm1
cvtss2sd %xmm1, %xmm2
movq -0x70(%rbp), %rax
movsd (%rax), %xmm1
movq %xmm0, %rcx
movabsq $-0x8000000000000000, %rdx # imm = 0x8000000000000000
xorq %rdx, %rcx
movq %rcx, %xmm0
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, (%rax)
movq -0x80(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x80(%rbp)
movq -0x78(%rbp), %rax
addq $0x8, %rax
movq %rax, -0x78(%rbp)
movl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
jmp 0x32b5f
movq -0x18(%rbp), %rax
movslq -0x2c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x2c(%rbp), %rcx
movss (%rax,%rcx,4), %xmm0
cvtss2sd %xmm0, %xmm1
movq -0x70(%rbp), %rax
movsd (%rax), %xmm0
divsd %xmm1, %xmm0
movsd %xmm0, (%rax)
movq -0x70(%rbp), %rax
movsd (%rax), %xmm0
cvtsd2ss %xmm0, %xmm0
movq -0x40(%rbp), %rax
movss %xmm0, (%rax)
movq -0x40(%rbp), %rax
addq $-0x4, %rax
movq %rax, -0x40(%rbp)
movq -0x38(%rbp), %rax
addq $-0x4, %rax
movq %rax, -0x38(%rbp)
movq -0x70(%rbp), %rax
addq $-0x8, %rax
movq %rax, -0x70(%rbp)
movl -0x2c(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x32b0d
movq -0x58(%rbp), %rax
movq %rax, %rsp
jmp 0x32c41
movq %rbp, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)