// File: /workspace/github_c_makefile_star2_O3/ugobas[P]tnm/buildup.c
// Function: Find_previous
struct bond *Find_previous(struct bond *bond, int n, int N_atoms,
			   struct residue *seq)
{
  // Find previous atom in same chain
  struct bond *previous=bond-1;
  int res=previous->atom->res;
  if((res+1)<bond->atom->res){
    printf("Gap %d-%d ", res, bond->atom->res);
  }

  int ichar=-1; char name_p[4]="   "; // Ex. B in CB
  if((seq->type==1)||(seq->type==-1)){ // Amino-acid
    ichar=Get_previous_AA(name_p, bond, res);
  }else if((seq->type==2)||(seq->type==3)||
	   (seq->type==-2)||(seq->type==-3)){ // Nucleic acid
    Get_previous_nuc(name_p, bond, seq->amm);
  }

  struct bond *prev=NULL, *pname=NULL;
  double dmin=1000000, dname=100000; int i;
  for(i=n; i>0; i--){
    if(previous->atom->res<(res-1))break;
    if((bond->atom->main)&&(previous->atom->main==0))goto next;
    if((((ichar>=0)&&(previous->atom->name[ichar]==name_p[0]))||
	(strncmp(previous->atom->name, name_p, 3)==0)||
	(strncmp(previous->atom->name, name_p, 2)==0))&&
       (previous->atom->name[0]!='H')){
      double d2=0, x; int j;
      for(j=0; j<3; j++){
	x=previous->r[j]-bond->r[j]; d2+=x*x;
      }
      if(d2< BONDTHR1_2)return(previous);
      if(d2<dname){pname=previous; dname=d2;}
    }else{ // Not the name I am looking for!
      double d2=0, x; int j;
      for(j=0; j<3; j++){
	x=previous->r[j]-bond->r[j]; d2+=x*x;
      }
      if(d2<dmin){prev=previous; dmin=d2;}
    }
  next:
    previous--;
  }
  /*// Look ahead
  previous=bond+1;
  for(i=n+1; i<N_atoms; i++){
    if(previous->atom->res>res)break;
    if((bond->atom->main)&&(previous->atom->main==0))goto next2;
    if((((ichar>=0)&&(previous->atom->name[ichar]==name_p[0]))||
	(strncmp(previous->atom->name, name_p, 3)==0)||
	(strncmp(previous->atom->name, name_p, 2)==0))&&
       (previous->atom->name[0]!='H')){
      float d2=0, x; int j;
      for(j=0; j<3; j++){
	x=previous->r[j]-bond->r[j]; d2+=x*x;
      }
      if(d2< BONDTHR1_2)return(previous);
      if(d2<dname){pname=previous; dname=d2;}
    }else{ // Not the name I am looking for!
      float d2=0, x; int j;
      for(j=0; j<3; j++){
	x=previous->r[j]-bond->r[j]; d2+=x*x;
      }
      if(d2<dmin){prev=previous; dmin=d2;}
    }
  next2:
    previous++;
    }*/


  if(pname!=NULL){
    prev=pname;
  }else{
    printf("WARNING, no proper previous atom of %s ", bond->atom->name);
    printf("res %d chain %d type %d %c\n", bond->atom->res,
	   bond->atom->chain, seq->type, seq->amm);
    printf("Expected previous: %s %d %c\n", name_p, ichar, name_p[0]);
  }

