// File: /workspace/github_c_makefile_star2_O3/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 $0x28, %rsp
movl %ecx, %ebp
movl %edx, %r15d
movl %esi, %r12d
movq %rdi, %r14
movl $0x1, %edi
movl $0x80, %esi
callq 0x2170
testq %rax, %rax
je 0x59ff
movq %rax, %rbx
movl %r12d, (%rax)
movl %r15d, 0x8(%rax)
movl %ebp, 0x4(%rax)
movq %r14, 0x28(%rax)
movl $0x8, %esi
movq %r14, %rdi
callq 0x2170
movq %rax, 0x20(%rsp)
movq %rax, 0x30(%rbx)
movl $0x8, %esi
movq %r14, %rdi
callq 0x2170
movq %rax, 0x18(%rsp)
movq %rax, 0x38(%rbx)
movl $0x8, %esi
movq %r14, %rdi
callq 0x2170
movq %rax, 0x10(%rsp)
movq %rax, 0x40(%rbx)
movl $0x8, %esi
movq %r14, %rdi
callq 0x2170
movq %rax, 0x8(%rsp)
movq %rax, 0x48(%rbx)
movl $0x8, %esi
movq %r14, %rdi
callq 0x2170
movq %rax, %r12
movq %rax, 0x50(%rbx)
movl $0x8, %esi
movq %r14, %rdi
callq 0x2170
movq %rax, %r13
movq %rax, 0x58(%rbx)
movl $0x8, %esi
movq %r14, %rdi
callq 0x2170
movq %rax, %rbp
movq %rax, 0x60(%rbx)
movl $0x8, %esi
movq %r14, %rdi
callq 0x2170
movq %rax, %r15
movq %rax, 0x68(%rbx)
movl $0x8, %esi
movq %r14, %rdi
callq 0x2170
movq %rax, (%rsp)
movq %rax, 0x70(%rbx)
movl $0x8, %esi
movq %r14, %rdi
callq 0x2170
movq %rax, 0x78(%rbx)
movq %rbp, %xmm0
movq %r15, %xmm1
punpcklqdq %xmm1, %xmm0    # xmm0 = xmm0[0],xmm1[0]
movq 0x18(%rsp), %xmm1
movq 0x10(%rsp), %xmm2
punpcklqdq %xmm2, %xmm1    # xmm1 = xmm1[0],xmm2[0]
movq %r12, %xmm2
movq %r13, %xmm3
punpcklqdq %xmm3, %xmm2    # xmm2 = xmm2[0],xmm3[0]
movq 0x20(%rsp), %xmm3
movq 0x8(%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
testl $0xaaaa, %ecx           # imm = 0xAAAA
jne 0x59fa
cmpq $0x0, (%rsp)
je 0x59fa
testq %rax, %rax
je 0x59fa
movq %rbx, %rax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x2da3
callq 0x2dc8