// File: /workspace/github_c_makefile_star2_O1/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, %r12
movq %rcx, %r15
movq %rdx, %rbx
movq %rsi, 0x78(%rsp)
movq %rdi, 0x70(%rsp)
movl 0x4a8(%rsp), %ecx
leaq 0x44(%rsp), %r14
movl $0x0, (%r14)
leaq 0x14db3(%rip), %rdi     # 0x5ddbe
xorl %ebp, %ebp
movq %r8, %rsi
movq %r9, 0x28(%rsp)
movq %r9, %rdx
xorl %eax, %eax
callq 0x20f0
movq %r12, %rdi
movq %r14, %rsi
callq 0xe1e8
testq %rax, %rax
je 0x4932a
movq %rax, %r14
movq %r15, 0x60(%rsp)
movl 0x4b0(%rsp), %eax
testl %eax, %eax
jle 0x49056
movl %eax, %edx
shlq $0x2, %rdx
movq %rbx, %rdi
xorl %esi, %esi
callq 0x2110
leaq 0x30(%rsp), %rax
movb $0x0, 0x4(%rax)
movl $0x202020, (%rax)       # imm = 0x202020
movl $0xffffffff, %r12d      # imm = 0xFFFFFFFF
leaq 0x80(%rsp), %r13
movabsq $0x5345445f45544953, %r15 # imm = 0x5345445F45544953
movq $0x0, 0x50(%rsp)
movl $0x0, 0x10(%rsp)
movq %r13, %rdi
movl $0x3e8, %esi            # imm = 0x3E8
movq %r14, %rdx
callq 0x2170
testq %rax, %rax
je 0x49366
movl 0x80(%rsp), %eax
cmpl $0x45544953, %eax       # imm = 0x45544953
je 0x490ed
movq 0x8b(%rsp), %rcx
xorq %r15, %rcx
movzwl 0x93(%rsp), %edx
xorq $0x5243, %rdx           # imm = 0x5243
orq %rcx, %rdx
je 0x4916c
testl %r12d, %r12d
jns 0x49366
cmpl $0x4d4f5441, %eax       # imm = 0x4D4F5441
jne 0x4908e
jmp 0x49366
leaq 0x8b(%rsp), %rdi
leaq 0xe170(%rip), %rsi      # 0x5726c
leaq 0x4b(%rsp), %r15
movq %r15, %rdx
xorl %eax, %eax
callq 0x21f0
movl $0x3, %edx
movq %r15, %rdi
leaq 0x30(%rsp), %rsi
callq 0x2070
testl %eax, %eax
movq %r14, 0x20(%rsp)
je 0x491a3
testl %r12d, %r12d
js 0x49135
movl %r12d, %eax
movl 0x10(%rsp), %ecx
movl %ecx, (%rbx,%rax,4)
leaq 0x30(%rsp), %rdi
leaq 0x4b(%rsp), %rsi
callq 0x2080
leal 0x1(%r12), %eax
movl $0x0, 0x10(%rsp)
cmpl 0x4b0(%rsp), %eax
movq 0x28(%rsp), %r14
movq 0x4a0(%rsp), %rbp
jl 0x491b3
jmp 0x493df
movl $0x64, %edi
callq 0x21d0
movq 0x50(%rsp), %rbp
movslq %ebp, %rbp
movq 0x60(%rsp), %rcx
movq %rax, (%rcx,%rbp,8)
movq %rax, %rdi
leaq 0x9c(%rsp), %rsi
callq 0x2080
incl %ebp
movq %rbp, 0x50(%rsp)
jmp 0x4908e
movl %r12d, %eax
movq 0x28(%rsp), %r14
movq 0x4a0(%rsp), %rbp
movq %rbx, 0x38(%rsp)
movl %eax, 0x14(%rsp)
cltq
movq %rax, 0x68(%rsp)
movl $0x7, %r15d
leaq 0x92(%rsp), %r12
leaq 0x5a(%rsp), %rbx
movq %rbx, %rdi
leaq 0x1b(%rsp), %rsi
leaq 0xf(%rsp), %rdx
movq %r12, %rcx
movq %r14, %r8
callq 0x49401
cmpl $-0x1, %eax
je 0x492f8
cmpl $-0x2, %eax
je 0x4930a
movb 0xf(%rsp), %cl
movb %cl, 0xe(%rsp)
movsbl %cl, %r13d
movq %rbx, %rdi
movl %r13d, %esi
movq %rbp, %rdx
movl 0x4a8(%rsp), %ecx
movl %eax, %r8d
callq 0x494ce
movq %rbx, %r14
movq %rbp, %rbx
testl %eax, %eax
js 0x492cc
movl %eax, %ebp
movl %eax, %r13d
shlq $0x5, %r13
movb 0x13(%rbx,%r13), %r14b
leaq 0x1b(%rsp), %rdi
callq 0xf6d3
cmpb %al, %r14b
je 0x49276
movq 0x4a0(%rsp), %rax
addq %r13, %rax
addq $0x13, %rax
movsbl (%rax), %edx
leaq 0x14be3(%rip), %rdi     # 0x5de4b
movl %ebp, %esi
leaq 0x1b(%rsp), %rcx
xorl %eax, %eax
callq 0x20f0
movq 0x70(%rsp), %rax
movq 0x68(%rsp), %rdx
movq (%rax,%rdx,8), %rax
movslq 0x10(%rsp), %rcx
movl %ebp, (%rax,%rcx,4)
movq 0x78(%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 0x28(%rsp), %r14
leaq 0x5a(%rsp), %rbx
jge 0x49340
movq 0x4a0(%rsp), %rbp
leaq 0x80(%rsp), %r13
jmp 0x492f8
leaq 0x14b53(%rip), %rdi     # 0x5de26
movq %r14, %rsi
movl %r13d, %edx
leaq 0x1b(%rsp), %rcx
xorl %eax, %eax
callq 0x20f0
movq %rbx, %rbp
leaq 0x80(%rsp), %r13
movq %r14, %rbx
movq 0x28(%rsp), %r14
addq $0xb, %r15
addq $0xb, %r12
cmpq $0x31, %r15
jb 0x491d6
movl 0x14(%rsp), %eax
movl %eax, %r12d
movq 0x38(%rsp), %rbx
movq 0x20(%rsp), %r14
movabsq $0x5345445f45544953, %r15 # imm = 0x5345445F45544953
jmp 0x4908e
leaq 0x14abd(%rip), %rdi     # 0x5ddee
movq %r12, %rsi
xorl %eax, %eax
callq 0x20f0
jmp 0x493cb
leaq 0x14b36(%rip), %rdi     # 0x5de7d
movl 0x4b8(%rsp), %esi
xorl %eax, %eax
callq 0x20f0
movl 0x14(%rsp), %eax
movl %eax, %r12d
movq 0x38(%rsp), %rbx
movq 0x20(%rsp), %r14
movq %r14, %rdi
callq 0x20c0
cmpl $0x0, 0x44(%rsp)
je 0x4937c
xorl %eax, %eax
callq 0xf69f
testl %r12d, %r12d
js 0x4938b
movl %r12d, %eax
movl 0x10(%rsp), %ecx
movl %ecx, (%rbx,%rax,4)
leal 0x1(%r12), %ebp
testl %r12d, %r12d
js 0x493b7
incl %r12d
xorl %eax, %eax
xorl %edx, %edx
xorl %esi, %esi
movl (%rbx,%rax,4), %ecx
addl %ecx, %esi
xorl %edi, %edi
testl %ecx, %ecx
setg %dil
addl %edi, %edx
incq %rax
cmpq %rax, %r12
jne 0x4939e
jmp 0x493bb
xorl %esi, %esi
xorl %edx, %edx
leaq 0x14ae5(%rip), %rdi     # 0x5dea7
movl %ebp, %ecx
xorl %eax, %eax
callq 0x20f0
movl %ebp, %eax
addq $0x468, %rsp            # imm = 0x468
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x14a24(%rip), %rdi     # 0x5de0a
movl $0x0, 0x10(%rsp)
movl 0x4b0(%rsp), %esi
xorl %eax, %eax
callq 0x20f0
jmp 0x49361