// File: /workspace/github_c_makefile_star2_O0/josch[P]stride/dssp.c
// Function: ReadDSSP
int ReadDSSP(CHAIN **Chain, DSSP **Dssp, COMMAND *Cmd)
{

  FILE *fi;
  int ChainNumber = -1, Start = 0, i;
  BOOLEAN DuplicateChain = NO;
  BUFFER Buffer, Tmp1, Tmp2;
  char *Fields[MAX_FIELD];
  
  if( strlen(Cmd->DsspFile) == 0 ) {
    strcpy(Cmd->DsspFile,DSSPPATH);
    GetFileNameFromPath(Chain[0]->File,Tmp1);
    StripPathFromLastExtention(Tmp1,Tmp2);
    strcat(Cmd->DsspFile,Tmp2);
    strcat(Cmd->DsspFile,".dssp");
  }

  if( (fi = fopen(Cmd->DsspFile,"r")) ) {

    while( fgets(Buffer,BUFSZ,fi) != NULL && !DuplicateChain ) {
      if( Buffer[2] == '#' ) Start = 1;
      else
      if( Start == 1 ) {
	if( Buffer[13] == '!' ) continue;
	if( ChainNumber > 0 ) {
	  for( i=0; i<ChainNumber; i++ ) 
	    if( Dssp[i]->Id == Buffer[11] ) {
	      DuplicateChain = YES;
	      fprintf(stderr,"# Duplicate chain(s) in DSSP file %s\n",Cmd->DsspFile);
	    break;
	  }
	}
	if( ( ChainNumber == -1 || Buffer[11] != Dssp[ChainNumber]->Id ) ) {
	  ChainNumber++;
	  Dssp[ChainNumber]       = (DSSP *)ckalloc(sizeof(DSSP));
	  Dssp[ChainNumber]->ResType = CharMatrix(MAX_RES,RES_FIELD);
	  Dssp[ChainNumber]->PDB_ResNumb = CharMatrix(MAX_RES,RES_FIELD);
	  Dssp[ChainNumber]->SecondStr = (char *)ckalloc(MAX_RES*sizeof(char));
	  Dssp[ChainNumber]->Accessibility = (float *)ckalloc(MAX_RES*sizeof(float));
	  strcpy(Dssp[ChainNumber]->File,Cmd->DsspFile);
	  Dssp[ChainNumber]->Id   = Buffer[11];
	  Dssp[ChainNumber]->NRes = 0;
	}
	
	if( islower(Buffer[13]) ) Buffer[13] = 'C';
	strcpy(Dssp[ChainNumber]->ResType[ Dssp[ChainNumber]->NRes ],OneToThree(Buffer[13]));
	if( Buffer[16] == ' ' )
	  Dssp[ChainNumber]->SecondStr[ Dssp[ChainNumber]->NRes ] = 'C';
	else
	  Dssp[ChainNumber]->SecondStr[ Dssp[ChainNumber]->NRes ] = Buffer[16];
	SplitString(Buffer+6,Fields,1);
	strcpy(Dssp[ChainNumber]->PDB_ResNumb[Dssp[ChainNumber]->NRes],Fields[0]);
	SplitString(Buffer+34,Fields,1);
	Dssp[ChainNumber]->Accessibility[ Dssp[ChainNumber]->NRes ] = atof(Fields[0]);
	Dssp[ChainNumber]->NRes++;
      }
    }
    fclose(fi);
  }

  ChainNumber++;

  for( i=0; i<ChainNumber; i++ ) 
    Dssp[i]->Id = SpaceToDash(Dssp[i]->Id);

  return(ChainNumber);
}

// Assembly:
subq $0xdf8, %rsp            # imm = 0xDF8
movq %rdi, 0xdf0(%rsp)
movq %rsi, 0xde8(%rsp)
movq %rdx, 0xde0(%rsp)
movl $0xffffffff, 0xdd4(%rsp) # imm = 0xFFFFFFFF
movl $0x0, 0xdd0(%rsp)
movl $0x0, 0xdc8(%rsp)
movq 0xde0(%rsp), %rdi
addq $0x1806, %rdi           # imm = 0x1806
callq 0x20b0
cmpq $0x0, %rax
jne 0x25191
movq 0xde0(%rsp), %rdi
addq $0x1806, %rdi           # imm = 0x1806
leaq 0x797c(%rip), %rsi      # 0x2caa0
callq 0x2060
movq 0xdf0(%rsp), %rax
movq (%rax), %rax
movq 0x48(%rax), %rdi
leaq 0x5b0(%rsp), %rsi
callq 0x5f40
leaq 0x5b0(%rsp), %rdi
leaq 0x1a0(%rsp), %rsi
callq 0x5fc0
movq 0xde0(%rsp), %rdi
addq $0x1806, %rdi           # imm = 0x1806
leaq 0x1a0(%rsp), %rsi
callq 0x21e0
movq 0xde0(%rsp), %rdi
addq $0x1806, %rdi           # imm = 0x1806
leaq 0x7920(%rip), %rsi      # 0x2caac
callq 0x21e0
movq 0xde0(%rsp), %rdi
addq $0x1806, %rdi           # imm = 0x1806
leaq 0x76f6(%rip), %rsi      # 0x2c89d
callq 0x2190
movq %rax, 0xdd8(%rsp)
cmpq $0x0, %rax
je 0x2565a
jmp 0x251c0
leaq 0x9c0(%rsp), %rdi
movq 0xdd8(%rsp), %rdx
movl $0x400, %esi            # imm = 0x400
callq 0x2110
movq %rax, %rcx
xorl %eax, %eax
cmpq $0x0, %rcx
movb %al, 0xf(%rsp)
je 0x251fa
cmpl $0x0, 0xdc8(%rsp)
setne %al
xorb $-0x1, %al
movb %al, 0xf(%rsp)
movb 0xf(%rsp), %al
testb $0x1, %al
jne 0x25207
jmp 0x2564d
movsbl 0x9c2(%rsp), %eax
cmpl $0x23, %eax
jne 0x25224
movl $0x1, 0xdd0(%rsp)
jmp 0x25648
cmpl $0x1, 0xdd0(%rsp)
jne 0x25646
movsbl 0x9cd(%rsp), %eax
cmpl $0x21, %eax
jne 0x25244
jmp 0x251c0
cmpl $0x0, 0xdd4(%rsp)
jle 0x252df
movl $0x0, 0xdcc(%rsp)
movl 0xdcc(%rsp), %eax
cmpl 0xdd4(%rsp), %eax
jge 0x252dd
movq 0xde8(%rsp), %rax
movslq 0xdcc(%rsp), %rcx
movq (%rax,%rcx,8), %rax
movsbl 0x401(%rax), %eax
movsbl 0x9cb(%rsp), %ecx
cmpl %ecx, %eax
jne 0x252c8
movl $0x1, 0xdc8(%rsp)
movq 0xad52(%rip), %rax      # 0x2fff8
movq (%rax), %rdi
movq 0xde0(%rsp), %rdx
addq $0x1806, %rdx           # imm = 0x1806
leaq 0x77f3(%rip), %rsi      # 0x2cab2
movb $0x0, %al
callq 0x2140
jmp 0x252dd
jmp 0x252ca
movl 0xdcc(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xdcc(%rsp)
jmp 0x2525d
jmp 0x252df
cmpl $-0x1, 0xdd4(%rsp)
je 0x25314
movsbl 0x9cb(%rsp), %eax
movq 0xde8(%rsp), %rcx
movslq 0xdd4(%rsp), %rdx
movq (%rcx,%rdx,8), %rcx
movsbl 0x401(%rcx), %ecx
cmpl %ecx, %eax
je 0x25457
movl 0xdd4(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xdd4(%rsp)
movl $0x428, %edi            # imm = 0x428
callq 0x7360
movq %rax, %rdx
movq 0xde8(%rsp), %rax
movslq 0xdd4(%rsp), %rcx
movq %rdx, (%rax,%rcx,8)
movl $0x4e20, %edi           # imm = 0x4E20
movl $0x6, %esi
callq 0x7b40
movq %rax, %rcx
movq 0xde8(%rsp), %rax
movslq 0xdd4(%rsp), %rdx
movq (%rax,%rdx,8), %rax
movq %rcx, 0x408(%rax)
movl $0x4e20, %edi           # imm = 0x4E20
movl $0x6, %esi
callq 0x7b40
movq %rax, %rcx
movq 0xde8(%rsp), %rax
movslq 0xdd4(%rsp), %rdx
movq (%rax,%rdx,8), %rax
movq %rcx, 0x418(%rax)
movl $0x4e20, %edi           # imm = 0x4E20
callq 0x7360
movq %rax, %rcx
movq 0xde8(%rsp), %rax
movslq 0xdd4(%rsp), %rdx
movq (%rax,%rdx,8), %rax
movq %rcx, 0x410(%rax)
movl $0x13880, %edi          # imm = 0x13880
callq 0x7360
movq %rax, %rcx
movq 0xde8(%rsp), %rax
movslq 0xdd4(%rsp), %rdx
movq (%rax,%rdx,8), %rax
movq %rcx, 0x420(%rax)
movq 0xde8(%rsp), %rax
movslq 0xdd4(%rsp), %rcx
movq (%rax,%rcx,8), %rdi
movq 0xde0(%rsp), %rsi
addq $0x1806, %rsi           # imm = 0x1806
callq 0x2060
movb 0x9cb(%rsp), %cl
movq 0xde8(%rsp), %rax
movslq 0xdd4(%rsp), %rdx
movq (%rax,%rdx,8), %rax
movb %cl, 0x401(%rax)
movq 0xde8(%rsp), %rax
movslq 0xdd4(%rsp), %rcx
movq (%rax,%rcx,8), %rax
movl $0x0, 0x404(%rax)
callq 0x2250
movq (%rax), %rax
movsbl 0x9cd(%rsp), %ecx
movslq %ecx, %rcx
movzwl (%rax,%rcx,2), %eax
andl $0x200, %eax            # imm = 0x200
cmpl $0x0, %eax
je 0x25480
movb $0x43, 0x9cd(%rsp)
movq 0xde8(%rsp), %rax
movslq 0xdd4(%rsp), %rcx
movq (%rax,%rcx,8), %rax
movq 0x408(%rax), %rax
movq 0xde8(%rsp), %rcx
movslq 0xdd4(%rsp), %rdx
movq (%rcx,%rdx,8), %rcx
movslq 0x404(%rcx), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, (%rsp)
movsbl 0x9cd(%rsp), %edi
callq 0x5cc0
movq (%rsp), %rdi
movq %rax, %rsi
callq 0x2060
movsbl 0x9d0(%rsp), %eax
cmpl $0x20, %eax
jne 0x25520
movq 0xde8(%rsp), %rax
movslq 0xdd4(%rsp), %rcx
movq (%rax,%rcx,8), %rax
movq 0x410(%rax), %rax
movq 0xde8(%rsp), %rcx
movslq 0xdd4(%rsp), %rdx
movq (%rcx,%rdx,8), %rcx
movslq 0x404(%rcx), %rcx
movb $0x43, (%rax,%rcx)
jmp 0x25560
movb 0x9d0(%rsp), %dl
movq 0xde8(%rsp), %rax
movslq 0xdd4(%rsp), %rcx
movq (%rax,%rcx,8), %rax
movq 0x410(%rax), %rax
movq 0xde8(%rsp), %rcx
movslq 0xdd4(%rsp), %rsi
movq (%rcx,%rsi,8), %rcx
movslq 0x404(%rcx), %rcx
movb %dl, (%rax,%rcx)
leaq 0x9c0(%rsp), %rdi
addq $0x6, %rdi
leaq 0x10(%rsp), %rsi
movl $0x1, %edx
callq 0x37c0
movq 0xde8(%rsp), %rax
movslq 0xdd4(%rsp), %rcx
movq (%rax,%rcx,8), %rax
movq 0x418(%rax), %rax
movq 0xde8(%rsp), %rcx
movslq 0xdd4(%rsp), %rdx
movq (%rcx,%rdx,8), %rcx
movslq 0x404(%rcx), %rcx
movq (%rax,%rcx,8), %rdi
movq 0x10(%rsp), %rsi
callq 0x2060
leaq 0x9c0(%rsp), %rdi
addq $0x22, %rdi
leaq 0x10(%rsp), %rsi
movl $0x1, %edx
callq 0x37c0
movq 0x10(%rsp), %rdi
callq 0x2080
cvtsd2ss %xmm0, %xmm0
movq 0xde8(%rsp), %rax
movslq 0xdd4(%rsp), %rcx
movq (%rax,%rcx,8), %rax
movq 0x420(%rax), %rax
movq 0xde8(%rsp), %rcx
movslq 0xdd4(%rsp), %rdx
movq (%rcx,%rdx,8), %rcx
movslq 0x404(%rcx), %rcx
movss %xmm0, (%rax,%rcx,4)
movq 0xde8(%rsp), %rax
movslq 0xdd4(%rsp), %rcx
movq (%rax,%rcx,8), %rax
movl 0x404(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x404(%rax)
jmp 0x25648
jmp 0x251c0
movq 0xdd8(%rsp), %rdi
callq 0x20a0
movl 0xdd4(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xdd4(%rsp)
movl $0x0, 0xdcc(%rsp)
movl 0xdcc(%rsp), %eax
cmpl 0xdd4(%rsp), %eax
jge 0x256d5
movq 0xde8(%rsp), %rax
movslq 0xdcc(%rsp), %rcx
movq (%rax,%rcx,8), %rax
movsbl 0x401(%rax), %edi
callq 0x6550
movb %al, %cl
movq 0xde8(%rsp), %rax
movslq 0xdcc(%rsp), %rdx
movq (%rax,%rdx,8), %rax
movb %cl, 0x401(%rax)
movl 0xdcc(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xdcc(%rsp)
jmp 0x25676
movl 0xdd4(%rsp), %eax
addq $0xdf8, %rsp            # imm = 0xDF8
retq
nopw %cs:(%rax,%rax)