// File: /workspace/github_c_makefile_star2_O1/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 $0x5a8, %rsp            # imm = 0x5A8
movq %rdx, %r15
movq %rsi, %r14
movq %rdi, %rbx
cmpl $0x0, 0x1cf8(%rcx)
je 0xf5d1
movq %rcx, %r12
addq $0x1c08, %r12           # imm = 0x1C08
movsbl 0x15(%rbx), %edi
callq 0x517a
movsbl %al, %esi
movq %r12, %rdi
callq 0x5187
testl %eax, %eax
je 0xfa79
movl (%r15), %eax
testl %eax, %eax
jle 0xf5f2
movb 0x15(%rbx), %dl
xorl %ecx, %ecx
movq (%r14,%rcx,8), %rsi
cmpb %dl, 0x40(%rsi)
je 0xf5f4
incq %rcx
cmpq %rcx, %rax
jne 0xf5dd
movl %eax, %ecx
jmp 0xf5f4
xorl %ecx, %ecx
movl %ecx, %r13d
cmpl %eax, %ecx
jne 0xf614
leaq (%r14,%r13,8), %r12
movq %r12, %rdi
callq 0x3d9c
movb 0x15(%rbx), %al
movq (%r12), %rcx
movb %al, 0x40(%rcx)
incl (%r15)
movq (%r14,%r13,8), %rax
cmpl $-0x1, 0x20(%rax)
jne 0xf62e
movb $0x2a, 0x12fe3(%rip)    # 0x22608
movw $0x2a, 0x12fdc(%rip)    # 0x2260a
leaq 0x7(%rbx), %rdi
leaq 0x10(%rsp), %r15
movq %r15, %rsi
movl $0x2, %edx
callq 0x36b8
movq (%r15), %rdi
callq 0x21f0
cmpl $0x1, %eax
je 0xf679
movb 0x15(%rbx), %al
cmpb 0x12fae(%rip), %al      # 0x22608
jne 0xf679
movq (%r14,%r13,8), %rax
movslq 0x20(%rax), %r12
movq 0x88(%rax), %rax
movq (%rax,%r12,8), %rax
movslq (%rax), %rax
movq %rax, 0x8(%rsp)
jmp 0xf6f4
movb 0x15(%rbx), %al
cmpb 0x12f86(%rip), %al      # 0x22608
jne 0xf69d
movq 0x18(%rsp), %rsi
leaq 0x12f7a(%rip), %rdi     # 0x2260a
callq 0x2150
testl %eax, %eax
je 0xfa90
movq (%r14,%r13,8), %rax
movslq 0x20(%rax), %r15
leaq 0x1(%r15), %r12
movl %r12d, 0x20(%rax)
movl $0x584, %edi            # imm = 0x584
callq 0x595c
movq (%r14,%r13,8), %rcx
movq 0x88(%rcx), %rcx
movq %rax, 0x8(%rcx,%r15,8)
movq (%r14,%r13,8), %rax
movq 0x88(%rax), %rax
movq 0x8(%rax,%r15,8), %rdi
movl $0x0, (%rdi)
addq $0x4, %rdi
movq 0x18(%rsp), %rsi
callq 0x2070
movq $0x0, 0x8(%rsp)
leaq 0x11(%rbx), %rdi
leaq 0x10(%rsp), %r15
movq %r15, %rsi
movl $0x1, %edx
callq 0x36b8
movq (%r14,%r13,8), %rax
movq 0x88(%rax), %rax
movslq %r12d, %rbp
movq (%rax,%rbp,8), %rax
movq %rbx, (%rsp)
movq 0x8(%rsp), %rcx
addq %rcx, %rcx
leaq (%rcx,%rcx,2), %rbx
leaq (%rax,%rbx), %rdi
addq $0xa, %rdi
movq (%r15), %rsi
callq 0x2070
movq (%rsp), %rax
leaq 0x1c(%rax), %rdi
movq %r15, %rsi
movl $0x1, %edx
callq 0x36b8
movq (%r14,%r13,8), %rax
movq 0x88(%rax), %rax
movq (%rax,%rbp,8), %rax
leaq (%rax,%rbx), %rdi
addq $0x82, %rdi
movq (%r15), %rsi
callq 0x2070
leaq 0x1a0(%rsp), %r12
movq %r12, %rdi
movq (%rsp), %rsi
callq 0x2070
movb $0x20, %al
movb %al, 0x1b(%r12)
movb %al, 0x26(%r12)
leaq 0x1b6(%rsp), %rdi
movq %r15, %rsi
movl $0x1, %edx
callq 0x36b8
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 0x1c1(%rsp), %rdi
movq %r15, %rsi
movl $0x1, %edx
callq 0x36b8
movq (%r14,%r13,8), %rax
movq 0x88(%rax), %rax
movq (%rax,%rbp,8), %rax
movq %rbx, %r12
leaq (%rax,%rbx), %rdi
addq $0x172, %rdi            # imm = 0x172
movq (%r15), %rsi
callq 0x2070
movq (%rsp), %rax
movb 0x1a(%rax), %al
movq (%r14,%r13,8), %rcx
movq 0x88(%rcx), %rcx
movq (%rcx,%rbp,8), %rcx
movq 0x8(%rsp), %rdx
movb %al, 0x1ea(%rcx,%rdx)
movq (%rsp), %rax
movb 0x25(%rax), %al
movq (%r14,%r13,8), %rcx
movq 0x88(%rcx), %rcx
movq (%rcx,%rbp,8), %rcx
movb %al, 0x1fe(%rcx,%rdx)
movq %rdx, %rbx
movq (%rsp), %rax
leaq 0x26(%rax), %rdi
movq %r15, %rsi
movl $0x1, %edx
callq 0x36b8
movq (%r15), %rdi
callq 0x21f0
movq (%r14,%r13,8), %rcx
movq 0x88(%rcx), %rcx
movq (%rcx,%rbp,8), %rcx
movl %eax, 0x214(%rcx,%rbx,4)
movq (%rsp), %rbx
movb $0x20, %al
cmpb %al, 0x2d(%rbx)
jne 0xf899
movq 0x8(%rsp), %rax
movl $0x0, 0x264(%rcx,%rax,4)
jmp 0xfa4e
leaq 0x2d(%rbx), %rdi
movq 0x8(%rsp), %rbx
movl $0x1, 0x264(%rcx,%rbx,4)
leaq 0x10(%rsp), %r15
movq %r15, %rsi
movl $0x1, %edx
callq 0x36b8
movq (%r14,%r13,8), %rax
movq 0x88(%rax), %rax
movq (%rax,%rbp,8), %rax
leaq (%rax,%r12), %rdi
addq $0x37c, %rdi            # imm = 0x37C
movq (%r15), %rsi
callq 0x2070
movq (%rsp), %rax
leaq 0x3c(%rax), %rdi
movq %r15, %rsi
movl $0x1, %edx
callq 0x36b8
movq (%r14,%r13,8), %rax
movq 0x88(%rax), %rax
movq (%rax,%rbp,8), %rax
leaq (%rax,%r12), %rdi
addq $0x3f4, %rdi            # imm = 0x3F4
movq (%r15), %rsi
callq 0x2070
leaq 0x1d2(%rsp), %rdi
movb $0x20, %al
movb %al, 0x5(%rdi)
movb %al, 0x14(%rdi)
movq %r15, %rsi
movl $0x1, %edx
callq 0x36b8
movq (%r14,%r13,8), %rax
movq 0x88(%rax), %rax
movq (%rax,%rbp,8), %rax
leaq (%rax,%r12), %rdi
addq $0x46c, %rdi            # imm = 0x46C
movq (%r15), %rsi
callq 0x2070
leaq 0x1e2(%rsp), %rdi
movq %r15, %rsi
movl $0x1, %edx
callq 0x36b8
movq (%r14,%r13,8), %rax
movq 0x88(%rax), %rax
movq (%rax,%rbp,8), %rax
leaq (%rax,%r12), %rdi
addq $0x4e4, %rdi            # imm = 0x4E4
movq (%r15), %rsi
callq 0x2070
movq (%rsp), %rax
movb 0x36(%rax), %al
movq (%r14,%r13,8), %rcx
movq 0x88(%rcx), %rcx
movq (%rcx,%rbp,8), %rcx
movb %al, 0x55c(%rcx,%rbx)
movq (%rsp), %rax
movb 0x45(%rax), %al
movq (%r14,%r13,8), %rcx
movq 0x88(%rcx), %rcx
movq (%rcx,%rbp,8), %rcx
movb %al, 0x570(%rcx,%rbx)
movb $0x20, %al
leaq 0x1e2(%rsp), %rcx
movb %al, -0x15(%rcx)
movb %al, -0x6(%rcx)
leaq 0x1c9(%rsp), %rdi
movq %r15, %rsi
movl $0x1, %edx
callq 0x36b8
movq (%r14,%r13,8), %rax
movq 0x88(%rax), %rax
movq (%rax,%rbp,8), %rax
leaq (%rbx,%rbx,4), %r12
movq (%rsp), %rbx
leaq (%rax,%r12), %rdi
addq $0x2b4, %rdi            # imm = 0x2B4
movq (%r15), %rsi
callq 0x2070
leaq 0x1d8(%rsp), %rdi
movq %r15, %rsi
movl $0x1, %edx
callq 0x36b8
movq (%r14,%r13,8), %rax
movq 0x88(%rax), %rax
movq (%rax,%rbp,8), %rax
leaq (%rax,%r12), %rdi
addq $0x318, %rdi            # imm = 0x318
movq (%r15), %rsi
callq 0x2070
movq (%r14,%r13,8), %rax
movq 0x88(%rax), %rax
movq (%rax,%rbp,8), %r14
leaq 0x4(%r14), %rsi
leaq 0x12ba2(%rip), %rdi     # 0x2260a
callq 0x2070
movb 0x15(%rbx), %al
movb %al, 0x12b92(%rip)      # 0x22608
incl (%r14)
movl $0x1, %eax
addq $0x5a8, %rsp            # imm = 0x5A8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
xorl %eax, %eax
jmp 0xfa7e