// File: /workspace/github_c_makefile_star2_O0/ugobas[P]tnm/site_dynamics.c
// Function: Read_sites_file
int Read_sites_file(int **site_res, char **chain_res,
		    int *nres_site, char **description,
		    char *file, char *chain, struct residue *seq,
		    int Nres, int NMAX, int SMAX)
{
  printf("Reading sites in file %s, chain %s %d residues\n",file, chain, Nres);
  FILE *file_in=fopen(file, "r");
  if(file_in==NULL){
    printf("WARNING, active site file %s not found\n", file); return(0);
  }
  int nsite=-1, sres=0, i, res; 
  char string[1000], resnum[6]="\0", resnam[5]="\0"; //, icode='\0';
  char snam[5], snam_old[5]="   ", ch[6]; i=-1;
  while(fgets(string, sizeof(string), file_in)!=NULL){
    if(string[0]=='#'){
      continue;
    }else if(strncmp(string, "SITE_DESCRIPTION", 10)==0){
      if(New_site(&nsite, &sres, nres_site, description, NMAX))break;
      strcpy(description[nsite], string+18);
      strcpy(snam_old, "   ");
    }else{
      sscanf(string, "%s%s%s%d", snam, resnam, ch, &res); //, &icode
      if(strcmp(snam, snam_old)!=0){
	if(strcmp(snam_old, "   ")!=0){
	  if(New_site(&nsite, &sres, nres_site, description, NMAX))break;
	  sprintf(description[nsite], "SITE_%s", snam);
	}
	strcpy(snam_old, snam);
      }
      //if(icode=='\n')icode='\0';
      //sprintf(resnum, "%d%c", res, icode);
      sprintf(resnum, "%d", res);
      i=Find_residue(resnum, ch[0], seq, Nres, i+1);
      if(i<0){
	printf("Residue %s_%s_%c discarded, chain: %s L=%d\n",
	       resnam, resnum,ch[0],chain,Nres); continue;
      }
      if(seq[i].amm!=Code_3_1(resnam)){
	printf("WARNING, residue %d is %c while it is %s in site %s\n",
	       i, seq[i].amm, resnam, snam);
      }
      site_res[nsite][sres]=i;
      chain_res[nsite][sres]=ch[0];
      sres++;
      if(sres > SMAX){
	printf("ERROR, too many residues > %d\n", SMAX); goto end;
      }
    }
  }
 end:
  fclose(file_in);
  if(nsite>=0)nres_site[nsite]=sres;
  nsite++;
  int num=0, msites=0;
  for(i=0; i<nsite; i++){
    num+=nres_site[i];
    if(nres_site[i]>0)msites++;
  }
  printf("file %s, reading %d residues in %d binding sites out of %d\n",
	 file, num, msites, nsite);
  return(nsite);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x470, %rsp            # imm = 0x470
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)
movq -0x30(%rbp), %rsi
movq -0x38(%rbp), %rdx
movl 0x18(%rbp), %ecx
leaq 0x1ab13(%rip), %rdi     # 0x83185
movb $0x0, %al
callq 0x10d0
movq -0x30(%rbp), %rdi
leaq 0x19e59(%rip), %rsi     # 0x824dd
callq 0x11b0
movq %rax, -0x40(%rbp)
cmpq $0x0, -0x40(%rbp)
jne 0x686b2
movq -0x30(%rbp), %rsi
leaq 0x1ac04(%rip), %rdi     # 0x832a3
movb $0x0, %al
callq 0x10d0
movl $0x0, -0x4(%rbp)
jmp 0x68a46
movl $0xffffffff, -0x44(%rbp) # imm = 0xFFFFFFFF
movl $0x0, -0x48(%rbp)
leaq -0x446(%rbp), %rdi
xorl %esi, %esi
movl $0x6, %edx
callq 0x10e0
leaq -0x44b(%rbp), %rdi
xorl %esi, %esi
movl $0x5, %edx
callq 0x10e0
movl 0x1aca7(%rip), %eax     # 0x83393
movl %eax, -0x455(%rbp)
movb 0x1ac9f(%rip), %al      # 0x83397
movb %al, -0x451(%rbp)
movl $0xffffffff, -0x4c(%rbp) # imm = 0xFFFFFFFF
leaq -0x440(%rbp), %rdi
movq -0x40(%rbp), %rdx
movl $0x3e8, %esi            # imm = 0x3E8
callq 0x1130
cmpq $0x0, %rax
je 0x68992
movsbl -0x440(%rbp), %eax
cmpl $0x23, %eax
jne 0x68732
jmp 0x68705
leaq -0x440(%rbp), %rdi
leaq 0x1ab8b(%rip), %rsi     # 0x832cb
movl $0xa, %edx
callq 0x1050
cmpl $0x0, %eax
jne 0x687a6
movq -0x20(%rbp), %rdx
movq -0x28(%rbp), %rcx
movl 0x20(%rbp), %r8d
leaq -0x44(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0x69120
cmpl $0x0, %eax
je 0x68772
jmp 0x68992
movq -0x28(%rbp), %rax
movslq -0x44(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
leaq -0x440(%rbp), %rsi
addq $0x12, %rsi
callq 0x1060
leaq -0x455(%rbp), %rdi
leaq 0x15de3(%rip), %rsi     # 0x7e57f
callq 0x1060
jmp 0x6898b
leaq -0x440(%rbp), %rdi
leaq -0x450(%rbp), %rdx
leaq -0x44b(%rbp), %rcx
leaq -0x45b(%rbp), %r8
leaq 0x1ab13(%rip), %rsi     # 0x832dc
leaq -0x50(%rbp), %r9
movb $0x0, %al
callq 0x11a0
leaq -0x450(%rbp), %rdi
leaq -0x455(%rbp), %rsi
callq 0x1140
cmpl $0x0, %eax
je 0x6885b
leaq -0x455(%rbp), %rdi
leaq 0x15d85(%rip), %rsi     # 0x7e57f
callq 0x1140
cmpl $0x0, %eax
je 0x68848
movq -0x20(%rbp), %rdx
movq -0x28(%rbp), %rcx
movl 0x20(%rbp), %r8d
leaq -0x44(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0x69120
cmpl $0x0, %eax
je 0x68827
jmp 0x68992
movq -0x28(%rbp), %rax
movslq -0x44(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
leaq -0x450(%rbp), %rdx
leaq 0x1aaa4(%rip), %rsi     # 0x832e5
movb $0x0, %al
callq 0x1200
leaq -0x455(%rbp), %rdi
leaq -0x450(%rbp), %rsi
callq 0x1060
leaq -0x446(%rbp), %rdi
movl -0x50(%rbp), %edx
leaq 0x19e42(%rip), %rsi     # 0x826ae
movb $0x0, %al
callq 0x1200
leaq -0x446(%rbp), %rdi
movb -0x45b(%rbp), %al
movq 0x10(%rbp), %rdx
movl 0x18(%rbp), %ecx
movl -0x4c(%rbp), %r8d
addl $0x1, %r8d
movsbl %al, %esi
callq 0x69010
movl %eax, -0x4c(%rbp)
cmpl $0x0, -0x4c(%rbp)
jge 0x688d0
leaq -0x44b(%rbp), %rsi
leaq -0x446(%rbp), %rdx
movsbl -0x45b(%rbp), %ecx
movq -0x38(%rbp), %r8
movl 0x18(%rbp), %r9d
leaq 0x1aa29(%rip), %rdi     # 0x832ed
movb $0x0, %al
callq 0x10d0
jmp 0x68705
movq 0x10(%rbp), %rax
movslq -0x4c(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movsbl 0x13(%rax), %eax
movl %eax, -0x468(%rbp)
leaq -0x44b(%rbp), %rdi
callq 0x130d0
movb %al, %cl
movl -0x468(%rbp), %eax
movsbl %cl, %ecx
cmpl %ecx, %eax
je 0x68936
movl -0x4c(%rbp), %esi
movq 0x10(%rbp), %rax
movslq -0x4c(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movsbl 0x13(%rax), %edx
leaq -0x44b(%rbp), %rcx
leaq -0x450(%rbp), %r8
leaq 0x1a9ea(%rip), %rdi     # 0x83319
movb $0x0, %al
callq 0x10d0
movl -0x4c(%rbp), %edx
movq -0x10(%rbp), %rax
movslq -0x44(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x48(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
movb -0x45b(%rbp), %dl
movq -0x18(%rbp), %rax
movslq -0x44(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x48(%rbp), %rcx
movb %dl, (%rax,%rcx)
movl -0x48(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x48(%rbp)
movl -0x48(%rbp), %eax
cmpl 0x28(%rbp), %eax
jle 0x68989
movl 0x28(%rbp), %esi
leaq 0x1a8c9(%rip), %rdi     # 0x83249
movb $0x0, %al
callq 0x10d0
jmp 0x68994
jmp 0x6898b
jmp 0x6898d
jmp 0x68705
jmp 0x68994
movq -0x40(%rbp), %rdi
callq 0x10a0
cmpl $0x0, -0x44(%rbp)
jl 0x689b1
movl -0x48(%rbp), %edx
movq -0x20(%rbp), %rax
movslq -0x44(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
movl -0x44(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x44(%rbp)
movl $0x0, -0x460(%rbp)
movl $0x0, -0x464(%rbp)
movl $0x0, -0x4c(%rbp)
movl -0x4c(%rbp), %eax
cmpl -0x44(%rbp), %eax
jge 0x68a1e
movq -0x20(%rbp), %rax
movslq -0x4c(%rbp), %rcx
movl (%rax,%rcx,4), %eax
addl -0x460(%rbp), %eax
movl %eax, -0x460(%rbp)
movq -0x20(%rbp), %rax
movslq -0x4c(%rbp), %rcx
cmpl $0x0, (%rax,%rcx,4)
jle 0x68a11
movl -0x464(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x464(%rbp)
jmp 0x68a13
movl -0x4c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4c(%rbp)
jmp 0x689d5
movq -0x30(%rbp), %rsi
movl -0x460(%rbp), %edx
movl -0x464(%rbp), %ecx
movl -0x44(%rbp), %r8d
leaq 0x1a915(%rip), %rdi     # 0x8334e
movb $0x0, %al
callq 0x10d0
movl -0x44(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x470, %rsp            # imm = 0x470
popq %rbp
retq
nopw %cs:(%rax,%rax)