// File: /workspace/github_cpp_makefile_star2_O3/redpony[P]cpyp/./cpyp/mf_crp.h
// Function: cpyp::mf_crp<2u, unsigned int, std::hash<unsigned int>>::log_likelihood(double const&, double const&) const
double log_likelihood(const double& discount, const double& strength) const {
    double lp = 0.0;
    if (has_discount_prior())
      lp = Md::log_beta_density(discount, discount_prior_strength_, discount_prior_beta_);
    if (has_strength_prior())
      lp += Md::log_gamma_density(strength + discount, strength_prior_shape_, strength_prior_rate_);
    assert(lp <= 0.0);
    if (num_customers_) {  // if restaurant is not empty
      if (discount > 0.0) {  // two parameter case: discount > 0
        const double r = lgamma(1.0 - discount);
        if (strength)
          lp += lgamma(strength) - lgamma(strength / discount);
        lp += - lgamma(strength + num_customers_)
             + num_tables_ * log(discount) + lgamma(strength / discount + num_tables_);
        // above line implies
        // 1) when adding a customer to a restaurant containing N customers:
        //    lp -= log(strength + N)    [because \Gamma(s+N+1) = (s+N)\Gamma(s+N)
        // 2) when removing a customer from a restaurant containing N customers:
        //    lp += log(strength + N - 1)  [because \Gamma(s+N) = (s+N-1)\Gamma(s+N-1)]
        // 3) when adding a table to a restaurant containing T tables:
        //    lp += log(discount) + log(s / d + T)
        // 4) when removing a table from a restuarant containint T tables:
        //    lp -= log(discount) + log(s / d + T - 1)

        assert(std::isfinite(lp));
        for (auto& dish_loc : dish_locs_)
          for (unsigned floor = 0; floor < NumFloors; ++floor)
            for (auto& bin : dish_loc.second.h[floor])
              lp += (lgamma(bin.first - discount) - r) * bin.second;
         // above implies
         // 1) when adding to a table seating N > 1 customers
         //    lp += log(N - discount)
         // 2) when adding a new table
         //    do nothing
         // 3) when removing a customer from a table with N > 1 customers
         //    lp -= log(N - discount - 1)
         // 4) when closing a table
         //    do nothing
      } else if (!discount) { // discount == 0.0 (ie, Dirichlet Process)
        lp += lgamma(strength) + num_tables_ * log(strength) - lgamma(strength + num_tables_);
        assert(std::isfinite(lp));
        for (auto& dish_loc : dish_locs_)
          lp += lgamma(dish_loc.second.num_tables());
      } else { // should never happen
        assert(!"discount less than 0 detected!");
      }
    }
    assert(std::isfinite(lp));
    return lp;
  }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rdx, %r15
