// File: /workspace/github_cpp_makefile_star2_O1/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 0x4129
movq 0x78(%rbx), %rsi
movslq %r15d, %rdx
movq %rbx, %rdi
callq 0x4d4e
testb %al, %al
je 0x4129
cmpl %r15d, 0x8c(%rbx)
jge 0x4104
movl 0x90(%rbx), %eax
imull %r15d, %eax
cltd
idivl 0x94(%rbx)
movl %eax, %r12d
jmp 0x410b
movl 0x88(%rbx), %r12d
movl %r15d, %esi
subl %r12d, %esi
movq %rbx, %rdi
movq %r14, %rdx
movl %ebp, %ecx
callq 0x40b2
addl %r15d, %ebp
subl %r12d, %ebp
movl %r12d, %r15d
jmp 0x40c9
movsd 0x78(%rbx), %xmm0
movapd %xmm0, (%rsp)
leaq 0x63a6(%rip), %rdi      # 0xa4e0
callq 0x4ea6
testl %r15d, %r15d
jle 0x421f
movapd (%rsp), %xmm2
unpcklps 0x1f2c(%rip), %xmm2     # xmm2 = xmm2[0],mem[0],xmm2[1],mem[1]
subpd 0x1f34(%rip), %xmm2     # 0x6090
movapd %xmm2, %xmm1
unpckhpd %xmm2, %xmm1            # xmm1 = xmm1[1],xmm2[1]
addsd %xmm2, %xmm1
xorps %xmm2, %xmm2
cvtsi2sd %r15d, %xmm2
divsd %xmm2, %xmm1
addl %ebp, %r15d
movsd 0x78(%rbx), %xmm3
unpcklps 0x1efd(%rip), %xmm3     # xmm3 = xmm3[0],mem[0],xmm3[1],mem[1]
subpd 0x1f05(%rip), %xmm3     # 0x6090
movapd %xmm3, %xmm2
unpckhpd %xmm3, %xmm2            # xmm2 = xmm2[1],xmm3[1]
addsd %xmm3, %xmm2
movsd 0x76d1(%rip), %xmm3     # 0xb870
movsd 0x76c1(%rip), %xmm4     # 0xb868
subsd %xmm4, %xmm3
mulsd %xmm3, %xmm0
addsd %xmm4, %xmm0
movsd 0x1e55(%rip), %xmm3     # 0x6010
subsd %xmm0, %xmm3
mulsd %xmm1, %xmm3
subsd %xmm3, %xmm2
movq 0x60(%rbx), %rax
movq (%r14), %rcx
movslq %ebp, %rdx
movslq %r15d, %rsi
leaq 0x30(%rbx), %rdi
addq $0x18, %rbx
cvttsd2si %xmm2, %r8d
cvttpd2dq %xmm2, %xmm0
cvtdq2pd %xmm0, %xmm0
movapd %xmm2, %xmm3
subsd %xmm0, %xmm3
movslq %r8d, %r8
movsd (%rax,%r8,8), %xmm0
ucomisd %xmm3, %xmm0
movq %rdi, %r9
cmovbq %rbx, %r9
movq (%r9), %r9
movsd (%r9,%r8,8), %xmm0
movsd %xmm0, (%rcx,%rdx,8)
subsd %xmm1, %xmm2
incq %rdx
cmpq %rsi, %rdx
jl 0x41dc
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq