// File: /workspace/github_c_makefile_star2_O1/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, %r15
movq %r8, 0x28(%rsp)
movq %rcx, %rbp
movq %rdx, %r13
movq %rsi, %r14
movq %rdi, %rbx
leaq 0x41c7(%rip), %rsi      # 0x68b7
callq 0x1160
movq %rax, %r12
movq 0x78f9(%rip), %rax      # 0x9ff8
movq (%rax), %rdi
testq %r12, %r12
jne 0x271f
leaq 0x3ea1(%rip), %rsi      # 0x65af
xorl %ebp, %ebp
movq %rbx, %rdx
xorl %eax, %eax
callq 0x1100
jmp 0x2ad6
movq %rbp, 0x18(%rsp)
movq %r15, 0x20(%rsp)
leaq 0x3e9d(%rip), %rsi      # 0x65cd
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(%r13), %rdx
leaq 0x18(%r13), %rcx
leaq 0x46c5(%rip), %r15      # 0x6e23
movq %rbp, %rdi
movq %r15, %rsi
xorl %eax, %eax
callq 0x1130
movq %rbp, %rdi
movl $0x12c, %esi            # imm = 0x12C
movq %r12, %rdx
callq 0x10e0
leaq 0xc(%r13), %rdx
leaq 0x10(%r13), %rcx
movq %rbp, %rdi
movq %r15, %rsi
xorl %eax, %eax
callq 0x1130
movq %rbp, %rdi
movl $0x12c, %esi            # imm = 0x12C
movq %r12, %rdx
callq 0x10e0
leaq 0x20(%r13), %rdx
movq %r13, 0x10(%rsp)
leaq 0x1c(%r13), %rcx
movq %rbp, %rdi
movq %r15, %rsi
xorl %eax, %eax
callq 0x1130
movq %rbp, %rdi
movl $0x12c, %esi            # imm = 0x12C
movq %r12, %rdx
callq 0x10e0
leaq 0xc(%r14), %r15
leaq 0x3ba0(%rip), %rsi      # 0x6375
movq %rbp, %rdi
movq %r15, %rdx
xorl %eax, %eax
callq 0x1130
cmpl $0x0, 0xc(%r14)
jle 0x282f
addq $0x3c, %r14
leaq 0x30(%rsp), %rbp
leaq 0x3d6f(%rip), %rbx      # 0x6568
xorl %r13d, %r13d
movq %rbp, %rdi
movl $0x12c, %esi            # imm = 0x12C
movq %r12, %rdx
callq 0x10e0
leaq -0x28(%r14), %rcx
movq %rbp, %rdi
movq %rbx, %rsi
movq %r14, %rdx
xorl %eax, %eax
callq 0x1130
incq %r13
movslq (%r15), %rax
addq $0x4, %r14
cmpq %rax, %r13
jl 0x27fc
leaq 0x30(%rsp), %rbp
movq %rbp, %rdi
movl $0x12c, %esi            # imm = 0x12C
movq %r12, %rdx
callq 0x10e0
leaq 0x3b2a(%rip), %r14      # 0x6375
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 0x3b00(%rip), %r13      # 0x637b
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 0x4575(%rip), %rsi      # 0x6e20
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 0x44c4(%rip), %rsi      # 0x6e23
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 0x2a12
movabsq $0x77614c7265776f70, %rax # imm = 0x77614C7265776F70
xorq 0x6(%rsp), %rax
movzbl 0xe(%rsp), %ecx
orq %rax, %rcx
movl $0x0, %eax
jne 0x2aea
movl %eax, 0x20(%r15)
movq %r12, %rdi
callq 0x1080
movl $0x1, 0x14(%r15)
movq 0x75cb(%rip), %rbx      # 0x9ff8
movq (%rbx), %rcx
leaq 0x3c13(%rip), %rdi      # 0x664a
movl $0x28, %esi
movl $0x1, %edx
callq 0x11a0
movss 0x28(%r15), %xmm0
movss %xmm0, 0x2c(%r15)
movq (%rbx), %rdi
cvtss2sd %xmm0, %xmm0
leaq 0x3c13(%rip), %rsi      # 0x6673
movb $0x1, %al
callq 0x1100
movq (%rbx), %rdi
movl 0x18(%r15), %edx
leaq 0x3c0a(%rip), %rsi      # 0x667f
xorl %eax, %eax
callq 0x1100
movq (%rbx), %rdi
leaq 0x3c04(%rip), %rsi      # 0x668a
movq %r14, %rdx
xorl %eax, %eax
callq 0x1100
movq 0x10(%rsp), %rdx
movss 0x10(%rdx), %xmm0
subss 0xc(%rdx), %xmm0
movss 0x18(%rdx), %xmm1
divss 0x1c(%rdx), %xmm0
movss 0x3867(%rip), %xmm2     # 0x6318
addss %xmm2, %xmm0
cvttss2si %xmm0, %eax
movl %eax, (%rdx)
subss 0x14(%rdx), %xmm1
divss 0x20(%rdx), %xmm1
addss %xmm2, %xmm1
cvttss2si %xmm1, %ecx
movl %ecx, 0x4(%rdx)
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