// File: /workspace/github_c_makefile_star2_O3/josch[P]stride/p_atom.c
// Function: Process_ATOM
int Process_ATOM(BUFFER Buffer, CHAIN **Chain, int *ChainNumber, 
		 BOOLEAN *First_ATOM, COMMAND *Cmd)
{

  char *Field[MAX_FIELD];
  BUFFER Tmp;
  int CC, NR, NA;
  static char LastRes[MAX_CHAIN][RES_FIELD];
  RESIDUE *r;

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

  if( Buffer[16] != 'A' && Buffer[16] != ' ' && Buffer[16] != '1' ) 
    return(SUCCESS);

  if( *First_ATOM ) {
    for( CC=0; CC<MAX_CHAIN; CC++ ) 
      strcpy(LastRes[CC],"XXXX");
    *First_ATOM = NO;
  }
  
  for( CC=0; CC < *ChainNumber && Chain[CC]->Id != Buffer[21] ; CC++ );
  
  if( CC == *ChainNumber ) {
    InitChain(&Chain[CC]); 
    Chain[CC]->Id = Buffer[21];
    (*ChainNumber)++;
  }
  else
  if( Chain[CC]->Ter == 1 ) 
    return(SUCCESS);

  if( Buffer[34] != '.' || Buffer[42] != '.' || Buffer[50] != '.' )
    return(escape(FAILURE,"File %s has no coordinates\n",Cmd->InputFile));

  
  if( Cmd->Stringent && Buffer[63] != '.')
    return(escape(FAILURE,"File %s has no temperature factor\n",Cmd->InputFile));


  SplitString(Buffer+22,Field,1);
  if( strcmp(Field[0],LastRes[CC]) ) {
    if( strcmp(LastRes[CC],"XXXX") && !FindAtom(Chain[CC],Chain[CC]->NRes,"CA",&NA) ) {
      free(Chain[CC]->Rsd[Chain[CC]->NRes]);
      Chain[CC]->NRes--;
    }
    if( strcmp(LastRes[CC],"XXXX") ) Chain[CC]->NRes++;
    NR = Chain[CC]->NRes;
    strcpy(LastRes[CC],Field[0]);
    Chain[CC]->Rsd[NR] = (RESIDUE *)ckalloc(sizeof(RESIDUE));
    strcpy(Chain[CC]->Rsd[NR]->PDB_ResNumb,LastRes[CC]);
    Chain[CC]->Rsd[NR]->NAtom = 0;
    SplitString(Buffer+17,Field,1);
    strcpy(Chain[CC]->Rsd[NR]->ResType,Field[0]);
  }
  else 
    NR = Chain[CC]->NRes;
  
  NA = Chain[CC]->Rsd[NR]->NAtom;

  if( Buffer[16] != ' ' ) {
    strcpy(Tmp,Buffer);
    Tmp[16] = ' ';
    SplitString(Tmp+12,Field,1);
  }
  else
    SplitString(Buffer+12,Field,1);
  
  r = Chain[CC]->Rsd[NR];
  strcpy(r->AtomType[NA],Field[0]);


  strcpy(Tmp,Buffer);
  Buffer[38] = ' ';
  SplitString(Tmp+30,Field,1);
  r->Coord[NA][0] = atof(Field[0]);

  strcpy(Tmp,Buffer);
  Buffer[46] = ' ';
  SplitString(Tmp+38,Field,1);
  r->Coord[NA][1] = atof(Field[0]);

  strcpy(Tmp,Buffer);
  Buffer[54] = ' ';
  SplitString(Tmp+46,Field,1);
  r->Coord[NA][2] = atof(Field[0]);

  if( Buffer[57] == '.' ) {
    strcpy(Tmp,Buffer);
    Tmp[60] = ' ';
    SplitString(Tmp+54,Field,1);
    r->Occupancy[NA] = atof(Field[0]);
  }
  else 
    r->Occupancy[NA] = -1.00;
  
  SplitString(Buffer+63,Field,1);
  r->TempFactor[NA] = atof(Field[0]);

  r->NAtom++;

  if( r->NAtom > MAX_AT_IN_RES-1 )
    return(escape(FAILURE,"File %s has too many atoms in residue %s %s %c\n",
		  Cmd->InputFile,r->ResType,r->PDB_ResNumb,Chain[CC]->Id));

  return(SUCCESS);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x5b8, %rsp            # imm = 0x5B8
movq %r8, %rbx
movq %rcx, %r13
movq %rdx, %r12
movq %rsi, %r14
movq %rdi, %r15
cmpl $0x0, 0x1cf8(%r8)
je 0xf08a
leaq 0x1c08(%rbx), %rbp
movsbl 0x15(%r15), %edi
callq 0x50a2
movsbl %al, %esi
movq %rbp, %rdi
callq 0x50af
testl %eax, %eax
je 0xf10e
movzbl 0x10(%r15), %eax
movl $0x1, %ebp
addl $-0x20, %eax
cmpl $0x21, %eax
ja 0xf144
movabsq $0x200020001, %rcx      # imm = 0x200020001
btq %rax, %rcx
jae 0xf144
cmpl $0x0, (%r13)
je 0xf0e4
xorl %eax, %eax
leaq 0x132ec(%rip), %rcx     # 0x223b0
movb $0x0, 0x4(%rax,%rcx)
movl $0x58585858, (%rax,%rcx) # imm = 0x58585858
addq $0x6, %rax
cmpq $0x258, %rax            # imm = 0x258
jne 0xf0c4
movl $0x0, (%r13)
movq %rbx, 0x10(%rsp)
movl (%r12), %ebx
testl %ebx, %ebx
jle 0xf115
movb 0x15(%r15), %al
xorl %r13d, %r13d
movq (%r14,%r13,8), %rcx
cmpb %al, 0x40(%rcx)
je 0xf118
incq %r13
cmpq %r13, %rbx
jne 0xf0f8
movl %ebx, %r13d
jmp 0xf11d
movl $0x1, %ebp
jmp 0xf144
xorl %r13d, %r13d
cmpl %ebx, %r13d
jne 0xf137
leaq (%r14,%rbx,8), %rdi
callq 0x3d9c
movb 0x15(%r15), %al
movq (%r14,%rbx,8), %rcx
movb %al, 0x40(%rcx)
incl (%r12)
jmp 0xf158
movl %r13d, %eax
movq (%r14,%rax,8), %rax
cmpl $0x1, 0xc(%rax)
jne 0xf158
movl %ebp, %eax
addq $0x5b8, %rsp            # imm = 0x5B8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
cmpb $0x2e, 0x22(%r15)
jne 0xf2c4
cmpb $0x2e, 0x2a(%r15)
jne 0xf2c4
cmpb $0x2e, 0x32(%r15)
jne 0xf2c4
movq 0x10(%rsp), %rdx
cmpl $0x0, 0x1d84(%rdx)
je 0xf192
cmpb $0x2e, 0x3f(%r15)
jne 0xf2ea
leaq 0x16(%r15), %rdi
leaq 0x20(%rsp), %r12
movq %r12, %rsi
movl $0x1, %edx
callq 0x36c4
movq (%r12), %rdi
movl %r13d, %ebx
leaq (%rbx,%rbx,2), %rax
leaq 0x131f6(%rip), %rcx     # 0x223b0
leaq (%rcx,%rax,2), %r12
movq %r12, %rsi
callq 0x2150
testl %eax, %eax
movq %rbx, 0x18(%rsp)
je 0xf2f5
leaq 0xaf7b(%rip), %rsi      # 0x1a155
movq %r12, %rdi
callq 0x2150
testl %eax, %eax
je 0xf21b
movq (%r14,%rbx,8), %rdi
movl (%rdi), %esi
leaq 0xbc45(%rip), %rdx      # 0x1ae38
leaq 0xc(%rsp), %rcx
callq 0x4ea0
testl %eax, %eax
jne 0xf21b
movq (%r14,%rbx,8), %rax
movq 0x68(%rax), %rcx
movslq (%rax), %rax
movq (%rcx,%rax,8), %rdi
callq 0x2040
movq (%r14,%rbx,8), %rax
decl (%rax)
leaq 0xaf33(%rip), %rsi      # 0x1a155
movq %r12, %rdi
callq 0x2150
movq (%r14,%rbx,8), %rcx
movl (%rcx), %ebx
testl %eax, %eax
je 0xf238
incl %ebx
movl %ebx, (%rcx)
leaq 0x20(%rsp), %r13
movq (%r13), %rsi
movq %r12, %rdi
callq 0x2070
movl $0x778, %edi            # imm = 0x778
callq 0x5880
movq 0x18(%rsp), %rdx
movq (%r14,%rdx,8), %rcx
movq 0x68(%rcx), %rcx
movslq %ebx, %rbp
movq %rdx, %rbx
movq %rax, (%rcx,%rbp,8)
movq (%r14,%rdx,8), %rax
movq 0x68(%rax), %rax
movq (%rax,%rbp,8), %rdi
addq $0x4, %rdi
movq %r12, %rsi
callq 0x2070
movq (%r14,%rbx,8), %rax
movq 0x68(%rax), %rax
movq (%rax,%rbp,8), %rax
movl $0x0, (%rax)
leaq 0x11(%r15), %rdi
movq %r13, %rsi
movl $0x1, %edx
callq 0x36c4
movq (%r14,%rbx,8), %rax
movq 0x68(%rax), %rax
movq (%rax,%rbp,8), %rdi
addq $0xa, %rdi
movq (%r13), %rsi
callq 0x2070
movq (%r14,%rbx,8), %rax
jmp 0xf2fc
leaq 0xae8f(%rip), %rsi      # 0x1a15a
xorl %edi, %edi
movq 0x10(%rsp), %rdx
xorl %eax, %eax
addq $0x5b8, %rsp            # imm = 0x5B8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x2424
leaq 0xae85(%rip), %rsi      # 0x1a176
xorl %edi, %edi
jmp 0xf2d2
movq (%r14,%rbx,8), %rax
movslq (%rax), %rbp
movq 0x68(%rax), %rax
movq (%rax,%rbp,8), %rax
movl (%rax), %eax
movl %eax, 0xc(%rsp)
cmpb $0x20, 0x10(%r15)
movq %r15, %r12
je 0xf32d
leaq 0x1b0(%rsp), %r12
movq %r12, %rdi
movq %r15, %rsi
callq 0x2070
movb $0x20, 0x10(%r12)
addq $0xc, %r12
leaq 0x20(%rsp), %r13
movq %r12, %rdi
movq %r13, %rsi
movl $0x1, %edx
callq 0x36c4
movq (%r14,%rbx,8), %rax
movq 0x68(%rax), %rax
movq (%rax,%rbp,8), %r12
movslq 0xc(%rsp), %rax
leaq (%rax,%rax,4), %rax
leaq (%r12,%rax), %rdi
addq $0x10, %rdi
movq (%r13), %rsi
callq 0x2070
leaq 0x1b0(%rsp), %rbp
movq %rbp, %rdi
movq %r15, %rsi
callq 0x2070
movb $0x20, %bl
movb %bl, 0x26(%r15)
leaq 0x1ce(%rsp), %rdi
movq %r13, %rsi
movl $0x1, %edx
callq 0x36c4
movq (%r13), %rdi
callq 0x2080
cvtsd2ss %xmm0, %xmm0
movslq 0xc(%rsp), %rax
leaq (%rax,%rax,2), %rax
movss %xmm0, 0x188(%r12,%rax,4)
movq %rbp, %rdi
movq %r15, %rsi
callq 0x2070
movb %bl, 0x2e(%r15)
leaq 0x1d6(%rsp), %rdi
movq %r13, %rsi
movl $0x1, %edx
callq 0x36c4
movq (%r13), %rdi
callq 0x2080
cvtsd2ss %xmm0, %xmm0
movslq 0xc(%rsp), %rax
leaq (%rax,%rax,2), %rax
movss %xmm0, 0x18c(%r12,%rax,4)
movq %rbp, %rdi
movq %r15, %rsi
callq 0x2070
movb %bl, 0x36(%r15)
leaq 0x1de(%rsp), %rdi
movq %r13, %rsi
movl $0x1, %edx
callq 0x36c4
movq (%r13), %rdi
callq 0x2080
cvtsd2ss %xmm0, %xmm0
movslq 0xc(%rsp), %rax
leaq (%rax,%rax,2), %rcx
movss %xmm0, 0x190(%r12,%rcx,4)
cmpb $0x2e, 0x39(%r15)
jne 0xf499
leaq 0x1b0(%rsp), %r13
movq %r13, %rdi
movq %r15, %rsi
callq 0x2070
movb $0x20, 0x3c(%r13)
leaq 0x1e6(%rsp), %rdi
leaq 0x20(%rsp), %r13
movq %r13, %rsi
movl $0x1, %edx
callq 0x36c4
movq (%r13), %rdi
callq 0x2080
cvtsd2ss %xmm0, %xmm0
movslq 0xc(%rsp), %rax
movss %xmm0, 0x50c(%r12,%rax,4)
jmp 0xf4a5
movl $0xbf800000, 0x50c(%r12,%rax,4) # imm = 0xBF800000
addq $0x3f, %r15
leaq 0x20(%rsp), %r13
movl $0x1, %ebp
movq %r15, %rdi
movq %r13, %rsi
movl $0x1, %edx
callq 0x36c4
movq (%r13), %rdi
callq 0x2080
cvtsd2ss %xmm0, %xmm0
movslq 0xc(%rsp), %rax
movss %xmm0, 0x638(%r12,%rax,4)
movl (%r12), %eax
leal 0x1(%rax), %ecx
movl %ecx, (%r12)
cmpl $0x4a, %eax
movq 0x18(%rsp), %rax
jl 0xf144
leaq 0xa(%r12), %rcx
addq $0x4, %r12
movq (%r14,%rax,8), %rax
movsbl 0x40(%rax), %r9d
leaq 0xac88(%rip), %rsi      # 0x1a199
xorl %edi, %edi
movq 0x10(%rsp), %rdx
movq %r12, %r8
xorl %eax, %eax
callq 0x2424
movl %eax, %ebp
jmp 0xf144
nopl (%rax)