// File: bolongz[P]Systematic-Alias-Sampling/./sas.h
// Function: SystematicAliasSampling::empirical_distribution(std::vector<double, std::allocator<double>>&, std::vector<double, std::allocator<double>>&)
void empirical_distribution(Table &samples, Values &edf){
            std::sort(samples.begin(), samples.end()); 
            size_t count = 0;
            double last = samples[samples.size() - 1];
            for(size_t i = 0; i < values.size(); i++){
                count = 0;
                if(values[i] < samples[0] && fabs(samples[0] - values[i]) > 1e-6){
                    edf[i] = 0.0;
                    continue;
                }else if(values[i] >= last || fabs(values[i] - last)  < 1e-6){
                
                    edf[i] = 1.0;
                    continue;
                }else{
                    for(size_t j = 0 ; j < samples.size(); j++){
                        if( values[i] >= samples[j] || fabs(values[i] - samples[j]) < 1e-6 ){
                            count++;
                        }else{
                            break;
                        }

                    }
                    edf[i] = double(count) / samples.size();
                }
            }
        
        }

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xc0, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x58(%rbp)
movq -0x10(%rbp), %rdi
callq 0x4620
movq %rax, -0x20(%rbp)
movq -0x10(%rbp), %rdi
callq 0x4650
movq %rax, -0x28(%rbp)
movq -0x20(%rbp), %rdi
movq -0x28(%rbp), %rsi
callq 0x7c70
movq $0x0, -0x30(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x50(%rbp)
movq -0x10(%rbp), %rdi
callq 0x5080
movq -0x50(%rbp), %rdi
movq %rax, %rsi
subq $0x1, %rsi
callq 0x3b70
movsd (%rax), %xmm0
movsd %xmm0, -0x38(%rbp)
movq $0x0, -0x40(%rbp)
movq -0x58(%rbp), %rdi
movq -0x40(%rbp), %rax
movq %rax, -0x60(%rbp)
addq $0x18, %rdi
callq 0x5080
movq %rax, %rcx
movq -0x60(%rbp), %rax
cmpq %rcx, %rax
jae 0x49ad
movq -0x58(%rbp), %rdi
movq $0x0, -0x30(%rbp)
addq $0x18, %rdi
movq -0x40(%rbp), %rsi
callq 0x3b70
movsd (%rax), %xmm0
movsd %xmm0, -0x68(%rbp)
movq -0x10(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x3b70
movsd -0x68(%rbp), %xmm1
movsd (%rax), %xmm0
ucomisd %xmm1, %xmm0
jbe 0x47c5
movq -0x10(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x3b70
movq -0x58(%rbp), %rdi
movsd (%rax), %xmm0
movsd %xmm0, -0x70(%rbp)
addq $0x18, %rdi
movq -0x40(%rbp), %rsi
callq 0x3b70
movsd -0x70(%rbp), %xmm0
subsd (%rax), %xmm0
movaps 0x68e6(%rip), %xmm1     # 0xb080
pand %xmm1, %xmm0
movsd 0x68a2(%rip), %xmm1     # 0xb048
ucomisd %xmm1, %xmm0
jbe 0x47c5
movq -0x18(%rbp), %rdi
movq -0x40(%rbp), %rsi
callq 0x3b70
xorps %xmm0, %xmm0
movsd %xmm0, (%rax)
jmp 0x499c
movq -0x58(%rbp), %rdi
addq $0x18, %rdi
movq -0x40(%rbp), %rsi
callq 0x3b70
movsd (%rax), %xmm0
ucomisd -0x38(%rbp), %xmm0
jae 0x4814
movq -0x58(%rbp), %rdi
addq $0x18, %rdi
movq -0x40(%rbp), %rsi
callq 0x3b70
movsd (%rax), %xmm1
subsd -0x38(%rbp), %xmm1
movaps 0x687e(%rip), %xmm0     # 0xb080
pand %xmm0, %xmm1
movsd 0x683a(%rip), %xmm0     # 0xb048
ucomisd %xmm1, %xmm0
jbe 0x4832
movq -0x18(%rbp), %rdi
movq -0x40(%rbp), %rsi
callq 0x3b70
movsd 0x67df(%rip), %xmm0     # 0xb008
movsd %xmm0, (%rax)
jmp 0x499c
movq $0x0, -0x48(%rbp)
movq -0x48(%rbp), %rax
movq %rax, -0x78(%rbp)
movq -0x10(%rbp), %rdi
callq 0x5080
movq %rax, %rcx
movq -0x78(%rbp), %rax
cmpq %rcx, %rax
jae 0x48ff
movq -0x58(%rbp), %rdi
addq $0x18, %rdi
movq -0x40(%rbp), %rsi
callq 0x3b70
movsd (%rax), %xmm0
movsd %xmm0, -0x80(%rbp)
movq -0x10(%rbp), %rdi
movq -0x48(%rbp), %rsi
callq 0x3b70
movsd -0x80(%rbp), %xmm0
ucomisd (%rax), %xmm0
jae 0x48dc
movq -0x58(%rbp), %rdi
addq $0x18, %rdi
movq -0x40(%rbp), %rsi
callq 0x3b70
movsd (%rax), %xmm0
movsd %xmm0, -0x88(%rbp)
movq -0x10(%rbp), %rdi
movq -0x48(%rbp), %rsi
callq 0x3b70
movsd -0x88(%rbp), %xmm1
subsd (%rax), %xmm1
movaps 0x67b6(%rip), %xmm0     # 0xb080
pand %xmm0, %xmm1
movsd 0x6772(%rip), %xmm0     # 0xb048
ucomisd %xmm1, %xmm0
jbe 0x48ea
movq -0x30(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x30(%rbp)
jmp 0x48ec
jmp 0x48ff
jmp 0x48ee
movq -0x48(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x48(%rbp)
jmp 0x483a
movq -0x30(%rbp), %xmm0
movaps 0x6785(%rip), %xmm1     # 0xb090
movaps %xmm1, -0xc0(%rbp)
punpckldq %xmm1, %xmm0    # xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
movapd 0x6782(%rip), %xmm1     # 0xb0a0
movaps %xmm1, -0xb0(%rbp)
subpd %xmm1, %xmm0
movaps %xmm0, %xmm1
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
addsd %xmm1, %xmm0
movsd %xmm0, -0x98(%rbp)
movq -0x10(%rbp), %rdi
callq 0x5080
movaps -0xc0(%rbp), %xmm3
movaps -0xb0(%rbp), %xmm2
movsd -0x98(%rbp), %xmm0
movq %rax, %xmm1
punpckldq %xmm3, %xmm1    # xmm1 = xmm1[0],xmm3[0],xmm1[1],xmm3[1]
subpd %xmm2, %xmm1
movaps %xmm1, %xmm2
unpckhpd %xmm1, %xmm1            # xmm1 = xmm1[1,1]
addsd %xmm2, %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, -0x90(%rbp)
movq -0x18(%rbp), %rdi
movq -0x40(%rbp), %rsi
callq 0x3b70
movsd -0x90(%rbp), %xmm0
movsd %xmm0, (%rax)
jmp 0x499a
jmp 0x499c
movq -0x40(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x40(%rbp)
jmp 0x4700
addq $0xc0, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)