// File: /workspace/github_c_makefile_star2_O2/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, %rbx
cmpl $0x0, 0x1cf8(%rcx)
je 0xf6f9
movq %rcx, %r12
addq $0x1c08, %r12           # imm = 0x1C08
movsbl 0x15(%rbx), %edi
callq 0x4969
movsbl %al, %esi
movq %r12, %rdi
callq 0x4974
testl %eax, %eax
je 0xfb84
movl (%r15), %eax
xorl %ecx, %ecx
testl %eax, %eax
movl $0x0, %r13d
cmovgl %eax, %r13d
cmpq %rcx, %r13
je 0xf723
movq (%r14,%rcx,8), %rdx
movb 0x40(%rdx), %dl
cmpb 0x15(%rbx), %dl
je 0xf720
incq %rcx
jmp 0xf70a
movl %ecx, %r13d
cmpl %eax, %r13d
jne 0xf741
leaq (%r14,%rax,8), %r12
movq %r12, %rdi
callq 0x3798
movb 0x15(%rbx), %al
movq (%r12), %rcx
movb %al, 0x40(%rcx)
incl (%r15)
movl %r13d, %ebp
movq (%r14,%rbp,8), %rax
cmpl $-0x1, 0x20(%rax)
jne 0xf75e
movb $0x2a, 0x11ec3(%rip)    # 0x21618
movw $0x2a, 0x11ebc(%rip)    # 0x2161a
leaq 0x7(%rbx), %rdi
leaq 0x20(%rsp), %r15
pushq $0x2
popq %rdx
movq %r15, %rsi
callq 0x311c
movq (%r15), %rdi
callq 0x2200
cmpl $0x1, %eax
setne %dl
movb 0x15(%rbx), %al
movb 0x11e8f(%rip), %cl      # 0x21618
cmpb %cl, %al
sete %sil
testb %sil, %dl
je 0xf7ac
movq (%r14,%rbp,8), %rax
movslq 0x20(%rax), %r12
movq 0x88(%rax), %rax
movq (%rax,%r12,8), %rax
movslq (%rax), %r13
jmp 0xf817
cmpb %cl, %al
jne 0xf7c9
movq 0x28(%rsp), %rsi
leaq 0x11e5e(%rip), %rdi     # 0x2161a
callq 0x2150
testl %eax, %eax
je 0xfb99
movq (%r14,%rbp,8), %rax
movslq 0x20(%rax), %r15
leaq 0x1(%r15), %r12
movl %r12d, 0x20(%rax)
movl $0x584, %edi            # imm = 0x584
callq 0x50f4
movq (%r14,%rbp,8), %rcx
movq 0x88(%rcx), %rcx
movq %rax, 0x8(%rcx,%r15,8)
movq (%r14,%rbp,8), %rax
movq 0x88(%rax), %rax
movq 0x8(%rax,%r15,8), %rdi
andl $0x0, (%rdi)
addq $0x4, %rdi
movq 0x28(%rsp), %rsi
callq 0x2070
xorl %r13d, %r13d
movq %r12, 0x18(%rsp)
leaq 0x11(%rbx), %rdi
leaq 0x20(%rsp), %rsi
pushq $0x1
popq %rdx
callq 0x311c
movq (%r14,%rbp,8), %rax
movq 0x88(%rax), %rax
movq (%rax,%r12,8), %rax
movq %r13, 0x10(%rsp)
imulq $0x6, %r13, %r15
leaq (%rax,%r15), %rdi
addq $0xa, %rdi
leaq 0x20(%rsp), %rax
movq (%rax), %rsi
callq 0x2070
leaq 0x1c(%rbx), %rdi
leaq 0x20(%rsp), %rsi
movq %rsi, %r13
pushq $0x1
popq %rdx
callq 0x311c
movq (%r14,%rbp,8), %rax
movq 0x88(%rax), %rax
movq (%rax,%r12,8), %rax
leaq (%rax,%r15), %rdi
addq $0x82, %rdi
movq (%r13), %rsi
callq 0x2070
leaq 0x1b0(%rsp), %r12
movq %r12, %rdi
movq %rbx, %rsi
callq 0x2070
movb $0x20, %al
movb %al, 0x1b(%r12)
movb %al, 0x26(%r12)
movq 0x18(%rsp), %r12
leaq 0x1c6(%rsp), %rdi
movq %r13, %rsi
pushq $0x1
popq %rdx
callq 0x311c
movq (%r14,%rbp,8), %rax
movq 0x88(%rax), %rax
movq (%rax,%r12,8), %rax
leaq (%rax,%r15), %rdi
addq $0xfa, %rdi
movq (%r13), %rsi
callq 0x2070
leaq 0x1d1(%rsp), %rdi
movq %r13, %rsi
pushq $0x1
popq %rdx
callq 0x311c
movq (%r14,%rbp,8), %rax
movq 0x88(%rax), %rax
movq (%rax,%r12,8), %rax
movq %r15, 0x8(%rsp)
leaq (%rax,%r15), %rdi
addq $0x172, %rdi            # imm = 0x172
movq (%r13), %rsi
movq %r13, %r15
callq 0x2070
movb 0x1a(%rbx), %al
movq (%r14,%rbp,8), %rcx
movq 0x88(%rcx), %rcx
movq (%rcx,%r12,8), %rcx
movq 0x10(%rsp), %r13
movb %al, 0x1ea(%rcx,%r13)
movb 0x25(%rbx), %al
movq (%r14,%rbp,8), %rcx
movq 0x88(%rcx), %rcx
movq (%rcx,%r12,8), %rcx
movb %al, 0x1fe(%rcx,%r13)
leaq 0x26(%rbx), %rdi
movq %r15, %rsi
pushq $0x1
popq %rdx
callq 0x311c
movq (%r15), %rdi
callq 0x2200
movq (%r14,%rbp,8), %rcx
movq 0x88(%rcx), %rcx
movq (%rcx,%r12,8), %r15
movl %eax, 0x214(%r15,%r13,4)
movb $0x20, %al
cmpb %al, 0x2d(%rbx)
jne 0xf9a5
andl $0x0, 0x264(%r15,%r13,4)
jmp 0xfb68
leaq 0x2d(%rbx), %rdi
movl $0x1, 0x264(%r15,%r13,4)
leaq 0x20(%rsp), %rsi
pushq $0x1
popq %rdx
callq 0x311c
movq (%r14,%rbp,8), %rax
movq 0x88(%rax), %rax
movq (%rax,%r12,8), %rax
movq 0x8(%rsp), %r15
leaq (%rax,%r15), %rdi
addq $0x37c, %rdi            # imm = 0x37C
leaq 0x20(%rsp), %rax
movq (%rax), %rsi
callq 0x2070
leaq 0x3c(%rbx), %rdi
leaq 0x20(%rsp), %rsi
pushq $0x1
popq %rdx
callq 0x311c
movq (%r14,%rbp,8), %rax
movq 0x88(%rax), %rax
movq (%rax,%r12,8), %rax
leaq (%rax,%r15), %rdi
addq $0x3f4, %rdi            # imm = 0x3F4
leaq 0x20(%rsp), %rax
movq (%rax), %rsi
callq 0x2070
leaq 0x1e2(%rsp), %rdi
movb $0x20, %al
movb %al, 0x5(%rdi)
movb %al, 0x14(%rdi)
leaq 0x20(%rsp), %rsi
pushq $0x1
popq %rdx
callq 0x311c
movq (%r14,%rbp,8), %rax
movq 0x88(%rax), %rax
movq (%rax,%r12,8), %rax
leaq (%rax,%r15), %rdi
addq $0x46c, %rdi            # imm = 0x46C
leaq 0x20(%rsp), %rax
movq (%rax), %rsi
callq 0x2070
leaq 0x1f2(%rsp), %rdi
leaq 0x20(%rsp), %rsi
pushq $0x1
popq %rdx
callq 0x311c
movq (%r14,%rbp,8), %rax
movq 0x88(%rax), %rax
movq (%rax,%r12,8), %rax
leaq (%rax,%r15), %rdi
addq $0x4e4, %rdi            # imm = 0x4E4
leaq 0x20(%rsp), %r15
movq (%r15), %rsi
callq 0x2070
movb 0x36(%rbx), %al
movq (%r14,%rbp,8), %rcx
movq 0x88(%rcx), %rcx
movq (%rcx,%r12,8), %rcx
movb %al, 0x55c(%rcx,%r13)
movb 0x45(%rbx), %al
movq (%r14,%rbp,8), %rcx
movq 0x88(%rcx), %rcx
movq (%rcx,%r12,8), %rcx
movb %al, 0x570(%rcx,%r13)
movb $0x20, %al
leaq 0x1f2(%rsp), %rcx
movb %al, -0x15(%rcx)
movb %al, -0x6(%rcx)
leaq 0x1d9(%rsp), %rdi
movq %r15, %rsi
pushq $0x1
popq %rdx
callq 0x311c
movq (%r14,%rbp,8), %rax
movq 0x88(%rax), %rax
movq (%rax,%r12,8), %rax
leaq (%r13,%r13,4), %r13
leaq (%rax,%r13), %rdi
addq $0x2b4, %rdi            # imm = 0x2B4
movq (%r15), %rsi
callq 0x2070
leaq 0x1e8(%rsp), %rdi
movq %r15, %rsi
pushq $0x1
popq %rdx
callq 0x311c
movq (%r14,%rbp,8), %rax
movq 0x88(%rax), %rax
movq (%rax,%r12,8), %rax
leaq (%rax,%r13), %rdi
addq $0x318, %rdi            # imm = 0x318
movq (%r15), %rsi
callq 0x2070
movq (%r14,%rbp,8), %rax
movq 0x88(%rax), %rax
movq (%rax,%r12,8), %r15
leaq 0x4(%r15), %rsi
leaq 0x11aa7(%rip), %rdi     # 0x2161a
callq 0x2070
movb 0x15(%rbx), %al
movb %al, 0x11a97(%rip)      # 0x21618
incl (%r15)
pushq $0x1
popq %rax
addq $0x5b8, %rsp            # imm = 0x5B8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
xorl %eax, %eax
jmp 0xfb87
nopl (%rax)