// File: /workspace/github_c_makefile_star2_O0/ugobas[P]tnm/seqres.c
// Function: Align_seqres
void Align_seqres(int *ali_seqres, char *seqres, int N_seqres,
		  char *seq, int nres)
{
  // ali_seqres[iseqres]=resstruct
  int IDMIN=7;
  int i=0, k=0; char *s1=seqres, *s2=seq;
  for(i=0; i<N_seqres; i++){
    if((*s1==*s2)&&(k<nres)){
      int ali=1;
      if((i==0)||(ali_seqres[i-1]<0)){
	// gap, look forward
	for(int i1=i; i1<N_seqres; i1++){
	  char *t1=seqres+i1, *t2=s2; int id=0;
	  while(*t2==*t1){
	    id++; if(id==IDMIN)break; t1++; t2++;
	  }
	  if(id==IDMIN){if(i1!=i)ali=0; break;}
	}
      }
      if(ali){ali_seqres[i]=k; k++; s2++;} // Align here
      else{ali_seqres[i]=-1;} // Align forward, not here
    }else{
      ali_seqres[i]=-1;
    }
    s1++;
  }
  if(0){
    printf("%d aligned residues over %d disordered: %d\n",
	   k, N_seqres, N_seqres-k);
    printf("SEQRES:  ");
    for(i=0; i<N_seqres; i++)printf("%c", seqres[i]);
    printf("\n");
    printf("ATOMRES: ");
    for(i=0; i<N_seqres; i++){
      if(ali_seqres[i]<0){printf("-");}
      else{printf("%c", seq[ali_seqres[i]]);}
    }
    printf("\n");
    exit(8);
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movq %rcx, -0x20(%rbp)
movl %r8d, -0x24(%rbp)
movl $0x7, -0x28(%rbp)
movl $0x0, -0x2c(%rbp)
movl $0x0, -0x30(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x20(%rbp), %rax
movq %rax, -0x40(%rbp)
movl $0x0, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
cmpl -0x14(%rbp), %eax
jge 0x149b4
movq -0x38(%rbp), %rax
movsbl (%rax), %eax
movq -0x40(%rbp), %rcx
movsbl (%rcx), %ecx
cmpl %ecx, %eax
jne 0x1498b
movl -0x30(%rbp), %eax
cmpl -0x24(%rbp), %eax
jge 0x1498b
movl $0x1, -0x44(%rbp)
cmpl $0x0, -0x2c(%rbp)
je 0x148b5
movq -0x8(%rbp), %rax
movl -0x2c(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
cmpl $0x0, (%rax,%rcx,4)
jge 0x1494f
movl -0x2c(%rbp), %eax
movl %eax, -0x48(%rbp)
movl -0x48(%rbp), %eax
cmpl -0x14(%rbp), %eax
jge 0x1494d
movq -0x10(%rbp), %rax
movslq -0x48(%rbp), %rcx
addq %rcx, %rax
movq %rax, -0x50(%rbp)
movq -0x40(%rbp), %rax
movq %rax, -0x58(%rbp)
movl $0x0, -0x5c(%rbp)
movq -0x58(%rbp), %rax
movsbl (%rax), %eax
movq -0x50(%rbp), %rcx
movsbl (%rcx), %ecx
cmpl %ecx, %eax
jne 0x14924
movl -0x5c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x5c(%rbp)
movl -0x5c(%rbp), %eax
cmpl -0x28(%rbp), %eax
jne 0x1490a
jmp 0x14924
movq -0x50(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x50(%rbp)
movq -0x58(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x58(%rbp)
jmp 0x148e5
movl -0x5c(%rbp), %eax
cmpl -0x28(%rbp), %eax
jne 0x1493d
movl -0x48(%rbp), %eax
cmpl -0x2c(%rbp), %eax
je 0x1493b
movl $0x0, -0x44(%rbp)
jmp 0x1494d
jmp 0x1493f
movl -0x48(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x48(%rbp)
jmp 0x148bb
jmp 0x1494f
cmpl $0x0, -0x44(%rbp)
je 0x1497a
movl -0x30(%rbp), %edx
movq -0x8(%rbp), %rax
movslq -0x2c(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
movl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
movq -0x40(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x40(%rbp)
jmp 0x14989
movq -0x8(%rbp), %rax
movslq -0x2c(%rbp), %rcx
movl $0xffffffff, (%rax,%rcx,4) # imm = 0xFFFFFFFF
jmp 0x1499a
movq -0x8(%rbp), %rax
movslq -0x2c(%rbp), %rcx
movl $0xffffffff, (%rax,%rcx,4) # imm = 0xFFFFFFFF
movq -0x38(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x38(%rbp)
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x14863
popq %rbp
retq
nopw %cs:(%rax,%rax)