// File: /workspace/github_c_makefile_star2_O0/josch[P]stride/rdpdb.c
// Function: ReadPDBFile
int ReadPDBFile(CHAIN **Chain, int *Cn, COMMAND *Cmd)
{

  int ChainCnt, InfoCnt, i;
  enum METHOD Method = XRay;
  BOOLEAN First_ATOM, Published=YES, DsspAssigned=NO;
  float Resolution = 0.0;
  FILE *pdb;
  BUFFER Buffer;
  char *Info[MAX_INFO], PdbIdent[5];
  RESIDUE *r;
  CHAIN *c;

  *Cn= 0;
  InfoCnt = 0;
  strcpy(PdbIdent,"~~~~");

  if( !(pdb = fopen(Cmd->InputFile,"r")) )
    return(FAILURE); 
     
  First_ATOM = YES;
  
  while( fgets(Buffer,BUFSZ,pdb) ) {
    
    if(!strncmp(Buffer,"HEADER",6)) {
      Info[InfoCnt] = (char *)ckalloc(BUFSZ*sizeof(char));
      strcpy(Info[InfoCnt],"HDR  ");
      strcat(Info[InfoCnt++],Buffer+10);
      strncpy(PdbIdent,Buffer+62,4);
      PdbIdent[4] = '\0';
    }
    else
    if(!strncmp(Buffer,"AUTHOR",6)) {
      Info[InfoCnt] = (char *)ckalloc(BUFSZ*sizeof(char));
      strcpy(Info[InfoCnt],"AUT  ");
      strcat(Info[InfoCnt++],Buffer+10);
    }
    else
    if(!strncmp(Buffer,"SOURCE",6)) {
      Info[InfoCnt] = (char *)ckalloc(BUFSZ*sizeof(char));
      strcpy(Info[InfoCnt],"SRC  ");
      strcat(Info[InfoCnt++],Buffer+10);
    }
    else
    if(!strncmp(Buffer,"COMPND",6)) {
      if( !Process_COMPND(Buffer,&Method) ) 
	return(FAILURE);
      else {
	Info[InfoCnt] = (char *)ckalloc(BUFSZ*sizeof(char));
	strcpy(Info[InfoCnt],"CMP  ");
	strcat(Info[InfoCnt++],Buffer+10);
      }
    }
    else if(!strncmp(Buffer,"JRNL",4) && !Process_JRNL(Buffer,&Published)) 
	return(FAILURE);
    else if(!strncmp(Buffer,"REMARK",6) && !Process_REMARK(Buffer,&Method,&Resolution,
							   &DsspAssigned)) 
      return(FAILURE);
    else if(!strncmp(Buffer,"EXPDTA",6) && !Process_EXPDTA(Buffer,&Method)) 
      return(FAILURE);
    else if(!strncmp(Buffer,"MODEL",5) && !Process_MODEL(&Method)) 
      return(FAILURE);
    else if(!strncmp(Buffer,"ENDMDL",6)) {
      Process_ENDMDL(Buffer,Chain,Cn);
      break;
    }
    else if(!strncmp(Buffer,"HELIX",5) && !Process_HELIX(Buffer,Chain,Cn,Cmd)) 
      return(FAILURE);
    else if(!strncmp(Buffer,"SHEET",5) && !Process_SHEET(Buffer,Chain,Cn,Cmd)) 
      return(FAILURE);
    else if(!strncmp(Buffer,"TURN",4) && !Process_TURN(Buffer,Chain,Cn,Cmd)) 
      return(FAILURE);
    else if(!strncmp(Buffer,"SSBOND",6) && !Process_SSBOND(Buffer,Chain,Cn,Cmd)) 
      return(FAILURE);
    else if(!strncmp(Buffer,"ATOM",4) && !Process_ATOM(Buffer,Chain,Cn,&First_ATOM,Cmd)) 
      return(FAILURE);
  }
  fclose(pdb);

  for( ChainCnt=0; ChainCnt< *Cn; ChainCnt++ ) {
    c = Chain[ChainCnt];
    if( c->NRes != 0  && !FindAtom(c,c->NRes,"CA",&i) )
      c->NRes--;
    strcpy(c->File,Cmd->InputFile);

    strcpy(c->PdbIdent,PdbIdent);
    if( c->NRes != 0 )  c->NRes++;
    if( c->NSheet != -1 ) c->NSheet++;
    c->Resolution = Resolution;
    c->Method = Method;
    c->Published = Published;
    c->DsspAssigned = DsspAssigned;
    c->NInfo = InfoCnt;
    for(i=0; i<InfoCnt; i++) {
      c->Info[i] = (char *)ckalloc(BUFSZ*sizeof(char));
      strcpy(c->Info[i],Info[i]);
      c->Info[i][71] = '\0';
    }
    for( i=0; i<c->NRes; i++ ) {
      r = c->Rsd[i];
      r->Inv =  (INVOLVED *)ckalloc(sizeof(INVOLVED));
      r->Prop = (PROPERTY *)ckalloc(sizeof(PROPERTY));
      r->Inv->NBondDnr = 0;
      r->Inv->NBondAcc = 0;
      r->Inv->InterchainHBonds = NO;
      r->Prop->Asn     = 'C';
      r->Prop->PdbAsn  = 'C';
      r->Prop->DsspAsn = 'C';
      r->Prop->Solv    = 0.0;
      r->Prop->Phi     = 360.0;
      r->Prop->Psi     = 360.0;
    }
  }
  
  for(i=0; i<InfoCnt; i++)
    free(Info[i]);
  
  return(SUCCESS);
}

