// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x40, %rsp
movl $0x0, -0x4(%rbp)
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq $0x0, -0x18(%rbp)
cmpl $0x3, -0x8(%rbp)
jge 0xd679
callq 0xd5c0
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x20(%rbp)
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x28(%rbp)
movq -0x20(%rbp), %rdi
movq -0x28(%rbp), %rsi
callq 0xa430
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
movq (%rax), %rax
movq 0x50(%rax), %rax
movq -0x30(%rbp), %rcx
movq (%rcx), %rcx
cmpq 0x58(%rcx), %rax
jle 0xd70a
cmpl $0x4, -0x8(%rbp)
jge 0xd6dd
movq 0x6931(%rip), %rax      # 0x13ff8
movq (%rax), %rdi
leaq 0x2d36(%rip), %rsi      # 0x10407
movb $0x0, %al
callq 0x2170
callq 0xd5c0
movq -0x30(%rbp), %rax
movq (%rax), %rdi
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rsi
callq 0x3390
movq -0x30(%rbp), %rax
movq (%rax), %rax
movq 0x60(%rax), %rdi
leaq 0x2d1b(%rip), %rsi      # 0x1041e
movb $0x0, %al
callq 0x2170
movq -0x30(%rbp), %rax
movq (%rax), %rdi
callq 0x7240
movq %rax, -0x38(%rbp)
movq -0x30(%rbp), %rax
movq (%rax), %rax
movq 0x38(%rax), %rcx
movq -0x38(%rbp), %rax
movq %rcx, 0x60(%rax)
movq 0x68a4(%rip), %rax      # 0x13fd8
movq (%rax), %rdi
movq -0x38(%rbp), %rsi
callq 0x73b0
cmpl $0x0, %eax
je 0xd864
movq -0x18(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x18(%rbp)
movq -0x38(%rbp), %rax
cmpl $0x1, 0x8(%rax)
jne 0xd783
movq -0x30(%rbp), %rax
movq 0x8(%rax), %rdi
movq -0x38(%rbp), %rax
movsd 0x68(%rax), %xmm1
xorps %xmm0, %xmm0
callq 0x8980
movq -0x38(%rbp), %rax
movsd %xmm0, 0x70(%rax)
jmp 0xd7d6
movq -0x38(%rbp), %rax
cmpl $0x3, 0x8(%rax)
jne 0xd7d4
movq -0x30(%rbp), %rax
movq 0x8(%rax), %rdi
movq -0x38(%rbp), %rax
movsd 0x68(%rax), %xmm1
xorps %xmm0, %xmm0
callq 0x8980
movq -0x38(%rbp), %rax
movsd %xmm0, 0x70(%rax)
movq -0x30(%rbp), %rax
movq 0x8(%rax), %rdi
movq -0x38(%rbp), %rax
movsd 0x78(%rax), %xmm1
xorps %xmm0, %xmm0
callq 0x8980
movq -0x38(%rbp), %rax
movsd %xmm0, 0x80(%rax)
jmp 0xd7d6
cmpq $0x1, -0x18(%rbp)
jne 0xd7fe
movq 0x6814(%rip), %rax      # 0x13ff8
movq (%rax), %rdi
leaq 0x2c52(%rip), %rsi      # 0x10440
movb $0x0, %al
callq 0x2170
movq -0x38(%rbp), %rdi
callq 0x76a0
cmpq $0x2, -0x18(%rbp)
jne 0xd826
movq 0x67ec(%rip), %rax      # 0x13ff8
movq (%rax), %rdi
leaq 0x2c39(%rip), %rsi      # 0x1044f
movb $0x0, %al
callq 0x2170
movq -0x38(%rbp), %rdi
callq 0x76a0
movq -0x18(%rbp), %rax
movl $0x2710, %ecx           # imm = 0x2710
cqto
idivq %rcx
cmpq $0x0, %rdx
jne 0xd852
movq 0x67b7(%rip), %rax      # 0x13ff8
movq (%rax), %rdi
leaq 0x2372(%rip), %rsi      # 0xfbbd
movb $0x0, %al
callq 0x2170
movq -0x30(%rbp), %rdi
movq -0x38(%rbp), %rsi
callq 0xa7e0
jmp 0xd72d
movq 0x678d(%rip), %rax      # 0x13ff8
movq (%rax), %rdi
leaq 0x2bea(%rip), %rsi      # 0x1045f
movb $0x0, %al
callq 0x2170
movq -0x38(%rbp), %rdi
callq 0x76a0
movq 0x676c(%rip), %rax      # 0x13ff8
movq (%rax), %rdi
movq -0x18(%rbp), %rdx
leaq 0x2bd4(%rip), %rsi      # 0x1046e
movb $0x0, %al
callq 0x2170
movq -0x30(%rbp), %rdi
callq 0xb360
movq 0x6747(%rip), %rax      # 0x13ff8
movq (%rax), %rdi
leaq 0x2bcb(%rip), %rsi      # 0x10486
movb $0x0, %al
callq 0x2170
movq -0x30(%rbp), %rax
movq 0x20(%rax), %rdi
movq 0x66ff(%rip), %rax      # 0x13fd0
movq (%rax), %rsi
callq 0xb7d0
movq -0x30(%rbp), %rax
movq (%rax), %rax
movq 0x50(%rax), %rax
movq -0x30(%rbp), %rcx
movq (%rcx), %rcx
cmpq 0x58(%rcx), %rax
jle 0xd901
movq -0x30(%rbp), %rax
movq (%rax), %rax
movq 0x60(%rax), %rdi
callq 0x20c0
movq -0x38(%rbp), %rdi
callq 0x7330
movq %rax, -0x38(%rbp)
movq -0x30(%rbp), %rdi
callq 0xb3d0
movq %rax, -0x30(%rbp)
movq 0x66d6(%rip), %rax      # 0x13ff8
movq (%rax), %rdi
leaq 0x2b75(%rip), %rsi      # 0x104a1
movb $0x0, %al
callq 0x2170
xorl %eax, %eax
addq $0x40, %rsp
popq %rbp
retq
nopl (%rax,%rax)