// File: /workspace/github_c_makefile_star2_O0/c-zhou[P]yahs/enzyme.c
// Function: calc_re_cuts_density
double **calc_re_cuts_density(re_cuts_t *re_cuts, uint32_t resolution)
{
    if (!re_cuts)
        return 0;

    uint32_t i, j, b;
    double **dens, *ds;
    re_t re;
    dens = (double **) malloc(re_cuts->n * sizeof(double *));
    for (i = 0; i < re_cuts->n; ++i) {
        re = re_cuts->re[i];
        b = div_ceil(re.l, resolution);
        ds = (double *) calloc(b, sizeof(double));
        for (j = 0; j < re.n; ++j)
            ds[re.sites[j] / resolution] += 1.;
        for (j = 0; j < b - 1; ++j)
            ds[j] /= (double) resolution * re_cuts->density;
        ds[b - 1] /= ((double) re.l - (double) (b - 1) * resolution) * re_cuts->density;
        
        for (j = 0; j < b; ++j)
            if (ds[j] < MIN_RE_DENS || ds[j] > MAX_RE_DENS)
                ds[j] = .0;
        
        dens[i] = ds;
#ifdef DEBUG_ENZ
        fprintf(stderr, "[DEBUG_ENZ::%s] DENS [%u/%u] (%u):", __func__, i, re_cuts->n, b);
        for (j = 0; j < b; ++j)
            fprintf(stderr, " %.6f", ds[j]);
        fprintf(stderr, "\n");
#endif
    }
    return dens;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
cmpq $0x0, -0x10(%rbp)
jne 0x29d63
movq $0x0, -0x8(%rbp)
jmp 0x29f3e
movq -0x10(%rbp), %rax
movl (%rax), %eax
movl %eax, %edi
shlq $0x3, %rdi
callq 0x2340
movq %rax, -0x28(%rbp)
movl $0x0, -0x18(%rbp)
movl -0x18(%rbp), %eax
movq -0x10(%rbp), %rcx
cmpl (%rcx), %eax
jae 0x29f36
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movl -0x18(%rbp), %ecx
shlq $0x4, %rcx
addq %rcx, %rax
movq (%rax), %rcx
movq %rcx, -0x40(%rbp)
movq 0x8(%rax), %rax
movq %rax, -0x38(%rbp)
movl -0x40(%rbp), %eax
movl %eax, %edi
movl -0x14(%rbp), %esi
callq 0x2aa0
movl %eax, -0x20(%rbp)
movl -0x20(%rbp), %eax
movl %eax, %edi
movl $0x8, %esi
callq 0x2290
movq %rax, -0x30(%rbp)
movl $0x0, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
cmpl -0x3c(%rbp), %eax
jae 0x29e1d
movq -0x30(%rbp), %rax
movq %rax, -0x48(%rbp)
movq -0x38(%rbp), %rax
movl -0x1c(%rbp), %ecx
movl (%rax,%rcx,4), %eax
xorl %edx, %edx
divl -0x14(%rbp)
movl %eax, %ecx
movq -0x48(%rbp), %rax
movl %ecx, %ecx
movsd 0x77f0(%rip), %xmm0     # 0x315f8
addsd (%rax,%rcx,8), %xmm0
movsd %xmm0, (%rax,%rcx,8)
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x29dd9
movl $0x0, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
movl -0x20(%rbp), %ecx
subl $0x1, %ecx
cmpl %ecx, %eax
jae 0x29e62
movl -0x14(%rbp), %eax
cvtsi2sd %rax, %xmm1
movq -0x10(%rbp), %rax
mulsd 0x8(%rax), %xmm1
movq -0x30(%rbp), %rax
movl -0x1c(%rbp), %ecx
movsd (%rax,%rcx,8), %xmm0
divsd %xmm1, %xmm0
movsd %xmm0, (%rax,%rcx,8)
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x29e24
movl -0x40(%rbp), %eax
cvtsi2sd %rax, %xmm0
movl -0x20(%rbp), %eax
decl %eax
cvtsi2sd %rax, %xmm1
movl -0x14(%rbp), %eax
cvtsi2sd %rax, %xmm2
movq %xmm1, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm1
mulsd %xmm2, %xmm1
addsd %xmm0, %xmm1
movq -0x10(%rbp), %rax
mulsd 0x8(%rax), %xmm1
movq -0x30(%rbp), %rax
movl -0x20(%rbp), %ecx
subl $0x1, %ecx
movl %ecx, %ecx
movsd (%rax,%rcx,8), %xmm0
divsd %xmm1, %xmm0
movsd %xmm0, (%rax,%rcx,8)
movl $0x0, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
cmpl -0x20(%rbp), %eax
jae 0x29f19
movq -0x30(%rbp), %rax
movl -0x1c(%rbp), %ecx
movsd (%rax,%rcx,8), %xmm1
movsd 0xfb37(%rip), %xmm0     # 0x39a18
ucomisd %xmm1, %xmm0
ja 0x29efd
movq -0x30(%rbp), %rax
movl -0x1c(%rbp), %ecx
movsd (%rax,%rcx,8), %xmm0
ucomisd 0xfb25(%rip), %xmm0     # 0x39a20
jbe 0x29f0c
movq -0x30(%rbp), %rax
movl -0x1c(%rbp), %ecx
xorps %xmm0, %xmm0
movsd %xmm0, (%rax,%rcx,8)
jmp 0x29f0e
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x29ec5
movq -0x30(%rbp), %rdx
movq -0x28(%rbp), %rax
movl -0x18(%rbp), %ecx
movq %rdx, (%rax,%rcx,8)
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
jmp 0x29d7f
movq -0x28(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x50, %rsp
popq %rbp
retq
nopl (%rax,%rax)