// File: /workspace/github_c_makefile_star2_O1/esheldon[P]xshear/src/xshear.c
// Function: main
int main(int argc, char** argv) {
    int64 nsource=0;

    if (argc < 3) {
        usage_and_exit();
    }

    const char* config_url=argv[1];
    const char* lens_url=argv[2];
    Shear* shear=shear_init(config_url, lens_url);
    
    if(shear->config->pairlog_rmax>shear->config->pairlog_rmin) { // print pair ids to file
      if (argc < 4) {
	wlog("no pair logfile given\n");
        usage_and_exit();
      }
      sconfig_open_pair_url(shear->config,argv[3]);
      fprintf(shear->config->pair_fd, "# lens_id source_id r_bin weight\n");
    }

    Source* src=source_new(shear->config);
    src->zlens = (const dvector*) shear->config->zl;

    while (source_read(stdin, src)) {
        nsource++;

        if (src->scstyle == SIGMACRIT_STYLE_POINT) {
            src->dc = Dc(shear->cosmo, 0.0, src->z);
        } else if (src->scstyle == SIGMACRIT_STYLE_SAMPLE) {
            src->dc  = Dc(shear->cosmo, 0.0, src->z);
            src->dcs = Dc(shear->cosmo, 0.0, src->zs);
        }

        if (nsource == 1) {
            wlog("first source:\n");
            source_print(src);
        }
        if (nsource == 2) {
            wlog("second source:\n");
            source_print(src);
        }
        if ((nsource % 10000) == 0) {
            wlog(".");
        }


        shear_process_source(shear, src);
    }
    wlog("\nlast source:\n");
    source_print(src);

    wlog("processed %lld sources\n", nsource);

    // print some summary info
    shear_print_sum(shear);

    wlog("Writing results to stdout\n");
    lensums_write(shear->lensums, stdout);

    if(shear->config->pairlog_rmax>shear->config->pairlog_rmin) {
     fclose(shear->config->pair_fd);
    }
    
    src=source_free(src);
    shear=shear_free(shear);
    wlog("Done\n");

    return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
cmpl $0x2, %edi
jle 0x9469
movq %rsi, %r14
movl %edi, %ebx
movq 0x8(%rsi), %rdi
movq 0x10(%rsi), %rsi
callq 0x79b8
movq %rax, %rbp
movq (%rax), %rax
movq 0x50(%rax), %rcx
cmpq 0x58(%rax), %rcx
jle 0x9258
cmpl $0x3, %ebx
je 0x946e
movq %rbp, %rdi
movq %r14, %rsi
callq 0x40b2
movq (%rbp), %rdi
callq 0x6250
movq %rax, %r14
movq (%rbp), %rax
movq 0x38(%rax), %rax
movq %rax, 0x60(%r14)
movq 0x6d61(%rip), %rax      # 0xffd8
movq (%rax), %rdi
movq %r14, %rsi
callq 0x62fa
testl %eax, %eax
jne 0x934e
xorl %r15d, %r15d
movq 0x6d64(%rip), %rbx      # 0xfff8
movq (%rbx), %rcx
leaq 0x21f7(%rip), %rdi      # 0xb495
movl $0xe, %esi
movl $0x1, %edx
callq 0x22a0
movq %r14, %rdi
callq 0x307e
movq (%rbx), %rdi
leaq 0x21e5(%rip), %rsi      # 0xb4a4
movq %r15, %rdx
xorl %eax, %eax
callq 0x21b0
movq %rbp, %rdi
callq 0x3852
movq (%rbx), %rcx
leaq 0x21e1(%rip), %rdi      # 0xb4bc
movl $0x1a, %esi
movl $0x1, %edx
callq 0x22a0
movq 0x20(%rbp), %rdi
movq 0x6cdb(%rip), %rax      # 0xffd0
movq (%rax), %rsi
callq 0x80fc
movq (%rbp), %rax
movq 0x50(%rax), %rcx
cmpq 0x58(%rax), %rcx
jle 0x9314
movq 0x60(%rax), %rdi
callq 0x20e0
movq %r14, %rdi
callq 0x62bc
movq %rbp, %rdi
callq 0x80a7
movq (%rbx), %rcx
leaq 0x21a9(%rip), %rdi      # 0xb4d7
movl $0x5, %esi
movl $0x1, %edx
callq 0x22a0
xorl %eax, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rbp, %rax
addq $0x8, %rax
movq %rax, (%rsp)
leaq 0x78(%r14), %rax
movq %rax, 0x10(%rsp)
leaq 0x80(%r14), %rax
movq %rax, 0x8(%rsp)
leaq 0x68(%r14), %rax
movq %rax, 0x20(%rsp)
movq %r14, %rax
addq $0x70, %rax
movq %rax, 0x18(%rsp)
movl $0x1, %r12d
xorl %r15d, %r15d
movq %r12, %rax
movabsq $0x346dc5d63886594b, %rcx # imm = 0x346DC5D63886594B
mulq %rcx
movq %rdx, %r13
movl 0x8(%r14), %ecx
movq 0x20(%rsp), %rax
movq 0x18(%rsp), %rbx
cmpl $0x1, %ecx
je 0x93dc
cmpl $0x3, %ecx
jne 0x93f3
movq (%rsp), %rax
movq (%rax), %rdi
movsd 0x68(%r14), %xmm1
xorps %xmm0, %xmm0
callq 0x6ad1
movsd %xmm0, 0x70(%r14)
movq 0x10(%rsp), %rax
movq 0x8(%rsp), %rbx
movq (%rsp), %rcx
movq (%rcx), %rdi
movsd (%rax), %xmm1
xorps %xmm0, %xmm0
callq 0x6ad1
movsd %xmm0, (%rbx)
testq %r15, %r15
je 0x9455
cmpq $0x1, %r15
je 0x945f
shrq $0xb, %r13
imulq $0x2710, %r13, %rax     # imm = 0x2710
decq %rax
cmpq %r15, %rax
jne 0x9425
movq 0x6be0(%rip), %rax      # 0xfff8
movq (%rax), %rsi
movl $0x2e, %edi
callq 0x2160
movq %rbp, %rdi
movq %r14, %rsi
callq 0x79f6
movq 0x6ba1(%rip), %rax      # 0xffd8
movq (%rax), %rdi
movq %r14, %rsi
callq 0x62fa
incq %r12
incq %r15
testl %eax, %eax
jne 0x938c
jmp 0x928d
movq %r14, %rdi
callq 0x4060
jmp 0x93f8
movq %r14, %rdi
callq 0x4089
jmp 0x93fe
callq 0x917c
callq 0x40dc
nop