movq %rsi, %rbx
movq %rdi, %r14
movsd 0x50(%rdi), %xmm0
ucomisd %xmm0, %xmm0
jp 0x8039
leaq 0x50(%r14), %rsi
leaq 0x58(%r14), %rdx
movq %rbx, %rdi
callq 0x61ee
movsd %xmm0, 0x8(%rsp)
movsd 0x60(%r14), %xmm0
ucomisd %xmm0, %xmm0
jp 0x8042
movsd (%r15), %xmm0
addsd (%rbx), %xmm0
leaq 0x60(%r14), %rsi
leaq 0x30(%rsp), %rdi
movsd %xmm0, (%rdi)
leaq 0x68(%r14), %rdx
callq 0x6372
movsd 0x8(%rsp), %xmm2
addsd %xmm0, %xmm2
xorpd %xmm0, %xmm0
ucomisd %xmm2, %xmm0
jb 0x804d
cmpl $0x0, 0x4(%r14)
movabsq $0x7ff0000000000000, %r12 # imm = 0x7FF0000000000000
je 0x800d
movsd (%rbx), %xmm1
ucomisd %xmm0, %xmm1
movsd %xmm2, 0x8(%rsp)
jbe 0x7dbb
movsd 0x12b0(%rip), %xmm0     # 0x9010
subsd %xmm1, %xmm0
callq 0x2130
movsd %xmm0, 0x18(%rsp)
movsd (%r15), %xmm0
ucomisd 0x12fc(%rip), %xmm0     # 0x9078
jne 0x7d84
jnp 0x7e72
callq 0x2130
movsd %xmm0, 0x10(%rsp)
movsd (%r15), %xmm0
divsd (%rbx), %xmm0
callq 0x2130
movsd 0x10(%rsp), %xmm2
subsd %xmm0, %xmm2
movsd 0x8(%rsp), %xmm1
addsd %xmm2, %xmm1
movsd (%r15), %xmm0
jmp 0x7e78
jne 0x808b
jp 0x808b
movsd (%r15), %xmm0
callq 0x2130
movsd %xmm0, 0x18(%rsp)
movl (%r14), %eax
xorps %xmm0, %xmm0
cvtsi2sd %rax, %xmm0
movsd %xmm0, 0x10(%rsp)
movsd (%r15), %xmm0
callq 0x2150
mulsd 0x10(%rsp), %xmm0
addsd 0x18(%rsp), %xmm0
movsd %xmm0, 0x18(%rsp)
movl (%r14), %eax
xorps %xmm0, %xmm0
cvtsi2sd %rax, %xmm0
addsd (%r15), %xmm0
callq 0x2130
movsd 0x18(%rsp), %xmm1
subsd %xmm0, %xmm1
movsd 0x8(%rsp), %xmm2
addsd %xmm1, %xmm2
movq %xmm2, %rax
btrq $0x3f, %rax
cmpq %r12, %rax
jge 0x80c9
movq 0x18(%r14), %rbx
testq %rbx, %rbx
je 0x800d
movsd %xmm2, 0x8(%rsp)
movl 0x14(%rbx), %eax
xorps %xmm0, %xmm0
cvtsi2sd %rax, %xmm0
callq 0x2130
movsd 0x8(%rsp), %xmm2
addsd %xmm0, %xmm2
movq (%rbx), %rbx
jmp 0x7e44
movsd 0x8(%rsp), %xmm1
movsd %xmm1, 0x8(%rsp)
movl 0x4(%r14), %eax
xorps %xmm1, %xmm1
cvtsi2sd %rax, %xmm1
addsd %xmm0, %xmm1
movapd %xmm1, %xmm0
callq 0x2130
movsd %xmm0, 0x10(%rsp)
movl (%r14), %eax
xorps %xmm0, %xmm0
cvtsi2sd %rax, %xmm0
movsd %xmm0, 0x20(%rsp)
movsd (%rbx), %xmm0
callq 0x2150
mulsd 0x20(%rsp), %xmm0
subsd 0x10(%rsp), %xmm0
movsd %xmm0, 0x10(%rsp)
movsd (%r15), %xmm1
divsd (%rbx), %xmm1
movl (%r14), %eax
xorps %xmm0, %xmm0
cvtsi2sd %rax, %xmm0
addsd %xmm1, %xmm0
callq 0x2130
movapd %xmm0, %xmm2
addsd 0x10(%rsp), %xmm2
addsd 0x8(%rsp), %xmm2
movq %xmm2, %rax
btrq $0x3f, %rax
cmpq %r12, %rax
jge 0x80aa
movq 0x18(%r14), %rax
testq %rax, %rax
je 0x800d
movq %rax, 0x28(%rsp)
addq $0x18, %rax
movq %rax, 0x20(%rsp)
movb $0x1, %cl
xorl %eax, %eax
movl %ecx, 0x10(%rsp)
shlq $0x7, %rax
movq 0x20(%rsp), %rdx
leaq (%rdx,%rax), %rcx
movb 0x79(%rdx,%rax), %r14b
testb %r14b, %r14b
je 0x7f4f
movq (%rcx), %rax
movq 0x10(%rax), %rbp
movq %r13, %rcx
jmp 0x7f5c
movzbl 0x78(%rcx), %eax
leaq (%rcx,%rax,8), %r15
xorl %ebp, %ebp
movq %rcx, %r13
xorl %eax, %eax
cmpq %rcx, %r15
setne %al
xorl %ecx, %ecx
testq %rbp, %rbp
setne %cl
testb %r14b, %r14b
cmovel %eax, %ecx
cmpb $0x1, %cl
jne 0x7fe7
movsd %xmm2, 0x8(%rsp)
leaq 0x8(%rbp), %r12
testb %r14b, %r14b
cmoveq %r13, %r12
movl (%r12), %eax
xorps %xmm0, %xmm0
cvtsi2sd %rax, %xmm0
subsd (%rbx), %xmm0
callq 0x2130
testb %r14b, %r14b
je 0x7fa8
movq (%rbp), %rbp
jmp 0x7fac
addq $0x8, %r13
movsd 0x8(%rsp), %xmm2
subsd 0x18(%rsp), %xmm0
movl 0x4(%r12), %eax
xorps %xmm1, %xmm1
cvtsi2sd %rax, %xmm1
mulsd %xmm0, %xmm1
addsd %xmm1, %xmm2
xorl %eax, %eax
cmpq %r13, %r15
setne %al
xorl %ecx, %ecx
testq %rbp, %rbp
setne %cl
testb %r14b, %r14b
cmovel %eax, %ecx
testb %cl, %cl
jne 0x7f77
movl $0x1, %eax
testb $0x1, 0x10(%rsp)
movl $0x0, %ecx
jne 0x7f28
movq 0x28(%rsp), %rax
movq (%rax), %rax
testq %rax, %rax
jne 0x7f16
movq %xmm2, %rax
btrq $0x3f, %rax
movabsq $0x7ff0000000000000, %rcx # imm = 0x7FF0000000000000
cmpq %rcx, %rax
jge 0x806c
movapd %xmm2, %xmm0
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
xorpd %xmm0, %xmm0
jmp 0x7ce6
movsd 0x8(%rsp), %xmm2
jmp 0x7d25
leaq 0x1545(%rip), %rdi      # 0x9599
leaq 0x18f0(%rip), %rsi      # 0x994b
leaq 0x18f9(%rip), %rcx      # 0x995b
movl $0x102, %edx            # imm = 0x102
callq 0x20e0
leaq 0x15b1(%rip), %rdi      # 0x9624
leaq 0x18d1(%rip), %rsi      # 0x994b
leaq 0x18da(%rip), %rcx      # 0x995b
movl $0x12b, %edx            # imm = 0x12B
callq 0x20e0
leaq 0x15a4(%rip), %rdi      # 0x9636
leaq 0x18b2(%rip), %rsi      # 0x994b
leaq 0x18bb(%rip), %rcx      # 0x995b
movl $0x128, %edx            # imm = 0x128
callq 0x20e0
leaq 0x1573(%rip), %rdi      # 0x9624
leaq 0x1893(%rip), %rsi      # 0x994b
leaq 0x189c(%rip), %rcx      # 0x995b
movl $0x114, %edx            # imm = 0x114
callq 0x20e0
leaq 0x1554(%rip), %rdi      # 0x9624
leaq 0x1874(%rip), %rsi      # 0x994b
leaq 0x187d(%rip), %rcx      # 0x995b
movl $0x124, %edx            # imm = 0x124
callq 0x20e0