// File: /workspace/github_c_makefile_star2_O0/ugobas[P]tnm/nma.c
// Function: Set_reference
int Set_reference(// Output:
		  struct Reference *Ref,
		  // Input:
		  int ini_ref, char *SEL, atom *atoms,
		  int ini_atom, int natoms)
{
  // Set reference atoms
  Ref->atom_num=malloc(natoms*sizeof(int));
  int N_ref=
    Select_atoms(Ref->atom_num+ini_ref, atoms+ini_atom, natoms, SEL);
  Ref->N_ref=N_ref;
  Ref->N_Cart=3*N_ref;
  printf("%d atoms out of %d selected for kinetic energy (%s)\n",
	 N_ref, natoms, SEL);
  Ref->mass_atom=malloc(N_ref*sizeof(float));
  Ref->mass_coord=malloc(Ref->N_Cart*sizeof(float));
  Ref->mass_sqrt=malloc(Ref->N_Cart*sizeof(float));

  float *ma=Ref->mass_atom, *mc=Ref->mass_coord, *ms=Ref->mass_sqrt;
  int *a_num=Ref->atom_num;
  double mass_sum=0;
  for(int i=ini_ref; i<ini_ref+N_ref; i++){
    (*a_num)+=ini_atom;
    (*ma) = Mass(atoms+(*a_num));
    mass_sum+=(*ma);
    for(int j=0; j<3; j++){*mc = *ma; *ms=sqrt(*ma); mc++; ms++;}
    ma++; a_num++;
  }
  Ref->mass_sum=mass_sum;
  return(N_ref);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movl %r8d, -0x24(%rbp)
movl %r9d, -0x28(%rbp)
movslq -0x28(%rbp), %rdi
shlq $0x2, %rdi
callq 0x1180
movq %rax, %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x28(%rax)
movq -0x8(%rbp), %rax
movq 0x28(%rax), %rdi
movslq -0xc(%rbp), %rax
shlq $0x2, %rax
addq %rax, %rdi
movq -0x20(%rbp), %rsi
movslq -0x24(%rbp), %rax
imulq $0x70, %rax, %rax
addq %rax, %rsi
movl -0x28(%rbp), %edx
movq -0x18(%rbp), %rcx
callq 0x35130
movl %eax, -0x2c(%rbp)
movl -0x2c(%rbp), %ecx
movq -0x8(%rbp), %rax
movl %ecx, (%rax)
imull $0x3, -0x2c(%rbp), %ecx
movq -0x8(%rbp), %rax
movl %ecx, 0x4(%rax)
movl -0x2c(%rbp), %esi
movl -0x28(%rbp), %edx
movq -0x18(%rbp), %rcx
leaq 0x48f76(%rip), %rdi     # 0x7df13
movb $0x0, %al
callq 0x10d0
movslq -0x2c(%rbp), %rdi
shlq $0x2, %rdi
callq 0x1180
movq %rax, %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x8(%rbp), %rax
movslq 0x4(%rax), %rdi
shlq $0x2, %rdi
callq 0x1180
movq %rax, %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x18(%rax)
movq -0x8(%rbp), %rax
movslq 0x4(%rax), %rdi
shlq $0x2, %rdi
callq 0x1180
movq %rax, %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x20(%rax)
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x38(%rbp)
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0x40(%rbp)
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0x48(%rbp)
movq -0x8(%rbp), %rax
movq 0x28(%rax), %rax
movq %rax, -0x50(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0x58(%rbp)
movl -0xc(%rbp), %eax
movl %eax, -0x5c(%rbp)
movl -0x5c(%rbp), %eax
movl -0xc(%rbp), %ecx
addl -0x2c(%rbp), %ecx
cmpl %ecx, %eax
jge 0x35106
movl -0x24(%rbp), %ecx
movq -0x50(%rbp), %rax
addl (%rax), %ecx
movl %ecx, (%rax)
movq -0x20(%rbp), %rdi
movq -0x50(%rbp), %rax
movslq (%rax), %rax
imulq $0x70, %rax, %rax
addq %rax, %rdi
callq 0x351c0
movq -0x38(%rbp), %rax
movss %xmm0, (%rax)
movq -0x38(%rbp), %rax
movss (%rax), %xmm0
cvtss2sd %xmm0, %xmm0
addsd -0x58(%rbp), %xmm0
movsd %xmm0, -0x58(%rbp)
movl $0x0, -0x60(%rbp)
cmpl $0x3, -0x60(%rbp)
jge 0x350e0
movq -0x38(%rbp), %rax
movss (%rax), %xmm0
movq -0x40(%rbp), %rax
movss %xmm0, (%rax)
movq -0x38(%rbp), %rax
movss (%rax), %xmm0
cvtss2sd %xmm0, %xmm0
callq 0x1220
cvtsd2ss %xmm0, %xmm0
movq -0x48(%rbp), %rax
movss %xmm0, (%rax)
movq -0x40(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x40(%rbp)
movq -0x48(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x48(%rbp)
movl -0x60(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x60(%rbp)
jmp 0x3508a
movq -0x38(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x38(%rbp)
movq -0x50(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x50(%rbp)
movl -0x5c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x5c(%rbp)
jmp 0x35032
movsd -0x58(%rbp), %xmm0
cvtsd2ss %xmm0, %xmm0
movq -0x8(%rbp), %rax
movss %xmm0, 0x8(%rax)
movl -0x2c(%rbp), %eax
addq $0x60, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)