// File: /workspace/github_c_makefile_star2_O3/ugobas[P]tnm/simulation.c
// Function: Internal_differences
void  Internal_differences(struct bond *bonds, struct bond *bonds2,
			   int natoms, char *prots)
{
  int PRINT_ALL=0;
  if(PRINT_ALL){
    char name[80]; sprintf(name, "Internal_coordinates_%s.dat", prots);
    FILE *file=fopen(name, "w"); // Write internal coordinates
    fprintf(file,
	    "#1=l1 2=l2 3=cos(th1) 4=cos(th2) 5=phi1 6=phi2 atom res\n");
    for(int i=0; i<natoms; i++){
      struct bond *bond1=bonds+i; if(bond1->atom==NULL)break;
      if(bond1->atom->main==0)continue;
      if(bond1->atom->ali<0)continue;
      struct bond *bond2=bonds2+bond1->atom->ali;
      struct bond *b1=bond1->previous;
      if(b1 &&(b1->atom->ali>=0)){
	b1=b1->previous;
	if(b1 &&(b1->atom->ali>=0)){
	  fprintf(file, "%.3f\t%.3f\t%.3f\t%.3f\t%.3f\t%.3f\t%s\t%d\n", 
		  bond1->l, bond2->l,
		  bond1->r_cos_theta/bond1->l, bond2->r_cos_theta/bond2->l,
		  bond1->phi, bond2->phi, bond1->atom->name, bond1->atom->res);
	}
      }
    }
    fclose(file); printf("Writing %s\n", name);
  }

  int n[3], k, a;
  double diff1[3], diff2[3], diff1_aa[3][20], diff2_aa[3][20], n_aa[3][20];
  //float diff[3][natoms];  //diff[k][n[k]]=d;
  for(k=0; k<3; k++){  
    n[k]=0; diff1[k]=0; diff2[k]=0;
    for(a=0; a<20; a++){
      n_aa[k][a]=0; diff1_aa[k][a]=0; diff2_aa[k][a]=0;
    }
  }
  Atom_type("CA"); // Needed to initialize num_BB
  double internal[3][num_BB], internal_2[3][num_BB];
  int n_int[3][num_BB];
  for(k=0; k<3; k++){
    for(a=0; a<num_BB; a++){
      internal[k][a]=0; internal_2[k][a]=0; n_int[k][a]=0;
    }
  }

  float pi=3.1415925, deg=180.0/pi, twopi=2*pi;
  float d, m;
  struct bond *bond1=bonds, *bond2=bonds2, *b1;
  float omega2[natoms];
  for(int i=0; i<natoms; i++){
    bond1=bonds+i;
    int na=Atom_type(bond1->atom->name);
    if(na<0)continue;
    if((bond1->len>=0)||(bond1->angle>=0))continue;  // exclude pseudo-bonds
    if((bond1->atom->ali<0))continue;
    a=Code_AA(bond1->atom->aa);
    bond2=bonds2+bond1->atom->ali; b1=bond1->previous;
    if(b1 &&(b1->atom->ali>=0)){
      k=0; // bond length
      d=bond1->l; // l1
      internal[k][na]+=d; internal_2[k][na]+=d*d;
      d=bond2->l; // l2
      internal[k][na]+=d; internal_2[k][na]+=d*d; n_int[k][na]+=2;
      d= bond1->l-bond2->l; // difference
      diff1[k]+=d; diff2[k]+=d*d; n[k]++;
      if((a>=0)&&(a<20)){
	diff1_aa[k][a]+=d; diff2_aa[k][a]+=d*d; n_aa[k][a]++;
      }
      b1=b1->previous;
      if(b1 && (b1->atom->ali>=0)){
	k=1;  // bond angle
	float s1, c1=Cos_sin(&s1, bond1->r_cos_theta/bond1->l);
	float s2, c2=Cos_sin(&s2, bond2->r_cos_theta/bond2->l);

	d=acos(c1); // theta1
	internal[k][na]+=d; internal_2[k][na]+=d*d;
	d=acos(c2); // theta2
	internal[k][na]+=d; internal_2[k][na]+=d*d; n_int[k][na]+=2;
	d=asin(s2*c1-s1*c2); // difference
	diff1[k]+=d; diff2[k]+=d*d; n[k]++;
	if((a>=0)&&(a<20)){
	  diff1_aa[k][a]+=d; diff2_aa[k][a]+=d*d; n_aa[k][a]++;
	}
	b1=b1->previous;
	if(b1 && (b1->atom->ali>=0)){
	  k=2;  // torsion angle
	  d=bond1->phi; // phi1
	  internal[k][na]+=d; internal_2[k][na]+=d*d;
	  d=bond2->phi; // phi2
	  internal[k][na]+=d; internal_2[k][na]+=d*d; n_int[k][na]+=2;
	  omega2[i]=bond2->phi;
	  d=bond1->phi-bond2->phi; // difference
	  if(d>pi){d-=twopi;}else if(d<-pi){d+=twopi;}
	  bond1->d_phi=fabs(d)*deg; // difference in degrees
	  diff1[k]+=d; diff2[k]+=d*d; n[k]++;
	  if((a>=0)&&(a<20)){
	    diff1_aa[k][a]+=d; diff2_aa[k][a]+=d*d; n_aa[k][a]++;
	  }
	}
      }
    }
  }

  char name[100]; sprintf(name, "Internal_differences_%s.dat", prots);
  FILE *file_out=fopen(name, "w"); printf("Writing %s\n", name);
  fprintf(file_out, "# atom\tn\t3=len s.e.\t5=angle s.e.\t7=torsion\n"); 
  for(a=0; a<num_BB; a++){
    fprintf(file_out, "# %s\t%d ", BB_name[a], n_int[1][a]);
    for(k=0; k<3; k++){
      Ave_se(&(internal[k][a]), &(internal_2[k][a]), n_int[k][a]);
      fprintf(file_out, "\t%.3f %.3f", internal[k][a], internal_2[k][a]);
    }
    fprintf(file_out, "\n");
  }
  fprintf(file_out, "#\n");
  for(k=0; k<3; k++){
    if(k==0){     fprintf(file_out, "# Bond lengths:   ");}
    else if(k==1){fprintf(file_out, "# Bond angles:    ");}
    else if(k==2){fprintf(file_out, "# Torsion angles: ");}
    diff1[k]/=n[k]; diff2[k]/=n[k];
    d=sqrt((diff2[k]-diff1[k]*diff1[k])/(n[k]-1));
    fprintf(file_out, "<d>= %7.4f s.e.= %.4f t= %5.1f RMSD= %.3f n= %.0f\n",
	    diff1[k], d, diff1[k]/d, sqrt(diff2[k]), (float)n[k]);
  }
  fprintf(file_out, "#aa Bond lengths: 2=mean 3=RMSD ");
  fprintf(file_out, "Bond angles: 4=mean 5=RMSD ");
  fprintf(file_out, "Torsion angles: 6=mean 7=RMSD 8=n\n");
  for(a=0; a<20; a++){
    fprintf(file_out, "%c", AA_code[a]);
    for(k=0; k<3; k++){
      if(n_aa[k][a]){
	m=diff1_aa[k][a]/n_aa[k][a];
	d=sqrt(diff2_aa[k][a]/n_aa[k][a]);
      }else{
	m=0; d=0;
      }
      fprintf(file_out, "\t%.3f\t%.3f", m, d);
    }
    fprintf(file_out, "\t%.0f\n", n_aa[0][a]);
  }

  printf("# List of residues with D_omega > %d\n", D_omega_thr);
  printf("#Atom Res nres d_phi\n");
  fprintf(file_out, "# List of residues with D_omega > %d\n", D_omega_thr);
  fprintf(file_out, "#Atom Res nres d_omega omega1 omega2\n");
  bond1=bonds;
  for(int i=0; i<natoms; i++){
    atom *atom=bond1->atom;
    if((strncmp(atom->name, "CA", 2)==0)&&(bond1->d_phi > D_omega_thr)){
      fprintf(file_out, "%s %c%dch%d  %d %.0f %.0f\n",
	      atom->name, atom->aa, atom->res, atom->chain+1,
	      bond1->d_phi, bond1->phi*deg, omega2[i]*deg);
      printf("%s %c%d %d\n", atom->name, atom->aa, atom->res, bond1->d_phi);
    }
    bond1++;
  }

  fclose(file_out);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x778, %rsp            # imm = 0x778
movq %rcx, -0x180(%rbp)
movl %edx, -0x70(%rbp)
movq %rsi, -0x178(%rbp)
movq %rdi, -0x120(%rbp)
leaq -0x370(%rbp), %rdi
xorl %ebx, %ebx
movl $0x1e0, %edx            # imm = 0x1E0
movq %rdi, -0x150(%rbp)
xorl %esi, %esi
callq 0x2110
leaq -0x730(%rbp), %rdi
movl $0x1e0, %edx            # imm = 0x1E0
movq %rdi, -0x148(%rbp)
xorl %esi, %esi
callq 0x2110
leaq -0x550(%rbp), %rdi
movl $0x1e0, %edx            # imm = 0x1E0
movq %rdi, -0x140(%rbp)
xorl %esi, %esi
callq 0x2110
xorl %eax, %eax
movl $0x0, -0x7c(%rbp,%rax,4)
movq %rbx, -0x100(%rbp,%rax,8)
movq %rbx, -0xe0(%rbp,%rax,8)
incq %rax
cmpq $0x3, %rax
jne 0x39407
leaq 0x1bd67(%rip), %rdi     # 0x55196
callq 0xff04
movq %rsp, -0x188(%rbp)
leaq 0x2f1a6(%rip), %rcx     # 0x685e8
movl (%rcx), %edx
movq %rsp, %r12
leaq (%rdx,%rdx,2), %rax
leaq 0xf(,%rax,8), %rax
andq $-0x10, %rax
subq %rax, %r12
movq %r12, %rsp
movl (%rcx), %r13d
leaq (,%r13,2), %rax
addq %r13, %rax
movq %rsp, %rsi
leaq 0xf(,%rax,8), %rcx
andq $-0x10, %rcx
subq %rcx, %rsi
movq %rsi, %rsp
movq %rsp, %rcx
leaq 0xf(,%rax,4), %rax
andq $-0x10, %rax
subq %rax, %rcx
movq %rcx, -0x38(%rbp)
movq %rcx, %rsp
movq %rdx, -0xb8(%rbp)
leaq (,%rdx,8), %rax
movq %rax, -0x40(%rbp)
leaq (,%r13,8), %rax
movq %rax, -0x88(%rbp)
leaq (,%r13,4), %rbx
movl $0x3, %r14d
xorl %r15d, %r15d
movq %r12, -0x90(%rbp)
movq %rsi, -0x58(%rbp)
movq %rbx, -0x138(%rbp)
movq %r13, -0x50(%rbp)
testl %r13d, %r13d
jle 0x39534
leaq (%rsi,%r15,2), %rbx
movq -0x38(%rbp), %rax
addq %r15, %rax
movq %rax, -0x48(%rbp)
movq %r12, %rdi
xorl %esi, %esi
movq -0x88(%rbp), %r13
movq %r13, %rdx
callq 0x2110
movq %rbx, %rdi
movq -0x138(%rbp), %rbx
xorl %esi, %esi
movq %r13, %rdx
callq 0x2110
movq -0x48(%rbp), %rdi
movq -0x50(%rbp), %r13
xorl %esi, %esi
movq %rbx, %rdx
callq 0x2110
movq -0x58(%rbp), %rsi
addq %rbx, %r15
addq -0x40(%rbp), %r12
decq %r14
jne 0x394e2
movl -0x70(%rbp), %ecx
movl %ecx, %eax
movq %rsp, %rdx
movq %rax, -0x88(%rbp)
leaq 0xf(,%rax,4), %rax
andq $-0x10, %rax
subq %rax, %rdx
movq %rdx, -0x128(%rbp)
movq %rdx, %rsp
movsd -0x100(%rbp), %xmm0
movsd %xmm0, -0xc0(%rbp)
movsd -0xe0(%rbp), %xmm0
movsd %xmm0, -0x48(%rbp)
movl -0x7c(%rbp), %edx
movq -0x38(%rbp), %r15
leaq (%r15,%r13,4), %rax
movq %rax, -0x130(%rbp)
testl %ecx, %ecx
jle 0x39c0b
movl %edx, -0x6c(%rbp)
movq -0x90(%rbp), %r14
movq -0xb8(%rbp), %rax
leaq (%r14,%rax,8), %rcx
movq %rcx, -0x118(%rbp)
leaq (%rsi,%r13,8), %rcx
movq %rcx, -0x110(%rbp)
shlq $0x4, %rax
addq %r14, %rax
movq %rax, -0xb8(%rbp)
leaq (%r15,%r13,8), %rax
movq %rax, -0x170(%rbp)
shlq $0x4, %r13
addq %rsi, %r13
movq %r13, -0x50(%rbp)
movsd -0xf8(%rbp), %xmm0
movsd %xmm0, -0xb0(%rbp)
movsd -0xf0(%rbp), %xmm0
movsd %xmm0, -0xa0(%rbp)
movsd -0xd8(%rbp), %xmm0
movsd %xmm0, -0xa8(%rbp)
movsd -0xd0(%rbp), %xmm0
movsd %xmm0, -0x98(%rbp)
movl -0x78(%rbp), %eax
movl %eax, -0x68(%rbp)
movl -0x74(%rbp), %eax
movl %eax, -0x64(%rbp)
xorl %ebx, %ebx
movq -0x120(%rbp), %r13
movq (%r13), %rdi
addq $0x18, %rdi
callq 0xff04
testl %eax, %eax
js 0x3965e
cmpl $0x0, 0x34(%r13)
jns 0x3965e
cmpl $0x0, 0x38(%r13)
js 0x39676
incq %rbx
addq $0xc0, %r13
cmpq %rbx, -0x88(%rbp)
jne 0x3963f
jmp 0x39bba
movl %eax, %r12d
movq (%r13), %rax
cmpl $0x0, 0x54(%rax)
js 0x3965e
movsbl 0x68(%rax), %edi
callq 0x1f488
movq 0x28(%r13), %rsi
testq %rsi, %rsi
je 0x3965e
movq (%rsi), %rcx
cmpl $0x0, 0x54(%rcx)
movq -0x58(%rbp), %rdx
js 0x3965e
movq (%r13), %rcx
movslq 0x54(%rcx), %rcx
leaq (%rcx,%rcx,2), %rdi
shlq $0x6, %rdi
addq -0x178(%rbp), %rdi
movsd 0x58(%r13), %xmm1
xorps %xmm0, %xmm0
cvtsd2ss %xmm1, %xmm0
xorps %xmm2, %xmm2
cvtss2sd %xmm0, %xmm2
movl %r12d, %r12d
addsd (%r14,%r12,8), %xmm2
mulss %xmm0, %xmm0
xorps %xmm3, %xmm3
cvtss2sd %xmm0, %xmm3
addsd (%rdx,%r12,8), %xmm3
movsd 0x58(%rdi), %xmm0
xorps %xmm4, %xmm4
cvtsd2ss %xmm0, %xmm4
cvtss2sd %xmm4, %xmm5
addsd %xmm2, %xmm5
movsd %xmm5, (%r14,%r12,8)
mulss %xmm4, %xmm4
xorps %xmm2, %xmm2
cvtss2sd %xmm4, %xmm2
addsd %xmm3, %xmm2
movsd %xmm2, (%rdx,%r12,8)
addl $0x2, (%r15,%r12,4)
movaps %xmm1, %xmm2
subsd %xmm0, %xmm2
xorps %xmm3, %xmm3
cvtsd2ss %xmm2, %xmm3
xorps %xmm2, %xmm2
cvtss2sd %xmm3, %xmm2
mulss %xmm3, %xmm3
cvtss2sd %xmm3, %xmm3
cmpl $0x13, %eax
ja 0x39785
movl %eax, %ecx
movsd -0x730(%rbp,%rcx,8), %xmm4
addsd %xmm2, %xmm4
movsd %xmm4, -0x730(%rbp,%rcx,8)
movsd -0x550(%rbp,%rcx,8), %xmm4
addsd %xmm3, %xmm4
movsd %xmm4, -0x550(%rbp,%rcx,8)
movsd -0x370(%rbp,%rcx,8), %xmm4
addsd 0x179cc(%rip), %xmm4    # 0x51148
movsd %xmm4, -0x370(%rbp,%rcx,8)
movsd -0xc0(%rbp), %xmm4
addsd %xmm2, %xmm4
movsd %xmm4, -0xc0(%rbp)
movsd -0x48(%rbp), %xmm2
addsd %xmm3, %xmm2
movsd %xmm2, -0x48(%rbp)
incl -0x6c(%rbp)
movq 0x28(%rsi), %rdx
testq %rdx, %rdx
je 0x3965e
movq (%rdx), %rcx
cmpl $0x0, 0x54(%rcx)
js 0x3965e
movsd 0x60(%r13), %xmm2
divsd %xmm1, %xmm2
xorps %xmm5, %xmm5
cvtsd2ss %xmm2, %xmm5
xorps %xmm1, %xmm1
movss %xmm1, -0x60(%rbp)
movss 0x17937(%rip), %xmm2    # 0x5111c
ucomiss %xmm2, %xmm5
movq %rdi, -0x108(%rbp)
movl %eax, -0xc8(%rbp)
movq %rdx, -0x168(%rbp)
jbe 0x39806
xorps %xmm3, %xmm3
movaps %xmm2, %xmm4
jmp 0x39870
movss 0x17902(%rip), %xmm1    # 0x51110
ucomiss %xmm5, %xmm1
xorps %xmm3, %xmm3
movaps %xmm1, %xmm4
ja 0x39870
movaps %xmm5, %xmm0
mulss %xmm5, %xmm0
xorps %xmm1, %xmm1
cvtss2sd %xmm0, %xmm1
movsd 0x17919(%rip), %xmm0    # 0x51148
subsd %xmm1, %xmm0
ucomisd 0x1793d(%rip), %xmm0    # 0x51178
jb 0x39843
sqrtsd %xmm0, %xmm0
jmp 0x39861
movss %xmm5, -0x2c(%rbp)
callq 0x22a0
movss -0x2c(%rbp), %xmm5
movq -0x108(%rbp), %rdi
movss 0x178bb(%rip), %xmm2    # 0x5111c
xorps %xmm3, %xmm3
cvtsd2ss %xmm0, %xmm3
movsd 0x58(%rdi), %xmm0
movaps %xmm5, %xmm4
movsd 0x60(%rdi), %xmm1
divsd %xmm0, %xmm1
xorps %xmm5, %xmm5
cvtsd2ss %xmm1, %xmm5
ucomiss %xmm2, %xmm5
movss %xmm3, -0xc4(%rbp)
movss %xmm4, -0x5c(%rbp)
ja 0x398ec
movss 0x17876(%rip), %xmm0    # 0x51110
ucomiss %xmm5, %xmm0
movaps %xmm0, %xmm2
ja 0x398ec
movaps %xmm5, %xmm0
mulss %xmm5, %xmm0
xorps %xmm1, %xmm1
cvtss2sd %xmm0, %xmm1
movsd 0x17890(%rip), %xmm0    # 0x51148
subsd %xmm1, %xmm0
ucomisd 0x178b4(%rip), %xmm0    # 0x51178
jb 0x398cc
sqrtsd %xmm0, %xmm0
jmp 0x398e0
movss %xmm5, -0x2c(%rbp)
callq 0x22a0
movss -0x2c(%rbp), %xmm5
movss -0x5c(%rbp), %xmm4
cvtsd2ss %xmm0, %xmm0
movss %xmm0, -0x60(%rbp)
movaps %xmm5, %xmm2
movss %xmm2, -0x2c(%rbp)
xorps %xmm0, %xmm0
cvtss2sd %xmm4, %xmm0
callq 0x2150
cvtsd2ss %xmm0, %xmm0
xorps %xmm1, %xmm1
cvtss2sd %xmm0, %xmm1
movq -0x118(%rbp), %rax
addsd (%rax,%r12,8), %xmm1
movsd %xmm1, -0x158(%rbp)
mulss %xmm0, %xmm0
cvtss2sd %xmm0, %xmm0
movq -0x110(%rbp), %rax
addsd (%rax,%r12,8), %xmm0
movsd %xmm0, -0x160(%rbp)
xorps %xmm0, %xmm0
cvtss2sd -0x2c(%rbp), %xmm0
callq 0x2150
cvtsd2ss %xmm0, %xmm0
xorps %xmm1, %xmm1
cvtss2sd %xmm0, %xmm1
addsd -0x158(%rbp), %xmm1
movq -0x118(%rbp), %rax
movsd %xmm1, (%rax,%r12,8)
mulss %xmm0, %xmm0
cvtss2sd %xmm0, %xmm0
addsd -0x160(%rbp), %xmm0
movq -0x110(%rbp), %rax
movsd %xmm0, (%rax,%r12,8)
movq -0x130(%rbp), %rax
addl $0x2, (%rax,%r12,4)
movss -0xc4(%rbp), %xmm1
mulss -0x2c(%rbp), %xmm1
movss -0x60(%rbp), %xmm0
mulss -0x5c(%rbp), %xmm0
subss %xmm1, %xmm0
cvtss2sd %xmm0, %xmm0
callq 0x2260
xorps %xmm1, %xmm1
cvtsd2ss %xmm0, %xmm1
xorps %xmm0, %xmm0
cvtss2sd %xmm1, %xmm0
mulss %xmm1, %xmm1
cvtss2sd %xmm1, %xmm1
movl -0xc8(%rbp), %edx
cmpl $0x13, %edx
ja 0x39a1d
movl %edx, %eax
movsd -0x690(%rbp,%rax,8), %xmm2
addsd %xmm0, %xmm2
movsd %xmm2, -0x690(%rbp,%rax,8)
movsd -0x4b0(%rbp,%rax,8), %xmm2
addsd %xmm1, %xmm2
movsd %xmm2, -0x4b0(%rbp,%rax,8)
movsd -0x2d0(%rbp,%rax,8), %xmm2
addsd 0x17734(%rip), %xmm2    # 0x51148
movsd %xmm2, -0x2d0(%rbp,%rax,8)
incl -0x68(%rbp)
movsd -0xb0(%rbp), %xmm2
addsd %xmm0, %xmm2
movsd %xmm2, -0xb0(%rbp)
movsd -0xa8(%rbp), %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0xa8(%rbp)
movq -0x168(%rbp), %rax
movq 0x28(%rax), %rax
testq %rax, %rax
movq -0x108(%rbp), %rsi
je 0x3965e
movq (%rax), %rax
cmpl $0x0, 0x54(%rax)
js 0x3965e
movsd 0x68(%r13), %xmm0
xorps %xmm1, %xmm1
cvtsd2ss %xmm0, %xmm1
xorps %xmm2, %xmm2
cvtss2sd %xmm1, %xmm2
movq -0xb8(%rbp), %rax
addsd (%rax,%r12,8), %xmm2
mulss %xmm1, %xmm1
cvtss2sd %xmm1, %xmm1
movq -0x50(%rbp), %rcx
addsd (%rcx,%r12,8), %xmm1
movsd 0x68(%rsi), %xmm3
cvtsd2ss %xmm3, %xmm4
cvtss2sd %xmm4, %xmm5
addsd %xmm2, %xmm5
movsd %xmm5, (%rax,%r12,8)
movq -0x128(%rbp), %rax
movss %xmm4, (%rax,%rbx,4)
mulss %xmm4, %xmm4
xorps %xmm2, %xmm2
cvtss2sd %xmm4, %xmm2
addsd %xmm1, %xmm2
movsd %xmm2, (%rcx,%r12,8)
movq -0x170(%rbp), %rax
addl $0x2, (%rax,%r12,4)
subsd %xmm3, %xmm0
cvtsd2ss %xmm0, %xmm0
ucomiss 0x2129a(%rip), %xmm0    # 0x5ad90
jbe 0x39b02
addss 0x2129c(%rip), %xmm0    # 0x5ad9c
jmp 0x39b17
movss 0x2128a(%rip), %xmm1    # 0x5ad94
ucomiss %xmm0, %xmm1
jbe 0x39b17
addss 0x21281(%rip), %xmm0    # 0x5ad98
incl -0x64(%rbp)
xorps %xmm1, %xmm1
cvtss2sd %xmm0, %xmm1
movaps %xmm1, %xmm2
andps 0x1d7c5(%rip), %xmm2    # 0x572f0
mulsd 0x21235(%rip), %xmm2    # 0x5ad68
cvttsd2si %xmm2, %eax
movw %ax, 0x70(%r13)
movsd -0xa0(%rbp), %xmm2
addsd %xmm1, %xmm2
movsd %xmm2, -0xa0(%rbp)
mulss %xmm0, %xmm0
cvtss2sd %xmm0, %xmm0
movsd -0x98(%rbp), %xmm2
addsd %xmm0, %xmm2
movsd %xmm2, -0x98(%rbp)
cmpl $0x13, %edx
ja 0x3965e
movl %edx, %eax
addsd -0x5f0(%rbp,%rax,8), %xmm1
movsd %xmm1, -0x5f0(%rbp,%rax,8)
addsd -0x410(%rbp,%rax,8), %xmm0
movsd %xmm0, -0x410(%rbp,%rax,8)
movsd -0x230(%rbp,%rax,8), %xmm0
addsd 0x1759c(%rip), %xmm0    # 0x51148
movsd %xmm0, -0x230(%rbp,%rax,8)
jmp 0x3965e
movsd -0xb0(%rbp), %xmm0
movsd %xmm0, -0xf8(%rbp)
movsd -0xa8(%rbp), %xmm0
movsd %xmm0, -0xd8(%rbp)
movl -0x68(%rbp), %eax
movl %eax, -0x78(%rbp)
movsd -0xa0(%rbp), %xmm0
movsd %xmm0, -0xf0(%rbp)
movsd -0x98(%rbp), %xmm0
movsd %xmm0, -0xd0(%rbp)
movl -0x64(%rbp), %eax
movl %eax, -0x74(%rbp)
movl -0x6c(%rbp), %edx
jmp 0x39c12
movq -0x90(%rbp), %r14
movsd -0xc0(%rbp), %xmm0
movsd %xmm0, -0x100(%rbp)
movsd -0x48(%rbp), %xmm0
movsd %xmm0, -0xe0(%rbp)
movl %edx, -0x7c(%rbp)
leaq 0x21cb0(%rip), %rsi     # 0x5b8e9
leaq -0x7a0(%rbp), %r12
movq %r12, %rdi
movq -0x180(%rbp), %rdx
xorl %eax, %eax
callq 0x2270
leaq 0x1d5a8(%rip), %rsi     # 0x57200
movq %r12, %rdi
callq 0x2220
movq %rax, %r13
leaq 0x180e5(%rip), %rdi     # 0x51d4f
movq %r12, %rsi
xorl %eax, %eax
callq 0x20f0
leaq 0x21c8a(%rip), %rdi     # 0x5b905
movl $0x2b, %esi
movl $0x1, %edx
movq %r13, %rcx
callq 0x2290
leaq 0x2e954(%rip), %rax     # 0x685e8
cmpl $0x0, (%rax)
jle 0x39dc7
xorl %ecx, %ecx
movq %r15, -0x38(%rbp)
leaq (%rcx,%rcx,2), %rdx
addq 0x2d32a(%rip), %rdx     # 0x66fd8
movq -0x130(%rbp), %rax
movq %rcx, -0x50(%rbp)
movl (%rax,%rcx,4), %ecx
movq %r13, %rbx
movq %r13, %rdi
leaq 0x21c68(%rip), %rsi     # 0x5b931
xorl %eax, %eax
callq 0x21a0
movl $0x3, %r15d
movq %r14, -0x90(%rbp)
movq %r14, %r13
xorl %r14d, %r14d
movq -0x58(%rbp), %r12
movq -0x38(%rbp), %rax
movl (%rax,%r14), %eax
xorps %xmm1, %xmm1
cvtsi2sd %eax, %xmm1
movsd (%r13), %xmm2
divsd %xmm1, %xmm2
movsd (%r12,%r14,2), %xmm0
divsd %xmm1, %xmm0
movapd %xmm2, %xmm1
mulsd %xmm2, %xmm1
subsd %xmm1, %xmm0
decl %eax
xorps %xmm1, %xmm1
cvtsi2sd %eax, %xmm1
movsd %xmm2, (%r13)
divsd %xmm1, %xmm0
ucomisd 0x17447(%rip), %xmm0    # 0x51178
jb 0x39d3c
xorps %xmm1, %xmm1
sqrtsd %xmm0, %xmm1
jmp 0x39d53
movsd %xmm2, -0x48(%rbp)
callq 0x22a0
movsd -0x48(%rbp), %xmm2
movq -0x58(%rbp), %r12
movapd %xmm0, %xmm1
movsd %xmm1, (%r12,%r14,2)
movq %rbx, %rdi
leaq 0x21bd7(%rip), %rsi     # 0x5b93a
movapd %xmm2, %xmm0
movb $0x2, %al
callq 0x21a0
addq -0x138(%rbp), %r14
addq -0x40(%rbp), %r13
decq %r15
jne 0x39ce7
movl $0xa, %edi
movq %rbx, %r13
movq %rbx, %rsi
callq 0x2140
movq -0x50(%rbp), %rcx
incq %rcx
leaq 0x2e848(%rip), %rax     # 0x685e8
movslq (%rax), %rax
movq -0x38(%rbp), %r15
addq $0x4, %r15
addq $0x8, %r12
movq %r12, -0x58(%rbp)
movq -0x90(%rbp), %r14
addq $0x8, %r14
cmpq %rax, %rcx
jl 0x39c9f
leaq 0x227a9(%rip), %rdi     # 0x5c577
movl $0x2, %esi
movl $0x1, %edx
movq %r13, %rcx
callq 0x2290
xorl %r12d, %r12d
leaq 0x220a6(%rip), %r14     # 0x5be90
leaq 0x21b8d(%rip), %rax     # 0x5b97e
movq %r13, %rbx
movq %rax, %r13
movslq (%r12,%r14), %rdi
addq %r14, %rdi
movl $0x12, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x2290
movl -0x7c(%rbp,%r12), %r15d
xorps %xmm0, %xmm0
cvtsi2sd %r15d, %xmm0
movsd -0x100(%rbp,%r12,2), %xmm1
divsd %xmm0, %xmm1
movsd %xmm1, -0x100(%rbp,%r12,2)
movsd -0xe0(%rbp,%r12,2), %xmm2
divsd %xmm0, %xmm2
movsd %xmm1, -0x38(%rbp)
mulsd %xmm1, %xmm1
movapd %xmm2, %xmm0
subsd %xmm1, %xmm0
leal -0x1(%r15), %eax
xorps %xmm1, %xmm1
cvtsi2sd %eax, %xmm1
movsd %xmm2, -0xe0(%rbp,%r12,2)
divsd %xmm1, %xmm0
ucomisd 0x17303(%rip), %xmm0    # 0x51178
jb 0x39e7d
sqrtsd %xmm0, %xmm0
jmp 0x39e8c
movsd %xmm2, -0x40(%rbp)
callq 0x22a0
movsd -0x40(%rbp), %xmm2
ucomisd 0x172e4(%rip), %xmm2    # 0x51178
jb 0x39e9f
xorps %xmm3, %xmm3
sqrtsd %xmm2, %xmm3
jmp 0x39eb6
movsd %xmm0, -0x40(%rbp)
movapd %xmm2, %xmm0
callq 0x22a0
movapd %xmm0, %xmm3
movsd -0x40(%rbp), %xmm0
cvtsd2ss %xmm0, %xmm0
xorps %xmm1, %xmm1
cvtss2sd %xmm0, %xmm1
movsd -0x38(%rbp), %xmm0
movapd %xmm0, %xmm2
divsd %xmm1, %xmm2
xorps %xmm4, %xmm4
cvtsi2ss %r15d, %xmm4
cvtss2sd %xmm4, %xmm4
movq %rbx, %rdi
movq %r13, %rsi
movb $0x5, %al
callq 0x21a0
addq $0x4, %r12
cmpq $0xc, %r12
jne 0x39df7
leaq 0x21ab5(%rip), %rdi     # 0x5b9b1
movl $0x20, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x2290
leaq 0x21abd(%rip), %rdi     # 0x5b9d2
movl $0x1b, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x2290
leaq 0x21ac0(%rip), %rdi     # 0x5b9ee
movl $0x22, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x2290
xorl %r13d, %r13d
leaq 0x21ac7(%rip), %r14     # 0x5ba11
leaq 0x21acb(%rip), %r12     # 0x5ba1c
leaq 0x2f220(%rip), %rax     # 0x69178
movq (%rax), %rax
movsbl (%rax,%r13), %edi
movq %rbx, %rsi
callq 0x2140
xorl %r15d, %r15d
movq -0x150(%rbp), %rax
movsd (%rax,%r15), %xmm2
xorpd %xmm0, %xmm0
ucomisd %xmm0, %xmm2
xorpd %xmm1, %xmm1
jne 0x39f88
jnp 0x39fec
movq -0x148(%rbp), %rax
movsd (%rax,%r15), %xmm1
movq -0x140(%rbp), %rax
movsd (%rax,%r15), %xmm0
divsd %xmm2, %xmm0
ucomisd 0x171ca(%rip), %xmm0    # 0x51178
jb 0x39fb6
sqrtsd %xmm0, %xmm0
jmp 0x39fcf
movsd %xmm2, -0x38(%rbp)
movsd %xmm1, -0x40(%rbp)
callq 0x22a0
movsd -0x40(%rbp), %xmm1
movsd -0x38(%rbp), %xmm2
divsd %xmm2, %xmm1
cvtsd2ss %xmm1, %xmm1
xorps %xmm2, %xmm2
cvtsd2ss %xmm0, %xmm2
xorps %xmm0, %xmm0
cvtss2sd %xmm1, %xmm0
xorps %xmm1, %xmm1
cvtss2sd %xmm2, %xmm1
movq %rbx, %rdi
movq %r14, %rsi
movb $0x2, %al
callq 0x21a0
addq $0xa0, %r15
cmpq $0x1e0, %r15            # imm = 0x1E0
jne 0x39f6b
movsd -0x370(%rbp,%r13,8), %xmm0
movq %rbx, %rdi
movq %r12, %rsi
movb $0x1, %al
callq 0x21a0
incq %r13
addq $0x8, -0x150(%rbp)
addq $0x8, -0x148(%rbp)
addq $0x8, -0x140(%rbp)
cmpq $0x14, %r13
jne 0x39f51
leaq 0x2f070(%rip), %r13     # 0x690c0
movl (%r13), %esi
leaq 0x219c8(%rip), %r14     # 0x5ba23
movq %r14, %rdi
xorl %eax, %eax
callq 0x20f0
leaq 0x21d1f(%rip), %rdi     # 0x5bd8b
callq 0x2090
movl (%r13), %edx
movq %rbx, %rdi
movq %r14, %rsi
xorl %eax, %eax
callq 0x21a0
leaq 0x219c0(%rip), %rdi     # 0x5ba49
movl $0x25, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x2290
cmpl $0x0, -0x70(%rbp)
movq -0x120(%rbp), %r12
jle 0x3a174
addq $0x70, %r12
xorl %r14d, %r14d
movq -0x70(%r12), %r15
cmpb $0x43, 0x18(%r15)
jne 0x3a15d
cmpb $0x41, 0x19(%r15)
jne 0x3a15d
movswl (%r12), %r10d
cmpl %r10d, (%r13)
jge 0x3a15d
leaq 0x18(%r15), %r13
movsbl 0x68(%r15), %ecx
movl 0x64(%r15), %r8d
movl 0x6c(%r15), %r9d
incl %r9d
movsd -0x8(%r12), %xmm0
mulsd 0x20c68(%rip), %xmm0    # 0x5ad68
movq -0x128(%rbp), %rax
movss (%rax,%r14,4), %xmm1
mulss 0x20c8b(%rip), %xmm1    # 0x5ada0
cvtss2sd %xmm1, %xmm1
subq $0x8, %rsp
movq %rbx, %rdi
leaq 0x21948(%rip), %rsi     # 0x5ba6f
movq %r13, %rdx
movb $0x2, %al
pushq %r10
callq 0x21a0
addq $0x10, %rsp
movsbl 0x68(%r15), %edx
movl 0x64(%r15), %ecx
movswl (%r12), %r8d
leaq 0x2193e(%rip), %rdi     # 0x5ba8a
movq %r13, %rsi
leaq 0x2ef6a(%rip), %r13     # 0x690c0
xorl %eax, %eax
callq 0x20f0
incq %r14
addq $0xc0, %r12
cmpq %r14, -0x88(%rbp)
jne 0x3a0b3
movq %rbx, %rdi
callq 0x20c0
movq -0x188(%rbp), %rsp
leaq -0x28(%rbp), %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq