// File: /workspace/github_c_makefile_star2_O2/usgs[P]nshmp-haz-catalogs/src/agrid/adaptive/read_write_params.c
// Function: read_params
int read_params(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], 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\n", parf);

// read parameters
  fgets(buff,BUFFLEN,fpparam); sscanf(buff,"%f %f", &reg->minlat, &reg->maxlat);
  fgets(buff,BUFFLEN,fpparam); sscanf(buff,"%f %f", &reg->minlon, &reg->maxlon);
  fgets(buff,BUFFLEN,fpparam); sscanf(buff,"%f %f", &reg->dlat, &reg->dlon);
// completeness levels
  fgets(buff,BUFFLEN,fpparam); sscanf(buff,"%d", &cat_comp->nlevels);
  for (cnt=0; cnt<cat_comp->nlevels; cnt++) {
    fgets(buff,BUFFLEN,fpparam); sscanf(buff,"%f %d", &cat_comp->mag_comp[cnt], &cat_comp->yr_comp[cnt]);
  }
// catalog end year, name, and min-magnitude/d-mag/b-value
  fgets(buff,BUFFLEN,fpparam); sscanf(buff,"%d", &cat->end_yr);
  fgets(buff,BUFFLEN,fpparam); sscanf(buff,"%s", cat->catnm);
  fgets(buff,BUFFLEN,fpparam); sscanf(buff,"%f %f %f", &cat->minMag, &cat->dMag, &cat->bval);
// smoothing parameters
  fgets(buff,BUFFLEN,fpparam); sscanf(buff,"%d", &smp->cumul_rates);
  fgets(buff,BUFFLEN,fpparam); sscanf(buff,"%d", &smp->adj_compl);
  fgets(buff,BUFFLEN,fpparam); sscanf(buff,"%d", &smp->apply_sm);
  fgets(buff,BUFFLEN,fpparam); sscanf(buff,"%d", &smp->adapt_sm);
  fgets(buff,BUFFLEN,fpparam); sscanf(buff,"%f %f", &smp->sigmin, &smp->sigmax);
  fgets(buff,BUFFLEN,fpparam); sscanf(buff,"%d", &smp->nnum);
  fgets(buff,BUFFLEN,fpparam); sscanf(buff,"%s", outfnm);
  fgets(buff,BUFFLEN,fpparam); sscanf(buff,"%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);
  }
//  fscanf(fpparam,"%d", &smp->nnum);
//  fscanf(fpparam,"%s", outfnm);
// close file
  fclose(fpparam);

// force to use effective-numbers of earthquakes
  smp->use_neff=1;
  fprintf(stderr,"Using effective numbers of earthquakes.\n");

// currently set fixed-R to sigmax value
  smp->sigfix=smp->sigmax;
  fprintf(stderr,"sigmax: %f\n", smp->sigmax);
  fprintf(stderr,"nnum : %d\n", smp->nnum);
  fprintf(stderr,"outname: %s\n", outfnm);

