// File: /workspace/github_c_makefile_star2_O2/esheldon[P]xshear/src/lensum.c
// Function: lensum_new
Lensum* lensum_new(size_t nbin, int shear_style, int scstyle, int shear_units) {
    Lensum* lensum=calloc(1,sizeof(Lensum));
    if (lensum == NULL) {
        wlog("failed to allocate lensum\n");
        exit(EXIT_FAILURE);
    }

    lensum->shear_style=shear_style;
    lensum->scstyle=scstyle;
    lensum->shear_units=shear_units;

    lensum->nbin = nbin;

    lensum->npair = calloc(nbin, sizeof(int64));
    lensum->rsum  = calloc(nbin, sizeof(double));
    lensum->wsum  = calloc(nbin, sizeof(double));
    lensum->ssum  = calloc(nbin, sizeof(double));
    lensum->dsum  = calloc(nbin, sizeof(double));
    lensum->osum  = calloc(nbin, sizeof(double));

    lensum->dsensum_w  = calloc(nbin, sizeof(double));
    lensum->osensum_w  = calloc(nbin, sizeof(double));
    lensum->dsensum_s  = calloc(nbin, sizeof(double));
    lensum->osensum_s  = calloc(nbin, sizeof(double));


    if (lensum->npair==NULL
            || lensum->wsum==NULL
            || lensum->ssum==NULL
            || lensum->dsum==NULL
            || lensum->osum==NULL
            || lensum->rsum==NULL
            || lensum->dsensum_w==NULL
            || lensum->osensum_w==NULL
            || lensum->dsensum_s==NULL
            || lensum->osensum_s==NULL
            ) {

        wlog("failed to allocate lensum\n");
        exit(EXIT_FAILURE);
    }

    return lensum;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movl %ecx, %ebp
movl %edx, %r15d
movl %esi, %r12d
movq %rdi, %r14
pushq $0x1
popq %rdi
movl $0x80, %esi
callq 0x2170
testq %rax, %rax
je 0x462b
movq %rax, %rbx
movl %r12d, (%rax)
movl %r15d, 0x8(%rax)
movl %ebp, 0x4(%rax)
movq %r14, 0x28(%rax)
pushq $0x8
popq %r12
movq %r14, %rdi
movq %r12, %rsi
callq 0x2170
movq %rax, 0x30(%rsp)
movq %rax, 0x30(%rbx)
movq %r14, %rdi
movq %r12, %rsi
callq 0x2170
movq %rax, 0x28(%rsp)
movq %rax, 0x38(%rbx)
movq %r14, %rdi
movq %r12, %rsi
callq 0x2170
movq %rax, 0x18(%rsp)
movq %rax, 0x40(%rbx)
movq %r14, %rdi
movq %r12, %rsi
callq 0x2170
movq %rax, 0x20(%rsp)
movq %rax, 0x48(%rbx)
movq %r14, %rdi
movq %r12, %rsi
callq 0x2170
movq %rax, 0x10(%rsp)
movq %rax, 0x50(%rbx)
movq %r14, %rdi
movq %r12, %rsi
callq 0x2170
movq %rax, %r15
movq %rax, 0x58(%rbx)
movq %r14, %rdi
movq %r12, %rsi
callq 0x2170
movq %rax, %r13
movq %rax, 0x60(%rbx)
movq %r14, %rdi
movq %r12, %rsi
callq 0x2170
movq %rax, %rbp
movq %rax, 0x68(%rbx)
movq %r14, %rdi
movq %r12, %rsi
callq 0x2170
movq %rax, 0x8(%rsp)
movq %rax, 0x70(%rbx)
movq %r14, %rdi
movq %r12, %rsi
callq 0x2170
movq %rax, 0x78(%rbx)
movq %r13, %xmm0
movq %rbp, %xmm1
punpcklqdq %xmm1, %xmm0    # xmm0 = xmm0[0],xmm1[0]
movq 0x28(%rsp), %xmm1
movq 0x18(%rsp), %xmm2
punpcklqdq %xmm2, %xmm1    # xmm1 = xmm1[0],xmm2[0]
movq 0x10(%rsp), %xmm2
movq %r15, %xmm3
punpcklqdq %xmm3, %xmm2    # xmm2 = xmm2[0],xmm3[0]
movq 0x30(%rsp), %xmm3
movq 0x20(%rsp), %xmm4
punpcklqdq %xmm4, %xmm3    # xmm3 = xmm3[0],xmm4[0]
pxor %xmm4, %xmm4
pcmpeqd %xmm4, %xmm3
pshufd $0xb1, %xmm3, %xmm5     # xmm5 = xmm3[1,0,3,2]
pand %xmm3, %xmm5
pcmpeqd %xmm4, %xmm2
pshufd $0xb1, %xmm2, %xmm3     # xmm3 = xmm2[1,0,3,2]
pand %xmm2, %xmm3
packssdw %xmm3, %xmm5
pcmpeqd %xmm4, %xmm1
pshufd $0xb1, %xmm1, %xmm2     # xmm2 = xmm1[1,0,3,2]
pand %xmm1, %xmm2
pcmpeqd %xmm4, %xmm0
pshufd $0xb1, %xmm0, %xmm1     # xmm1 = xmm0[1,0,3,2]
pand %xmm0, %xmm1
packssdw %xmm1, %xmm2
packssdw %xmm2, %xmm5
pmovmskb %xmm5, %ecx
testw $0xaaaa, %cx            # imm = 0xAAAA
jne 0x462b
cmpq $0x0, 0x8(%rsp)
je 0x462b
testq %rax, %rax
je 0x462b
movq %rbx, %rax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x99c6(%rip), %rax      # 0xdff8
movq (%rax), %rcx
leaq 0x4e56(%rip), %rdi      # 0x9492
pushq $0x1a
popq %rsi
pushq $0x1
popq %rdx
callq 0x2290
pushq $0x1
popq %rdi
callq 0x2280