// File: /workspace/github_c_makefile_star2_O2/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 $0x2b8, %rsp            # imm = 0x2B8
movq %rsi, %rbx
movq %rdi, 0x78(%rsp)
movss %xmm1, 0x40(%rsp)
movaps %xmm0, 0x80(%rsp)
andl $0x0, 0x44(%rsp)
movss 0x58(%rsi), %xmm0
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
movss %xmm2, 0x4(%rsp)
jne 0x2b8b
jnp 0x2bb0
ucomiss %xmm1, %xmm2
jbe 0x2ba2
movb $0x1, %bpl
ucomiss %xmm0, %xmm1
movss 0x4(%rsp), %xmm2
ja 0x2c29
ucomiss %xmm2, %xmm1
jbe 0x2c1d
ucomiss %xmm1, %xmm0
seta %bpl
jmp 0x2c1f
ucomiss %xmm1, %xmm2
jbe 0x2be1
movq 0x1470(%rbx), %rax
movss 0xc(%rbx), %xmm0
divss 0x54(%rbx), %xmm0
cvttss2si %xmm0, %ecx
movq (%rax), %rax
movslq %ecx, %rcx
imulq $0xc, %rcx, %rcx
movb $0x1, %bpl
xorps %xmm0, %xmm0
ucomiss 0x20(%rax,%rcx), %xmm0
ja 0x2c29
xorps %xmm0, %xmm0
ucomiss %xmm2, %xmm0
jbe 0x2c27
movq 0x1470(%rbx), %rax
movss 0xc(%rbx), %xmm1
divss 0x54(%rbx), %xmm1
cvttss2si %xmm1, %ecx
movq (%rax), %rax
movslq %ecx, %rcx
imulq $0xc, %rcx, %rcx
movss 0x20(%rax,%rcx), %xmm1
ucomiss %xmm0, %xmm1
movss 0x4(%rsp), %xmm2
seta %bpl
jmp 0x2c29
xorl %ebp, %ebp
movss 0x4(%rsp), %xmm2
jmp 0x2c29
xorl %ebp, %ebp
movl 0x390(%rbx), %eax
movq %rax, 0xa0(%rsp)
cltq
movq %rax, 0x90(%rsp)
leaq 0x1580(%rbx), %rax
leaq 0x1588(%rbx), %rcx
xorps %xmm0, %xmm0
ucomiss %xmm0, %xmm2
cvtss2sd %xmm2, %xmm0
movsd %xmm0, 0x48(%rsp)
movq %rax, 0x50(%rsp)
movq %rcx, 0x98(%rsp)
cmovaq %rcx, %rax
movq %rax, 0xa8(%rsp)
movss 0x5384(%rip), %xmm2     # 0x8004
xorl %r15d, %r15d
pushq $0x8
popq %r12
xorl %r13d, %r13d
xorl %r14d, %r14d
xorps %xmm0, %xmm0
movsd %xmm0, 0x70(%rsp)
xorps %xmm0, %xmm0
movss %xmm0, 0x8(%rsp)
movapd 0x80(%rsp), %xmm5
movss 0x40(%rsp), %xmm1
movss %xmm2, 0x2c(%rsp)
movapd %xmm5, 0x10(%rsp)
movapd %xmm5, %xmm0
movss %xmm1, (%rsp)
movss 0x4(%rsp), %xmm2
leaq 0x30(%rsp), %rdi
movq %rbx, %rsi
callq 0x55c1
testl %eax, %eax
js 0x31e7
testl %r13d, %r13d
jne 0x31e7
movq 0xa8(%rsp), %rax
movq (%rax), %rax
movaps 0x10(%rsp), %xmm1
movlps %xmm1, -0x8(%rax,%r12)
movss (%rsp), %xmm2
movss %xmm2, (%rax,%r12)
testb %bpl, %bpl
je 0x2e58
testq %r15, %r15
je 0x2e63
cmpl $0x0, 0x3a0(%rbx)
je 0x2e58
movsd 0x30(%rsp), %xmm0
movss 0x38(%rsp), %xmm1
callq 0x5ad9
movaps %xmm0, %xmm4
divss 0x8(%rsp), %xmm0
cvtss2sd %xmm0, %xmm1
mulsd 0x15a8(%rbx), %xmm1
movsd %xmm1, 0x15a8(%rbx)
cvtss2sd 0x159c(%rbx), %xmm0
mulsd 0x70(%rsp), %xmm0
movapd %xmm1, %xmm2
mulsd %xmm1, %xmm2
divsd %xmm2, %xmm0
movsd 0x52c9(%rip), %xmm3     # 0x8040
movapd %xmm3, %xmm5
minsd %xmm0, %xmm5
cvtss2sd 0x15a0(%rbx), %xmm6
mulsd 0x52b9(%rip), %xmm6     # 0x8048
movapd %xmm6, %xmm0
divsd %xmm1, %xmm0
addsd %xmm5, %xmm0
ucomisd %xmm3, %xmm0
ja 0x2dbb
cvtss2sd 0x394(%rbx), %xmm3
mulsd %xmm0, %xmm3
ucomisd 0x529b(%rip), %xmm3     # 0x8050
jbe 0x2f84
cmpl $0x2, (%rbx)
movss %xmm4, 0x8(%rsp)
jl 0x2e00
leaq 0x54c6(%rip), %rdi      # 0x8293
movb $0x2, %al
movsd %xmm5, 0x60(%rsp)
callq 0x24d5
movsd 0x60(%rsp), %xmm5
cvtss2sd 0x15a0(%rbx), %xmm6
movsd 0x15a8(%rbx), %xmm1
mulsd 0x5250(%rip), %xmm6     # 0x8048
movapd %xmm1, %xmm2
mulsd %xmm1, %xmm2
addsd %xmm6, %xmm6
cvtss2sd 0x394(%rbx), %xmm0
mulsd %xmm0, %xmm6
movsd %xmm6, 0x60(%rsp)
mulsd 0x523a(%rip), %xmm5     # 0x8058
mulsd %xmm0, %xmm5
addsd %xmm1, %xmm5
mulsd %xmm2, %xmm5
movapd %xmm5, %xmm0
movsd 0x522a(%rip), %xmm1     # 0x8060
callq 0x2280
addsd 0x60(%rsp), %xmm0
ucomisd 0x527f(%rip), %xmm0     # 0x80c8
jb 0x2f44
sqrtsd %xmm0, %xmm0
jmp 0x2f49
movss 0x8(%rsp), %xmm4
jmp 0x2f9a
movsd 0x30(%rsp), %xmm0
movss 0x38(%rsp), %xmm1
callq 0x5ad9
movaps %xmm0, %xmm4
movss %xmm0, 0x1594(%rbx)
movss %xmm0, 0x1598(%rbx)
cvtss2sd 0x39c(%rbx), %xmm0
movsd %xmm0, 0x15a8(%rbx)
cmpl $0x0, 0x3a0(%rbx)
je 0x2f0b
movsd 0x51c0(%rip), %xmm1     # 0x8068
ucomisd %xmm0, %xmm1
jbe 0x2ebf
movabsq $0x3f847ae147ae147b, %rax # imm = 0x3F847AE147AE147B
movq %rax, 0x15a8(%rbx)
cvtss2sd 0x3a4(%rbx), %xmm0
ucomisd 0x5181(%rip), %xmm0     # 0x8050
jbe 0x2f0b
movsd 0x516f(%rip), %xmm1     # 0x8048
mulsd %xmm1, %xmm0
mulsd %xmm1, %xmm0
mulsd %xmm1, %xmm0
divsd 0x5183(%rip), %xmm0     # 0x8070
divsd 0x5183(%rip), %xmm0     # 0x8078
mulsd 0x5183(%rip), %xmm0     # 0x8080
mulsd 0x5183(%rip), %xmm0     # 0x8088
movsd %xmm0, 0x70(%rsp)
cmpl $0x2, (%rbx)
jl 0x2f3c
cvtss2sd %xmm4, %xmm0
cvtss2sd 0x30(%rsp), %xmm1
cvtss2sd 0x34(%rsp), %xmm2
cvtss2sd 0x38(%rsp), %xmm3
leaq 0x534c(%rip), %rdi      # 0x8279
movb $0x4, %al
movss %xmm4, 0x8(%rsp)
callq 0x24d5
jmp 0x2f6a
movss %xmm4, 0x8(%rsp)
jmp 0x2f78
callq 0x2290
movss 0x8(%rsp), %xmm1
movsd %xmm0, 0x15a8(%rbx)
cmpl $0x2, (%rbx)
jl 0x2f72
leaq 0x534a(%rip), %rdi      # 0x82ad
movb $0x1, %al
callq 0x24d5
movss 0x8(%rsp), %xmm4
jmp 0x2f90
movss %xmm1, 0x8(%rsp)
movss (%rsp), %xmm2
movaps 0x10(%rsp), %xmm1
jmp 0x2fe7
addsd %xmm1, %xmm3
movsd %xmm3, 0x15a8(%rbx)
movss (%rsp), %xmm2
movaps 0x10(%rsp), %xmm1
cmpl $0x2, (%rbx)
jl 0x2fe1
cvtss2sd %xmm1, %xmm0
shufps $0x55, %xmm1, %xmm1     # xmm1 = xmm1[1,1,1,1]
cvtss2sd %xmm1, %xmm1
cvtss2sd %xmm2, %xmm2
cvtss2sd 0x30(%rsp), %xmm3
movss %xmm4, 0x8(%rsp)
cvtss2sd 0x34(%rsp), %xmm4
cvtss2sd 0x38(%rsp), %xmm5
leaq 0x52e9(%rip), %rdi      # 0x82b7
movb $0x6, %al
callq 0x24d5
movaps 0x10(%rsp), %xmm1
movss (%rsp), %xmm2
jmp 0x2fe7
movss %xmm4, 0x8(%rsp)
movaps %xmm1, %xmm0
movaps %xmm2, %xmm1
leaq 0xc(%rsp), %rdi
movq %rbx, %rsi
callq 0x5140
testl %eax, %eax
jne 0x32e6
movss 0xc(%rsp), %xmm0
xorps %xmm1, %xmm1
ucomiss %xmm0, %xmm1
jbe 0x3018
andl $0x0, 0xc(%rsp)
xorps %xmm0, %xmm0
cmpl $0x2, (%rbx)
jl 0x302f
cvtss2sd %xmm0, %xmm0
leaq 0x52de(%rip), %rdi      # 0x8306
movb $0x1, %al
callq 0x24d5
movss 0xc(%rsp), %xmm3
cvtss2sd %xmm3, %xmm0
testb %bpl, %bpl
je 0x305e
movsd 0x5052(%rip), %xmm1     # 0x8098
subsd %xmm0, %xmm1
movsd 0x503e(%rip), %xmm2     # 0x8090
ucomisd %xmm1, %xmm2
jbe 0x3078
pushq $0x3
popq %r13
jmp 0x307b
movsd 0x502a(%rip), %xmm1     # 0x8090
ucomisd %xmm0, %xmm1
movss 0x2c(%rsp), %xmm2
jbe 0x3083
pushq $0x2
popq %r13
jmp 0x3086
xorl %r13d, %r13d
movss 0x2c(%rsp), %xmm2
jmp 0x3086
xorl %r13d, %r13d
movslq 0x390(%rbx), %rax
addq $-0x2, %rax
cmpq %rax, %r15
pushq $0x1
popq %rax
cmovgel %eax, %r13d
testq %r15, %r15
je 0x30be
movaps %xmm3, %xmm1
subss %xmm2, %xmm1
mulss 0x4(%rsp), %xmm1
movq 0x78(%rsp), %rax
addss (%rax,%r15,4), %xmm1
movss %xmm1, (%rax,%r15,4)
ucomisd 0x4fda(%rip), %xmm0     # 0x80a0
jb 0x30e5
movaps %xmm3, %xmm0
subss %xmm2, %xmm0
cvtss2sd %xmm0, %xmm0
movsd 0x4fcd(%rip), %xmm1     # 0x80a8
ucomisd %xmm0, %xmm1
ja 0x3317
movss %xmm3, 0x2c(%rsp)
movss 0x394(%rbx), %xmm2
movsd 0x30(%rsp), %xmm0
movss 0x38(%rsp), %xmm1
callq 0x5b8d
movaps %xmm0, %xmm3
movaps %xmm1, %xmm4
testl %r14d, %r14d
je 0x3135
xorps %xmm0, %xmm0
ucomiss %xmm4, %xmm0
movss (%rsp), %xmm1
movaps 0x10(%rsp), %xmm0
jbe 0x313f
movss 0x1590(%rbx), %xmm2
shufps $0x0, %xmm2, %xmm2      # xmm2 = xmm2[0,0,0,0]
mulps %xmm2, %xmm3
xorps %xmm4, %xmm4
jmp 0x313f
movss (%rsp), %xmm1
movaps 0x10(%rsp), %xmm0
movaps %xmm3, 0x60(%rsp)
movaps %xmm3, %xmm2
movss %xmm4, 0x5c(%rsp)
movaps %xmm4, %xmm3
callq 0x5b1e
movaps %xmm0, %xmm5
xorps %xmm0, %xmm0
ucomiss %xmm1, %xmm0
jbe 0x31d5
movss 0x10(%rbx), %xmm0
movss 0x14(%rbx), %xmm4
ucomiss %xmm4, %xmm0
movaps %xmm5, %xmm0
mulps %xmm5, %xmm0
jae 0x3190
movaps %xmm0, %xmm2
shufps $0x55, %xmm0, %xmm2     # xmm2 = xmm2[1,1],xmm0[1,1]
movaps %xmm5, %xmm3
mulss %xmm5, %xmm3
addss %xmm2, %xmm3
mulss %xmm4, %xmm4
ucomiss %xmm3, %xmm4
jbe 0x31d5
xorps %xmm1, %xmm1
cmpl $0x2, (%rbx)
jl 0x31d1
shufps $0x55, %xmm0, %xmm0     # xmm0 = xmm0[1,1,1,1]
movaps %xmm5, %xmm1
mulss %xmm5, %xmm1
addss %xmm0, %xmm1
cvtss2sd %xmm1, %xmm0
sqrtsd %xmm0, %xmm1
leaq 0x515f(%rip), %rdi      # 0x8315
movsd 0x48(%rsp), %xmm0
movb $0x2, %al
movaps %xmm5, 0x10(%rsp)
callq 0x24d5
movaps 0x10(%rsp), %xmm5
xorpd %xmm1, %xmm1
pushq $0x1
popq %r14
incq %r15
addq $0xc, %r12
movss 0x2c(%rsp), %xmm2
jmp 0x2cae
movl (%rbx), %eax
testq %r15, %r15
je 0x3346
cmpl $0x2, %eax
jl 0x322a
leaq 0xb0(%rsp), %rdi
movl $0x200, %esi            # imm = 0x200
movaps 0x10(%rsp), %xmm0
movss (%rsp), %xmm1
callq 0x5c68
leaq 0x519b(%rip), %rdi      # 0x83b5
movq %rax, %rsi
movsd 0x48(%rsp), %xmm0
movb $0x1, %al
callq 0x24d5
cmpl $0x1, %r13d
movss 0x4(%rsp), %xmm2
movss (%rsp), %xmm1
movaps 0x10(%rsp), %xmm5
ja 0x3584
movslq %r15d, %r12
movq 0x90(%rsp), %rax
cmpq %r12, %rax
cmovgq %rax, %r12
movq %r12, %r13
subq %r15, %r13
xorps %xmm0, %xmm0
ucomiss %xmm0, %xmm2
movq 0x50(%rsp), %rax
cmovaq 0x98(%rsp), %rax
movq %rax, 0x50(%rsp)
movl %r15d, %eax
imulq $0xc, %rax, %rbp
subl %r15d, %r12d
xorl %r14d, %r14d
cmpq %r14, %r12
movss %xmm1, (%rsp)
movaps %xmm5, 0x10(%rsp)
je 0x3388
movaps %xmm5, %xmm0
movq %rbx, %rdi
callq 0x3874
testl %eax, %eax
jne 0x338d
movaps 0x10(%rsp), %xmm0
movss (%rsp), %xmm1
movaps 0x60(%rsp), %xmm2
movss 0x5c(%rsp), %xmm3
callq 0x5b1e
movaps %xmm0, %xmm5
movq 0x50(%rsp), %rax
movq (%rax), %rax
movlps %xmm0, (%rax,%rbp)
movss %xmm1, 0x8(%rax,%rbp)
incq %r14
addq $0xc, %rbp
movss 0x4(%rsp), %xmm2
jmp 0x3282
pushq $-0x1
popq %rbp
cmpl $0x0, (%rbx)
jle 0x35e9
leaq 0xb0(%rsp), %rdi
movl $0x200, %esi            # imm = 0x200
movaps 0x10(%rsp), %xmm0
movss (%rsp), %xmm1
callq 0x5c68
leaq 0x4fc6(%rip), %rdi      # 0x82db
jmp 0x3379
movl (%rbx), %eax
testq %r15, %r15
je 0x3346
cmpl $0x2, %eax
movss 0x4(%rsp), %xmm2
jl 0x35c6
leaq 0x5040(%rip), %rdi      # 0x8374
xorl %eax, %eax
callq 0x24d5
movss 0x4(%rsp), %xmm2
jmp 0x3584
pushq $-0x1
popq %rbp
cmpl $0x2, %eax
jl 0x35e9
leaq 0xb0(%rsp), %rdi
movl $0x200, %esi            # imm = 0x200
movaps 0x80(%rsp), %xmm0
movss 0x40(%rsp), %xmm1
callq 0x5c68
leaq 0x4fc8(%rip), %rdi      # 0x8341
movq %rax, %rsi
xorl %eax, %eax
callq 0x24d5
jmp 0x35e9
movl %r13d, %r14d
jmp 0x3398
movss 0x4(%rsp), %xmm2
movaps 0x10(%rsp), %xmm5
cmpl $0x1, %r14d
movl %r14d, %r12d
adcl $0x0, %r12d
cmpl $0x0, (%rbx)
jle 0x33fb
movaps 0x80(%rsp), %xmm0
cvtss2sd %xmm0, %xmm1
shufps $0x55, %xmm0, %xmm0     # xmm0 = xmm0[1,1,1,1]
cvtss2sd %xmm0, %xmm2
cvtss2sd 0x40(%rsp), %xmm3
cvtss2sd %xmm5, %xmm4
movaps %xmm5, %xmm0
shufps $0x55, %xmm5, %xmm0     # xmm0 = xmm0[1,1],xmm5[1,1]
cvtss2sd %xmm0, %xmm5
cvtss2sd (%rsp), %xmm6
leaq 0x5010(%rip), %rdi      # 0x83ed
movsd 0x48(%rsp), %xmm0
movl %r15d, %esi
movl %r12d, %edx
movb $0x7, %al
callq 0x24d5
movaps 0x10(%rsp), %xmm5
movss 0x4(%rsp), %xmm2
movl %r14d, %eax
cmpq $0x1, %rax
adcq $0x0, %rax
addl %r15d, %eax
movq 0xa0(%rsp), %rsi
cmpl %esi, %eax
jge 0x344b
movss 0xc(%rsp), %xmm1
cvtss2sd %xmm1, %xmm0
ucomisd 0x4c99(%rip), %xmm0     # 0x80c0
jbe 0x34e3
cvtsi2sd %r12d, %xmm1
movsd 0x4c5e(%rip), %xmm2     # 0x8098
subsd %xmm0, %xmm2
divsd %xmm1, %xmm2
cvtsd2ss %xmm2, %xmm0
jmp 0x34fd
movq %rsi, %r12
subq %r15, %r12
xorps %xmm0, %xmm0
ucomiss %xmm0, %xmm2
ja 0x346d
cvtss2sd 0xc(%rsp), %xmm0
ucomisd 0x4c49(%rip), %xmm0     # 0x80b0
jbe 0x34fa
cmpl $0x2, (%rbx)
jl 0x3485
leaq 0x4fae(%rip), %rdi      # 0x8427
xorl %eax, %eax
callq 0x24d5
movaps 0x10(%rsp), %xmm5
movss 0xc(%rsp), %xmm0
cvtss2sd %xmm0, %xmm1
movsd 0x4c21(%rip), %xmm2     # 0x80b8
ucomisd %xmm1, %xmm2
ja 0x34ab
xorpd %xmm2, %xmm2
ucomisd 0x4b97(%rip), %xmm1     # 0x8040
jbe 0x3510
leaq 0x44(%rsp), %rdi
movaps %xmm5, %xmm0
movss (%rsp), %xmm1
movq %rbx, %rsi
callq 0x5140
testl %eax, %eax
je 0x3504
pushq $-0x1
popq %rbp
cmpl $0x2, (%rbx)
jl 0x35e9
leaq 0x4f7c(%rip), %rdi      # 0x8453
xorl %eax, %eax
callq 0x24d5
jmp 0x35e9
xorps 0x4be6(%rip), %xmm1     # 0x80d0
cvtsi2ss %r12d, %xmm0
divss %xmm0, %xmm1
movaps %xmm1, 0x10(%rsp)
jmp 0x3522
xorps %xmm0, %xmm0
movaps %xmm0, 0x10(%rsp)
jmp 0x3522
movss 0x44(%rsp), %xmm2
movss 0xc(%rsp), %xmm0
subss %xmm0, %xmm2
cvtsi2ss %r12d, %xmm0
divss %xmm0, %xmm2
movaps %xmm2, 0x10(%rsp)
movss 0x394(%rbx), %xmm2
movsd 0x30(%rsp), %xmm0
movss 0x38(%rsp), %xmm1
callq 0x5b8d
xorps %xmm0, %xmm0
movss (%rsp), %xmm1
ucomiss %xmm0, %xmm1
movss 0x4(%rsp), %xmm2
movaps 0x10(%rsp), %xmm1
jbe 0x3584
xorl %eax, %eax
testl %r12d, %r12d
cmovlel %eax, %r12d
movl %r15d, %ecx
movq 0x78(%rsp), %rdx
leaq (%rdx,%rcx,4), %rcx
mulss %xmm2, %xmm1
cmpq %rax, %r12
je 0x3584
movss (%rcx,%rax,4), %xmm0
addss %xmm1, %xmm0
movss %xmm0, (%rcx,%rax,4)
incq %rax
jmp 0x356c
cmpl $0x2, (%rbx)
jl 0x35c6
leaq 0xb0(%rsp), %rdi
movl $0x200, %esi            # imm = 0x200
movaps 0x80(%rsp), %xmm0
movss 0x40(%rsp), %xmm1
callq 0x5c68
leaq 0x4edb(%rip), %rdi      # 0x848b
movsd 0x48(%rsp), %xmm0
movq %rax, %rsi
movb $0x1, %al
callq 0x24d5
movss 0x4(%rsp), %xmm2
xorl %ebp, %ebp
xorps %xmm0, %xmm0
ucomiss %xmm0, %xmm2
jbe 0x35e9
movsd 0x30(%rsp), %xmm0
movss 0x38(%rsp), %xmm1
callq 0x5ad9
movss %xmm0, 0x1598(%rbx)
movl %ebp, %eax
addq $0x2b8, %rsp            # imm = 0x2B8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq