// File: /workspace/github_cpp_makefile_star2_O2/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 $0x58, %rsp
movq %rdx, %r15
movq %rsi, %r14
movq %rdi, %rbx
movsd 0x50(%rdi), %xmm0
ucomisd %xmm0, %xmm0
xorpd %xmm0, %xmm0
jp 0x513b
movsd (%r14), %xmm2
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm2
jne 0x512b
jnp 0x513b
leaq 0x50(%rbx), %rsi
leaq 0x58(%rbx), %rdx
movq %r14, %rdi
callq 0x55ae
movsd %xmm0, 0x8(%rsp)
movsd 0x60(%rbx), %xmm0
ucomisd %xmm0, %xmm0
jp 0x5508
movsd (%r15), %xmm0
addsd (%r14), %xmm0
leaq 0x60(%rbx), %rsi
leaq 0x20(%rsp), %rdi
movsd %xmm0, (%rdi)
leaq 0x68(%rbx), %rdx
callq 0x56f0
movsd 0x8(%rsp), %xmm2
addsd %xmm0, %xmm2
xorpd %xmm0, %xmm0
ucomisd %xmm2, %xmm0
jb 0x5513
cmpl $0x0, 0x4(%rbx)
movabsq $0x7ff0000000000000, %rbp # imm = 0x7FF0000000000000
je 0x54e6
movsd (%r14), %xmm1
ucomisd %xmm0, %xmm1
movsd %xmm2, 0x8(%rsp)
jbe 0x5211
movsd 0x3e5b(%rip), %xmm0     # 0x9010
subsd %xmm1, %xmm0
callq 0x2110
movsd %xmm0, 0x18(%rsp)
movsd (%r15), %xmm0
ucomisd 0x3ea7(%rip), %xmm0     # 0x9078
jne 0x51d9
jnp 0x536a
callq 0x2110
movsd %xmm0, 0x10(%rsp)
movsd (%r15), %xmm0
divsd (%r14), %xmm0
callq 0x2110
movsd 0x10(%rsp), %xmm2
subsd %xmm0, %xmm2
movsd 0x8(%rsp), %xmm1
addsd %xmm2, %xmm1
movsd (%r15), %xmm0
jmp 0x5370
jne 0x5551
jp 0x5551
movsd (%r15), %xmm0
callq 0x2110
movsd %xmm0, 0x18(%rsp)
movl (%rbx), %eax
cvtsi2sd %rax, %xmm0
movsd %xmm0, 0x10(%rsp)
movsd (%r15), %xmm0
callq 0x2130
mulsd 0x10(%rsp), %xmm0
addsd 0x18(%rsp), %xmm0
movsd %xmm0, 0x18(%rsp)
movl 0x4(%rbx), %eax
cvtsi2sd %rax, %xmm0
addsd (%r15), %xmm0
callq 0x2110
movsd 0x18(%rsp), %xmm1
subsd %xmm0, %xmm1
movsd 0x8(%rsp), %xmm2
addsd %xmm1, %xmm2
movq %xmm2, %rax
btrq $0x3f, %rax
cmpq %rbp, %rax
jge 0x558f
addq $0x18, %rbx
leaq 0x20(%rsp), %r14
leaq 0x38(%rsp), %r15
movq (%rbx), %rbx
testq %rbx, %rbx
je 0x54e6
movsd %xmm2, 0x8(%rsp)
leaq 0x18(%rbx), %r12
movq %r14, %rdi
movq %r12, %rsi
callq 0x585e
movb 0x91(%rbx), %al
movl %eax, %ecx
xorb $0x1, %cl
movb %cl, 0x38(%rsp)
andq $0x0, 0x48(%rsp)
testb %al, %al
je 0x52df
andq $0x0, 0x48(%rsp)
jmp 0x5350
movzbl 0x90(%rbx), %eax
leaq (%r12,%rax,8), %rax
movq %rax, 0x40(%rsp)
jmp 0x5350
cmpb $0x0, 0x20(%rsp)
je 0x52ff
movq 0x28(%rsp), %r12
jmp 0x5308
movq 0x30(%rsp), %r12
addq $0x8, %r12
movl (%r12), %eax
cvtsi2sd %rax, %xmm0
callq 0x2110
movl 0x4(%r12), %eax
cvtsi2sd %rax, %xmm1
mulsd %xmm0, %xmm1
movsd 0x8(%rsp), %xmm0
addsd %xmm1, %xmm0
cmpb $0x1, 0x20(%rsp)
movsd %xmm0, 0x8(%rsp)
jne 0x5343
addq $0x8, 0x28(%rsp)
jmp 0x5350
movq 0x30(%rsp), %rax
movq (%rax), %rax
movq %rax, 0x30(%rsp)
movq %r14, %rdi
movq %r15, %rsi
callq 0x57fc
testb %al, %al
jne 0x52f1
movsd 0x8(%rsp), %xmm2
jmp 0x529d
movsd 0x8(%rsp), %xmm1
movsd %xmm1, 0x8(%rsp)
movl 0x4(%rbx), %eax
cvtsi2sd %rax, %xmm1
addsd %xmm0, %xmm1
movapd %xmm1, %xmm0
callq 0x2110
movsd %xmm0, 0x10(%rsp)
movl (%rbx), %eax
cvtsi2sd %rax, %xmm0
movsd %xmm0, 0x50(%rsp)
movsd (%r14), %xmm0
callq 0x2130
mulsd 0x50(%rsp), %xmm0
subsd 0x10(%rsp), %xmm0
movsd %xmm0, 0x10(%rsp)
movsd (%r15), %xmm1
divsd (%r14), %xmm1
movl (%rbx), %eax
cvtsi2sd %rax, %xmm0
addsd %xmm1, %xmm0
callq 0x2110
movapd %xmm0, %xmm2
addsd 0x10(%rsp), %xmm2
addsd 0x8(%rsp), %xmm2
movq %xmm2, %rax
btrq $0x3f, %rax
cmpq %rbp, %rax
jge 0x5570
addq $0x18, %rbx
leaq 0x20(%rsp), %r15
leaq 0x38(%rsp), %r12
movq (%rbx), %rbx
testq %rbx, %rbx
je 0x54e6
movsd %xmm2, 0x8(%rsp)
leaq 0x18(%rbx), %r13
movq %r15, %rdi
movq %r13, %rsi
callq 0x585e
movb 0x91(%rbx), %al
movl %eax, %ecx
xorb $0x1, %cl
movb %cl, 0x38(%rsp)
andq $0x0, 0x48(%rsp)
testb %al, %al
je 0x544a
andq $0x0, 0x48(%rsp)
jmp 0x54cc
movzbl 0x90(%rbx), %eax
leaq (,%rax,8), %rax
addq %r13, %rax
movq %rax, 0x40(%rsp)
jmp 0x54cc
cmpb $0x0, 0x20(%rsp)
je 0x5471
movq 0x28(%rsp), %r13
jmp 0x547a
movq 0x30(%rsp), %r13
addq $0x8, %r13
movl (%r13), %eax
cvtsi2sd %rax, %xmm0
subsd (%r14), %xmm0
callq 0x2110
subsd 0x18(%rsp), %xmm0
movl 0x4(%r13), %eax
cvtsi2sd %rax, %xmm1
mulsd %xmm0, %xmm1
movsd 0x8(%rsp), %xmm0
addsd %xmm1, %xmm0
cmpb $0x1, 0x20(%rsp)
movsd %xmm0, 0x8(%rsp)
jne 0x54bf
addq $0x8, 0x28(%rsp)
jmp 0x54cc
movq 0x30(%rsp), %rax
movq (%rax), %rax
movq %rax, 0x30(%rsp)
movq %r15, %rdi
movq %r12, %rsi
callq 0x57fc
testb %al, %al
jne 0x5463
movsd 0x8(%rsp), %xmm2
jmp 0x5405
movq %xmm2, %rax
btrq $0x3f, %rax
cmpq %rbp, %rax
jge 0x5532
movapd %xmm2, %xmm0
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movsd 0x8(%rsp), %xmm2
jmp 0x517a
leaq 0x4050(%rip), %rdi      # 0x956a
leaq 0x4053(%rip), %rsi      # 0x9574
leaq 0x4059(%rip), %rcx      # 0x9581
movl $0x134, %edx            # imm = 0x134
callq 0x20d0
leaq 0x40bc(%rip), %rdi      # 0x95f5
leaq 0x4034(%rip), %rsi      # 0x9574
leaq 0x403a(%rip), %rcx      # 0x9581
movl $0x160, %edx            # imm = 0x160
callq 0x20d0
leaq 0x40af(%rip), %rdi      # 0x9607
leaq 0x4015(%rip), %rsi      # 0x9574
leaq 0x401b(%rip), %rcx      # 0x9581
movl $0x15d, %edx            # imm = 0x15D
callq 0x20d0
leaq 0x407e(%rip), %rdi      # 0x95f5
leaq 0x3ff6(%rip), %rsi      # 0x9574
leaq 0x3ffc(%rip), %rcx      # 0x9581
movl $0x148, %edx            # imm = 0x148
callq 0x20d0
leaq 0x405f(%rip), %rdi      # 0x95f5
leaq 0x3fd7(%rip), %rsi      # 0x9574
leaq 0x3fdd(%rip), %rcx      # 0x9581
movl $0x158, %edx            # imm = 0x158
callq 0x20d0