// File: /workspace/github_c_makefile_star2_O2/josch[P]stride/hydrbond.c
// Function: FindHydrogenBonds
int FindHydrogenBonds(CHAIN **Chain, int NChain, HBOND **HBond, COMMAND *Cmd)
{
  DONOR **Dnr;
  ACCEPTOR **Acc;
  BOOLEAN *BondedDonor, *BondedAcceptor;
  int NDnr=0, NAcc=0;
  int dc, ac, ccd, cca, cc, hc=0, i;
  void (*HBOND_Energy)();
  BUFFER Text;

  Dnr = (DONOR **)ckalloc(MAXDONOR*sizeof(DONOR *));
  Acc = (ACCEPTOR **)ckalloc(MAXACCEPTOR*sizeof(ACCEPTOR *));
  
  for( cc=0; cc<NChain; cc++ ) { 
    FindDnr(Chain[cc],Dnr,&NDnr,Cmd); 
    FindAcc(Chain[cc],Acc,&NAcc,Cmd);
  }

  BondedDonor    = (BOOLEAN *)ckalloc(NDnr*sizeof(BOOLEAN));
  BondedAcceptor = (BOOLEAN *)ckalloc(NAcc*sizeof(BOOLEAN));
  for( i=0; i<NDnr; i++ )
    BondedDonor[i] = NO;
  for( i=0; i<NAcc; i++ )
    BondedAcceptor[i] = NO;

  if( Cmd->EnergyType == 'D' ) 
    HBOND_Energy = DSSP_Energy; 
  else 
    HBOND_Energy = GRID_Energy;

  for( dc=0; dc<NDnr; dc++ ) {

    if( Dnr[dc]->Group != Peptide && !Cmd->SideChainHBond ) continue;
    
    for( ac=0; ac<NAcc; ac++ ) {
      
      if( abs(Acc[ac]->A_Res - Dnr[dc]->D_Res) < 2 && Acc[ac]->Chain->Id == Dnr[dc]->Chain->Id ) 
	continue;
      
       if( Acc[ac]->Group != Peptide && !Cmd->SideChainHBond ) continue;

      if( hc == MAXHYDRBOND ) 
	die("Number of hydrogen bonds exceeds current limit of %d in %s\n",
	    MAXHYDRBOND,Chain[0]->File);
      HBond[hc] = (HBOND *)ckalloc(sizeof(HBOND));

      HBond[hc]->ExistHydrBondRose = NO;
      HBond[hc]->ExistHydrBondBaker = NO;
      HBond[hc]->ExistPolarInter = NO;
      
      if( (HBond[hc]->AccDonDist = 
	   Dist(Dnr[dc]->Chain->Rsd[Dnr[dc]->D_Res]->Coord[Dnr[dc]->D_At],
		Acc[ac]->Chain->Rsd[Acc[ac]->A_Res]->Coord[Acc[ac]->A_At]) ) <=
	 Cmd->DistCutOff ) {
	
	
	if( Cmd->MainChainPolarInt && Dnr[dc]->Group == Peptide && 
	   Acc[ac]->Group == Peptide && Dnr[dc]->H != ERR) {
	  HBOND_Energy(Acc[ac]->Chain->Rsd[Acc[ac]->AA2_Res]->Coord[Acc[ac]->AA2_At],
		       Acc[ac]->Chain->Rsd[Acc[ac]->AA_Res]->Coord[Acc[ac]->AA_At],
		       Acc[ac]->Chain->Rsd[Acc[ac]->A_Res]->Coord[Acc[ac]->A_At],
		       Dnr[dc]->Chain->Rsd[Dnr[dc]->D_Res]->Coord[Dnr[dc]->H],
		       Dnr[dc]->Chain->Rsd[Dnr[dc]->D_Res]->Coord[Dnr[dc]->D_At],
		       Cmd,HBond[hc]);
	  
	  if( HBond[hc]->Energy < -10.0 &&
	     ( (Cmd->EnergyType == 'G' && fabs(HBond[hc]->Et) > Eps && 
		fabs(HBond[hc]->Ep) > Eps ) || Cmd->EnergyType != 'G' ) )
	    HBond[hc]->ExistPolarInter = YES;
	}

	if( Cmd->MainChainHBond && 
	    (HBond[hc]->OHDist = 
	     Dist(Dnr[dc]->Chain->Rsd[Dnr[dc]->D_Res]->Coord[Dnr[dc]->H],
		  Acc[ac]->Chain->Rsd[Acc[ac]->A_Res]->Coord[Acc[ac]->A_At])) <= 2.5 &&
	    (HBond[hc]->AngNHO = 
	     Ang(Dnr[dc]->Chain->Rsd[Dnr[dc]->D_Res]->Coord[Dnr[dc]->D_At],
		 Dnr[dc]->Chain->Rsd[Dnr[dc]->D_Res]->Coord[Dnr[dc]->H],
		 Acc[ac]->Chain->Rsd[Acc[ac]->A_Res]->Coord[Acc[ac]->A_At])) >= 90.0 &&
	     HBond[hc]->AngNHO <= 180.0 &&
	    (HBond[hc]->AngCOH = 
	     Ang(Acc[ac]->Chain->Rsd[Acc[ac]->AA_Res]->Coord[Acc[ac]->AA_At],
		 Acc[ac]->Chain->Rsd[Acc[ac]->A_Res]->Coord[Acc[ac]->A_At],
		 Dnr[dc]->Chain->Rsd[Dnr[dc]->D_Res]->Coord[Dnr[dc]->H])) >= 90.0 &&
	     
	     HBond[hc]->AngCOH <= 180.0 )
	  HBond[hc]->ExistHydrBondBaker = YES;

	if( Cmd->MainChainHBond && 
	   HBond[hc]->AccDonDist <= Dnr[dc]->HB_Radius+Acc[ac]->HB_Radius ) {
	  
	  HBond[hc]->AccAng = 
	    Ang(Dnr[dc]->Chain->Rsd[Dnr[dc]->D_Res]->Coord[Dnr[dc]->D_At],
		Acc[ac]->Chain->Rsd[Acc[ac]->A_Res]->Coord[Acc[ac]->A_At],
		Acc[ac]->Chain->Rsd[Acc[ac]->AA_Res]->Coord[Acc[ac]->AA_At]);
	  
	  if( ( ( Acc[ac]->Hybrid == Nsp2 || Acc[ac]->Hybrid == Osp2 ) && 
	       ( HBond[hc]->AccAng >= MINACCANG_SP2 && 
		HBond[hc]->AccAng <= MAXACCANG_SP2 ) ) || 
	     ( ( Acc[ac]->Hybrid == Ssp3 ||  Acc[ac]->Hybrid == Osp3 ) && 
	      ( HBond[hc]->AccAng >= MINACCANG_SP3 && 
	       HBond[hc]->AccAng <= MAXACCANG_SP3 ) ) ) {
	    
	    HBond[hc]->DonAng = 
	      Ang(Acc[ac]->Chain->Rsd[Acc[ac]->A_Res]->Coord[Acc[ac]->A_At],
		  Dnr[dc]->Chain->Rsd[Dnr[dc]->D_Res]->Coord[Dnr[dc]->D_At],
		  Dnr[dc]->Chain->Rsd[Dnr[dc]->DD_Res]->Coord[Dnr[dc]->DD_At]);
	    
	    if( ( ( Dnr[dc]->Hybrid == Nsp2 || Dnr[dc]->Hybrid == Osp2 ) && 
		 ( HBond[hc]->DonAng >= MINDONANG_SP2 && 
		  HBond[hc]->DonAng <= MAXDONANG_SP2 ) ) || 
	       ( ( Dnr[dc]->Hybrid == Nsp3 || Dnr[dc]->Hybrid == Osp3 ) && 
		( HBond[hc]->DonAng >= MINDONANG_SP3 &&
		 HBond[hc]->DonAng <= MAXDONANG_SP3 ) ) ) {
	      
	      if( Dnr[dc]->Hybrid == Nsp2 || Dnr[dc]->Hybrid == Osp2 ) {
		HBond[hc]->AccDonAng = 
		  fabs(Torsion(Dnr[dc]->Chain->Rsd[Dnr[dc]->DDI_Res]->Coord[Dnr[dc]->DDI_At],
			       Dnr[dc]->Chain->Rsd[Dnr[dc]->D_Res]->Coord[Dnr[dc]->D_At],
			       Dnr[dc]->Chain->Rsd[Dnr[dc]->DD_Res]->Coord[Dnr[dc]->DD_At],
			       Acc[ac]->Chain->Rsd[Acc[ac]->A_Res]->Coord[Acc[ac]->A_At]));
		
		if( HBond[hc]->AccDonAng > 90.0 && HBond[hc]->AccDonAng < 270.0 )
		  HBond[hc]->AccDonAng = fabs(180.0 - HBond[hc]->AccDonAng);
		
	      }
	      
	      if( Acc[ac]->Hybrid == Nsp2 || Acc[ac]->Hybrid == Osp2 ) {
		HBond[hc]->DonAccAng = 
		  fabs(Torsion(Dnr[dc]->Chain->Rsd[Dnr[dc]->D_Res]->Coord[Dnr[dc]->D_At],
			       Acc[ac]->Chain->Rsd[Acc[ac]->A_Res]->Coord[Acc[ac]->A_At],
			       Acc[ac]->Chain->Rsd[Acc[ac]->AA_Res]->Coord[Acc[ac]->AA_At],
			       Acc[ac]->Chain->Rsd[Acc[ac]->AA2_Res]->Coord[Acc[ac]->AA2_At]));
		
		if(HBond[hc]->DonAccAng > 90.0 && HBond[hc]->DonAccAng < 270.0)
		  HBond[hc]->DonAccAng = fabs(180.0 - HBond[hc]->DonAccAng);
		
	      }
	      
	      if( ( Dnr[dc]->Hybrid != Nsp2 && Dnr[dc]->Hybrid != Osp2 && 
		   Acc[ac]->Hybrid != Nsp2 && Acc[ac]->Hybrid != Osp2 ) ||
		 ( Acc[ac]->Hybrid != Nsp2 && Acc[ac]->Hybrid != Osp2 &&
		  ( Dnr[dc]->Hybrid == Nsp2 || Dnr[dc]->Hybrid == Osp2 ) &&
		  HBond[hc]->AccDonAng <= ACCDONANG ) ||
		 ( Dnr[dc]->Hybrid != Nsp2 && Dnr[dc]->Hybrid != Osp2 &&
		  ( Acc[ac]->Hybrid == Nsp2 || Acc[ac]->Hybrid == Osp2 ) &&
		  HBond[hc]->DonAccAng <= DONACCANG ) ||
		 ( ( Dnr[dc]->Hybrid == Nsp2 || Dnr[dc]->Hybrid == Osp2 ) && 
		  ( Acc[ac]->Hybrid == Nsp2 || Acc[ac]->Hybrid == Osp2 ) &&
		  HBond[hc]->AccDonAng <= ACCDONANG &&
		  HBond[hc]->DonAccAng <= DONACCANG ) )
		HBond[hc]->ExistHydrBondRose = YES;
	    }
	  }
	}
	
      }

      if( (HBond[hc]->ExistPolarInter && HBond[hc]->Energy < 0.0) 
	  || HBond[hc]->ExistHydrBondRose || HBond[hc]->ExistHydrBondBaker ) {
	HBond[hc]->Dnr = Dnr[dc];
	HBond[hc]->Acc = Acc[ac];
	BondedDonor[dc] = YES;
	BondedAcceptor[ac] = YES;
	if( (ccd = FindChain(Chain,NChain,Dnr[dc]->Chain->Id)) != ERR ) {
	  if( Chain[ccd]->Rsd[Dnr[dc]->D_Res]->Inv->NBondDnr < MAXRESDNR )
	    Chain[ccd]->Rsd[Dnr[dc]->D_Res]->Inv->
	      HBondDnr[Chain[ccd]->Rsd[Dnr[dc]->D_Res]->Inv->NBondDnr++] = hc;
	  else
	    fprintf(stderr,"Residue %s %s of chain %s%c is involved in %d hydrogen bonds (%d are allowed)\n",
		Chain[ccd]->Rsd[Dnr[dc]->D_Res]->ResType,
		Chain[ccd]->Rsd[Dnr[dc]->D_Res]->PDB_ResNumb,
		Chain[ccd]->File,SpaceToDash(Chain[ccd]->Id),
		Chain[ccd]->Rsd[Dnr[dc]->D_Res]->Inv->NBondDnr,MAXRESDNR-1);
	}
	if( (cca  = FindChain(Chain,NChain,Acc[ac]->Chain->Id)) != ERR ) {
	  if( Chain[cca]->Rsd[Acc[ac]->A_Res]->Inv->NBondAcc < MAXRESACC )
	    Chain[cca]->Rsd[Acc[ac]->A_Res]->Inv->
	      HBondAcc[Chain[cca]->Rsd[Acc[ac]->A_Res]->Inv->NBondAcc++] = hc;
	  else
	    fprintf(stderr,"Residue %s %s of chain %s%c is involved in %d hydrogen bonds (%d are allowed)\n",
		Chain[cca]->Rsd[Acc[ac]->A_Res]->ResType,
		Chain[cca]->Rsd[Acc[ac]->A_Res]->PDB_ResNumb,
		Chain[cca]->File,SpaceToDash(Chain[cca]->Id),
		Chain[cca]->Rsd[Acc[ac]->A_Res]->Inv->NBondAcc,MAXRESACC-1);
	}
	if( ccd != cca && ccd != ERR ) {
	  Chain[ccd]->Rsd[Dnr[dc]->D_Res]->Inv->InterchainHBonds = YES;
	  Chain[cca]->Rsd[Acc[ac]->A_Res]->Inv->InterchainHBonds = YES;
	  if( HBond[hc]->ExistHydrBondRose ) {
	    Chain[0]->NHydrBondInterchain++;
	    Chain[0]->NHydrBondTotal++;
	  }
	}
	else
	if( ccd == cca && ccd != ERR && HBond[hc]->ExistHydrBondRose ) {
	  Chain[ccd]->NHydrBond++;
	  Chain[0]->NHydrBondTotal++;
	}
	hc++;
      }
      else
	free(HBond[hc]);
    }
  }
  if( Cmd->Info )
    for( i=0; i<hc; i++ ) { 
      if( HBond[i]->Energy < 0.0 ) {
	sprintf(Text,"%3d ",i); 
	PrintHydrBond(Text,HBond[i]); 
      }
    } 
    
  for( i=0; i<NDnr; i++ )
    if( !BondedDonor[i] )
      free(Dnr[i]);
  for( i=0; i<NAcc; i++ )
    if( !BondedAcceptor[i] )
      free(Acc[i]);

  if( NDnr )
    free(BondedDonor);
  if( NAcc )
    free(BondedAcceptor);

  return(hc);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x4a8, %rsp            # imm = 0x4A8
movq %rcx, %rbp
movq %rdx, 0x48(%rsp)
movl %esi, %r15d
movq %rdi, 0x20(%rsp)
leaq 0x34(%rsp), %rax
andl $0x0, (%rax)
leaq 0x74(%rsp), %r13
andl $0x0, (%r13)
movl $0x27100, %edi          # imm = 0x27100
callq 0x50f4
movq %rax, %r12
movl $0x27100, %edi          # imm = 0x27100
callq 0x50f4
movq %rax, 0x28(%rsp)
xorl %ebx, %ebx
testl %r15d, %r15d
movl $0x0, %r14d
movl %r15d, 0x30(%rsp)
cmovgl %r15d, %r14d
movq 0x20(%rsp), %r15
cmpq %rbx, %r14
je 0x8a12
movq (%r15,%rbx,8), %rdi
movq %r12, %rsi
leaq 0x34(%rsp), %rdx
movq %rbp, %rcx
callq 0x7ce4
movq (%r15,%rbx,8), %rdi
movq 0x28(%rsp), %rsi
movq %r13, %rdx
movq %rbp, %rcx
callq 0x835f
incq %rbx
jmp 0x89e0
movslq 0x34(%rsp), %rbx
leaq (,%rbx,4), %rdi
callq 0x50f4
movq %rax, 0x38(%rsp)
movslq 0x74(%rsp), %rax
movq %rax, 0x50(%rsp)
leaq (,%rax,4), %rdi
callq 0x50f4
movq %rax, 0x40(%rsp)
xorl %eax, %eax
testl %ebx, %ebx
movl $0x0, %esi
movq %rbx, 0x80(%rsp)
cmovgl %ebx, %esi
movq 0x28(%rsp), %r15
movq 0x48(%rsp), %r14
movq 0x38(%rsp), %rcx
cmpq %rax, %rsi
je 0x8a76
andl $0x0, (%rcx,%rax,4)
incq %rax
jmp 0x8a68
xorl %eax, %eax
movq 0x50(%rsp), %rdx
testl %edx, %edx
movl $0x0, %ecx
cmovgl %edx, %ecx
movq 0x40(%rsp), %rdx
cmpq %rax, %rcx
je 0x8a9a
andl $0x0, (%rdx,%rax,4)
incq %rax
jmp 0x8a8c
cmpb $0x44, 0x1c07(%rbp)
movq %rsi, 0x90(%rsp)
jne 0x8ab4
leaq -0x3a6f(%rip), %rax     # 0x5043
jmp 0x8abb
leaq -0x3cff(%rip), %rax     # 0x4dbc
movq %rax, 0x78(%rsp)
xorl %r8d, %r8d
movl $0x0, 0x14(%rsp)
movq %r12, 0x68(%rsp)
movq %rbp, 0x88(%rsp)
cmpq 0x80(%rsp), %r8
jge 0x9600
movq (%r12,%r8,8), %rax
cmpl $0x0, 0x28(%rax)
je 0x8afd
cmpl $0x0, 0x1d48(%rbp)
je 0x95f8
xorl %ebx, %ebx
movq %r8, 0x8(%rsp)
cmpq 0x50(%rsp), %rbx
jge 0x95f8
movq (%r15,%rbx,8), %rax
movl 0x8(%rax), %edx
movq (%r12,%r8,8), %rcx
subl 0x8(%rcx), %edx
movl %edx, %esi
negl %esi
cmovsl %edx, %esi
cmpl $0x1, %esi
movq 0x20(%rsp), %r13
ja 0x8b40
movq (%rax), %rdx
movb 0x40(%rdx), %dl
movq (%rcx), %rcx
cmpb 0x40(%rcx), %dl
je 0x8fbe
cmpl $0x0, 0x24(%rax)
je 0x8b53
cmpl $0x0, 0x1d48(%rbp)
je 0x8fbe
movq %r14, %rbp
cmpl $0xc350, 0x14(%rsp)     # imm = 0xC350
jne 0x8b7b
movq (%r13), %rax
movq 0x48(%rax), %rdx
leaq 0x10400(%rip), %rdi     # 0x18f6f
movl $0xc350, %esi           # imm = 0xC350
xorl %eax, %eax
callq 0x7c4c
pushq $0x58
popq %rdi
callq 0x50f4
movslq 0x14(%rsp), %r14
movq %rax, (%rbp,%r14,8)
andl $0x0, 0x18(%rax)
andq $0x0, 0x10(%rax)
movq 0x8(%rsp), %rax
movq (%r12,%rax,8), %rax
movq (%rax), %rcx
movq 0x68(%rcx), %rcx
movslq 0x8(%rax), %rdx
movslq 0x14(%rax), %rax
imulq $0xc, %rax, %rdi
addq (%rcx,%rdx,8), %rdi
movl $0x188, %r8d            # imm = 0x188
addq %r8, %rdi
movq (%r15,%rbx,8), %rax
movq (%rax), %rcx
movq 0x68(%rcx), %rcx
movslq 0x8(%rax), %rdx
movslq 0x14(%rax), %rax
imulq $0xc, %rax, %rsi
addq (%rcx,%rdx,8), %rsi
addq %r8, %rsi
callq 0x3abc
movq %r14, 0x18(%rsp)
movq (%rbp,%r14,8), %r10
movq %rbp, %r14
movss %xmm0, 0x38(%r10)
movq 0x88(%rsp), %rbp
movss 0x1d0c(%rbp), %xmm1
ucomiss %xmm0, %xmm1
jae 0x8c14
movq 0x8(%rsp), %r8
jmp 0x8de8
cmpl $0x0, 0x1d50(%rbp)
je 0x8d40
movq 0x8(%rsp), %r8
movq (%r12,%r8,8), %rax
cmpl $0x0, 0x28(%rax)
jne 0x8d45
movq (%r15,%rbx,8), %rdx
cmpl $0x0, 0x24(%rdx)
jne 0x8d45
movslq 0x20(%rax), %rcx
cmpq $-0x1, %rcx
je 0x8d45
movq (%rdx), %rsi
movq 0x68(%rsi), %r8
movslq 0x10(%rdx), %rsi
movslq 0x1c(%rdx), %rdi
imulq $0xc, %rdi, %rdi
addq (%r8,%rsi,8), %rdi
movl $0x188, %r11d           # imm = 0x188
addq %r11, %rdi
movslq 0xc(%rdx), %r9
movslq 0x18(%rdx), %rsi
imulq $0xc, %rsi, %rsi
addq (%r8,%r9,8), %rsi
addq %r11, %rsi
movslq 0x8(%rdx), %r9
movslq 0x14(%rdx), %rdx
imulq $0xc, %rdx, %rdx
addq (%r8,%r9,8), %rdx
addq %r11, %rdx
movq (%rax), %r8
movq 0x68(%r8), %r8
movslq 0x8(%rax), %r9
movq (%r8,%r9,8), %r8
imulq $0xc, %rcx, %rcx
addq %r8, %rcx
addq $0x188, %rcx            # imm = 0x188
movslq 0x14(%rax), %rax
imulq $0xc, %rax, %rax
addq %rax, %r8
addq $0x188, %r8             # imm = 0x188
subq $0x8, %rsp
movq %rbp, %r9
xorl %eax, %eax
pushq %r10
callq *0x88(%rsp)
addq $0x10, %rsp
movq 0x18(%rsp), %rax
movq (%r14,%rax,8), %r10
movss 0x101ac(%rip), %xmm0    # 0x18e98
ucomiss 0x1c(%r10), %xmm0
jbe 0x8d40
cmpb $0x47, 0x1c07(%rbp)
movq 0x8(%rsp), %r8
jne 0x8d36
movss 0x24(%r10), %xmm0
movaps 0xfbd2(%rip), %xmm1     # 0x188e0
andps %xmm1, %xmm0
cvtss2sd %xmm0, %xmm0
movsd 0xfb43(%rip), %xmm2     # 0x18860
ucomisd %xmm2, %xmm0
jbe 0x8d45
movss 0x28(%r10), %xmm0
andps %xmm1, %xmm0
cvtss2sd %xmm0, %xmm0
ucomisd %xmm2, %xmm0
jbe 0x8d45
movl $0x1, 0x10(%r10)
jmp 0x8d45
movq 0x8(%rsp), %r8
cmpl $0x0, 0x1d4c(%rbp)
je 0x8de8
movq (%r12,%r8,8), %rax
movq (%rax), %rcx
movq 0x68(%rcx), %rcx
movslq 0x8(%rax), %rdx
movslq 0x20(%rax), %rax
imulq $0xc, %rax, %rdi
addq (%rcx,%rdx,8), %rdi
movl $0x188, %r8d            # imm = 0x188
addq %r8, %rdi
movq (%r15,%rbx,8), %rax
movq (%rax), %rcx
movq 0x68(%rcx), %rcx
movslq 0x8(%rax), %rdx
movslq 0x14(%rax), %rax
imulq $0xc, %rax, %rsi
addq (%rcx,%rdx,8), %rsi
addq %r8, %rsi
callq 0x3abc
movq 0x18(%rsp), %rax
movq (%r14,%rax,8), %r10
movss %xmm0, 0x3c(%r10)
movss 0xfb50(%rip), %xmm1     # 0x18900
ucomiss %xmm0, %xmm1
jae 0x8fc6
cmpl $0x0, 0x1d4c(%rbp)
je 0x8c0a
movq 0x8(%rsp), %r8
movq (%r12,%r8,8), %rcx
movss 0x2c(%rcx), %xmm0
movq (%r15,%rbx,8), %rax
addss 0x28(%rax), %xmm0
ucomiss 0x38(%r10), %xmm0
jae 0x90f2
cmpl $0x0, 0x10(%r10)
je 0x8df9
xorps %xmm0, %xmm0
ucomiss 0x1c(%r10), %xmm0
ja 0x8e0b
cmpl $0x0, 0x14(%r10)
jne 0x8e0b
cmpl $0x0, 0x18(%r10)
je 0x9448
movq (%r12,%r8,8), %rax
movq %rax, (%r10)
movq (%r15,%rbx,8), %rax
movq 0x18(%rsp), %rcx
movq (%r14,%rcx,8), %rcx
movq %rax, 0x8(%rcx)
movq 0x38(%rsp), %rax
pushq $0x1
popq %rcx
movl %ecx, (%rax,%r8,4)
movq 0x40(%rsp), %rax
movl %ecx, (%rax,%rbx,4)
movq (%r12,%r8,8), %rax
movq (%rax), %rax
movsbl 0x40(%rax), %edx
movq %r13, %rdi
movl 0x30(%rsp), %esi
callq 0x4847
movl %eax, %ebp
movslq %eax, %r14
cmpl $-0x1, %eax
je 0x8e99
movq (%r13,%r14,8), %rax
movq 0x68(%rax), %rcx
movq 0x8(%rsp), %rdx
movq (%r12,%rdx,8), %rdx
movslq 0x8(%rdx), %rdx
movq (%rcx,%rdx,8), %r13
movq 0x770(%r13), %rcx
movslq 0x30(%rcx), %rdx
cmpq $0x5, %rdx
jg 0x945a
leal 0x1(%rdx), %eax
movl %eax, 0x30(%rcx)
movl 0x14(%rsp), %eax
movl %eax, (%rcx,%rdx,4)
movq 0x20(%rsp), %r13
movq (%r15,%rbx,8), %rax
movq (%rax), %rax
movsbl 0x40(%rax), %edx
movq %r13, %rdi
movl 0x30(%rsp), %esi
callq 0x4847
movl %eax, %r13d
movslq %eax, %r12
cmpl $-0x1, %eax
movq 0x8(%rsp), %r8
je 0x8f01
movq 0x20(%rsp), %rax
movq (%rax,%r12,8), %rax
movq 0x68(%rax), %rcx
movq (%r15,%rbx,8), %rdx
movslq 0x8(%rdx), %rdx
movq (%rcx,%rdx,8), %r15
movq 0x770(%r15), %rcx
movslq 0x34(%rcx), %rdx
cmpq $0x5, %rdx
jg 0x94e1
leal 0x1(%rdx), %eax
movl %eax, 0x34(%rcx)
movl 0x14(%rsp), %eax
movl %eax, 0x18(%rcx,%rdx,4)
movq 0x28(%rsp), %r15
cmpl $-0x1, %ebp
je 0x8f78
cmpl %r13d, %ebp
je 0x8f78
movq 0x20(%rsp), %rsi
movq (%rsi,%r14,8), %rax
movq 0x68(%rax), %rax
movq 0x68(%rsp), %rdx
movq (%rdx,%r8,8), %rcx
movslq 0x8(%rcx), %rcx
movq (%rax,%rcx,8), %rax
movq 0x770(%rax), %rax
pushq $0x1
popq %rdi
movl %edi, 0x38(%rax)
movq (%rsi,%r12,8), %rax
movq %rdx, %r12
movq 0x68(%rax), %rax
movq (%r15,%rbx,8), %rcx
movslq 0x8(%rcx), %rcx
movq (%rax,%rcx,8), %rax
movq 0x770(%rax), %rax
movl %edi, 0x38(%rax)
movq 0x48(%rsp), %rax
movq 0x18(%rsp), %rcx
movq (%rax,%rcx,8), %rax
cmpl $0x0, 0x14(%rax)
je 0x8fad
movq 0x20(%rsp), %rax
movq (%rax), %rax
incl 0x34(%rax)
jmp 0x8faa
cmpl $-0x1, %ebp
movq 0x68(%rsp), %r12
je 0x8fad
cmpl %r13d, %ebp
jne 0x8fad
movq 0x48(%rsp), %rax
movq 0x18(%rsp), %rcx
movq (%rax,%rcx,8), %rax
cmpl $0x0, 0x14(%rax)
je 0x8fad
movq 0x20(%rsp), %rcx
movq (%rcx,%r14,8), %rax
incl 0x30(%rax)
movq (%rcx), %rax
incl 0x38(%rax)
incl 0x14(%rsp)
movq 0x48(%rsp), %r14
movq 0x88(%rsp), %rbp
incq %rbx
jmp 0x8b04
movq 0x8(%rsp), %rax
movq (%r12,%rax,8), %rax
movq (%rax), %rcx
movq 0x68(%rcx), %rcx
movslq 0x8(%rax), %rdx
movq (%rcx,%rdx,8), %rcx
movslq 0x14(%rax), %rdx
imulq $0xc, %rdx, %rdx
leaq (%rcx,%rdx), %rdi
addq $0x188, %rdi            # imm = 0x188
movslq 0x20(%rax), %rax
imulq $0xc, %rax, %rax
leaq (%rcx,%rax), %rsi
addq $0x188, %rsi            # imm = 0x188
movq (%r15,%rbx,8), %rax
movq (%rax), %rcx
movq 0x68(%rcx), %rcx
movslq 0x8(%rax), %r8
movslq 0x14(%rax), %rax
imulq $0xc, %rax, %rdx
addq (%rcx,%r8,8), %rdx
movl $0x188, %eax            # imm = 0x188
addq %rax, %rdx
callq 0x3aef
movq 0x18(%rsp), %rax
movq (%r14,%rax,8), %r10
movss %xmm0, 0x40(%r10)
ucomiss 0xfac6(%rip), %xmm0     # 0x18b08
jb 0x8db9
movss 0xfab4(%rip), %xmm1     # 0x18b04
ucomiss %xmm0, %xmm1
jb 0x8db9
movq (%r15,%rbx,8), %rax
movq (%rax), %rcx
movq 0x68(%rcx), %rcx
movslq 0xc(%rax), %rdx
movslq 0x18(%rax), %rsi
imulq $0xc, %rsi, %rdi
addq (%rcx,%rdx,8), %rdi
movl $0x188, %r9d            # imm = 0x188
addq %r9, %rdi
movslq 0x8(%rax), %rdx
movslq 0x14(%rax), %rax
imulq $0xc, %rax, %rsi
addq (%rcx,%rdx,8), %rsi
addq %r9, %rsi
movq 0x8(%rsp), %rax
movq (%r12,%rax,8), %rax
movq (%rax), %rcx
movq 0x68(%rcx), %rcx
movslq 0x8(%rax), %r8
movslq 0x20(%rax), %rax
imulq $0xc, %rax, %rdx
addq (%rcx,%r8,8), %rdx
addq %r9, %rdx
callq 0x3aef
movq 0x18(%rsp), %rax
movq (%r14,%rax,8), %r10
movss %xmm0, 0x44(%r10)
ucomiss 0xfa3a(%rip), %xmm0     # 0x18b08
jb 0x8db9
movss 0xfa28(%rip), %xmm1     # 0x18b04
ucomiss %xmm0, %xmm1
jb 0x8db9
movl $0x1, 0x18(%r10)
jmp 0x8db9
movq (%rcx), %rdx
movq 0x68(%rdx), %rdx
movslq 0x8(%rcx), %rsi
movslq 0x14(%rcx), %rcx
imulq $0xc, %rcx, %rdi
addq (%rdx,%rsi,8), %rdi
movq (%rax), %rcx
movq 0x68(%rcx), %rcx
movslq 0x8(%rax), %rdx
movslq 0x14(%rax), %rsi
imulq $0xc, %rsi, %rsi
addq (%rcx,%rdx,8), %rsi
movl $0x188, %r9d            # imm = 0x188
addq %r9, %rdi
addq %r9, %rsi
movslq 0xc(%rax), %r8
movslq 0x18(%rax), %rax
imulq $0xc, %rax, %rdx
addq (%rcx,%r8,8), %rdx
addq %r9, %rdx
callq 0x3aef
movq 0x18(%rsp), %rax
movq (%r14,%rax,8), %r10
movss %xmm0, 0x48(%r10)
movq (%r15,%rbx,8), %rax
movl 0x20(%rax), %ecx
testl $0xfffffffd, %ecx       # imm = 0xFFFFFFFD
jne 0x9577
ucomiss 0xf99b(%rip), %xmm0     # 0x18b08
jb 0x8c0a
movss 0xf989(%rip), %xmm1     # 0x18b04
ucomiss %xmm0, %xmm1
movq 0x8(%rsp), %r8
jb 0x8de8
movq (%rax), %rcx
movq 0x68(%rcx), %rcx
movslq 0x8(%rax), %rdx
movslq 0x14(%rax), %rax
imulq $0xc, %rax, %rdi
addq (%rcx,%rdx,8), %rdi
movq (%r12,%r8,8), %rax
movq (%rax), %rcx
movq 0x68(%rcx), %rcx
movslq 0x8(%rax), %rdx
movslq 0x14(%rax), %rsi
imulq $0xc, %rsi, %rsi
addq (%rcx,%rdx,8), %rsi
movl $0x188, %r9d            # imm = 0x188
addq %r9, %rdi
addq %r9, %rsi
movslq 0xc(%rax), %r8
movslq 0x18(%rax), %rax
imulq $0xc, %rax, %rdx
addq (%rcx,%r8,8), %rdx
addq %r9, %rdx
callq 0x3aef
movq 0x8(%rsp), %r8
movq 0x18(%rsp), %rax
movq (%r14,%rax,8), %r10
movss %xmm0, 0x4c(%r10)
movq (%r12,%r8,8), %rax
movl 0x24(%rax), %ecx
cmpq $0x3, %rcx
ja 0x8de8
leaq 0xfcf9(%rip), %rsi      # 0x18f04
movslq (%rsi,%rcx,4), %rdx
addq %rsi, %rdx
jmpq *%rdx
ucomiss 0xf8ed(%rip), %xmm0     # 0x18b08
jb 0x922a
movss 0xf8df(%rip), %xmm1     # 0x18b04
ucomiss %xmm0, %xmm1
jae 0x9251
cmpl $0x1, %ecx
jne 0x8de8
ucomiss 0xf8ce(%rip), %xmm0     # 0x18b08
jb 0x8de8
movss 0xf8bc(%rip), %xmm1     # 0x18b04
ucomiss %xmm0, %xmm1
jb 0x8de8
testl $0xfffffffd, %ecx       # imm = 0xFFFFFFFD
jne 0x9310
movq (%rax), %rcx
movq 0x68(%rcx), %rcx
movslq 0x10(%rax), %rdx
movslq 0x1c(%rax), %rsi
imulq $0xc, %rsi, %rdi
addq (%rcx,%rdx,8), %rdi
movl $0x188, %r10d           # imm = 0x188
addq %r10, %rdi
movslq 0x8(%rax), %rdx
movslq 0x14(%rax), %rsi
imulq $0xc, %rsi, %rsi
addq (%rcx,%rdx,8), %rsi
addq %r10, %rsi
movslq 0xc(%rax), %r8
movslq 0x18(%rax), %rax
imulq $0xc, %rax, %rdx
addq (%rcx,%r8,8), %rdx
addq %r10, %rdx
movq (%r15,%rbx,8), %rax
movq (%rax), %rcx
movq 0x68(%rcx), %r8
movslq 0x8(%rax), %r9
movslq 0x14(%rax), %rax
imulq $0xc, %rax, %rcx
addq (%r8,%r9,8), %rcx
addq %r10, %rcx
callq 0x3894
andps 0xf613(%rip), %xmm0     # 0x188e0
movq 0x18(%rsp), %rax
movq (%r14,%rax,8), %r10
movss %xmm0, 0x50(%r10)
ucomiss 0xf825(%rip), %xmm0     # 0x18b08
jbe 0x930b
movss 0xf823(%rip), %xmm1     # 0x18b10
ucomiss %xmm0, %xmm1
jbe 0x930b
movss 0xf80a(%rip), %xmm1     # 0x18b04
subss %xmm0, %xmm1
andps 0xf5db(%rip), %xmm1     # 0x188e0
movss %xmm1, 0x50(%r10)
movq 0x8(%rsp), %r8
movq (%r15,%rbx,8), %rax
testl $0xfffffffd, 0x20(%rax) # imm = 0xFFFFFFFD
jne 0x93d4
movq (%r12,%r8,8), %rcx
movq (%rcx), %rdx
movq 0x68(%rdx), %rdx
movslq 0x8(%rcx), %rsi
movslq 0x14(%rcx), %rcx
imulq $0xc, %rcx, %rdi
addq (%rdx,%rsi,8), %rdi
movl $0x188, %r10d           # imm = 0x188
addq %r10, %rdi
movq (%rax), %rcx
movq 0x68(%rcx), %r8
movslq 0x8(%rax), %rcx
movslq 0x14(%rax), %rdx
imulq $0xc, %rdx, %rsi
addq (%r8,%rcx,8), %rsi
movslq 0xc(%rax), %rcx
movslq 0x18(%rax), %rdx
imulq $0xc, %rdx, %rdx
addq (%r8,%rcx,8), %rdx
addq %r10, %rsi
addq %r10, %rdx
movslq 0x10(%rax), %r9
movslq 0x1c(%rax), %rax
imulq $0xc, %rax, %rcx
addq (%r8,%r9,8), %rcx
addq %r10, %rcx
callq 0x3894
andps 0xf54f(%rip), %xmm0     # 0x188e0
movq 0x18(%rsp), %rax
movq (%r14,%rax,8), %r10
movss %xmm0, 0x54(%r10)
ucomiss 0xf761(%rip), %xmm0     # 0x18b08
jbe 0x93cf
movss 0xf75f(%rip), %xmm1     # 0x18b10
ucomiss %xmm0, %xmm1
jbe 0x93cf
movss 0xf746(%rip), %xmm1     # 0x18b04
subss %xmm0, %xmm1
andps 0xf517(%rip), %xmm1     # 0x188e0
movss %xmm1, 0x54(%r10)
movq 0x8(%rsp), %r8
movq (%r12,%r8,8), %rax
movl 0x24(%rax), %eax
testl $0xfffffffd, %eax       # imm = 0xFFFFFFFD
je 0x93f3
movq (%r15,%rbx,8), %rcx
testl $0xfffffffd, 0x20(%rcx) # imm = 0xFFFFFFFD
jne 0x95eb
movq (%r15,%rbx,8), %rcx
movl 0x20(%rcx), %ecx
testl $0xfffffffd, %ecx       # imm = 0xFFFFFFFD
jne 0x95ab
testl $0xfffffffd, %eax       # imm = 0xFFFFFFFD
jne 0x95c7
testl $0xfffffffd, %ecx       # imm = 0xFFFFFFFD
jne 0x8de8
movss 0xfa77(%rip), %xmm0     # 0x18e9c
ucomiss 0x50(%r10), %xmm0
jb 0x8de8
movss 0xf6d0(%rip), %xmm0     # 0x18b08
ucomiss 0x54(%r10), %xmm0
jb 0x8de8
jmp 0x95eb
movq %r10, %rdi
callq 0x2040
movq 0x8(%rsp), %r8
jmp 0x8fbe
movq 0x16b8f(%rip), %rcx     # 0x1fff0
movq (%rcx), %r15
leaq 0xa(%r13), %rcx
movq %rcx, 0x60(%rsp)
addq $0x4, %r13
movq 0x48(%rax), %rcx
movq %rcx, 0x58(%rsp)
movsbl 0x40(%rax), %edi
callq 0x4969
movsbl %al, %r9d
movq 0x20(%rsp), %r8
movq (%r8,%r14,8), %rax
movq 0x68(%rax), %rax
movq 0x8(%rsp), %rcx
movq (%r12,%rcx,8), %rcx
movslq 0x8(%rcx), %rcx
movq (%rax,%rcx,8), %rax
movq 0x770(%rax), %rax
movl 0x30(%rax), %r10d
movq %r15, %rdi
movq 0x28(%rsp), %r15
leaq 0xfaec(%rip), %rsi      # 0x18fab
movq 0x60(%rsp), %rdx
movq %r13, %rcx
movq %r8, %r13
movq 0x58(%rsp), %r8
xorl %eax, %eax
pushq $0x5
pushq %r10
callq 0x2160
popq %rcx
popq %rdx
jmp 0x8e99
movq 0x16b08(%rip), %rcx     # 0x1fff0
movq (%rcx), %rcx
movq %rcx, 0x58(%rsp)
leaq 0xa(%r15), %rcx
movq %rcx, 0x60(%rsp)
addq $0x4, %r15
movq 0x48(%rax), %rcx
movq %rcx, 0x98(%rsp)
movsbl 0x40(%rax), %edi
callq 0x4969
movsbl %al, %r9d
movq 0x20(%rsp), %rax
movq (%rax,%r12,8), %rax
movq 0x68(%rax), %rax
movq 0x28(%rsp), %r8
movq (%r8,%rbx,8), %rcx
movslq 0x8(%rcx), %rcx
movq (%rax,%rcx,8), %rax
movq 0x770(%rax), %rax
movl 0x34(%rax), %r10d
movq 0x58(%rsp), %rdi
leaq 0xfa60(%rip), %rsi      # 0x18fab
movq 0x60(%rsp), %rdx
movq %r15, %rcx
movq %r8, %r15
movq 0x98(%rsp), %r8
xorl %eax, %eax
pushq $0x5
pushq %r10
callq 0x2160
movq 0x18(%rsp), %r8
addq $0x10, %rsp
jmp 0x8f01
addl $-0x3, %ecx
cmpl $0x1, %ecx
ja 0x8c0a
ucomiss 0xf912(%rip), %xmm0     # 0x18e9c
movq 0x8(%rsp), %r8
jb 0x8de8
movss 0xf567(%rip), %xmm1     # 0x18b04
ucomiss %xmm0, %xmm1
jae 0x9189
jmp 0x8de8
testl $0xfffffffd, %eax       # imm = 0xFFFFFFFD
jne 0x95c7
movss 0xf8e2(%rip), %xmm0     # 0x18e9c
ucomiss 0x50(%r10), %xmm0
jb 0x9406
jmp 0x95eb
testl $0xfffffffd, %ecx       # imm = 0xFFFFFFFD
jne 0x95de
movss 0xf531(%rip), %xmm0     # 0x18b08
ucomiss 0x54(%r10), %xmm0
jae 0x95eb
testl %eax, %eax
jne 0x8de8
jmp 0x9411
movl $0x1, 0x14(%r10)
jmp 0x8de8
incq %r8
jmp 0x8ad8
cmpl $0x0, 0x1d60(%rbp)
je 0x965d
movl 0x14(%rsp), %eax
testl %eax, %eax
movl $0x0, %ebx
cmovgl %eax, %ebx
xorps %xmm0, %xmm0
leaq 0xf9d9(%rip), %r12      # 0x18ffa
leaq 0xa0(%rsp), %r13
xorl %ebp, %ebp
cmpq %rbp, %rbx
je 0x965d
movq (%r14,%rbp,8), %rax
ucomiss 0x1c(%rax), %xmm0
jbe 0x9658
movq %r13, %rdi
movq %r12, %rsi
movl %ebp, %edx
xorl %eax, %eax
callq 0x2230
movq (%r14,%rbp,8), %rsi
movq %r13, %rdi
callq 0x96f6
xorps %xmm0, %xmm0
incq %rbp
jmp 0x962b
xorl %ebx, %ebx
movq 0x68(%rsp), %r14
movq 0x90(%rsp), %r12
cmpq %rbx, %r12
je 0x968a
movq 0x38(%rsp), %rax
cmpl $0x0, (%rax,%rbx,4)
jne 0x9685
movq (%r14,%rbx,8), %rdi
callq 0x2040
incq %rbx
jmp 0x966c
xorl %ebx, %ebx
movq 0x50(%rsp), %rax
testl %eax, %eax
movl $0x0, %r14d
cmovgl %eax, %r14d
cmpq %rbx, %r14
je 0x96bb
movq 0x40(%rsp), %rax
cmpl $0x0, (%rax,%rbx,4)
jne 0x96b6
movq (%r15,%rbx,8), %rdi
callq 0x2040
incq %rbx
jmp 0x969d
cmpl $0x0, 0x80(%rsp)
je 0x96cf
movq 0x38(%rsp), %rdi
callq 0x2040
cmpl $0x0, 0x50(%rsp)
je 0x96e0
movq 0x40(%rsp), %rdi
callq 0x2040
movl 0x14(%rsp), %eax
addq $0x4a8, %rsp            # imm = 0x4A8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq