// File: /workspace/github_cpp_makefile_star2_O3/JenTus[P]TCEM/src_TCEM/allocator.cc
// Function: Cide::allocator::lowerBoundOPT()
double allocator::lowerBoundOPT() {

        double epsilon_1 = epsilon * 2.0; //

        for (int x = 1; x < log2(n); x++) {

            int64 theta_x = (2+2.0/3.0 * epsilon_1)* (ell * log(n) + logP(n,k_r,tao) + log(log2(n))) * pow(2.0,x) / (epsilon_1 * epsilon_1);
            //int64 theta_x =  (2+2.0/3.0 * epsilon_1)* (ell * log(n) + logcnk(n*(n-1), k_r*k_b) + log(log2(n))) * pow(2.0,x) / (epsilon_1 * epsilon_1);
            
//            std::cout << "theta_x " << theta_x << std::endl;
            generateRCSets(theta_x);
            
            double ept = rcGreedy(theta_x, false);

//            cout << "ept is: " << ept << endl;

            if (ept > ((1+epsilon_1) / pow(2.0, x))) {
                double lowerBound = ept * n / (1 + epsilon_1);
                // kontrol:
//                std:cout << "x and theta_x " << x << " " << theta_x << std::endl;
                return lowerBound;
            }
        }
        cout << "returning naive lower bound  " << endl;
        double naive = 1.0;
        return naive;
    }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rdi, %rbx
movsd 0x90(%rdi), %xmm0
movsd %xmm0, 0x18(%rsp)
xorps %xmm0, %xmm0
cvtsi2sdl 0x68(%rdi), %xmm0
callq 0x35d0
ucomisd 0x92d2(%rip), %xmm0     # 0x12150
jbe 0x90b1
movsd 0x18(%rsp), %xmm0
addsd %xmm0, %xmm0
movsd 0x92ea(%rip), %xmm1     # 0x12180
mulsd %xmm0, %xmm1
addsd 0x92e6(%rip), %xmm1     # 0x12188
movsd %xmm1, 0x30(%rsp)
movapd %xmm0, %xmm1
mulsd %xmm0, %xmm1
movsd %xmm1, 0x28(%rsp)
addsd 0x9292(%rip), %xmm0     # 0x12150
movsd %xmm0, 0x18(%rsp)
movl $0x1, %ebp
movsd 0xa0(%rbx), %xmm0
movsd %xmm0, 0x20(%rsp)
xorps %xmm0, %xmm0
cvtsi2sdl 0x68(%rbx), %xmm0
callq 0x3240
movsd %xmm0, 0x38(%rsp)
movl 0x68(%rbx), %r12d
movl 0x78(%rbx), %r14d
movl 0x80(%rbx), %r15d
movl %r15d, %r13d
notl %r13d
imull %r14d, %r13d
leal (%r12,%r13), %eax
xorpd %xmm0, %xmm0
cmpl %r12d, %eax
jge 0x8f44
incl %r12d
movsd %xmm0, 0x8(%rsp)
leal (%r12,%r13), %eax
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
callq 0x3240
movsd 0x8(%rsp), %xmm1
addsd %xmm0, %xmm1
movsd %xmm1, 0x8(%rsp)
movsd 0x8(%rsp), %xmm0
incl %r13d
jne 0x8f13
movapd %xmm0, %xmm1
testl %r14d, %r14d
movsd 0x91fd(%rip), %xmm0     # 0x12150
jle 0x8f92
movl %r14d, %r12d
movapd %xmm0, %xmm2
movsd %xmm2, 0x10(%rsp)
movsd %xmm1, 0x8(%rsp)
movapd %xmm2, %xmm0
callq 0x3240
movsd 0x10(%rsp), %xmm2
movsd 0x8(%rsp), %xmm1
subsd %xmm0, %xmm1
movsd 0x91c7(%rip), %xmm0     # 0x12150
addsd %xmm0, %xmm2
decl %r12d
jne 0x8f5c
movsd %xmm1, 0x8(%rsp)
xorpd %xmm1, %xmm1
testl %r15d, %r15d
jle 0x8fd7
movapd %xmm0, %xmm2
movsd %xmm2, 0x40(%rsp)
movsd %xmm1, 0x10(%rsp)
movapd %xmm2, %xmm0
callq 0x3240
movsd 0x40(%rsp), %xmm2
movsd 0x10(%rsp), %xmm1
addsd %xmm0, %xmm1
addsd 0x917e(%rip), %xmm2     # 0x12150
decl %r15d
jne 0x8fa5
xorps %xmm0, %xmm0
cvtsi2sd %r14d, %xmm0
mulsd %xmm1, %xmm0
movsd 0x8(%rsp), %xmm1
subsd %xmm0, %xmm1
movsd 0x20(%rsp), %xmm0
mulsd 0x38(%rsp), %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, 0x20(%rsp)
xorps %xmm0, %xmm0
cvtsi2sdl 0x68(%rbx), %xmm0
callq 0x35d0
callq 0x3240
addsd 0x20(%rsp), %xmm0
mulsd 0x30(%rsp), %xmm0
movsd %xmm0, 0x10(%rsp)
xorps %xmm0, %xmm0
cvtsi2sd %ebp, %xmm0
movsd %xmm0, 0x8(%rsp)
callq 0x3290
mulsd 0x10(%rsp), %xmm0
divsd 0x28(%rsp), %xmm0
cvttsd2si %xmm0, %r14
movq %rbx, %rdi
movq %r14, %rsi
callq 0x911e
movq %rbx, %rdi
movq %r14, %rsi
xorl %edx, %edx
callq 0x936c
movsd %xmm0, 0x10(%rsp)
movsd 0x8(%rsp), %xmm0
callq 0x3290
movsd 0x18(%rsp), %xmm1
divsd %xmm0, %xmm1
movsd 0x10(%rsp), %xmm0
ucomisd %xmm1, %xmm0
ja 0x90fd
incl %ebp
xorps %xmm0, %xmm0
cvtsi2sd %ebp, %xmm0
movsd %xmm0, 0x8(%rsp)
xorps %xmm0, %xmm0
cvtsi2sdl 0x68(%rbx), %xmm0
callq 0x35d0
ucomisd 0x8(%rsp), %xmm0
ja 0x8ec9
movq 0xef20(%rip), %rbx      # 0x17fd8
leaq 0x9194(%rip), %rsi      # 0x12253
movl $0x1d, %edx
movq %rbx, %rdi
callq 0x3340
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x32d0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x3030
movq %rax, %rdi
callq 0x31e0
movsd 0x9055(%rip), %xmm0     # 0x12150
jmp 0x910f
xorps %xmm1, %xmm1
cvtsi2sdl 0x68(%rbx), %xmm1
mulsd %xmm1, %xmm0
divsd 0x18(%rsp), %xmm0
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq