// File: /workspace/github_cpp_makefile_star2_O3/redpony[P]cpyp/./cpyp/crp.h
// Function: cpyp::crp<int, std::hash<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() && discount) {
      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 (auto& bin : dish_loc.second.h[0])
            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_customers_);
        assert(std::isfinite(lp));
        for (auto& dish_loc : dish_locs_)
          for (auto& bin : dish_loc.second.h[0])
            lp += lgamma(bin.first) * bin.second;
      } else {  // should never happen, we check this elsewhere
        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 $0x28, %rsp
movq %rdx, %r15
movq %rsi, %r12
movq %rdi, %r14
movsd 0x50(%rdi), %xmm0
ucomisd %xmm0, %xmm0
xorpd %xmm0, %xmm0
jp 0x5d7c
movsd (%r12), %xmm2
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm2
jne 0x5d6c
jnp 0x5d7c
leaq 0x50(%r14), %rsi
leaq 0x58(%r14), %rdx
movq %r12, %rdi
callq 0x61ee
movsd %xmm0, (%rsp)
movsd 0x60(%r14), %xmm0
ucomisd %xmm0, %xmm0
jp 0x6148
movsd (%r15), %xmm0
addsd (%r12), %xmm0
leaq 0x60(%r14), %rsi
leaq 0x20(%rsp), %rdi
movsd %xmm0, (%rdi)
leaq 0x68(%r14), %rdx
callq 0x6372
movsd (%rsp), %xmm2
addsd %xmm0, %xmm2
xorpd %xmm0, %xmm0
ucomisd %xmm2, %xmm0
jb 0x6152
cmpl $0x0, 0x4(%r14)
movabsq $0x7ff0000000000000, %rbx # imm = 0x7FF0000000000000
je 0x611c
movsd (%r12), %xmm1
ucomisd %xmm0, %xmm1
movsd %xmm2, (%rsp)
jbe 0x5e53
movsd 0x3219(%rip), %xmm0     # 0x9010
subsd %xmm1, %xmm0
callq 0x2130
movsd %xmm0, 0x10(%rsp)
movsd (%r15), %xmm0
ucomisd 0x3265(%rip), %xmm0     # 0x9078
jne 0x5e1b
jnp 0x5fa2
callq 0x2130
movsd %xmm0, 0x8(%rsp)
movsd (%r15), %xmm0
divsd (%r12), %xmm0
callq 0x2130
movsd 0x8(%rsp), %xmm2
subsd %xmm0, %xmm2
movsd (%rsp), %xmm1
addsd %xmm2, %xmm1
movsd (%r15), %xmm0
jmp 0x5fa7
jne 0x6190
jp 0x6190
movsd (%r15), %xmm0
callq 0x2130
movsd %xmm0, 0x10(%rsp)
movl (%r14), %eax
xorps %xmm0, %xmm0
cvtsi2sd %rax, %xmm0
movsd %xmm0, 0x8(%rsp)
movsd (%r15), %xmm0
callq 0x2150
mulsd 0x8(%rsp), %xmm0
addsd 0x10(%rsp), %xmm0
movsd %xmm0, 0x10(%rsp)
movl 0x4(%r14), %eax
xorps %xmm0, %xmm0
cvtsi2sd %rax, %xmm0
addsd (%r15), %xmm0
callq 0x2130
movsd 0x10(%rsp), %xmm1
subsd %xmm0, %xmm1
movsd (%rsp), %xmm2
addsd %xmm1, %xmm2
movq %xmm2, %rax
btrq $0x3f, %rax
cmpq %rbx, %rax
jge 0x61ce
movq 0x18(%r14), %rbx
testq %rbx, %rbx
je 0x611c
leaq 0x18(%rbx), %r15
movb 0x91(%rbx), %bpl
testb %bpl, %bpl
je 0x5f01
movq (%r15), %rcx
movq 0x10(%rcx), %r12
movq %rax, %r15
jmp 0x5f0f
movzbl 0x90(%rbx), %eax
leaq (%r15,%rax,8), %r14
xorl %r12d, %r12d
xorl %eax, %eax
cmpq %r15, %r14
setne %al
xorl %ecx, %ecx
testq %r12, %r12
setne %cl
testb %bpl, %bpl
cmovel %eax, %ecx
cmpb $0x1, %cl
jne 0x5f8e
movsd %xmm2, (%rsp)
leaq 0x8(%r12), %r13
testb %bpl, %bpl
cmoveq %r15, %r13
movl (%r13), %eax
xorps %xmm0, %xmm0
cvtsi2sd %rax, %xmm0
callq 0x2130
testb %bpl, %bpl
je 0x5f57
movq (%r12), %r12
jmp 0x5f5b
addq $0x8, %r15
movsd (%rsp), %xmm2
movl 0x4(%r13), %eax
xorps %xmm1, %xmm1
cvtsi2sd %rax, %xmm1
mulsd %xmm1, %xmm0
addsd %xmm0, %xmm2
xorl %eax, %eax
cmpq %r15, %r14
setne %al
xorl %ecx, %ecx
testq %r12, %r12
setne %cl
testb %bpl, %bpl
cmovel %eax, %ecx
testb %cl, %cl
jne 0x5f2a
movq (%rbx), %rbx
movq %r15, %rax
testq %rbx, %rbx
jne 0x5ee5
jmp 0x611c
movsd (%rsp), %xmm1
movsd %xmm1, (%rsp)
movl 0x4(%r14), %eax
xorps %xmm1, %xmm1
cvtsi2sd %rax, %xmm1
addsd %xmm0, %xmm1
movapd %xmm1, %xmm0
callq 0x2130
movsd %xmm0, 0x8(%rsp)
movl (%r14), %eax
xorps %xmm0, %xmm0
cvtsi2sd %rax, %xmm0
movsd %xmm0, 0x18(%rsp)
movsd (%r12), %xmm0
callq 0x2150
mulsd 0x18(%rsp), %xmm0
subsd 0x8(%rsp), %xmm0
movsd %xmm0, 0x8(%rsp)
movsd (%r15), %xmm1
divsd (%r12), %xmm1
movl (%r14), %eax
xorps %xmm0, %xmm0
cvtsi2sd %rax, %xmm0
addsd %xmm1, %xmm0
callq 0x2130
movapd %xmm0, %xmm2
addsd 0x8(%rsp), %xmm2
addsd (%rsp), %xmm2
movq %xmm2, %rax
btrq $0x3f, %rax
cmpq %rbx, %rax
jge 0x61af
movq 0x18(%r14), %rcx
testq %rcx, %rcx
je 0x611c
movq %r12, %r14
leaq 0x18(%rcx), %r13
movb 0x91(%rcx), %bpl
testb %bpl, %bpl
movq %rcx, 0x8(%rsp)
je 0x606c
movq (%r13), %rcx
movq 0x10(%rcx), %r12
movq %rax, %r13
jmp 0x6081
movzbl 0x90(%rcx), %eax
leaq (,%rax,8), %r15
addq %r13, %r15
xorl %r12d, %r12d
xorl %eax, %eax
cmpq %r13, %r15
setne %al
xorl %ecx, %ecx
testq %r12, %r12
setne %cl
testb %bpl, %bpl
cmovel %eax, %ecx
cmpb $0x1, %cl
jne 0x6108
movsd %xmm2, (%rsp)
leaq 0x8(%r12), %rbx
testb %bpl, %bpl
cmoveq %r13, %rbx
movl (%rbx), %eax
xorps %xmm0, %xmm0
cvtsi2sd %rax, %xmm0
subsd (%r14), %xmm0
callq 0x2130
testb %bpl, %bpl
je 0x60cc
movq (%r12), %r12
jmp 0x60d0
addq $0x8, %r13
movsd (%rsp), %xmm2
subsd 0x10(%rsp), %xmm0
movl 0x4(%rbx), %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 %r12, %r12
setne %cl
testb %bpl, %bpl
cmovel %eax, %ecx
testb %cl, %cl
jne 0x609c
movq 0x8(%rsp), %rcx
movq (%rcx), %rcx
movq %r13, %rax
testq %rcx, %rcx
jne 0x604a
movq %xmm2, %rax
btrq $0x3f, %rax
movabsq $0x7ff0000000000000, %rcx # imm = 0x7FF0000000000000
cmpq %rcx, %rax
jge 0x6171
movapd %xmm2, %xmm0
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movsd (%rsp), %xmm2
jmp 0x5dbb
leaq 0x3440(%rip), %rdi      # 0x9599
leaq 0x3443(%rip), %rsi      # 0x95a3
leaq 0x3449(%rip), %rcx      # 0x95b0
movl $0x134, %edx            # imm = 0x134
callq 0x20e0
leaq 0x34ac(%rip), %rdi      # 0x9624
leaq 0x3424(%rip), %rsi      # 0x95a3
leaq 0x342a(%rip), %rcx      # 0x95b0
movl $0x160, %edx            # imm = 0x160
callq 0x20e0
leaq 0x349f(%rip), %rdi      # 0x9636
leaq 0x3405(%rip), %rsi      # 0x95a3
leaq 0x340b(%rip), %rcx      # 0x95b0
movl $0x15d, %edx            # imm = 0x15D
callq 0x20e0
leaq 0x346e(%rip), %rdi      # 0x9624
leaq 0x33e6(%rip), %rsi      # 0x95a3
leaq 0x33ec(%rip), %rcx      # 0x95b0
movl $0x148, %edx            # imm = 0x148
callq 0x20e0
leaq 0x344f(%rip), %rdi      # 0x9624
leaq 0x33c7(%rip), %rsi      # 0x95a3
leaq 0x33cd(%rip), %rcx      # 0x95b0
movl $0x158, %edx            # imm = 0x158
callq 0x20e0
nop