// File: /workspace/github_c_makefile_star2_O2/esheldon[P]xshear/src/sconfig.c
// Function: sconfig_read
ShearConfig* sconfig_read(const char* url) {

    wlog("Reading config from %s\n", url);

    enum cfg_status status=0, ostatus=0;
    struct cfg *cfg=cfg_read(url, &status);
    if (status) {
        fprintf(stderr,"Config Error: %s\n", cfg_status_string(status));
        exit(1);
    }

    ShearConfig* c=calloc(1, sizeof(ShearConfig));
    char key[CONFIG_KEYSZ];

    // set defaults for optional
    c->healpix_nside=HEALPIX_NSIDE_DEFAULT;

    c->min_zlens_interp=0;
    c->pairlog_rmax=0;
    c->pairlog_rmin=0;

    // this strcpy business is so we can print error messages
    // below
    c->H0 = cfg_get_double(cfg,strcpy(key,"H0"),&status);
    if (status) goto _sconfig_read_bail;

    c->omega_m = cfg_get_double(cfg,strcpy(key,"omega_m"),&status);
    if (status) goto _sconfig_read_bail;

    c->nbin = (int64) cfg_get_long(cfg,strcpy(key,"nbin"),&status);
    if (status) goto _sconfig_read_bail;

    c->rmin = cfg_get_double(cfg,strcpy(key,"rmin"),&status);
    if (status) goto _sconfig_read_bail;

    c->rmax = cfg_get_double(cfg,strcpy(key,"rmax"),&status);
    if (status) goto _sconfig_read_bail;

    // strings.  Error checking interior to functions
    c->mask_style = get_mask_style(cfg);

    c->shear_style = get_shear_style(cfg);

    c->scstyle = get_scstyle(cfg);

    c->Dlens_input = get_Dlens_input(cfg);

    c->sourceid_style = get_sourceid_style(cfg);

    c->r_units = get_r_units(cfg);
    
    c->shear_units = get_shear_units(cfg);

    c->weight_style = get_weight_style(cfg);

    if (c->Dlens_input && c->scstyle != SIGMACRIT_STYLE_INTERP) {
        fprintf(stderr,"Error: If the lens distance in input \n");
        fprintf(stderr,"       (Dlens_input set in config) the \n");
        fprintf(stderr,"       sigma crit style must be interpolated\n");
        exit(1);
    }
    if (c->scstyle == SIGMACRIT_STYLE_INTERP) {
        c->zl = dvector_new();

        c->zl->data=cfg_get_dblarr(cfg, strcpy(key,"zlvals"), &c->zl->size, &status);
        if (status) goto _sconfig_read_bail;

        c->nzl = (int64) c->zl->size;

    }

    // optional
    double mzl = cfg_get_double(cfg, "min_zlens_interp", &ostatus);
    if (!ostatus) {
        c->min_zlens_interp=mzl;
    }

    double dz = cfg_get_double(cfg, "zdiff_min", &ostatus);
    if (!ostatus) {
        c->zdiff_min=dz;
    }

    int nside = (int64) cfg_get_long(cfg,strcpy(key,"healpix_nside"),&ostatus);
    if (!ostatus) {
        c->healpix_nside = nside;
    }
    
    int pairlog_rmax = (int64) cfg_get_long(cfg,strcpy(key,"pairlog_rmax"),&ostatus);
    if (!ostatus) {
        c->pairlog_rmax = pairlog_rmax; 
    }
    int pairlog_rmin = (int64) cfg_get_long(cfg,strcpy(key,"pairlog_rmin"),&ostatus);
    if (!ostatus) {
        c->pairlog_rmin = pairlog_rmin; 
    }


    c->log_rmin = log10(c->rmin);
    c->log_rmax = log10(c->rmax);
    c->log_binsize = (c->log_rmax - c->log_rmin)/c->nbin;

_sconfig_read_bail:
    if (status) {
        fprintf(stderr,"Config Error for key '%s': %s\n", key,cfg_status_string(status));
        exit(1);
    }

    cfg=cfg_free(cfg);
    return c;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movq %rdi, %rbx
movq 0x9150(%rip), %rax      # 0xdff8
movq (%rax), %rdi
leaq 0x4764(%rip), %rsi      # 0x9616
movq %rbx, %rdx
xorl %eax, %eax
callq 0x21a0
leaq 0xc(%rsp), %r14
andl $0x0, (%r14)
andl $0x0, 0x14(%rsp)
movq %rbx, %rdi
movq %r14, %rsi
callq 0x5c4a
movl (%r14), %edi
testl %edi, %edi
jne 0x561c
movq %rax, %rbx
pushq $0x1
popq %rdi
movl $0xa0, %esi
callq 0x2170
movq %rax, %r14
movq $0x40, 0x10(%rax)
leaq 0x30(%rsp), %rsi
movb $0x0, 0x2(%rsi)
movw $0x3048, (%rsi)         # imm = 0x3048
leaq 0xc(%rsp), %r15
movq %rbx, %rdi
movq %r15, %rdx
callq 0x629f
movsd %xmm0, (%r14)
movl (%r15), %edi
testl %edi, %edi
jne 0x55ef
movabsq $0x6d5f6167656d6f, %rax # imm = 0x6D5F6167656D6F
leaq 0x30(%rsp), %rsi
movq %rax, (%rsi)
leaq 0xc(%rsp), %r15
movq %rbx, %rdi
movq %r15, %rdx
callq 0x629f
movsd %xmm0, 0x8(%r14)
movl (%r15), %edi
testl %edi, %edi
jne 0x55ef
leaq 0x30(%rsp), %rsi
movb $0x0, 0x4(%rsi)
movl $0x6e69626e, (%rsi)     # imm = 0x6E69626E
leaq 0xc(%rsp), %r12
movq %rbx, %rdi
movq %r12, %rdx
callq 0x6459
movq %rax, 0x40(%r14)
movl (%r12), %edi
testl %edi, %edi
jne 0x55ef
movq %rax, %r15
leaq 0x30(%rsp), %rsi
movb $0x0, 0x4(%rsi)
movl $0x6e696d72, (%rsi)     # imm = 0x6E696D72
leaq 0xc(%rsp), %r12
movq %rbx, %rdi
movq %r12, %rdx
callq 0x629f
movsd %xmm0, 0x18(%rsp)
movsd %xmm0, 0x68(%r14)
movl (%r12), %edi
testl %edi, %edi
jne 0x55ef
leaq 0x30(%rsp), %rsi
movb $0x0, 0x4(%rsi)
movl $0x78616d72, (%rsi)     # imm = 0x78616D72
leaq 0xc(%rsp), %r12
movq %rbx, %rdi
movq %r12, %rdx
callq 0x629f
movsd %xmm0, 0x28(%rsp)
movsd %xmm0, 0x70(%r14)
movl (%r12), %edi
testl %edi, %edi
jne 0x55ef
leaq 0x10(%rsp), %r13
andl $0x0, (%r13)
leaq 0x4909(%rip), %rsi      # 0x9916
movq %rbx, %rdi
movq %r13, %rdx
callq 0x65b2
movl (%r13), %edi
testl %edi, %edi
jne 0x5634
movq %rax, %r12
leaq 0x4917(%rip), %rsi      # 0x9945
movq %rax, %rdi
callq 0x59b1
testl %eax, %eax
movq %r15, 0x20(%rsp)
je 0x506d
leaq 0x4904(%rip), %rsi      # 0x994a
movq %r12, %rdi
callq 0x59b1
testl %eax, %eax
je 0x5071
leaq 0x48f6(%rip), %rsi      # 0x994f
movq %r12, %rdi
callq 0x59b1
testl %eax, %eax
jne 0x56be
pushq $0x3
jmp 0x5073
pushq $0x1
jmp 0x5073
pushq $0x2
popq %rbp
movq %r12, %rdi
callq 0x2030
movl %ebp, 0x1c(%r14)
leaq 0x10(%rsp), %r13
andl $0x0, (%r13)
leaq 0x48ec(%rip), %rsi      # 0x997d
movq %rbx, %rdi
movq %r13, %rdx
callq 0x65b2
movl (%r13), %edi
testl %edi, %edi
jne 0x564c
movq %rax, %r12
leaq 0x48fc(%rip), %rsi      # 0x99ae
movq %rax, %rdi
callq 0x59b1
testl %eax, %eax
je 0x50d9
leaq 0x48f1(%rip), %rsi      # 0x99b6
movq %r12, %rdi
callq 0x59b1
testl %eax, %eax
jne 0x5685
pushq $0x2
jmp 0x50db
pushq $0x1
popq %rbp
movq %r12, %rdi
callq 0x2030
movl %ebp, 0x18(%r14)
leaq 0x10(%rsp), %r13
andl $0x0, (%r13)
leaq 0x48e9(%rip), %rsi      # 0x99e2
movq %rbx, %rdi
movq %r13, %rdx
callq 0x65b2
movl (%r13), %edi
testl %edi, %edi
jne 0x5664
movq %rax, %r12
leaq 0x4901(%rip), %rsi      # 0x9a1b
movq %rax, %rdi
callq 0x59b1
testl %eax, %eax
je 0x5154
leaq 0x45aa(%rip), %rsi      # 0x96d7
movq %r12, %rdi
callq 0x59b1
testl %eax, %eax
je 0x515c
leaq 0x48e1(%rip), %rsi      # 0x9a21
movq %r12, %rdi
callq 0x59b1
testl %eax, %eax
jne 0x56d1
pushq $0x3
jmp 0x5156
pushq $0x1
popq %rbp
xorl %r15d, %r15d
jmp 0x5162
pushq $0x2
popq %rbp
movb $0x1, %r15b
movq %r12, %rdi
callq 0x2030
movl %ebp, 0x20(%r14)
leaq 0x10(%rsp), %r13
andl $0x0, (%r13)
leaq 0x48d1(%rip), %rsi      # 0x9a50
movq %rbx, %rdi
movq %r13, %rdx
callq 0x6459
cmpl $0x0, (%r13)
jne 0x555f
movq %rax, %r12
movl %r12d, 0x2c(%r14)
leaq 0x10(%rsp), %rbp
andl $0x0, (%rbp)
leaq 0x48df(%rip), %rsi      # 0x9a8b
movq %rbx, %rdi
movq %rbp, %rdx
callq 0x65b2
cmpl $0x0, (%rbp)
je 0x51c2
pushq $0x1
popq %rbp
jmp 0x51fe
movq %rax, %r13
leaq 0x4779(%rip), %rsi      # 0x9945
movq %rax, %rdi
callq 0x59b1
testl %eax, %eax
je 0x51f3
leaq 0x48bb(%rip), %rsi      # 0x9a9a
movq %r13, %rdi
callq 0x59b1
testl %eax, %eax
jne 0x56fa
pushq $0x2
jmp 0x51f5
pushq $0x1
popq %rbp
movq %r13, %rdi
callq 0x2030
movl %ebp, 0x24(%r14)
leaq 0x10(%rsp), %rbp
andl $0x0, (%rbp)
leaq 0x4913(%rip), %rsi      # 0x9b25
movq %rbx, %rdi
movq %rbp, %rdx
callq 0x65b2
cmpl $0x0, (%rbp)
jne 0x5583
movq %rax, %r13
leaq 0x48c4(%rip), %rsi      # 0x9af5
movq %rax, %rdi
callq 0x59b1
testl %eax, %eax
je 0x5258
leaq 0x48b5(%rip), %rsi      # 0x9af9
movq %r13, %rdi
callq 0x59b1
testl %eax, %eax
jne 0x5698
pushq $0x2
jmp 0x525a
pushq $0x1
popq %rbp
movq %r13, %rdi
callq 0x2030
movl %ebp, 0x48(%r14)
leaq 0x10(%rsp), %rbp
andl $0x0, (%rbp)
leaq 0x48aa(%rip), %rsi      # 0x9b21
movq %rbx, %rdi
movq %rbp, %rdx
callq 0x65b2
cmpl $0x0, (%rbp)
jne 0x55a7
movq %rax, %r13
leaq 0x48c9(%rip), %rsi      # 0x9b5f
movq %rax, %rdi
callq 0x59b1
testl %eax, %eax
je 0x52d0
leaq 0x48bf(%rip), %rsi      # 0x9b68
movq %r13, %rdi
callq 0x59b1
testl %eax, %eax
je 0x52d4
leaq 0x48b2(%rip), %rsi      # 0x9b6e
movq %r13, %rdi
callq 0x59b1
testl %eax, %eax
jne 0x56e7
pushq $0x3
jmp 0x52d6
pushq $0x1
jmp 0x52d6
pushq $0x2
popq %rbp
movq %r13, %rdi
callq 0x2030
movl %ebp, 0x4c(%r14)
leaq 0x10(%rsp), %rbp
andl $0x0, (%rbp)
leaq 0x48a5(%rip), %rsi      # 0x9b98
movq %rbx, %rdi
movq %rbp, %rdx
callq 0x65b2
cmpl $0x0, (%rbp)
jne 0x55cb
movq %rax, %r13
leaq 0x48c5(%rip), %rsi      # 0x9bd7
movq %rax, %rdi
callq 0x59b1
testl %eax, %eax
je 0x5339
leaq 0x48ba(%rip), %rsi      # 0x9bdf
movq %r13, %rdi
callq 0x59b1
testl %eax, %eax
jne 0x56ab
pushq $0x2
jmp 0x533b
pushq $0x1
popq %rbp
movq %r13, %rdi
callq 0x2030
movl %ebp, 0x28(%r14)
testl %r12d, %r12d
je 0x53a5
testb %r15b, %r15b
movq 0x20(%rsp), %rbp
jne 0x53af
movq 0x8c9a(%rip), %r14      # 0xdff8
movq (%r14), %rcx
leaq 0x42e0(%rip), %rdi      # 0x9648
pushq $0x26
popq %rsi
pushq $0x1
popq %rbx
movq %rbx, %rdx
callq 0x2290
movq (%r14), %rcx
leaq 0x42ef(%rip), %rdi      # 0x966f
pushq $0x28
popq %rsi
movq %rbx, %rdx
callq 0x2290
movq (%r14), %rcx
leaq 0x4303(%rip), %rdi      # 0x9698
pushq $0x2d
popq %rsi
movq %rbx, %rdx
callq 0x2290
jmp 0x5715
testb %r15b, %r15b
movq 0x20(%rsp), %rbp
je 0x53fb
xorl %eax, %eax
callq 0x6fa1
movq %rax, %r12
movq %rax, 0x38(%r14)
leaq 0x30(%rsp), %rsi
movl $0x61766c7a, (%rsi)     # imm = 0x61766C7A
movl $0x736c61, 0x3(%rsi)    # imm = 0x736C61
leaq 0xc(%rsp), %r13
movq %rbx, %rdi
movq %rax, %rdx
movq %r13, %rcx
callq 0x638b
movq %rax, 0x10(%r12)
movl (%r13), %edi
testl %edi, %edi
jne 0x55ef
movq (%r12), %rax
movq %rax, 0x30(%r14)
leaq 0x42cb(%rip), %rsi      # 0x96cd
leaq 0x14(%rsp), %r12
movq %rbx, %rdi
movq %r12, %rdx
callq 0x629f
cmpl $0x0, (%r12)
jne 0x5422
movsd %xmm0, 0x90(%r14)
leaq 0x42b5(%rip), %rsi      # 0x96de
leaq 0x14(%rsp), %r12
movq %rbx, %rdi
movq %r12, %rdx
callq 0x629f
cmpl $0x0, (%r12)
jne 0x5449
movsd %xmm0, 0x98(%r14)
movabsq $0x656469736e5f78, %rax # imm = 0x656469736E5F78
leaq 0x30(%rsp), %rsi
movq %rax, 0x6(%rsi)
movabsq $0x5f7869706c616568, %rax # imm = 0x5F7869706C616568
movq %rax, (%rsi)
leaq 0x14(%rsp), %r12
movq %rbx, %rdi
movq %r12, %rdx
callq 0x6459
cmpl $0x0, (%r12)
jne 0x5486
cltq
movq %rax, 0x10(%r14)
movabsq $0x78616d725f676f, %rax # imm = 0x78616D725F676F
leaq 0x30(%rsp), %rsi
movq %rax, 0x5(%rsi)
movabsq $0x5f676f6c72696170, %r15 # imm = 0x5F676F6C72696170
movq %r15, (%rsi)
leaq 0x14(%rsp), %r12
movq %rbx, %rdi
movq %r12, %rdx
callq 0x6459
cmpl $0x0, (%r12)
jne 0x54c3
cltq
movq %rax, 0x50(%r14)
movabsq $0x6e696d725f676f, %rax # imm = 0x6E696D725F676F
leaq 0x30(%rsp), %rsi
movq %rax, 0x5(%rsi)
movq %r15, (%rsi)
leaq 0x14(%rsp), %r12
movq %rbx, %rdi
movq %r12, %rdx
callq 0x6459
cmpl $0x0, (%r12)
jne 0x54f6
cltq
movq %rax, 0x58(%r14)
movsd 0x18(%rsp), %xmm0
callq 0x2190
movsd %xmm0, 0x18(%rsp)
movsd %xmm0, 0x78(%r14)
movsd 0x28(%rsp), %xmm0
callq 0x2190
movsd %xmm0, 0x80(%r14)
subsd 0x18(%rsp), %xmm0
cvtsi2sd %rbp, %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, 0x88(%r14)
movl 0xc(%rsp), %edi
testl %edi, %edi
jne 0x55ef
movq %rbx, %rdi
callq 0x5a3c
movq %r14, %rax
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x8a92(%rip), %rax      # 0xdff8
movq (%rax), %rcx
leaq 0x44ec(%rip), %rdi      # 0x9a5c
pushq $0x2e
popq %rsi
pushq $0x1
popq %rdx
callq 0x2290
xorl %r12d, %r12d
jmp 0x5198
movq 0x8a6e(%rip), %rax      # 0xdff8
movq (%rax), %rcx
leaq 0x4533(%rip), %rdi      # 0x9ac7
pushq $0x2d
popq %rsi
pushq $0x1
popq %rdx
callq 0x2290
pushq $0x1
popq %rbp
jmp 0x5263
movq 0x8a4a(%rip), %rax      # 0xdff8
movq (%rax), %rcx
leaq 0x4575(%rip), %rdi      # 0x9b2d
pushq $0x31
popq %rsi
pushq $0x1
popq %rdx
callq 0x2290
pushq $0x1
popq %rbp
jmp 0x52df
movq 0x8a26(%rip), %rax      # 0xdff8
movq (%rax), %rcx
leaq 0x45c9(%rip), %rdi      # 0x9ba5
pushq $0x31
popq %rsi
pushq $0x1
popq %rdx
callq 0x2290
pushq $0x1
popq %rbp
jmp 0x5344
movq 0x8a02(%rip), %rax      # 0xdff8
movq (%rax), %rbx
callq 0x5a23
leaq 0x410b(%rip), %rsi      # 0x9710
leaq 0x30(%rsp), %rdx
movq %rbx, %rdi
movq %rax, %rcx
xorl %eax, %eax
callq 0x21a0
jmp 0x5715
movq 0x89d5(%rip), %rax      # 0xdff8
movq (%rax), %rbx
callq 0x5a23
leaq 0x3ffc(%rip), %rsi      # 0x962e
jmp 0x567a
movq 0x89bd(%rip), %rax      # 0xdff8
movq (%rax), %rbx
callq 0x5a23
leaq 0x42d7(%rip), %rsi      # 0x9921
jmp 0x567a
movq 0x89a5(%rip), %rax      # 0xdff8
movq (%rax), %rbx
callq 0x5a23
leaq 0x4327(%rip), %rsi      # 0x9989
jmp 0x567a
movq 0x898d(%rip), %rax      # 0xdff8
movq (%rax), %rbx
callq 0x5a23
leaq 0x4378(%rip), %rsi      # 0x99f2
movq %rbx, %rdi
movq %rax, %rdx
jmp 0x570e
movq 0x896c(%rip), %rax      # 0xdff8
movq (%rax), %rdi
leaq 0x4328(%rip), %rsi      # 0x99be
jmp 0x56e2
movq 0x8959(%rip), %rax      # 0xdff8
movq (%rax), %rdi
leaq 0x4457(%rip), %rsi      # 0x9b00
jmp 0x570b
movq 0x8946(%rip), %rax      # 0xdff8
movq (%rax), %rdi
leaq 0x452b(%rip), %rsi      # 0x9be7
jmp 0x570b
movq 0x8933(%rip), %rax      # 0xdff8
movq (%rax), %rdi
leaq 0x428b(%rip), %rsi      # 0x995a
jmp 0x56e2
movq 0x8920(%rip), %rax      # 0xdff8
movq (%rax), %rdi
leaq 0x4346(%rip), %rsi      # 0x9a28
movq %r12, %rdx
jmp 0x570e
movq 0x890a(%rip), %rax      # 0xdff8
movq (%rax), %rdi
leaq 0x447b(%rip), %rsi      # 0x9b73
jmp 0x570b
movq 0x88f7(%rip), %rax      # 0xdff8
movq (%rax), %rdi
leaq 0x4395(%rip), %rsi      # 0x9aa0
movq %r13, %rdx
xorl %eax, %eax
callq 0x21a0
pushq $0x1
popq %rdi
callq 0x2280