// Assembly:
subq $0x23b8, %rsp           # imm = 0x23B8
movq %rdi, 0x23a8(%rsp)
movq %rsi, 0x23a0(%rsp)
movq %rdx, 0x2398(%rsp)
movl $0x0, 0x2388(%rsp)
movl $0x1, 0x2380(%rsp)
movl $0x0, 0x237c(%rsp)
xorps %xmm0, %xmm0
movss %xmm0, 0x2378(%rsp)
movq 0x23a0(%rsp), %rax
movl $0x0, (%rax)
movl $0x0, 0x2390(%rsp)
leaq 0x1b(%rsp), %rdi
leaq 0x27d57(%rip), %rsi     # 0x2b778
callq 0x2060
movq 0x2398(%rsp), %rdi
leaq 0x28e68(%rip), %rsi     # 0x2c89d
callq 0x2190
movq %rax, 0x2370(%rsp)
cmpq $0x0, %rax
jne 0x3a58
movl $0x0, 0x23b4(%rsp)
jmp 0x4383
movl $0x1, 0x2384(%rsp)
leaq 0x1f60(%rsp), %rdi
movq 0x2370(%rsp), %rdx
movl $0x400, %esi            # imm = 0x400
callq 0x2110
cmpq $0x0, %rax
je 0x4024
leaq 0x1f60(%rsp), %rdi
leaq 0x27ce7(%rip), %rsi     # 0x2b77d
movl $0x6, %edx
callq 0x2050
cmpl $0x0, %eax
jne 0x3b2c
movl $0x400, %edi            # imm = 0x400
callq 0x7360
movq %rax, %rcx
movslq 0x2390(%rsp), %rax
movq %rcx, 0x20(%rsp,%rax,8)
movslq 0x2390(%rsp), %rax
movq 0x20(%rsp,%rax,8), %rdi
leaq 0x27cad(%rip), %rsi     # 0x2b784
callq 0x2060
movl 0x2390(%rsp), %eax
movl %eax, %ecx
addl $0x1, %ecx
movl %ecx, 0x2390(%rsp)
cltq
movq 0x20(%rsp,%rax,8), %rdi
leaq 0x1f60(%rsp), %rsi
addq $0xa, %rsi
callq 0x21e0
leaq 0x1b(%rsp), %rdi
leaq 0x1f60(%rsp), %rsi
addq $0x3e, %rsi
movl $0x4, %edx
callq 0x2040
movb $0x0, 0x1f(%rsp)
jmp 0x401f
leaq 0x1f60(%rsp), %rdi
leaq 0x27c4f(%rip), %rsi     # 0x2b78a
movl $0x6, %edx
callq 0x2050
cmpl $0x0, %eax
jne 0x3bad
movl $0x400, %edi            # imm = 0x400
callq 0x7360
movq %rax, %rcx
movslq 0x2390(%rsp), %rax
movq %rcx, 0x20(%rsp,%rax,8)
movslq 0x2390(%rsp), %rax
movq 0x20(%rsp,%rax,8), %rdi
leaq 0x27c19(%rip), %rsi     # 0x2b791
callq 0x2060
movl 0x2390(%rsp), %eax
movl %eax, %ecx
addl $0x1, %ecx
movl %ecx, 0x2390(%rsp)
cltq
movq 0x20(%rsp,%rax,8), %rdi
leaq 0x1f60(%rsp), %rsi
addq $0xa, %rsi
callq 0x21e0
jmp 0x401d
leaq 0x1f60(%rsp), %rdi
leaq 0x27bdb(%rip), %rsi     # 0x2b797
movl $0x6, %edx
callq 0x2050
cmpl $0x0, %eax
jne 0x3c2e
movl $0x400, %edi            # imm = 0x400
callq 0x7360
movq %rax, %rcx
movslq 0x2390(%rsp), %rax
movq %rcx, 0x20(%rsp,%rax,8)
movslq 0x2390(%rsp), %rax
movq 0x20(%rsp,%rax,8), %rdi
leaq 0x27ba5(%rip), %rsi     # 0x2b79e
callq 0x2060
movl 0x2390(%rsp), %eax
movl %eax, %ecx
addl $0x1, %ecx
movl %ecx, 0x2390(%rsp)
cltq
movq 0x20(%rsp,%rax,8), %rdi
leaq 0x1f60(%rsp), %rsi
addq $0xa, %rsi
callq 0x21e0
jmp 0x401b
leaq 0x1f60(%rsp), %rdi
leaq 0x27b67(%rip), %rsi     # 0x2b7a4
movl $0x6, %edx
callq 0x2050
cmpl $0x0, %eax
jne 0x3cdd
leaq 0x1f60(%rsp), %rdi
leaq 0x2388(%rsp), %rsi
callq 0x1b6b0
cmpl $0x0, %eax
jne 0x3c7a
movl $0x0, 0x23b4(%rsp)
jmp 0x4383
movl $0x400, %edi            # imm = 0x400
callq 0x7360
movq %rax, %rcx
movslq 0x2390(%rsp), %rax
movq %rcx, 0x20(%rsp,%rax,8)
movslq 0x2390(%rsp), %rax
movq 0x20(%rsp,%rax,8), %rdi
leaq 0x27b03(%rip), %rsi     # 0x2b7ab
callq 0x2060
movl 0x2390(%rsp), %eax
movl %eax, %ecx
addl $0x1, %ecx
movl %ecx, 0x2390(%rsp)
cltq
movq 0x20(%rsp,%rax,8), %rdi
leaq 0x1f60(%rsp), %rsi
addq $0xa, %rsi
callq 0x21e0
jmp 0x4019
leaq 0x1f60(%rsp), %rdi
leaq 0x27ac5(%rip), %rsi     # 0x2b7b1
movl $0x4, %edx
callq 0x2050
cmpl $0x0, %eax
jne 0x3d25
leaq 0x1f60(%rsp), %rdi
leaq 0x2380(%rsp), %rsi
callq 0x19530
cmpl $0x0, %eax
jne 0x3d25
movl $0x0, 0x23b4(%rsp)
jmp 0x4383
leaq 0x1f60(%rsp), %rdi
leaq 0x27a82(%rip), %rsi     # 0x2b7b6
movl $0x6, %edx
callq 0x2050
cmpl $0x0, %eax
jne 0x3d7d
leaq 0x1f60(%rsp), %rdi
leaq 0x2388(%rsp), %rsi
leaq 0x2378(%rsp), %rdx
leaq 0x237c(%rsp), %rcx
callq 0x195f0
cmpl $0x0, %eax
jne 0x3d7d
movl $0x0, 0x23b4(%rsp)
jmp 0x4383
leaq 0x1f60(%rsp), %rdi
leaq 0x27a31(%rip), %rsi     # 0x2b7bd
movl $0x6, %edx
callq 0x2050
cmpl $0x0, %eax
jne 0x3dc5
leaq 0x1f60(%rsp), %rdi
leaq 0x2388(%rsp), %rsi
callq 0x1b5b0
cmpl $0x0, %eax
jne 0x3dc5
movl $0x0, 0x23b4(%rsp)
jmp 0x4383
leaq 0x1f60(%rsp), %rdi
leaq 0x279f0(%rip), %rsi     # 0x2b7c4
movl $0x5, %edx
callq 0x2050
cmpl $0x0, %eax
jne 0x3e05
leaq 0x2388(%rsp), %rdi
callq 0x1b690
cmpl $0x0, %eax
jne 0x3e05
movl $0x0, 0x23b4(%rsp)
jmp 0x4383
leaq 0x1f60(%rsp), %rdi
leaq 0x279b6(%rip), %rsi     # 0x2b7ca
movl $0x6, %edx
callq 0x2050
cmpl $0x0, %eax
jne 0x3e45
leaq 0x1f60(%rsp), %rdi
movq 0x23a8(%rsp), %rsi
movq 0x23a0(%rsp), %rdx
callq 0x299a0
jmp 0x4024
leaq 0x1f60(%rsp), %rdi
leaq 0x2797d(%rip), %rsi     # 0x2b7d1
movl $0x5, %edx
callq 0x2050
cmpl $0x0, %eax
jne 0x3e9d
leaq 0x1f60(%rsp), %rdi
movq 0x23a8(%rsp), %rsi
movq 0x23a0(%rsp), %rdx
movq 0x2398(%rsp), %rcx
callq 0x1a0b0
cmpl $0x0, %eax
jne 0x3e9d
movl $0x0, 0x23b4(%rsp)
jmp 0x4383
leaq 0x1f60(%rsp), %rdi
leaq 0x2792b(%rip), %rsi     # 0x2b7d7
movl $0x5, %edx
callq 0x2050
cmpl $0x0, %eax
jne 0x3ef5
leaq 0x1f60(%rsp), %rdi
movq 0x23a8(%rsp), %rsi
movq 0x23a0(%rsp), %rdx
movq 0x2398(%rsp), %rcx
callq 0x1a4c0
cmpl $0x0, %eax
jne 0x3ef5
movl $0x0, 0x23b4(%rsp)
jmp 0x4383
leaq 0x1f60(%rsp), %rdi
leaq 0x278d9(%rip), %rsi     # 0x2b7dd
movl $0x4, %edx
callq 0x2050
cmpl $0x0, %eax
jne 0x3f4d
leaq 0x1f60(%rsp), %rdi
movq 0x23a8(%rsp), %rsi
movq 0x23a0(%rsp), %rdx
movq 0x2398(%rsp), %rcx
callq 0x1aed0
cmpl $0x0, %eax
jne 0x3f4d
movl $0x0, 0x23b4(%rsp)
jmp 0x4383
leaq 0x1f60(%rsp), %rdi
leaq 0x27886(%rip), %rsi     # 0x2b7e2
movl $0x6, %edx
callq 0x2050
cmpl $0x0, %eax
jne 0x3fa5
leaq 0x1f60(%rsp), %rdi
movq 0x23a8(%rsp), %rsi
movq 0x23a0(%rsp), %rdx
movq 0x2398(%rsp), %rcx
callq 0x1b280
cmpl $0x0, %eax
jne 0x3fa5
movl $0x0, 0x23b4(%rsp)
jmp 0x4383
leaq 0x1f60(%rsp), %rdi
leaq 0x27835(%rip), %rsi     # 0x2b7e9
movl $0x4, %edx
callq 0x2050
cmpl $0x0, %eax
jne 0x4005
leaq 0x1f60(%rsp), %rdi
movq 0x23a8(%rsp), %rsi
movq 0x23a0(%rsp), %rdx
movq 0x2398(%rsp), %r8
leaq 0x2384(%rsp), %rcx
callq 0x19880
cmpl $0x0, %eax
jne 0x4005
movl $0x0, 0x23b4(%rsp)
jmp 0x4383
jmp 0x4007
jmp 0x4009
jmp 0x400b
jmp 0x400d
jmp 0x400f
jmp 0x4011
jmp 0x4013
jmp 0x4015
jmp 0x4017
jmp 0x4019
jmp 0x401b
jmp 0x401d
jmp 0x401f
jmp 0x3a63
movq 0x2370(%rsp), %rdi
callq 0x20a0
movl $0x0, 0x2394(%rsp)
movl 0x2394(%rsp), %eax
movq 0x23a0(%rsp), %rcx
cmpl (%rcx), %eax
jge 0x4338
movq 0x23a8(%rsp), %rax
movslq 0x2394(%rsp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, 0x8(%rsp)
movq 0x8(%rsp), %rax
cmpl $0x0, (%rax)
je 0x40a7
movq 0x8(%rsp), %rdi
movq 0x8(%rsp), %rax
movl (%rax), %esi
leaq 0x28bb7(%rip), %rdx     # 0x2cc40
leaq 0x238c(%rsp), %rcx
callq 0x6140
cmpl $0x0, %eax
jne 0x40a7
movq 0x8(%rsp), %rax
movl (%rax), %ecx
addl $-0x1, %ecx
movl %ecx, (%rax)
movq 0x8(%rsp), %rax
movq 0x48(%rax), %rdi
movq 0x2398(%rsp), %rsi
callq 0x2060
movq 0x8(%rsp), %rdi
addq $0xb0, %rdi
leaq 0x1b(%rsp), %rsi
callq 0x2060
movq 0x8(%rsp), %rax
cmpl $0x0, (%rax)
je 0x40e9
movq 0x8(%rsp), %rax
movl (%rax), %ecx
addl $0x1, %ecx
movl %ecx, (%rax)
movq 0x8(%rsp), %rax
cmpl $-0x1, 0x20(%rax)
je 0x4102
movq 0x8(%rsp), %rax
movl 0x20(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x20(%rax)
movss 0x2378(%rsp), %xmm0
movq 0x8(%rsp), %rax
movss %xmm0, 0x50(%rax)
movl 0x2388(%rsp), %ecx
movq 0x8(%rsp), %rax
movl %ecx, 0x54(%rax)
movl 0x2380(%rsp), %ecx
movq 0x8(%rsp), %rax
movl %ecx, 0x5c(%rax)
movl 0x237c(%rsp), %ecx
movq 0x8(%rsp), %rax
movl %ecx, 0x60(%rax)
movl 0x2390(%rsp), %ecx
movq 0x8(%rsp), %rax
movl %ecx, 0x3c(%rax)
movl $0x0, 0x238c(%rsp)
movl 0x238c(%rsp), %eax
cmpl 0x2390(%rsp), %eax
jge 0x41f1
movl $0x400, %edi            # imm = 0x400
callq 0x7360
movq %rax, %rdx
movq 0x8(%rsp), %rax
movq 0xa8(%rax), %rax
movslq 0x238c(%rsp), %rcx
movq %rdx, (%rax,%rcx,8)
movq 0x8(%rsp), %rax
movq 0xa8(%rax), %rax
movslq 0x238c(%rsp), %rcx
movq (%rax,%rcx,8), %rdi
movslq 0x238c(%rsp), %rax
movq 0x20(%rsp,%rax,8), %rsi
callq 0x2060
movq 0x8(%rsp), %rax
movq 0xa8(%rax), %rax
movslq 0x238c(%rsp), %rcx
movq (%rax,%rcx,8), %rax
movb $0x0, 0x47(%rax)
movl 0x238c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x238c(%rsp)
jmp 0x415c
movl $0x0, 0x238c(%rsp)
movl 0x238c(%rsp), %eax
movq 0x8(%rsp), %rcx
cmpl (%rcx), %eax
jge 0x4320
movq 0x8(%rsp), %rax
movq 0x68(%rax), %rax
movslq 0x238c(%rsp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, 0x10(%rsp)
movl $0x3c, %edi
callq 0x7360
movq %rax, %rcx
movq 0x10(%rsp), %rax
movq %rcx, 0x770(%rax)
movl $0x20, %edi
callq 0x7360
movq %rax, %rcx
movq 0x10(%rsp), %rax
movq %rcx, 0x768(%rax)
movq 0x10(%rsp), %rax
movq 0x770(%rax), %rax
movl $0x0, 0x30(%rax)
movq 0x10(%rsp), %rax
movq 0x770(%rax), %rax
movl $0x0, 0x34(%rax)
movq 0x10(%rsp), %rax
movq 0x770(%rax), %rax
movl $0x0, 0x38(%rax)
movq 0x10(%rsp), %rax
movq 0x768(%rax), %rax
movb $0x43, 0x1c(%rax)
movq 0x10(%rsp), %rax
movq 0x768(%rax), %rax
movb $0x43, 0x1d(%rax)
movq 0x10(%rsp), %rax
movq 0x768(%rax), %rax
movb $0x43, 0x1e(%rax)
movq 0x10(%rsp), %rax
movq 0x768(%rax), %rax
xorps %xmm0, %xmm0
movss %xmm0, 0x14(%rax)
movq 0x10(%rsp), %rax
movq 0x768(%rax), %rax
movss 0x27487(%rip), %xmm0    # 0x2b774
movss %xmm0, (%rax)
movq 0x10(%rsp), %rax
movq 0x768(%rax), %rax
movss 0x2746f(%rip), %xmm0    # 0x2b774
movss %xmm0, 0x4(%rax)
movl 0x238c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x238c(%rsp)
jmp 0x41fc
jmp 0x4322
movl 0x2394(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x2394(%rsp)
jmp 0x403c
movl $0x0, 0x238c(%rsp)
movl 0x238c(%rsp), %eax
cmpl 0x2390(%rsp), %eax
jge 0x4378
movslq 0x238c(%rsp), %rax
movq 0x20(%rsp,%rax,8), %rdi
callq 0x2030
movl 0x238c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x238c(%rsp)
jmp 0x4343
movl $0x1, 0x23b4(%rsp)
movl 0x23b4(%rsp), %eax
addq $0x23b8, %rsp           # imm = 0x23B8
retq
nopw %cs:(%rax,%rax)
nopl (%rax)