// File: /workspace/github_c_makefile_star2_O3/josch[P]stride/stride.c
// Function: main
int main(int argc, char **argv)
{

  CHAIN **Chain;
  HBOND **HBond;
  COMMAND *Cmd;
  int Cn, NChain=0, NHBond=0, ValidChain=0;
  float **PhiPsiMapHelix, **PhiPsiMapSheet;
  register int i;

  /* argc = ccommand(&argv); */ /* For Macintosh only, see readme.mac */



  Chain = (CHAIN  **)ckalloc(MAX_CHAIN*sizeof(CHAIN *));
  HBond = (HBOND  **)ckalloc(MAXHYDRBOND*sizeof(HBOND *));
  Cmd   = (COMMAND *)ckalloc(sizeof(COMMAND));

  ProcessStrideOptions(argv,argc,Cmd);

  if( !ReadPDBFile(Chain,&NChain,Cmd) || !NChain )
    die("Error reading PDB file %s\n",Cmd->InputFile);
  
  for( Cn=0; Cn<NChain; Cn++ )
    ValidChain += CheckChain(Chain[Cn],Cmd);

/*   if( Cmd->Stringent )
 *     exit(0);
 */
  if( !ValidChain ) 
    die("No valid chain in %s\n",Chain[0]->File);
  
  if( Cmd->BrookhavenAsn )
    GetPdbAsn(Chain,NChain);

  if( Cmd->DsspAsn )
    GetDsspAsn(Chain,NChain,Cmd);

  BackboneAngles(Chain,NChain);

  if( Cmd->OutSeq )
    OutSeq(Chain,NChain,Cmd);

  if( Cmd->ContactOrder )
    ContactOrder(Chain,NChain,Cmd);

  if( Cmd->ContactMap )
    ContactMap(Chain,NChain,Cmd);

  if( !strlen(Cmd->MapFileHelix) )
    PhiPsiMapHelix = DefaultHelixMap(Cmd);
  else
    ReadPhiPsiMap(Cmd->MapFileHelix,&PhiPsiMapHelix,Cmd);

  if( !strlen(Cmd->MapFileSheet) )
    PhiPsiMapSheet = DefaultSheetMap(Cmd);
  else
    ReadPhiPsiMap(Cmd->MapFileSheet,&PhiPsiMapSheet,Cmd);
  
  for( Cn=0; Cn<NChain; Cn++ )
    PlaceHydrogens(Chain[Cn]);
  
  if( (NHBond = FindHydrogenBonds(Chain,Cn,HBond,Cmd)) == 0 ) 
    die("No hydrogen bonds found in %s\n",Cmd->InputFile);
  
  NoDoubleHBond(HBond,NHBond);
  
  DiscrPhiPsi(Chain,NChain,Cmd);
  
  if(Cmd->ExposedArea)
    Area(Chain,NChain,Cmd);

  for( Cn=0; Cn<NChain; Cn++ ) {

    if( Chain[Cn]->Valid ) {
    
      Helix(Chain,Cn,HBond,Cmd,PhiPsiMapHelix);
      
      for( i=0; i<NChain; i++ ) 
	if( Chain[i]->Valid )
	  Sheet(Chain,Cn,i,HBond,Cmd,PhiPsiMapSheet);    
      
      BetaTurn(Chain,Cn);
      GammaTurn(Chain,Cn,HBond);
      
    }
  }
    
  Report(Chain,NChain,HBond,Cmd);

  if( Cmd->MolScript )
    MolScript(Chain,NChain,Cmd);

  for( i=0; i<Cn; i++ ) free(Chain[i]);
  for( i=0; i<NHBond; i++ ) free(HBond[i]);
  free(Cmd);

  return(0);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rsi, %r13
movl %edi, %ebp
leaq 0x4(%rsp), %r12
movl $0x0, (%r12)
movl $0x320, %edi            # imm = 0x320
callq 0x5880
movq %rax, %r15
movl $0x61a80, %edi          # imm = 0x61A80
callq 0x5880
movq %rax, %rbx
movl $0x29e4, %edi           # imm = 0x29E4
callq 0x5880
movq %rax, %r14
movq %r13, %rdi
movl %ebp, %esi
movq %rax, %rdx
callq 0x2c33
movq %r15, %rdi
movq %r12, %rsi
movq %r14, %rdx
callq 0x37d8
testl %eax, %eax
setne %cl
movl (%r12), %eax
testl %eax, %eax
setne %dl
testb %dl, %cl
jne 0x2985
leaq 0x16729(%rip), %rdi     # 0x190a0
movq %r14, %rsi
xorl %eax, %eax
callq 0x87c8
movl 0x4(%rsp), %eax
testl %eax, %eax
jle 0x29ad
xorl %r12d, %r12d
xorl %ebp, %ebp
movq (%r15,%r12,8), %rdi
movq %r14, %rsi
callq 0x16080
addl %eax, %ebp
incq %r12
movslq 0x4(%rsp), %rsi
cmpq %rsi, %r12
jl 0x298e
testl %ebp, %ebp
jne 0x29c6
movq (%r15), %rax
movq 0x48(%rax), %rsi
leaq 0x16700(%rip), %rdi     # 0x190bb
xorl %eax, %eax
callq 0x87c8
movl 0x4(%rsp), %esi
cmpl $0x0, 0x1d74(%r14)
je 0x29dc
movq %r15, %rdi
callq 0x15574
movl 0x4(%rsp), %esi
cmpl $0x0, 0x1d78(%r14)
je 0x29f5
movq %r15, %rdi
movq %r14, %rdx
callq 0x15d6f
movl 0x4(%rsp), %esi
movq %r15, %rdi
callq 0x808c
cmpl $0x0, 0x1d80(%r14)
je 0x2a16
movl 0x4(%rsp), %esi
movq %r15, %rdi
movq %r14, %rdx
callq 0x15f44
cmpl $0x0, 0x1d8c(%r14)
je 0x2a2f
movl 0x4(%rsp), %esi
movq %r15, %rdi
movq %r14, %rdx
callq 0x17fb8
cmpl $0x0, 0x1d90(%r14)
je 0x2a48
movl 0x4(%rsp), %esi
movq %r15, %rdi
movq %r14, %rdx
callq 0x18370
cmpb $0x0, 0xc03(%r14)
je 0x2a68
leaq 0xc03(%r14), %rdi
leaq 0x10(%rsp), %rsi
movq %r14, %rdx
callq 0x7d64
jmp 0x2a75
movq %r14, %rdi
callq 0x7f82
movq %rax, 0x10(%rsp)
cmpb $0x0, 0x1004(%r14)
je 0x2a98
movq %r14, %rdi
addq $0x1004, %rdi           # imm = 0x1004
leaq 0x8(%rsp), %rsi
movq %r14, %rdx
callq 0x7d64
jmp 0x2aa5
movq %r14, %rdi
callq 0x8006
movq %rax, 0x8(%rsp)
cmpl $0x0, 0x4(%rsp)
jle 0x2ac7
xorl %r12d, %r12d
movq (%r15,%r12,8), %rdi
callq 0x528c
incq %r12
movslq 0x4(%rsp), %rax
cmpq %rax, %r12
jl 0x2aaf
jmp 0x2aca
xorl %r12d, %r12d
movq %r15, %rdi
movl %r12d, %esi
movq %rbx, %rdx
movq %r14, %rcx
callq 0x95fe
movl %eax, %ebp
testl %eax, %eax
jne 0x2af2
leaq 0x165e9(%rip), %rdi     # 0x190d1
movq %r14, %rsi
xorl %eax, %eax
callq 0x87c8
movq %rbx, %rdi
movl %ebp, %esi
callq 0xa49b
movl 0x4(%rsp), %esi
movq %r15, %rdi
movq %r14, %rdx
callq 0x80da
cmpl $0x0, 0x1d68(%r14)
je 0x2b24
movl 0x4(%rsp), %esi
movq %r15, %rdi
movq %r14, %rdx
callq 0x146a0
movl 0x4(%rsp), %esi
xorl %r12d, %r12d
testl %esi, %esi
jle 0x2bbc
movq (%r15,%r12,8), %rax
cmpl $0x0, 0x58(%rax)
je 0x2bad
movq 0x10(%rsp), %r8
movq %r15, %rdi
movl %r12d, %esi
movq %rbx, %rdx
movq %r14, %rcx
callq 0x6148
movl 0x4(%rsp), %eax
testl %eax, %eax
jle 0x2b90
xorl %r13d, %r13d
movq (%r15,%r13,8), %rcx
cmpl $0x0, 0x58(%rcx)
je 0x2b85
movq 0x8(%rsp), %r9
movq %r15, %rdi
movl %r12d, %esi
movl %r13d, %edx
movq %rbx, %rcx
movq %r14, %r8
callq 0x66b0
movl 0x4(%rsp), %eax
incq %r13
movslq %eax, %rcx
cmpq %rcx, %r13
jl 0x2b5e
movq %r15, %rdi
movl %r12d, %esi
callq 0x14dbc
movq %r15, %rdi
movl %r12d, %esi
movq %rbx, %rdx
callq 0x15397
movl 0x4(%rsp), %esi
incq %r12
movslq %esi, %rax
cmpq %rax, %r12
jl 0x2b33
movq %r15, %rdi
movq %rbx, %rdx
movq %r14, %rcx
callq 0x1002c
cmpl $0x0, 0x1d7c(%r14)
je 0x2be3
movl 0x4(%rsp), %esi
movq %r15, %rdi
movq %r14, %rdx
callq 0x8430
testl %r12d, %r12d
je 0x2bff
movl %r12d, %r12d
xorl %r13d, %r13d
movq (%r15,%r13,8), %rdi
callq 0x2040
incq %r13
cmpq %r13, %r12
jne 0x2bee
testl %ebp, %ebp
jle 0x2c1a
movl %ebp, %r15d
xorl %r12d, %r12d
movq (%rbx,%r12,8), %rdi
callq 0x2040
incq %r12
cmpq %r12, %r15
jne 0x2c09
movq %r14, %rdi
callq 0x2040
xorl %eax, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq