// File: /workspace/github_c_makefile_star2_O1/josch[P]stride/nsc.c
// Function: nsc_dclm
int nsc_dclm(
  double *co, double *radius, int nat,
  int densit, int mode,
  double *value_of_area, double **at_area,
  double *value_of_vol,
  double **lidots, int *nu_dots) {

  int iat, i, ii, iii, ix, iy, iz, ixe, ixs, iye, iys, ize, izs, i_ac;
  int jat, j, jj, jjj, jx, jy, jz;
  int distribution;
  int l;
  int maxnei, nnei, last, maxdots;
  point_int wkdot=NULL, wkbox=NULL, wkat1=NULL, wkatm=NULL;
  Neighb  *wknb, *ctnb;
  int iii1, iii2, iiat, lfnr, i_at, j_at;
  double dx, dy, dz, dd, ai, aisq, ajsq, aj, as, a;
  double xi, yi, zi, xs=0., ys=0., zs=0.;
  double dotarea, area, vol=0.;
  point_double xus, dots=NULL, atom_area=NULL;

  int    nxbox, nybox, nzbox, nxy, nxyz;
  double xmin, ymin, zmin, xmax, ymax, zmax, ra2max, d, *pco;

  distribution = unsp_type(densit);
  if (distribution != -last_unsp || last_cubus != 4 ||
     (densit != last_densit && densit != last_n_dot)) {
    if (make_unsp(densit, (-distribution), &n_dot, 4)) return 1;
    }
  xus = xpunsp;

  dotarea = FOURPI/(double) n_dot;
  area = 0.;

#if TEST_CUBE 
  printf("nsc_dclm: n_dot=%5d %9.3f\n", n_dot, dotarea);
#endif

/* start with neighbour list */
/* calculate neighbour list with the box algorithm */
  if (nat==0) {
    WARNING("nsc_dclm: no surface atoms selected");
    return 1;
    }
  if (mode & FLAG_VOLUME) vol=0.;
  if (mode & FLAG_DOTS) {
    maxdots = 3*n_dot*nat/10;
    dots = (double *) CALLOC(maxdots, sizeof(double));
    lfnr=0;
    }
  if (mode & FLAG_ATOM_AREA) {
    atom_area = (double *) CALLOC(nat, sizeof(double));
    }

/* dimensions of atomic set, cell edge is 2*ra_max */
  xmin = co[0]; xmax = xmin; xs=xmin;
  ymin = co[1]; ymax = ymin; ys=ymin;
  zmin = co[2]; zmax = zmin; zs=zmin;
  ra2max = radius[0];

  for (iat=1; iat<nat; iat++) {
    pco = co+3*iat;
    xmin = MINIMUM(xmin, *pco);     xmax = MAXIMUM(xmax, *pco);
    ymin = MINIMUM(ymin, *(pco+1)); ymax = MAXIMUM(ymax, *(pco+1));
    zmin = MINIMUM(zmin, *(pco+2)); zmax = MAXIMUM(zmax, *(pco+2));
    xs= xs+ *pco; ys = ys+ *(pco+1); zs= zs+ *(pco+2);
    ra2max = MAXIMUM(ra2max, radius[iat]);
    }
  xs = xs/ (double) nat;
  ys = ys/ (double) nat;
  zs = zs/ (double) nat;
  ra2max = 2.*ra2max;
#if TEST_CUBE
  printf("nsc_dclm: n_dot=%5d ra2max=%9.3f %9.3f\n", n_dot, ra2max, dotarea);
#endif

  d = xmax-xmin; nxbox = (int) MAXIMUM(ceil(d/ra2max), 1.);
  d = (((double)nxbox)*ra2max-d)/2.;
  xmin = xmin-d; xmax = xmax+d;
  d = ymax-ymin; nybox = (int) MAXIMUM(ceil(d/ra2max), 1.);
  d = (((double)nybox)*ra2max-d)/2.;
  ymin = ymin-d; ymax = ymax+d;
  d = zmax-zmin; nzbox = (int) MAXIMUM(ceil(d/ra2max), 1.);
  d = (((double)nzbox)*ra2max-d)/2.;
  zmin = zmin-d; zmax = zmax+d;
  nxy = nxbox*nybox;
  nxyz = nxy*nzbox;

/* box number of atoms */
  wkatm = (int *) CALLOC(3*nat, sizeof(int));
  wkat1 = wkatm+nat;
  wkdot = (int *) CALLOC(n_dot+nxyz+1, sizeof(int));
  wkbox = wkdot+n_dot;

  for (iat=0; iat<nat; iat++) {
    pco = co+3*iat;
    i = (int) MAXIMUM(floor((  *pco  -xmin)/ra2max), 0); i = MINIMUM(i,nxbox-1);
    j = (int) MAXIMUM(floor((*(pco+1)-ymin)/ra2max), 0); j = MINIMUM(j,nybox-1);
    l = (int) MAXIMUM(floor((*(pco+2)-zmin)/ra2max), 0); l = MINIMUM(l,nzbox-1);
    i = i+j*nxbox+l*nxy;
    wkat1[iat] = i; wkbox[i]++;
    }

/* sorting of atoms in accordance with box numbers */
  j = wkbox[0]; for (i=1; i<nxyz; i++) j= MAXIMUM(wkbox[i], j);
  for (i=1; i<=nxyz; i++) wkbox[i] += wkbox[i-1];
/*
  maxnei = (int) floor(ra2max*ra2max*ra2max*0.5);
*/
  maxnei = MINIMUM(nat, 27*j);
  wknb = (Neighb *) CALLOC(maxnei, sizeof(Neighb));
  for (iat=0; iat<nat; iat++) {
    wkatm[--wkbox[wkat1[iat]]] = iat;
#if TEST_CUBE
    printf("atom %5d on place %5d\n", iat, wkbox[wkat1[iat]]);
#endif
    }
#if TEST_CUBE
  printf("nsc_dclm: n_dot=%5d ra2max=%9.3f %9.3f\n", n_dot, ra2max, dotarea);
  printf("neighbour list calculated/box(xyz):%d %d %d\n", nxbox, nybox, nzbox);
  for (i=0; i<nxyz; i++) printf("box %6d : atoms %4d-%4d    %5d\n",
    i, wkbox[i], wkbox[i+1]-1, wkbox[i+1]-wkbox[i]);
  for (i=0; i<nat; i++) {
    printf("list place %5d by atom %7d\n", i, wkatm[i]);
    }
#endif

/* calculate surface for all atoms, step cube-wise */
  for (iz=0; iz<nzbox; iz++) {
    iii = iz*nxy;
    izs = MAXIMUM(iz-1,0); ize = MINIMUM(iz+2, nzbox);
  for (iy=0; iy<nybox; iy++) {
    ii = iy*nxbox+iii;
    iys = MAXIMUM(iy-1,0); iye = MINIMUM(iy+2, nybox);
  for (ix=0; ix<nxbox; ix++) {
    i = ii+ix;
    iii1=wkbox[i]; iii2=wkbox[i+1];
    if (iii1 >= iii2) continue;
    ixs = MAXIMUM(ix-1,0); ixe = MINIMUM(ix+2, nxbox);

    iiat = 0;
/* make intermediate atom list */
    for (jz=izs; jz<ize; jz++) {
      jjj = jz*nxy;
    for (jy=iys; jy<iye; jy++) {
      jj = jy*nxbox+jjj;
    for (jx=ixs; jx<ixe; jx++) {
      j = jj+jx;
      for (jat=wkbox[j]; jat<wkbox[j+1]; jat++) {
        wkat1[iiat] = wkatm[jat]; iiat++;
        }     /* end of cycle "jat" */
      }       /* end of cycle "jx" */
      }       /* end of cycle "jy" */
      }       /* end of cycle "jz" */
    for (iat=iii1; iat<iii2; iat++) {
      i_at = wkatm[iat];
      ai = radius[i_at]; aisq = ai*ai;
      pco = co+3*i_at;
      xi = *pco; yi = *(pco+1); zi = *(pco+2);
      for (i=0; i<n_dot; i++) *(wkdot+i)=0;

      ctnb = wknb; nnei = 0;
      for (j=0; j<iiat; j++) {
        j_at = *(wkat1+j);
        if (j_at == i_at) continue;

        aj = radius[j_at]; ajsq = aj*aj;
        pco = co+3*j_at;
        dx = *pco-xi; dy = *(pco+1)-yi; dz = *(pco+2)-zi;
        dd = dx*dx+dy*dy+dz*dz;

        as = ai+aj; if (dd > as*as) continue;
        nnei++;
        ctnb->x = dx; ctnb->y = dy; ctnb->z = dz;
        ctnb->dot = (dd+aisq-ajsq)/(2.*ai); /* reference dot product */
        ctnb++;
        }

/* check points on accessibility */
      if (nnei) {
        last = 0; i_ac = 0;
        for (l=0; l<n_dot; l++) {
          if (xus[3*l]*(wknb+last)->x+
              xus[1+3*l]*(wknb+last)->y+
              xus[2+3*l]*(wknb+last)->z <= (wknb+last)->dot) {
            for (j=0; j<nnei; j++) {
              if (xus[3*l]*(wknb+j)->x+xus[1+3*l]*(wknb+j)->y+
                  xus[2+3*l]*(wknb+j)->z > (wknb+j)->dot) {
                last = j; break;
                }
              }
            if (j >= nnei) { i_ac++; wkdot[l] = 1; }
            }     /* end of cycle j */
          }       /* end of cycle l */
        }
      else {
        i_ac  = n_dot;
        for (l=0; l < n_dot; l++) wkdot[l] = 1;
        }

#if TEST_CUBE
      printf("i_ac=%d, dotarea=%8.3f, aisq=%8.3f\n", i_ac, dotarea, aisq);
#endif
      a = aisq*dotarea* (double) i_ac;
      area = area + a;
      if (mode & FLAG_ATOM_AREA) {
        atom_area[i_at] = a;
        }
      if (mode & FLAG_DOTS) {
        for (l=0; l<n_dot; l++) {
          if (wkdot[l]) {
            lfnr++;
            if (maxdots <= 3*lfnr+1) {
              maxdots = maxdots+n_dot*3;
              dots = (double *) REALLOC(dots, maxdots*sizeof(double));
              }
            dots[3*lfnr-3] = ai*xus[3*l]+xi;
            dots[3*lfnr-2] = ai*xus[1+3*l]+yi;
            dots[3*lfnr-1] = ai*xus[2+3*l]+zi;
            }
          }
        }
      if (mode & FLAG_VOLUME) {
        dx=0.; dy=0.; dz=0.;
        for (l=0; l<n_dot; l++) {
          if (wkdot[l]) {
            dx=dx+xus[3*l];
            dy=dy+xus[1+3*l];
            dz=dz+xus[2+3*l];
            }
          }
        vol = vol+aisq*(dx*(xi-xs)+dy*(yi-ys)+dz*(zi-zs)+ai* (double) i_ac);
        }

      }         /* end of cycle "iat" */
    }           /* end of cycle "ix" */
    }           /* end of cycle "iy" */
    }           /* end of cycle "iz" */

  free(wkatm); free(wkdot); free(wknb);

  if (mode & FLAG_VOLUME) {
    vol = vol*FOURPI/(3.* (double) n_dot);
    *value_of_vol = vol;
    }
  if (mode & FLAG_DOTS) {
    *nu_dots = lfnr;
    *lidots = dots;
    }
  if (mode & FLAG_ATOM_AREA) {
    *at_area = atom_area;
    }
  *value_of_area = area;

#if TEST_CUBE
  printf("area=%8.3f\n", area);
#endif
  return 0;
  }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x218, %rsp            # imm = 0x218
movq %r9, %rbx
movl %r8d, %ebp
movl %edx, %r12d
movq %rsi, 0x48(%rsp)
movq %rdi, 0x28(%rsp)
movl $0x1, %edx
movl $0xa, %esi
movl %esi, %eax
imull %edx, %eax
leal 0x2(%rax), %edi
incl %edx
addl $0xa, %esi
cmpl %ecx, %edi
jl 0x13717
movl $0x1, %edx
movl $0x1e, %esi
movl %esi, %edi
imull %edx, %edi
leal 0x2(%rdi), %r8d
incl %edx
addl $0x1e, %esi
cmpl %ecx, %r8d
jl 0x13732
xorl %esi, %esi
cmpl %edi, %eax
setb %sil
leal 0x9(%rsi), %eax
addl 0xeeda(%rip), %eax      # 0x22630
jne 0x13771
cmpl $0x4, 0xeed5(%rip)      # 0x22634
jne 0x13771
cmpl %ecx, 0xeec5(%rip)      # 0x2262c
je 0x13796
cmpl %ecx, 0xeeb9(%rip)      # 0x22628
je 0x13796
xorl $-0x9, %esi
leaq 0xeedd(%rip), %rdx      # 0x22658
movl %ecx, %edi
movl $0x4, %ecx
callq 0x132dd
movl %eax, %ecx
movl $0x1, %eax
testl %ecx, %ecx
jne 0x14805
testl %r12d, %r12d
je 0x14817
movq 0xee6a(%rip), %rax      # 0x22610
movq %rax, 0x158(%rsp)
movl 0xeea4(%rip), %ecx      # 0x22658
testb $0x1, %bpl
movl %ecx, 0xd8(%rsp)
je 0x13800
movl %r12d, %eax
imull %ecx, %eax
leal (%rax,%rax,2), %eax
cltq
imulq $0x66666667, %rax, %rcx # imm = 0x66666667
movq %rcx, %rax
shrq $0x3f, %rax
sarq $0x22, %rcx
addl %eax, %ecx
movq %rcx, 0x18(%rsp)
movslq %ecx, %rdx
leaq 0x716a(%rip), %rdi      # 0x1a959
movl $0x8, %ecx
movl $0x235, %esi            # imm = 0x235
callq 0x1139d
jmp 0x13807
xorl %eax, %eax
movq %rcx, 0x18(%rsp)
movq %rax, 0x8(%rsp)
movslq %r12d, %r15
testb $0x4, %bpl
jne 0x13823
movq $0x0, 0xd0(%rsp)
jmp 0x13844
leaq 0x712f(%rip), %rdi      # 0x1a959
movl $0x8, %ecx
movl $0x239, %esi            # imm = 0x239
movq %r15, %rdx
callq 0x1139d
movq %rax, 0xd0(%rsp)
movq 0x48(%rsp), %rdx
movq 0x28(%rsp), %rax
movupd (%rax), %xmm6
movsd 0x10(%rax), %xmm7
movsd (%rdx), %xmm4
movl %r12d, %esi
cmpl $0x2, %r12d
movl %ebp, 0x4(%rsp)
movq %rbx, 0x190(%rsp)
jl 0x138bf
addq $0x28, %rax
movl $0x1, %ecx
movapd %xmm7, %xmm8
movapd %xmm7, %xmm2
movapd %xmm6, %xmm5
movapd %xmm6, %xmm3
movupd -0x10(%rax), %xmm0
minpd %xmm0, %xmm5
maxpd %xmm0, %xmm6
movsd (%rax), %xmm1
minsd %xmm1, %xmm8
maxsd %xmm1, %xmm7
addpd %xmm0, %xmm3
maxsd (%rdx,%rcx,8), %xmm4
addsd %xmm1, %xmm2
incq %rcx
addq $0x18, %rax
cmpq %rcx, %rsi
jne 0x1388a
jmp 0x138d0
movapd %xmm7, %xmm2
movapd %xmm7, %xmm8
movapd %xmm6, %xmm5
movapd %xmm6, %xmm3
movapd %xmm8, 0x110(%rsp)
movapd %xmm7, 0x50(%rsp)
movapd %xmm3, 0x170(%rsp)
movsd %xmm2, 0x88(%rsp)
addsd %xmm4, %xmm4
movapd %xmm4, 0x70(%rsp)
movapd %xmm5, 0x130(%rsp)
subpd %xmm5, %xmm6
unpcklpd %xmm4, %xmm4            # xmm4 = xmm4[0,0]
movapd %xmm6, 0xa0(%rsp)
movapd %xmm6, %xmm0
movapd %xmm4, 0x120(%rsp)
divpd %xmm4, %xmm0
movapd %xmm0, 0xb0(%rsp)
movq %rsi, 0x20(%rsp)
callq 0x2260
movapd %xmm0, 0x180(%rsp)
movapd 0xb0(%rsp), %xmm0
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
callq 0x2260
movapd 0x180(%rsp), %xmm1
unpcklpd %xmm0, %xmm1            # xmm1 = xmm1[0],xmm0[0]
maxpd 0x6ec6(%rip), %xmm1     # 0x1a830
cvttpd2dq %xmm1, %xmm0
pshufd $0x55, %xmm0, %xmm1     # xmm1 = xmm0[1,1,1,1]
movdqa %xmm1, 0x100(%rsp)
movd %xmm1, %ebx
movaps %xmm0, 0x90(%rsp)
movd %xmm0, %r14d
movapd 0x50(%rsp), %xmm0
subsd 0x110(%rsp), %xmm0
movapd %xmm0, 0x50(%rsp)
divsd 0x70(%rsp), %xmm0
callq 0x2260
maxsd 0x5eb3(%rip), %xmm0     # 0x19868
cvttsd2si %xmm0, %eax
movq %r14, 0xc8(%rsp)
movl %r14d, %ecx
movl %ebx, 0x68(%rsp)
imull %ebx, %ecx
movl %ecx, 0x10(%rsp)
movl %ecx, %r14d
movl %eax, 0x34(%rsp)
imull %eax, %r14d
leal (%r12,%r12,2), %eax
movslq %eax, %rdx
leaq 0x6f71(%rip), %rbp      # 0x1a959
movl $0x4, %ecx
movq %rbp, %rdi
movl $0x25f, %esi            # imm = 0x25F
callq 0x1139d
movq %rax, %rbx
leaq (%rax,%r15,4), %r15
movl 0xec51(%rip), %eax      # 0x22658
movq %r14, 0xe0(%rsp)
leal 0x1(%r14,%rax), %eax
movslq %eax, %rdx
movl $0x4, %ecx
movq %rbp, %rdi
movl $0x261, %esi            # imm = 0x261
callq 0x1139d
movapd 0x70(%rsp), %xmm3
movslq 0xec22(%rip), %rcx      # 0x22658
movq %rax, 0xb0(%rsp)
leaq (%rax,%rcx,4), %rdi
movq %r12, 0x40(%rsp)
testl %r12d, %r12d
movq %rdi, 0x80(%rsp)
jle 0x13c0b
movq 0xc8(%rsp), %rax
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
mulsd %xmm3, %xmm0
movapd 0xa0(%rsp), %xmm5
subsd %xmm5, %xmm0
mulsd 0x6e58(%rip), %xmm0     # 0x1a8d8
movapd 0x130(%rsp), %xmm4
addsd %xmm4, %xmm0
movsd %xmm0, 0x160(%rsp)
movss 0x34(%rsp), %xmm0
unpcklpd 0x100(%rsp), %xmm0      # xmm0 = xmm0[0],mem[0]
movaps 0x90(%rsp), %xmm2
shufps $0x52, %xmm2, %xmm0     # xmm0 = xmm0[2,0],xmm2[1,1]
cvtdq2pd %xmm0, %xmm1
shufpd $0x1, 0x50(%rsp), %xmm5 # xmm5 = xmm5[1],mem[0]
mulpd 0x120(%rsp), %xmm1
subpd %xmm5, %xmm1
mulpd 0x6d6f(%rip), %xmm1     # 0x1a840
shufpd $0x1, 0x110(%rsp), %xmm4 # xmm4 = xmm4[1],mem[0]
addpd %xmm1, %xmm4
movapd %xmm4, 0x130(%rsp)
leal -0x1(%rax), %ebp
pcmpeqd %xmm1, %xmm1
paddd %xmm0, %xmm1
movdqa %xmm1, 0xa0(%rsp)
movss 0x10(%rsp), %xmm0
movlhps %xmm2, %xmm0            # xmm0 = xmm0[0],xmm2[0]
shufps $0xe2, %xmm2, %xmm0     # xmm0 = xmm0[2,0],xmm2[2,3]
movaps %xmm0, 0x100(%rsp)
movq 0x28(%rsp), %rax
leaq 0x8(%rax), %r14
xorl %r13d, %r13d
movsd -0x8(%r14), %xmm0
subsd 0x160(%rsp), %xmm0
divsd %xmm3, %xmm0
callq 0x21e0
maxsd 0x6d53(%rip), %xmm0     # 0x1a890
cvttsd2si %xmm0, %r12d
cmpl %ebp, %r12d
cmovgel %ebp, %r12d
movupd (%r14), %xmm0
subpd 0x130(%rsp), %xmm0
divpd 0x120(%rsp), %xmm0
movapd %xmm0, 0x110(%rsp)
callq 0x21e0
movapd %xmm0, 0x50(%rsp)
movapd 0x110(%rsp), %xmm0
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
callq 0x21e0
movapd 0x70(%rsp), %xmm3
movq 0x80(%rsp), %rdi
movapd 0x50(%rsp), %xmm1
unpcklpd %xmm0, %xmm1            # xmm1 = xmm1[0],xmm0[0]
maxpd 0x64da(%rip), %xmm1     # 0x1a080
cvttpd2dq %xmm1, %xmm0
movdqa 0xa0(%rsp), %xmm2
movdqa %xmm2, %xmm1
pcmpgtd %xmm0, %xmm1
pand %xmm1, %xmm0
pandn %xmm2, %xmm1
por %xmm0, %xmm1
pshufd $0xf5, %xmm1, %xmm0     # xmm0 = xmm1[1,1,3,3]
movdqa 0x100(%rsp), %xmm4
pshufd $0xf5, %xmm4, %xmm2     # xmm2 = xmm4[1,1,3,3]
pmuludq %xmm0, %xmm2
pmuludq %xmm4, %xmm1
movd %xmm1, %eax
addl %r12d, %eax
movd %xmm2, %ecx
addl %eax, %ecx
movslq %ecx, %rax
incl (%rdi,%rax,4)
movl %ecx, (%r15,%r13,4)
incq %r13
addq $0x18, %r14
cmpq %r13, 0x20(%rsp)
jne 0x13b1d
movq 0x20(%rsp), %r12
movl (%rdi), %eax
movq 0xe0(%rsp), %r8
cmpl $0x2, %r8d
jl 0x13c38
movl %r8d, %ecx
movl $0x1, %edx
movl (%rdi,%rdx,4), %esi
cmpl %eax, %esi
cmovgl %esi, %eax
incq %rdx
cmpq %rdx, %rcx
jne 0x13c28
testl %r8d, %r8d
movq 0x40(%rsp), %r14
jle 0x13c5a
incl %r8d
movl (%rdi), %ecx
movl $0x1, %edx
addl (%rdi,%rdx,4), %ecx
movl %ecx, (%rdi,%rdx,4)
incq %rdx
cmpq %rdx, %r8
jne 0x13c4c
leal (%rax,%rax,8), %eax
leal (%rax,%rax,2), %eax
cmpl %r14d, %eax
cmovgel %r14d, %eax
movslq %eax, %rdx
leaq 0x6ce8(%rip), %rdi      # 0x1a959
movl $0x20, %ecx
movl $0x274, %esi            # imm = 0x274
callq 0x1139d
movq 0x80(%rsp), %rdi
movq %rax, 0x50(%rsp)
testl %r14d, %r14d
jle 0x13caf
xorl %eax, %eax
movslq (%r15,%rax,4), %rcx
movslq (%rdi,%rcx,4), %rdx
leaq -0x1(%rdx), %rsi
movl %esi, (%rdi,%rcx,4)
movl %eax, -0x4(%rbx,%rdx,4)
incq %rax
cmpq %rax, %r12
jne 0x13c94
movl 0x34(%rsp), %ecx
testl %ecx, %ecx
movq 0x18(%rsp), %r9
movsd 0x88(%rsp), %xmm7
jle 0x14753
xorps %xmm0, %xmm0
cvtsi2sdl 0xd8(%rsp), %xmm0
movsd 0x6bf3(%rip), %xmm1     # 0x1a8d0
divsd %xmm0, %xmm1
movsd %xmm1, 0x1f0(%rsp)
xorps %xmm0, %xmm0
cvtsi2sd %r14d, %xmm0
movapd 0x170(%rsp), %xmm1
movapd %xmm1, %xmm2
unpckhpd %xmm1, %xmm2            # xmm2 = xmm2[1],xmm1[1]
divsd %xmm0, %xmm1
movapd %xmm1, 0x170(%rsp)
divsd %xmm0, %xmm2
movapd %xmm2, 0x200(%rsp)
divsd %xmm0, %xmm7
pshufd $0x50, 0x90(%rsp), %xmm0 # xmm0 = mem[0,0,1,1]
xorpd %xmm1, %xmm1
pcmpgtd %xmm1, %xmm0
movmskpd %xmm0, %eax
movl %eax, 0xec(%rsp)
shrb %al
movb %al, 0x3(%rsp)
movq 0xc8(%rsp), %rax
movslq %eax, %rdx
movq %rdx, 0x130(%rsp)
movl 0x10(%rsp), %esi
movslq %esi, %rdx
movq %rdx, 0x1d8(%rsp)
movl %eax, %eax
movq %rax, 0x140(%rsp)
movl %esi, %eax
movq %rax, 0x198(%rsp)
movl %ecx, %eax
movq %rax, 0x1a0(%rsp)
movl 0x68(%rsp), %eax
movq %rax, 0x1b8(%rsp)
movq 0x50(%rsp), %rax
addq $0x38, %rax
movq %rax, 0xe0(%rsp)
movq 0x158(%rsp), %rax
addq $0x10, %rax
movq %rax, 0x150(%rsp)
xorl %esi, %esi
xorpd %xmm0, %xmm0
movsd %xmm0, 0x38(%rsp)
movdqa 0x5af6(%rip), %xmm8     # 0x198c0
pcmpeqd %xmm9, %xmm9
movsd %xmm0, 0x40(%rsp)
xorl %ecx, %ecx
movq 0x8(%rsp), %rdx
movsd %xmm7, 0x88(%rsp)
movq %r15, 0x180(%rsp)
cmpl $0x2, %esi
movl $0x1, %eax
cmovgel %esi, %eax
cmpb $0x0, 0x3(%rsp)
movq %rsi, 0x1a8(%rsp)
je 0x14722
decq %rax
movq %rax, 0x1c8(%rsp)
movq %rsi, %rax
imulq 0x198(%rsp), %rax
movq %rax, 0x1b0(%rsp)
leal 0x2(%rsi), %edi
movl 0x34(%rsp), %eax
cmpl %eax, %edi
cmovgel %eax, %edi
cmpl $0x2, %esi
movl $0x1, %eax
cmovgel %esi, %eax
movl %eax, 0xf0(%rsp)
movl %edi, 0xf4(%rsp)
movslq %edi, %rax
movq %rax, 0x1f8(%rsp)
xorl %esi, %esi
cmpl $0x2, %esi
movl $0x1, %eax
cmovgel %esi, %eax
testb $0x1, 0xec(%rsp)
movq %rsi, 0x1c0(%rsp)
je 0x14709
decq %rax
movq %rax, 0x1e0(%rsp)
leal 0x2(%rsi), %edi
movl 0x68(%rsp), %eax
cmpl %eax, %edi
cmovgel %eax, %edi
cmpl $0x2, %esi
movl $0x1, %eax
cmovgel %esi, %eax
movl %eax, 0xf8(%rsp)
movl %esi, %eax
imull 0x140(%rsp), %eax
addl 0x1b0(%rsp), %eax
movl %edi, 0xfc(%rsp)
movslq %edi, %rsi
movq %rsi, 0x110(%rsp)
movq %rcx, %rsi
movq 0x80(%rsp), %rcx
leaq (%rcx,%rax,4), %rax
movq %rax, 0x1d0(%rsp)
movq %rsi, %rcx
xorl %esi, %esi
cmpl $0x2, %esi
movl $0x1, %eax
cmovgel %esi, %eax
movq %rax, 0x70(%rsp)
movq 0x1d0(%rsp), %rax
movslq (%rax,%rsi,4), %rdi
movq %rsi, 0x148(%rsp)
movl 0x4(%rax,%rsi,4), %eax
movl %eax, 0x6c(%rsp)
cmpl %eax, %edi
jge 0x146f0
movq %rdi, 0x10(%rsp)
movq %rcx, 0x90(%rsp)
movq %r9, 0x18(%rsp)
movq %rdx, 0x8(%rsp)
xorl %r12d, %r12d
movl 0xf0(%rsp), %eax
cmpl 0xf4(%rsp), %eax
jg 0x14027
decq 0x70(%rsp)
movq 0x148(%rsp), %rsi
leal 0x2(%rsi), %ecx
movq 0xc8(%rsp), %rax
cmpl %eax, %ecx
cmovgel %eax, %ecx
cmpl $0x2, %esi
movl $0x1, %edx
cmovgel %esi, %edx
movslq %ecx, %rsi
xorl %r12d, %r12d
movq 0x1c8(%rsp), %rdi
movl 0xf8(%rsp), %eax
cmpl 0xfc(%rsp), %eax
movq %rdi, 0x20(%rsp)
jg 0x14011
movq %rdi, %rax
imulq 0x1d8(%rsp), %rax
movq 0x80(%rsp), %rdi
leaq (%rdi,%rax,4), %r8
movq 0x1e0(%rsp), %r9
cmpl %ecx, %edx
jg 0x14004
movq %r9, %rax
imulq 0x130(%rsp), %rax
leaq (%r8,%rax,4), %r10
movq 0x70(%rsp), %r11
movslq (%r10,%r11,4), %rbp
movslq 0x4(%r10,%r11,4), %r14
cmpl %r14d, %ebp
jge 0x13ffc
movslq %r12d, %rax
leaq (%r15,%rax,4), %r13
leaq (%rbx,%rbp,4), %rax
subq %rbp, %r14
xorl %ebp, %ebp
movl (%rax,%rbp,4), %edi
movl %edi, (%r13,%rbp,4)
incq %rbp
cmpq %rbp, %r14
jne 0x13fe9
addl %ebp, %r12d
incq %r11
cmpq %rsi, %r11
jl 0x13fcb
incq %r9
cmpq 0x110(%rsp), %r9
jl 0x13fb2
movq 0x20(%rsp), %rdi
incq %rdi
cmpq 0x1f8(%rsp), %rdi
jl 0x13f7d
movq 0x10(%rsp), %r14
cmpl 0x6c(%rsp), %r14d
jge 0x146de
movl %r12d, %eax
movq %rax, 0x1e8(%rsp)
movq 0x48(%rsp), %r10
movq 0x28(%rsp), %r8
movq 0x8(%rsp), %rdx
movq 0x18(%rsp), %r9
movq 0xb0(%rsp), %rdi
movq 0x90(%rsp), %rcx
movq %rcx, 0x90(%rsp)
movq %r9, 0x18(%rsp)
movq %rdx, 0x8(%rsp)
movq %r14, 0x10(%rsp)
movslq (%rbx,%r14,4), %r13
movsd (%r10,%r13,8), %xmm10
leaq (%r13,%r13,2), %rax
movupd (%r8,%rax,8), %xmm12
movsd 0x10(%r8,%rax,8), %xmm11
movslq 0xe5b8(%rip), %r14      # 0x22658
testq %r14, %r14
movsd %xmm10, 0x20(%rsp)
movsd %xmm11, 0x120(%rsp)
movapd %xmm12, 0x160(%rsp)
jle 0x14113
leaq (,%r14,4), %rdx
xorl %esi, %esi
callq 0x20f0
movapd 0x160(%rsp), %xmm12
movsd 0x120(%rsp), %xmm11
movsd 0x20(%rsp), %xmm10
pcmpeqd %xmm9, %xmm9
movdqa 0x57c8(%rip), %xmm8     # 0x198c0
movq 0xb0(%rsp), %rdi
movsd 0x88(%rsp), %xmm7
movq 0x28(%rsp), %r8
movq 0x48(%rsp), %r10
movapd %xmm10, %xmm0
mulsd %xmm10, %xmm0
movsd %xmm0, 0x70(%rsp)
testl %r12d, %r12d
jle 0x141e2
movapd %xmm10, %xmm0
addsd %xmm10, %xmm0
xorl %ecx, %ecx
xorl %eax, %eax
movq 0x50(%rsp), %rdx
movq 0x1e8(%rsp), %r9
movslq (%r15,%rcx,4), %rsi
cmpl %r13d, %esi
je 0x141d4
movsd (%r10,%rsi,8), %xmm1
leal (%rsi,%rsi,2), %esi
movslq %esi, %rsi
movupd (%r8,%rsi,8), %xmm2
subpd %xmm12, %xmm2
movsd 0x10(%r8,%rsi,8), %xmm3
subsd %xmm11, %xmm3
movapd %xmm2, %xmm4
mulpd %xmm2, %xmm4
unpckhpd %xmm4, %xmm4            # xmm4 = xmm4[1,1]
movapd %xmm2, %xmm5
mulsd %xmm2, %xmm5
addsd %xmm4, %xmm5
movapd %xmm3, %xmm4
mulsd %xmm3, %xmm4
addsd %xmm5, %xmm4
movapd %xmm10, %xmm5
addsd %xmm1, %xmm5
mulsd %xmm5, %xmm5
ucomisd %xmm5, %xmm4
ja 0x141d4
mulsd %xmm1, %xmm1
incl %eax
movupd %xmm2, (%rdx)
movsd %xmm3, 0x10(%rdx)
addsd 0x70(%rsp), %xmm4
subsd %xmm1, %xmm4
divsd %xmm0, %xmm4
movsd %xmm4, 0x18(%rdx)
addq $0x20, %rdx
incq %rcx
cmpq %rcx, %r9
jne 0x14147
jmp 0x141e4
xorl %eax, %eax
testl %eax, %eax
je 0x1434c
testl %r14d, %r14d
jle 0x1444d
testl %eax, %eax
setg %dl
movslq %eax, %rcx
movq %rcx, 0xa0(%rsp)
movl %eax, %edi
decq %rdi
xorl %r8d, %r8d
xorl %ecx, %ecx
xorl %r9d, %r9d
leaq (%r8,%r8,2), %r10
movq 0x158(%rsp), %rbp
movsd (%rbp,%r10,8), %xmm0
movsd 0x8(%rbp,%r10,8), %xmm1
movslq %r9d, %r11
shlq $0x5, %r11
movq 0x50(%rsp), %rsi
movsd 0x8(%rsi,%r11), %xmm2
mulsd %xmm1, %xmm2
movsd (%rsi,%r11), %xmm3
mulsd %xmm0, %xmm3
addsd %xmm2, %xmm3
movsd 0x10(%rbp,%r10,8), %xmm2
movsd 0x10(%rsi,%r11), %xmm4
mulsd %xmm2, %xmm4
addsd %xmm3, %xmm4
movsd 0x18(%rsi,%r11), %xmm3
ucomisd %xmm4, %xmm3
jae 0x1427c
movl %r9d, %r10d
jmp 0x14338
testl %eax, %eax
jle 0x1430a
movq 0x50(%rsp), %rsi
movsd 0x8(%rsi), %xmm3
mulsd %xmm1, %xmm3
movsd (%rsi), %xmm4
mulsd %xmm0, %xmm4
addsd %xmm3, %xmm4
movsd 0x10(%rsi), %xmm3
mulsd %xmm2, %xmm3
addsd %xmm4, %xmm3
xorl %r10d, %r10d
ucomisd 0x18(%rsi), %xmm3
movl %edx, %r11d
ja 0x14321
movq 0xe0(%rsp), %r11
xorl %r10d, %r10d
cmpq %r10, %rdi
je 0x1430f
movsd -0x10(%r11), %xmm3
mulsd %xmm1, %xmm3
movsd -0x18(%r11), %xmm4
mulsd %xmm0, %xmm4
addsd %xmm3, %xmm4
movsd -0x8(%r11), %xmm3
mulsd %xmm2, %xmm3
addsd %xmm4, %xmm3
incq %r10
ucomisd (%r11), %xmm3
leaq 0x20(%r11), %r11
jbe 0x142c3
cmpq 0xa0(%rsp), %r10
setl %r11b
jmp 0x14321
movl %edx, %r11d
jmp 0x1431e
incq %r10
cmpq 0xa0(%rsp), %r10
setl %r11b
movl %r9d, %r10d
testb %r11b, %r11b
jne 0x14338
incl %ecx
movq 0xb0(%rsp), %r9
movl $0x1, (%r9,%r8,4)
incq %r8
movl %r10d, %r9d
cmpq %r14, %r8
jne 0x14212
jmp 0x1444f
testl %r14d, %r14d
jle 0x14448
leal 0x3(%r14), %eax
movq %r14, %rcx
decq %rcx
movq %rcx, %xmm0
pshufd $0x44, %xmm0, %xmm0     # xmm0 = xmm0[0,1,0,1]
shrl $0x2, %eax
shlq $0x4, %rax
xorl %ecx, %ecx
movdqa 0x5956(%rip), %xmm1     # 0x19cd0
movdqa 0x64ce(%rip), %xmm2     # 0x1a850
movdqa %xmm0, %xmm3
pxor %xmm8, %xmm3
movdqa %xmm1, %xmm4
pxor %xmm8, %xmm4
movdqa %xmm4, %xmm5
pcmpgtd %xmm3, %xmm5
pcmpeqd %xmm3, %xmm4
pshufd $0xf5, %xmm4, %xmm6     # xmm6 = xmm4[1,1,3,3]
pand %xmm5, %xmm6
pshufd $0xf5, %xmm5, %xmm4     # xmm4 = xmm5[1,1,3,3]
por %xmm6, %xmm4
movd %xmm4, %edx
notl %edx
testb $0x1, %dl
je 0x143c4
movl $0x1, (%rdi,%rcx)
pxor %xmm9, %xmm4
pextrw $0x4, %xmm4, %edx
testb $0x1, %dl
je 0x143db
movl $0x1, 0x4(%rdi,%rcx)
movdqa %xmm2, %xmm4
pxor %xmm8, %xmm4
movdqa %xmm4, %xmm5
pcmpgtd %xmm3, %xmm5
pcmpeqd %xmm3, %xmm4
pshufd $0xf5, %xmm4, %xmm4     # xmm4 = xmm4[1,1,3,3]
pand %xmm5, %xmm4
pshufd $0xf5, %xmm5, %xmm3     # xmm3 = xmm5[1,1,3,3]
por %xmm4, %xmm3
pxor %xmm9, %xmm3
pextrw $0x0, %xmm3, %edx
testb $0x1, %dl
je 0x14419
movl $0x1, 0x8(%rdi,%rcx)
pextrw $0x4, %xmm3, %edx
testb $0x1, %dl
je 0x1442b
movl $0x1, 0xc(%rdi,%rcx)
movdqa 0x642d(%rip), %xmm3     # 0x1a860
paddq %xmm3, %xmm1
paddq %xmm3, %xmm2
addq $0x10, %rcx
cmpq %rcx, %rax
jne 0x14382
movl %r14d, %ecx
jmp 0x1444f
xorl %ecx, %ecx
movsd 0x1f0(%rsp), %xmm0
mulsd 0x70(%rsp), %xmm0
xorps %xmm1, %xmm1
cvtsi2sd %ecx, %xmm1
movsd %xmm1, 0xd8(%rsp)
mulsd %xmm1, %xmm0
movsd %xmm0, 0x100(%rsp)
testb $0x4, 0x4(%rsp)
je 0x14499
movq 0xd0(%rsp), %rax
movsd 0x100(%rsp), %xmm0
movsd %xmm0, (%rax,%r13,8)
movl 0xe1b9(%rip), %eax      # 0x22658
testl %eax, %eax
setg %cl
andb 0x4(%rsp), %cl
movapd %xmm12, %xmm3
unpckhpd %xmm12, %xmm3           # xmm3 = xmm3[1],xmm12[1]
cmpb $0x1, %cl
movq 0x48(%rsp), %r10
movq 0x28(%rsp), %r8
movq 0x8(%rsp), %rdx
movq 0x18(%rsp), %r9
movq 0xb0(%rsp), %rdi
jne 0x145f0
movq 0x150(%rsp), %r14
xorl %r13d, %r13d
movq 0x90(%rsp), %rcx
movapd %xmm3, 0xa0(%rsp)
cmpl $0x0, (%rdi,%r13,4)
je 0x145d7
movq %rbx, %r15
incl %ecx
movq %rcx, %rbx
leal (%rcx,%rcx,2), %ecx
incl %ecx
cmpl %ecx, %r9d
jg 0x14584
leal (%rax,%rax,2), %eax
addl %eax, %r9d
movslq %r9d, %rcx
shlq $0x3, %rcx
leaq 0x6435(%rip), %rdi      # 0x1a959
movl $0x2dc, %esi            # imm = 0x2DC
movq %r9, %rbp
callq 0x113f0
movapd 0xa0(%rsp), %xmm3
movapd 0x160(%rsp), %xmm12
movsd 0x120(%rsp), %xmm11
movsd 0x20(%rsp), %xmm10
pcmpeqd %xmm9, %xmm9
movdqa 0x535d(%rip), %xmm8     # 0x198c0
movq 0xb0(%rsp), %rdi
movsd 0x88(%rsp), %xmm7
movq %rbp, %r9
movq 0x28(%rsp), %r8
movq 0x48(%rsp), %r10
movq %rax, %rdx
movq %rbx, %rcx
leal (%rbx,%rbx,2), %eax
movsd -0x10(%r14), %xmm0
mulsd %xmm10, %xmm0
addsd %xmm12, %xmm0
cltq
movsd %xmm0, -0x18(%rdx,%rax,8)
movsd -0x8(%r14), %xmm0
mulsd %xmm10, %xmm0
addsd %xmm3, %xmm0
movsd %xmm0, -0x10(%rdx,%rax,8)
movsd (%r14), %xmm0
mulsd %xmm10, %xmm0
addsd %xmm11, %xmm0
movsd %xmm0, -0x8(%rdx,%rax,8)
movq %r15, %rbx
movq 0x180(%rsp), %r15
incq %r13
movslq 0xe077(%rip), %rax      # 0x22658
addq $0x18, %r14
cmpq %rax, %r13
jl 0x144f3
jmp 0x145f8
movq 0x90(%rsp), %rcx
testb $0x2, 0x4(%rsp)
jne 0x14609
movq 0x10(%rsp), %r14
jmp 0x146b9
movq %rdx, %rsi
movslq 0xe045(%rip), %rax      # 0x22658
testq %rax, %rax
movq 0x10(%rsp), %r14
movq %rcx, %r11
xorpd %xmm1, %xmm1
xorpd %xmm0, %xmm0
jle 0x14651
movq 0x150(%rsp), %rcx
xorl %edx, %edx
cmpl $0x0, (%rdi,%rdx,4)
je 0x14645
movupd -0x10(%rcx), %xmm2
addpd %xmm2, %xmm1
addsd (%rcx), %xmm0
incq %rdx
addq $0x18, %rcx
cmpq %rdx, %rax
jne 0x14632
subsd 0x170(%rsp), %xmm12
subsd 0x200(%rsp), %xmm3
movapd %xmm1, %xmm2
unpckhpd %xmm1, %xmm2            # xmm2 = xmm2[1],xmm1[1]
mulsd %xmm3, %xmm2
mulsd %xmm1, %xmm12
addsd %xmm2, %xmm12
subsd %xmm7, %xmm11
mulsd %xmm0, %xmm11
addsd %xmm12, %xmm11
mulsd 0xd8(%rsp), %xmm10
addsd %xmm11, %xmm10
movsd 0x70(%rsp), %xmm1
mulsd %xmm10, %xmm1
movsd 0x38(%rsp), %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, 0x38(%rsp)
movq %rsi, %rdx
movq %r11, %rcx
movsd 0x40(%rsp), %xmm0
addsd 0x100(%rsp), %xmm0
movsd %xmm0, 0x40(%rsp)
incq %r14
cmpl %r14d, 0x6c(%rsp)
jne 0x14066
jmp 0x146f0
movq 0x8(%rsp), %rdx
movq 0x18(%rsp), %r9
movq 0x90(%rsp), %rcx
movq 0x148(%rsp), %rsi
incq %rsi
cmpq 0x140(%rsp), %rsi
jne 0x13ee5
movq 0x1c0(%rsp), %rsi
incq %rsi
cmpq 0x1b8(%rsp), %rsi
jne 0x13e5c
movq 0x1a8(%rsp), %rsi
incq %rsi
cmpq 0x1a0(%rsp), %rsi
jne 0x13ded
movq %rcx, %r14
movq %rdx, 0x8(%rsp)
movsd 0x38(%rsp), %xmm0
mulsd 0x617f(%rip), %xmm0     # 0x1a8d0
jmp 0x14760
xorpd %xmm0, %xmm0
movsd %xmm0, 0x40(%rsp)
xorl %r14d, %r14d
movsd %xmm0, 0x38(%rsp)
movq %rbx, %rdi
callq 0x2040
movq 0xb0(%rsp), %rdi
callq 0x2040
movq 0x50(%rsp), %rdi
callq 0x2040
testb $0x2, 0x4(%rsp)
movq 0x250(%rsp), %rcx
movq 0x260(%rsp), %rdx
movq 0x268(%rsp), %rsi
movq 0x258(%rsp), %rax
je 0x147cd
xorps %xmm0, %xmm0
cvtsi2sdl 0xdea1(%rip), %xmm0 # 0x22658
mulsd 0x5379(%rip), %xmm0     # 0x19b38
movsd 0x38(%rsp), %xmm1
divsd %xmm0, %xmm1
movsd %xmm1, (%rax)
testb $0x1, 0x4(%rsp)
movq 0x190(%rsp), %rax
je 0x147e7
movl %r14d, (%rsi)
movq 0x8(%rsp), %rsi
movq %rsi, (%rdx)
testb $0x4, 0x4(%rsp)
je 0x147f9
movq 0xd0(%rsp), %rdx
movq %rdx, (%rcx)
movsd 0x40(%rsp), %xmm0
movsd %xmm0, (%rax)
xorl %eax, %eax
addq $0x218, %rsp            # imm = 0x218
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x2711
movl $0x1, %eax
jmp 0x14805
nop