// File: /workspace/github_c_makefile_star2_O3/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 0x5797(%rip), %rdi      # 0x6fd4
leaq 0x4dcb(%rip), %rsi      # 0x660f
callq 0x1160
movq %rax, %r15
cmpl $0x1, 0x8(%rbx)
jne 0x1894
leaq 0x5796(%rip), %rdi      # 0x6fef
pushq $0x4c
popq %rsi
pushq $0x1
popq %rdx
movq %r15, %rcx
callq 0x11a0
pushq $0x2
popq %rbp
leaq 0x581c(%rip), %r12      # 0x708d
movq %r15, %rdi
movq %r12, %rsi
movl %ebp, %edx
xorl %eax, %eax
callq 0x1100
incl %ebp
cmpl $0xb, %ebp
jne 0x1871
pushq $0xa
popq %rdi
movq %r15, %rsi
callq 0x10d0
jmp 0x18a9
leaq 0x57a1(%rip), %rdi      # 0x703c
pushq $0x2f
popq %rsi
pushq $0x1
popq %rdx
movq %r15, %rcx
callq 0x11a0
cmpl $0x0, (%r14)
jle 0x1998
leaq 0xbe6e4(%r14), %r12
xorl %ebp, %ebp
leaq 0x57ce(%rip), %r13      # 0x7091
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 0x5756(%rip), %rsi      # 0x706c
movb $0x4, %al
callq 0x1100
xorl %eax, %eax
movss (%r12,%rax,4), %xmm0
movss 0x24(%rbx), %xmm1
ucomiss %xmm0, %xmm1
jbe 0x1938
movss %xmm1, (%r12,%rax,4)
movaps %xmm1, %xmm0
movss 0x28(%rbx), %xmm1
ucomiss %xmm1, %xmm0
jbe 0x1948
movss %xmm1, (%r12,%rax,4)
incq %rax
cmpq $0xa, %rax
jne 0x191f
xorl %r14d, %r14d
cmpl $0x1, 0x8(%rbx)
jne 0x196d
cvtss2sd (%r12,%r14,4), %xmm0
movq %r15, %rdi
movq %r13, %rsi
movb $0x1, %al
callq 0x1100
incq %r14
cmpq $0xa, %r14
jne 0x1954
pushq $0xa
popq %rdi
movq %r15, %rsi
callq 0x10d0
incq %rbp
movq (%rsp), %r14
movslq (%r14), %rax
addq $0x28, %r12
cmpq %rax, %rbp
jl 0x18c7
movq %r15, %rdi
callq 0x1080
movq 0x8651(%rip), %rax      # 0x9ff8
movq (%rax), %rcx
leaq 0x56e7(%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 0x11a0