// File: /workspace/github_c_makefile_star2_O2/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 %r9, 0x50(%rsp)
movq %r8, 0x40(%rsp)
movq %rcx, %r12
movq %rdx, %r13
movq %rsi, %rbp
movq %rdi, %rbx
cmpl $0x0, 0x8(%rsi)
jne 0x3d8e
xorl %r14d, %r14d
movslq (%r13), %rdx
cmpq %rdx, %r14
jge 0x3e29
movss 0x18(%r12), %xmm0
subss 0x75304(%r13,%r14,4), %xmm0
divss 0x20(%r12), %xmm0
callq 0x1070
cvttss2si %xmm0, %r15d
movss 0x668a4(%r13,%r14,4), %xmm0
subss 0xc(%r12), %xmm0
divss 0x1c(%r12), %xmm0
callq 0x1070
cvttss2si %xmm0, %eax
imull (%r12), %r15d
addl %eax, %r15d
movl %r15d, 0x493e4(%r13,%r14,4)
movq %rbp, %rdi
movq %r13, %rsi
movq 0x40(%rsp), %rdx
movq 0x50(%rsp), %rcx
movl %r14d, %r8d
callq 0x3b47
movslq %r15d, %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
jmp 0x3ce0
xorl %r14d, %r14d
movslq (%r13), %rax
cmpq %rax, %r14
jge 0x3e7b
movss 0x18(%r12), %xmm0
subss 0x75304(%r13,%r14,4), %xmm0
divss 0x20(%r12), %xmm0
callq 0x1070
cvttss2si %xmm0, %r15d
movss 0x668a4(%r13,%r14,4), %xmm0
subss 0xc(%r12), %xmm0
divss 0x1c(%r12), %xmm0
callq 0x1070
cvttss2si %xmm0, %eax
imull (%r12), %r15d
addl %eax, %r15d
movl %r15d, 0x493e4(%r13,%r14,4)
movq %rbp, %rdi
movq %r13, %rsi
movq 0x40(%rsp), %rdx
movq 0x50(%rsp), %rcx
movl %r14d, %r8d
callq 0x3b47
movslq %r15d, %rax
incl (%rbx,%rax,4)
addss 0xa6040(%rbx,%rax,4), %xmm0
movss %xmm0, 0xa6040(%rbx,%rax,4)
incq %r14
jmp 0x3d91
movq 0x61c8(%rip), %rax      # 0x9ff8
movq (%rax), %rdi
leaq 0x3423(%rip), %rsi      # 0x725d
xorl %r14d, %r14d
xorl %eax, %eax
callq 0x10f0
movl 0x298100(%rbx), %eax
testl %eax, %eax
cmovlel %r14d, %eax
xorps %xmm2, %xmm2
xorl %edx, %edx
xorps %xmm0, %xmm0
cmpq %r14, %rax
je 0x3ea4
movss 0x14c080(%rbx,%r14,4), %xmm1
addl (%rbx,%r14,4), %edx
addss %xmm1, %xmm0
maxss %xmm2, %xmm1
incq %r14
movaps %xmm1, %xmm2
jmp 0x3e58
movl 0x298100(%rbx), %eax
xorl %ecx, %ecx
testl %eax, %eax
cmovlel %ecx, %eax
cmpq %rcx, %rax
je 0x3eee
movss 0xa6040(%rbx,%rcx,4), %xmm0
movss %xmm0, 0x1f20c0(%rbx,%rcx,4)
incq %rcx
jmp 0x3e88
movq 0x612d(%rip), %rbx      # 0x9fd8
movq (%rbx), %rdi
cvtss2sd %xmm0, %xmm0
leaq 0x33e9(%rip), %rsi      # 0x72a2
movb $0x1, %al
movss %xmm2, 0x30(%rsp)
callq 0x10f0
movq (%rbx), %rdi
cvtss2sd 0x30(%rsp), %xmm0
leaq 0x341b(%rip), %rsi      # 0x72f1
movb $0x1, %al
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x10f0
xorps %xmm0, %xmm0
xorl %ecx, %ecx
xorl %edx, %edx
xorl %r14d, %r14d
xorps %xmm2, %xmm2
cmpq %rcx, %rax
je 0x3f28
movss 0x1f20c0(%rbx,%rcx,4), %xmm1
ucomiss %xmm0, %xmm1
cmoval %ecx, %edx
maxss %xmm0, %xmm1
addl (%rbx,%rcx,4), %r14d
addss 0xa6040(%rbx,%rcx,4), %xmm2
incq %rcx
movaps %xmm1, %xmm0
jmp 0x3efb
movq 0x60a9(%rip), %r15      # 0x9fd8
movq (%r15), %rdi
cvtss2sd %xmm0, %xmm0
leaq 0x33dc(%rip), %rsi      # 0x7319
movb $0x1, %al
movss %xmm2, 0x30(%rsp)
callq 0x10f0
movq (%r15), %rdi
cvtss2sd 0x30(%rsp), %xmm0
leaq 0x3401(%rip), %rsi      # 0x735b
movsd %xmm0, 0x88(%rsp)
movl %r14d, %edx
movb $0x1, %al
callq 0x10f0
movq 0x6084(%rip), %rax      # 0x9ff8
movq (%rax), %rcx
leaq 0x3422(%rip), %rdi      # 0x73a0
pushq $0x13
popq %rsi
pushq $0x1
popq %rdx
callq 0x1190
movq %r13, %r15
xorl %r13d, %r13d
movq %r15, 0x90(%rsp)
movslq (%r15), %rax
cmpq %rax, %r13
jge 0x43d3
movss 0x18(%r12), %xmm0
subss 0x75304(%r15,%r13,4), %xmm0
divss 0x20(%r12), %xmm0
callq 0x1070
cvttss2si %xmm0, %eax
movl %eax, 0x10(%rsp)
movss 0x668a4(%r15,%r13,4), %xmm0
subss 0xc(%r12), %xmm0
divss 0x1c(%r12), %xmm0
callq 0x1070
cvttss2si %xmm0, %eax
movl %eax, 0x30(%rsp)
movq %rbp, %rdi
movq %r15, %r14
movq %r15, %rsi
movq 0x40(%rsp), %rdx
movq 0x50(%rsp), %rcx
movq %r13, 0x48(%rsp)
movl %r13d, %r8d
callq 0x3b47
movl 0x30(%rsp), %edx
movss %xmm0, 0x18(%rsp)
movl (%r12), %r8d
testl %edx, %edx
js 0x4483
movl 0x4(%r12), %r15d
cmpl %edx, %r8d
jle 0x4488
movl 0x10(%rsp), %ecx
testl %ecx, %ecx
js 0x4495
cmpl %ecx, %r15d
jle 0x4495
cvtss2sd 0xc(%r12), %xmm0
cvtsi2sd %edx, %xmm1
movsd 0x318f(%rip), %xmm3     # 0x71e8
addsd %xmm3, %xmm1
cvtss2sd 0x1c(%r12), %xmm2
mulsd %xmm1, %xmm2
addsd %xmm0, %xmm2
cvtsd2ss %xmm2, %xmm0
movss %xmm0, 0x2c(%rsp)
cvtss2sd 0x18(%r12), %xmm0
cvtsi2sd %ecx, %xmm1
addsd %xmm3, %xmm1
cvtss2sd 0x20(%r12), %xmm2
mulsd %xmm1, %xmm2
subsd %xmm2, %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, 0xc(%rsp)
movq %rbp, %rdi
movq %r14, %rsi
movq 0x48(%rsp), %rdx
movl %r8d, %r14d
callq 0x3988
movl %r14d, %eax
movaps %xmm0, %xmm1
addss %xmm0, %xmm1
movss %xmm0, 0x28(%rsp)
mulss %xmm0, %xmm1
movss %xmm1, 0x24(%rsp)
xorps %xmm1, %xmm1
xorl %r14d, %r14d
cmpl %eax, %r14d
jge 0x4229
cvtsi2ss %r14d, %xmm0
movss %xmm0, 0x64(%rsp)
xorl %r13d, %r13d
cmpl %r15d, %r13d
jge 0x421d
movss %xmm1, 0x30(%rsp)
movss 0x1c(%r12), %xmm0
mulss 0x64(%rsp), %xmm0
addss 0xc(%r12), %xmm0
movss %xmm0, 0x20(%rsp)
movss 0x18(%r12), %xmm0
cvtsi2ss %r13d, %xmm1
mulss 0x20(%r12), %xmm1
subss %xmm1, %xmm0
movss %xmm0, 0x8(%rsp)
leaq 0x68(%rsp), %rax
movq %rax, (%rsp)
leaq 0xc(%rsp), %rdi
leaq 0x2c(%rsp), %rsi
leaq 0x8(%rsp), %rdx
leaq 0x20(%rsp), %rcx
leaq 0x1c(%rsp), %r8
leaq 0x6c(%rsp), %r9
callq 0x2db4
movss 0x1c(%rsp), %xmm0
mulss %xmm0, %xmm0
movaps %xmm0, 0x70(%rsp)
cvtss2sd 0x8(%rsp), %xmm0
movsd 0x3079(%rip), %xmm1     # 0x71f0
mulsd %xmm1, %xmm0
movsd 0x3075(%rip), %xmm1     # 0x71f8
divsd %xmm1, %xmm0
callq 0x10b0
movsd %xmm0, 0x10(%rsp)
cvtss2sd 0xc(%rsp), %xmm0
mulsd 0x3050(%rip), %xmm0     # 0x71f0
divsd 0x3050(%rip), %xmm0     # 0x71f8
callq 0x10b0
movsd %xmm0, 0x58(%rsp)
cmpl $0x1, 0x20(%rbp)
jne 0x41d2
movaps 0x70(%rsp), %xmm0
xorps 0x2f3b(%rip), %xmm0     # 0x7100
divss 0x24(%rsp), %xmm0
callq 0x1060
jmp 0x41ef
movss 0x28(%rsp), %xmm0
mulss %xmm0, %xmm0
addss 0x70(%rsp), %xmm0
movss 0x2ff2(%rip), %xmm1     # 0x71dc
callq 0x1140
movsd 0x10(%rsp), %xmm1
divsd 0x58(%rsp), %xmm1
cvtsd2ss %xmm1, %xmm1
mulss %xmm0, %xmm1
movss 0x30(%rsp), %xmm0
addss %xmm1, %xmm0
movaps %xmm0, %xmm1
incl %r13d
movl 0x4(%r12), %r15d
jmp 0x40e8
incl %r14d
movl (%r12), %eax
jmp 0x40d1
movss 0x2fa7(%rip), %xmm0     # 0x71d8
divss %xmm1, %xmm0
movss 0x18(%rsp), %xmm1
mulss %xmm0, %xmm1
movss %xmm1, 0x18(%rsp)
xorl %r14d, %r14d
cmpl %eax, %r14d
jge 0x43be
cvtsi2ss %r14d, %xmm0
movss %xmm0, 0x58(%rsp)
xorl %r13d, %r13d
cmpl %r15d, %r13d
jge 0x43b2
movl (%r12), %r15d
imull %r13d, %r15d
movss 0x1c(%r12), %xmm0
mulss 0x58(%rsp), %xmm0
addss 0xc(%r12), %xmm0
movss %xmm0, 0x20(%rsp)
movss 0x18(%r12), %xmm0
cvtsi2ss %r13d, %xmm1
mulss 0x20(%r12), %xmm1
subss %xmm1, %xmm0
movss %xmm0, 0x8(%rsp)
leaq 0x68(%rsp), %rax
movq %rax, (%rsp)
leaq 0xc(%rsp), %rdi
leaq 0x2c(%rsp), %rsi
leaq 0x8(%rsp), %rdx
leaq 0x20(%rsp), %rcx
leaq 0x1c(%rsp), %r8
leaq 0x6c(%rsp), %r9
callq 0x2db4
movss 0x1c(%rsp), %xmm0
mulss %xmm0, %xmm0
movaps %xmm0, 0x30(%rsp)
cvtss2sd 0x8(%rsp), %xmm0
movsd 0x2f00(%rip), %xmm1     # 0x71f0
mulsd %xmm1, %xmm0
movsd 0x2efc(%rip), %xmm1     # 0x71f8
divsd %xmm1, %xmm0
callq 0x10b0
movsd %xmm0, 0x10(%rsp)
cvtss2sd 0xc(%rsp), %xmm0
mulsd 0x2ed7(%rip), %xmm0     # 0x71f0
divsd 0x2ed7(%rip), %xmm0     # 0x71f8
callq 0x10b0
movsd %xmm0, 0x70(%rsp)
cmpl $0x1, 0x20(%rbp)
jne 0x434b
movaps 0x30(%rsp), %xmm0
xorps 0x2dc2(%rip), %xmm0     # 0x7100
divss 0x24(%rsp), %xmm0
callq 0x1060
jmp 0x4368
movss 0x28(%rsp), %xmm0
mulss %xmm0, %xmm0
addss 0x30(%rsp), %xmm0
movss 0x2e79(%rip), %xmm1     # 0x71dc
callq 0x1140
mulss 0x18(%rsp), %xmm0
movq 0x40(%rsp), %rax
cmpl $0x0, 0x8(%rax)
je 0x438d
movsd 0x10(%rsp), %xmm1
divsd 0x70(%rsp), %xmm1
cvtsd2ss %xmm1, %xmm1
mulss %xmm1, %xmm0
addl %r14d, %r15d
movslq %r15d, %rax
addss 0x14c080(%rbx,%rax,4), %xmm0
movss %xmm0, 0x14c080(%rbx,%rax,4)
incl %r13d
movl 0x4(%r12), %r15d
jmp 0x425f
incl %r14d
movl (%r12), %eax
jmp 0x4248
movq 0x48(%rsp), %r13
incq %r13
movq 0x90(%rsp), %r15
jmp 0x3f97
movl 0x298100(%rbx), %eax
xorl %ecx, %ecx
testl %eax, %eax
cmovlel %ecx, %eax
xorps %xmm0, %xmm0
xorl %edx, %edx
cmpq %rcx, %rax
je 0x4405
movss 0x14c080(%rbx,%rcx,4), %xmm1
ucomiss %xmm0, %xmm1
cmoval %ecx, %edx
maxss %xmm0, %xmm1
incq %rcx
movaps %xmm1, %xmm0
jmp 0x43e5
movq 0x5bcc(%rip), %rax      # 0x9fd8
movq (%rax), %rdi
cvtss2sd %xmm0, %xmm0
leaq 0x2ff5(%rip), %rsi      # 0x740f
movb $0x1, %al
callq 0x10f0
movl 0x298100(%rbx), %edx
xorl %eax, %eax
testl %edx, %edx
movl $0x0, %ecx
cmovgl %edx, %ecx
xorps %xmm0, %xmm0
cmpq %rax, %rcx
je 0x4449
addss 0x14c080(%rbx,%rax,4), %xmm0
incq %rax
jmp 0x4436
movq 0x5ba8(%rip), %rax      # 0x9ff8
movq (%rax), %rdi
cvtss2sd %xmm0, %xmm0
movl (%r15), %ecx
leaq 0x2fef(%rip), %rsi      # 0x7450
movsd 0x88(%rsp), %xmm1
movb $0x2, %al
callq 0x10f0
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl 0x4(%r12), %r15d
movq 0x5b69(%rip), %rax      # 0x9ff8
movl 0x10(%rsp), %ecx
jmp 0x449c
movq 0x5b5c(%rip), %rax      # 0x9ff8
movq (%rax), %rdi
movq 0x48(%rsp), %rax
cvtss2sd 0x668a4(%r14,%rax,4), %xmm0
cvtss2sd 0x75304(%r14,%rax,4), %xmm1
leaq 0x2ef5(%rip), %rsi      # 0x73b4
movl %r15d, %r9d
movb $0x2, %al
callq 0x10f0
pushq $0x1
popq %rdi
callq 0x1180
nopl (%rax)