// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x480, %rsp            # imm = 0x480
movl 0x28(%rbp), %eax
movl 0x20(%rbp), %eax
movl 0x18(%rbp), %eax
movq 0x10(%rbp), %rax
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movq %r8, -0x30(%rbp)
movq %r9, -0x38(%rbp)
movl $0x0, -0x3c(%rbp)
movq -0x30(%rbp), %rsi
movq -0x38(%rbp), %rdx
movl 0x18(%rbp), %ecx
leaq 0x1a6dc(%rip), %rdi     # 0x83185
movb $0x0, %al
callq 0x10d0
movq -0x30(%rbp), %rdi
leaq -0x3c(%rbp), %rsi
callq 0x117a0
movq %rax, -0x48(%rbp)
cmpq $0x0, -0x48(%rbp)
jne 0x68ae6
movq -0x30(%rbp), %rsi
leaq 0x1a6e2(%rip), %rdi     # 0x831b5
movb $0x0, %al
callq 0x10d0
movl $0x0, -0x4(%rbp)
jmp 0x68ee1
movl $0xffffffff, -0x4c(%rbp) # imm = 0xFFFFFFFF
movl $0x0, -0x50(%rbp)
movl $0x0, -0x54(%rbp)
movl $0x0, -0x5c(%rbp)
movl -0x5c(%rbp), %eax
cmpl 0x20(%rbp), %eax
jge 0x68b24
movq -0x20(%rbp), %rax
movslq -0x5c(%rbp), %rcx
movl $0x0, (%rax,%rcx,4)
movl -0x5c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x5c(%rbp)
jmp 0x68b02
movl 0x1a864(%rip), %eax     # 0x8338e
movl %eax, -0x465(%rbp)
movb 0x1a85c(%rip), %al      # 0x83392
movb %al, -0x461(%rbp)
movl $0x0, -0x5c(%rbp)
leaq -0x450(%rbp), %rdi
movq -0x48(%rbp), %rdx
movl $0x3e8, %esi            # imm = 0x3E8
callq 0x1130
cmpq $0x0, %rax
je 0x68e25
leaq -0x450(%rbp), %rdi
leaq 0x1a661(%rip), %rsi     # 0x831d1
movl $0x4, %edx
callq 0x1050
cmpl $0x0, %eax
jne 0x68d93
leaq -0x450(%rbp), %rdi
addq $0xb, %rdi
leaq -0x460(%rbp), %rdx
leaq 0x13802(%rip), %rsi     # 0x7c39e
movb $0x0, %al
callq 0x11a0
leaq -0x460(%rbp), %rdi
leaq -0x465(%rbp), %rsi
movl $0x3, %edx
callq 0x1050
cmpl $0x0, %eax
je 0x68c20
cmpl $0x0, -0x4c(%rbp)
jl 0x68bd4
movl -0x54(%rbp), %edx
movq -0x20(%rbp), %rax
movslq -0x4c(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
leaq -0x465(%rbp), %rdi
leaq -0x460(%rbp), %rsi
callq 0x1060
movl $0x0, -0x54(%rbp)
movl -0x4c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4c(%rbp)
movl -0x4c(%rbp), %eax
cmpl 0x20(%rbp), %eax
jl 0x68c1e
movl 0x20(%rbp), %esi
leaq 0x1a5cd(%rip), %rdi     # 0x831d6
movb $0x0, %al
callq 0x10d0
movl -0x4c(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x4c(%rbp)
jmp 0x68e25
jmp 0x68c20
movl $0x12, -0x58(%rbp)
cmpl $0x3c, -0x58(%rbp)
jge 0x68d8e
leaq -0x456(%rbp), %rdi
leaq -0x45b(%rbp), %rsi
leaq -0x450(%rbp), %rcx
movslq -0x58(%rbp), %rax
addq %rax, %rcx
movq -0x38(%rbp), %r8
leaq -0x466(%rbp), %rdx
callq 0x68ef0
movl %eax, -0x5c(%rbp)
cmpl $-0x2, -0x5c(%rbp)
jne 0x68c6b
jmp 0x68d8e
cmpl $-0x1, -0x5c(%rbp)
jne 0x68c76
jmp 0x68d80
jmp 0x68c78
leaq -0x456(%rbp), %rdi
movb -0x466(%rbp), %al
movq 0x10(%rbp), %rdx
movl 0x18(%rbp), %ecx
movl -0x5c(%rbp), %r8d
movsbl %al, %esi
callq 0x69010
movl %eax, -0x5c(%rbp)
cmpl $0x0, -0x5c(%rbp)
jge 0x68cc9
leaq -0x456(%rbp), %rsi
movsbl -0x466(%rbp), %edx
leaq -0x45b(%rbp), %rcx
leaq 0x1a535(%rip), %rdi     # 0x831f2
movb $0x0, %al
callq 0x10d0
jmp 0x68d80
movq 0x10(%rbp), %rax
movslq -0x5c(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movsbl 0x13(%rax), %eax
movl %eax, -0x474(%rbp)
leaq -0x45b(%rbp), %rdi
callq 0x130d0
movb %al, %cl
movl -0x474(%rbp), %eax
movsbl %cl, %ecx
cmpl %ecx, %eax
je 0x68d28
movl -0x5c(%rbp), %esi
movq 0x10(%rbp), %rax
movslq -0x5c(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movsbl 0x13(%rax), %edx
leaq -0x45b(%rbp), %rcx
leaq 0x1a4f6(%rip), %rdi     # 0x83217
movb $0x0, %al
callq 0x10d0
movl -0x5c(%rbp), %edx
movq -0x10(%rbp), %rax
movslq -0x4c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x54(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
movb -0x466(%rbp), %dl
movq -0x18(%rbp), %rax
movslq -0x4c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x54(%rbp), %rcx
movb %dl, (%rax,%rcx)
movl -0x54(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x54(%rbp)
movl -0x54(%rbp), %eax
cmpl 0x28(%rbp), %eax
jle 0x68d7e
movl 0x28(%rbp), %esi
leaq 0x1a4d7(%rip), %rdi     # 0x83249
movb $0x0, %al
callq 0x10d0
jmp 0x68e27
jmp 0x68d80
movl -0x58(%rbp), %eax
addl $0xb, %eax
movl %eax, -0x58(%rbp)
jmp 0x68c27
jmp 0x68e20
leaq -0x450(%rbp), %rdi
addq $0xb, %rdi
leaq 0x1a4c3(%rip), %rsi     # 0x83268
movl $0xa, %edx
callq 0x1050
cmpl $0x0, %eax
jne 0x68df4
movl $0x64, %edi
callq 0x1180
movq %rax, %rdx
movq -0x28(%rbp), %rax
movslq -0x50(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
movq -0x28(%rbp), %rax
movslq -0x50(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
leaq -0x450(%rbp), %rsi
addq $0x1c, %rsi
callq 0x1060
movl -0x50(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x50(%rbp)
jmp 0x68e1e
cmpl $0x0, -0x4c(%rbp)
jge 0x68e17
leaq -0x450(%rbp), %rdi
leaq 0x11f42(%rip), %rsi     # 0x7ad4a
movl $0x4, %edx
callq 0x1050
cmpl $0x0, %eax
jne 0x68e19
jmp 0x68e25
jmp 0x68b43
jmp 0x68e20
jmp 0x68b43
jmp 0x68e27
movq -0x48(%rbp), %rdi
callq 0x10a0
cmpl $0x0, -0x3c(%rbp)
je 0x68e3d
movb $0x0, %al
callq 0x13090
cmpl $0x0, -0x4c(%rbp)
jl 0x68e51
movl -0x54(%rbp), %edx
movq -0x20(%rbp), %rax
movslq -0x4c(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
movl -0x4c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4c(%rbp)
movl $0x0, -0x46c(%rbp)
movl $0x0, -0x470(%rbp)
movl $0x0, -0x5c(%rbp)
movl -0x5c(%rbp), %eax
cmpl -0x4c(%rbp), %eax
jge 0x68ebe
movq -0x20(%rbp), %rax
movslq -0x5c(%rbp), %rcx
movl (%rax,%rcx,4), %eax
addl -0x46c(%rbp), %eax
movl %eax, -0x46c(%rbp)
movq -0x20(%rbp), %rax
movslq -0x5c(%rbp), %rcx
cmpl $0x0, (%rax,%rcx,4)
jle 0x68eb1
movl -0x470(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x470(%rbp)
jmp 0x68eb3
movl -0x5c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x5c(%rbp)
jmp 0x68e75
movl -0x46c(%rbp), %esi
movl -0x470(%rbp), %edx
movl -0x4c(%rbp), %ecx
leaq 0x1a39f(%rip), %rdi     # 0x83273
movb $0x0, %al
callq 0x10d0
movl -0x4c(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x480, %rsp            # imm = 0x480
popq %rbp
retq
nopl (%rax)