// File: /workspace/github_c_makefile_star2_O1/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 $0x488, %rsp            # imm = 0x488
movq %rcx, %rbx
movq %rdx, 0x40(%rsp)
movl %esi, %r15d
movq %rdi, %r14
xorl %eax, %eax
movl %eax, 0x2c(%rsp)
movl %eax, 0x1c(%rsp)
movl $0x27100, %edi          # imm = 0x27100
callq 0x595c
movq %rax, %rbp
movl $0x27100, %edi          # imm = 0x27100
callq 0x595c
movq %rax, %r13
movl %r15d, 0x3c(%rsp)
testl %r15d, %r15d
jle 0x977f
movl 0x3c(%rsp), %r15d
xorl %r12d, %r12d
movq (%r14,%r12,8), %rdi
movq %rbp, %rsi
leaq 0x2c(%rsp), %rdx
movq %rbx, %rcx
callq 0x899c
movq (%r14,%r12,8), %rdi
movq %r13, %rsi
leaq 0x1c(%rsp), %rdx
movq %rbx, %rcx
callq 0x907a
incq %r12
cmpq %r12, %r15
jne 0x974f
movq %r14, 0x30(%rsp)
movq %rbx, 0x70(%rsp)
movq %rbp, 0x60(%rsp)
movq %r13, 0x58(%rsp)
movslq 0x2c(%rsp), %r12
leaq (,%r12,4), %r14
movq %r14, %rdi
callq 0x595c
movq %rax, 0x48(%rsp)
movslq 0x1c(%rsp), %r15
leaq (,%r15,4), %rbx
movq %rbx, %rdi
callq 0x595c
movq %rax, 0x50(%rsp)
testq %r12, %r12
jle 0x97db
movq 0x48(%rsp), %rdi
xorl %esi, %esi
movq %r14, %rdx
callq 0x20f0
testl %r15d, %r15d
jle 0x97ef
movq 0x50(%rsp), %rdi
xorl %esi, %esi
movq %rbx, %rdx
callq 0x20f0
movq 0x70(%rsp), %rbx
cmpb $0x44, 0x1c07(%rbx)
movq 0x58(%rsp), %r14
movq 0x60(%rsp), %rcx
jne 0x9810
leaq -0x3f66(%rip), %rax     # 0x58a8
jmp 0x9817
leaq -0x420f(%rip), %rax     # 0x5608
movq %rax, 0x68(%rsp)
movl 0x2c(%rsp), %r12d
testl %r12d, %r12d
jle 0xa292
movl $0x188, %r13d           # imm = 0x188
xorl %edx, %edx
xorl %r8d, %r8d
movq (%rcx,%rdx,8), %rax
cmpl $0x0, 0x28(%rax)
movq %rdx, 0x78(%rsp)
je 0x9862
cmpl $0x0, 0x1d48(%rbx)
movq 0x40(%rsp), %r12
je 0xa270
cmpl $0x0, 0x1c(%rsp)
jg 0x9872
jmp 0xa270
cmpl $0x0, 0x1c(%rsp)
movq 0x40(%rsp), %r12
jle 0xa270
leaq (%rcx,%rdx,8), %rax
movq %rax, 0x10(%rsp)
xorl %r15d, %r15d
movq (%r14), %rax
movl 0x8(%rax), %edx
movq 0x10(%rsp), %rcx
movq (%rcx), %rcx
subl 0x8(%rcx), %edx
movl %edx, %esi
negl %esi
cmovsl %edx, %esi
cmpl $0x1, %esi
ja 0x98ad
movq (%rax), %rdx
movb 0x40(%rdx), %dl
movq (%rcx), %rcx
cmpb 0x40(%rcx), %dl
je 0xa1c8
cmpl $0x0, 0x24(%rax)
je 0x98c0
cmpl $0x0, 0x1d48(%rbx)
je 0xa1c8
movl %r8d, 0xc(%rsp)
cmpl $0xc350, %r8d           # imm = 0xC350
jne 0x98ed
movq 0x30(%rsp), %rax
movq (%rax), %rax
movq 0x48(%rax), %rdx
leaq 0x106b6(%rip), %rdi     # 0x19f97
movl $0xc350, %esi           # imm = 0xC350
xorl %eax, %eax
callq 0x8900
movl $0x58, %edi
callq 0x595c
movslq 0xc(%rsp), %rbp
movq %rax, (%r12,%rbp,8)
movl $0x0, 0x18(%rax)
movq $0x0, 0x10(%rax)
movq 0x10(%rsp), %rax
movq (%rax), %rax
movq (%rax), %rcx
movq 0x68(%rcx), %rcx
movslq 0x8(%rax), %rdx
movslq 0x14(%rax), %rax
leaq (%rax,%rax,2), %rdi
shlq $0x2, %rdi
addq (%rcx,%rdx,8), %rdi
addq %r13, %rdi
movq (%r14), %rax
movq (%rax), %rcx
movq 0x68(%rcx), %rcx
movslq 0x8(%rax), %rdx
movslq 0x14(%rax), %rax
leaq (%rax,%rax,2), %rsi
shlq $0x2, %rsi
addq (%rcx,%rdx,8), %rsi
addq %r13, %rsi
callq 0x40d5
movq %rbp, %rsi
movq (%r12,%rbp,8), %rax
movss %xmm0, 0x38(%rax)
movss 0x1d0c(%rbx), %xmm1
ucomiss %xmm0, %xmm1
movq %rbp, 0x20(%rsp)
jb 0xa002
cmpl $0x0, 0x1d50(%rbx)
je 0x99a2
movq 0x10(%rsp), %rcx
movq (%rcx), %r8
cmpl $0x0, 0x28(%r8)
jne 0x99a2
movq (%r14), %rdx
cmpl $0x0, 0x24(%rdx)
je 0x9ec4
cmpl $0x0, 0x1d4c(%rbx)
je 0x9a16
movq 0x10(%rsp), %rax
movq (%rax), %rax
movq (%rax), %rcx
movq 0x68(%rcx), %rcx
movslq 0x8(%rax), %rdx
movslq 0x20(%rax), %rax
leaq (%rax,%rax,2), %rdi
shlq $0x2, %rdi
addq (%rcx,%rdx,8), %rdi
addq %r13, %rdi
movq (%r14), %rax
movq (%rax), %rcx
movq 0x68(%rcx), %rcx
movslq 0x8(%rax), %rdx
movslq 0x14(%rax), %rax
leaq (%rax,%rax,2), %rsi
shlq $0x2, %rsi
addq (%rcx,%rdx,8), %rsi
addq %r13, %rsi
callq 0x40d5
movq 0x20(%rsp), %rsi
movq (%r12,%rsi,8), %rax
movss %xmm0, 0x3c(%rax)
movss 0xfee3(%rip), %xmm1     # 0x198f0
ucomiss %xmm0, %xmm1
jae 0x9da0
cmpl $0x0, 0x1d4c(%rbx)
je 0xa002
movq 0x10(%rsp), %rax
movq (%rax), %rcx
movss 0x2c(%rcx), %xmm0
movq (%r14), %rax
addss 0x28(%rax), %xmm0
movq (%r12,%rsi,8), %rdx
ucomiss 0x38(%rdx), %xmm0
jb 0xa002
movq (%rcx), %rdx
movq 0x68(%rdx), %rdx
movslq 0x8(%rcx), %rsi
movslq 0x14(%rcx), %rcx
leaq (%rcx,%rcx,2), %rdi
shlq $0x2, %rdi
addq (%rdx,%rsi,8), %rdi
addq %r13, %rdi
movq (%rax), %rcx
movq 0x68(%rcx), %rcx
movslq 0x8(%rax), %rdx
movslq 0x14(%rax), %rsi
leaq (%rsi,%rsi,2), %rsi
shlq $0x2, %rsi
addq (%rcx,%rdx,8), %rsi
addq %r13, %rsi
movslq 0xc(%rax), %r8
movslq 0x18(%rax), %rax
leaq (%rax,%rax,2), %rdx
shlq $0x2, %rdx
addq (%rcx,%r8,8), %rdx
addq %r13, %rdx
callq 0x4106
movq 0x20(%rsp), %rsi
movq (%r12,%rsi,8), %rax
movss %xmm0, 0x48(%rax)
movq (%r14), %rax
movl 0x20(%rax), %ecx
testl $0xfffffffd, %ecx       # imm = 0xFFFFFFFD
jne 0x9ad0
ucomiss 0x10037(%rip), %xmm0    # 0x19af8
jb 0x9ad0
movss 0x10029(%rip), %xmm1    # 0x19af4
ucomiss %xmm0, %xmm1
jae 0x9afa
addl $-0x3, %ecx
cmpl $0x1, %ecx
ja 0xa002
ucomiss 0x103e1(%rip), %xmm0    # 0x19ec4
jb 0xa002
movss 0x10003(%rip), %xmm1    # 0x19af4
ucomiss %xmm0, %xmm1
jb 0xa002
movq (%rax), %rcx
movq 0x68(%rcx), %rcx
movslq 0x8(%rax), %rdx
movslq 0x14(%rax), %rax
leaq (%rax,%rax,2), %rdi
shlq $0x2, %rdi
addq (%rcx,%rdx,8), %rdi
addq %r13, %rdi
movq 0x10(%rsp), %rbp
movq (%rbp), %rax
movq (%rax), %rcx
movq 0x68(%rcx), %rcx
movslq 0x8(%rax), %rdx
movslq 0x14(%rax), %rsi
leaq (%rsi,%rsi,2), %rsi
shlq $0x2, %rsi
addq (%rcx,%rdx,8), %rsi
addq %r13, %rsi
movslq 0xc(%rax), %r8
movslq 0x18(%rax), %rax
leaq (%rax,%rax,2), %rdx
shlq $0x2, %rdx
addq (%rcx,%r8,8), %rdx
addq %r13, %rdx
callq 0x4106
movq 0x20(%rsp), %rsi
movq (%r12,%rsi,8), %rax
movss %xmm0, 0x4c(%rax)
movq (%rbp), %rax
movl 0x24(%rax), %ecx
cmpq $0x3, %rcx
ja 0xa002
leaq 0x103ab(%rip), %rsi     # 0x19f2c
movslq (%rsi,%rcx,4), %rdx
addq %rsi, %rdx
movq 0x20(%rsp), %rsi
jmpq *%rdx
ucomiss 0xff62(%rip), %xmm0     # 0x19af8
jb 0x9ba5
movss 0xff54(%rip), %xmm1     # 0x19af4
ucomiss %xmm0, %xmm1
jae 0x9bd1
movl %ecx, %edx
orl $0x2, %edx
cmpl $0x3, %edx
jne 0xa002
ucomiss 0xff3e(%rip), %xmm0     # 0x19af8
jb 0xa002
movss 0xff2c(%rip), %xmm1     # 0x19af4
ucomiss %xmm0, %xmm1
jb 0xa002
testl $0xfffffffd, %ecx       # imm = 0xFFFFFFFD
jne 0x9c92
movq (%rax), %rcx
movq 0x68(%rcx), %rcx
movslq 0x10(%rax), %rdx
movslq 0x1c(%rax), %rsi
leaq (%rsi,%rsi,2), %rdi
shlq $0x2, %rdi
addq (%rcx,%rdx,8), %rdi
addq %r13, %rdi
movslq 0x8(%rax), %rdx
movslq 0x14(%rax), %rsi
leaq (%rsi,%rsi,2), %rsi
shlq $0x2, %rsi
addq (%rcx,%rdx,8), %rsi
movslq 0xc(%rax), %r8
movslq 0x18(%rax), %rax
leaq (%rax,%rax,2), %rdx
shlq $0x2, %rdx
addq (%rcx,%r8,8), %rdx
addq %r13, %rsi
addq %r13, %rdx
movq (%r14), %rax
movq (%rax), %rcx
movq 0x68(%rcx), %r8
movslq 0x8(%rax), %r9
movslq 0x14(%rax), %rax
leaq (%rax,%rax,2), %rcx
shlq $0x2, %rcx
addq (%r8,%r9,8), %rcx
addq %r13, %rcx
callq 0x3e9c
movq 0x20(%rsp), %rsi
andps 0xfc75(%rip), %xmm0     # 0x198d0
movq (%r12,%rsi,8), %rax
movss %xmm0, 0x50(%rax)
ucomiss 0xfe8d(%rip), %xmm0     # 0x19af8
jbe 0x9c92
movss 0xfe8b(%rip), %xmm1     # 0x19b00
ucomiss %xmm0, %xmm1
jbe 0x9c92
movss 0xfe72(%rip), %xmm1     # 0x19af4
subss %xmm0, %xmm1
andps 0xfc43(%rip), %xmm1     # 0x198d0
movss %xmm1, 0x50(%rax)
movq (%r14), %rax
testl $0xfffffffd, 0x20(%rax) # imm = 0xFFFFFFFD
jne 0x9d5c
movq 0x10(%rsp), %rcx
movq (%rcx), %rcx
movq (%rcx), %rdx
movq 0x68(%rdx), %rdx
movslq 0x8(%rcx), %rsi
movslq 0x14(%rcx), %rcx
leaq (%rcx,%rcx,2), %rdi
shlq $0x2, %rdi
addq (%rdx,%rsi,8), %rdi
movq (%rax), %rcx
movq 0x68(%rcx), %r8
movslq 0x8(%rax), %rcx
movslq 0x14(%rax), %rdx
leaq (%rdx,%rdx,2), %rsi
shlq $0x2, %rsi
addq (%r8,%rcx,8), %rsi
addq %r13, %rdi
addq %r13, %rsi
movslq 0xc(%rax), %rcx
movslq 0x18(%rax), %rdx
leaq (%rdx,%rdx,2), %rdx
shlq $0x2, %rdx
addq (%r8,%rcx,8), %rdx
addq %r13, %rdx
movslq 0x10(%rax), %r9
movslq 0x1c(%rax), %rax
leaq (%rax,%rax,2), %rcx
shlq $0x2, %rcx
addq (%r8,%r9,8), %rcx
addq %r13, %rcx
callq 0x3e9c
movq 0x20(%rsp), %rsi
andps 0xfbab(%rip), %xmm0     # 0x198d0
movq (%r12,%rsi,8), %rax
movss %xmm0, 0x54(%rax)
ucomiss 0xfdc3(%rip), %xmm0     # 0x19af8
jbe 0x9d5c
movss 0xfdc1(%rip), %xmm1     # 0x19b00
ucomiss %xmm0, %xmm1
jbe 0x9d5c
movss 0xfda8(%rip), %xmm1     # 0x19af4
subss %xmm0, %xmm1
andps 0xfb79(%rip), %xmm1     # 0x198d0
movss %xmm1, 0x54(%rax)
movq 0x10(%rsp), %rax
movq (%rax), %rax
movl 0x24(%rax), %eax
testl $0xfffffffd, %eax       # imm = 0xFFFFFFFD
je 0x9d7e
movq (%r14), %rcx
testl $0xfffffffd, 0x20(%rcx) # imm = 0xFFFFFFFD
jne 0x9ff7
movq (%r14), %rcx
movl 0x20(%rcx), %ecx
testl $0xfffffffd, %ecx       # imm = 0xFFFFFFFD
jne 0x9f8f
testl $0xfffffffd, %eax       # imm = 0xFFFFFFFD
je 0x9fcf
jmp 0x9fae
movq 0x10(%rsp), %rax
movq (%rax), %rax
movq (%rax), %rcx
movq 0x68(%rcx), %rcx
movslq 0x8(%rax), %rdx
movq (%rcx,%rdx,8), %rcx
movslq 0x14(%rax), %rdx
leaq (%rdx,%rdx,2), %rdx
leaq 0x188(%rcx,%rdx,4), %rdi
movslq 0x20(%rax), %rax
leaq (%rax,%rax,2), %rax
leaq 0x188(%rcx,%rax,4), %rsi
movq (%r14), %rax
movq (%rax), %rcx
movq 0x68(%rcx), %rcx
movslq 0x8(%rax), %r8
movslq 0x14(%rax), %rax
leaq (%rax,%rax,2), %rdx
shlq $0x2, %rdx
addq (%rcx,%r8,8), %rdx
addq %r13, %rdx
callq 0x4106
movq 0x20(%rsp), %rsi
movq (%r12,%rsi,8), %rax
movss %xmm0, 0x40(%rax)
ucomiss 0xfce6(%rip), %xmm0     # 0x19af8
jb 0x9a16
movss 0xfcd4(%rip), %xmm1     # 0x19af4
ucomiss %xmm0, %xmm1
jb 0x9a16
movq (%r14), %rax
movq (%rax), %rcx
movq 0x68(%rcx), %rcx
movslq 0xc(%rax), %rdx
movslq 0x18(%rax), %rsi
leaq (%rsi,%rsi,2), %rdi
shlq $0x2, %rdi
addq (%rcx,%rdx,8), %rdi
movslq 0x8(%rax), %rdx
movslq 0x14(%rax), %rax
leaq (%rax,%rax,2), %rsi
shlq $0x2, %rsi
addq (%rcx,%rdx,8), %rsi
addq %r13, %rdi
addq %r13, %rsi
movq 0x10(%rsp), %rax
movq (%rax), %rax
movq (%rax), %rcx
movq 0x68(%rcx), %rcx
movslq 0x8(%rax), %r8
movslq 0x20(%rax), %rax
leaq (%rax,%rax,2), %rdx
shlq $0x2, %rdx
addq (%rcx,%r8,8), %rdx
addq %r13, %rdx
callq 0x4106
movq 0x20(%rsp), %rsi
movq (%r12,%rsi,8), %rax
movss %xmm0, 0x44(%rax)
ucomiss 0xfc57(%rip), %xmm0     # 0x19af8
jb 0x9a16
movss 0xfc45(%rip), %xmm1     # 0x19af4
ucomiss %xmm0, %xmm1
jb 0x9a16
movl $0x1, 0x18(%rax)
jmp 0x9a16
movslq 0x20(%r8), %rcx
cmpq $-0x1, %rcx
je 0x99a2
movq (%rdx), %rsi
movq 0x68(%rsi), %r9
movslq 0x10(%rdx), %rsi
movslq 0x1c(%rdx), %rdi
leaq (%rdi,%rdi,2), %rdi
shlq $0x2, %rdi
addq (%r9,%rsi,8), %rdi
addq %r13, %rdi
movslq 0xc(%rdx), %r10
movslq 0x18(%rdx), %rsi
leaq (%rsi,%rsi,2), %rsi
shlq $0x2, %rsi
addq (%r9,%r10,8), %rsi
addq %r13, %rsi
movslq 0x8(%rdx), %r10
movslq 0x14(%rdx), %rdx
leaq (%rdx,%rdx,2), %rdx
shlq $0x2, %rdx
addq (%r9,%r10,8), %rdx
addq %r13, %rdx
movq (%r8), %r9
movq 0x68(%r9), %r9
movslq 0x8(%r8), %r10
movq (%r9,%r10,8), %r9
leaq (%rcx,%rcx,2), %rcx
leaq 0x188(%r9,%rcx,4), %rcx
movslq 0x14(%r8), %r8
leaq (%r8,%r8,2), %r8
leaq (%r9,%r8,4), %r8
addq $0x188, %r8             # imm = 0x188
movq %rax, (%rsp)
movq %rbx, %r9
xorl %eax, %eax
callq *0x68(%rsp)
movq 0x20(%rsp), %rsi
movq (%r12,%rsi,8), %rax
movss 0xff56(%rip), %xmm0     # 0x19ec0
ucomiss 0x1c(%rax), %xmm0
jbe 0x99a2
movb 0x1c07(%rbx), %cl
cmpb $0x47, %cl
je 0xa21c
movl $0x1, 0x10(%rax)
jmp 0x99a2
testl $0xfffffffd, %eax       # imm = 0xFFFFFFFD
jne 0x9fae
movq (%r12,%rsi,8), %rdx
movss 0xff22(%rip), %xmm0     # 0x19ec4
ucomiss 0x50(%rdx), %xmm0
jb 0x9d90
jmp 0x9ff7
testl $0xfffffffd, %ecx       # imm = 0xFFFFFFFD
jne 0x9fc8
movq (%r12,%rsi,8), %rdx
movss 0xfb36(%rip), %xmm0     # 0x19af8
ucomiss 0x54(%rdx), %xmm0
jae 0x9ff7
testl $0xfffffffd, %eax       # imm = 0xFFFFFFFD
jne 0xa002
testl $0xfffffffd, %ecx       # imm = 0xFFFFFFFD
jne 0xa002
movq (%r12,%rsi,8), %rax
movss 0xfee1(%rip), %xmm0     # 0x19ec4
ucomiss 0x50(%rax), %xmm0
jb 0xa002
movss 0xfb07(%rip), %xmm0     # 0x19af8
ucomiss 0x54(%rax), %xmm0
jb 0xa002
movq (%r12,%rsi,8), %rax
movl $0x1, 0x14(%rax)
movq (%r12,%rsi,8), %rdi
cmpl $0x0, 0x10(%rdi)
je 0xa015
xorps %xmm0, %xmm0
ucomiss 0x1c(%rdi), %xmm0
ja 0xa025
cmpl $0x0, 0x14(%rdi)
jne 0xa025
cmpl $0x0, 0x18(%rdi)
je 0xa1e2
movq 0x10(%rsp), %rdx
movq (%rdx), %rax
movq %rax, (%rdi)
movq (%r14), %rax
movq (%r12,%rsi,8), %rcx
movq %rax, 0x8(%rcx)
movq 0x48(%rsp), %rsi
movl $0x1, %ecx
movq 0x78(%rsp), %rax
movl %ecx, (%rsi,%rax,4)
movq 0x50(%rsp), %rax
movl %ecx, (%rax,%r15,4)
movq (%rdx), %rax
movq (%rax), %rax
movsbl 0x40(%rax), %edx
movq 0x30(%rsp), %rbx
movq %rbx, %rdi
movl 0x3c(%rsp), %esi
callq 0x504f
movl %eax, %ebp
cmpl $-0x1, %eax
je 0xa0b5
movslq %ebp, %rax
movq (%rbx,%rax,8), %rsi
movq 0x68(%rsi), %rcx
movq 0x10(%rsp), %rdx
movq (%rdx), %rdx
movslq 0x8(%rdx), %rdx
movq (%rcx,%rdx,8), %rdi
movq 0x770(%rdi), %rcx
movslq 0x30(%rcx), %rdx
cmpq $0x5, %rdx
jg 0xa1ee
leal 0x1(%rdx), %eax
movl %eax, 0x30(%rcx)
movl 0xc(%rsp), %eax
movl %eax, (%rcx,%rdx,4)
movq (%r14), %rax
movq (%rax), %rax
movsbl 0x40(%rax), %edx
movq %rbx, %rdi
movl 0x3c(%rsp), %esi
callq 0x504f
movl %eax, %ebx
movslq %eax, %r12
cmpl $-0x1, %eax
movl 0xc(%rsp), %r8d
je 0xa112
movq 0x30(%rsp), %rax
movq (%rax,%r12,8), %rsi
movq 0x68(%rsi), %rax
movq (%r14), %rcx
movslq 0x8(%rcx), %rcx
movq (%rax,%rcx,8), %rdi
movq 0x770(%rdi), %rax
movslq 0x34(%rax), %rcx
cmpq $0x5, %rcx
jg 0xa201
leal 0x1(%rcx), %edx
movl %edx, 0x34(%rax)
movl %r8d, 0x18(%rax,%rcx,4)
cmpl $-0x1, %ebp
je 0xa188
cmpl %ebx, %ebp
je 0xa188
movslq %ebp, %rax
movq 0x30(%rsp), %rdx
movq (%rdx,%rax,8), %rax
movq 0x68(%rax), %rax
movq 0x10(%rsp), %rcx
movq (%rcx), %rcx
movslq 0x8(%rcx), %rcx
movq (%rax,%rcx,8), %rax
movq 0x770(%rax), %rax
movl $0x1, %esi
movl %esi, 0x38(%rax)
movq (%rdx,%r12,8), %rax
movq 0x68(%rax), %rax
movq (%r14), %rcx
movslq 0x8(%rcx), %rcx
movq (%rax,%rcx,8), %rax
movq 0x770(%rax), %rax
movl %esi, 0x38(%rax)
movq 0x40(%rsp), %r12
movq 0x20(%rsp), %rax
movq (%r12,%rax,8), %rax
cmpl $0x0, 0x14(%rax)
je 0xa1ba
movq 0x30(%rsp), %rax
movq (%rax), %rax
incl 0x34(%rax)
jmp 0xa1b7
cmpl $-0x1, %ebp
movq 0x40(%rsp), %r12
je 0xa1ba
cmpl %ebx, %ebp
jne 0xa1ba
movq 0x20(%rsp), %rax
movq (%r12,%rax,8), %rax
cmpl $0x0, 0x14(%rax)
je 0xa1ba
movslq %ebp, %rax
movq 0x30(%rsp), %rcx
movq (%rcx,%rax,8), %rax
incl 0x30(%rax)
movq (%rcx), %rax
incl 0x38(%rax)
incl %r8d
movq 0x70(%rsp), %rbx
movl $0x188, %r13d           # imm = 0x188
incq %r15
movslq 0x1c(%rsp), %rax
addq $0x8, %r14
cmpq %rax, %r15
jl 0x987e
jmp 0xa270
callq 0x2040
movl 0xc(%rsp), %r8d
jmp 0xa1c8
leaq (%rbx,%rax,8), %rdx
movq 0x10(%rsp), %rcx
callq 0x2328
jmp 0xa0b5
movq 0x30(%rsp), %rax
leaq (%rax,%r12,8), %rdx
movq %r14, %rcx
callq 0x23a6
movl 0xc(%rsp), %r8d
jmp 0xa112
movss 0x24(%rax), %xmm0
andps 0xf6a8(%rip), %xmm0     # 0x198d0
cvtss2sd %xmm0, %xmm0
ucomisd 0xf62c(%rip), %xmm0     # 0x19860
jbe 0xa262
cmpb $0x47, %cl
jne 0x9f83
movss 0x28(%rax), %xmm0
andps 0xf685(%rip), %xmm0     # 0x198d0
cvtss2sd %xmm0, %xmm0
ucomisd 0xf609(%rip), %xmm0     # 0x19860
jbe 0x99a2
jmp 0x9f83
cmpb $0x47, %cl
je 0x99a2
jmp 0x9f83
movq 0x78(%rsp), %rdx
incq %rdx
movslq 0x2c(%rsp), %r12
cmpq %r12, %rdx
movq 0x58(%rsp), %r14
movq 0x60(%rsp), %rcx
jl 0x9835
jmp 0xa295
xorl %r8d, %r8d
cmpl $0x0, 0x1d60(%rbx)
setne %al
testl %r8d, %r8d
setg %cl
andb %al, %cl
cmpb $0x1, %cl
movl %r8d, 0xc(%rsp)
jne 0xa304
movl %r8d, %r13d
xorps %xmm0, %xmm0
leaq 0xfd64(%rip), %rbx      # 0x1a022
leaq 0x80(%rsp), %r14
xorl %r15d, %r15d
movq 0x40(%rsp), %rax
movq (%rax,%r15,8), %rax
ucomiss 0x1c(%rax), %xmm0
jbe 0xa2fc
movq %r14, %rdi
movq %rbx, %rsi
movl %r15d, %edx
xorl %eax, %eax
callq 0x2220
movq 0x40(%rsp), %rax
movq (%rax,%r15,8), %rsi
movq %r14, %rdi
callq 0xa393
xorps %xmm0, %xmm0
incq %r15
cmpq %r15, %r13
jne 0xa2c9
testl %r12d, %r12d
movq 0x58(%rsp), %r15
jle 0xa336
movl %r12d, %ebx
xorl %r14d, %r14d
movq 0x48(%rsp), %rax
cmpl $0x0, (%rax,%r14,4)
jne 0xa32e
movq 0x60(%rsp), %rax
movq (%rax,%r14,8), %rdi
callq 0x2040
incq %r14
cmpq %r14, %rbx
jne 0xa314
movslq 0x1c(%rsp), %rbx
testq %rbx, %rbx
jle 0xa360
xorl %r14d, %r14d
movq 0x50(%rsp), %rax
cmpl $0x0, (%rax,%r14,4)
jne 0xa358
movq (%r15,%r14,8), %rdi
callq 0x2040
incq %r14
cmpq %r14, %rbx
jne 0xa343
testl %r12d, %r12d
je 0xa36f
movq 0x48(%rsp), %rdi
callq 0x2040
testl %ebx, %ebx
je 0xa37d
movq 0x50(%rsp), %rdi
callq 0x2040
movl 0xc(%rsp), %eax
addq $0x488, %rsp            # imm = 0x488
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq