// File: /workspace/github_c_makefile_star2_O3/josch[P]stride/p_sheet.c
// Function: Process_SHEET
int Process_SHEET(BUFFER Buffer, CHAIN **Chain, int *ChainNumber, COMMAND *Cmd)
{
  int CC, SC, STC;
  char *Field[MAX_FIELD];
  BUFFER Tmp;
  static char PreviousChain, PreviousSheetId[RES_FIELD];

  if( Cmd->NActive && !ChInStr(Cmd->Active,SpaceToDash(Buffer[21])) )
     return(SUCCESS);

  for( CC=0; CC < *ChainNumber && Chain[CC]->Id != Buffer[21]; CC++ );

  if( CC == *ChainNumber ) {
    InitChain(&Chain[CC]); 
    Chain[CC]->Id = Buffer[21];
    (*ChainNumber)++;
  }

  if( Chain[CC]->NSheet == -1 ) {
    PreviousChain = '*';
    strcpy(PreviousSheetId,"*");
  }

  SplitString(Buffer+7,Field,2);

  if( atoi(Field[0]) == 1 || Buffer[21] != PreviousChain ) {
    if( Buffer[21] == PreviousChain && !strcmp(PreviousSheetId,Field[1]) )
      return(FAILURE);
/*      die("Here it is! -> %s%c\n", Chain[CC]->File,Chain[CC]->Id);*/
    Chain[CC]->NSheet++;
    SC = Chain[CC]->NSheet;
    Chain[CC]->Sheet[SC] =  (SHEET *)ckalloc(sizeof(SHEET));
    Chain[CC]->Sheet[SC]->NStrand = 0;
    STC = Chain[CC]->Sheet[SC]->NStrand;
    strcpy(Chain[CC]->Sheet[SC]->SheetId,Field[1]);
  }
  else
    {
      SC = Chain[CC]->NSheet;
      STC = Chain[CC]->Sheet[SC]->NStrand;
    }
  
  SplitString(Buffer+17,Field,1);
  strcpy(Chain[CC]->Sheet[SC]->ResType1[STC],Field[0]);

  SplitString(Buffer+28,Field,1);
  strcpy(Chain[CC]->Sheet[SC]->ResType2[STC],Field[0]);

  strcpy(Tmp,Buffer);
  Tmp[27] = ' ';
  Tmp[38] = ' ';
  SplitString(Tmp+22,Field,1);
  strcpy(Chain[CC]->Sheet[SC]->PDB_ResNumb1[STC],Field[0]);
  SplitString(Tmp+33,Field,1);
  strcpy(Chain[CC]->Sheet[SC]->PDB_ResNumb2[STC],Field[0]);

  Chain[CC]->Sheet[SC]->InsCode1[STC] = Buffer[26];
  Chain[CC]->Sheet[SC]->InsCode2[STC] = Buffer[37];

  SplitString(Buffer+38,Field,1);
  Chain[CC]->Sheet[SC]->Sence[STC] = atoi(Field[0]);

  if( Buffer[45] != ' ' ) {
    Chain[CC]->Sheet[SC]->RegYN[STC] = 1;
    SplitString(Buffer+45,Field,1);
    strcpy(Chain[CC]->Sheet[SC]->ResTypeReg1[STC],Field[0]);
    SplitString(Buffer+60,Field,1);
    strcpy(Chain[CC]->Sheet[SC]->ResTypeReg2[STC],Field[0]);
    
    Tmp[55] = ' ';
    Tmp[70] = ' ';
    SplitString(Tmp+50,Field,1);
    strcpy(Chain[CC]->Sheet[SC]->PDB_ResNumbReg1[STC],Field[0]);
    SplitString(Tmp+66,Field,1);
    strcpy(Chain[CC]->Sheet[SC]->PDB_ResNumbReg2[STC],Field[0]);
    
    Chain[CC]->Sheet[SC]->InsCodeReg1[STC] = Buffer[54];
    Chain[CC]->Sheet[SC]->InsCodeReg2[STC] = Buffer[69];
    
    Tmp[45] = ' ';
    Tmp[60] = ' ';
    SplitString(Tmp+41,Field,1);
    strcpy(Chain[CC]->Sheet[SC]->AtomNameReg1[STC],Field[0]);
    SplitString(Tmp+56,Field,1);
    strcpy(Chain[CC]->Sheet[SC]->AtomNameReg2[STC],Field[0]);
  }
  else Chain[CC]->Sheet[SC]->RegYN[STC] = 0;

  strcpy(PreviousSheetId,Chain[CC]->Sheet[SC]->SheetId);
  PreviousChain = Buffer[21];
  Chain[CC]->Sheet[SC]->NStrand++;

  return(SUCCESS);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x5b8, %rsp            # imm = 0x5B8
movq %rdx, %r15
movq %rsi, %r14
movq %rdi, %rbp
cmpl $0x0, 0x1cf8(%rcx)
je 0xf765
movq %rcx, %r12
addq $0x1c08, %r12           # imm = 0x1C08
movsbl 0x15(%rbp), %edi
callq 0x50a2
movsbl %al, %esi
movq %r12, %rdi
callq 0x50af
testl %eax, %eax
je 0xfc21
movl (%r15), %ebx
testl %ebx, %ebx
jle 0xf788
movb 0x15(%rbp), %al
xorl %r12d, %r12d
movq (%r14,%r12,8), %rcx
cmpb %al, 0x40(%rcx)
je 0xf78b
incq %r12
cmpq %r12, %rbx
jne 0xf772
movl %ebx, %r12d
jmp 0xf790
xorl %r12d, %r12d
cmpl %ebx, %r12d
jne 0xf7a6
leaq (%r14,%rbx,8), %rdi
callq 0x3d9c
movb 0x15(%rbp), %al
movq (%r14,%rbx,8), %rcx
movb %al, 0x40(%rcx)
incl (%r15)
movl %r12d, %r13d
movq (%r14,%r13,8), %rax
cmpl $-0x1, 0x20(%rax)
jne 0xf7c3
movb $0x2a, 0x12e4e(%rip)    # 0x22608
movw $0x2a, 0x12e47(%rip)    # 0x2260a
leaq 0x7(%rbp), %rdi
leaq 0x20(%rsp), %r15
movq %r15, %rsi
movl $0x2, %edx
callq 0x36c4
movq (%r15), %rdi
callq 0x21f0
cmpl $0x1, %eax
setne %dl
movb 0x15(%rbp), %al
movb 0x12e18(%rip), %cl      # 0x22608
cmpb %cl, %al
sete %sil
testb %sil, %dl
je 0xf81a
movq %rbp, %r15
movq (%r14,%r13,8), %rax
movslq 0x20(%rax), %rcx
movq 0x88(%rax), %rax
movq %rcx, (%rsp)
movq (%rax,%rcx,8), %rax
movslq (%rax), %rbx
jmp 0xf88d
cmpb %cl, %al
jne 0xf837
movq 0x28(%rsp), %rsi
leaq 0x12de0(%rip), %rdi     # 0x2260a
callq 0x2150
testl %eax, %eax
je 0xfc38
movq %rbp, %r15
movq (%r14,%r13,8), %rax
movslq 0x20(%rax), %rbx
leaq 0x1(%rbx), %rcx
movq %rcx, (%rsp)
movl %ecx, 0x20(%rax)
movl $0x584, %edi            # imm = 0x584
callq 0x5880
movq (%r14,%r13,8), %rcx
movq 0x88(%rcx), %rcx
movq %rax, 0x8(%rcx,%rbx,8)
movq (%r14,%r13,8), %rax
movq 0x88(%rax), %rax
movq 0x8(%rax,%rbx,8), %rdi
movl $0x0, (%rdi)
addq $0x4, %rdi
movq 0x28(%rsp), %rsi
callq 0x2070
xorl %ebx, %ebx
movq %rbx, 0x10(%rsp)
leaq 0x11(%r15), %rdi
leaq 0x20(%rsp), %r12
movq %r12, %rsi
movl $0x1, %edx
callq 0x36c4
movq (%r14,%r13,8), %rax
movq 0x88(%rax), %rax
movq (%rsp), %rbp
movq (%rax,%rbp,8), %rax
leaq (%rbx,%rbx), %rcx
leaq (%rcx,%rcx,2), %rbx
leaq (%rax,%rbx), %rdi
addq $0xa, %rdi
movq (%r12), %rsi
callq 0x2070
leaq 0x1c(%r15), %rdi
movq %r12, %rsi
movl $0x1, %edx
callq 0x36c4
movq (%r14,%r13,8), %rax
movq 0x88(%rax), %rax
movq (%rax,%rbp,8), %rax
leaq (%rax,%rbx), %rdi
addq $0x82, %rdi
movq (%r12), %rsi
callq 0x2070
leaq 0x1b0(%rsp), %r12
movq %r12, %rdi
movq %r15, %rsi
callq 0x2070
movb $0x20, %al
movb %al, 0x1b(%r12)
movb %al, 0x26(%r12)
movq %r15, %r12
leaq 0x1c6(%rsp), %rdi
leaq 0x20(%rsp), %r15
movq %r15, %rsi
movl $0x1, %edx
callq 0x36c4
movq (%r14,%r13,8), %rax
movq 0x88(%rax), %rax
movq (%rax,%rbp,8), %rax
leaq (%rax,%rbx), %rdi
addq $0xfa, %rdi
movq (%r15), %rsi
callq 0x2070
leaq 0x1d1(%rsp), %rdi
movq %r15, %rsi
movl $0x1, %edx
callq 0x36c4
movq (%r14,%r13,8), %rax
movq 0x88(%rax), %rax
movq (%rax,%rbp,8), %rax
movq %rbx, 0x18(%rsp)
leaq (%rax,%rbx), %rdi
addq $0x172, %rdi            # imm = 0x172
movq (%r15), %rsi
callq 0x2070
movb 0x1a(%r12), %al
movq (%r14,%r13,8), %rcx
movq 0x88(%rcx), %rcx
movq (%rcx,%rbp,8), %rcx
movq 0x10(%rsp), %rbx
movb %al, 0x1ea(%rcx,%rbx)
movb 0x25(%r12), %al
movq (%r14,%r13,8), %rcx
movq 0x88(%rcx), %rcx
movq (%rcx,%rbp,8), %rcx
movb %al, 0x1fe(%rcx,%rbx)
leaq 0x26(%r12), %rdi
movq %r15, %rsi
movl $0x1, %edx
callq 0x36c4
movq (%r15), %rdi
callq 0x21f0
movq (%r14,%r13,8), %rcx
movq 0x88(%rcx), %rcx
movq (%rcx,%rbp,8), %r15
movl %eax, 0x214(%r15,%rbx,4)
movq %rbx, %rax
movq %r12, 0x8(%rsp)
movb $0x20, %cl
cmpb %cl, 0x2d(%r12)
jne 0xfa30
movl $0x0, 0x264(%r15,%rax,4)
jmp 0xfc00
movq 0x8(%rsp), %rbx
leaq 0x2d(%rbx), %rdi
movl $0x1, 0x264(%r15,%rax,4)
leaq 0x20(%rsp), %r12
movq %r12, %rsi
movl $0x1, %edx
callq 0x36c4
movq (%r14,%r13,8), %rax
movq 0x88(%rax), %rax
movq (%rsp), %rbp
movq (%rax,%rbp,8), %rax
movq 0x18(%rsp), %r15
leaq (%rax,%r15), %rdi
addq $0x37c, %rdi            # imm = 0x37C
movq (%r12), %rsi
callq 0x2070
leaq 0x3c(%rbx), %rdi
movq %r12, %rsi
movl $0x1, %edx
callq 0x36c4
movq (%r14,%r13,8), %rax
movq 0x88(%rax), %rax
movq (%rax,%rbp,8), %rax
leaq (%rax,%r15), %rdi
addq $0x3f4, %rdi            # imm = 0x3F4
movq (%r12), %rsi
callq 0x2070
leaq 0x1e2(%rsp), %rdi
movb $0x20, %al
movb %al, 0x5(%rdi)
movb %al, 0x14(%rdi)
movq %r12, %rsi
movl $0x1, %edx
callq 0x36c4
movq (%r14,%r13,8), %rax
movq 0x88(%rax), %rax
movq (%rax,%rbp,8), %rax
leaq (%rax,%r15), %rdi
addq $0x46c, %rdi            # imm = 0x46C
movq (%r12), %rsi
movq %r12, %rbx
callq 0x2070
movq 0x10(%rsp), %r12
leaq 0x1f2(%rsp), %rdi
movq %rbx, %rsi
movl $0x1, %edx
callq 0x36c4
movq (%r14,%r13,8), %rax
movq 0x88(%rax), %rax
movq (%rax,%rbp,8), %rax
leaq (%rax,%r15), %rdi
addq $0x4e4, %rdi            # imm = 0x4E4
movq (%rbx), %rsi
callq 0x2070
movq 0x8(%rsp), %rdx
movb 0x36(%rdx), %al
movq (%r14,%r13,8), %rcx
movq 0x88(%rcx), %rcx
movq (%rcx,%rbp,8), %rcx
movb %al, 0x55c(%rcx,%r12)
movb 0x45(%rdx), %al
movq (%r14,%r13,8), %rcx
movq 0x88(%rcx), %rcx
movq (%rcx,%rbp,8), %rcx
movb %al, 0x570(%rcx,%r12)
movb $0x20, %al
leaq 0x1f2(%rsp), %rcx
movb %al, -0x15(%rcx)
movb %al, -0x6(%rcx)
leaq 0x1d9(%rsp), %rdi
movq %rbx, %rsi
movl $0x1, %edx
callq 0x36c4
movq (%r14,%r13,8), %rax
movq 0x88(%rax), %rax
movq (%rax,%rbp,8), %rax
leaq (%r12,%r12,4), %r12
leaq (%rax,%r12), %rdi
addq $0x2b4, %rdi            # imm = 0x2B4
movq (%rbx), %rsi
callq 0x2070
leaq 0x1e8(%rsp), %rdi
movq %rbx, %rsi
movl $0x1, %edx
callq 0x36c4
movq (%r14,%r13,8), %rax
movq 0x88(%rax), %rax
movq (%rax,%rbp,8), %rax
leaq (%rax,%r12), %rdi
addq $0x318, %rdi            # imm = 0x318
movq (%rbx), %rsi
callq 0x2070
movq (%r14,%r13,8), %rax
movq 0x88(%rax), %rax
movq (%rax,%rbp,8), %r15
leaq 0x4(%r15), %rsi
leaq 0x129ff(%rip), %rdi     # 0x2260a
callq 0x2070
movq 0x8(%rsp), %rax
movb 0x15(%rax), %al
movb %al, 0x129ea(%rip)      # 0x22608
incl (%r15)
movl $0x1, %eax
addq $0x5b8, %rsp            # imm = 0x5B8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
xorl %eax, %eax
jmp 0xfc26