// File: /workspace/github_c_makefile_star2_O1/usgs[P]nshmp-haz-catalogs/src/agrid/adaptive/smooth_seis_rates.c
// Function: smooth_seis_rates
void smooth_seis_rates(struct rates* seisr, struct smoothp* smp, struct eqcat* catn, struct boundaries* reg, struct compl_levels* cat_comp, struct catalog* cat_par)
/*--------------------------------------------------------------------------*/
{
  int cnt, ix, iy, ix1, iy1, n;
  int log_shift_eq, log_shift_pt, log_actual_eq_loc;
  int imaxv=0, tot_asum_int;
//  float maxv=0.0, tot_asum, n_eff, eq_rate, beta, area_scaling;
  float maxv=0.0, tot_asum, n_eff, eq_rate, area_scaling;
//  float lonEq, latEq, lonPt, latPt, sigma, avg_lat;
  float lonEq, latEq, lonPt, latPt, sigma;
//  float lonEq1, latEq1;
  float dist, az, baz, fac_exp, sig2, dist2;
  float norm_term, kernel_sum, sum_eqs=0.0;

// logicals for adjusting earthquake points to grid cell locations and shifting grid cell 
  log_actual_eq_loc=0;
  log_shift_eq=1;
  log_shift_pt=0;

// 
//  beta=2.303*cat_par->bval;

// check if smoothing is to be applied
/* -------------------------------------------------------- */
// NO SMOOTHING
// time duration normalization - adjust completeness levels by Wiechert
// adjusts sum for different completeness times, assuming magnitude thresholds differ by 1 m.u.
/* -------------------------------------------------------- */
  if ( smp->apply_sm == 0 ) { 
    for(cnt=0; cnt<catn->nv; cnt++) {
//      iy=(int)nearbyintf(((reg->maxlat-catn->lat[cnt])/reg->dlat));
//      ix=(int)nearbyintf(((catn->lon[cnt]-reg->minlon)/reg->dlon));
      iy=(int)roundf(((reg->maxlat-catn->lat[cnt])/reg->dlat));
      ix=(int)roundf(((catn->lon[cnt]-reg->minlon)/reg->dlon));
      n=iy*reg->nsx+ix;
      catn->agrid_id[cnt]=n;
// convert from numbers to rates here
      eq_rate=calc_seis_rate(smp, catn, cat_comp, cat_par, cnt);
      n_eff=eq_rate;

//  Sum earthquake integers, effective-numbers-earthquakes in asum_cnt and asum
      seisr->asum_cnt_int[n]++;
      seisr->asum_cnt[n]=seisr->asum_cnt[n]+n_eff;
      seisr->asum[n]=seisr->asum[n]+n_eff;
    }
    fprintf(stderr,"Earthquakes assigned to grid cells (no smoothing) - %d earthquakes. ", catn->nv);
    maxv=0.0; imaxv=0; tot_asum=0.0; tot_asum_int=0;
    for(cnt=0; cnt<seisr->nv; cnt++) {
      if (seisr->asum[cnt]>maxv) {
        maxv=seisr->asum[cnt];
        imaxv=cnt;
      } 
      tot_asum_int=tot_asum_int+seisr->asum_cnt_int[cnt];
      tot_asum=tot_asum+seisr->asum[cnt];
    }
    fprintf(stdout,"Earthquakes recovered from grid cells: total-rates,eff=%.2f, total-numbers=%d\n", tot_asum, tot_asum_int);
    fprintf(stdout,"Max number earthquakes in a cell: %.2f\n", maxv);
  }
/* -------------------------------------------------------- */
// SMOOTHING
/* -------------------------------------------------------- */
  else {

// assign eqs to grid cells for un-smoothed results and maximum, un-smoothed rate
//    avg_lat=0.5*(reg->minlon+reg->maxlon);
    for(cnt=0; cnt<catn->nv; cnt++) {
//      iy=(int)nearbyintf(((reg->maxlat-catn->lat[cnt])/reg->dlat));
//      ix=(int)nearbyintf(((catn->lon[cnt]-reg->minlon)/reg->dlon));
      iy=(int)roundf(((reg->maxlat-catn->lat[cnt])/reg->dlat));
      ix=(int)roundf(((catn->lon[cnt]-reg->minlon)/reg->dlon));
      n=iy*reg->nsx+ix;
      catn->agrid_id[cnt]=n;
// convert from numbers to rates here
      eq_rate=calc_seis_rate(smp, catn, cat_comp, cat_par, cnt);
      n_eff=eq_rate;
// summing over asum
// get un-smoothed results for comparison
      seisr->asum_cnt_int[n]++;
      seisr->asum_cnt[n]=seisr->asum_cnt[n]+n_eff;
    }
    for(cnt=0; cnt<seisr->nv; cnt++) seisr->asum_noSm[cnt]=(float)seisr->asum_cnt[cnt];
// get maximum, un-smoothed rate
    maxv=0.0; imaxv=0; tot_asum=0.0; tot_asum_int=0;
    for(cnt=0; cnt<seisr->nv; cnt++) {
      if (seisr->asum_noSm[cnt]>maxv) {
        maxv=seisr->asum_noSm[cnt];
        imaxv=cnt;
      } 
      tot_asum_int=tot_asum_int+seisr->asum_cnt_int[cnt];
      tot_asum=tot_asum+seisr->asum_cnt[cnt];
    }
    fprintf(stdout,"Maximum, un-smoothed rate (eq nos/cell/yr), cell-number: %.2f %d\n", maxv, imaxv);
    fprintf(stdout,"Earthquakes recovered from grid cells: effective-rate=%.2f, #eqs=%d\n", tot_asum, tot_asum_int);
//    fprintf(stdout,"Max number earthquakes in a cell: %.2f\n", maxv);
//    fprintf(stderr,"unsmoothed nv: %d\n", seisr->nv);
//    fprintf(stderr,"maxv: %f \n", seisr->asum_noSm[35185]);

// SMOOTH GRID CELL NUMBERS
// loop over all earthquake sources to get smoothed rates
// assign eq location to center of cell
    fprintf(stderr,"Smoothing rates...\n");
    for(cnt=0; cnt<catn->nv; cnt++) {
      iy1=(int)roundf(((reg->maxlat-catn->lat[cnt])/reg->dlat));
      ix1=(int)roundf(((catn->lon[cnt]-reg->minlon)/reg->dlon));
//      iy1=(int)nearbyintf(((reg->maxlat-catn->lat[cnt])/reg->dlat));
//      ix1=(int)nearbyintf(((catn->lon[cnt]-reg->minlon)/reg->dlon));
//      iy1=(int)((reg->maxlat-catn->lat[cnt])/reg->dlat);
//      ix1=(int)((catn->lon[cnt]-reg->minlon)/reg->dlon);
// convert from numbers to rates here
      eq_rate=calc_seis_rate(smp, catn, cat_comp, cat_par, cnt);
      n_eff=eq_rate;
// check location parameters
      if ( (ix1<0) || (ix1>=reg->nsx) || (iy1<0) || (iy1>=reg->nsy) ) {
        fprintf(stderr,"Error with earthquake location parameters, lon/lat/ix/iy/nsx/nsy: %.3f %.3f %d %d (%d %d)\n", catn->lon[cnt], catn->lat[cnt], ix1, iy1, reg->nsx, reg->nsy);
        exit(1);
      }

// determine location of earthquake epicenter
// original point location
//      lonEq1=catn->lon[cnt];
//      latEq1=catn->lat[cnt];
      if ( log_actual_eq_loc==1 ) {
        lonEq=catn->lon[cnt];
        latEq=catn->lat[cnt];
      }
      else {
// epicenters determined from cell origin
        if ( log_shift_eq==1 ) {
          lonEq=reg->minlon+(ix1+0.5)*reg->dlon;
          latEq=reg->maxlat-(iy1+0.5)*reg->dlat;
        }
// epicenter at center of cell - shifted 0.5 increment
        else {
          lonEq=reg->minlon+(ix1)*reg->dlon;
          latEq=reg->maxlat-(iy1)*reg->dlat;
        }
      }

// optional test of earthquake locations
/*      delaz_(&latEq,&lonEq,&latEq1,&lonEq1,&dist,&az,&baz);
      fprintf(stderr,"EqDist %.2f %.2f %.2f %.2f %.2f %d %d\n", dist, lonEq1, latEq1, lonEq, latEq, ix1, iy1);
      exit(1); 	*/	


// loop over grid points and assign numbers
// get normalization term, first
      norm_term=0.0;
      kernel_sum=0.0;
      sigma=get_sigma_value(smp, catn, cnt);
      sig2=2*sigma*sigma;
      for(ix=0; ix<reg->nsx; ix++) {
        for(iy=0; iy<reg->nsy; iy++) {
          n=iy*reg->nsx+ix;
// shift cell origin to center cell
          if ( log_shift_pt==1 ) {
            lonPt=reg->minlon+(ix+0.5)*reg->dlon;
            latPt=reg->maxlat-(iy+0.5)*reg->dlat;
          }
// original location
          else {
            lonPt=reg->minlon+(ix)*reg->dlon;
            latPt=reg->maxlat-(iy)*reg->dlat;
          }
// distances from earthquakes to cells
          delaz_(&latEq,&lonEq,&latPt,&lonPt,&dist,&az,&baz);
          dist2=dist*dist;
          area_scaling=cos(latPt*DEG2RAD)/cos(latEq*DEG2RAD);
          if ( (smp->gauss_kern) == 1 ) {
            fac_exp=expf(-1*dist2/sig2);
          }
          else {
            fac_exp=powf((dist2+sigma*sigma),-1.5);
          }
          kernel_sum=kernel_sum+fac_exp*area_scaling;
//          if ( fac_exp > VTHR ) {
//            norm_term=norm_term+fac_exp;
//          }
//  if (n==29375) fprintf(stderr,"wt_norm: %.2f %.2f %.4e %d %d %.2f %.2f\n", dist, sigma, fac_exp, ix, iy, lonPt, latPt);
//          fprintf(stderr,"area-scaling/latPt/latEq: %.2f %.2f %.2f\n", area_scaling, latPt, latEq);
        }
      }
      norm_term=1/kernel_sum;
//fprintf(stderr,"wt_norm: %.4f %.2f %d\n", norm_term, sigma, cnt);
//      fprintf(stderr,"norm term: %.2f %.2f %d %.4f %.2f\n", catn->lon[cnt], catn->lat[cnt], cnt, norm_term, sigma);
/*
if (norm_term>1) {
  fprintf(stderr,"error norm term: %f\n", norm_term); exit(1);
}
else {
  fprintf(stderr,"norm term: %.2f %.2f %d %.2f %.2f\n", catn->lon[cnt], catn->lat[cnt], cnt, norm_term, sigma);
}
*/
// assign normalized weights 
      float eq_sum=0.0;
      for(ix=0; ix<reg->nsx; ix++) {
        for(iy=0; iy<reg->nsy; iy++) {
          n=iy*reg->nsx+ix;
// original location
          if ( log_shift_pt==0 ) {
            lonPt=reg->minlon+(ix)*reg->dlon;
            latPt=reg->maxlat-(iy)*reg->dlat;
          }
          else {
// shift cell origin to center cell
            lonPt=reg->minlon+(ix+0.5)*reg->dlon;
            latPt=reg->maxlat-(iy+0.5)*reg->dlat;
          }
// earthquake location - calculate distances
          delaz_(&latEq,&lonEq,&latPt,&lonPt,&dist,&az,&baz);
          dist2=dist*dist;
          area_scaling=cos(latPt*DEG2RAD)/cos(latEq*DEG2RAD);
          if ( (smp->gauss_kern) == 1 ) {
            fac_exp=n_eff*norm_term*expf(-1*dist2/sig2);
          }
          else {
            fac_exp=n_eff*norm_term*powf((dist2+sigma*sigma),-1.5);
          }
// scaling for variable-cell-area-with-latitude
          if ( cat_comp->correctAreaForLat ) {
//            fprintf(stderr,"correcting for grid cell area\n");
            eq_sum=eq_sum+fac_exp*area_scaling;
            seisr->asum[n]=seisr->asum[n]+fac_exp*area_scaling;
          }
          else {
            eq_sum=eq_sum+fac_exp;
            seisr->asum[n]=seisr->asum[n]+fac_exp;
          }
//          if ( fac_exp > norm_term*VTHR ) {
//fprintf(stderr,"sum_iter(sum/cnt/dist/sig/fac_exp): %.4f %d %.2f %.2f %.4e\n", eq_sum, cnt, dist, sigma, fac_exp);
          
//  if (n==29375) fprintf(stderr,"wt: %.2f %.2f %.4e %.4f %f %d %d n=%d\n", dist, sigma, fac_exp, norm_term, seisr->asum[n], ix, iy, cnt);
        }
      }				// end loops over gridpoints ix/iy
//fprintf(stderr,"sum eq: %.4f %d\n", eq_sum, cnt);
    }				// end loop earthquakes
// get maximum, smoothed rate
    maxv=0.0; imaxv=0;
    for(cnt=0; cnt<seisr->nv; cnt++) {
      if (seisr->asum[cnt]>maxv) {
        maxv=seisr->asum[cnt];
        imaxv=cnt;
      } 
    }
    fprintf(stdout,"Maximum, smoothed rate (eq nos/cell); grid-cell number: %.2f %d\n", maxv, imaxv);
// sum earthquake numbers to ensure that smoothing preserves numbers
    sum_eqs=0.0;
    for(cnt=0; cnt<seisr->nv; cnt++) {
      sum_eqs=sum_eqs+seisr->asum[cnt];
    }
    fprintf(stderr,"Over %d cells, %.2f earthquakes recovered, of %.2f effective events smoothed (%d actual).\n", seisr->nv, sum_eqs, tot_asum, catn->nv);
  } 				// end smoothing option


}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x98, %rsp
movq %rcx, %r15
movq %rdx, %r13
movq %rsi, %rbp
movq %rdi, %rbx
cmpl $0x0, 0x8(%rsi)
movl (%rdx), %edx
jne 0x4459
testl %edx, %edx
jle 0x43f3
movq %r9, 0x38(%rsp)
movq %r8, 0x20(%rsp)
xorl %r14d, %r14d
movss 0x18(%r15), %xmm0
subss 0x75304(%r13,%r14,4), %xmm0
divss 0x20(%r15), %xmm0
callq 0x1070
cvttss2si %xmm0, %r12d
movss 0x668a4(%r13,%r14,4), %xmm0
subss 0xc(%r15), %xmm0
divss 0x1c(%r15), %xmm0
callq 0x1070
cvttss2si %xmm0, %eax
imull (%r15), %r12d
addl %eax, %r12d
movl %r12d, 0x493e4(%r13,%r14,4)
movq %rbp, %rdi
movq %r13, %rsi
movq 0x20(%rsp), %rdx
movq 0x38(%rsp), %rcx
movl %r14d, %r8d
callq 0x41b0
movslq %r12d, %rax
incl (%rbx,%rax,4)
movss 0xa6040(%rbx,%rax,4), %xmm1
addss %xmm0, %xmm1
movss %xmm1, 0xa6040(%rbx,%rax,4)
addss 0x14c080(%rbx,%rax,4), %xmm0
movss %xmm0, 0x14c080(%rbx,%rax,4)
incq %r14
movslq (%r13), %rdx
cmpq %rdx, %r14
jl 0x434f
movq 0x5bfe(%rip), %rax      # 0x9ff8
movq (%rax), %rdi
leaq 0x2e49(%rip), %rsi      # 0x724d
xorl %ebp, %ebp
xorl %eax, %eax
callq 0x1100
movslq 0x298100(%rbx), %rax
testq %rax, %rax
jle 0x4a62
xorl %ecx, %ecx
xorps %xmm0, %xmm0
xorps %xmm1, %xmm1
xorl %ebp, %ebp
movaps %xmm1, %xmm2
movss 0x14c080(%rbx,%rcx,4), %xmm1
addl (%rbx,%rcx,4), %ebp
addss %xmm1, %xmm0
maxss %xmm2, %xmm1
incq %rcx
cmpq %rcx, %rax
jne 0x4427
cvtss2sd %xmm0, %xmm0
cvtss2sd %xmm1, %xmm1
movsd %xmm1, 0x40(%rsp)
jmp 0x4a6b
testl %edx, %edx
movq %r9, 0x38(%rsp)
movq %r8, 0x20(%rsp)
jle 0x44fc
xorl %r14d, %r14d
movss 0x18(%r15), %xmm0
subss 0x75304(%r13,%r14,4), %xmm0
divss 0x20(%r15), %xmm0
callq 0x1070
cvttss2si %xmm0, %r12d
movss 0x668a4(%r13,%r14,4), %xmm0
subss 0xc(%r15), %xmm0
divss 0x1c(%r15), %xmm0
callq 0x1070
cvttss2si %xmm0, %eax
imull (%r15), %r12d
addl %eax, %r12d
movl %r12d, 0x493e4(%r13,%r14,4)
movq %rbp, %rdi
movq %r13, %rsi
movq 0x20(%rsp), %rdx
movq 0x38(%rsp), %rcx
movl %r14d, %r8d
callq 0x41b0
movslq %r12d, %rax
incl (%rbx,%rax,4)
addss 0xa6040(%rbx,%rax,4), %xmm0
movss %xmm0, 0xa6040(%rbx,%rax,4)
incq %r14
movslq (%r13), %rax
cmpq %rax, %r14
jl 0x446e
movslq 0x298100(%rbx), %rax
testq %rax, %rax
jle 0x4524
xorl %ecx, %ecx
movss 0xa6040(%rbx,%rcx,4), %xmm0
movss %xmm0, 0x1f20c0(%rbx,%rcx,4)
incq %rcx
cmpq %rcx, %rax
jne 0x450a
testl %eax, %eax
jle 0x456a
xorl %ecx, %ecx
xorps %xmm1, %xmm1
xorps %xmm0, %xmm0
xorl %r14d, %r14d
xorl %edx, %edx
movaps %xmm0, %xmm2
movss 0x1f20c0(%rbx,%rcx,4), %xmm0
ucomiss %xmm2, %xmm0
cmoval %ecx, %edx
maxss %xmm2, %xmm0
addl (%rbx,%rcx,4), %r14d
addss 0xa6040(%rbx,%rcx,4), %xmm1
incq %rcx
cmpq %rcx, %rax
jne 0x4535
cvtss2sd %xmm0, %xmm0
cvtss2sd %xmm1, %xmm1
jmp 0x4575
xorps %xmm0, %xmm0
xorl %edx, %edx
xorl %r14d, %r14d
xorps %xmm1, %xmm1
movsd %xmm1, 0x50(%rsp)
movq 0x5a56(%rip), %r12      # 0x9fd8
movq (%r12), %rdi
leaq 0x2d7c(%rip), %rsi      # 0x7309
movb $0x1, %al
callq 0x1100
movq (%r12), %rdi
leaq 0x2dac(%rip), %rsi      # 0x734b
movsd 0x50(%rsp), %xmm0
movl %r14d, %edx
movb $0x1, %al
callq 0x1100
movq 0x5a42(%rip), %rax      # 0x9ff8
movq (%rax), %rcx
leaq 0x2dd0(%rip), %rdi      # 0x7390
movl $0x13, %esi
movl $0x1, %edx
callq 0x11a0
cmpl $0x0, (%r13)
jle 0x4a38
xorl %r14d, %r14d
movq %r13, 0x58(%rsp)
movss 0x18(%r15), %xmm0
subss 0x75304(%r13,%r14,4), %xmm0
divss 0x20(%r15), %xmm0
callq 0x1070
cvttss2si %xmm0, %r12d
movss 0x668a4(%r13,%r14,4), %xmm0
subss 0xc(%r15), %xmm0
divss 0x1c(%r15), %xmm0
callq 0x1070
movq %r13, %rsi
cvttss2si %xmm0, %r13d
movq %rbp, %rdi
movq 0x20(%rsp), %rdx
movq 0x38(%rsp), %rcx
movl %r14d, %r8d
callq 0x41b0
movss %xmm0, 0x10(%rsp)
testl %r13d, %r13d
js 0x4aad
cmpl %r13d, (%r15)
jle 0x4aad
testl %r12d, %r12d
js 0x4aad
cmpl %r12d, 0x4(%r15)
jle 0x4aad
xorps %xmm0, %xmm0
cvtss2sd 0xc(%r15), %xmm0
xorps %xmm1, %xmm1
cvtsi2sd %r13d, %xmm1
movsd 0x2b5a(%rip), %xmm3     # 0x71d8
addsd %xmm3, %xmm1
xorps %xmm2, %xmm2
cvtss2sd 0x1c(%r15), %xmm2
mulsd %xmm1, %xmm2
addsd %xmm0, %xmm2
xorps %xmm0, %xmm0
cvtsd2ss %xmm2, %xmm0
movss %xmm0, 0x34(%rsp)
xorps %xmm0, %xmm0
cvtss2sd 0x18(%r15), %xmm0
xorps %xmm1, %xmm1
cvtsi2sd %r12d, %xmm1
addsd %xmm3, %xmm1
xorps %xmm2, %xmm2
cvtss2sd 0x20(%r15), %xmm2
mulsd %xmm1, %xmm2
subsd %xmm2, %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, 0x14(%rsp)
movq %rbp, %rdi
movq 0x58(%rsp), %rsi
movq %r14, 0x90(%rsp)
movl %r14d, %edx
callq 0x3fdc
movaps %xmm0, %xmm1
addss %xmm0, %xmm1
movss %xmm0, 0x30(%rsp)
mulss %xmm0, %xmm1
movss %xmm1, 0x2c(%rsp)
cmpl $0x0, (%r15)
jle 0x4873
xorl %r14d, %r14d
xorps %xmm1, %xmm1
cmpl $0x0, 0x4(%r15)
jle 0x4865
xorps %xmm0, %xmm0
cvtsi2ss %r14d, %xmm0
movss %xmm0, 0x74(%rsp)
xorl %r12d, %r12d
movss %xmm1, 0x40(%rsp)
movss 0x1c(%r15), %xmm0
mulss 0x74(%rsp), %xmm0
addss 0xc(%r15), %xmm0
movss %xmm0, 0x1c(%rsp)
movss 0x18(%r15), %xmm0
xorps %xmm1, %xmm1
cvtsi2ss %r12d, %xmm1
mulss 0x20(%r15), %xmm1
subss %xmm1, %xmm0
movss %xmm0, 0xc(%rsp)
leaq 0x78(%rsp), %rax
movq %rax, (%rsp)
leaq 0x14(%rsp), %rdi
leaq 0x34(%rsp), %rsi
leaq 0xc(%rsp), %rdx
leaq 0x1c(%rsp), %rcx
leaq 0x18(%rsp), %r8
leaq 0x7c(%rsp), %r9
callq 0x3566
movss 0x18(%rsp), %xmm0
mulss %xmm0, %xmm0
movaps %xmm0, 0x80(%rsp)
xorps %xmm0, %xmm0
cvtss2sd 0xc(%rsp), %xmm0
movsd 0x2a2a(%rip), %xmm1     # 0x71e0
mulsd %xmm1, %xmm0
movsd 0x2a26(%rip), %xmm1     # 0x71e8
divsd %xmm1, %xmm0
callq 0x10c0
movsd %xmm0, 0x68(%rsp)
xorps %xmm0, %xmm0
cvtss2sd 0x14(%rsp), %xmm0
mulsd 0x29fe(%rip), %xmm0     # 0x71e0
divsd 0x29fe(%rip), %xmm0     # 0x71e8
callq 0x10c0
movsd %xmm0, 0x60(%rsp)
cmpl $0x1, 0x20(%rbp)
jne 0x4817
movaps 0x80(%rsp), %xmm0
xorps 0x28e6(%rip), %xmm0     # 0x70f0
divss 0x2c(%rsp), %xmm0
callq 0x1060
jmp 0x4837
movss 0x30(%rsp), %xmm0
mulss %xmm0, %xmm0
addss 0x80(%rsp), %xmm0
movss 0x2996(%rip), %xmm1     # 0x71c8
callq 0x1150
movsd 0x68(%rsp), %xmm1
divsd 0x60(%rsp), %xmm1
cvtsd2ss %xmm1, %xmm1
mulss %xmm0, %xmm1
movss 0x40(%rsp), %xmm0
addss %xmm1, %xmm0
movaps %xmm0, %xmm1
incl %r12d
cmpl 0x4(%r15), %r12d
jl 0x472b
incl %r14d
cmpl (%r15), %r14d
jl 0x470f
jmp 0x4876
xorps %xmm1, %xmm1
cmpl $0x0, (%r15)
jle 0x4a1b
movss 0x1a90(%rip), %xmm0     # 0x6318
divss %xmm1, %xmm0
movss 0x10(%rsp), %xmm1
mulss %xmm0, %xmm1
movss %xmm1, 0x10(%rsp)
xorl %r14d, %r14d
cmpl $0x0, 0x4(%r15)
jle 0x4a0f
xorps %xmm0, %xmm0
cvtsi2ss %r14d, %xmm0
movss %xmm0, 0x60(%rsp)
xorl %r12d, %r12d
movl (%r15), %r13d
imull %r12d, %r13d
movss 0x1c(%r15), %xmm0
mulss 0x60(%rsp), %xmm0
addss 0xc(%r15), %xmm0
movss %xmm0, 0x1c(%rsp)
movss 0x18(%r15), %xmm0
xorps %xmm1, %xmm1
cvtsi2ss %r12d, %xmm1
mulss 0x20(%r15), %xmm1
subss %xmm1, %xmm0
movss %xmm0, 0xc(%rsp)
leaq 0x78(%rsp), %rax
movq %rax, (%rsp)
leaq 0x14(%rsp), %rdi
leaq 0x34(%rsp), %rsi
leaq 0xc(%rsp), %rdx
leaq 0x1c(%rsp), %rcx
leaq 0x18(%rsp), %r8
leaq 0x7c(%rsp), %r9
callq 0x3566
movss 0x18(%rsp), %xmm0
mulss %xmm0, %xmm0
movaps %xmm0, 0x40(%rsp)
xorps %xmm0, %xmm0
cvtss2sd 0xc(%rsp), %xmm0
movsd 0x289c(%rip), %xmm1     # 0x71e0
mulsd %xmm1, %xmm0
movsd 0x2898(%rip), %xmm1     # 0x71e8
divsd %xmm1, %xmm0
callq 0x10c0
movsd %xmm0, 0x68(%rsp)
xorps %xmm0, %xmm0
cvtss2sd 0x14(%rsp), %xmm0
mulsd 0x2870(%rip), %xmm0     # 0x71e0
divsd 0x2870(%rip), %xmm0     # 0x71e8
callq 0x10c0
movsd %xmm0, 0x80(%rsp)
cmpl $0x1, 0x20(%rbp)
jne 0x49a5
movaps 0x40(%rsp), %xmm0
xorps 0x2758(%rip), %xmm0     # 0x70f0
divss 0x2c(%rsp), %xmm0
callq 0x1060
jmp 0x49c2
movss 0x30(%rsp), %xmm0
mulss %xmm0, %xmm0
addss 0x40(%rsp), %xmm0
movss 0x280b(%rip), %xmm1     # 0x71c8
callq 0x1150
mulss 0x10(%rsp), %xmm0
addl %r14d, %r13d
movq 0x20(%rsp), %rax
cmpl $0x0, 0x8(%rax)
movslq %r13d, %rax
je 0x49f0
movsd 0x68(%rsp), %xmm1
divsd 0x80(%rsp), %xmm1
cvtsd2ss %xmm1, %xmm1
mulss %xmm1, %xmm0
addss 0x14c080(%rbx,%rax,4), %xmm0
movss %xmm0, 0x14c080(%rbx,%rax,4)
incl %r12d
cmpl 0x4(%r15), %r12d
jl 0x48bb
incl %r14d
cmpl (%r15), %r14d
jl 0x489f
movq 0x90(%rsp), %r14
incq %r14
movq 0x58(%rsp), %r13
movslq (%r13), %rax
cmpq %rax, %r14
jl 0x45e2
leaq 0x298100(%rbx), %rdi
movq %rbx, %rsi
movq %r13, %rdx
movsd 0x50(%rsp), %xmm0
callq 0x19e4
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
xorps %xmm0, %xmm0
movsd %xmm0, 0x40(%rsp)
movq 0x5566(%rip), %rbx      # 0x9fd8
movq (%rbx), %rdi
leaq 0x2816(%rip), %rsi      # 0x7292
movl %ebp, %edx
movb $0x1, %al
callq 0x1100
movq (%rbx), %rdi
leaq 0x2852(%rip), %rsi      # 0x72e1
movsd 0x40(%rsp), %xmm0
movb $0x1, %al
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x1100
movq 0x5544(%rip), %rax      # 0x9ff8
movq (%rax), %rdi
movq 0x58(%rsp), %rax
xorps %xmm0, %xmm0
cvtss2sd 0x668a4(%rax,%r14,4), %xmm0
xorps %xmm1, %xmm1
cvtss2sd 0x75304(%rax,%r14,4), %xmm1
movl (%r15), %r8d
movl 0x4(%r15), %r9d
leaq 0x28c0(%rip), %rsi      # 0x73a4
movl %r13d, %edx
movl %r12d, %ecx
movb $0x2, %al
callq 0x1100
movl $0x1, %edi
callq 0x1190
nop