// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x180, %rsp            # imm = 0x180
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movq %r8, -0x30(%rbp)
movq %r9, -0x38(%rbp)
movq -0x10(%rbp), %rdi
leaq 0x6919(%rip), %rsi      # 0x88b7
callq 0x1130
movq %rax, -0x40(%rbp)
cmpq $0x0, %rax
jne 0x1fd5
movq 0xa044(%rip), %rax      # 0xbff8
movq (%rax), %rdi
movq -0x10(%rbp), %rdx
leaq 0x65ed(%rip), %rsi      # 0x85af
movb $0x0, %al
callq 0x10e0
movl $0x0, -0x4(%rbp)
jmp 0x2502
movq 0xa01c(%rip), %rax      # 0xbff8
movq (%rax), %rdi
movq -0x10(%rbp), %rdx
leaq 0x65e3(%rip), %rsi      # 0x85cd
movb $0x0, %al
callq 0x10e0
leaq -0x170(%rbp), %rdi
movq -0x40(%rbp), %rdx
movl $0x12c, %esi            # imm = 0x12C
callq 0x10c0
leaq -0x170(%rbp), %rdi
movq -0x20(%rbp), %rdx
addq $0x14, %rdx
movq -0x20(%rbp), %rcx
addq $0x18, %rcx
leaq 0x6dff(%rip), %rsi      # 0x8e23
movb $0x0, %al
callq 0x1100
leaq -0x170(%rbp), %rdi
movq -0x40(%rbp), %rdx
movl $0x12c, %esi            # imm = 0x12C
callq 0x10c0
leaq -0x170(%rbp), %rdi
movq -0x20(%rbp), %rdx
addq $0xc, %rdx
movq -0x20(%rbp), %rcx
addq $0x10, %rcx
leaq 0x6dc5(%rip), %rsi      # 0x8e23
movb $0x0, %al
callq 0x1100
leaq -0x170(%rbp), %rdi
movq -0x40(%rbp), %rdx
movl $0x12c, %esi            # imm = 0x12C
callq 0x10c0
leaq -0x170(%rbp), %rdi
movq -0x20(%rbp), %rdx
addq $0x20, %rdx
movq -0x20(%rbp), %rcx
addq $0x1c, %rcx
leaq 0x6d8b(%rip), %rsi      # 0x8e23
movb $0x0, %al
callq 0x1100
leaq -0x170(%rbp), %rdi
movq -0x40(%rbp), %rdx
movl $0x12c, %esi            # imm = 0x12C
callq 0x10c0
leaq -0x170(%rbp), %rdi
movq -0x18(%rbp), %rdx
addq $0xc, %rdx
leaq 0x62ab(%rip), %rsi      # 0x8375
movb $0x0, %al
callq 0x1100
movl $0x0, -0x44(%rbp)
movl -0x44(%rbp), %eax
movq -0x18(%rbp), %rcx
cmpl 0xc(%rcx), %eax
jge 0x213f
leaq -0x170(%rbp), %rdi
movq -0x40(%rbp), %rdx
movl $0x12c, %esi            # imm = 0x12C
callq 0x10c0
leaq -0x170(%rbp), %rdi
movq -0x18(%rbp), %rdx
addq $0x3c, %rdx
movslq -0x44(%rbp), %rax
shlq $0x2, %rax
addq %rax, %rdx
movq -0x18(%rbp), %rcx
addq $0x14, %rcx
movslq -0x44(%rbp), %rax
shlq $0x2, %rax
addq %rax, %rcx
leaq 0x643b(%rip), %rsi      # 0x8568
movb $0x0, %al
callq 0x1100
movl -0x44(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x44(%rbp)
jmp 0x20d8
leaq -0x170(%rbp), %rdi
movq -0x40(%rbp), %rdx
movl $0x12c, %esi            # imm = 0x12C
callq 0x10c0
leaq -0x170(%rbp), %rdi
movq -0x28(%rbp), %rdx
leaq 0x620f(%rip), %rsi      # 0x8375
movb $0x0, %al
callq 0x1100
leaq -0x170(%rbp), %rdi
movq -0x40(%rbp), %rdx
movl $0x12c, %esi            # imm = 0x12C
callq 0x10c0
leaq -0x170(%rbp), %rdi
movq -0x28(%rbp), %rdx
addq $0x10, %rdx
leaq 0x61e3(%rip), %rsi      # 0x837b
movb $0x0, %al
callq 0x1100
leaq -0x170(%rbp), %rdi
movq -0x40(%rbp), %rdx
movl $0x12c, %esi            # imm = 0x12C
callq 0x10c0
leaq -0x170(%rbp), %rdi
movq -0x28(%rbp), %rdx
addq $0x4, %rdx
movq -0x28(%rbp), %rcx
addq $0x8, %rcx
movq -0x28(%rbp), %r8
addq $0xc, %r8
leaq 0x6c46(%rip), %rsi      # 0x8e20
movb $0x0, %al
callq 0x1100
leaq -0x170(%rbp), %rdi
movq -0x40(%rbp), %rdx
movl $0x12c, %esi            # imm = 0x12C
callq 0x10c0
leaq -0x170(%rbp), %rdi
movq -0x30(%rbp), %rdx
leaq 0x616d(%rip), %rsi      # 0x8375
movb $0x0, %al
callq 0x1100
leaq -0x170(%rbp), %rdi
movq -0x40(%rbp), %rdx
movl $0x12c, %esi            # imm = 0x12C
callq 0x10c0
leaq -0x170(%rbp), %rdi
movq -0x30(%rbp), %rdx
addq $0x4, %rdx
leaq 0x613b(%rip), %rsi      # 0x8375
movb $0x0, %al
callq 0x1100
leaq -0x170(%rbp), %rdi
movq -0x40(%rbp), %rdx
movl $0x12c, %esi            # imm = 0x12C
callq 0x10c0
leaq -0x170(%rbp), %rdi
movq -0x30(%rbp), %rdx
addq $0x8, %rdx
leaq 0x6109(%rip), %rsi      # 0x8375
movb $0x0, %al
callq 0x1100
leaq -0x170(%rbp), %rdi
movq -0x40(%rbp), %rdx
movl $0x12c, %esi            # imm = 0x12C
callq 0x10c0
leaq -0x170(%rbp), %rdi
movq -0x30(%rbp), %rdx
addq $0xc, %rdx
leaq 0x60d7(%rip), %rsi      # 0x8375
movb $0x0, %al
callq 0x1100
leaq -0x170(%rbp), %rdi
movq -0x40(%rbp), %rdx
movl $0x12c, %esi            # imm = 0x12C
callq 0x10c0
leaq -0x170(%rbp), %rdi
movq -0x30(%rbp), %rdx
addq $0x24, %rdx
movq -0x30(%rbp), %rcx
addq $0x28, %rcx
leaq 0x6b4b(%rip), %rsi      # 0x8e23
movb $0x0, %al
callq 0x1100
leaq -0x170(%rbp), %rdi
movq -0x40(%rbp), %rdx
movl $0x12c, %esi            # imm = 0x12C
callq 0x10c0
leaq -0x170(%rbp), %rdi
movq -0x30(%rbp), %rdx
addq $0x18, %rdx
leaq 0x606b(%rip), %rsi      # 0x8375
movb $0x0, %al
callq 0x1100
leaq -0x170(%rbp), %rdi
movq -0x40(%rbp), %rdx
movl $0x12c, %esi            # imm = 0x12C
callq 0x10c0
leaq -0x170(%rbp), %rdi
movq -0x38(%rbp), %rdx
leaq 0x6043(%rip), %rsi      # 0x837b
movb $0x0, %al
callq 0x1100
leaq -0x170(%rbp), %rdi
movq -0x40(%rbp), %rdx
movl $0x12c, %esi            # imm = 0x12C
callq 0x10c0
leaq -0x170(%rbp), %rdi
leaq -0x17a(%rbp), %rdx
leaq 0x6012(%rip), %rsi      # 0x837b
movb $0x0, %al
callq 0x1100
leaq -0x17a(%rbp), %rdi
leaq 0x6270(%rip), %rsi      # 0x85ee
callq 0x10d0
cmpl $0x0, %eax
jne 0x2395
movq -0x30(%rbp), %rax
movl $0x1, 0x20(%rax)
jmp 0x23e5
leaq -0x17a(%rbp), %rdi
leaq 0x6251(%rip), %rsi      # 0x85f4
callq 0x10d0
cmpl $0x0, %eax
jne 0x23ba
movq -0x30(%rbp), %rax
movl $0x0, 0x20(%rax)
jmp 0x23e3
movq 0x9c37(%rip), %rax      # 0xbff8
movq (%rax), %rdi
leaq -0x17a(%rbp), %rdx
leaq 0x622b(%rip), %rsi      # 0x85fd
movb $0x0, %al
callq 0x10e0
movl $0x1, %edi
callq 0x1160
jmp 0x23e5
movq -0x40(%rbp), %rdi
callq 0x1080
movq -0x30(%rbp), %rax
movl $0x1, 0x14(%rax)
movq 0x9bf8(%rip), %rax      # 0xbff8
movq (%rax), %rdi
leaq 0x6240(%rip), %rsi      # 0x864a
movb $0x0, %al
callq 0x10e0
movq -0x30(%rbp), %rax
movss 0x28(%rax), %xmm0
movq -0x30(%rbp), %rax
movss %xmm0, 0x2c(%rax)
movq 0x9bce(%rip), %rax      # 0xbff8
movq (%rax), %rdi
movq -0x30(%rbp), %rax
movss 0x28(%rax), %xmm0
cvtss2sd %xmm0, %xmm0
leaq 0x6232(%rip), %rsi      # 0x8673
movb $0x1, %al
callq 0x10e0
movq 0x9ba9(%rip), %rax      # 0xbff8
movq (%rax), %rdi
movq -0x30(%rbp), %rax
movl 0x18(%rax), %edx
leaq 0x621f(%rip), %rsi      # 0x867f
movb $0x0, %al
callq 0x10e0
movq 0x9b8a(%rip), %rax      # 0xbff8
movq (%rax), %rdi
movq -0x38(%rbp), %rdx
leaq 0x620e(%rip), %rsi      # 0x868a
movb $0x0, %al
callq 0x10e0
movq -0x20(%rbp), %rax
movss 0x10(%rax), %xmm0
movq -0x20(%rbp), %rax
subss 0xc(%rax), %xmm0
movq -0x20(%rbp), %rax
divss 0x1c(%rax), %xmm0
movss 0x5e72(%rip), %xmm1     # 0x8318
addss %xmm1, %xmm0
cvttss2si %xmm0, %ecx
movq -0x20(%rbp), %rax
movl %ecx, (%rax)
movq -0x20(%rbp), %rax
movss 0x18(%rax), %xmm0
movq -0x20(%rbp), %rax
subss 0x14(%rax), %xmm0
movq -0x20(%rbp), %rax
divss 0x20(%rax), %xmm0
movss 0x5e41(%rip), %xmm1     # 0x8318
addss %xmm1, %xmm0
cvttss2si %xmm0, %ecx
movq -0x20(%rbp), %rax
movl %ecx, 0x4(%rax)
movq -0x20(%rbp), %rax
movl (%rax), %ecx
movq -0x20(%rbp), %rax
imull 0x4(%rax), %ecx
movq -0x20(%rbp), %rax
movl %ecx, 0x8(%rax)
movl $0x1, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x180, %rsp            # imm = 0x180
popq %rbp
retq
nop