// File: /workspace/github_c_makefile_star2_O0/usgs[P]nshmp-haz-catalogs/src/agrid/adaptive/ck_args_wt_results.c
// Function: write_results_to_file
void write_results_to_file(struct smoothp* smp, struct rates* seisr, struct catalog * cat, struct boundaries *boundR, char *outf)
/*--------------------------------------------------------------------------*/
{
  int cnt;
  float magv;
  float tmpsum=0.0;

// quick check of earthquake numbers
  for (cnt=0; cnt<seisr->nv; cnt++) {
    tmpsum=tmpsum+seisr->asum[cnt]*7;
  }
  fprintf(stderr,"tmpsum (no. M0+ eqs in 7 years) = %.4f\n", tmpsum);

// if a smoothed seismicity model is generated, output results at M0(10^a), M4, M5 and unsmoothed model
  if ( smp->apply_sm ) {
// M0, 10^a values
    magv=0.0;
    write_asum_to_file(seisr, outf, cat, magv);
    fprintf(stderr,"Writing to csv file...\n");
    write_asum_to_csvfile(seisr, outf, cat, boundR, magv);
// M0, 10^a, un-smoothed 
//    write_unsmoothed_asum_to_file(seisr, outf);

// M3.0, 10^(a-3.0b) values
/*
*    magv=3.0;
*    write_asum_to_file(seisr, outf, cat, magv);
// M3.5, 10^(a-3.5b) values
*    magv=3.5;
*    write_asum_to_file(seisr, outf, cat, magv);
// M4, 10^(a-4b) values
*    magv=4.0;
*    write_asum_to_file(seisr, outf, cat, magv);
// M4.5, 10^(a-4.5b) values
*    magv=4.5;
*    write_asum_to_file(seisr, outf, cat, magv);
*
// M5, 10^(a-5b) values
*    magv=5.0;
*    write_asum_to_file(seisr, outf, cat, magv);
*/    
  }
  else {
    magv=0.0;
    write_asum_to_file(seisr, outf, cat, magv);
    magv=cat->minMag;
    write_asum_to_file(seisr, outf, cat, magv);
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
xorps %xmm0, %xmm0
movss %xmm0, -0x34(%rbp)
movl $0x0, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
movq -0x10(%rbp), %rcx
cmpl 0x298100(%rcx), %eax
jge 0x68c0
movss -0x34(%rbp), %xmm1
movq -0x10(%rbp), %rax
movslq -0x2c(%rbp), %rcx
movss 0x14c080(%rax,%rcx,4), %xmm0
movss 0x2d9c(%rip), %xmm2     # 0x9644
mulss %xmm2, %xmm0
addss %xmm1, %xmm0
movss %xmm0, -0x34(%rbp)
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x687b
movq 0x5731(%rip), %rax      # 0xbff8
movq (%rax), %rdi
movss -0x34(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
leaq 0x2f9f(%rip), %rsi      # 0x9879
movb $0x1, %al
callq 0x10e0
movq -0x8(%rbp), %rax
cmpl $0x0, 0x8(%rax)
je 0x693d
xorps %xmm0, %xmm0
movss %xmm0, -0x30(%rbp)
movq -0x10(%rbp), %rdi
movq -0x28(%rbp), %rsi
movq -0x18(%rbp), %rdx
movss -0x30(%rbp), %xmm0
callq 0x59d0
movq 0x56e8(%rip), %rax      # 0xbff8
movq (%rax), %rdi
leaq 0x2f87(%rip), %rsi      # 0x98a1
movb $0x0, %al
callq 0x10e0
movq -0x10(%rbp), %rdi
movq -0x28(%rbp), %rsi
movq -0x18(%rbp), %rdx
movq -0x20(%rbp), %rcx
movss -0x30(%rbp), %xmm0
callq 0x6300
jmp 0x697f
xorps %xmm0, %xmm0
movss %xmm0, -0x30(%rbp)
movq -0x10(%rbp), %rdi
movq -0x28(%rbp), %rsi
movq -0x18(%rbp), %rdx
movss -0x30(%rbp), %xmm0
callq 0x59d0
movq -0x18(%rbp), %rax
movss 0x4(%rax), %xmm0
movss %xmm0, -0x30(%rbp)
movq -0x10(%rbp), %rdi
movq -0x28(%rbp), %rsi
movq -0x18(%rbp), %rdx
movss -0x30(%rbp), %xmm0
callq 0x59d0
addq $0x40, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
nop