// File: /workspace/github_c_makefile_star2_O3/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, %r13
movq %r8, 0x28(%rsp)
movq %rcx, %rbp
movq %rdx, %r15
movq %rsi, %r14
movq %rdi, %rbx
leaq 0x41d7(%rip), %rsi      # 0x68cb
callq 0x1160
movq %rax, %r12
movq 0x78f5(%rip), %rax      # 0x9ff8
movq (%rax), %rdi
testq %r12, %r12
jne 0x2723
leaq 0x3eb1(%rip), %rsi      # 0x65c3
xorl %ebp, %ebp
movq %rbx, %rdx
xorl %eax, %eax
callq 0x1100
jmp 0x2ae0
movq %rbp, 0x18(%rsp)
movq %r13, 0x20(%rsp)
leaq 0x3ead(%rip), %rsi      # 0x65e1
movq %rbx, %rdx
xorl %eax, %eax
callq 0x1100
leaq 0x30(%rsp), %rbp
movq %rbp, %rdi
movl $0x12c, %esi            # imm = 0x12C
movq %r12, %rdx
callq 0x10e0
leaq 0x14(%r15), %rdx
leaq 0x18(%r15), %rcx
leaq 0x46d5(%rip), %rbx      # 0x6e37
movq %rbp, %rdi
movq %rbx, %rsi
xorl %eax, %eax
callq 0x1130
movq %rbp, %rdi
movl $0x12c, %esi            # imm = 0x12C
movq %r12, %rdx
callq 0x10e0
leaq 0xc(%r15), %rdx
leaq 0x10(%r15), %rcx
movq %rbp, %rdi
movq %rbx, %rsi
xorl %eax, %eax
callq 0x1130
movq %rbp, %rdi
movl $0x12c, %esi            # imm = 0x12C
movq %r12, %rdx
callq 0x10e0
leaq 0x20(%r15), %rdx
movq %r15, 0x10(%rsp)
leaq 0x1c(%r15), %rcx
movq %rbp, %rdi
movq %rbx, %rsi
xorl %eax, %eax
callq 0x1130
movq %rbp, %rdi
movl $0x12c, %esi            # imm = 0x12C
movq %r12, %rdx
callq 0x10e0
leaq 0xc(%r14), %rbx
leaq 0x3bb0(%rip), %rsi      # 0x6389
movq %rbp, %rdi
movq %rbx, %rdx
xorl %eax, %eax
callq 0x1130
cmpl $0x0, 0xc(%r14)
jle 0x2833
addq $0x3c, %r14
leaq 0x30(%rsp), %rbp
leaq 0x3d7f(%rip), %r15      # 0x657c
xorl %r13d, %r13d
movq %rbp, %rdi
movl $0x12c, %esi            # imm = 0x12C
movq %r12, %rdx
callq 0x10e0
leaq -0x28(%r14), %rcx
movq %rbp, %rdi
movq %r15, %rsi
movq %r14, %rdx
xorl %eax, %eax
callq 0x1130
incq %r13
movslq (%rbx), %rax
addq $0x4, %r14
cmpq %rax, %r13
jl 0x2800
leaq 0x30(%rsp), %rbp
movq %rbp, %rdi
movl $0x12c, %esi            # imm = 0x12C
movq %r12, %rdx
callq 0x10e0
leaq 0x3b3a(%rip), %r14      # 0x6389
movq %rbp, %rdi
movq %r14, %rsi
movq 0x18(%rsp), %rbx
movq %rbx, %rdx
xorl %eax, %eax
callq 0x1130
movq %rbp, %rdi
movl $0x12c, %esi            # imm = 0x12C
movq %r12, %rdx
callq 0x10e0
leaq 0x10(%rbx), %rdx
leaq 0x3b10(%rip), %r13      # 0x638f
movq %rbp, %rdi
movq %r13, %rsi
xorl %eax, %eax
callq 0x1130
movq %rbp, %rdi
movl $0x12c, %esi            # imm = 0x12C
movq %r12, %rdx
callq 0x10e0
leaq 0x4(%rbx), %rdx
leaq 0x8(%rbx), %rcx
addq $0xc, %rbx
leaq 0x4585(%rip), %rsi      # 0x6e34
movq %rbp, %rdi
movq %rbx, %r8
xorl %eax, %eax
callq 0x1130
movq %rbp, %rdi
movl $0x12c, %esi            # imm = 0x12C
movq %r12, %rdx
callq 0x10e0
movq %rbp, %rdi
movq %r14, %rsi
movq 0x28(%rsp), %r15
movq %r15, %rdx
xorl %eax, %eax
callq 0x1130
movq %rbp, %rdi
movl $0x12c, %esi            # imm = 0x12C
movq %r12, %rdx
callq 0x10e0
leaq 0x4(%r15), %rdx
movq %rbp, %rdi
movq %r14, %rsi
xorl %eax, %eax
callq 0x1130
movq %rbp, %rdi
movl $0x12c, %esi            # imm = 0x12C
movq %r12, %rdx
callq 0x10e0
leaq 0x8(%r15), %rdx
movq %rbp, %rdi
movq %r14, %rsi
xorl %eax, %eax
callq 0x1130
movq %rbp, %rdi
movl $0x12c, %esi            # imm = 0x12C
movq %r12, %rdx
callq 0x10e0
leaq 0xc(%r15), %rdx
movq %rbp, %rdi
movq %r14, %rsi
xorl %eax, %eax
callq 0x1130
movq %rbp, %rdi
movl $0x12c, %esi            # imm = 0x12C
movq %r12, %rdx
callq 0x10e0
leaq 0x24(%r15), %rdx
leaq 0x28(%r15), %rcx
leaq 0x44d4(%rip), %rsi      # 0x6e37
movq %rbp, %rdi
xorl %eax, %eax
callq 0x1130
movq %rbp, %rdi
movl $0x12c, %esi            # imm = 0x12C
movq %r12, %rdx
callq 0x10e0
leaq 0x18(%r15), %rdx
movq %rbp, %rdi
movq %r14, %rsi
xorl %eax, %eax
callq 0x1130
movq %rbp, %rdi
movl $0x12c, %esi            # imm = 0x12C
movq %r12, %rdx
callq 0x10e0
movq %rbp, %rdi
movq %r13, %rsi
movq 0x20(%rsp), %r14
movq %r14, %rdx
xorl %eax, %eax
callq 0x1130
movq %rbp, %rdi
movl $0x12c, %esi            # imm = 0x12C
movq %r12, %rdx
callq 0x10e0
leaq 0x6(%rsp), %rbx
movq %rbp, %rdi
movq %r13, %rsi
movq %rbx, %rdx
xorl %eax, %eax
callq 0x1130
movl $0x73756167, %eax       # imm = 0x73756167
xorl (%rbx), %eax
movzwl 0x4(%rbx), %ecx
xorl $0x73, %ecx
movl $0x1, %ebp
orl %eax, %ecx
movl $0x1, %eax
je 0x2a16
movabsq $0x77614c7265776f70, %rax # imm = 0x77614C7265776F70
xorq 0x6(%rsp), %rax
movzbl 0xe(%rsp), %ecx
orq %rax, %rcx
movl $0x0, %eax
jne 0x2af4
movl %eax, 0x20(%r15)
movq %r12, %rdi
callq 0x1080
movl $0x1, 0x14(%r15)
movq 0x75c7(%rip), %rbx      # 0x9ff8
movq (%rbx), %rcx
leaq 0x3c23(%rip), %rdi      # 0x665e
movl $0x28, %esi
movl $0x1, %edx
callq 0x11a0
movss 0x28(%r15), %xmm0
movss %xmm0, 0x2c(%r15)
movq (%rbx), %rdi
cvtss2sd %xmm0, %xmm0
leaq 0x3c23(%rip), %rsi      # 0x6687
movb $0x1, %al
callq 0x1100
movq (%rbx), %rdi
movl 0x18(%r15), %edx
leaq 0x3c1a(%rip), %rsi      # 0x6693
xorl %eax, %eax
callq 0x1100
movq (%rbx), %rdi
leaq 0x3c14(%rip), %rsi      # 0x669e
movq %r14, %rdx
xorl %eax, %eax
callq 0x1100
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 0x385b(%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
leaq 0x6(%rsp), %rdi
callq 0x14d9