// File: /workspace/github_c_makefile_star2_O0/ugobas[P]tnm/seqres.c
// Function: Read_seqres
int Read_seqres(char **seqres, int *N_seqres, int NCHAIN,
		char *file_pdb, char *chain_to_read)
{
  /* Open file */
  int Compression;
  FILE *file_in=Open_compressed_file(file_pdb, &Compression);
  if(file_in==NULL)return(0);

  int nchain=0, read=0, L=0, n=0;
  char string[200], chain_old='-', *seq=NULL;
  while(fgets(string, sizeof(string), file_in)!=NULL){
    if(strncmp(string,"ATOM", 4)==0)break;
    if(strncmp(string,"SEQRES", 6)==0){
      char chain=string[11];
      if(chain!=chain_old){
	if(n){
	  printf("%d residues read %d expected for chain %d\n",
		 n, L, nchain); n=0;
	}
	chain_old=chain; int ic=0;
	while((chain_to_read[ic]!='\0')&&(chain!=chain_to_read[ic]))ic++;
	if(chain_to_read[ic]!=chain){read=0; continue;}
	read=1; sscanf(string+12, "%d", &L);
	printf("Reading chain %d %c %d residues\n", nchain, chain, L);
	seqres[nchain]=malloc(L*sizeof(char)); seq=seqres[nchain];
	N_seqres[nchain]=L;
	nchain++;
      }
      if(read==0)continue;
      char amm[3], aa3[4], *str=string+19;
      for(int k=0; k<13; k++){
	sscanf(str, "%s", aa3); str+=4;
	int exo=0; Get_amm(amm, &exo, aa3, 0, 0);
	*seq=amm[1]; seq++; n++; if(n==L)break;
      }
    }
  }
  if(n){
    printf("%d residues read %d expected for chain %d\n",
	   n, L, nchain); n=0;
  }
  if(nchain!=NCHAIN){
    printf("WARNING in SEQRES, %d chains expected (%s), %d found\n",
	   NCHAIN, chain_to_read, nchain);
    if(nchain==0){printf("Getting residues from atoms\n"); return(-1);}
    else{printf("Exiting\n"); exit(8);}
  }
  return(0);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x160, %rsp            # imm = 0x160
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl %edx, -0x1c(%rbp)
movq %rcx, -0x28(%rbp)
movq %r8, -0x30(%rbp)
movq -0x28(%rbp), %rdi
leaq -0x34(%rbp), %rsi
callq 0x117a0
movq %rax, -0x40(%rbp)
cmpq $0x0, -0x40(%rbp)
jne 0x144c2
movl $0x0, -0x4(%rbp)
jmp 0x14810
movl $0x0, -0x44(%rbp)
movl $0x0, -0x48(%rbp)
movl $0x0, -0x4c(%rbp)
movl $0x0, -0x50(%rbp)
movb $0x2d, -0x121(%rbp)
movq $0x0, -0x130(%rbp)
leaq -0x120(%rbp), %rdi
movq -0x40(%rbp), %rdx
movl $0xc8, %esi
callq 0x1130
cmpq $0x0, %rax
je 0x14790
leaq -0x120(%rbp), %rdi
leaq 0x6682d(%rip), %rsi     # 0x7ad4a
movl $0x4, %edx
callq 0x1050
cmpl $0x0, %eax
jne 0x14531
jmp 0x14790
leaq -0x120(%rbp), %rdi
leaq 0x66bd6(%rip), %rsi     # 0x7b115
movl $0x6, %edx
callq 0x1050
cmpl $0x0, %eax
jne 0x1478b
movb -0x115(%rbp), %al
movb %al, -0x131(%rbp)
movsbl -0x131(%rbp), %eax
movsbl -0x121(%rbp), %ecx
cmpl %ecx, %eax
je 0x146b3
cmpl $0x0, -0x50(%rbp)
je 0x14598
movl -0x50(%rbp), %esi
movl -0x4c(%rbp), %edx
movl -0x44(%rbp), %ecx
leaq 0x66b92(%rip), %rdi     # 0x7b11c
movb $0x0, %al
callq 0x10d0
movl $0x0, -0x50(%rbp)
movb -0x131(%rbp), %al
movb %al, -0x121(%rbp)
movl $0x0, -0x138(%rbp)
movq -0x30(%rbp), %rax
movslq -0x138(%rbp), %rcx
movsbl (%rax,%rcx), %ecx
xorl %eax, %eax
cmpl $0x0, %ecx
movb %al, -0x151(%rbp)
je 0x145eb
movsbl -0x131(%rbp), %eax
movq -0x30(%rbp), %rcx
movslq -0x138(%rbp), %rdx
movsbl (%rcx,%rdx), %ecx
cmpl %ecx, %eax
setne %al
movb %al, -0x151(%rbp)
movb -0x151(%rbp), %al
testb $0x1, %al
jne 0x145f7
jmp 0x14608
movl -0x138(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x138(%rbp)
jmp 0x145ae
movq -0x30(%rbp), %rax
movslq -0x138(%rbp), %rcx
movsbl (%rax,%rcx), %eax
movsbl -0x131(%rbp), %ecx
cmpl %ecx, %eax
je 0x1462e
movl $0x0, -0x48(%rbp)
jmp 0x144f0
movl $0x1, -0x48(%rbp)
leaq -0x120(%rbp), %rdi
addq $0xc, %rdi
leaq 0x6e067(%rip), %rsi     # 0x826ae
leaq -0x4c(%rbp), %rdx
movb $0x0, %al
callq 0x11a0
movl -0x44(%rbp), %esi
movsbl -0x131(%rbp), %edx
movl -0x4c(%rbp), %ecx
leaq 0x66ae1(%rip), %rdi     # 0x7b147
movb $0x0, %al
callq 0x10d0
movslq -0x4c(%rbp), %rdi
shlq $0x0, %rdi
callq 0x1180
movq %rax, %rdx
movq -0x10(%rbp), %rax
movslq -0x44(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
movq -0x10(%rbp), %rax
movslq -0x44(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x130(%rbp)
movl -0x4c(%rbp), %edx
movq -0x18(%rbp), %rax
movslq -0x44(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
movl -0x44(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x44(%rbp)
cmpl $0x0, -0x48(%rbp)
jne 0x146be
jmp 0x144f0
leaq -0x120(%rbp), %rax
addq $0x13, %rax
movq %rax, -0x148(%rbp)
movl $0x0, -0x14c(%rbp)
cmpl $0xd, -0x14c(%rbp)
jge 0x14789
movq -0x148(%rbp), %rdi
leaq -0x13f(%rbp), %rdx
leaq 0x67ca2(%rip), %rsi     # 0x7c39e
movb $0x0, %al
callq 0x11a0
movq -0x148(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x148(%rbp)
movl $0x0, -0x150(%rbp)
leaq -0x13b(%rbp), %rdi
leaq -0x13f(%rbp), %rdx
leaq -0x150(%rbp), %rsi
xorl %r8d, %r8d
movl %r8d, %ecx
callq 0x12810
movb -0x13a(%rbp), %cl
movq -0x130(%rbp), %rax
movb %cl, (%rax)
movq -0x130(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x130(%rbp)
movl -0x50(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x50(%rbp)
movl -0x50(%rbp), %eax
cmpl -0x4c(%rbp), %eax
jne 0x14773
jmp 0x14789
jmp 0x14775
movl -0x14c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14c(%rbp)
jmp 0x146da
jmp 0x1478b
jmp 0x144f0
cmpl $0x0, -0x50(%rbp)
je 0x147b4
movl -0x50(%rbp), %esi
movl -0x4c(%rbp), %edx
movl -0x44(%rbp), %ecx
leaq 0x66976(%rip), %rdi     # 0x7b11c
movb $0x0, %al
callq 0x10d0
movl $0x0, -0x50(%rbp)
movl -0x44(%rbp), %eax
cmpl -0x1c(%rbp), %eax
je 0x14809
movl -0x1c(%rbp), %esi
movq -0x30(%rbp), %rdx
movl -0x44(%rbp), %ecx
leaq 0x6699b(%rip), %rdi     # 0x7b168
movb $0x0, %al
callq 0x10d0
cmpl $0x0, -0x44(%rbp)
jne 0x147f1
leaq 0x669bd(%rip), %rdi     # 0x7b19e
movb $0x0, %al
callq 0x10d0
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x14810
leaq 0x669c3(%rip), %rdi     # 0x7b1bb
movb $0x0, %al
callq 0x10d0
movl $0x8, %edi
callq 0x1210
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x160, %rsp            # imm = 0x160
popq %rbp
retq
nopl (%rax)