// 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 $0x168, %rsp            # imm = 0x168
movq %r9, %rbp
movq %r8, %r13
movq %rcx, 0x28(%rsp)
movq %rdx, %r15
movq %rsi, %r14
movq %rdi, %rbx
leaq 0x4ba7(%rip), %rsi      # 0x68cb
callq 0x1150
movq %rax, %r12
movq 0x82c5(%rip), %rax      # 0x9ff8
movq (%rax), %rdi
testq %r12, %r12
jne 0x1d53
leaq 0x4881(%rip), %rsi      # 0x65c3
xorl %ebp, %ebp
movq %rbx, %rdx
xorl %eax, %eax
callq 0x10f0
jmp 0x20f6
movq %r13, 0x18(%rsp)
movq %rbp, 0x20(%rsp)
leaq 0x487d(%rip), %rsi      # 0x65e1
movq %rbx, %rdx
xorl %eax, %eax
callq 0x10f0
leaq 0x30(%rsp), %r13
movq %r13, %rdi
movl $0x12c, %esi            # imm = 0x12C
movq %r12, %rdx
callq 0x10d0
leaq 0x14(%r15), %rdx
leaq 0x18(%r15), %rcx
leaq 0x50a5(%rip), %rbx      # 0x6e37
movq %r13, %rdi
movq %rbx, %rsi
xorl %eax, %eax
callq 0x1110
movq %r13, %rdi
movl $0x12c, %esi            # imm = 0x12C
movq %r12, %rdx
callq 0x10d0
leaq 0xc(%r15), %rdx
leaq 0x10(%r15), %rcx
movq %r13, %rdi
movq %rbx, %rsi
xorl %eax, %eax
callq 0x1110
movq %r13, %rdi
movl $0x12c, %esi            # imm = 0x12C
movq %r12, %rdx
callq 0x10d0
leaq 0x20(%r15), %rdx
movq %r15, 0x10(%rsp)
leaq 0x1c(%r15), %rcx
movq %r13, %rdi
movq %rbx, %rsi
xorl %eax, %eax
callq 0x1110
movq %r13, %rdi
movl $0x12c, %esi            # imm = 0x12C
movq %r12, %rbp
movq %r12, %rdx
callq 0x10d0
leaq 0xc(%r14), %rbx
leaq 0x457d(%rip), %rsi      # 0x6389
movq %r13, %r15
movq %r13, %rdi
movq %rbx, %rdx
xorl %eax, %eax
callq 0x1110
addq $0x3c, %r14
xorl %r13d, %r13d
movslq (%rbx), %r12
movq %r15, %rdi
movl $0x12c, %esi            # imm = 0x12C
movq %rbp, %rdx
callq 0x10d0
cmpq %r12, %r13
jge 0x1e5c
leaq -0x28(%r14), %rcx
movq %r15, %rdi
leaq 0x4733(%rip), %rsi      # 0x657c
movq %r14, %rdx
xorl %eax, %eax
callq 0x1110
incq %r13
addq $0x4, %r14
jmp 0x1e23
leaq 0x4526(%rip), %r14      # 0x6389
leaq 0x30(%rsp), %r13
movq %r13, %rdi
movq %r14, %rsi
movq 0x28(%rsp), %rbx
movq %rbx, %rdx
xorl %eax, %eax
callq 0x1110
movq %r13, %rdi
movl $0x12c, %esi            # imm = 0x12C
movq %rbp, %r12
movq %rbp, %rdx
callq 0x10d0
leaq 0x10(%rbx), %rdx
leaq 0x44f4(%rip), %rbp      # 0x638f
movq %r13, %rdi
movq %rbp, %rsi
xorl %eax, %eax
callq 0x1110
movq %r13, %rdi
movl $0x12c, %esi            # imm = 0x12C
movq %r12, %rdx
callq 0x10d0
leaq 0x4(%rbx), %rdx
leaq 0x8(%rbx), %rcx
addq $0xc, %rbx
leaq 0x4f69(%rip), %rsi      # 0x6e34
movq %r13, %rdi
movq %rbx, %r8
xorl %eax, %eax
callq 0x1110
movq %r13, %rdi
movl $0x12c, %esi            # imm = 0x12C
movq %r12, %rdx
callq 0x10d0
movq %r13, %rdi
movq %r14, %rsi
movq 0x18(%rsp), %r15
movq %r15, %rdx
xorl %eax, %eax
callq 0x1110
movq %r13, %rdi
movl $0x12c, %esi            # imm = 0x12C
movq %r12, %rdx
callq 0x10d0
leaq 0x4(%r15), %rdx
movq %r13, %rdi
movq %r14, %rsi
xorl %eax, %eax
callq 0x1110
movq %r13, %rdi
movl $0x12c, %esi            # imm = 0x12C
movq %r12, %rdx
callq 0x10d0
leaq 0x8(%r15), %rdx
movq %r13, %rdi
movq %r14, %rsi
xorl %eax, %eax
callq 0x1110
movq %r13, %rdi
movl $0x12c, %esi            # imm = 0x12C
movq %r12, %rdx
callq 0x10d0
leaq 0xc(%r15), %rdx
movq %r13, %rdi
movq %r14, %rsi
xorl %eax, %eax
callq 0x1110
movq %r13, %rdi
movl $0x12c, %esi            # imm = 0x12C
movq %r12, %rdx
callq 0x10d0
leaq 0x24(%r15), %rdx
leaq 0x28(%r15), %rcx
leaq 0x4eb8(%rip), %rsi      # 0x6e37
movq %r13, %rdi
xorl %eax, %eax
callq 0x1110
movq %r13, %rdi
movl $0x12c, %esi            # imm = 0x12C
movq %r12, %rdx
callq 0x10d0
leaq 0x18(%r15), %rdx
movq %r13, %rdi
movq %r14, %rsi
xorl %eax, %eax
callq 0x1110
movq %r13, %rdi
movl $0x12c, %esi            # imm = 0x12C
movq %r12, %rdx
callq 0x10d0
movq %r13, %rdi
movq %rbp, %rsi
movq 0x20(%rsp), %r14
movq %r14, %rdx
xorl %eax, %eax
callq 0x1110
movq %r13, %rdi
movl $0x12c, %esi            # imm = 0x12C
movq %r12, %rdx
callq 0x10d0
leaq 0x6(%rsp), %rbx
movq %r13, %rdi
movq %rbp, %rsi
movq %rbx, %rdx
xorl %eax, %eax
callq 0x1110
leaq 0x4607(%rip), %rsi      # 0x6602
pushq $0x6
popq %rdx
movq %rbx, %rdi
callq 0x1120
pushq $0x1
popq %rbp
movl %ebp, %ecx
testl %eax, %eax
je 0x2030
leaq 0x45f2(%rip), %rsi      # 0x6608
leaq 0x6(%rsp), %rdi
pushq $0x9
popq %rdx
callq 0x1120
movl $0x0, %ecx
testl %eax, %eax
jne 0x210a
movl %ecx, 0x20(%r15)
movq %r12, %rdi
callq 0x1080
movl $0x1, 0x14(%r15)
movq 0x7fad(%rip), %rbx      # 0x9ff8
movq (%rbx), %rcx
leaq 0x4609(%rip), %rdi      # 0x665e
pushq $0x28
popq %rsi
pushq $0x1
popq %rdx
callq 0x1190
movss 0x28(%r15), %xmm0
movss %xmm0, 0x2c(%r15)
movq (%rbx), %rdi
cvtss2sd %xmm0, %xmm0
leaq 0x460d(%rip), %rsi      # 0x6687
movb $0x1, %al
callq 0x10f0
movq (%rbx), %rdi
movl 0x18(%r15), %edx
leaq 0x4604(%rip), %rsi      # 0x6693
xorl %eax, %eax
callq 0x10f0
movq (%rbx), %rdi
leaq 0x45fe(%rip), %rsi      # 0x669e
movq %r14, %rdx
xorl %eax, %eax
callq 0x10f0
movq 0x10(%rsp), %rdx
movss 0xc(%rdx), %xmm0
movss 0x10(%rdx), %xmm1
movss 0x14(%rdx), %xmm2
unpcklps %xmm2, %xmm0            # xmm0 = xmm0[0],xmm2[0],xmm0[1],xmm2[1]
movss 0x18(%rdx), %xmm2
unpcklps %xmm2, %xmm1            # xmm1 = xmm1[0],xmm2[0],xmm1[1],xmm2[1]
subps %xmm0, %xmm1
movsd 0x1c(%rdx), %xmm0
divps %xmm0, %xmm1
addps 0x4245(%rip), %xmm1     # 0x6320
cvttps2dq %xmm1, %xmm0
movq %xmm0, (%rdx)
movd %xmm0, %eax
pshufd $0x55, %xmm0, %xmm0     # xmm0 = xmm0[1,1,1,1]
movd %xmm0, %ecx
imull %eax, %ecx
movl %ecx, 0x8(%rdx)
movl %ebp, %eax
addq $0x168, %rsp            # imm = 0x168
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x7ee7(%rip), %rax      # 0x9ff8
movq (%rax), %rdi
leaq 0x44f6(%rip), %rsi      # 0x6611
leaq 0x6(%rsp), %rdx
xorl %eax, %eax
callq 0x10f0
pushq $0x1
popq %rdi
callq 0x1180