// File: /workspace/github_c_makefile_star2_O1/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 0x5791(%rip), %rdi      # 0x6fc4
leaq 0x4dc1(%rip), %rsi      # 0x65fb
callq 0x1160
movq %rax, %r15
cmpl $0x1, 0x8(%rbx)
jne 0x188a
leaq 0x5790(%rip), %rdi      # 0x6fdf
pushq $0x4c
popq %rsi
pushq $0x1
popq %rdx
movq %r15, %rcx
callq 0x11a0
pushq $0x2
popq %rbp
leaq 0x5816(%rip), %r12      # 0x707d
movq %r15, %rdi
movq %r12, %rsi
movl %ebp, %edx
xorl %eax, %eax
callq 0x1100
incl %ebp
cmpl $0xb, %ebp
jne 0x1867
pushq $0xa
popq %rdi
movq %r15, %rsi
callq 0x10d0
jmp 0x189f
leaq 0x579b(%rip), %rdi      # 0x702c
pushq $0x2f
popq %rsi
pushq $0x1
popq %rdx
movq %r15, %rcx
callq 0x11a0
cmpl $0x0, (%r14)
jle 0x198d
leaq 0xbe6e4(%r14), %r12
xorl %ebp, %ebp
leaq 0x57c8(%rip), %r13      # 0x7081
movq %r14, (%rsp)
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 0x5750(%rip), %rsi      # 0x705c
movb $0x4, %al
callq 0x1100
xorl %eax, %eax
movss 0x24(%rbx), %xmm0
ucomiss (%r12,%rax,4), %xmm0
jbe 0x1927
movss %xmm0, (%r12,%rax,4)
movss (%r12,%rax,4), %xmm1
movss 0x28(%rbx), %xmm0
ucomiss %xmm0, %xmm1
jbe 0x193d
movss %xmm0, (%r12,%rax,4)
incq %rax
cmpq $0xa, %rax
jne 0x1915
xorl %r14d, %r14d
cmpl $0x1, 0x8(%rbx)
jne 0x1962
cvtss2sd (%r12,%r14,4), %xmm0
movq %r15, %rdi
movq %r13, %rsi
movb $0x1, %al
callq 0x1100
incq %r14
cmpq $0xa, %r14
jne 0x1949
pushq $0xa
popq %rdi
movq %r15, %rsi
callq 0x10d0
incq %rbp
movq (%rsp), %r14
movslq (%r14), %rax
addq $0x28, %r12
cmpq %rax, %rbp
jl 0x18bd
movq %r15, %rdi
callq 0x1080
movq 0x865c(%rip), %rax      # 0x9ff8
movq (%rax), %rcx
leaq 0x56e2(%rip), %rdi      # 0x7088
pushq $0x4e
popq %rsi
pushq $0x1
popq %rdx
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x11a0