// File: /workspace/github_c_makefile_star2_O2/usgs[P]nshmp-haz-catalogs/src/agrid/adaptive/read_write_params.c
// Function: read_params_new
int read_params_new(char *parf, struct compl_levels* cat_comp, struct boundaries* reg, 
  struct catalog* cat, struct smoothp* smp, char *outfnm) 
/*--------------------------------------------------------------------------*/
{
  FILE *fpparam;
  int cnt;
//  char buff[BUFFLEN];
  char parseaux[256], gauss_plaw[10];
  
// open file
  if( (fpparam = fopen(parf, "r"))==NULL) {
    fprintf(stderr,"Parameter file not found, %s\n", parf);
    return 0;
  }
  fprintf(stderr,"Reading from parameter file, %s - new formatting style.\n", parf);

// read parameters
  Parse_Text(fpparam, "Min_Lat",'f', &(reg->minlat) );
  Parse_Text(fpparam, "Max_Lat",'f', &(reg->maxlat) );
  Parse_Text(fpparam, "Min_Lon",'f', &(reg->minlon) );
  Parse_Text(fpparam, "Max_Lon",'f', &(reg->maxlon) );
  Parse_Text(fpparam, "Inc_Lat",'f', &(reg->dlat) );
  Parse_Text(fpparam, "Inc_Lon",'f', &(reg->dlon) );
  Parse_Text(fpparam, "Correct_Area_for_Latitude",'i', &(cat_comp->correctAreaForLat) );
  Parse_Text(fpparam, "Variable_Completeness",'i', &(cat_comp->variableCompleteness) );
  if ( (cat_comp->variableCompleteness) == 1 ) {
    Parse_Text(fpparam, "Completeness_File",'s', &(cat_comp->completenessFile) );
  }
  Parse_Text(fpparam, "Catalog_Gaps",'i', &(cat_comp->catalogGaps) );
  if ( (cat_comp->catalogGaps) == 1 ) {
    Parse_Text(fpparam, "Catalog_Gaps_File",'s', &(cat_comp->catalogGapsFile) );
    Parse_Text(fpparam, "Polygons_for_Gaps_Path", 's', &(cat_comp->catalogGapsPolygonPath));
    load_poly_data(cat_comp);
  }
  Parse_Text(fpparam, "N_Completeness_Levels",'i', &(cat_comp->nlevels) );
  for (cnt=0; cnt<cat_comp->nlevels; cnt++) {
    sprintf(parseaux,"Completeness_Level_yr_%d", cnt+1);
    Parse_Text(fpparam,parseaux,'i', &(cat_comp->yr_comp[cnt]) );
    sprintf(parseaux,"Completeness_Level_M_%d", cnt+1);
    Parse_Text(fpparam,parseaux,'f', &(cat_comp->mag_comp[cnt]) );
  }
  Parse_Text(fpparam, "End_yr_Catalog",'i', &(cat->end_yr) );
  Parse_Text(fpparam, "Catalog_Name",'s', &(cat->catnm) );
  Parse_Text(fpparam, "Output_Name",'s', outfnm);
  Parse_Text(fpparam, "Min_Magnitude",'f', &(cat->minMag) );
  Parse_Text(fpparam, "b_Value",'f', &(cat->bval) );
  Parse_Text(fpparam, "dMag_value",'f', &(cat->dMag) );
// logical values
  Parse_Text(fpparam, "logical_Effective_Num_Eqs",'i', &(smp->use_neff) );
  Parse_Text(fpparam, "logical_Cumulative_rates",'i', &(smp->cumul_rates) );
  Parse_Text(fpparam, "logical_Apply_smoothing",'i', &(smp->apply_sm) );
  if ( (smp->apply_sm) == 1 ) {
    Parse_Text(fpparam, "logical_Adjust_completeness",'i', &(smp->adj_compl) );
    Parse_Text(fpparam, "Gauss_PowerLaw_Kernel",'s', gauss_plaw);
    if ( STREQ(gauss_plaw,"gauss") ) {
      smp->gauss_kern=1;
    }
    else if ( STREQ(gauss_plaw,"powerLaw") ) {
      smp->gauss_kern=0;
    }
    else {
      fprintf(stderr,"No kernel option for %s. User must enter gauss or powerLaw for kernel-type.\n", gauss_plaw);
      exit(1);
    }
    Parse_Text(fpparam, "logical_Adaptive_smoothing",'i', &(smp->adapt_sm) );
    if ( (smp->adapt_sm) ) {
      Parse_Text(fpparam, "Adaptive_Neighbor_Number",'i', &(smp->nnum) );
      Parse_Text(fpparam, "Sigma_Min",'f', &(smp->sigmin) );
      Parse_Text(fpparam, "Sigma_Max",'f', &(smp->sigmax) );
      Parse_Text(fpparam, "logical_Avg_Neighbor",'i', &(smp->nnum2_log) );
      if (smp->nnum2_log) {
        Parse_Text(fpparam, "Adaptive_Neighbor_Number_2",'i', &(smp->nnum2) );
      }
    }
    else {
      Parse_Text(fpparam, "Sigma_Fix",'f', &(smp->sigfix) );
    }
  }
  fclose(fpparam);

// get numbers of points in x-, y-directions
  reg->nsx=(int)( (reg->maxlon-reg->minlon)/reg->dlon +1);
  reg->nsy=(int)( (reg->maxlat-reg->minlat)/reg->dlat +1 );
  reg->nsrc=reg->nsx*reg->nsy;

  return 1;

}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x138, %rsp            # imm = 0x138
movq %r9, %rbx
movq %r8, %r12
movq %rcx, 0x28(%rsp)
movq %rdx, %r15
movq %rsi, %rbp
movq %rdi, %r14
leaq 0x5137(%rip), %rsi      # 0x68cb
callq 0x1150
movq %rax, %r13
movq 0x8855(%rip), %rax      # 0x9ff8
movq (%rax), %rdi
testq %r13, %r13
jne 0x17c3
leaq 0x4e11(%rip), %rsi      # 0x65c3
xorl %ebx, %ebx
movq %r14, %rdx
xorl %eax, %eax
callq 0x10f0
jmp 0x1bf8
movq %rbx, 0x10(%rsp)
leaq 0x4edc(%rip), %rsi      # 0x66ab
movq %r14, %rdx
xorl %eax, %eax
callq 0x10f0
leaq 0x14(%r15), %rcx
leaq 0x4f00(%rip), %rsi      # 0x66e4
pushq $0x66
popq %rbx
movq %r13, %rdi
movl %ebx, %edx
callq 0x53c0
leaq 0x18(%r15), %rcx
leaq 0x4ef0(%rip), %rsi      # 0x66ec
movq %r13, %rdi
movl %ebx, %edx
callq 0x53c0
leaq 0xc(%r15), %rcx
leaq 0x4ee3(%rip), %rsi      # 0x66f4
movq %r13, %rdi
movl %ebx, %edx
callq 0x53c0
leaq 0x10(%r15), %rcx
leaq 0x4ed6(%rip), %rsi      # 0x66fc
movq %r13, %rdi
movl %ebx, %edx
callq 0x53c0
leaq 0x20(%r15), %rcx
leaq 0x4ec9(%rip), %rsi      # 0x6704
movq %r13, %rdi
movl %ebx, %edx
callq 0x53c0
leaq 0x1c(%r15), %rcx
leaq 0x4ebc(%rip), %rsi      # 0x670c
movq %r13, %rdi
movl %ebx, %edx
callq 0x53c0
leaq 0x8(%rbp), %rcx
leaq 0x4eaf(%rip), %rsi      # 0x6714
pushq $0x69
popq %rbx
movq %r13, %rdi
movl %ebx, %edx
callq 0x53c0
leaq 0x4eb5(%rip), %rsi      # 0x672e
movq %r13, %rdi
movl %ebx, %edx
movq %rbp, %rcx
callq 0x53c0
cmpl $0x1, (%rbp)
jne 0x18a2
leaq 0x68(%rbp), %rcx
leaq 0x4ead(%rip), %rsi      # 0x6744
pushq $0x73
popq %rdx
movq %r13, %rdi
callq 0x53c0
movq %r12, 0x18(%rsp)
movq %r15, 0x20(%rsp)
leaq 0x4(%rbp), %rcx
leaq 0x4e9f(%rip), %rsi      # 0x6756
pushq $0x69
popq %rdx
movq %r13, %rdi
callq 0x53c0
cmpl $0x1, 0x4(%rbp)
jne 0x1903
leaq 0x130(%rbp), %rcx
leaq 0x4e8d(%rip), %rsi      # 0x6763
pushq $0x73
popq %rbx
movq %r13, %rdi
movl %ebx, %edx
callq 0x53c0
leaq 0x1f8(%rbp), %rcx
leaq 0x4e84(%rip), %rsi      # 0x6775
movq %r13, %rdi
movl %ebx, %edx
callq 0x53c0
movq %rbp, %rdi
callq 0x1498
movq %r13, %rdi
leaq 0xc(%rbp), %r13
leaq 0x4e7b(%rip), %rsi      # 0x678c
pushq $0x69
popq %rdx
movq %rdi, %r15
movq %r13, %rcx
callq 0x53c0
addq $0x3c, %rbp
leaq 0x30(%rsp), %rbx
xorl %r12d, %r12d
movslq (%r13), %rax
cmpq %rax, %r12
jge 0x1988
incq %r12
movq %rbx, %rdi
leaq 0x4e61(%rip), %rsi      # 0x67a2
movl %r12d, %edx
xorl %eax, %eax
callq 0x1170
leaq -0x28(%rbp), %rcx
movq %r15, %rdi
movq %rbx, %rsi
pushq $0x69
popq %rdx
callq 0x53c0
movq %rbx, %rdi
leaq 0x4e54(%rip), %rsi      # 0x67bb
movl %r12d, %edx
xorl %eax, %eax
callq 0x1170
movq %r15, %rdi
movq %rbx, %rsi
pushq $0x66
popq %rdx
movq %rbp, %rcx
callq 0x53c0
addq $0x4, %rbp
jmp 0x192b
leaq 0x4e44(%rip), %rsi      # 0x67d3
pushq $0x69
popq %rbp
movq %r15, %r12
movq %r15, %rdi
movl %ebp, %edx
movq 0x28(%rsp), %r14
movq %r14, %rcx
callq 0x53c0
leaq 0x10(%r14), %rcx
leaq 0x4e30(%rip), %rsi      # 0x67e2
pushq $0x73
popq %rbx
movq %r15, %rdi
movl %ebx, %edx
callq 0x53c0
leaq 0x4e29(%rip), %rsi      # 0x67ef
movq %r15, %rdi
movl %ebx, %edx
movq 0x10(%rsp), %rcx
callq 0x53c0
leaq 0x4(%r14), %rcx
leaq 0x4e1b(%rip), %rsi      # 0x67fb
pushq $0x66
popq %rbx
movq %r15, %rdi
movl %ebx, %edx
callq 0x53c0
leaq 0xc(%r14), %rcx
leaq 0x4e11(%rip), %rsi      # 0x6809
movq %r15, %rdi
movl %ebx, %edx
callq 0x53c0
addq $0x8, %r14
leaq 0x4e04(%rip), %rsi      # 0x6811
movq %r15, %rdi
movl %ebx, %edx
movq %r14, %rcx
callq 0x53c0
movq 0x18(%rsp), %r15
leaq 0x14(%r15), %rcx
leaq 0x4df2(%rip), %rsi      # 0x681c
movq %r12, %rdi
movl %ebp, %edx
callq 0x53c0
leaq 0x4dfb(%rip), %rsi      # 0x6836
movq %r12, %rdi
movl %ebp, %edx
movq %r15, %rcx
callq 0x53c0
leaq 0x8(%r15), %rcx
leaq 0x4dfc(%rip), %rsi      # 0x684f
movq %r12, %rdi
movl %ebp, %edx
callq 0x53c0
cmpl $0x1, 0x8(%r15)
movq 0x20(%rsp), %r14
jne 0x1b9f
leaq 0x4(%r15), %rcx
leaq 0x4def(%rip), %rsi      # 0x6867
pushq $0x69
popq %rdx
movq %r12, %rdi
callq 0x53c0
leaq 0x4df9(%rip), %rsi      # 0x6883
pushq $0x73
popq %rdx
leaq 0x6(%rsp), %rbx
movq %r12, %rdi
movq %rbx, %rcx
callq 0x53c0
leaq 0x4b5e(%rip), %rsi      # 0x6602
pushq $0x6
popq %rdx
movq %rbx, %rdi
callq 0x1120
testl %eax, %eax
je 0x1af2
leaq 0x4b4e(%rip), %rsi      # 0x6608
leaq 0x6(%rsp), %rdi
pushq $0x9
popq %rdx
callq 0x1120
xorl %ecx, %ecx
testl %eax, %eax
je 0x1af5
movq 0x8524(%rip), %rax      # 0x9ff8
movq (%rax), %rdi
leaq 0x4b33(%rip), %rsi      # 0x6611
leaq 0x6(%rsp), %rdx
xorl %eax, %eax
callq 0x10f0
pushq $0x1
popq %rdi
callq 0x1180
pushq $0x1
popq %rcx
movl %ecx, 0x20(%r15)
leaq 0xc(%r15), %rcx
leaq 0x4d95(%rip), %rsi      # 0x6899
pushq $0x69
popq %rdx
movq %r12, %rdi
callq 0x53c0
cmpl $0x0, 0xc(%r15)
je 0x1b86
leaq 0x18(%r15), %rcx
leaq 0x4d93(%rip), %rsi      # 0x68b4
pushq $0x69
popq %rbx
movq %r12, %rdi
movl %ebx, %edx
callq 0x53c0
leaq 0x24(%r15), %rcx
leaq 0x4d94(%rip), %rsi      # 0x68cd
pushq $0x66
popq %rbp
movq %r12, %rdi
movl %ebp, %edx
callq 0x53c0
leaq 0x28(%r15), %rcx
leaq 0x4d86(%rip), %rsi      # 0x68d7
movq %r12, %rdi
movl %ebp, %edx
callq 0x53c0
leaq 0x10(%r15), %rcx
leaq 0x4d7b(%rip), %rsi      # 0x68e1
movq %r12, %rdi
movl %ebx, %edx
callq 0x53c0
cmpl $0x0, 0x10(%r15)
je 0x1b9f
addq $0x1c, %r15
leaq 0x4d74(%rip), %rsi      # 0x68f6
pushq $0x69
jmp 0x1b93
addq $0x2c, %r15
leaq 0x4d80(%rip), %rsi      # 0x6911
pushq $0x66
popq %rdx
movq %r12, %rdi
movq %r15, %rcx
callq 0x53c0
pushq $0x1
popq %rbx
movq %r12, %rdi
callq 0x1080
movss 0xc(%r14), %xmm0
movss 0x10(%r14), %xmm1
movss 0x14(%r14), %xmm2
unpcklps %xmm2, %xmm0            # xmm0 = xmm0[0],xmm2[0],xmm0[1],xmm2[1]
movss 0x18(%r14), %xmm2
unpcklps %xmm2, %xmm1            # xmm1 = xmm1[0],xmm2[0],xmm1[1],xmm2[1]
subps %xmm0, %xmm1
movsd 0x1c(%r14), %xmm0
divps %xmm0, %xmm1
addps 0x4745(%rip), %xmm1     # 0x6320
cvttps2dq %xmm1, %xmm0
movq %xmm0, (%r14)
movd %xmm0, %eax
pshufd $0x55, %xmm0, %xmm0     # xmm0 = xmm0[1,1,1,1]
movd %xmm0, %ecx
imull %eax, %ecx
movl %ecx, 0x8(%r14)
movl %ebx, %eax
addq $0x138, %rsp            # imm = 0x138
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq