// File: /workspace/github_c_makefile_star2_O2/usgs[P]nshmp-haz-catalogs/src/agrid/adaptive/write_eq_neighbor_dists.c
// Function: write_eq_neighbor_dists
void write_eq_neighbor_dists(struct eqcat* catn, struct smoothp* smp)
/*--------------------------------------------------------------------------*/
{
  FILE *fpeq;
  int cnt, cnt1;

// open file for writing. add header
  fpeq=fopen("selected_eqs_neighbors.dat","w");
  if ( smp->apply_sm == 1 ) {
    fprintf(fpeq, "Lon Lat Mag Depth Year Month Day agrid-cell-no. distances(km)_to-neighbor:1 ");
    for (cnt=2; cnt<=(int)NNUM; cnt++) fprintf(fpeq, "%d ", cnt);
    fprintf(fpeq, "\n");
  }
  else {
    fprintf(fpeq, "Lon Lat Mag Depth Year Month Day agrid-cell-no\n");
  }
//  fprintf(stderr, "sigmin/max %f %f\n",smp->sigmin, smp->sigmax);  

// write earthquake parameters to file
// eq hypocenter params
  for(cnt=0; cnt<catn->nv; cnt++) {
    fprintf(fpeq, "%7.2f %6.2f %4.2f %7.2f %d %d %d %d ", catn->lon[cnt], catn->lat[cnt], catn->mag[cnt], catn->depth[cnt], catn->year[cnt], catn->month[cnt], catn->day[cnt], catn->agrid_id[cnt]);
// neighbor number
// modify neighbor distances to within min/max smoothing parameters
    for(cnt1=0; cnt1<(int)NNUM; cnt1++) {
      if ( catn->dist_nbr[cnt][cnt1] < smp->sigmin) catn->dist_nbr[cnt][cnt1]=smp->sigmin;
      if ( catn->dist_nbr[cnt][cnt1] > smp->sigmax) catn->dist_nbr[cnt][cnt1]=smp->sigmax;
    }
// write out results
    for(cnt1=0; cnt1<(int)NNUM; cnt1++) {
      if ( smp->apply_sm == 1 ) fprintf(fpeq, "%6.1f ", catn->dist_nbr[cnt][cnt1]);
    }
    fprintf(fpeq, "\n");
  }

// close and report file name
  fclose(fpeq);
  fprintf(stderr, "Wrote parameters for selected earthquakes to file, selected_eqs_neighbors.dat\n");
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %rbx
movq %rdi, %r14
leaq 0x3ae4(%rip), %rdi      # 0x6fd4
leaq 0x3118(%rip), %rsi      # 0x660f
callq 0x1150
movq %rax, %r15
cmpl $0x1, 0x8(%rbx)
jne 0x353c
leaq 0x3ae3(%rip), %rdi      # 0x6fef
pushq $0x4c
popq %rsi
pushq $0x1
popq %rdx
movq %r15, %rcx
callq 0x1190
pushq $0x2
popq %rbp
leaq 0x3b69(%rip), %r12      # 0x708d
cmpl $0xb, %ebp
je 0x3553
movq %r15, %rdi
movq %r12, %rsi
movl %ebp, %edx
xorl %eax, %eax
callq 0x10f0
incl %ebp
jmp 0x3524
leaq 0x3af9(%rip), %rdi      # 0x703c
pushq $0x2f
popq %rsi
pushq $0x1
popq %rdx
movq %r15, %rcx
callq 0x1190
jmp 0x355e
pushq $0xa
popq %rdi
movq %r15, %rsi
callq 0x10c0
leaq 0xbe6e4(%r14), %r12
xorl %ebp, %ebp
leaq 0x3b23(%rip), %r13      # 0x7091
movq %r14, (%rsp)
movslq (%r14), %rax
cmpq %rax, %rbp
jge 0x364c
cvtss2sd 0x668a4(%r14,%rbp,4), %xmm0
cvtss2sd 0x75304(%r14,%rbp,4), %xmm1
cvtss2sd 0x57e44(%r14,%rbp,4), %xmm2
cvtss2sd 0x83d64(%r14,%rbp,4), %xmm3
movl 0x4(%r14,%rbp,4), %edx
movl 0xea64(%r14,%rbp,4), %ecx
movl 0x1d4c4(%r14,%rbp,4), %r8d
movl 0x493e4(%r14,%rbp,4), %r9d
movq %r15, %rdi
leaq 0x3a9f(%rip), %rsi      # 0x706c
movb $0x4, %al
callq 0x10f0
xorl %eax, %eax
cmpq $0xa, %rax
je 0x360a
movss (%r12,%rax,4), %xmm0
movss 0x24(%rbx), %xmm1
ucomiss %xmm0, %xmm1
jbe 0x35f5
movss %xmm1, (%r12,%rax,4)
movaps %xmm1, %xmm0
movss 0x28(%rbx), %xmm1
ucomiss %xmm1, %xmm0
jbe 0x3605
movss %xmm1, (%r12,%rax,4)
incq %rax
jmp 0x35d6
xorl %r14d, %r14d
cmpq $0xa, %r14
je 0x3631
cmpl $0x1, 0x8(%rbx)
jne 0x362c
cvtss2sd (%r12,%r14,4), %xmm0
movq %r15, %rdi
movq %r13, %rsi
movb $0x1, %al
callq 0x10f0
incq %r14
jmp 0x360d
pushq $0xa
popq %rdi
movq %r15, %rsi
callq 0x10c0
incq %rbp
addq $0x28, %r12
movq (%rsp), %r14
jmp 0x3572
movq %r15, %rdi
callq 0x1080
movq 0x699d(%rip), %rax      # 0x9ff8
movq (%rax), %rcx
leaq 0x3a33(%rip), %rdi      # 0x7098
pushq $0x4e
popq %rsi
pushq $0x1
popq %rdx
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x1190
nop