// File: /workspace/github_c_makefile_star2_O2/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, %r12
movl %edi, %ebp
leaq 0x4(%rsp), %r13
andl $0x0, (%r13)
movl $0x320, %edi            # imm = 0x320
callq 0x50f4
movq %rax, %r15
movl $0x61a80, %edi          # imm = 0x61A80
callq 0x50f4
movq %rax, %rbx
movl $0x29e4, %edi           # imm = 0x29E4
callq 0x50f4
movq %rax, %r14
movq %r12, %rdi
movl %ebp, %esi
movq %rax, %rdx
callq 0x26ac
movq %r15, %rdi
movq %r13, %rsi
movq %r14, %rdx
callq 0x3248
testl %eax, %eax
je 0x2416
cmpl $0x0, 0x4(%rsp)
jne 0x2427
leaq 0x15c83(%rip), %rdi     # 0x180a0
movq %r14, %rsi
xorl %eax, %eax
callq 0x7c4c
xorl %r12d, %r12d
xorl %ebp, %ebp
movslq 0x4(%rsp), %rsi
cmpq %rsi, %r12
jge 0x2449
movq (%r15,%r12,8), %rdi
movq %r14, %rsi
callq 0x15ad0
addl %eax, %ebp
incq %r12
jmp 0x242c
testl %ebp, %ebp
jne 0x2466
movq (%r15), %rax
movq 0x48(%rax), %rsi
leaq 0x15c60(%rip), %rdi     # 0x180bb
xorl %eax, %eax
callq 0x7c4c
movl 0x4(%rsp), %esi
cmpl $0x0, 0x1d74(%r14)
je 0x247c
movq %r15, %rdi
callq 0x1503c
movl 0x4(%rsp), %esi
cmpl $0x0, 0x1d78(%r14)
je 0x2495
movq %r15, %rdi
movq %r14, %rdx
callq 0x157a9
movl 0x4(%rsp), %esi
movq %r15, %rdi
callq 0x7584
cmpl $0x0, 0x1d80(%r14)
je 0x24b6
movl 0x4(%rsp), %esi
movq %r15, %rdi
movq %r14, %rdx
callq 0x159a4
cmpl $0x0, 0x1d8c(%r14)
je 0x24cf
movl 0x4(%rsp), %esi
movq %r15, %rdi
movq %r14, %rdx
callq 0x17790
cmpl $0x0, 0x1d90(%r14)
je 0x24e8
movl 0x4(%rsp), %esi
movq %r15, %rdi
movq %r14, %rdx
callq 0x17ae0
cmpb $0x0, 0xc03(%r14)
je 0x2508
leaq 0xc03(%r14), %rdi
leaq 0x10(%rsp), %rsi
movq %r14, %rdx
callq 0x72e8
jmp 0x2515
movq %r14, %rdi
callq 0x7501
movq %rax, 0x10(%rsp)
cmpb $0x0, 0x1004(%r14)
je 0x2538
movq %r14, %rdi
addq $0x1004, %rdi           # imm = 0x1004
leaq 0x8(%rsp), %rsi
movq %r14, %rdx
callq 0x72e8
jmp 0x2545
movq %r14, %rdi
callq 0x7541
movq %rax, 0x8(%rsp)
xorl %r12d, %r12d
movslq 0x4(%rsp), %rax
cmpq %rax, %r12
jge 0x2560
movq (%r15,%r12,8), %rdi
callq 0x4b38
incq %r12
jmp 0x2548
movq %r15, %rdi
movl %r12d, %esi
movq %rbx, %rdx
movq %r14, %rcx
callq 0x8978
movl %eax, %r12d
testl %eax, %eax
jne 0x2589
leaq 0x15b52(%rip), %rdi     # 0x180d1
movq %r14, %rsi
xorl %eax, %eax
callq 0x7c4c
movq %rbx, %rdi
movl %r12d, %esi
callq 0x98eb
movl 0x4(%rsp), %esi
movq %r15, %rdi
movq %r14, %rdx
callq 0x75ce
cmpl $0x0, 0x1d68(%r14)
je 0x25bc
movl 0x4(%rsp), %esi
movq %r15, %rdi
movq %r14, %rdx
callq 0x14260
xorl %r13d, %r13d
movslq 0x4(%rsp), %rsi
cmpq %rsi, %r13
jge 0x263a
movq (%r15,%r13,8), %rax
cmpl $0x0, 0x58(%rax)
je 0x2635
movq 0x10(%rsp), %r8
movq %r15, %rdi
movl %r13d, %esi
movq %rbx, %rdx
movq %r14, %rcx
callq 0x5778
xorl %ebp, %ebp
movslq 0x4(%rsp), %rax
cmpq %rax, %rbp
jge 0x261c
movq (%r15,%rbp,8), %rax
cmpl $0x0, 0x58(%rax)
je 0x2617
movq 0x8(%rsp), %r9
movq %r15, %rdi
movl %r13d, %esi
movl %ebp, %edx
movq %rbx, %rcx
movq %r14, %r8
callq 0x5ca4
incq %rbp
jmp 0x25eb
movq %r15, %rdi
movl %r13d, %esi
callq 0x148c0
movq %r15, %rdi
movl %r13d, %esi
movq %rbx, %rdx
callq 0x14e6a
incq %r13
jmp 0x25bf
movq %r15, %rdi
movq %rbx, %rdx
movq %r14, %rcx
callq 0xff84
cmpl $0x0, 0x1d7c(%r14)
je 0x2661
movl 0x4(%rsp), %esi
movq %r15, %rdi
movq %r14, %rdx
callq 0x78f4
xorl %ebp, %ebp
cmpq %rbp, %r13
je 0x2676
movq (%r15,%rbp,8), %rdi
callq 0x2040
incq %rbp
jmp 0x2663
xorl %r15d, %r15d
testl %r12d, %r12d
cmovlel %r15d, %r12d
cmpq %r15, %r12
je 0x2693
movq (%rbx,%r15,8), %rdi
callq 0x2040
incq %r15
jmp 0x2680
movq %r14, %rdi
callq 0x2040
xorl %eax, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq