// File: /workspace/github_c_makefile_star2_O2/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 $0x5a8, %rsp            # imm = 0x5A8
movq %rcx, %r13
movq %rdx, %r12
movq %rsi, %r14
movq %rdi, %r15
cmpl $0x0, 0x1cf8(%r8)
pushq $0x1
popq %rbp
je 0xf057
leaq 0x1c08(%r8), %rbx
movsbl 0x15(%r15), %edi
movq %r8, %rbp
callq 0x4969
movsbl %al, %esi
movq %rbx, %rdi
callq 0x4974
movq %rbp, %r8
pushq $0x1
popq %rbp
testl %eax, %eax
je 0xf108
movzbl 0x10(%r15), %eax
addl $-0x20, %eax
cmpl $0x21, %eax
ja 0xf108
movabsq $0x200020001, %rcx      # imm = 0x200020001
btq %rax, %rcx
jae 0xf108
cmpl $0x0, (%r13)
je 0xf0ab
xorl %eax, %eax
leaq 0x12334(%rip), %rcx     # 0x213c0
cmpq $0x258, %rax            # imm = 0x258
je 0xf0a6
movb $0x0, 0x4(%rax,%rcx)
movl $0x58585858, (%rax,%rcx) # imm = 0x58585858
addq $0x6, %rax
jmp 0xf08c
andl $0x0, (%r13)
movl (%r12), %eax
xorl %edx, %edx
testl %eax, %eax
movl $0x0, %ecx
cmovgl %eax, %ecx
cmpq %rdx, %rcx
je 0xf0d5
movq (%r14,%rdx,8), %rsi
movb 0x40(%rsi), %sil
cmpb 0x15(%r15), %sil
je 0xf0d3
incq %rdx
jmp 0xf0bb
movl %edx, %ecx
movl %ecx, %r13d
cmpl %eax, %ecx
jne 0xf0fe
leaq (%r14,%rax,8), %rbx
movq %rbx, %rdi
movq %r8, %rbp
callq 0x3798
movq %rbp, %r8
movb 0x15(%r15), %al
movq (%rbx), %rcx
movb %al, 0x40(%rcx)
incl (%r12)
jmp 0xf11c
movq (%r14,%r13,8), %rax
cmpl $0x1, 0xc(%rax)
jne 0xf11c
movl %ebp, %eax
addq $0x5a8, %rsp            # imm = 0x5A8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
cmpb $0x2e, 0x22(%r15)
jne 0xf270
cmpb $0x2e, 0x2a(%r15)
jne 0xf270
cmpb $0x2e, 0x32(%r15)
jne 0xf270
cmpl $0x0, 0x1d84(%r8)
je 0xf152
cmpb $0x2e, 0x3f(%r15)
jne 0xf294
movq %r8, 0x8(%rsp)
leaq 0x16(%r15), %rdi
leaq 0x10(%rsp), %rbx
pushq $0x1
popq %rdx
movq %rbx, %rsi
callq 0x311c
movq (%rbx), %rdi
imulq $0x6, %r13, %rax
leaq 0x12247(%rip), %r12     # 0x213c0
addq %rax, %r12
movq %r12, %rsi
callq 0x2150
testl %eax, %eax
je 0xf29d
leaq 0x9f92(%rip), %rsi      # 0x19125
movq %r12, %rdi
callq 0x2150
testl %eax, %eax
je 0xf1d4
movq (%r14,%r13,8), %rdi
movl (%rdi), %esi
leaq 0xac3c(%rip), %rdx      # 0x19de8
leaq 0x4(%rsp), %rcx
callq 0x4777
testl %eax, %eax
jne 0xf1d4
movq (%r14,%r13,8), %rax
movq 0x68(%rax), %rcx
movslq (%rax), %rax
movq (%rcx,%rax,8), %rdi
callq 0x2040
movq (%r14,%r13,8), %rax
decl (%rax)
leaq 0x9f4a(%rip), %rsi      # 0x19125
movq %r12, %rdi
callq 0x2150
movq (%r14,%r13,8), %rcx
movl (%rcx), %ebx
testl %eax, %eax
je 0xf1f1
incl %ebx
movl %ebx, (%rcx)
leaq 0x10(%rsp), %rbp
movq (%rbp), %rsi
movq %r12, %rdi
callq 0x2070
movl $0x778, %edi            # imm = 0x778
callq 0x50f4
movq (%r14,%r13,8), %rcx
movq 0x68(%rcx), %rcx
movslq %ebx, %rbx
movq %rax, (%rcx,%rbx,8)
movq (%r14,%r13,8), %rax
movq 0x68(%rax), %rax
movq (%rax,%rbx,8), %rdi
addq $0x4, %rdi
movq %r12, %rsi
callq 0x2070
movq (%r14,%r13,8), %rax
movq 0x68(%rax), %rax
movq (%rax,%rbx,8), %rax
andl $0x0, (%rax)
leaq 0x11(%r15), %rdi
pushq $0x1
popq %rdx
movq %rbp, %rsi
callq 0x311c
movq (%r14,%r13,8), %rax
movq 0x68(%rax), %rax
movq (%rax,%rbx,8), %rdi
addq $0xa, %rdi
movq (%rbp), %rsi
callq 0x2070
movq (%r14,%r13,8), %rax
jmp 0xf2a4
leaq 0x9eb3(%rip), %rsi      # 0x1912a
xorl %edi, %edi
movq %r8, %rdx
xorl %eax, %eax
addq $0x5a8, %rsp            # imm = 0x5A8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xece4
leaq 0x9eab(%rip), %rsi      # 0x19146
jmp 0xf277
movq (%r14,%r13,8), %rax
movslq (%rax), %rbx
movq 0x68(%rax), %rax
movq (%rax,%rbx,8), %rax
movl (%rax), %eax
movl %eax, 0x4(%rsp)
cmpb $0x20, 0x10(%r15)
movq %r15, %r12
je 0xf2d5
leaq 0x1a0(%rsp), %r12
movq %r12, %rdi
movq %r15, %rsi
callq 0x2070
movb $0x20, 0x10(%r12)
addq $0xc, %r12
leaq 0x10(%rsp), %rsi
pushq $0x1
popq %rbp
movq %r12, %rdi
movl %ebp, %edx
callq 0x311c
movq (%r14,%r13,8), %rax
movq 0x68(%rax), %rax
movq (%rax,%rbx,8), %r12
movslq 0x4(%rsp), %rax
leaq (%rax,%rax,4), %rax
leaq (%r12,%rax), %rdi
addq $0x10, %rdi
leaq 0x10(%rsp), %rbx
movq (%rbx), %rsi
callq 0x2070
leaq 0x1a0(%rsp), %rdi
movq %r15, %rsi
callq 0x2070
movb $0x20, %al
movb %al, 0x26(%r15)
leaq 0x1be(%rsp), %rdi
movq %rbx, %rsi
movl %ebp, %edx
callq 0x311c
movq (%rbx), %rdi
callq 0x2080
cvtsd2ss %xmm0, %xmm0
movslq 0x4(%rsp), %rax
imulq $0xc, %rax, %rax
movss %xmm0, 0x188(%r12,%rax)
leaq 0x1a0(%rsp), %rdi
movq %r15, %rsi
callq 0x2070
movb $0x20, %al
movb %al, 0x2e(%r15)
leaq 0x1c6(%rsp), %rdi
movq %rbx, %rsi
movl %ebp, %edx
callq 0x311c
movq (%rbx), %rdi
callq 0x2080
cvtsd2ss %xmm0, %xmm0
movslq 0x4(%rsp), %rax
imulq $0xc, %rax, %rax
movss %xmm0, 0x18c(%r12,%rax)
leaq 0x1a0(%rsp), %rdi
movq %r15, %rsi
callq 0x2070
movb $0x20, %al
movb %al, 0x36(%r15)
leaq 0x1ce(%rsp), %rdi
movq %rbx, %rsi
movl %ebp, %edx
callq 0x311c
movq (%rbx), %rdi
callq 0x2080
cvtsd2ss %xmm0, %xmm0
movslq 0x4(%rsp), %rax
imulq $0xc, %rax, %rcx
movss %xmm0, 0x190(%r12,%rcx)
cmpb $0x2e, 0x39(%r15)
jne 0xf43d
leaq 0x1a0(%rsp), %rbx
movq %rbx, %rdi
movq %r15, %rsi
callq 0x2070
movb $0x20, 0x3c(%rbx)
leaq 0x1d6(%rsp), %rdi
leaq 0x10(%rsp), %rbx
pushq $0x1
popq %rdx
movq %rbx, %rsi
callq 0x311c
movq (%rbx), %rdi
callq 0x2080
cvtsd2ss %xmm0, %xmm0
movslq 0x4(%rsp), %rax
movss %xmm0, 0x50c(%r12,%rax,4)
jmp 0xf449
movl $0xbf800000, 0x50c(%r12,%rax,4) # imm = 0xBF800000
addq $0x3f, %r15
leaq 0x10(%rsp), %rbx
movq %r15, %rdi
movq %rbx, %rsi
movl %ebp, %edx
callq 0x311c
movq (%rbx), %rdi
callq 0x2080
cvtsd2ss %xmm0, %xmm0
movslq 0x4(%rsp), %rax
movss %xmm0, 0x638(%r12,%rax,4)
movl (%r12), %eax
leal 0x1(%rax), %ecx
movl %ecx, (%r12)
cmpl $0x4a, %eax
movq 0x8(%rsp), %rdx
jl 0xf108
leaq 0xa(%r12), %rcx
addq $0x4, %r12
movq (%r14,%r13,8), %rax
movsbl 0x40(%rax), %r9d
leaq 0x9cbd(%rip), %rsi      # 0x19169
xorl %edi, %edi
movq %r12, %r8
xorl %eax, %eax
callq 0xece4
movl %eax, %ebp
jmp 0xf108
nop