// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
leaq 0x515d(%rip), %rdi      # 0x8fc4
leaq 0x478d(%rip), %rsi      # 0x85fb
callq 0x1130
movq %rax, -0x18(%rbp)
movq -0x10(%rbp), %rax
cmpl $0x1, 0x8(%rax)
jne 0x3ed4
movq -0x18(%rbp), %rdi
leaq 0x5153(%rip), %rsi      # 0x8fdf
movb $0x0, %al
callq 0x10e0
movl $0x2, -0x1c(%rbp)
cmpl $0xa, -0x1c(%rbp)
jg 0x3ec0
movq -0x18(%rbp), %rdi
movl -0x1c(%rbp), %edx
leaq 0x51cf(%rip), %rsi      # 0x907d
movb $0x0, %al
callq 0x10e0
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x3e9a
movq -0x18(%rbp), %rdi
leaq 0x4e18(%rip), %rsi      # 0x8ce3
movb $0x0, %al
callq 0x10e0
jmp 0x3ee6
movq -0x18(%rbp), %rdi
leaq 0x514d(%rip), %rsi      # 0x902c
movb $0x0, %al
callq 0x10e0
movl $0x0, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
movq -0x8(%rbp), %rcx
cmpl (%rcx), %eax
jge 0x40d8
movq -0x18(%rbp), %rdi
movq -0x8(%rbp), %rax
movslq -0x1c(%rbp), %rcx
movss 0x668a4(%rax,%rcx,4), %xmm0
cvtss2sd %xmm0, %xmm0
movq -0x8(%rbp), %rax
movslq -0x1c(%rbp), %rcx
movss 0x75304(%rax,%rcx,4), %xmm1
cvtss2sd %xmm1, %xmm1
movq -0x8(%rbp), %rax
movslq -0x1c(%rbp), %rcx
movss 0x57e44(%rax,%rcx,4), %xmm2
cvtss2sd %xmm2, %xmm2
movq -0x8(%rbp), %rax
movslq -0x1c(%rbp), %rcx
movss 0x83d64(%rax,%rcx,4), %xmm3
cvtss2sd %xmm3, %xmm3
movq -0x8(%rbp), %rax
movslq -0x1c(%rbp), %rcx
movl 0x4(%rax,%rcx,4), %edx
movq -0x8(%rbp), %rax
movslq -0x1c(%rbp), %rcx
movl 0xea64(%rax,%rcx,4), %ecx
movq -0x8(%rbp), %rax
movslq -0x1c(%rbp), %rsi
movl 0x1d4c4(%rax,%rsi,4), %r8d
movq -0x8(%rbp), %rax
movslq -0x1c(%rbp), %rsi
movl 0x493e4(%rax,%rsi,4), %r9d
leaq 0x50c6(%rip), %rsi      # 0x905c
movb $0x4, %al
callq 0x10e0
movl $0x0, -0x20(%rbp)
cmpl $0xa, -0x20(%rbp)
jge 0x4060
movq -0x8(%rbp), %rax
addq $0xbe6e4, %rax          # imm = 0xBE6E4
movslq -0x1c(%rbp), %rcx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movslq -0x20(%rbp), %rcx
movss (%rax,%rcx,4), %xmm1
movq -0x10(%rbp), %rax
movss 0x24(%rax), %xmm0
ucomiss %xmm1, %xmm0
jbe 0x4001
movq -0x10(%rbp), %rax
movss 0x24(%rax), %xmm0
movq -0x8(%rbp), %rax
addq $0xbe6e4, %rax          # imm = 0xBE6E4
movslq -0x1c(%rbp), %rcx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movslq -0x20(%rbp), %rcx
movss %xmm0, (%rax,%rcx,4)
movq -0x8(%rbp), %rax
addq $0xbe6e4, %rax          # imm = 0xBE6E4
movslq -0x1c(%rbp), %rcx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movslq -0x20(%rbp), %rcx
movss (%rax,%rcx,4), %xmm0
movq -0x10(%rbp), %rax
ucomiss 0x28(%rax), %xmm0
jbe 0x4050
movq -0x10(%rbp), %rax
movss 0x28(%rax), %xmm0
movq -0x8(%rbp), %rax
addq $0xbe6e4, %rax          # imm = 0xBE6E4
movslq -0x1c(%rbp), %rcx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movslq -0x20(%rbp), %rcx
movss %xmm0, (%rax,%rcx,4)
jmp 0x4052
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0x3fa4
movl $0x0, -0x20(%rbp)
cmpl $0xa, -0x20(%rbp)
jge 0x40b8
movq -0x10(%rbp), %rax
cmpl $0x1, 0x8(%rax)
jne 0x40ab
movq -0x18(%rbp), %rdi
movq -0x8(%rbp), %rax
addq $0xbe6e4, %rax          # imm = 0xBE6E4
movslq -0x1c(%rbp), %rcx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movslq -0x20(%rbp), %rcx
movss (%rax,%rcx,4), %xmm0
cvtss2sd %xmm0, %xmm0
leaq 0x4fdd(%rip), %rsi      # 0x9081
movb $0x1, %al
callq 0x10e0
jmp 0x40ad
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0x4067
movq -0x18(%rbp), %rdi
leaq 0x4c20(%rip), %rsi      # 0x8ce3
movb $0x0, %al
callq 0x10e0
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x3eed
movq -0x18(%rbp), %rdi
callq 0x1080
movq 0x7f10(%rip), %rax      # 0xbff8
movq (%rax), %rdi
leaq 0x4f96(%rip), %rsi      # 0x9088
movb $0x0, %al
callq 0x10e0
addq $0x20, %rsp
popq %rbp
retq
nop