// File: /workspace/github_c_makefile_star2_O0/ugobas[P]tnm/read.c
// Function: Order_atoms_aa
int Order_atoms_aa(atom *res_atom, int n_atom)
{
  int i_N=-1, i_CA=-1, i_C=-1, i_O=-1, i_OT=-1;
  int i_HN[3], i_HA[3], n_HN=0, n_HA=0, i, j;
  if(HYD)for(j=0; j<3; j++){i_HN[j]=-1; i_HA[j]=-1;}
  atom *atom1=res_atom;
  for(i=0; i<n_atom; i++){
    if(strncmp(atom1->name, "N ", 2)==0){i_N=i;}
    else if(strncmp(atom1->name, "CA", 2)==0){i_CA=i;}
    else if(strncmp(atom1->name, "C ", 2)==0){i_C=i;}
    else if(strncmp(atom1->name, "O ", 2)==0){i_O=i;}
    else if((strncmp(atom1->name, "OT", 2)==0)||
	    (strncmp(atom1->name, "OX", 2)==0)){i_OT=i;}
    else if(atom1->name[0]=='H'){
      if((atom1->name[1]==' ')||(atom1->name[1]=='1')||
	 (atom1->name[1]=='2')||(atom1->name[1]=='3')){
	atom1->name[2]=atom1->name[1]; atom1->name[1]='N';
	i_HN[n_HN]=i; n_HN++;
      }else if(atom1->name[1]=='A'){
	i_HA[n_HA]=i; n_HA++;
      }
    }
    atom1++;
  }
  
  // Store main chain in the order N (HN) CA (HA)
  atom *atom2=atom_tmp;
  int N_atom_res=0;
  N_atom_res+=Copy_atom(&atom2, res_atom, i_N);
  if(HYD){
    for(j=0; j<3; j++)
      N_atom_res+=Copy_atom(&atom2, res_atom, i_HN[j]);
  }
  N_atom_res+=Copy_atom(&atom2, res_atom, i_CA);
  if(HYD){
    for(j=0; j<3; j++)
      N_atom_res+=Copy_atom(&atom2, res_atom, i_HA[j]);
  }
  
  // Store side chain before C-O
  int N_side=n_atom;
  if(i_C>=0)N_side--;
  if(i_O>=0)N_side--; 
  if(N_atom_res==N_side)goto CO;
  N_atom_res+=Store_branch(&atom2, 'B', res_atom, n_atom);
  if(N_atom_res==N_side)goto CO;
  N_atom_res+=Store_branch(&atom2, 'G', res_atom, n_atom);
  if(N_atom_res==N_side)goto CO;
  N_atom_res+=Store_branch(&atom2, 'D', res_atom, n_atom);
  if(N_atom_res==N_side)goto CO;
  N_atom_res+=Store_branch(&atom2, 'E', res_atom, n_atom);
  if(N_atom_res==N_side)goto CO;
  N_atom_res+=Store_branch(&atom2, 'Z', res_atom, n_atom);
  if(N_atom_res==N_side)goto CO;
  N_atom_res+=Store_branch(&atom2, 'H', res_atom, n_atom);
  if(N_atom_res==N_side)goto CO;
  
  // Store other side chain atoms before C-O
  atom1=res_atom;
  for(i=0; i<n_atom; i++){
    if((strncmp(atom1->name, "N ", 2)!=0)&&
       (strncmp(atom1->name, "CA", 2)!=0)&&
       (strncmp(atom1->name, "C ", 2)!=0)&&
       (strncmp(atom1->name, "O ", 2)!=0)&&
       (strncmp(atom1->name, "OT", 2)!=0)&&
       (strncmp(atom1->name, "OX", 2)!=0)&&
       (atom1->name[1]!='N')&&
       (atom1->name[1]!='A')&&
       (atom1->name[1]!='B')&&
       (atom1->name[1]!='G')&&
       (atom1->name[1]!='D')&&
       (atom1->name[1]!='E')&&
       (atom1->name[1]!='Z')&&
       (atom1->name[1]!='H')){
      N_atom_res+=Copy_atom(&atom2, res_atom, i);
    }
    atom1++;
  }
  
  // Store CO
 CO:
  N_atom_res+=Copy_atom(&atom2, res_atom, i_C);
  N_atom_res+=Copy_atom(&atom2, res_atom, i_O);
  N_atom_res+=Copy_atom(&atom2, res_atom, i_OT);

  if(N_atom_res!=n_atom){
    printf("ERROR changing the order of protein atoms\n");
    printf("residue %d %c cain %d has %d residues but %d stored\n",
	   res_atom->res, res_atom->aa, res_atom->chain, n_atom, N_atom_res);
    exit(8);
  }

  for(i=0; i<n_atom; i++){
    res_atom[i]=atom_tmp[i];
  }
  return(N_atom_res);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movl $0xffffffff, -0x10(%rbp) # imm = 0xFFFFFFFF
movl $0xffffffff, -0x14(%rbp) # imm = 0xFFFFFFFF
movl $0xffffffff, -0x18(%rbp) # imm = 0xFFFFFFFF
movl $0xffffffff, -0x1c(%rbp) # imm = 0xFFFFFFFF
movl $0xffffffff, -0x20(%rbp) # imm = 0xFFFFFFFF
movl $0x0, -0x3c(%rbp)
movl $0x0, -0x40(%rbp)
leaq 0x78769(%rip), %rax     # 0x8c020
cmpl $0x0, (%rax)
je 0x138ee
movl $0x0, -0x48(%rbp)
cmpl $0x3, -0x48(%rbp)
jge 0x138ec
movslq -0x48(%rbp), %rax
movl $0xffffffff, -0x2c(%rbp,%rax,4) # imm = 0xFFFFFFFF
movslq -0x48(%rbp), %rax
movl $0xffffffff, -0x38(%rbp,%rax,4) # imm = 0xFFFFFFFF
movl -0x48(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x48(%rbp)
jmp 0x138c3
jmp 0x138ee
movq -0x8(%rbp), %rax
movq %rax, -0x50(%rbp)
movl $0x0, -0x44(%rbp)
movl -0x44(%rbp), %eax
cmpl -0xc(%rbp), %eax
jge 0x13aae
movq -0x50(%rbp), %rdi
addq $0x18, %rdi
leaq 0x67715(%rip), %rsi     # 0x7b02d
movl $0x2, %edx
callq 0x1050
cmpl $0x0, %eax
jne 0x13932
movl -0x44(%rbp), %eax
movl %eax, -0x10(%rbp)
jmp 0x13a94
movq -0x50(%rbp), %rdi
addq $0x18, %rdi
leaq 0x629c7(%rip), %rsi     # 0x76308
movl $0x2, %edx
callq 0x1050
cmpl $0x0, %eax
jne 0x1395b
movl -0x44(%rbp), %eax
movl %eax, -0x14(%rbp)
jmp 0x13a92
movq -0x50(%rbp), %rdi
addq $0x18, %rdi
leaq 0x676c6(%rip), %rsi     # 0x7b030
movl $0x2, %edx
callq 0x1050
cmpl $0x0, %eax
jne 0x13984
movl -0x44(%rbp), %eax
movl %eax, -0x18(%rbp)
jmp 0x13a90
movq -0x50(%rbp), %rdi
addq $0x18, %rdi
leaq 0x676a0(%rip), %rsi     # 0x7b033
movl $0x2, %edx
callq 0x1050
cmpl $0x0, %eax
jne 0x139ad
movl -0x44(%rbp), %eax
movl %eax, -0x1c(%rbp)
jmp 0x13a8e
movq -0x50(%rbp), %rdi
addq $0x18, %rdi
leaq 0x6767a(%rip), %rsi     # 0x7b036
movl $0x2, %edx
callq 0x1050
cmpl $0x0, %eax
je 0x139e9
movq -0x50(%rbp), %rdi
addq $0x18, %rdi
leaq 0x6765f(%rip), %rsi     # 0x7b039
movl $0x2, %edx
callq 0x1050
cmpl $0x0, %eax
jne 0x139f4
movl -0x44(%rbp), %eax
movl %eax, -0x20(%rbp)
jmp 0x13a8c
movq -0x50(%rbp), %rax
movsbl 0x18(%rax), %eax
cmpl $0x48, %eax
jne 0x13a8a
movq -0x50(%rbp), %rax
movsbl 0x19(%rax), %eax
cmpl $0x20, %eax
je 0x13a39
movq -0x50(%rbp), %rax
movsbl 0x19(%rax), %eax
cmpl $0x31, %eax
je 0x13a39
movq -0x50(%rbp), %rax
movsbl 0x19(%rax), %eax
cmpl $0x32, %eax
je 0x13a39
movq -0x50(%rbp), %rax
movsbl 0x19(%rax), %eax
cmpl $0x33, %eax
jne 0x13a65
movq -0x50(%rbp), %rax
movb 0x19(%rax), %cl
movq -0x50(%rbp), %rax
movb %cl, 0x1a(%rax)
movq -0x50(%rbp), %rax
movb $0x4e, 0x19(%rax)
movl -0x44(%rbp), %ecx
movslq -0x3c(%rbp), %rax
movl %ecx, -0x2c(%rbp,%rax,4)
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x13a88
movq -0x50(%rbp), %rax
movsbl 0x19(%rax), %eax
cmpl $0x41, %eax
jne 0x13a86
movl -0x44(%rbp), %ecx
movslq -0x40(%rbp), %rax
movl %ecx, -0x38(%rbp,%rax,4)
movl -0x40(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x40(%rbp)
jmp 0x13a88
jmp 0x13a8a
jmp 0x13a8c
jmp 0x13a8e
jmp 0x13a90
jmp 0x13a92
jmp 0x13a94
movq -0x50(%rbp), %rax
addq $0x70, %rax
movq %rax, -0x50(%rbp)
movl -0x44(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x44(%rbp)
jmp 0x138fd
leaq 0x7acbb(%rip), %rax     # 0x8e770
movq %rax, -0x58(%rbp)
movl $0x0, -0x5c(%rbp)
movq -0x8(%rbp), %rsi
movl -0x10(%rbp), %edx
leaq -0x58(%rbp), %rdi
callq 0x13ef0
addl -0x5c(%rbp), %eax
movl %eax, -0x5c(%rbp)
leaq 0x78543(%rip), %rax     # 0x8c020
cmpl $0x0, (%rax)
je 0x13b17
movl $0x0, -0x48(%rbp)
cmpl $0x3, -0x48(%rbp)
jge 0x13b15
movq -0x8(%rbp), %rsi
movslq -0x48(%rbp), %rax
movl -0x2c(%rbp,%rax,4), %edx
leaq -0x58(%rbp), %rdi
callq 0x13ef0
addl -0x5c(%rbp), %eax
movl %eax, -0x5c(%rbp)
movl -0x48(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x48(%rbp)
jmp 0x13ae9
jmp 0x13b17
movq -0x8(%rbp), %rsi
movl -0x14(%rbp), %edx
leaq -0x58(%rbp), %rdi
callq 0x13ef0
addl -0x5c(%rbp), %eax
movl %eax, -0x5c(%rbp)
leaq 0x784ec(%rip), %rax     # 0x8c020
cmpl $0x0, (%rax)
je 0x13b6e
movl $0x0, -0x48(%rbp)
cmpl $0x3, -0x48(%rbp)
jge 0x13b6c
movq -0x8(%rbp), %rsi
movslq -0x48(%rbp), %rax
movl -0x38(%rbp,%rax,4), %edx
leaq -0x58(%rbp), %rdi
callq 0x13ef0
addl -0x5c(%rbp), %eax
movl %eax, -0x5c(%rbp)
movl -0x48(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x48(%rbp)
jmp 0x13b40
jmp 0x13b6e
movl -0xc(%rbp), %eax
movl %eax, -0x60(%rbp)
cmpl $0x0, -0x18(%rbp)
jl 0x13b83
movl -0x60(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x60(%rbp)
cmpl $0x0, -0x1c(%rbp)
jl 0x13b92
movl -0x60(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x60(%rbp)
movl -0x5c(%rbp), %eax
cmpl -0x60(%rbp), %eax
jne 0x13b9f
jmp 0x13e0c
movq -0x8(%rbp), %rdx
movl -0xc(%rbp), %ecx
leaq -0x58(%rbp), %rdi
movl $0x42, %esi
callq 0x13f50
addl -0x5c(%rbp), %eax
movl %eax, -0x5c(%rbp)
movl -0x5c(%rbp), %eax
cmpl -0x60(%rbp), %eax
jne 0x13bc7
jmp 0x13e0c
movq -0x8(%rbp), %rdx
movl -0xc(%rbp), %ecx
leaq -0x58(%rbp), %rdi
movl $0x47, %esi
callq 0x13f50
addl -0x5c(%rbp), %eax
movl %eax, -0x5c(%rbp)
movl -0x5c(%rbp), %eax
cmpl -0x60(%rbp), %eax
jne 0x13bef
jmp 0x13e0c
movq -0x8(%rbp), %rdx
movl -0xc(%rbp), %ecx
leaq -0x58(%rbp), %rdi
movl $0x44, %esi
callq 0x13f50
addl -0x5c(%rbp), %eax
movl %eax, -0x5c(%rbp)
movl -0x5c(%rbp), %eax
cmpl -0x60(%rbp), %eax
jne 0x13c17
jmp 0x13e0c
movq -0x8(%rbp), %rdx
movl -0xc(%rbp), %ecx
leaq -0x58(%rbp), %rdi
movl $0x45, %esi
callq 0x13f50
addl -0x5c(%rbp), %eax
movl %eax, -0x5c(%rbp)
movl -0x5c(%rbp), %eax
cmpl -0x60(%rbp), %eax
jne 0x13c3f
jmp 0x13e0c
movq -0x8(%rbp), %rdx
movl -0xc(%rbp), %ecx
leaq -0x58(%rbp), %rdi
movl $0x5a, %esi
callq 0x13f50
addl -0x5c(%rbp), %eax
movl %eax, -0x5c(%rbp)
movl -0x5c(%rbp), %eax
cmpl -0x60(%rbp), %eax
jne 0x13c67
jmp 0x13e0c
movq -0x8(%rbp), %rdx
movl -0xc(%rbp), %ecx
leaq -0x58(%rbp), %rdi
movl $0x48, %esi
callq 0x13f50
addl -0x5c(%rbp), %eax
movl %eax, -0x5c(%rbp)
movl -0x5c(%rbp), %eax
cmpl -0x60(%rbp), %eax
jne 0x13c8f
jmp 0x13e0c
movq -0x8(%rbp), %rax
movq %rax, -0x50(%rbp)
movl $0x0, -0x44(%rbp)
movl -0x44(%rbp), %eax
cmpl -0xc(%rbp), %eax
jge 0x13e0a
movq -0x50(%rbp), %rdi
addq $0x18, %rdi
leaq 0x67374(%rip), %rsi     # 0x7b02d
movl $0x2, %edx
callq 0x1050
cmpl $0x0, %eax
je 0x13df0
movq -0x50(%rbp), %rdi
addq $0x18, %rdi
leaq 0x6262d(%rip), %rsi     # 0x76308
movl $0x2, %edx
callq 0x1050
cmpl $0x0, %eax
je 0x13df0
movq -0x50(%rbp), %rdi
addq $0x18, %rdi
leaq 0x67333(%rip), %rsi     # 0x7b030
movl $0x2, %edx
callq 0x1050
cmpl $0x0, %eax
je 0x13df0
movq -0x50(%rbp), %rdi
addq $0x18, %rdi
leaq 0x67314(%rip), %rsi     # 0x7b033
movl $0x2, %edx
callq 0x1050
cmpl $0x0, %eax
je 0x13df0
movq -0x50(%rbp), %rdi
addq $0x18, %rdi
leaq 0x672f5(%rip), %rsi     # 0x7b036
movl $0x2, %edx
callq 0x1050
cmpl $0x0, %eax
je 0x13df0
movq -0x50(%rbp), %rdi
addq $0x18, %rdi
leaq 0x672d6(%rip), %rsi     # 0x7b039
movl $0x2, %edx
callq 0x1050
cmpl $0x0, %eax
je 0x13df0
movq -0x50(%rbp), %rax
movsbl 0x19(%rax), %eax
cmpl $0x4e, %eax
je 0x13df0
movq -0x50(%rbp), %rax
movsbl 0x19(%rax), %eax
cmpl $0x41, %eax
je 0x13df0
movq -0x50(%rbp), %rax
movsbl 0x19(%rax), %eax
cmpl $0x42, %eax
je 0x13df0
movq -0x50(%rbp), %rax
movsbl 0x19(%rax), %eax
cmpl $0x47, %eax
je 0x13df0
movq -0x50(%rbp), %rax
movsbl 0x19(%rax), %eax
cmpl $0x44, %eax
je 0x13df0
movq -0x50(%rbp), %rax
movsbl 0x19(%rax), %eax
cmpl $0x45, %eax
je 0x13df0
movq -0x50(%rbp), %rax
movsbl 0x19(%rax), %eax
cmpl $0x5a, %eax
je 0x13df0
movq -0x50(%rbp), %rax
movsbl 0x19(%rax), %eax
cmpl $0x48, %eax
je 0x13df0
movq -0x8(%rbp), %rsi
movl -0x44(%rbp), %edx
leaq -0x58(%rbp), %rdi
callq 0x13ef0
addl -0x5c(%rbp), %eax
movl %eax, -0x5c(%rbp)
movq -0x50(%rbp), %rax
addq $0x70, %rax
movq %rax, -0x50(%rbp)
movl -0x44(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x44(%rbp)
jmp 0x13c9e
jmp 0x13e0c
movq -0x8(%rbp), %rsi
movl -0x18(%rbp), %edx
leaq -0x58(%rbp), %rdi
callq 0x13ef0
addl -0x5c(%rbp), %eax
movl %eax, -0x5c(%rbp)
movq -0x8(%rbp), %rsi
movl -0x1c(%rbp), %edx
leaq -0x58(%rbp), %rdi
callq 0x13ef0
addl -0x5c(%rbp), %eax
movl %eax, -0x5c(%rbp)
movq -0x8(%rbp), %rsi
movl -0x20(%rbp), %edx
leaq -0x58(%rbp), %rdi
callq 0x13ef0
addl -0x5c(%rbp), %eax
movl %eax, -0x5c(%rbp)
movl -0x5c(%rbp), %eax
cmpl -0xc(%rbp), %eax
je 0x13e9a
leaq 0x671df(%rip), %rdi     # 0x7b03c
movb $0x0, %al
callq 0x10d0
movq -0x8(%rbp), %rax
movl 0x64(%rax), %esi
movq -0x8(%rbp), %rax
movsbl 0x68(%rax), %edx
movq -0x8(%rbp), %rax
movl 0x6c(%rax), %ecx
movl -0xc(%rbp), %r8d
movl -0x5c(%rbp), %r9d
leaq 0x671de(%rip), %rdi     # 0x7b067
movb $0x0, %al
callq 0x10d0
movl $0x8, %edi
callq 0x1210
movl $0x0, -0x44(%rbp)
movl -0x44(%rbp), %eax
cmpl -0xc(%rbp), %eax
jge 0x13edf
movq -0x8(%rbp), %rdi
movslq -0x44(%rbp), %rax
imulq $0x70, %rax, %rax
addq %rax, %rdi
movslq -0x44(%rbp), %rax
leaq 0x7a8ad(%rip), %rsi     # 0x8e770
imulq $0x70, %rax, %rax
addq %rax, %rsi
movl $0x70, %edx
callq 0x1160
movl -0x44(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x44(%rbp)
jmp 0x13ea1
movl -0x5c(%rbp), %eax
addq $0x60, %rsp
popq %rbp
retq
nopl (%rax,%rax)