// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0xd0, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
movq %r9, -0x30(%rbp)
movl $0x0, -0x58(%rbp)
xorps %xmm0, %xmm0
movss %xmm0, -0x60(%rbp)
xorps %xmm0, %xmm0
movss %xmm0, -0xa8(%rbp)
movl $0x0, -0x54(%rbp)
movl $0x1, -0x4c(%rbp)
movl $0x0, -0x50(%rbp)
movq -0x10(%rbp), %rax
cmpl $0x0, 0x8(%rax)
jne 0x4dc1
movl $0x0, -0x34(%rbp)
movl -0x34(%rbp), %eax
movq -0x18(%rbp), %rcx
cmpl (%rcx), %eax
jge 0x4cbb
movq -0x20(%rbp), %rax
movss 0x18(%rax), %xmm0
movq -0x18(%rbp), %rax
movslq -0x34(%rbp), %rcx
subss 0x75304(%rax,%rcx,4), %xmm0
movq -0x20(%rbp), %rax
divss 0x20(%rax), %xmm0
callq 0x1070
cvttss2si %xmm0, %eax
movl %eax, -0x3c(%rbp)
movq -0x18(%rbp), %rax
movslq -0x34(%rbp), %rcx
movss 0x668a4(%rax,%rcx,4), %xmm0
movq -0x20(%rbp), %rax
subss 0xc(%rax), %xmm0
movq -0x20(%rbp), %rax
divss 0x1c(%rax), %xmm0
callq 0x1070
cvttss2si %xmm0, %eax
movl %eax, -0x38(%rbp)
movl -0x3c(%rbp), %eax
movq -0x20(%rbp), %rcx
imull (%rcx), %eax
addl -0x38(%rbp), %eax
movl %eax, -0x48(%rbp)
movl -0x48(%rbp), %edx
movq -0x18(%rbp), %rax
movslq -0x34(%rbp), %rcx
movl %edx, 0x493e4(%rax,%rcx,4)
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x28(%rbp), %rdx
movq -0x30(%rbp), %rcx
movl -0x34(%rbp), %r8d
callq 0x4920
movss %xmm0, -0x6c(%rbp)
movss -0x6c(%rbp), %xmm0
movss %xmm0, -0x68(%rbp)
movq -0x8(%rbp), %rax
movslq -0x48(%rbp), %rcx
movl (%rax,%rcx,4), %edx
addl $0x1, %edx
movl %edx, (%rax,%rcx,4)
movq -0x8(%rbp), %rax
movslq -0x48(%rbp), %rcx
movss 0xa6040(%rax,%rcx,4), %xmm0
addss -0x68(%rbp), %xmm0
movq -0x8(%rbp), %rax
movslq -0x48(%rbp), %rcx
movss %xmm0, 0xa6040(%rax,%rcx,4)
movq -0x8(%rbp), %rax
movslq -0x48(%rbp), %rcx
movss 0x14c080(%rax,%rcx,4), %xmm0
addss -0x68(%rbp), %xmm0
movq -0x8(%rbp), %rax
movslq -0x48(%rbp), %rcx
movss %xmm0, 0x14c080(%rax,%rcx,4)
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x4b97
movq 0x7336(%rip), %rax      # 0xbff8
movq (%rax), %rdi
movq -0x18(%rbp), %rax
movl (%rax), %edx
leaq 0x4563(%rip), %rsi      # 0x9235
movb $0x0, %al
callq 0x10e0
xorps %xmm0, %xmm0
movss %xmm0, -0x60(%rbp)
movl $0x0, -0x58(%rbp)
xorps %xmm0, %xmm0
movss %xmm0, -0x64(%rbp)
movl $0x0, -0x5c(%rbp)
movl $0x0, -0x34(%rbp)
movl -0x34(%rbp), %eax
movq -0x8(%rbp), %rcx
cmpl 0x298100(%rcx), %eax
jge 0x4d77
movq -0x8(%rbp), %rax
movslq -0x34(%rbp), %rcx
movss 0x14c080(%rax,%rcx,4), %xmm0
ucomiss -0x60(%rbp), %xmm0
jbe 0x4d40
movq -0x8(%rbp), %rax
movslq -0x34(%rbp), %rcx
movss 0x14c080(%rax,%rcx,4), %xmm0
movss %xmm0, -0x60(%rbp)
movl -0x34(%rbp), %eax
movl %eax, -0x58(%rbp)
movl -0x5c(%rbp), %eax
movq -0x8(%rbp), %rcx
movslq -0x34(%rbp), %rdx
addl (%rcx,%rdx,4), %eax
movl %eax, -0x5c(%rbp)
movss -0x64(%rbp), %xmm0
movq -0x8(%rbp), %rax
movslq -0x34(%rbp), %rcx
addss 0x14c080(%rax,%rcx,4), %xmm0
movss %xmm0, -0x64(%rbp)
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x4cfe
movq 0x725a(%rip), %rax      # 0xbfd8
movq (%rax), %rdi
movss -0x64(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
movl -0x5c(%rbp), %edx
leaq 0x44e6(%rip), %rsi      # 0x927a
movb $0x1, %al
callq 0x10e0
movq 0x7236(%rip), %rax      # 0xbfd8
movq (%rax), %rdi
movss -0x60(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
leaq 0x4514(%rip), %rsi      # 0x92c9
movb $0x1, %al
callq 0x10e0
jmp 0x59c1
movl $0x0, -0x34(%rbp)
movl -0x34(%rbp), %eax
movq -0x18(%rbp), %rcx
cmpl (%rcx), %eax
jge 0x4ec5
movq -0x20(%rbp), %rax
movss 0x18(%rax), %xmm0
movq -0x18(%rbp), %rax
movslq -0x34(%rbp), %rcx
subss 0x75304(%rax,%rcx,4), %xmm0
movq -0x20(%rbp), %rax
divss 0x20(%rax), %xmm0
callq 0x1070
cvttss2si %xmm0, %eax
movl %eax, -0x3c(%rbp)
movq -0x18(%rbp), %rax
movslq -0x34(%rbp), %rcx
movss 0x668a4(%rax,%rcx,4), %xmm0
movq -0x20(%rbp), %rax
subss 0xc(%rax), %xmm0
movq -0x20(%rbp), %rax
divss 0x1c(%rax), %xmm0
callq 0x1070
cvttss2si %xmm0, %eax
movl %eax, -0x38(%rbp)
movl -0x3c(%rbp), %eax
movq -0x20(%rbp), %rcx
imull (%rcx), %eax
addl -0x38(%rbp), %eax
movl %eax, -0x48(%rbp)
movl -0x48(%rbp), %edx
movq -0x18(%rbp), %rax
movslq -0x34(%rbp), %rcx
movl %edx, 0x493e4(%rax,%rcx,4)
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x28(%rbp), %rdx
movq -0x30(%rbp), %rcx
movl -0x34(%rbp), %r8d
callq 0x4920
movss %xmm0, -0x6c(%rbp)
movss -0x6c(%rbp), %xmm0
movss %xmm0, -0x68(%rbp)
movq -0x8(%rbp), %rax
movslq -0x48(%rbp), %rcx
movl (%rax,%rcx,4), %edx
addl $0x1, %edx
movl %edx, (%rax,%rcx,4)
movq -0x8(%rbp), %rax
movslq -0x48(%rbp), %rcx
movss 0xa6040(%rax,%rcx,4), %xmm0
addss -0x68(%rbp), %xmm0
movq -0x8(%rbp), %rax
movslq -0x48(%rbp), %rcx
movss %xmm0, 0xa6040(%rax,%rcx,4)
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x4dc8
movl $0x0, -0x34(%rbp)
movl -0x34(%rbp), %eax
movq -0x8(%rbp), %rcx
cmpl 0x298100(%rcx), %eax
jge 0x4f08
movq -0x8(%rbp), %rax
movslq -0x34(%rbp), %rcx
movss 0xa6040(%rax,%rcx,4), %xmm0
movq -0x8(%rbp), %rax
movslq -0x34(%rbp), %rcx
movss %xmm0, 0x1f20c0(%rax,%rcx,4)
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x4ecc
xorps %xmm0, %xmm0
movss %xmm0, -0x60(%rbp)
movl $0x0, -0x58(%rbp)
xorps %xmm0, %xmm0
movss %xmm0, -0x64(%rbp)
movl $0x0, -0x5c(%rbp)
movl $0x0, -0x34(%rbp)
movl -0x34(%rbp), %eax
movq -0x8(%rbp), %rcx
cmpl 0x298100(%rcx), %eax
jge 0x4fa6
movq -0x8(%rbp), %rax
movslq -0x34(%rbp), %rcx
movss 0x1f20c0(%rax,%rcx,4), %xmm0
ucomiss -0x60(%rbp), %xmm0
jbe 0x4f6f
movq -0x8(%rbp), %rax
movslq -0x34(%rbp), %rcx
movss 0x1f20c0(%rax,%rcx,4), %xmm0
movss %xmm0, -0x60(%rbp)
movl -0x34(%rbp), %eax
movl %eax, -0x58(%rbp)
movl -0x5c(%rbp), %eax
movq -0x8(%rbp), %rcx
movslq -0x34(%rbp), %rdx
addl (%rcx,%rdx,4), %eax
movl %eax, -0x5c(%rbp)
movss -0x64(%rbp), %xmm0
movq -0x8(%rbp), %rax
movslq -0x34(%rbp), %rcx
addss 0xa6040(%rax,%rcx,4), %xmm0
movss %xmm0, -0x64(%rbp)
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x4f2d
movq 0x702b(%rip), %rax      # 0xbfd8
movq (%rax), %rdi
movss -0x60(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
movl -0x58(%rbp), %edx
leaq 0x432e(%rip), %rsi      # 0x92f1
movb $0x1, %al
callq 0x10e0
movq 0x7007(%rip), %rax      # 0xbfd8
movq (%rax), %rdi
movss -0x64(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
movl -0x5c(%rbp), %edx
leaq 0x434c(%rip), %rsi      # 0x9333
movb $0x1, %al
callq 0x10e0
movq 0x7003(%rip), %rax      # 0xbff8
movq (%rax), %rdi
leaq 0x4379(%rip), %rsi      # 0x9378
movb $0x0, %al
callq 0x10e0
movl $0x0, -0x34(%rbp)
movl -0x34(%rbp), %eax
movq -0x18(%rbp), %rcx
cmpl (%rcx), %eax
jge 0x58ae
movq -0x20(%rbp), %rax
movss 0x18(%rax), %xmm0
movq -0x18(%rbp), %rax
movslq -0x34(%rbp), %rcx
subss 0x75304(%rax,%rcx,4), %xmm0
movq -0x20(%rbp), %rax
divss 0x20(%rax), %xmm0
callq 0x1070
cvttss2si %xmm0, %eax
movl %eax, -0x44(%rbp)
movq -0x18(%rbp), %rax
movslq -0x34(%rbp), %rcx
movss 0x668a4(%rax,%rcx,4), %xmm0
movq -0x20(%rbp), %rax
subss 0xc(%rax), %xmm0
movq -0x20(%rbp), %rax
divss 0x1c(%rax), %xmm0
callq 0x1070
cvttss2si %xmm0, %eax
movl %eax, -0x40(%rbp)
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x28(%rbp), %rdx
movq -0x30(%rbp), %rcx
movl -0x34(%rbp), %r8d
callq 0x4920
movss %xmm0, -0x6c(%rbp)
movss -0x6c(%rbp), %xmm0
movss %xmm0, -0x68(%rbp)
cmpl $0x0, -0x40(%rbp)
jl 0x50c5
movl -0x40(%rbp), %eax
movq -0x20(%rbp), %rcx
cmpl (%rcx), %eax
jge 0x50c5
cmpl $0x0, -0x44(%rbp)
jl 0x50c5
movl -0x44(%rbp), %eax
movq -0x20(%rbp), %rcx
cmpl 0x4(%rcx), %eax
jl 0x5126
movq 0x6f2c(%rip), %rax      # 0xbff8
movq (%rax), %rdi
movq -0x18(%rbp), %rax
movslq -0x34(%rbp), %rcx
movss 0x668a4(%rax,%rcx,4), %xmm0
cvtss2sd %xmm0, %xmm0
movq -0x18(%rbp), %rax
movslq -0x34(%rbp), %rcx
movss 0x75304(%rax,%rcx,4), %xmm1
cvtss2sd %xmm1, %xmm1
movl -0x40(%rbp), %edx
movl -0x44(%rbp), %ecx
movq -0x20(%rbp), %rax
movl (%rax), %r8d
movq -0x20(%rbp), %rax
movl 0x4(%rax), %r9d
leaq 0x4277(%rip), %rsi      # 0x938c
movb $0x2, %al
callq 0x10e0
movl $0x1, %edi
callq 0x1160
cmpl $0x1, -0x54(%rbp)
jne 0x515d
movq -0x18(%rbp), %rax
movslq -0x34(%rbp), %rcx
movss 0x668a4(%rax,%rcx,4), %xmm0
movss %xmm0, -0x74(%rbp)
movq -0x18(%rbp), %rax
movslq -0x34(%rbp), %rcx
movss 0x75304(%rax,%rcx,4), %xmm0
movss %xmm0, -0x78(%rbp)
jmp 0x524f
cmpl $0x1, -0x4c(%rbp)
jne 0x51f8
movq -0x20(%rbp), %rax
movss 0xc(%rax), %xmm0
cvtss2sd %xmm0, %xmm1
cvtsi2sdl -0x40(%rbp), %xmm0
movsd 0x3f67(%rip), %xmm2     # 0x90e8
addsd %xmm2, %xmm0
movq -0x20(%rbp), %rax
movss 0x1c(%rax), %xmm2
cvtss2sd %xmm2, %xmm2
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, -0x74(%rbp)
movq -0x20(%rbp), %rax
movss 0x18(%rax), %xmm0
cvtss2sd %xmm0, %xmm1
cvtsi2sdl -0x44(%rbp), %xmm0
movsd 0x3f2b(%rip), %xmm2     # 0x90e8
addsd %xmm2, %xmm0
movq -0x20(%rbp), %rax
movss 0x20(%rax), %xmm2
cvtss2sd %xmm2, %xmm2
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, -0x78(%rbp)
jmp 0x524d
movq -0x20(%rbp), %rax
movss 0xc(%rax), %xmm1
cvtsi2ssl -0x40(%rbp), %xmm0
movq -0x20(%rbp), %rax
movss 0x1c(%rax), %xmm2
mulss %xmm2, %xmm0
addss %xmm1, %xmm0
movss %xmm0, -0x74(%rbp)
movq -0x20(%rbp), %rax
movss 0x18(%rax), %xmm1
cvtsi2ssl -0x44(%rbp), %xmm0
movq -0x20(%rbp), %rax
movss 0x20(%rax), %xmm2
movd %xmm0, %eax
xorl $0x80000000, %eax       # imm = 0x80000000
movd %eax, %xmm0
mulss %xmm2, %xmm0
addss %xmm1, %xmm0
movss %xmm0, -0x78(%rbp)
jmp 0x524f
xorps %xmm0, %xmm0
movss %xmm0, -0xa0(%rbp)
xorps %xmm0, %xmm0
movss %xmm0, -0xa4(%rbp)
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movl -0x34(%rbp), %edx
callq 0x4600
movss %xmm0, -0x84(%rbp)
movss 0x3a8b(%rip), %xmm0     # 0x8d10
mulss -0x84(%rbp), %xmm0
mulss -0x84(%rbp), %xmm0
movss %xmm0, -0x98(%rbp)
movl $0x0, -0x38(%rbp)
movl -0x38(%rbp), %eax
movq -0x20(%rbp), %rcx
cmpl (%rcx), %eax
jge 0x5525
movl $0x0, -0x3c(%rbp)
movl -0x3c(%rbp), %eax
movq -0x20(%rbp), %rcx
cmpl 0x4(%rcx), %eax
jge 0x5515
movl -0x3c(%rbp), %eax
movq -0x20(%rbp), %rcx
imull (%rcx), %eax
addl -0x38(%rbp), %eax
movl %eax, -0x48(%rbp)
cmpl $0x1, -0x50(%rbp)
jne 0x5375
movq -0x20(%rbp), %rax
movss 0xc(%rax), %xmm0
cvtss2sd %xmm0, %xmm1
cvtsi2sdl -0x38(%rbp), %xmm0
movsd 0x3dea(%rip), %xmm2     # 0x90e8
addsd %xmm2, %xmm0
movq -0x20(%rbp), %rax
movss 0x1c(%rax), %xmm2
cvtss2sd %xmm2, %xmm2
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, -0x7c(%rbp)
movq -0x20(%rbp), %rax
movss 0x18(%rax), %xmm0
cvtss2sd %xmm0, %xmm1
cvtsi2sdl -0x3c(%rbp), %xmm0
movsd 0x3dae(%rip), %xmm2     # 0x90e8
addsd %xmm2, %xmm0
movq -0x20(%rbp), %rax
movss 0x20(%rax), %xmm2
cvtss2sd %xmm2, %xmm2
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, -0x80(%rbp)
jmp 0x53ca
movq -0x20(%rbp), %rax
movss 0xc(%rax), %xmm1
cvtsi2ssl -0x38(%rbp), %xmm0
movq -0x20(%rbp), %rax
movss 0x1c(%rax), %xmm2
mulss %xmm2, %xmm0
addss %xmm1, %xmm0
movss %xmm0, -0x7c(%rbp)
movq -0x20(%rbp), %rax
movss 0x18(%rax), %xmm1
cvtsi2ssl -0x3c(%rbp), %xmm0
movq -0x20(%rbp), %rax
movss 0x20(%rax), %xmm2
movd %xmm0, %eax
xorl $0x80000000, %eax       # imm = 0x80000000
movd %eax, %xmm0
mulss %xmm2, %xmm0
addss %xmm1, %xmm0
movss %xmm0, -0x80(%rbp)
leaq -0x78(%rbp), %rdi
leaq -0x74(%rbp), %rsi
leaq -0x80(%rbp), %rdx
leaq -0x7c(%rbp), %rcx
leaq -0x88(%rbp), %r8
leaq -0x8c(%rbp), %r9
leaq -0x90(%rbp), %rax
movq %rax, (%rsp)
callq 0x3728
movss -0x88(%rbp), %xmm0
mulss -0x88(%rbp), %xmm0
movss %xmm0, -0x9c(%rbp)
movss -0x80(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
movsd 0x3daf(%rip), %xmm1     # 0x91d0
mulsd %xmm1, %xmm0
movsd 0x3d9b(%rip), %xmm1     # 0x91c8
divsd %xmm1, %xmm0
callq 0x10b0
movsd %xmm0, -0xb8(%rbp)
movss -0x78(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
movsd 0x3d81(%rip), %xmm1     # 0x91d0
mulsd %xmm1, %xmm0
movsd 0x3d6d(%rip), %xmm1     # 0x91c8
divsd %xmm1, %xmm0
callq 0x10b0
movaps %xmm0, %xmm1
movsd -0xb8(%rbp), %xmm0
divsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, -0x70(%rbp)
movq -0x10(%rbp), %rax
cmpl $0x1, 0x20(%rax)
jne 0x54ad
movss 0x3d2e(%rip), %xmm0     # 0x91bc
mulss -0x9c(%rbp), %xmm0
divss -0x98(%rbp), %xmm0
callq 0x1060
movss %xmm0, -0x94(%rbp)
jmp 0x54e2
movss -0x9c(%rbp), %xmm1
movss -0x84(%rbp), %xmm0
movss -0x84(%rbp), %xmm2
mulss %xmm2, %xmm0
addss %xmm1, %xmm0
movss 0x3ce3(%rip), %xmm1     # 0x91b8
callq 0x1120
movss %xmm0, -0x94(%rbp)
movss -0xa4(%rbp), %xmm1
movss -0x94(%rbp), %xmm0
movss -0x70(%rbp), %xmm2
mulss %xmm2, %xmm0
addss %xmm1, %xmm0
movss %xmm0, -0xa4(%rbp)
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x52ba
jmp 0x5517
movl -0x38(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x38(%rbp)
jmp 0x52a4
movss 0x2deb(%rip), %xmm0     # 0x8318
divss -0xa4(%rbp), %xmm0
movss %xmm0, -0xa0(%rbp)
xorps %xmm0, %xmm0
movss %xmm0, -0xac(%rbp)
movl $0x0, -0x38(%rbp)
movl -0x38(%rbp), %eax
movq -0x20(%rbp), %rcx
cmpl (%rcx), %eax
jge 0x589e
movl $0x0, -0x3c(%rbp)
movl -0x3c(%rbp), %eax
movq -0x20(%rbp), %rcx
cmpl 0x4(%rcx), %eax
jge 0x588e
movl -0x3c(%rbp), %eax
movq -0x20(%rbp), %rcx
imull (%rcx), %eax
addl -0x38(%rbp), %eax
movl %eax, -0x48(%rbp)
cmpl $0x0, -0x50(%rbp)
jne 0x55e5
movq -0x20(%rbp), %rax
movss 0xc(%rax), %xmm1
cvtsi2ssl -0x38(%rbp), %xmm0
movq -0x20(%rbp), %rax
movss 0x1c(%rax), %xmm2
mulss %xmm2, %xmm0
addss %xmm1, %xmm0
movss %xmm0, -0x7c(%rbp)
movq -0x20(%rbp), %rax
movss 0x18(%rax), %xmm1
cvtsi2ssl -0x3c(%rbp), %xmm0
movq -0x20(%rbp), %rax
movss 0x20(%rax), %xmm2
movd %xmm0, %eax
xorl $0x80000000, %eax       # imm = 0x80000000
movd %eax, %xmm0
mulss %xmm2, %xmm0
addss %xmm1, %xmm0
movss %xmm0, -0x80(%rbp)
jmp 0x5674
movq -0x20(%rbp), %rax
movss 0xc(%rax), %xmm0
cvtss2sd %xmm0, %xmm1
cvtsi2sdl -0x38(%rbp), %xmm0
movsd 0x3ae9(%rip), %xmm2     # 0x90e8
addsd %xmm2, %xmm0
movq -0x20(%rbp), %rax
movss 0x1c(%rax), %xmm2
cvtss2sd %xmm2, %xmm2
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, -0x7c(%rbp)
movq -0x20(%rbp), %rax
movss 0x18(%rax), %xmm0
cvtss2sd %xmm0, %xmm1
cvtsi2sdl -0x3c(%rbp), %xmm0
movsd 0x3aad(%rip), %xmm2     # 0x90e8
addsd %xmm2, %xmm0
movq -0x20(%rbp), %rax
movss 0x20(%rax), %xmm2
cvtss2sd %xmm2, %xmm2
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, -0x80(%rbp)
leaq -0x78(%rbp), %rdi
leaq -0x74(%rbp), %rsi
leaq -0x80(%rbp), %rdx
leaq -0x7c(%rbp), %rcx
leaq -0x88(%rbp), %r8
leaq -0x8c(%rbp), %r9
leaq -0x90(%rbp), %rax
movq %rax, (%rsp)
callq 0x3728
movss -0x88(%rbp), %xmm0
mulss -0x88(%rbp), %xmm0
movss %xmm0, -0x9c(%rbp)
movss -0x80(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
movsd 0x3b05(%rip), %xmm1     # 0x91d0
mulsd %xmm1, %xmm0
movsd 0x3af1(%rip), %xmm1     # 0x91c8
divsd %xmm1, %xmm0
callq 0x10b0
movsd %xmm0, -0xc0(%rbp)
movss -0x78(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
movsd 0x3ad7(%rip), %xmm1     # 0x91d0
mulsd %xmm1, %xmm0
movsd 0x3ac3(%rip), %xmm1     # 0x91c8
divsd %xmm1, %xmm0
callq 0x10b0
movaps %xmm0, %xmm1
movsd -0xc0(%rbp), %xmm0
divsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, -0x70(%rbp)
movq -0x10(%rbp), %rax
cmpl $0x1, 0x20(%rax)
jne 0x577b
movss -0x68(%rbp), %xmm0
mulss -0xa0(%rbp), %xmm0
movss %xmm0, -0xc4(%rbp)
movss 0x3a6f(%rip), %xmm0     # 0x91bc
mulss -0x9c(%rbp), %xmm0
divss -0x98(%rbp), %xmm0
callq 0x1060
movaps %xmm0, %xmm1
movss -0xc4(%rbp), %xmm0
mulss %xmm1, %xmm0
movss %xmm0, -0x94(%rbp)
jmp 0x57d4
movss -0x68(%rbp), %xmm0
mulss -0xa0(%rbp), %xmm0
movss %xmm0, -0xc8(%rbp)
movss -0x9c(%rbp), %xmm1
movss -0x84(%rbp), %xmm0
movss -0x84(%rbp), %xmm2
mulss %xmm2, %xmm0
addss %xmm1, %xmm0
movss 0x3a00(%rip), %xmm1     # 0x91b8
callq 0x1120
movaps %xmm0, %xmm1
movss -0xc8(%rbp), %xmm0
mulss %xmm1, %xmm0
movss %xmm0, -0x94(%rbp)
movq -0x28(%rbp), %rax
cmpl $0x0, 0x8(%rax)
je 0x583c
movss -0xac(%rbp), %xmm1
movss -0x94(%rbp), %xmm0
movss -0x70(%rbp), %xmm2
mulss %xmm2, %xmm0
addss %xmm1, %xmm0
movss %xmm0, -0xac(%rbp)
movq -0x8(%rbp), %rax
movslq -0x48(%rbp), %rcx
movss 0x14c080(%rax,%rcx,4), %xmm1
movss -0x94(%rbp), %xmm0
movss -0x70(%rbp), %xmm2
mulss %xmm2, %xmm0
addss %xmm1, %xmm0
movq -0x8(%rbp), %rax
movslq -0x48(%rbp), %rcx
movss %xmm0, 0x14c080(%rax,%rcx,4)
jmp 0x587e
movss -0xac(%rbp), %xmm0
addss -0x94(%rbp), %xmm0
movss %xmm0, -0xac(%rbp)
movq -0x8(%rbp), %rax
movslq -0x48(%rbp), %rcx
movss 0x14c080(%rax,%rcx,4), %xmm0
addss -0x94(%rbp), %xmm0
movq -0x8(%rbp), %rax
movslq -0x48(%rbp), %rcx
movss %xmm0, 0x14c080(%rax,%rcx,4)
jmp 0x5880
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x5565
jmp 0x5890
movl -0x38(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x38(%rbp)
jmp 0x554f
jmp 0x58a0
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x500d
xorps %xmm0, %xmm0
movss %xmm0, -0x60(%rbp)
movl $0x0, -0x58(%rbp)
movl $0x0, -0x34(%rbp)
movl -0x34(%rbp), %eax
movq -0x8(%rbp), %rcx
cmpl 0x298100(%rcx), %eax
jge 0x5913
movq -0x8(%rbp), %rax
movslq -0x34(%rbp), %rcx
movss 0x14c080(%rax,%rcx,4), %xmm0
ucomiss -0x60(%rbp), %xmm0
jbe 0x5906
movq -0x8(%rbp), %rax
movslq -0x34(%rbp), %rcx
movss 0x14c080(%rax,%rcx,4), %xmm0
movss %xmm0, -0x60(%rbp)
movl -0x34(%rbp), %eax
movl %eax, -0x58(%rbp)
jmp 0x5908
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x58c4
movq 0x66be(%rip), %rax      # 0xbfd8
movq (%rax), %rdi
movss -0x60(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
movl -0x58(%rbp), %edx
leaq 0x3ab7(%rip), %rsi      # 0x93e7
movb $0x1, %al
callq 0x10e0
xorps %xmm0, %xmm0
movss %xmm0, -0xa8(%rbp)
movl $0x0, -0x34(%rbp)
movl -0x34(%rbp), %eax
movq -0x8(%rbp), %rcx
cmpl 0x298100(%rcx), %eax
jge 0x5984
movss -0xa8(%rbp), %xmm0
movq -0x8(%rbp), %rax
movslq -0x34(%rbp), %rcx
addss 0x14c080(%rax,%rcx,4), %xmm0
movss %xmm0, -0xa8(%rbp)
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x5949
movq 0x666d(%rip), %rax      # 0xbff8
movq (%rax), %rdi
movq -0x8(%rbp), %rax
movl 0x298100(%rax), %edx
movss -0xa8(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
movss -0x64(%rbp), %xmm1
cvtss2sd %xmm1, %xmm1
movq -0x18(%rbp), %rax
movl (%rax), %ecx
leaq 0x3a6e(%rip), %rsi      # 0x9428
movb $0x2, %al
callq 0x10e0
addq $0xd0, %rsp
popq %rbp
retq
nopw (%rax,%rax)