// File: /workspace/github_cpp_makefile_star2_O2/bolongz[P]Systematic-Alias-Sampling/./sas.h
// Function: SystematicAliasSampling::systematicaliassampling(int, std::vector<double, std::allocator<double>>&, int)
void systematicaliassampling(int samplecount, Table &samples, int from = 0){
            int splitindex;  
            if(samplecount > minbatchsize && isdivisible(bincount, samplecount)){
                if(samplecount <= minrecursize){
                    splitindex = minbatchsize;
                }else{
                    splitindex = samplecount * batchsplitnumerator / batchsplitdenominator;
                }
                systematicaliassampling(samplecount - splitindex, samples, from);
                systematicaliassampling(splitindex, samples, from + samplecount - splitindex);
            }else{
                 
                double steps = double(bincount) / samplecount;
                double r = steps * (1.0 - __random(gen));
                //double x =  r;
                double x =  bincount - r;
                int i = from;

                int to = from + samplecount;
                while(i < to){
                    int ri = int(x);
                    double rf  = x  -ri;
                    samples[i] = aliassample(ri, rf);
                    //x += steps;
                    x -= steps;
                    i++;
                }
            }
        
        }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x10, %rsp
movl %ecx, %ebp
movq %rdx, %r14
movl %esi, %r15d
movq %rdi, %rbx
cmpl %r15d, 0x88(%rbx)
jge 0x3949
movq 0x78(%rbx), %rsi
movslq %r15d, %rdx
movq %rbx, %rdi
callq 0x467a
testb %al, %al
je 0x3949
cmpl %r15d, 0x8c(%rbx)
jge 0x3924
movl 0x90(%rbx), %eax
imull %r15d, %eax
cltd
idivl 0x94(%rbx)
movl %eax, %r12d
jmp 0x392b
movl 0x88(%rbx), %r12d
movl %r15d, %esi
subl %r12d, %esi
movq %rbx, %rdi
movq %r14, %rdx
movl %ebp, %ecx
callq 0x38d2
addl %r15d, %ebp
subl %r12d, %ebp
movl %r12d, %r15d
jmp 0x38e9
movsd 0x78(%rbx), %xmm0
unpcklps 0x273b(%rip), %xmm0     # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0x2743(%rip), %xmm0     # 0x60a0
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
cvtsi2sd %r15d, %xmm0
divsd %xmm0, %xmm1
movapd %xmm1, (%rsp)
leaq 0x7ed2(%rip), %rdi      # 0xb850
leaq 0x6b3b(%rip), %rsi      # 0xa4c0
callq 0x35f0
movapd (%rsp), %xmm3
movsd 0x2679(%rip), %xmm1     # 0x6010
subsd %xmm0, %xmm1
mulsd %xmm3, %xmm1
movsd 0x78(%rbx), %xmm2
unpcklps 0x26e5(%rip), %xmm2     # xmm2 = xmm2[0],mem[0],xmm2[1],mem[1]
subpd 0x26ed(%rip), %xmm2     # 0x60a0
movapd %xmm2, %xmm0
unpckhpd %xmm2, %xmm0            # xmm0 = xmm0[1],xmm2[1]
addsd %xmm2, %xmm0
subsd %xmm1, %xmm0
addl %ebp, %r15d
movq 0x60(%rbx), %rax
movq (%r14), %rcx
movslq %ebp, %rdx
movslq %r15d, %rsi
leaq 0x30(%rbx), %rdi
addq $0x18, %rbx
cmpq %rsi, %rdx
jge 0x3a20
cvttsd2si %xmm0, %r8d
cvttpd2dq %xmm0, %xmm1
cvtdq2pd %xmm1, %xmm1
movapd %xmm0, %xmm2
subsd %xmm1, %xmm2
movslq %r8d, %r8
movsd (%rax,%r8,8), %xmm1
ucomisd %xmm2, %xmm1
movq %rdi, %r9
cmovbq %rbx, %r9
movq (%r9), %r9
movsd (%r9,%r8,8), %xmm1
movsd %xmm1, (%rcx,%rdx,8)
subsd %xmm3, %xmm0
incq %rdx
jmp 0x39db
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
nop