  if(prev==NULL){ 
    printf("ERROR, no previous atom of %s found\n", bond->atom->name);
    printf("n= %d i= %d ", n, i);
    printf("d(atom: %s%d%c previous: %s %d%c)= %.1f\n",
	 bond->atom->name, bond->atom->res, bond->atom->aa,
	 previous->atom->name, previous->atom->res, previous->atom->aa,
	   sqrt(dmin));
    exit(8);
  }
  printf("d(atom: %s%d%c previous: %s%d%c)= %.1f\n",
	 bond->atom->name, bond->atom->res, bond->atom->aa,
	 prev->atom->name, prev->atom->res, prev->atom->aa, sqrt(dmin));
  return(prev);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movq %rcx, %r15
movl %esi, %r14d
movq %rdi, %rbx
movq -0xc0(%rdi), %rax
movq (%rdi), %rcx
movl 0x64(%rax), %eax
movq %rax, 0x30(%rsp)
incl %eax
movl 0x64(%rcx), %edx
cmpl %edx, %eax
jge 0x15894
leaq 0x41477(%rip), %rdi     # 0x56cff
movq 0x30(%rsp), %rsi
xorl %eax, %eax
callq 0x20f0
movl $0x202020, 0x18(%rsp)   # imm = 0x202020
movzwl 0x18(%r15), %eax
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
movb $0x20, 0x17(%rsp)
movl $0x0, 0x1c(%rsp)
cmpl $0xfffc, %eax           # imm = 0xFFFC
movq %r15, 0x50(%rsp)
jg 0x158d1
leal -0x2(%rax), %ecx
cmpl $0x2, %ecx
jb 0x158dc
cmpl $0x1, %eax
je 0x15928
jmp 0x15db0
leal -0xfffd(%rax), %ecx
cmpl $0x2, %ecx
jae 0x1591d
movzbl 0x13(%r15), %edi
movq (%rbx), %rax
movzbl 0x18(%rax), %ecx
cmpl $0x43, %ecx
je 0x159b3
cmpl $0x4f, %ecx
je 0x15945
cmpl $0x50, %ecx
jne 0x15914
cmpb $0x20, 0x19(%rax)
jne 0x15914
cmpb $0x20, 0x1a(%rax)
jne 0x15914
movl $0x27334f, 0x18(%rsp)   # imm = 0x27334F
jmp 0x15a43
xorl %esi, %esi
xorl %edx, %edx
jmp 0x15abc
cmpl $0xffff, %eax           # imm = 0xFFFF
jne 0x15db0
movq (%rbx), %rsi
movl 0x64(%rsi), %edx
cmpl 0x30(%rsp), %edx
jle 0x15973
movb $0x0, 0x1a(%rsp)
movw $0x2043, 0x18(%rsp)     # imm = 0x2043
jmp 0x15da3
movzbl 0x19(%rax), %edx
movb $0x1, %sil
leal -0x32(%rdx), %r8d
cmpl $0x3, %r8d
ja 0x15a19
leaq 0x4100b(%rip), %rdx     # 0x5696c
movslq (%rdx,%r8,4), %r8
addq %rdx, %r8
jmpq *%r8
cmpb $0x27, 0x1a(%rax)
jne 0x15916
jmp 0x159df
movb 0x19(%rsi), %dil
movzbl %dil, %eax
movzbl 0x18(%rsi), %ecx
cmpl $0x48, %ecx
jne 0x159ec
addl $-0x31, %eax
cmpl $0x1d, %eax
ja 0x15d0b
movl $0x20000007, %ecx       # imm = 0x20000007
btl %eax, %ecx
jae 0x15d0b
movb $0x20, 0x18(%rsp)
movl $0x1, %ebp
movb $0x1, %al
movl %eax, 0x1c(%rsp)
jmp 0x15db0
movzbl 0x19(%rax), %esi
movb $0x1, %dl
addl $-0x31, %esi
cmpl $0x4, %esi
ja 0x15aba
leaq 0x40f8c(%rip), %r8      # 0x56958
movslq (%r8,%rsi,4), %rsi
addq %r8, %rsi
jmpq *%rsi
cmpb $0x27, 0x1a(%rax)
jne 0x15aba
movl $0x273243, 0x18(%rsp)   # imm = 0x273243
jmp 0x15da3
leal -0x41(%rax), %edi
cmpl $0x7, %edi
ja 0x15c8d
leaq 0x40f7d(%rip), %r8      # 0x5697c
movslq (%r8,%rdi,4), %rdi
addq %r8, %rdi
jmpq *%rdi
movb $0x0, 0x1a(%rsp)
movw $0x204e, 0x18(%rsp)     # imm = 0x204E
jmp 0x15cd5
cmpl $0x50, %edx
jne 0x15916
movzbl 0x1a(%rax), %edx
cmpl $0x32, %edx
je 0x15a76
cmpl $0x31, %edx
je 0x15a76
jmp 0x15916
cmpb $0x27, 0x1a(%rax)
jne 0x15aba
movl $0x27354f, 0x18(%rsp)   # imm = 0x27354F
movb $0x4f, 0x17(%rsp)
jmp 0x15da8
cmpb $0x27, 0x1a(%rax)
jne 0x15916
jmp 0x15a5f
cmpb $0x27, 0x1a(%rax)
jne 0x15aba
movl $0x273443, 0x18(%rsp)   # imm = 0x273443
jmp 0x15da3
cmpb $0x27, 0x1a(%rax)
jne 0x15916
movl $0x202050, 0x18(%rsp)   # imm = 0x202050
movb $0x50, 0x17(%rsp)
jmp 0x15da8
cmpb $0x27, 0x1a(%rax)
jne 0x15916
jmp 0x15aad
cmpb $0x27, 0x1a(%rax)
jne 0x15aba
movl $0x273543, 0x18(%rsp)   # imm = 0x273543
jmp 0x15da3
cmpb $0x27, 0x1a(%rax)
jne 0x15aba
movl $0x273343, 0x18(%rsp)   # imm = 0x273343
jmp 0x15da3
xorl %esi, %esi
addl $-0x41, %edi
cmpl $0x14, %edi
ja 0x15c15
movl $0x180004, %r8d         # imm = 0x180004
btl %edi, %r8d
jae 0x15b02
cmpb $0x4e, %cl
jne 0x15ae5
cmpb $0x31, 0x19(%rax)
jne 0x15ae5
cmpb $0x20, 0x1a(%rax)
je 0x15b25
testb %dl, %dl
je 0x15b32
cmpb $0x32, 0x19(%rax)
jne 0x15b32
cmpb $0x20, 0x1a(%rax)
jne 0x15b32
movl $0x20314e, 0x18(%rsp)   # imm = 0x20314E
jmp 0x15cd5
movl $0x41, %r8d
btl %edi, %r8d
jae 0x15c15
cmpb $0x4e, %cl
jne 0x15bde
cmpb $0x39, 0x19(%rax)
jne 0x15bde
movl $0x273143, 0x18(%rsp)   # imm = 0x273143
jmp 0x15da3
testb %sil, %sil
je 0x15b43
cmpb $0x32, 0x19(%rax)
jne 0x15b43
cmpb $0x20, 0x1a(%rax)
je 0x15b54
cmpb $0x4e, %cl
jne 0x15b61
cmpb $0x33, 0x19(%rax)
jne 0x15b61
cmpb $0x20, 0x1a(%rax)
jne 0x15b61
movl $0x203243, 0x18(%rsp)   # imm = 0x203243
jmp 0x15da3
testb %dl, %dl
je 0x15b7e
cmpb $0x34, 0x19(%rax)
jne 0x15b7e
cmpb $0x20, 0x1a(%rax)
jne 0x15b7e
movl $0x20334e, 0x18(%rsp)   # imm = 0x20334E
jmp 0x15cd5
testb %sil, %sil
je 0x15b8f
cmpb $0x34, 0x19(%rax)
jne 0x15b8f
cmpb $0x20, 0x1a(%rax)
je 0x15bd1
cmpb $0x4e, %cl
jne 0x15ba0
cmpb $0x34, 0x19(%rax)
jne 0x15ba0
cmpb $0x20, 0x1a(%rax)
je 0x15bd1
testb %dl, %dl
je 0x15da8
movzbl 0x19(%rax), %ecx
cmpl $0x37, %ecx
je 0x15d31
cmpl $0x36, %ecx
je 0x15d25
cmpl $0x35, %ecx
jne 0x15da8
cmpb $0x20, 0x1a(%rax)
jne 0x15da8
movl $0x203443, 0x18(%rsp)   # imm = 0x203443
jmp 0x15da3
testb %dl, %dl
je 0x15bf9
cmpb $0x38, 0x19(%rax)
jne 0x15bf9
movb $0x0, 0x1a(%rsp)
movw $0x394e, 0x18(%rsp)     # imm = 0x394E
jmp 0x15cd5
cmpb $0x4e, %cl
jne 0x15c3a
cmpb $0x37, 0x19(%rax)
jne 0x15c3a
movb $0x0, 0x1a(%rsp)
movw $0x3843, 0x18(%rsp)     # imm = 0x3843
jmp 0x15da3
leaq 0x18(%rax), %rsi
movl 0x64(%rax), %edx
movl 0x6c(%rax), %ecx
leaq 0x411c8(%rip), %rdi     # 0x56dee
movl $0x0, 0x1c(%rsp)
xorl %eax, %eax
callq 0x20f0
jmp 0x15db0
testb %dl, %dl
je 0x15c5e
movzbl 0x19(%rax), %edi
cmpl $0x36, %edi
je 0x15d97
cmpl $0x35, %edi
jne 0x15c5e
movb $0x0, 0x1a(%rsp)
movw $0x374e, 0x18(%rsp)     # imm = 0x374E
jmp 0x15cd5
testb %sil, %sil
je 0x15c69
cmpb $0x36, 0x19(%rax)
je 0x15c7c
cmpb $0x4e, %cl
jne 0x15cbf
movzbl 0x19(%rax), %esi
cmpl $0x31, %esi
je 0x15c7c
cmpl $0x36, %esi
jne 0x15cbf
movb $0x0, 0x1a(%rsp)
movw $0x3643, 0x18(%rsp)     # imm = 0x3643
jmp 0x15da3
cmpl $0x5a, %eax
je 0x160e1
cmpl $0x20, %eax
jne 0x15d41
cmpl $0x43, %ecx
je 0x15d89
cmpl $0x4f, %ecx
je 0x15934
cmpl $0x4e, %ecx
je 0x15934
jmp 0x159a3
testb %dl, %dl
je 0x15cdf
cmpb $0x32, 0x19(%rax)
jne 0x15cdf
movb $0x0, 0x1a(%rsp)
movw $0x314e, 0x18(%rsp)     # imm = 0x314E
movb $0x4e, 0x17(%rsp)
jmp 0x15da8
cmpb $0x4e, %cl
jne 0x16062
movzbl 0x19(%rax), %ecx
cmpl $0x33, %ecx
je 0x15cfa
cmpl $0x32, %ecx
jne 0x16062
movb $0x0, 0x1a(%rsp)
movw $0x3243, 0x18(%rsp)     # imm = 0x3243
jmp 0x15da3
movb %dil, 0x18(%rsp)
movl $0x1, %ebp
movb $0x1, %al
movl %eax, 0x1c(%rsp)
movb %dil, 0x17(%rsp)
jmp 0x15db0
cmpb $0x20, 0x1a(%rax)
je 0x15af5
jmp 0x15da8
cmpb $0x20, 0x1a(%rax)
jne 0x15da8
movl $0x203543, 0x18(%rsp)   # imm = 0x203543
jmp 0x15da3
cmpl $0x4f, %ecx
jne 0x15d5e
cmpl $0x54, %eax
je 0x15934
cmpl $0x58, %eax
jne 0x15d5e
cmpb $0x54, 0x1a(%rsi)
je 0x15934
movl 0x6c(%rsi), %ecx
addq $0x18, %rsi
leaq 0x41082(%rip), %rdi     # 0x56dee
movl $0x0, 0x1c(%rsp)
xorl %eax, %eax
callq 0x20f0
movw $0x2020, 0x18(%rsp)     # imm = 0x2020
movb $0x0, 0x1a(%rsp)
jmp 0x15db0
movb $0x0, 0x1a(%rsp)
movw $0x4143, 0x18(%rsp)     # imm = 0x4143
jmp 0x15da3
movb $0x0, 0x1a(%rsp)
movw $0x3543, 0x18(%rsp)     # imm = 0x3543
movb $0x43, 0x17(%rsp)
movl $0x0, 0x1c(%rsp)
leaq -0xc0(%rbx), %r15
testl %r14d, %r14d
movl %r14d, 0x40(%rsp)
jle 0x15f6e
movq 0x30(%rsp), %rax
decl %eax
movq %rax, 0x30(%rsp)
movl %ebp, 0x44(%rsp)
movl %ebp, %eax
movq %rax, 0x60(%rsp)
cvtss2sd 0x63494(%rip), %xmm0    # 0x79278
movsd %xmm0, 0x58(%rsp)
leaq -0xb8(%rbx), %rbp
movsd 0x40b47(%rip), %xmm0    # 0x56940
movsd 0x40b47(%rip), %xmm1    # 0x56948
movsd %xmm1, 0x48(%rsp)
movq $0x0, 0x28(%rsp)
movl %r14d, %r13d
movq $0x0, 0x38(%rsp)
movq (%r15), %r12
movq 0x30(%rsp), %rax
cmpl %eax, 0x64(%r12)
jl 0x15f57
movq (%rbx), %rax
cmpl $0x0, 0x48(%rax)
je 0x15e44
cmpl $0x0, 0x48(%r12)
je 0x15f36
movsd %xmm0, 0x20(%rsp)
cmpb $0x0, 0x1c(%rsp)
je 0x15e61
movb 0x17(%rsp), %al
movq 0x60(%rsp), %rcx
cmpb %al, 0x18(%r12,%rcx)
je 0x15e92
leaq 0x18(%r12), %r14
movl $0x3, %edx
movq %r14, %rdi
leaq 0x18(%rsp), %rsi
callq 0x2070
testl %eax, %eax
je 0x15e92
movl $0x2, %edx
movq %r14, %rdi
leaq 0x18(%rsp), %rsi
callq 0x2070
testl %eax, %eax
jne 0x15e9a
cmpb $0x48, 0x18(%r12)
jne 0x15edb
xorpd %xmm0, %xmm0
xorl %eax, %eax
movsd (%rbp,%rax,8), %xmm1
subsd 0x8(%rbx,%rax,8), %xmm1
mulsd %xmm1, %xmm1
addsd %xmm1, %xmm0
incq %rax
cmpq $0x3, %rax
jne 0x15ea0
movsd 0x20(%rsp), %xmm1
ucomisd %xmm0, %xmm1
movq 0x38(%rsp), %rax
cmovaq %r15, %rax
movq %rax, 0x38(%rsp)
minsd %xmm1, %xmm0
jmp 0x15f36
xorpd %xmm2, %xmm2
xorl %eax, %eax
movsd (%rbp,%rax,8), %xmm1
subsd 0x8(%rbx,%rax,8), %xmm1
mulsd %xmm1, %xmm1
addsd %xmm1, %xmm2
incq %rax
cmpq $0x3, %rax
jne 0x15ee1
movsd 0x58(%rsp), %xmm0
ucomisd %xmm2, %xmm0
movsd 0x20(%rsp), %xmm0
ja 0x1605d
movsd 0x48(%rsp), %xmm1
ucomisd %xmm2, %xmm1
movq 0x28(%rsp), %rax
cmovaq %r15, %rax
movq %rax, 0x28(%rsp)
minsd %xmm1, %xmm2
movsd %xmm2, 0x48(%rsp)
movq $-0xc0, %rcx
addq %rcx, %r15
leal -0x1(%r13), %eax
addq %rcx, %rbp
cmpl $0x1, %r13d
movl %eax, %r13d
jg 0x15e1c
xorl %r13d, %r13d
movq (%rbx), %rsi
movq 0x28(%rsp), %rax
testq %rax, %rax
movl 0x44(%rsp), %ebp
jne 0x15ff3
jmp 0x15f85
movq (%rbx), %rsi
movsd 0x409c7(%rip), %xmm0    # 0x56940
movq $0x0, 0x38(%rsp)
movl %r14d, %r13d
movsd %xmm0, 0x20(%rsp)
addq $0x18, %rsi
leaq 0x40d74(%rip), %rdi     # 0x56d0a
xorl %eax, %eax
callq 0x20f0
movq (%rbx), %rax
movl 0x64(%rax), %esi
movl 0x6c(%rax), %edx
movq 0x50(%rsp), %rax
movswl 0x18(%rax), %ecx
movsbl 0x13(%rax), %r8d
leaq 0x40d77(%rip), %rdi     # 0x56d32
xorl %eax, %eax
callq 0x20f0
movsbl 0x17(%rsp), %ecx
leaq 0x40d80(%rip), %rdi     # 0x56d4e
leaq 0x18(%rsp), %rsi
movl %ebp, %edx
xorl %eax, %eax
callq 0x20f0
movq (%rbx), %rsi
movq 0x38(%rsp), %rax
testq %rax, %rax
je 0x160fb
movsd 0x20(%rsp), %xmm0
leaq 0x18(%rsi), %rbx
movl 0x64(%rsi), %ebp
movsbl 0x68(%rsi), %r14d
movq %rax, 0x28(%rsp)
movq (%rax), %rax
leaq 0x18(%rax), %r12
movl 0x64(%rax), %r13d
movsbl 0x68(%rax), %r15d
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jb 0x16024
sqrtsd %xmm0, %xmm0
jmp 0x16029
callq 0x22a0
movl %r15d, (%rsp)
leaq 0x40d92(%rip), %rdi     # 0x56dc6
movq %rbx, %rsi
movl %ebp, %edx
movl %r14d, %ecx
movq %r12, %r8
movl %r13d, %r9d
movb $0x1, %al
callq 0x20f0
movq 0x28(%rsp), %rax
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %r15, %rax
jmp 0x1604e
testb %dl, %dl
je 0x15da8
cmpb $0x34, 0x19(%rax)
je 0x15be8
jmp 0x15da8
movb $0x44, 0x18(%rsp)
movl $0x1, %ebp
movb $0x1, %al
movl %eax, 0x1c(%rsp)
movb $0x44, 0x17(%rsp)
jmp 0x15db0
movb $0x42, 0x18(%rsp)
movl $0x1, %ebp
movb $0x1, %al
movl %eax, 0x1c(%rsp)
movb $0x42, 0x17(%rsp)
jmp 0x15db0
movb $0x47, 0x18(%rsp)
movl $0x1, %ebp
movb $0x1, %al
movl %eax, 0x1c(%rsp)
movb $0x47, 0x17(%rsp)
jmp 0x15db0
movb $0x5a, 0x18(%rsp)
movl $0x1, %ebp
movb $0x1, %al
movl %eax, 0x1c(%rsp)
movb $0x5a, 0x17(%rsp)
jmp 0x15db0
movb $0x45, 0x18(%rsp)
movl $0x1, %ebp
movb $0x1, %al
movl %eax, 0x1c(%rsp)
movb $0x45, 0x17(%rsp)
jmp 0x15db0
addq $0x18, %rsi
leaq 0x40c65(%rip), %rdi     # 0x56d6b
xorl %eax, %eax
callq 0x20f0
leaq 0x40c7c(%rip), %rdi     # 0x56d90
movl 0x40(%rsp), %esi
movl %r13d, %edx
xorl %eax, %eax
callq 0x20f0
movq (%rbx), %rax
leaq 0x18(%rax), %rbx
movl 0x64(%rax), %ebp
movsbl 0x68(%rax), %r14d
movq (%r15), %rax
leaq 0x18(%rax), %r15
movl 0x64(%rax), %r12d
movsbl 0x68(%rax), %r13d
xorpd %xmm0, %xmm0
movsd 0x20(%rsp), %xmm1
ucomisd %xmm0, %xmm1
jb 0x1615c
xorps %xmm0, %xmm0
sqrtsd 0x20(%rsp), %xmm0
jmp 0x16167
movsd 0x20(%rsp), %xmm0
callq 0x22a0
movl %r13d, (%rsp)
leaq 0x40c2b(%rip), %rdi     # 0x56d9d
movq %rbx, %rsi
movl %ebp, %edx
movl %r14d, %ecx
movq %r15, %r8
movl %r12d, %r9d
movb $0x1, %al
callq 0x20f0
movl $0x8, %edi
callq 0x2280