// File: /workspace/github_c_makefile_star2_O2/ugobas[P]tnm/site_dynamics.c
// Function: Read_sites_PDB
int Read_sites_PDB(int **site_res, char **chain_res,
		   int *nres_site, char **description,
		   char *pdb, char *chain, struct residue *seq,
		   int Nres, int NMAX, int SMAX)
{
  int Compression=0;
  printf("Reading sites in file %s, chain %s %d residues\n",pdb, chain, Nres);
  FILE *file_in=Open_compressed_file(pdb, &Compression);
  if(file_in==NULL){
    printf("WARNING, file %s not found\n", pdb); return(0);
  }
  int nsites=-1, dsite=0, sres=0, l, i;
  for(i=0; i<NMAX; i++)nres_site[i]=0;
  char string[1000], resnum[6], resnam[5];
  char snam[5], snam_old[5]="   ", ch; i=0;
  while(fgets(string, sizeof(string), file_in)!=NULL){
    if(strncmp(string, "SITE", 4)==0){
      sscanf(string+11, "%s", snam);
      if(strncmp(snam, snam_old, 3)!=0){
	if(nsites>=0)nres_site[nsites]=sres;
	strcpy(snam_old, snam); sres=0; nsites++;
	if(nsites >= NMAX){
	  printf("ERROR, too many sites > %d\n", NMAX); nsites--; break;
	}
      }
      for(l=18; l<60; l+=11){
	i=Read_site(resnum, resnam, &ch, string+l, chain);
	if(i==-2){break;}else if(i==-1){continue;}
	i=Find_residue(resnum, ch, seq, Nres, i);
	if(i<0){
	  printf("WARNING, residue %s_%c_%s not found\n",
		 resnum, ch, resnam); continue;
	}
	if(seq[i].amm!=Code_3_1(resnam)){
	  printf("WARNING, residue %d is %c while it is %s in site\n",
		 i, seq[i].amm, resnam);
	}
	site_res[nsites][sres]=i;
	chain_res[nsites][sres]=ch;
	sres++;
	if(sres > SMAX){
	  printf("ERROR, too many residues > %d\n", SMAX); goto end;
	}
      }
    }else if(strncmp(string+11, "SITE_DESCR", 10)==0){
      description[dsite]=malloc(100*sizeof(char));
      strcpy(description[dsite], string+28);
      dsite++;
    }else{
      if((nsites>=0)||(strncmp(string, "ATOM", 4)==0)){break;}
      else{continue;}
    }
  }
 end:
  fclose(file_in);
  if(Compression)Delete_tmp_file();
  if(nsites>=0)nres_site[nsites]=sres;
  nsites++;
  int num=0, msites=0;
  for(i=0; i<nsites; i++){
    num+=nres_site[i];
    if(nres_site[i]>0)msites++;
  }
  printf("%d residues read in %d binding sites out of %d\n",
	 num, msites, nsites);
  return(nsites);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x468, %rsp            # imm = 0x468
movq %r8, %r13
movq %rcx, %r15
movq %rdx, 0x28(%rsp)
movq %rsi, 0x70(%rsp)
movq %rdi, 0x68(%rsp)
movl 0x4a8(%rsp), %ecx
leaq 0x3c(%rsp), %r14
andl $0x0, (%r14)
leaq 0x14baa(%rip), %rdi     # 0x57cfe
xorl %r12d, %r12d
movq %r8, %rsi
movq %r9, 0x30(%rsp)
movq %r9, %rdx
xorl %eax, %eax
callq 0x20f0
movq %r13, %rdi
movq %r14, %rsi
callq 0xd804
testq %rax, %rax
je 0x4343d
movq %rax, %r14
movl 0x4b0(%rsp), %ecx
testl %ecx, %ecx
movl $0x0, %eax
cmovgl %ecx, %eax
movq 0x28(%rsp), %rcx
cmpq %r12, %rax
je 0x431a5
andl $0x0, (%rcx,%r12,4)
incq %r12
jmp 0x43196
leaq 0x20(%rsp), %rax
movb $0x0, 0x4(%rax)
movl $0x202020, (%rax)       # imm = 0x202020
leaq 0x8b(%rsp), %r13
pushq $-0x1
popq %r12
leaq 0x7b(%rsp), %rbx
movq $0x0, 0x50(%rsp)
movl $0x0, 0x10(%rsp)
leaq 0x80(%rsp), %rdi
movl $0x3e8, %esi            # imm = 0x3E8
movq %r14, %rdx
callq 0x2170
testq %rax, %rax
je 0x43474
movl 0x80(%rsp), %ebp
movq %r13, %rdi
cmpl $0x45544953, %ebp       # imm = 0x45544953
je 0x43233
leaq 0x14bcf(%rip), %rsi     # 0x57ddc
pushq $0xa
popq %rdx
callq 0x2200
testl %eax, %eax
je 0x432a5
testl %r12d, %r12d
jns 0x43474
cmpl $0x4d4f5441, %ebp       # imm = 0x4D4F5441
jne 0x431d6
jmp 0x43474
leaq 0xdf42(%rip), %rsi      # 0x5117c
leaq 0x43(%rsp), %rbp
movq %rbp, %rdx
xorl %eax, %eax
callq 0x21f0
movq %rbp, %rdi
leaq 0x20(%rsp), %rsi
pushq $0x3
popq %rdx
callq 0x2070
testl %eax, %eax
movq %r14, 0x18(%rsp)
je 0x432d5
testl %r12d, %r12d
js 0x43276
movl %r12d, %eax
movl 0x10(%rsp), %ecx
movq 0x28(%rsp), %rdx
movl %ecx, (%rdx,%rax,4)
leaq 0x20(%rsp), %rdi
leaq 0x43(%rsp), %rsi
callq 0x2080
leal 0x1(%r12), %ebp
movl $0x0, 0x10(%rsp)
cmpl 0x4b0(%rsp), %ebp
movq 0x30(%rsp), %r14
jl 0x432dd
jmp 0x434eb
pushq $0x64
popq %rdi
callq 0x21d0
movq 0x50(%rsp), %rbp
movslq %ebp, %rbp
movq %rax, (%r15,%rbp,8)
movq %rax, %rdi
leaq 0x9c(%rsp), %rsi
callq 0x2080
incl %ebp
movq %rbp, 0x50(%rsp)
jmp 0x431d6
movl %r12d, %ebp
movq 0x30(%rsp), %r14
movq %r15, 0x48(%rsp)
movslq %ebp, %rax
movq %rax, 0x60(%rsp)
pushq $0x12
popq %r15
leaq 0x5a(%rsp), %r12
movl %ebp, 0x14(%rsp)
cmpq $0x3b, %r15
ja 0x4342b
leaq (%rsp,%r15), %rcx
addq $0x80, %rcx
movq %r12, %rdi
movq %rbx, %rsi
leaq 0xf(%rsp), %rdx
movq %r14, %r8
callq 0x4350d
cmpl $-0x1, %eax
je 0x43422
cmpl $-0x2, %eax
je 0x4342b
movq %rbx, %r13
movb 0xf(%rsp), %cl
movb %cl, 0xe(%rsp)
movsbl %cl, %ebp
movq %r12, %rdi
movl %ebp, %esi
movq 0x4a0(%rsp), %rdx
movl 0x4a8(%rsp), %ecx
movl %eax, %r8d
callq 0x435c2
testl %eax, %eax
js 0x433fa
movl %eax, %r12d
movl %eax, %ebp
shlq $0x5, %rbp
movq 0x4a0(%rsp), %rax
movb 0x13(%rax,%rbp), %r14b
movq %r13, %rbx
movq %r13, %rdi
callq 0xea8b
cmpb %al, %r14b
je 0x433af
movq 0x4a0(%rsp), %rax
addq %rbp, %rax
addq $0x13, %rax
movsbl (%rax), %edx
leaq 0x149e9(%rip), %rdi     # 0x57d8b
movl %r12d, %esi
movq %rbx, %rcx
xorl %eax, %eax
callq 0x20f0
movq 0x68(%rsp), %rax
movq 0x60(%rsp), %rdx
movq (%rax,%rdx,8), %rax
movslq 0x10(%rsp), %rcx
movl %r12d, (%rax,%rcx,4)
movq 0x70(%rsp), %rax
movq (%rax,%rdx,8), %rax
movb 0xe(%rsp), %dl
movb %dl, (%rax,%rcx)
leal 0x1(%rcx), %eax
movl %eax, 0x10(%rsp)
cmpl 0x4b8(%rsp), %ecx
movq 0x30(%rsp), %r14
jge 0x43453
leaq 0x8b(%rsp), %r13
leaq 0x5a(%rsp), %r12
jmp 0x4341e
leaq 0x14965(%rip), %rdi     # 0x57d66
movq %r12, %rsi
movl %ebp, %edx
movq %r13, %rbp
movq %r13, %rcx
xorl %eax, %eax
callq 0x20f0
leaq 0x8b(%rsp), %r13
movq %rbp, %rbx
movl 0x14(%rsp), %ebp
addq $0xb, %r15
jmp 0x432f7
movl %ebp, %r12d
movq 0x18(%rsp), %r14
movq 0x48(%rsp), %r15
jmp 0x431d6
leaq 0x148ea(%rip), %rdi     # 0x57d2e
movq %r13, %rsi
xorl %eax, %eax
callq 0x20f0
jmp 0x434d6
leaq 0x14963(%rip), %rdi     # 0x57dbd
movl 0x4b8(%rsp), %esi
xorl %eax, %eax
callq 0x20f0
movl 0x14(%rsp), %eax
movl %eax, %r12d
movq 0x18(%rsp), %r14
movq %r14, %rdi
callq 0x20c0
cmpl $0x0, 0x3c(%rsp)
movq 0x28(%rsp), %rbx
je 0x4348f
xorl %eax, %eax
callq 0xea57
testl %r12d, %r12d
js 0x4349e
movl %r12d, %eax
movl 0x10(%rsp), %ecx
movl %ecx, (%rbx,%rax,4)
movslq %r12d, %rax
xorl %ecx, %ecx
xorl %esi, %esi
xorl %edx, %edx
cmpq %rax, %rcx
jg 0x434c2
movl (%rbx,%rcx,4), %edi
addl %edi, %esi
xorl %r8d, %r8d
testl %edi, %edi
setg %r8b
addl %r8d, %edx
incq %rcx
jmp 0x434a7
incl %r12d
leaq 0x1491b(%rip), %rdi     # 0x57de7
movl %r12d, %ecx
xorl %eax, %eax
callq 0x20f0
movl %r12d, %eax
addq $0x468, %rsp            # imm = 0x468
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x14858(%rip), %rdi     # 0x57d4a
movl $0x0, 0x10(%rsp)
movl 0x4b0(%rsp), %esi
xorl %eax, %eax
callq 0x20f0
jmp 0x4346f