// File: /workspace/github_c_makefile_star2_O3/usgs[P]nshmp-haz-catalogs/src/agrid/adaptive/read_write_params.c
// Function: load_poly_data
void load_poly_data(struct compl_levels* cat_comp)
/*--------------------------------------------------------------------------*/
{
   FILE *fplst, *fppoly;
   int cnt, cnt1, cnt2, nheaders, years_gap;
   char buff[BUFFLEN], nm_tmp[200];
   char polygonFilePath[200];

   if( (fplst = fopen(cat_comp->catalogGapsFile, "r"))==NULL) {
     fprintf(stderr,"Cannot open file with list of polygons, %s\n", cat_comp->catalogGapsFile);
     exit(1);
   }
   fprintf(stderr,"Opened file with list of polygons, %s\n", cat_comp->catalogGapsFile);
// loop through list of all polygon files
   cnt=0;
   while(fgets(buff,BUFFLEN,fplst) ) {
     sscanf(buff,"%s %d %d", nm_tmp, &years_gap, &nheaders);
     sprintf(polygonFilePath, "%s/%s", cat_comp->catalogGapsPolygonPath, nm_tmp);

     if( (fppoly  = fopen(polygonFilePath, "r"))==NULL) {
       fprintf(stderr, "Cannot open polygon file, %s\n", polygonFilePath);
       exit(1);
     }
     for(cnt1=0; cnt1<nheaders; cnt1++) fgets(buff,BUFFLEN,fppoly);
     cat_comp->polygons.elem[cnt].nyears=years_gap;
     cnt2=0;
     while(fgets(buff,BUFFLEN,fppoly) ) {
       sscanf(buff,"%f %f", &(cat_comp->polygons.elem[cnt].lon[cnt2]), &(cat_comp->polygons.elem[cnt].lat[cnt2]) );
       cnt2++;
     }
     cat_comp->polygons.elem[cnt].npts=cnt2;
     fclose(fppoly);
     cnt++;
   }
   cat_comp->polygons.npoly=cnt;
   fprintf(stderr,"Read %d polygons.\n", cat_comp->polygons.npoly);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x308, %rsp            # imm = 0x308
movq %rdi, %r14
leaq 0x130(%rdi), %rbx
leaq 0x4a0d(%rip), %rsi      # 0x68cb
movq %rbx, %rdi
callq 0x1160
movq 0x812b(%rip), %r15      # 0x9ff8
movq (%r15), %rdi
testq %rax, %rax
je 0x20b7
movq %rax, %r13
leaq 0x4479(%rip), %rsi      # 0x635c
xorl %r12d, %r12d
movq %rbx, %rdx
xorl %eax, %eax
callq 0x1100
leaq 0x110(%rsp), %rdi
movl $0x12c, %esi            # imm = 0x12C
movq %r13, %rdx
callq 0x10e0
testq %rax, %rax
je 0x2080
leaq 0x1f8(%r14), %rax
movq %rax, 0x30(%rsp)
leaq 0x2983c8(%r14), %rax
movq %rax, 0x18(%rsp)
movq %r14, 0x20(%rsp)
leaq 0x298420(%r14), %rax
movq %rax, 0x10(%rsp)
leaq 0x110(%rsp), %rbp
leaq 0x4ef1(%rip), %r14      # 0x6e37
xorl %r15d, %r15d
movq %r13, 0x28(%rsp)
movq %rbp, %rdi
leaq 0x442b(%rip), %rsi      # 0x6383
leaq 0x240(%rsp), %rbx
movq %rbx, %rdx
leaq 0xc(%rsp), %rcx
leaq 0x8(%rsp), %r8
xorl %eax, %eax
callq 0x1130
leaq 0x40(%rsp), %r12
movq %r12, %rdi
leaq 0x4409(%rip), %rsi      # 0x638c
movq 0x30(%rsp), %rdx
movq %rbx, %rcx
xorl %eax, %eax
callq 0x1180
movq %r12, %rdi
leaq 0x492f(%rip), %rsi      # 0x68cb
callq 0x1160
testq %rax, %rax
je 0x20ad
movq %rax, %r12
cmpl $0x0, 0x8(%rsp)
jle 0x1fce
xorl %ebx, %ebx
movq %rbp, %rdi
movl $0x12c, %esi            # imm = 0x12C
movq %r12, %rdx
callq 0x10e0
incl %ebx
cmpl 0x8(%rsp), %ebx
jl 0x1fb6
movl 0xc(%rsp), %eax
movq %r15, 0x38(%rsp)
imulq $0xa8, %r15, %r15
movq 0x18(%rsp), %rcx
movl %eax, 0x4(%rcx,%r15)
movq %rbp, %rdi
movl $0x12c, %esi            # imm = 0x12C
movq %r12, %rdx
callq 0x10e0
xorl %r13d, %r13d
testq %rax, %rax
je 0x2035
movq 0x10(%rsp), %rbx
leaq -0x50(%rbx), %rdx
movq %rbp, %rdi
movq %r14, %rsi
movq %rbx, %rcx
xorl %eax, %eax
callq 0x1130
movq %rbp, %rdi
movl $0x12c, %esi            # imm = 0x12C
movq %r12, %rdx
callq 0x10e0
addq $0x4, %rbx
incl %r13d
testq %rax, %rax
jne 0x2005
addq 0x18(%rsp), %r15
movl %r13d, (%r15)
movq %r12, %rdi
callq 0x1080
movq 0x38(%rsp), %r15
incq %r15
movq %rbp, %rdi
movl $0x12c, %esi            # imm = 0x12C
movq 0x28(%rsp), %rdx
callq 0x10e0
addq $0xa8, 0x10(%rsp)
testq %rax, %rax
jne 0x1f4e
movq 0x20(%rsp), %r14
movq %r15, %r12
movq 0x7f78(%rip), %r15      # 0x9ff8
movl %r12d, 0x2983c4(%r14)
movq (%r15), %rdi
leaq 0x431f(%rip), %rsi      # 0x63b0
movl %r12d, %edx
xorl %eax, %eax
callq 0x1100
addq $0x308, %rsp            # imm = 0x308
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x40(%rsp), %rdi
callq 0x13bc
leaq 0x4272(%rip), %rsi      # 0x6330
movq %rbx, %rdx
xorl %eax, %eax
callq 0x1100
movl $0x1, %edi
callq 0x1190