// File: /workspace/github_cpp_makefile_star2_O1/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 0x5e22
movsd (%r12), %xmm2
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm2
jne 0x5e12
jnp 0x5e22
leaq 0x50(%r14), %rsi
leaq 0x58(%r14), %rdx
movq %r12, %rdi
callq 0x6288
movsd %xmm0, (%rsp)
movsd 0x60(%r14), %xmm0
ucomisd %xmm0, %xmm0
jp 0x61e2
movsd (%r15), %xmm0
addsd (%r12), %xmm0
leaq 0x60(%r14), %rsi
leaq 0x20(%rsp), %rdi
movsd %xmm0, (%rdi)
leaq 0x68(%r14), %rdx
callq 0x640c
movsd (%rsp), %xmm2
addsd %xmm0, %xmm2
xorpd %xmm0, %xmm0
ucomisd %xmm2, %xmm0
jb 0x61ec
cmpl $0x0, 0x4(%r14)
movabsq $0x7ff0000000000000, %rbx # imm = 0x7FF0000000000000
je 0x61b6
movsd (%r12), %xmm1
ucomisd %xmm0, %xmm1
movsd %xmm2, (%rsp)
jbe 0x5ef4
movsd 0x4173(%rip), %xmm0     # 0xa010
subsd %xmm1, %xmm0
callq 0x2130
movsd %xmm0, 0x10(%rsp)
movsd (%r15), %xmm0
ucomisd 0x41bf(%rip), %xmm0     # 0xa078
jne 0x5ec1
jnp 0x6045
callq 0x2130
movsd %xmm0, 0x8(%rsp)
movsd (%r15), %xmm0
divsd (%r12), %xmm0
callq 0x2130
movsd 0x8(%rsp), %xmm1
subsd %xmm0, %xmm1
movsd (%rsp), %xmm0
addsd %xmm1, %xmm0
jmp 0x604a
jne 0x622a
jp 0x622a
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 0x6268
movq 0x18(%r14), %rbx
testq %rbx, %rbx
je 0x61b6
leaq 0x18(%rbx), %rax
movb 0x91(%rbx), %bpl
testb %bpl, %bpl
je 0x5f9f
movq (%rax), %rcx
movq 0x10(%rcx), %r12
jmp 0x5fa5
xorl %r12d, %r12d
movq %rax, %r15
testb %bpl, %bpl
jne 0x5fb5
movzbl 0x90(%rbx), %ecx
leaq (%rax,%rcx,8), %r14
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 0x6034
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 0x5ffd
movq (%r12), %r12
jmp 0x6001
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 0x5fd0
movq (%rbx), %rbx
testq %rbx, %rbx
jne 0x5f86
jmp 0x61b6
movsd (%rsp), %xmm0
movsd %xmm0, (%rsp)
movl 0x4(%r14), %eax
xorps %xmm0, %xmm0
cvtsi2sd %rax, %xmm0
addsd (%r15), %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 0x6249
movq 0x18(%r14), %rdx
testq %rdx, %rdx
je 0x61b6
movq %r12, %r14
leaq 0x18(%rdx), %rax
movb 0x91(%rdx), %bpl
testb %bpl, %bpl
je 0x6103
movq (%rax), %rcx
movq 0x10(%rcx), %r12
jmp 0x6109
movq %rax, %r15
xorl %r12d, %r12d
testb %bpl, %bpl
jne 0x6119
movzbl 0x90(%rdx), %ecx
leaq (%rax,%rcx,8), %r13
movq %rdx, 0x8(%rsp)
xorl %eax, %eax
cmpq %r15, %r13
setne %al
xorl %ecx, %ecx
testq %r12, %r12
setne %cl
testb %bpl, %bpl
cmovel %eax, %ecx
cmpb $0x1, %cl
jne 0x61a5
movsd %xmm2, (%rsp)
leaq 0x8(%r12), %rbx
testb %bpl, %bpl
cmoveq %r15, %rbx
movl (%rbx), %eax
xorps %xmm0, %xmm0
cvtsi2sd %rax, %xmm0
subsd (%r14), %xmm0
callq 0x2130
testb %bpl, %bpl
je 0x6169
movq (%r12), %r12
jmp 0x616d
addq $0x8, %r15
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 %r15, %r13
setne %al
xorl %ecx, %ecx
testq %r12, %r12
setne %cl
testb %bpl, %bpl
cmovel %eax, %ecx
testb %cl, %cl
jne 0x6139
movq 0x8(%rsp), %rdx
movq (%rdx), %rdx
testq %rdx, %rdx
jne 0x60ea
movq %xmm2, %rax
btrq $0x3f, %rax
movabsq $0x7ff0000000000000, %rcx # imm = 0x7FF0000000000000
cmpq %rcx, %rax
jge 0x620b
movapd %xmm2, %xmm0
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movsd (%rsp), %xmm2
jmp 0x5e61
leaq 0x43a6(%rip), %rdi      # 0xa599
leaq 0x43a9(%rip), %rsi      # 0xa5a3
leaq 0x43af(%rip), %rcx      # 0xa5b0
movl $0x134, %edx            # imm = 0x134
callq 0x20e0
leaq 0x4412(%rip), %rdi      # 0xa624
leaq 0x438a(%rip), %rsi      # 0xa5a3
leaq 0x4390(%rip), %rcx      # 0xa5b0
movl $0x160, %edx            # imm = 0x160
callq 0x20e0
leaq 0x4405(%rip), %rdi      # 0xa636
leaq 0x436b(%rip), %rsi      # 0xa5a3
leaq 0x4371(%rip), %rcx      # 0xa5b0
movl $0x15d, %edx            # imm = 0x15D
callq 0x20e0
leaq 0x43d4(%rip), %rdi      # 0xa624
leaq 0x434c(%rip), %rsi      # 0xa5a3
leaq 0x4352(%rip), %rcx      # 0xa5b0
movl $0x148, %edx            # imm = 0x148
callq 0x20e0
leaq 0x43b5(%rip), %rdi      # 0xa624
leaq 0x432d(%rip), %rsi      # 0xa5a3
leaq 0x4333(%rip), %rcx      # 0xa5b0
movl $0x158, %edx            # imm = 0x158
callq 0x20e0
nop