// File: /workspace/github_cpp_makefile_star2_O3/bolongz[P]Systematic-Alias-Sampling/./sas.h
// Function: SystematicAliasSampling::aliastable()
void aliastable(){
            
            if( !normalize() ) std::cout << "Wrong normalization" <<std::endl;;
            Table F(bincount); //define F
            for(size_t i = 0; i < bincount ; i++){
                F[i] = pmf[i] * double(bincount);
            }
            aliasvalue.resize(bincount);
            aliasindices.resize(bincount);
            aliasprobabilities.resize(bincount);
            std::stack<double> G, S;

            /* Denote by G the set of i, if F[i] >= 1, otherwise S*/
            
            for(size_t i = 0; i < bincount ; i++) {
                if(F[i] >= 1.0 || fabs(F[i] - 1.0) < 1e-6) G.push(i);
                else S.push(i);
                
                aliasindices[i] = i;
            }
             
            /* main loop until S is empty */
            while(!G.empty() && !S.empty()){
            
               int j = S.top();
               S.pop(); // remove the top element of stack S
               int k = G.top(); //get the top element in the stack G
               aliasindices[j] = k;
               aliasprobabilities[j] = 1.0 - F[j];
               
               F[k] = (F[k] + F[j]) -1.0;
               if(F[k] < 1.0){
                    G.pop();
                    S.push(k);
               }

            }
            for(size_t i = 0; i < bincount ; i++) {
                aliasvalue[i] = values[aliasindices[i]];
            }
         //   aliasprobabilities = F;
        }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xd8, %rsp
movq %rdi, %rbx
callq 0x43fa
testb %al, %al
jne 0x3883
movq 0x5790(%rip), %r14      # 0x8fd8
leaq 0x290d(%rip), %rsi      # 0x615c
movl $0x13, %edx
movq %r14, %rdi
callq 0x2180
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x2150
movsbl %al, %esi
movq %r14, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x20b0
movq 0x78(%rbx), %rsi
leaq 0xc0(%rsp), %rdi
leaq 0x70(%rsp), %rdx
callq 0x3d22
movq 0x78(%rbx), %rsi
testq %rsi, %rsi
je 0x38e6
movq %rsi, %xmm1
punpckldq 0x27d1(%rip), %xmm1 # xmm1 = xmm1[0],mem[0],xmm1[1],mem[1]
movq (%rbx), %rax
subpd 0x27d6(%rip), %xmm1     # 0x6090
movapd %xmm1, %xmm0
unpckhpd %xmm1, %xmm0            # xmm0 = xmm0[1],xmm1[1]
addsd %xmm1, %xmm0
movq 0xc0(%rsp), %rcx
xorl %edx, %edx
movsd (%rax,%rdx,8), %xmm1
mulsd %xmm0, %xmm1
movsd %xmm1, (%rcx,%rdx,8)
incq %rdx
cmpq %rdx, %rsi
jne 0x38d0
leaq 0x30(%rbx), %rdi
callq 0x4476
leaq 0x48(%rbx), %r14
movq 0x78(%rbx), %rsi
movq %r14, %rdi
callq 0x4476
leaq 0x60(%rbx), %r15
movq 0x78(%rbx), %rsi
movq %r15, %rdi
callq 0x4476
xorpd %xmm0, %xmm0
leaq 0x70(%rsp), %rdi
movapd %xmm0, 0x40(%rdi)
movapd %xmm0, 0x30(%rdi)
movapd %xmm0, 0x20(%rdi)
movapd %xmm0, 0x10(%rdi)
movapd %xmm0, (%rdi)
xorl %esi, %esi
callq 0x45f0
leaq 0x20(%rsp), %rdi
xorpd %xmm0, %xmm0
movapd %xmm0, 0x40(%rdi)
movapd %xmm0, 0x30(%rdi)
movapd %xmm0, 0x20(%rdi)
movapd %xmm0, 0x10(%rdi)
movapd %xmm0, (%rdi)
xorl %esi, %esi
callq 0x45f0
cmpq $0x0, 0x78(%rbx)
je 0x3a8b
xorl %r12d, %r12d
leaq 0x8(%rsp), %r13
leaq 0x70(%rsp), %rbp
movq 0xc0(%rsp), %rax
movsd (%rax,%r12,8), %xmm1
ucomisd 0x2683(%rip), %xmm1     # 0x6010
movq %r12, %xmm0
jae 0x39b2
addsd 0x26a4(%rip), %xmm1     # 0x6040
andpd 0x270c(%rip), %xmm1     # 0x60b0
movsd 0x269c(%rip), %xmm2     # 0x6048
ucomisd %xmm1, %xmm2
jbe 0x3a12
punpckldq 0x26c6(%rip), %xmm0 # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0x26ce(%rip), %xmm0     # 0x6090
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
movsd %xmm1, 0x8(%rsp)
movq 0xa0(%rsp), %rax
movq 0xb0(%rsp), %rcx
addq $-0x8, %rcx
cmpq %rcx, %rax
movapd %xmm1, 0x10(%rsp)
je 0x3a05
movsd %xmm1, (%rax)
addq $0x8, %rax
movq %rax, 0xa0(%rsp)
jmp 0x3a69
movq %rbp, %rdi
movq %r13, %rsi
callq 0x4758
jmp 0x3a69
punpckldq 0x2666(%rip), %xmm0 # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0x266e(%rip), %xmm0     # 0x6090
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
movsd %xmm1, 0x8(%rsp)
movq 0x50(%rsp), %rax
movq 0x60(%rsp), %rcx
addq $-0x8, %rcx
cmpq %rcx, %rax
movapd %xmm1, 0x10(%rsp)
je 0x3a5c
movsd %xmm1, (%rax)
addq $0x8, %rax
movq %rax, 0x50(%rsp)
jmp 0x3a69
leaq 0x20(%rsp), %rdi
movq %r13, %rsi
callq 0x4758
movq 0x48(%rbx), %rax
movapd 0x10(%rsp), %xmm0
movsd %xmm0, (%rax,%r12,8)
incq %r12
movq 0x78(%rbx), %rcx
cmpq %rcx, %r12
jb 0x3977
jmp 0x3a8d
xorl %ecx, %ecx
movq 0xa0(%rsp), %rax
cmpq 0x80(%rsp), %rax
je 0x3c5a
movl $0x1f8, %ebp            # imm = 0x1F8
movl $0x200, %r12d           # imm = 0x200
leaq 0x8(%rsp), %r13
movq 0x50(%rsp), %rcx
cmpq 0x30(%rsp), %rcx
je 0x3c56
movq 0x58(%rsp), %rdi
cmpq %rdi, %rcx
je 0x3ad8
movsd -0x8(%rcx), %xmm0
addq $-0x8, %rcx
jmp 0x3b28
movq 0x68(%rsp), %rax
movq -0x8(%rax), %rax
movsd 0x1f8(%rax), %xmm0
movsd %xmm0, 0x10(%rsp)
callq 0x2140
movsd 0x10(%rsp), %xmm0
movq 0x68(%rsp), %rax
leaq -0x8(%rax), %rcx
movq %rcx, 0x68(%rsp)
movq -0x8(%rax), %rcx
movq %rcx, 0x58(%rsp)
leaq 0x200(%rcx), %rax
movq %rax, 0x60(%rsp)
addq %rbp, %rcx
movq 0xa0(%rsp), %rax
movq %rcx, 0x50(%rsp)
movq 0xa8(%rsp), %rdi
movq %rax, %rcx
cmpq %rdi, %rax
jne 0x3b4c
movq 0xb8(%rsp), %rcx
movq -0x8(%rcx), %rcx
addq %r12, %rcx
cvttsd2si %xmm0, %edx
movsd -0x8(%rcx), %xmm0
cvttsd2si %xmm0, %ecx
cvttpd2dq %xmm0, %xmm0
cvtdq2pd %xmm0, %xmm2
movslq %edx, %rdx
movq (%r14), %rsi
movlpd %xmm2, (%rsi,%rdx,8)
movq 0xc0(%rsp), %rsi
movsd 0x2494(%rip), %xmm1     # 0x6010
movapd %xmm1, %xmm0
subsd (%rsi,%rdx,8), %xmm0
movq (%r15), %r8
movsd %xmm0, (%r8,%rdx,8)
movslq %ecx, %rcx
movsd (%rsi,%rcx,8), %xmm0
addsd (%rsi,%rdx,8), %xmm0
addsd 0x249d(%rip), %xmm0     # 0x6040
movsd %xmm0, (%rsi,%rcx,8)
ucomisd %xmm0, %xmm1
jbe 0x3c48
cmpq %rdi, %rax
je 0x3bbd
addq $-0x8, %rax
jmp 0x3c03
movapd %xmm2, 0x10(%rsp)
callq 0x2140
movapd 0x10(%rsp), %xmm2
movq 0xb8(%rsp), %rax
leaq -0x8(%rax), %rcx
movq %rcx, 0xb8(%rsp)
movq -0x8(%rax), %rax
movq %rax, 0xa8(%rsp)
leaq 0x200(%rax), %rcx
movq %rcx, 0xb0(%rsp)
addq $0x1f8, %rax            # imm = 0x1F8
movq %rax, 0xa0(%rsp)
movsd %xmm2, 0x8(%rsp)
movq 0x50(%rsp), %rcx
movq 0x60(%rsp), %rdx
addq $-0x8, %rdx
cmpq %rdx, %rcx
je 0x3c33
movsd %xmm2, (%rcx)
addq $0x8, %rcx
movq %rcx, 0x50(%rsp)
jmp 0x3c48
leaq 0x20(%rsp), %rdi
movq %r13, %rsi
callq 0x4758
movq 0xa0(%rsp), %rax
cmpq 0x80(%rsp), %rax
jne 0x3ab3
movq 0x78(%rbx), %rcx
testq %rcx, %rcx
je 0x3ca8
movq 0x48(%rbx), %rax
movq 0x18(%rbx), %rdx
movq 0x30(%rbx), %rsi
xorl %edi, %edi
movsd 0x23db(%rip), %xmm0     # 0x6050
movsd (%rax,%rdi,8), %xmm1
cvttsd2si %xmm1, %r8
movq %r8, %r9
sarq $0x3f, %r9
subsd %xmm0, %xmm1
cvttsd2si %xmm1, %r10
andq %r9, %r10
orq %r8, %r10
movsd (%rdx,%r10,8), %xmm1
movsd %xmm1, (%rsi,%rdi,8)
incq %rdi
cmpq %rdi, %rcx
jne 0x3c75
leaq 0x20(%rsp), %rdi
callq 0x4954
leaq 0x70(%rsp), %rdi
callq 0x4954
movq 0xc0(%rsp), %rdi
testq %rdi, %rdi
je 0x3cce
callq 0x2140
addq $0xd8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
jmp 0x3cfd
jmp 0x3ceb
jmp 0x3cf0
jmp 0x3cf0
movq %rax, %rbx
jmp 0x3d07
movq %rax, %rbx
leaq 0x20(%rsp), %rdi
callq 0x4954
leaq 0x70(%rsp), %rdi
callq 0x4954
movq 0xc0(%rsp), %rdi
testq %rdi, %rdi
je 0x3d19
callq 0x2140
movq %rbx, %rdi
callq 0x2230
nop