// File: /workspace/github_c_makefile_star2_O1/radforddc[P]icpc_siggen/calc_signal.c
// Function: make_signal
int make_signal(point pt, float *signal, float q, MJD_Siggen_Setup *setup) {
  float  wpot, wpot2=0, dwpot=0;
  char   tmpstr[MAX_LINE];
  point  new_pt;
  vector v, dx;
  float  vel0, vel1 = 0, wpot_old=-1;
  // double diffusion_coeff;
  double repulsion_fact = 0.0, ds2, ds3, dv, ds_dt;
  int    ntsteps, i, t, n, collect2pc, low_field=0, surface_drift=0, stop_drifting = 0;

  new_pt = pt;
  if (setup->impurity_z0 != 0.0) {
    collect2pc = ((q > 0 && setup->impurity_z0 < 0) ||  // holes for p-type 
                  (q < 0 && setup->impurity_z0 > 0));   // electrons for n-type
  } else {                                                // sometimes the impurity_z0 values can be commented out
    collect2pc = ((q > 0 && setup->efld[0][2 + (int)(setup->pc_length/setup->xtal_grid)].z < 0) ||  // holes for p-type 
                  (q < 0 && setup->efld[0][2 + (int)(setup->pc_length/setup->xtal_grid)].z > 0));   // electrons for n-type
  }
  /*
  if (q > 0) {
    diffusion_coeff = TWO_TIMES_DIFFUSION_COEF_H;
  } else {
    diffusion_coeff = TWO_TIMES_DIFFUSION_COEF_E;
  }
  */
  ntsteps = setup->time_steps_calc;
  for (t = 0; drift_velocity(new_pt, q, &v, setup) >= 0 && !stop_drifting; t++) { 
    if (q > 0) {
      setup->dpath_h[t] = new_pt;
    } else {
      setup->dpath_e[t] = new_pt;
    }
    if (collect2pc) {
      if (t == 0) {
	vel1 = setup->final_vel = setup->initial_vel = vector_length(v);
	setup->final_charge_size = setup->charge_cloud_size;
	if (setup->use_diffusion) {
	  if (setup->final_charge_size < 0.01) setup->final_charge_size = 0.01;
	  /* for a spherically symmetric charge cloud, the equivalent
	     delta-E at a distance of 1 sigma from the cloud center is
	     dE = Q/(4*pi*epsilon*sigma^2)  (Q is charge inside the 3D 1-sigma envelope)
	     dE (V/cm) = Q (C) * 1/(4*pi*epsilon) (N m2 / C2) / sigma2 (mm2)
	     1 V/m = 1 N/C
	     dE (V/cm) = Q (C) * 1/(4*pi*epsilon) (V m / C) / sigma2 (mm2)
	     dE (V/cm) = repulsion_fact * FWHM/sigma / (FWHM^2) (mm2), so
	     repulsion_fact = (FWHM/sigma)^3 * Q (C) * 1/(4*pi*epsilon) (V m / C) * mm/m * mm/cm
	  */
	  if (setup->energy > 0.1) {  // set up charge cloud self-repulsion
	    repulsion_fact = setup->energy * 0.67*0.67*0.67 / 0.003; // charge in 1 sigma (3D)
	    repulsion_fact /= 6.241e18;        // convert to Coulombs
	    repulsion_fact *= 9.0e13/16.0;     // 1/(4*pi*epsilon)  (N m2 / C2) * 1e4
	    repulsion_fact *= 2.355*2.355*2.355;      // convert FWHM to sigma
	  }
	}
	TELL_CHATTY("initial v: %f (%e %e %e)\n",
		    setup->initial_vel, v.x, v.y, v.z);
      } else if (setup->use_diffusion) {
	vel0 = vel1;
	vel1 = vector_length(v);
	setup->final_charge_size *= vel1/vel0;  // effect of acceleration
	// include effects of acceleration and diffusion on cloud size
	dv = repulsion_fact * setup->dv_dE /        // effect of repulsion
	        (setup->final_charge_size*setup->final_charge_size);
	// FIXME? this next line could more more fine-grained
	if (dv > 0.05) dv = 0.05;  // on account of drift velocity saturation
	ds_dt = dv + DIFFUSION_COEF/setup->final_charge_size;  // effect of diffusion
	if (ds_dt > 0.05 || ds_dt * setup->step_time_calc > 0.1) {
	  // nonlinear growth due to small size; need more careful calculation
	  TELL_CHATTY("ds_dt = %.2f; size = %.2f", ds_dt, setup->final_charge_size);
	  // ds_dt = 0.05;  // artificially limit nonlinear growth
	  ds2 = 2.0 * DIFFUSION_COEF * setup->step_time_calc; // increase^2 from diff.
	  ds3 = (setup->final_charge_size*setup->final_charge_size *
		 (setup->final_charge_size +
		  3.0 * dv * setup->step_time_calc));         // FWHM^3 after repulsion
	  setup->final_charge_size = sqrt(ds2 + pow(ds3, 0.6667)); 
	  TELL_CHATTY(" -> %.2f\n", setup->final_charge_size);
	} else {
	  setup->final_charge_size +=  ds_dt * setup->step_time_calc;  // effect of diff. + rep.
	}
      }
    }

    TELL_CHATTY("pt: (%.2f %.2f %.2f), v: (%e %e %e)",
		new_pt.x, new_pt.y, new_pt.z, v.x, v.y, v.z);
    if (0 && t >= ntsteps - 2) {   // DRC removed (if(0)) Oct 2019; t>ntsteps now dealt with below
      if (collect2pc || wpot > WP_THRESH_ELECTRONS) {
	/* for p-type, this is hole or electron+high wp */
	TELL_CHATTY("\nExceeded maximum number of time steps (%d)\n", ntsteps);
	low_field = 1;
	// return -1;
      }
      break;
    }
    if (wpotential(new_pt, &wpot, setup) != 0) {
      TELL_NORMAL("\nCan calculate velocity but not WP at %s!\n",
		  pt_to_str(tmpstr, MAX_LINE, new_pt));
      return -1;
    }
    if (wpot < 0.0) wpot = 0.0;
    TELL_CHATTY(" -> wp: %.10f\n", wpot);

    /* ------------- DCR added Oct 2019: if WP is very small or large, then stop drifting */
    if (!collect2pc &&    wpot < 5.0e-5) stop_drifting = 2;    // drifting to outside
    if (collect2pc && 1.0-wpot < 5.0e-5) stop_drifting = 3;    // drifting to point contact
    if (t >= setup->time_steps_calc - 2) stop_drifting = 1;    // have run out of time...

    if (t > 0) signal[t] += q*(wpot - wpot_old);
    // FIXME! Hack added by DCR to deal with undepleted point contact
    if (wpot >= 0.999 && (wpot - wpot_old) < 0.0002) {
      low_field = 1;
      break;
    }
    wpot_old = wpot;

    dx = vector_scale(v, setup->step_time_calc);
    if (surface_drift && dx.z < 0) {
      dx.x *= setup->surface_drift_vel_factor;  // Hmmm... should the default be zero or one?
      dx.y *= setup->surface_drift_vel_factor;
      dx.z = 0;
    }
    new_pt = vector_add(new_pt, dx);
    // q = charge_trapping(dx, q); //FIXME

    // look for charges on passivated surface of a PPC detector
    if (new_pt.z < 0 &&                                    // at or below surface, and
        (setup->wrap_around_radius <= setup->pc_radius ||  // this is a PPC detector
         new_pt.x*new_pt.x + new_pt.y*new_pt.y <           // or point is inside wrap-around
         setup->wrap_around_radius*setup->wrap_around_radius)) {
      TELL_CHATTY(" -> Passivated surface! q = %.2f  r = %.2f\n",
                  q, sqrt(new_pt.x*new_pt.x + new_pt.y*new_pt.y));
      //break;
      surface_drift = 1;
      new_pt.z = 0;
    }

  }
  if (t == 0) {
    TELL_CHATTY("The starting point %s is outside the WP or field.\n",
		pt_to_str(tmpstr, MAX_LINE, pt));
    return -1;
  }

  if (low_field) {
    TELL_CHATTY("Low field near point contact; this may or may not be a problem.\n");
  } else {
    TELL_CHATTY("Drifted to edge of WP or field grid, point: %s q: %.2f\n", 
		pt_to_str(tmpstr, MAX_LINE, new_pt), q);
  }
  if (!low_field && stop_drifting<2) {
    /* figure out how much we must drift to get to the crystal boundary */
    for (n = 0; n+t < ntsteps && !outside_detector(new_pt, setup); n++){
      new_pt = vector_add(new_pt, dx);
      if (q > 0) setup->dpath_h[t+n] = new_pt;
      else setup->dpath_e[t+n] = new_pt;
    }
    if (n == 0) n = 1; /* always drift at least one more step */
    // TELL_CHATTY(
    TELL_NORMAL("q: %.1f t: %d n: %d ((%.2f %.2f %.2f)=>(%.2f %.2f %.2f))\n", 
		q, t, n, pt.x, pt.y, pt.z, new_pt.x, new_pt.y, new_pt.z);

    if (n + t >= ntsteps){
      n = ntsteps - t;
      if (q > 0 || wpot > WP_THRESH_ELECTRONS) { /* hole or electron+high wp */
	TELL_CHATTY("Exceeded maximum number of time steps (%d)\n", ntsteps);
        /* check WP to see if we have produced most of the signal */
        if ((wpot < 0.95 || wpot > 0.05) &&
            wpotential(new_pt, &wpot2, setup) != 0) {
          TELL_CHATTY("Cannot finish drifting to make at least 95\% of signal.\n");
          return -1;  /* FIXME: could this be improved? */
        }
        /* drift to new_pt and wpot2 */
        dwpot = (wpot2 - wpot)/n;
      }
    } else {
      /* make WP go gradually to 1 or 0 */
      if (wpot > 0.3) {
        dwpot = (1.0 - wpot)/n;
      } else {
        dwpot = - wpot/n;
      }
    }

    /* now drift the final n steps */
    dx = vector_scale(v, setup->step_time_calc);
    if (new_pt.z > 0) {               // charges NOT on passivated surface
      for (i = 0; i < n; i++){
        signal[i+t] += q*dwpot;
        // q = charge_trapping(dx, q); //FIXME
      }
    }
  }
  TELL_CHATTY("q:%.2f pt: %s\n", q, pt_to_str(tmpstr, MAX_LINE, pt));
  if (q > 0) setup->final_vel = vector_length(v);

  return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x2a8, %rsp            # imm = 0x2A8
movq %rsi, %rbx
movq %rdi, 0x78(%rsp)
movl $0x0, 0x4c(%rsp)
movss 0x58(%rsi), %xmm4
xorps %xmm3, %xmm3
ucomiss %xmm3, %xmm4
jne 0x2be1
jnp 0x2bf8
ucomiss %xmm3, %xmm2
jbe 0x2bee
movb $0x1, %r13b
ucomiss %xmm4, %xmm3
ja 0x2c62
ucomiss %xmm2, %xmm3
jbe 0x2c5f
ucomiss %xmm3, %xmm4
jmp 0x2c59
ucomiss %xmm3, %xmm2
jbe 0x2c29
movq 0x1470(%rbx), %rax
movss 0xc(%rbx), %xmm3
divss 0x54(%rbx), %xmm3
cvttss2si %xmm3, %ecx
movq (%rax), %rax
movslq %ecx, %rcx
leaq (%rcx,%rcx,2), %rcx
movb $0x1, %r13b
xorps %xmm3, %xmm3
ucomiss 0x20(%rax,%rcx,4), %xmm3
ja 0x2c62
xorps %xmm4, %xmm4
ucomiss %xmm2, %xmm4
jbe 0x2c5f
movq 0x1470(%rbx), %rax
movss 0xc(%rbx), %xmm3
divss 0x54(%rbx), %xmm3
cvttss2si %xmm3, %ecx
movq (%rax), %rax
movslq %ecx, %rcx
leaq (%rcx,%rcx,2), %rcx
movss 0x20(%rax,%rcx,4), %xmm3
ucomiss %xmm4, %xmm3
seta %r13b
jmp 0x2c62
xorl %r13d, %r13d
movl 0x390(%rbx), %eax
movl %eax, 0x44(%rsp)
leaq 0x30(%rsp), %rdi
movq %rbx, %rsi
movss %xmm2, 0x10(%rsp)
movss %xmm1, 0x18(%rsp)
movaps %xmm0, 0x50(%rsp)
callq 0x5b16
movss 0x10(%rsp), %xmm2
movss 0x18(%rsp), %xmm1
movaps 0x50(%rsp), %xmm3
movl %eax, %ebp
shrl $0x1f, %ebp
testl %eax, %eax
js 0x32aa
xorps %xmm0, %xmm0
xorl %eax, %eax
ucomiss %xmm0, %xmm2
seta %al
xorps %xmm0, %xmm0
cvtss2sd %xmm2, %xmm0
movsd %xmm0, 0x80(%rsp)
leaq 0x1580(,%rax,8), %rax
movq %rax, 0x88(%rsp)
xorl %r15d, %r15d
movss 0x5326(%rip), %xmm2     # 0x8004
movl $0x8, %r12d
movl $0x0, 0x48(%rsp)
xorl %r14d, %r14d
movapd %xmm1, %xmm4
movaps %xmm3, %xmm5
xorpd %xmm0, %xmm0
movss %xmm0, 0x40(%rsp)
xorpd %xmm0, %xmm0
movsd %xmm0, 0x70(%rsp)
movq 0x88(%rsp), %rax
movq (%rbx,%rax), %rax
movlps %xmm5, -0x8(%rax,%r12)
movss %xmm4, (%rax,%r12)
testb %r13b, %r13b
movss %xmm4, 0xc(%rsp)
movaps %xmm5, 0x20(%rsp)
movss %xmm2, 0x1c(%rsp)
je 0x2fad
testq %r15, %r15
je 0x2e89
cmpl $0x0, 0x3a0(%rbx)
je 0x2fad
movsd 0x30(%rsp), %xmm0
movss 0x38(%rsp), %xmm1
callq 0x61b2
movaps %xmm0, %xmm3
divss 0x40(%rsp), %xmm0
xorps %xmm1, %xmm1
cvtss2sd %xmm0, %xmm1
mulsd 0x15a8(%rbx), %xmm1
movsd %xmm1, 0x15a8(%rbx)
xorps %xmm0, %xmm0
cvtss2sd 0x159c(%rbx), %xmm0
mulsd 0x70(%rsp), %xmm0
movapd %xmm1, %xmm2
mulsd %xmm1, %xmm2
divsd %xmm2, %xmm0
movsd 0x5298(%rip), %xmm2     # 0x8040
movapd %xmm2, %xmm4
minsd %xmm0, %xmm4
xorps %xmm0, %xmm0
cvtss2sd 0x15a0(%rbx), %xmm0
mulsd 0x5285(%rip), %xmm0     # 0x8048
divsd %xmm1, %xmm0
addsd %xmm4, %xmm0
ucomisd %xmm2, %xmm0
ja 0x2dee
xorps %xmm2, %xmm2
cvtss2sd 0x394(%rbx), %xmm2
mulsd %xmm0, %xmm2
ucomisd 0x5268(%rip), %xmm2     # 0x8050
jbe 0x2f90
movss %xmm3, 0x40(%rsp)
cmpl $0x2, (%rbx)
jl 0x2e13
leaq 0x5493(%rip), %rdi      # 0x8293
movb $0x2, %al
movsd %xmm4, 0x60(%rsp)
callq 0x25b2
movsd 0x60(%rsp), %xmm4
xorps %xmm0, %xmm0
cvtss2sd 0x15a0(%rbx), %xmm0
mulsd 0x5222(%rip), %xmm0     # 0x8048
xorps %xmm1, %xmm1
cvtss2sd 0x394(%rbx), %xmm1
addsd %xmm0, %xmm0
mulsd %xmm1, %xmm0
movsd %xmm0, 0x60(%rsp)
movsd 0x15a8(%rbx), %xmm0
mulsd 0x5209(%rip), %xmm4     # 0x8058
mulsd %xmm1, %xmm4
addsd %xmm0, %xmm4
mulsd %xmm0, %xmm0
mulsd %xmm4, %xmm0
movsd 0x51f9(%rip), %xmm1     # 0x8060
callq 0x2270
addsd 0x60(%rsp), %xmm0
ucomisd 0x524e(%rip), %xmm0     # 0x80c8
jb 0x2f6e
sqrtsd %xmm0, %xmm0
jmp 0x2f73
movsd 0x30(%rsp), %xmm0
movss 0x38(%rsp), %xmm1
callq 0x61b2
movss %xmm0, 0x1594(%rbx)
movss %xmm0, 0x1598(%rbx)
xorps %xmm2, %xmm2
cvtss2sd 0x39c(%rbx), %xmm2
movsd %xmm2, 0x15a8(%rbx)
cmpl $0x0, 0x3a0(%rbx)
je 0x2f34
movsd 0x519a(%rip), %xmm1     # 0x8068
ucomisd %xmm2, %xmm1
jbe 0x2ee5
movabsq $0x3f847ae147ae147b, %rax # imm = 0x3F847AE147AE147B
movq %rax, 0x15a8(%rbx)
xorps %xmm2, %xmm2
cvtss2sd 0x3a4(%rbx), %xmm2
ucomisd 0x5158(%rip), %xmm2     # 0x8050
jbe 0x2f34
movsd 0x5146(%rip), %xmm1     # 0x8048
mulsd %xmm1, %xmm2
mulsd %xmm1, %xmm2
mulsd %xmm1, %xmm2
divsd 0x515a(%rip), %xmm2     # 0x8070
divsd 0x515a(%rip), %xmm2     # 0x8078
mulsd 0x515a(%rip), %xmm2     # 0x8080
mulsd 0x515a(%rip), %xmm2     # 0x8088
movsd %xmm2, 0x70(%rsp)
cmpl $0x2, (%rbx)
movss %xmm0, 0x40(%rsp)
jl 0x2fa2
cvtss2sd %xmm0, %xmm0
xorps %xmm1, %xmm1
cvtss2sd 0x30(%rsp), %xmm1
xorps %xmm2, %xmm2
cvtss2sd 0x34(%rsp), %xmm2
xorps %xmm3, %xmm3
cvtss2sd 0x38(%rsp), %xmm3
leaq 0x5314(%rip), %rdi      # 0x8279
movb $0x4, %al
callq 0x25b2
jmp 0x2fa2
callq 0x2280
movsd %xmm0, 0x15a8(%rbx)
cmpl $0x2, (%rbx)
jl 0x2fa2
leaq 0x5326(%rip), %rdi      # 0x82ad
movb $0x1, %al
callq 0x25b2
jmp 0x2fa2
addsd %xmm1, %xmm2
movsd %xmm2, 0x15a8(%rbx)
movss %xmm3, 0x40(%rsp)
movss 0xc(%rsp), %xmm4
movaps 0x20(%rsp), %xmm5
cmpl $0x2, (%rbx)
jl 0x2fff
xorps %xmm0, %xmm0
cvtss2sd %xmm5, %xmm0
shufps $0x55, %xmm5, %xmm5     # xmm5 = xmm5[1,1,1,1]
xorps %xmm1, %xmm1
cvtss2sd %xmm5, %xmm1
xorps %xmm2, %xmm2
cvtss2sd %xmm4, %xmm2
xorps %xmm3, %xmm3
cvtss2sd 0x30(%rsp), %xmm3
xorps %xmm4, %xmm4
cvtss2sd 0x34(%rsp), %xmm4
xorps %xmm5, %xmm5
cvtss2sd 0x38(%rsp), %xmm5
leaq 0x52ca(%rip), %rdi      # 0x82b7
movb $0x6, %al
callq 0x25b2
movaps 0x20(%rsp), %xmm5
movss 0xc(%rsp), %xmm4
movaps %xmm5, %xmm0
movapd %xmm4, %xmm1
leaq 0x14(%rsp), %rdi
movq %rbx, %rsi
callq 0x56af
testl %eax, %eax
jne 0x32b9
xorps %xmm0, %xmm0
ucomiss 0x14(%rsp), %xmm0
jbe 0x302d
movl $0x0, 0x14(%rsp)
cmpl $0x2, (%rbx)
jl 0x3049
xorps %xmm0, %xmm0
cvtss2sd 0x14(%rsp), %xmm0
leaq 0x52c4(%rip), %rdi      # 0x8306
movb $0x1, %al
callq 0x25b2
testb %r13b, %r13b
movss 0x10(%rsp), %xmm2
jne 0x3071
xorps %xmm0, %xmm0
cvtss2sd 0x14(%rsp), %xmm0
movsd 0x502b(%rip), %xmm1     # 0x8090
ucomisd %xmm0, %xmm1
jbe 0x3071
movl $0x2, %r14d
testb %r13b, %r13b
je 0x30a7
xorps %xmm0, %xmm0
cvtss2sd 0x14(%rsp), %xmm0
movsd 0x5011(%rip), %xmm1     # 0x8098
subsd %xmm0, %xmm1
movsd 0x4ffd(%rip), %xmm0     # 0x8090
ucomisd %xmm1, %xmm0
movss 0x1c(%rsp), %xmm1
jbe 0x30ad
movl $0x3, %r14d
jmp 0x30ad
movss 0x1c(%rsp), %xmm1
movslq 0x390(%rbx), %rax
addq $-0x2, %rax
cmpq %rax, %r15
movl $0x1, %eax
cmovgel %eax, %r14d
testq %r15, %r15
je 0x30e8
movss 0x14(%rsp), %xmm0
subss %xmm1, %xmm0
mulss %xmm2, %xmm0
movq 0x78(%rsp), %rax
addss (%rax,%r15,4), %xmm0
movss %xmm0, (%rax,%r15,4)
movss 0x14(%rsp), %xmm3
xorps %xmm0, %xmm0
cvtss2sd %xmm3, %xmm0
ucomisd 0x4fa3(%rip), %xmm0     # 0x80a0
jb 0x311c
movaps %xmm3, %xmm0
subss %xmm1, %xmm0
cvtss2sd %xmm0, %xmm0
movsd 0x4f96(%rip), %xmm1     # 0x80a8
ucomisd %xmm0, %xmm1
ja 0x32f0
movss %xmm3, 0x1c(%rsp)
movss 0x394(%rbx), %xmm2
movsd 0x30(%rsp), %xmm0
movss 0x38(%rsp), %xmm1
callq 0x628a
movaps %xmm0, %xmm4
movaps %xmm1, %xmm3
cmpl $0x0, 0x48(%rsp)
je 0x317d
xorps %xmm0, %xmm0
ucomiss %xmm3, %xmm0
movss 0xc(%rsp), %xmm1
movaps 0x20(%rsp), %xmm0
jbe 0x3188
movss 0x1590(%rbx), %xmm3
movaps %xmm4, %xmm2
mulss %xmm3, %xmm2
shufps $0x55, %xmm4, %xmm4     # xmm4 = xmm4[1,1,1,1]
mulss %xmm3, %xmm4
unpcklps %xmm4, %xmm2            # xmm2 = xmm2[0],xmm4[0],xmm2[1],xmm4[1]
xorps %xmm3, %xmm3
movaps %xmm2, %xmm4
jmp 0x3188
movss 0xc(%rsp), %xmm1
movaps 0x20(%rsp), %xmm0
movaps %xmm4, 0x90(%rsp)
movaps %xmm4, %xmm2
movss %xmm3, 0x6c(%rsp)
callq 0x621d
xorps %xmm2, %xmm2
ucomiss %xmm1, %xmm2
movaps %xmm0, 0x20(%rsp)
jbe 0x321d
movss 0x10(%rbx), %xmm2
movss 0x14(%rbx), %xmm5
ucomiss %xmm5, %xmm2
movss 0x10(%rsp), %xmm2
jae 0x31de
movaps %xmm0, %xmm4
mulps %xmm0, %xmm4
shufps $0x55, %xmm4, %xmm4     # xmm4 = xmm4[1,1,1,1]
movaps %xmm0, %xmm3
mulss %xmm0, %xmm3
addss %xmm4, %xmm3
mulss %xmm5, %xmm5
ucomiss %xmm3, %xmm5
jbe 0x3254
xorps %xmm1, %xmm1
movl $0x1, 0x48(%rsp)
cmpl $0x2, (%rbx)
jl 0x3254
movaps %xmm0, %xmm2
mulps %xmm0, %xmm2
shufps $0x55, %xmm2, %xmm2     # xmm2 = xmm2[1,1,1,1]
movaps %xmm0, %xmm1
mulss %xmm0, %xmm1
addss %xmm2, %xmm1
xorps %xmm0, %xmm0
cvtss2sd %xmm1, %xmm0
ucomisd 0x4eb6(%rip), %xmm0     # 0x80c8
jb 0x3225
xorps %xmm1, %xmm1
sqrtsd %xmm0, %xmm1
jmp 0x322e
movss 0x10(%rsp), %xmm2
jmp 0x3254
callq 0x2280
movapd %xmm0, %xmm1
leaq 0x50e0(%rip), %rdi      # 0x8315
movsd 0x80(%rsp), %xmm0
movb $0x2, %al
callq 0x25b2
movss 0x10(%rsp), %xmm2
xorpd %xmm1, %xmm1
movaps 0x20(%rsp), %xmm0
movss %xmm1, 0xc(%rsp)
incq %r15
leaq 0x30(%rsp), %rdi
movq %rbx, %rsi
callq 0x5b16
movaps 0x20(%rsp), %xmm5
movss 0xc(%rsp), %xmm4
testl %eax, %eax
sets %al
testl %r14d, %r14d
setne %bpl
orb %al, %bpl
addq $0xc, %r12
testb %bpl, %bpl
movss 0x18(%rsp), %xmm1
movaps 0x50(%rsp), %xmm3
movss 0x1c(%rsp), %xmm2
je 0x2d0a
movss 0x10(%rsp), %xmm2
jmp 0x3306
movb $0x1, %r14b
xorl %r15d, %r15d
movaps %xmm3, %xmm5
movapd %xmm1, %xmm4
jmp 0x330e
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
cmpl $0x0, (%rbx)
jle 0x3737
leaq 0xa0(%rsp), %rdi
movl $0x200, %esi            # imm = 0x200
movaps 0x20(%rsp), %xmm0
movss 0xc(%rsp), %xmm1
callq 0x6378
leaq 0x4ff0(%rip), %rdi      # 0x82db
jmp 0x3474
movss 0x18(%rsp), %xmm1
movaps 0x50(%rsp), %xmm3
movss 0xc(%rsp), %xmm4
movaps 0x20(%rsp), %xmm5
cmpl $0x2, %r14d
setl %r14b
movl (%rbx), %eax
testl %r15d, %r15d
je 0x344a
testb $0x1, %bpl
je 0x3483
cmpl $0x2, %eax
jl 0x3382
leaq 0xa0(%rsp), %rdi
movl $0x200, %esi            # imm = 0x200
movaps %xmm5, %xmm0
movapd %xmm4, %xmm1
movss %xmm4, 0xc(%rsp)
movaps %xmm5, 0x20(%rsp)
callq 0x6378
xorps %xmm0, %xmm0
cvtss2sd 0x10(%rsp), %xmm0
leaq 0x5059(%rip), %rdi      # 0x83b5
movq %rax, %rsi
movb $0x1, %al
callq 0x25b2
movaps 0x20(%rsp), %xmm5
movss 0xc(%rsp), %xmm4
movaps 0x50(%rsp), %xmm3
movss 0x18(%rsp), %xmm1
movss 0x10(%rsp), %xmm2
testb %r14b, %r14b
je 0x36cf
xorl %r12d, %r12d
movl 0x44(%rsp), %ebp
movl %ebp, %r14d
subl %r15d, %r14d
jle 0x34b0
movl %r14d, 0x1c(%rsp)
xorpd %xmm0, %xmm0
xorl %eax, %eax
ucomiss %xmm0, %xmm2
seta %al
movl %r15d, %ecx
movl %ebp, %r12d
subl %r15d, %r12d
leaq 0x1580(,%rax,8), %r14
leaq (%rcx,%rcx,2), %rax
leaq 0x8(,%rax,4), %rbp
xorl %r13d, %r13d
movss %xmm4, 0xc(%rsp)
movaps %xmm5, 0x20(%rsp)
movaps %xmm5, %xmm0
movapd %xmm4, %xmm1
movq %rbx, %rdi
callq 0x3b04
testl %eax, %eax
jne 0x34b8
movaps 0x20(%rsp), %xmm0
movss 0xc(%rsp), %xmm1
movaps 0x90(%rsp), %xmm2
movss 0x6c(%rsp), %xmm3
callq 0x621d
movaps %xmm0, %xmm5
movapd %xmm1, %xmm4
movq (%rbx,%r14), %rax
movlps %xmm0, -0x8(%rax,%rbp)
movss %xmm1, (%rax,%rbp)
incq %r13
addq $0xc, %rbp
cmpq %r13, %r12
jne 0x33cf
movss %xmm4, 0xc(%rsp)
movss 0x10(%rsp), %xmm2
movaps 0x50(%rsp), %xmm3
movl 0x44(%rsp), %ebp
jmp 0x34cf
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
cmpl $0x2, %eax
jl 0x3737
leaq 0xa0(%rsp), %rdi
movl $0x200, %esi            # imm = 0x200
movaps %xmm3, %xmm0
callq 0x6378
leaq 0x4ecd(%rip), %rdi      # 0x8341
movq %rax, %rsi
xorl %eax, %eax
callq 0x25b2
jmp 0x3737
cmpl $0x2, %eax
jl 0x36cf
leaq 0x4ee1(%rip), %rdi      # 0x8374
xorl %eax, %eax
callq 0x25b2
movaps 0x50(%rsp), %xmm3
movss 0x18(%rsp), %xmm1
movss 0x10(%rsp), %xmm2
jmp 0x36cf
movss %xmm4, 0xc(%rsp)
jmp 0x34d4
movl %r13d, %r12d
movss 0x10(%rsp), %xmm2
movaps 0x50(%rsp), %xmm3
movl 0x44(%rsp), %ebp
movaps 0x20(%rsp), %xmm5
movl 0x1c(%rsp), %r14d
cmpl $0x1, %r12d
adcl $0x0, %r12d
cmpl $0x0, (%rbx)
jle 0x3541
xorps %xmm0, %xmm0
cvtss2sd %xmm2, %xmm0
xorps %xmm1, %xmm1
cvtss2sd %xmm3, %xmm1
shufps $0x55, %xmm3, %xmm3     # xmm3 = xmm3[1,1,1,1]
xorps %xmm2, %xmm2
cvtss2sd %xmm3, %xmm2
xorps %xmm3, %xmm3
cvtss2sd 0x18(%rsp), %xmm3
xorps %xmm4, %xmm4
cvtss2sd %xmm5, %xmm4
movaps %xmm5, 0x20(%rsp)
movaps 0x20(%rsp), %xmm5
shufps $0x55, %xmm5, %xmm5     # xmm5 = xmm5[1,1,1,1]
cvtss2sd %xmm5, %xmm5
cvtss2sd 0xc(%rsp), %xmm6
leaq 0x4ec4(%rip), %rdi      # 0x83ed
movl %r15d, %esi
movl %r12d, %edx
movb $0x7, %al
callq 0x25b2
movaps 0x20(%rsp), %xmm5
movss 0x10(%rsp), %xmm2
leal (%r12,%r15), %eax
cmpl %ebp, %eax
jge 0x358d
movss 0x14(%rsp), %xmm1
xorps %xmm0, %xmm0
cvtss2sd %xmm1, %xmm0
ucomisd 0x4b62(%rip), %xmm0     # 0x80c0
jbe 0x3647
movsd 0x4b2c(%rip), %xmm1     # 0x8098
subsd %xmm0, %xmm1
xorps %xmm0, %xmm0
cvtsi2sd %r12d, %xmm0
divsd %xmm0, %xmm1
xorps %xmm0, %xmm0
cvtsd2ss %xmm1, %xmm0
movaps %xmm0, 0x20(%rsp)
jmp 0x365f
xorpd %xmm0, %xmm0
ucomiss %xmm0, %xmm2
ja 0x35ad
xorps %xmm0, %xmm0
cvtss2sd 0x14(%rsp), %xmm0
ucomisd 0x4b09(%rip), %xmm0     # 0x80b0
jbe 0x374b
cmpl $0x2, (%rbx)
jl 0x35cc
leaq 0x4e6e(%rip), %rdi      # 0x8427
movl %ebp, %esi
xorl %eax, %eax
movaps %xmm5, 0x20(%rsp)
callq 0x25b2
movaps 0x20(%rsp), %xmm5
xorps %xmm0, %xmm0
cvtss2sd 0x14(%rsp), %xmm0
movsd 0x4adb(%rip), %xmm1     # 0x80b8
ucomisd %xmm0, %xmm1
ja 0x35ed
ucomisd 0x4a55(%rip), %xmm0     # 0x8040
jbe 0x3628
leaq 0x4c(%rsp), %rdi
movaps %xmm5, %xmm0
movss 0xc(%rsp), %xmm1
movq %rbx, %rsi
callq 0x56af
testl %eax, %eax
je 0x3628
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
cmpl $0x2, (%rbx)
jl 0x3737
leaq 0x4e37(%rip), %rdi      # 0x8453
xorl %eax, %eax
callq 0x25b2
jmp 0x3737
movss 0x4c(%rsp), %xmm1
subss 0x14(%rsp), %xmm1
xorps %xmm0, %xmm0
cvtsi2ss %r14d, %xmm0
divss %xmm0, %xmm1
movaps %xmm1, 0x20(%rsp)
jmp 0x3662
xorps %xmm0, %xmm0
cvtsi2ss %r12d, %xmm0
xorps 0x4a7a(%rip), %xmm1     # 0x80d0
divss %xmm0, %xmm1
movaps %xmm1, 0x20(%rsp)
movl %r12d, %r14d
movss 0x394(%rbx), %xmm2
movsd 0x30(%rsp), %xmm0
movss 0x38(%rsp), %xmm1
callq 0x628a
xorps %xmm0, %xmm0
movss 0xc(%rsp), %xmm1
ucomiss %xmm0, %xmm1
movss 0x10(%rsp), %xmm2
movss 0x18(%rsp), %xmm1
movaps 0x50(%rsp), %xmm3
movaps 0x20(%rsp), %xmm4
jbe 0x36cf
testl %r14d, %r14d
jle 0x36cf
movl %r15d, %ecx
movl %r14d, %eax
movq 0x78(%rsp), %rdx
leaq (%rdx,%rcx,4), %rcx
xorl %edx, %edx
mulss %xmm2, %xmm4
movss (%rcx,%rdx,4), %xmm0
addss %xmm4, %xmm0
movss %xmm0, (%rcx,%rdx,4)
incq %rdx
cmpq %rdx, %rax
jne 0x36b9
cmpl $0x2, (%rbx)
jl 0x3713
xorps %xmm0, %xmm0
cvtss2sd %xmm2, %xmm0
movsd %xmm0, 0x20(%rsp)
leaq 0xa0(%rsp), %rdi
movl $0x200, %esi            # imm = 0x200
movaps %xmm3, %xmm0
callq 0x6378
leaq 0x4d8e(%rip), %rdi      # 0x848b
movsd 0x20(%rsp), %xmm0
movq %rax, %rsi
movb $0x1, %al
callq 0x25b2
movss 0x10(%rsp), %xmm2
xorl %ebp, %ebp
xorpd %xmm0, %xmm0
ucomiss %xmm0, %xmm2
jbe 0x3737
movsd 0x30(%rsp), %xmm0
movss 0x38(%rsp), %xmm1
callq 0x61b2
movss %xmm0, 0x1598(%rbx)
movl %ebp, %eax
addq $0x2a8, %rsp            # imm = 0x2A8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
xorps %xmm0, %xmm0
movaps %xmm0, 0x20(%rsp)
jmp 0x3662