// File: /workspace/github_c_makefile_star2_O0/usgs[P]nshmp-haz-catalogs/src/agrid/adaptive/write_asum_to_file.c
// Function: write_asum_to_file
void write_asum_to_file(struct rates* seisr, char *fbasenm, struct catalog * catv, float mag)
/*--------------------------------------------------------------------------*/
{ 
  FILE *fpout;
//  int nsrc, cnt, ierr, out2=0;
  int nsrc, cnt, ierr;
//  int nsrc, cnt;
  float diffth=1e-1;
  float asum[NV];
  char fileout[200];
//  struct header headr;

// get rate array and naming based on magnitude input values
  nsrc=seisr->nv;
// Magnitudes
  if ( fabsf(mag-0.0)<diffth ) {
    sprintf(fileout,"%s_M0.out", fbasenm);
    fprintf(stderr,"M%.2f, writing to file - %s\n", mag, fileout);
    for(cnt=0; cnt<nsrc; cnt++) asum[cnt]=seisr->asum[cnt];
  }
  else if ( fabsf(mag-2.5)<diffth ) {
    sprintf(fileout,"%s_M2p5.out", fbasenm);
    fprintf(stderr,"M%.2f, writing to file - %s\n", mag, fileout);
    for(cnt=0; cnt<nsrc; cnt++) asum[cnt]=seisr->asum[cnt]*powf(10,-(catv->bval)*mag);
  }
  else if ( fabsf(mag-2.7)<diffth ) {
    sprintf(fileout,"%s_M2p7.out", fbasenm);
    fprintf(stderr,"M%.2f, writing to file - %s\n", mag, fileout);
    for(cnt=0; cnt<nsrc; cnt++) asum[cnt]=seisr->asum[cnt]*powf(10,-(catv->bval)*mag);
  }
  else if ( fabsf(mag-3.0)<diffth ) {
    sprintf(fileout,"%s_M3.out", fbasenm);
    fprintf(stderr,"M%.2f, writing to file - %s\n", mag, fileout);
    for(cnt=0; cnt<nsrc; cnt++) asum[cnt]=seisr->asum[cnt]*powf(10,-(catv->bval)*mag);
  }
  else if ( fabsf(mag-3.5)<diffth ) {
    sprintf(fileout,"%s_M3p5.out", fbasenm);
    fprintf(stderr,"M%.2f, writing to file - %s\n", mag, fileout);
    for(cnt=0; cnt<nsrc; cnt++) asum[cnt]=seisr->asum[cnt]*powf(10,-(catv->bval)*mag);
  }
  else if ( fabsf(mag-4.0)<diffth ) {
    sprintf(fileout,"%s_M4.out", fbasenm);
    fprintf(stderr,"M%.2f, writing to file - %s\n", mag, fileout);
    for(cnt=0; cnt<nsrc; cnt++) asum[cnt]=seisr->asum[cnt]*powf(10,-(catv->bval)*mag);
  }
  else if ( fabsf(mag-4.7)<diffth ) {
    sprintf(fileout,"%s_M4p7.out", fbasenm);
    fprintf(stderr,"M%.2f, writing to file - %s\n", mag, fileout);
    for(cnt=0; cnt<nsrc; cnt++) asum[cnt]=seisr->asum[cnt]*powf(10,-(catv->bval)*mag);
  }
  else if ( fabsf(mag-4.5)<diffth ) {
    sprintf(fileout,"%s_M4p5.out", fbasenm);
    fprintf(stderr,"M%.2f, writing to file - %s\n", mag, fileout);
    for(cnt=0; cnt<nsrc; cnt++) asum[cnt]=seisr->asum[cnt]*powf(10,-(catv->bval)*mag);
  }
  else if ( fabsf(mag-5.0)<diffth ) {
    sprintf(fileout,"%s_M5.out", fbasenm);
    fprintf(stderr,"M%.2f, writing to file - %s\n", mag, fileout);
    for(cnt=0; cnt<nsrc; cnt++) asum[cnt]=seisr->asum[cnt]*powf(10,-(catv->bval)*mag);
  }
  else {
//    out2=1;
    sprintf(fileout,"%s_M0.out", fbasenm);
    fprintf(stderr,"No option for M%.2f printing, writing to M0 file - %s\n", mag, fileout);
    for(cnt=0; cnt<nsrc; cnt++) asum[cnt]=seisr->asum[cnt];
  }


// write results to file, fileout
  fpout=fopen(fileout,"wb+");
  ierr=fwrite(asum,4,nsrc,fpout);
  fclose(fpout);
//  fprintf(stderr,"Wrote M%.2f results to file, %s.\n", mag, fileout);
  

}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xa6170, %rsp          # imm = 0xA6170
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movss %xmm0, -0x1c(%rbp)
movss 0x3aac(%rip), %xmm0     # 0x94a0
movss %xmm0, -0x38(%rbp)
movq -0x8(%rbp), %rax
movl 0x298100(%rax), %eax
movl %eax, -0x2c(%rbp)
movss -0x1c(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
xorps %xmm1, %xmm1
subsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm1
movaps 0x3a6f(%rip), %xmm0     # 0x9490
pand %xmm0, %xmm1
movss -0x38(%rbp), %xmm0
ucomiss %xmm1, %xmm0
jbe 0x5aad
leaq -0xa6150(%rbp), %rdi
movq -0x10(%rbp), %rdx
leaq 0x3aa7(%rip), %rsi      # 0x94e8
movb $0x0, %al
callq 0x1150
movq 0x65a9(%rip), %rax      # 0xbff8
movq (%rax), %rdi
movss -0x1c(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
leaq -0xa6150(%rbp), %rdx
leaq 0x3a89(%rip), %rsi      # 0x94f2
movb $0x1, %al
callq 0x10e0
movl $0x0, -0x30(%rbp)
movl -0x30(%rbp), %eax
cmpl -0x2c(%rbp), %eax
jge 0x5aa8
movq -0x8(%rbp), %rax
movslq -0x30(%rbp), %rcx
movss 0x14c080(%rax,%rcx,4), %xmm0
movslq -0x30(%rbp), %rax
movss %xmm0, -0xa6080(%rbp,%rax,4)
movl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
jmp 0x5a77
jmp 0x62ad
movss -0x1c(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
movsd 0x39ea(%rip), %xmm1     # 0x94a8
subsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm1
movaps 0x39c3(%rip), %xmm0     # 0x9490
pand %xmm0, %xmm1
movss -0x38(%rbp), %xmm0
ucomiss %xmm1, %xmm0
jbe 0x5b9c
leaq -0xa6150(%rbp), %rdi
movq -0x10(%rbp), %rdx
leaq 0x3a1e(%rip), %rsi      # 0x950f
movb $0x0, %al
callq 0x1150
movq 0x64f9(%rip), %rax      # 0xbff8
movq (%rax), %rdi
movss -0x1c(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
leaq -0xa6150(%rbp), %rdx
leaq 0x39d9(%rip), %rsi      # 0x94f2
movb $0x1, %al
callq 0x10e0
movl $0x0, -0x30(%rbp)
movl -0x30(%rbp), %eax
cmpl -0x2c(%rbp), %eax
jge 0x5b97
movq -0x8(%rbp), %rax
movslq -0x30(%rbp), %rcx
movss 0x14c080(%rax,%rcx,4), %xmm0
movss %xmm0, -0xa6154(%rbp)
movq -0x18(%rbp), %rax
movss 0xc(%rax), %xmm0
movd %xmm0, %eax
xorl $0x80000000, %eax       # imm = 0x80000000
movd %eax, %xmm1
mulss -0x1c(%rbp), %xmm1
movss 0x356d(%rip), %xmm0     # 0x90d8
callq 0x1120
movaps %xmm0, %xmm1
movss -0xa6154(%rbp), %xmm0
mulss %xmm1, %xmm0
movslq -0x30(%rbp), %rax
movss %xmm0, -0xa6080(%rbp,%rax,4)
movl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
jmp 0x5b27
jmp 0x62ab
movss -0x1c(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
movsd 0x3903(%rip), %xmm1     # 0x94b0
subsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm1
movaps 0x38d4(%rip), %xmm0     # 0x9490
pand %xmm0, %xmm1
movss -0x38(%rbp), %xmm0
ucomiss %xmm1, %xmm0
jbe 0x5c8b
leaq -0xa6150(%rbp), %rdi
movq -0x10(%rbp), %rdx
leaq 0x393b(%rip), %rsi      # 0x951b
movb $0x0, %al
callq 0x1150
movq 0x640a(%rip), %rax      # 0xbff8
movq (%rax), %rdi
movss -0x1c(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
leaq -0xa6150(%rbp), %rdx
leaq 0x38ea(%rip), %rsi      # 0x94f2
movb $0x1, %al
callq 0x10e0
movl $0x0, -0x30(%rbp)
movl -0x30(%rbp), %eax
cmpl -0x2c(%rbp), %eax
jge 0x5c86
movq -0x8(%rbp), %rax
movslq -0x30(%rbp), %rcx
movss 0x14c080(%rax,%rcx,4), %xmm0
movss %xmm0, -0xa6158(%rbp)
movq -0x18(%rbp), %rax
movss 0xc(%rax), %xmm0
movd %xmm0, %eax
xorl $0x80000000, %eax       # imm = 0x80000000
movd %eax, %xmm1
mulss -0x1c(%rbp), %xmm1
movss 0x347e(%rip), %xmm0     # 0x90d8
callq 0x1120
movaps %xmm0, %xmm1
movss -0xa6158(%rbp), %xmm0
mulss %xmm1, %xmm0
movslq -0x30(%rbp), %rax
movss %xmm0, -0xa6080(%rbp,%rax,4)
movl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
jmp 0x5c16
jmp 0x62a9
movss -0x1c(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
movsd 0x381c(%rip), %xmm1     # 0x94b8
subsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm1
movaps 0x37e5(%rip), %xmm0     # 0x9490
pand %xmm0, %xmm1
movss -0x38(%rbp), %xmm0
ucomiss %xmm1, %xmm0
jbe 0x5d7a
leaq -0xa6150(%rbp), %rdi
movq -0x10(%rbp), %rdx
leaq 0x3858(%rip), %rsi      # 0x9527
movb $0x0, %al
callq 0x1150
movq 0x631b(%rip), %rax      # 0xbff8
movq (%rax), %rdi
movss -0x1c(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
leaq -0xa6150(%rbp), %rdx
leaq 0x37fb(%rip), %rsi      # 0x94f2
movb $0x1, %al
callq 0x10e0
movl $0x0, -0x30(%rbp)
movl -0x30(%rbp), %eax
cmpl -0x2c(%rbp), %eax
jge 0x5d75
movq -0x8(%rbp), %rax
movslq -0x30(%rbp), %rcx
movss 0x14c080(%rax,%rcx,4), %xmm0
movss %xmm0, -0xa615c(%rbp)
movq -0x18(%rbp), %rax
movss 0xc(%rax), %xmm0
movd %xmm0, %eax
xorl $0x80000000, %eax       # imm = 0x80000000
movd %eax, %xmm1
mulss -0x1c(%rbp), %xmm1
movss 0x338f(%rip), %xmm0     # 0x90d8
callq 0x1120
movaps %xmm0, %xmm1
movss -0xa615c(%rbp), %xmm0
mulss %xmm1, %xmm0
movslq -0x30(%rbp), %rax
movss %xmm0, -0xa6080(%rbp,%rax,4)
movl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
jmp 0x5d05
jmp 0x62a7
movss -0x1c(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
movsd 0x3735(%rip), %xmm1     # 0x94c0
subsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm1
movaps 0x36f6(%rip), %xmm0     # 0x9490
pand %xmm0, %xmm1
movss -0x38(%rbp), %xmm0
ucomiss %xmm1, %xmm0
jbe 0x5e69
leaq -0xa6150(%rbp), %rdi
movq -0x10(%rbp), %rdx
leaq 0x3773(%rip), %rsi      # 0x9531
movb $0x0, %al
callq 0x1150
movq 0x622c(%rip), %rax      # 0xbff8
movq (%rax), %rdi
movss -0x1c(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
leaq -0xa6150(%rbp), %rdx
leaq 0x370c(%rip), %rsi      # 0x94f2
movb $0x1, %al
callq 0x10e0
movl $0x0, -0x30(%rbp)
movl -0x30(%rbp), %eax
cmpl -0x2c(%rbp), %eax
jge 0x5e64
movq -0x8(%rbp), %rax
movslq -0x30(%rbp), %rcx
movss 0x14c080(%rax,%rcx,4), %xmm0
movss %xmm0, -0xa6160(%rbp)
movq -0x18(%rbp), %rax
movss 0xc(%rax), %xmm0
movd %xmm0, %eax
xorl $0x80000000, %eax       # imm = 0x80000000
movd %eax, %xmm1
mulss -0x1c(%rbp), %xmm1
movss 0x32a0(%rip), %xmm0     # 0x90d8
callq 0x1120
movaps %xmm0, %xmm1
movss -0xa6160(%rbp), %xmm0
mulss %xmm1, %xmm0
movslq -0x30(%rbp), %rax
movss %xmm0, -0xa6080(%rbp,%rax,4)
movl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
jmp 0x5df4
jmp 0x62a5
movss -0x1c(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
movsd 0x364e(%rip), %xmm1     # 0x94c8
subsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm1
movaps 0x3607(%rip), %xmm0     # 0x9490
pand %xmm0, %xmm1
movss -0x38(%rbp), %xmm0
ucomiss %xmm1, %xmm0
jbe 0x5f58
leaq -0xa6150(%rbp), %rdi
movq -0x10(%rbp), %rdx
leaq 0x3690(%rip), %rsi      # 0x953d
movb $0x0, %al
callq 0x1150
movq 0x613d(%rip), %rax      # 0xbff8
movq (%rax), %rdi
movss -0x1c(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
leaq -0xa6150(%rbp), %rdx
leaq 0x361d(%rip), %rsi      # 0x94f2
movb $0x1, %al
callq 0x10e0
movl $0x0, -0x30(%rbp)
movl -0x30(%rbp), %eax
cmpl -0x2c(%rbp), %eax
jge 0x5f53
movq -0x8(%rbp), %rax
movslq -0x30(%rbp), %rcx
movss 0x14c080(%rax,%rcx,4), %xmm0
movss %xmm0, -0xa6164(%rbp)
movq -0x18(%rbp), %rax
movss 0xc(%rax), %xmm0
movd %xmm0, %eax
xorl $0x80000000, %eax       # imm = 0x80000000
movd %eax, %xmm1
mulss -0x1c(%rbp), %xmm1
movss 0x31b1(%rip), %xmm0     # 0x90d8
callq 0x1120
movaps %xmm0, %xmm1
movss -0xa6164(%rbp), %xmm0
mulss %xmm1, %xmm0
movslq -0x30(%rbp), %rax
movss %xmm0, -0xa6080(%rbp,%rax,4)
movl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
jmp 0x5ee3
jmp 0x62a3
movss -0x1c(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
movsd 0x3567(%rip), %xmm1     # 0x94d0
subsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm1
movaps 0x3518(%rip), %xmm0     # 0x9490
pand %xmm0, %xmm1
movss -0x38(%rbp), %xmm0
ucomiss %xmm1, %xmm0
jbe 0x6047
leaq -0xa6150(%rbp), %rdi
movq -0x10(%rbp), %rdx
leaq 0x35ab(%rip), %rsi      # 0x9547
movb $0x0, %al
callq 0x1150
movq 0x604e(%rip), %rax      # 0xbff8
movq (%rax), %rdi
movss -0x1c(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
leaq -0xa6150(%rbp), %rdx
leaq 0x352e(%rip), %rsi      # 0x94f2
movb $0x1, %al
callq 0x10e0
movl $0x0, -0x30(%rbp)
movl -0x30(%rbp), %eax
cmpl -0x2c(%rbp), %eax
jge 0x6042
movq -0x8(%rbp), %rax
movslq -0x30(%rbp), %rcx
movss 0x14c080(%rax,%rcx,4), %xmm0
movss %xmm0, -0xa6168(%rbp)
movq -0x18(%rbp), %rax
movss 0xc(%rax), %xmm0
movd %xmm0, %eax
xorl $0x80000000, %eax       # imm = 0x80000000
movd %eax, %xmm1
mulss -0x1c(%rbp), %xmm1
movss 0x30c2(%rip), %xmm0     # 0x90d8
callq 0x1120
movaps %xmm0, %xmm1
movss -0xa6168(%rbp), %xmm0
mulss %xmm1, %xmm0
movslq -0x30(%rbp), %rax
movss %xmm0, -0xa6080(%rbp,%rax,4)
movl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
jmp 0x5fd2
jmp 0x62a1
movss -0x1c(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
movsd 0x3480(%rip), %xmm1     # 0x94d8
subsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm1
movaps 0x3429(%rip), %xmm0     # 0x9490
pand %xmm0, %xmm1
movss -0x38(%rbp), %xmm0
ucomiss %xmm1, %xmm0
jbe 0x6136
leaq -0xa6150(%rbp), %rdi
movq -0x10(%rbp), %rdx
leaq 0x34c8(%rip), %rsi      # 0x9553
movb $0x0, %al
callq 0x1150
movq 0x5f5f(%rip), %rax      # 0xbff8
movq (%rax), %rdi
movss -0x1c(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
leaq -0xa6150(%rbp), %rdx
leaq 0x343f(%rip), %rsi      # 0x94f2
movb $0x1, %al
callq 0x10e0
movl $0x0, -0x30(%rbp)
movl -0x30(%rbp), %eax
cmpl -0x2c(%rbp), %eax
jge 0x6131
movq -0x8(%rbp), %rax
movslq -0x30(%rbp), %rcx
movss 0x14c080(%rax,%rcx,4), %xmm0
movss %xmm0, -0xa616c(%rbp)
movq -0x18(%rbp), %rax
movss 0xc(%rax), %xmm0
movd %xmm0, %eax
xorl $0x80000000, %eax       # imm = 0x80000000
movd %eax, %xmm1
mulss -0x1c(%rbp), %xmm1
movss 0x2fd3(%rip), %xmm0     # 0x90d8
callq 0x1120
movaps %xmm0, %xmm1
movss -0xa616c(%rbp), %xmm0
mulss %xmm1, %xmm0
movslq -0x30(%rbp), %rax
movss %xmm0, -0xa6080(%rbp,%rax,4)
movl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
jmp 0x60c1
jmp 0x629f
movss -0x1c(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
movsd 0x3399(%rip), %xmm1     # 0x94e0
subsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm1
movaps 0x333a(%rip), %xmm0     # 0x9490
pand %xmm0, %xmm1
movss -0x38(%rbp), %xmm0
ucomiss %xmm1, %xmm0
jbe 0x6222
leaq -0xa6150(%rbp), %rdi
movq -0x10(%rbp), %rdx
leaq 0x33e5(%rip), %rsi      # 0x955f
movb $0x0, %al
callq 0x1150
movq 0x5e70(%rip), %rax      # 0xbff8
movq (%rax), %rdi
movss -0x1c(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
leaq -0xa6150(%rbp), %rdx
leaq 0x3350(%rip), %rsi      # 0x94f2
movb $0x1, %al
callq 0x10e0
movl $0x0, -0x30(%rbp)
movl -0x30(%rbp), %eax
cmpl -0x2c(%rbp), %eax
jge 0x6220
movq -0x8(%rbp), %rax
movslq -0x30(%rbp), %rcx
movss 0x14c080(%rax,%rcx,4), %xmm0
movss %xmm0, -0xa6170(%rbp)
movq -0x18(%rbp), %rax
movss 0xc(%rax), %xmm0
movd %xmm0, %eax
xorl $0x80000000, %eax       # imm = 0x80000000
movd %eax, %xmm1
mulss -0x1c(%rbp), %xmm1
movss 0x2ee4(%rip), %xmm0     # 0x90d8
callq 0x1120
movaps %xmm0, %xmm1
movss -0xa6170(%rbp), %xmm0
mulss %xmm1, %xmm0
movslq -0x30(%rbp), %rax
movss %xmm0, -0xa6080(%rbp,%rax,4)
movl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
jmp 0x61b0
jmp 0x629d
leaq -0xa6150(%rbp), %rdi
movq -0x10(%rbp), %rdx
leaq 0x32b4(%rip), %rsi      # 0x94e8
movb $0x0, %al
callq 0x1150
movq 0x5db6(%rip), %rax      # 0xbff8
movq (%rax), %rdi
movss -0x1c(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
leaq -0xa6150(%rbp), %rdx
leaq 0x330d(%rip), %rsi      # 0x9569
movb $0x1, %al
callq 0x10e0
movl $0x0, -0x30(%rbp)
movl -0x30(%rbp), %eax
cmpl -0x2c(%rbp), %eax
jge 0x629b
movq -0x8(%rbp), %rax
movslq -0x30(%rbp), %rcx
movss 0x14c080(%rax,%rcx,4), %xmm0
movslq -0x30(%rbp), %rax
movss %xmm0, -0xa6080(%rbp,%rax,4)
movl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
jmp 0x626a
jmp 0x629d
jmp 0x629f
jmp 0x62a1
jmp 0x62a3
jmp 0x62a5
jmp 0x62a7
jmp 0x62a9
jmp 0x62ab
jmp 0x62ad
leaq -0xa6150(%rbp), %rdi
leaq 0x32e5(%rip), %rsi      # 0x95a0
callq 0x1130
movq %rax, -0x28(%rbp)
leaq -0xa6080(%rbp), %rdi
movslq -0x2c(%rbp), %rdx
movq -0x28(%rbp), %rcx
movl $0x4, %esi
callq 0x1170
movl %eax, -0x34(%rbp)
movq -0x28(%rbp), %rdi
callq 0x1080
addq $0xa6170, %rsp          # imm = 0xA6170
popq %rbp
retq
nopw %cs:(%rax,%rax)