// File: /workspace/github_c_makefile_star2_O1/usgs[P]nshmp-haz-catalogs/src/agrid/adaptive/calc_agrid_seis_rates.c
// Function: main
int main (int argc, char *argv[])
/*--------------------------------------------------------------------------*/
{
  int stop_run=0, fnew=0;
//  float magv;
  float atotal[NV];
  char paramf[200], paramf_format[200], summf[200], outf[200];
  struct compl_levels cat_compl;
  struct boundaries region;
  struct catalog cat;
  struct smoothp smoothing_params;
  struct rates seis_rates;
  struct eqcat eq_catalog;


// check input arguments and assign command line arguments for parameter file, file formatting, summary file
  if ( check_args(argc,argv,paramf,summf,paramf_format,&stop_run,&fnew) ) exit(1);
  
// initialize parameters, then open and read parameters file
  initialize_params(&cat_compl, &region, &cat, &smoothing_params);
  if( ! read_params_new_old(paramf, &cat_compl, &region, &cat, &smoothing_params, outf,fnew) ) exit(1);
fprintf(stderr,"outfnm: %s\n", outf);
  write_params(&cat_compl, &region, &cat, &smoothing_params, outf);
  write_params_to_file(summf, &cat_compl, &region, &cat, &smoothing_params, outf);
  if ( stop_run == 1 ) exit(1);

// get source region parameters
  fprintf(stderr,"Number of source points: %d (%d x %d)\n",region.nsrc, region.nsx, region.nsy);
  if (region.nsrc > NV ) {
    fprintf(stderr,"nsrc (%d) > NV (%d)\n", region.nsrc, NV); exit(1);
  }

// initialize distances to neighbors and seismicity rate variables
  init_dist_rates(&eq_catalog,atotal,&seis_rates);

// read earthquakes from catalog and assign to grid cells
  if ( ! get_eqs_fm_catalog(cat.catnm, &eq_catalog, &cat_compl, &region, &seis_rates) ) {
    fprintf(stderr,"Error getting earthquakes from catalog. Exiting ...\n"); exit(1);
  }
  seis_rates.nv=region.nsrc;

// get distances from all earthquakes to 10-nearest neighbors
  get_eq_neighbor_dists(&eq_catalog);

// smooth seismicity rates, if smoothing is specified
  smooth_seis_rates(&seis_rates, &smoothing_params, &eq_catalog, &region, &cat_compl, &cat);
  write_eq_neighbor_dists(&eq_catalog, &smoothing_params);
// convert from earthquake numbers in each bin to earthquake rates, adjust completeness, if required
  convert_eq_nos_rates(&seis_rates, &cat_compl, &smoothing_params, &cat, &region);

// write results to file
//fprintf(stdout,"call to write_results_to_file - %s\n", outf);
  write_results_to_file(&smoothing_params, &seis_rates, &cat, &region, outf);

// code completion steps
  fprintf(stdout,"\nSummary of processing written to file, %s\n", summf);
  return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x728558, %rsp         # imm = 0x728558
xorl %eax, %eax
leaq 0x10(%rsp), %r9
movl %eax, (%r9)
leaq 0xc(%rsp), %rcx
movl %eax, (%rcx)
movq %rcx, (%rsp)
leaq 0x2e0(%rsp), %rdx
leaq 0x210(%rsp), %rcx
leaq 0x3b0(%rsp), %r8
callq 0x5350
testl %eax, %eax
jne 0x56e4
leaq 0xa64c8(%rsp), %rbx
leaq 0x14(%rsp), %r14
leaq 0x68(%rsp), %r15
leaq 0x38(%rsp), %r12
movq %rbx, %rdi
movq %r14, %rsi
movq %r15, %rdx
movq %r12, %rcx
callq 0x56f8
movl 0xc(%rsp), %eax
movl %eax, (%rsp)
leaq 0x2e0(%rsp), %rdi
leaq 0x140(%rsp), %r9
movq %rbx, %rsi
movq %r14, %rdx
movq %r15, %rcx
movq %r12, %r8
callq 0x20d2
testl %eax, %eax
je 0x56e4
movq 0x4ab6(%rip), %rbp      # 0x9ff8
movq (%rbp), %rdi
leaq 0x2354(%rip), %rsi      # 0x78a1
leaq 0x140(%rsp), %rbx
movq %rbx, %rdx
xorl %eax, %eax
callq 0x1100
leaq 0xa64c8(%rsp), %r14
leaq 0x14(%rsp), %r15
leaq 0x68(%rsp), %r12
leaq 0x38(%rsp), %r13
movq %r14, %rdi
movq %r15, %rsi
movq %r12, %rdx
movq %r13, %rcx
movq %rbx, %r8
callq 0x2af4
leaq 0x210(%rsp), %rdi
movq %r14, %rsi
movq %r15, %rdx
movq %r12, %rcx
movq %r13, %r8
movq %rbx, %r9
callq 0x2ddb
cmpl $0x1, 0x10(%rsp)
je 0x56e4
movq (%rbp), %rdi
movl 0x1c(%rsp), %edx
movl 0x14(%rsp), %ecx
movl 0x18(%rsp), %r8d
leaq 0x22e4(%rip), %rsi      # 0x78ad
xorl %eax, %eax
callq 0x1100
movl 0x1c(%rsp), %edi
cmpl $0x29811, %edi          # imm = 0x29811
jge 0x56ee
leaq 0x33f5b0(%rsp), %rbx
leaq 0x480(%rsp), %rsi
leaq 0x490454(%rsp), %r14
movq %rbx, %rdi
movq %r14, %rdx
callq 0x30e0
leaq 0x78(%rsp), %rdi
leaq 0xa64c8(%rsp), %rdx
leaq 0x14(%rsp), %rcx
movq %rbx, %rsi
movq %r14, %r8
callq 0x3120
testl %eax, %eax
je 0x56f3
leaq 0x14(%rsp), %rbx
movl 0x8(%rbx), %eax
leaq 0x490454(%rsp), %r14
movl %eax, 0x298100(%r14)
leaq 0x33f5b0(%rsp), %r15
movq %r15, %rdi
callq 0x340d
leaq 0x38(%rsp), %r12
leaq 0xa64c8(%rsp), %r13
leaq 0x68(%rsp), %rbp
movq %r14, %rdi
movq %r12, %rsi
movq %r15, %rdx
movq %rbx, %rcx
movq %r13, %r8
movq %rbp, %r9
callq 0x4311
movq %r15, %rdi
movq %r12, %rsi
callq 0x181b
movq %r14, %rdi
movq %r13, %rsi
movq %r12, %rdx
movq %rbp, %rcx
movq %rbx, %r8
callq 0x3c8c
leaq 0x140(%rsp), %r8
movq %r12, %rdi
movq %r14, %rsi
movq %rbp, %rdx
movq %rbx, %rcx
callq 0x1b60
movq 0x4921(%rip), %rax      # 0x9fd8
movq (%rax), %rdi
leaq 0x225d(%rip), %rsi      # 0x791e
leaq 0x210(%rsp), %rdx
xorl %eax, %eax
callq 0x1100
xorl %eax, %eax
addq $0x728558, %rsp         # imm = 0x728558
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0x1, %edi
callq 0x1190
callq 0x1cf9
callq 0x1cd4