// File: /workspace/github_cpp_makefile_star2_O2/redpony[P]cpyp/./cpyp/mf_crp.h
// Function: std::pair<unsigned int, int> cpyp::mf_crp<2u, unsigned int, std::hash<unsigned int>>::decrement<cpyp::MT19937>(unsigned int const&, cpyp::MT19937&, double*)
std::pair<unsigned,int> decrement(const Dish& dish, Engine& eng, double* logq = nullptr) {
    crp_table_manager<NumFloors>& loc = dish_locs_[dish];
    assert(loc.num_customers());
    if (loc.num_customers() == 1) {
      update_llh_remove_customer_from_table_seating(1);
      unsigned floor = 0;
      for (; floor < NumFloors; ++floor)
        if (!loc.h[floor].empty()) break;
      assert(floor < NumFloors);
      
      dish_locs_.erase(dish);
      --num_tables_;
      --num_customers_;
      // q = 1 since this is the first customer
      return std::make_pair(floor, -1);
    } else {
      unsigned selected_table_postcount = 0;
      const std::pair<unsigned,int> delta = loc.remove_customer(eng, &selected_table_postcount);
      update_llh_remove_customer_from_table_seating(selected_table_postcount + 1);
      --num_customers_;
      if (delta.second) --num_tables_;

      if (logq) {
        double p_empty = (strength_ + num_tables_ * discount_);
        double p_share = (loc.num_customers() - loc.num_tables() * discount_);
        const double z = p_empty + p_share;
        p_empty /= z;
        p_share /= z;
        if (selected_table_postcount)
          *logq += log(p_share * (selected_table_postcount - discount_) /
                     (loc.num_customers() - loc.num_tables() * discount_));
        else
          *logq += log(p_empty);
      }
      return delta;
    }
  }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rcx, %r15
movq %rdx, %rbx
movq %rsi, %r13
movq %rdi, %r14
leaq 0x8(%rdi), %rbp
movq %rbp, %rdi
callq 0x79ca
movq %rax, %r12
movl (%rax), %eax
cmpl $0x1, %eax
je 0x479d
testl %eax, %eax
je 0x484d
leaq 0x4(%rsp), %r13
andl $0x0, (%r13)
movq %r12, %rdi
movq %rbx, %rsi
movq %r13, %rdx
callq 0x80a4
movq %rax, %rbx
movl (%r13), %esi
incl %esi
movq %r14, %rdi
callq 0x8004
decl 0x4(%r14)
movq %rbx, %rax
shrq $0x20, %rax
je 0x4730
decl (%r14)
testq %r15, %r15
je 0x481c
movl (%r14), %eax
cvtsi2sd %rax, %xmm0
movsd 0x40(%r14), %xmm1
mulsd %xmm1, %xmm0
addsd 0x48(%r14), %xmm0
movl (%r12), %eax
movl 0x4(%r12), %ecx
cvtsi2sd %rax, %xmm2
cvtsi2sd %rcx, %xmm3
mulsd %xmm1, %xmm3
subsd %xmm3, %xmm2
movapd %xmm0, %xmm3
addsd %xmm2, %xmm3
movl 0x4(%rsp), %eax
testl %eax, %eax
je 0x4809
movapd %xmm2, %xmm4
movl %eax, %eax
cvtsi2sd %rax, %xmm0
divsd %xmm3, %xmm4
subsd %xmm1, %xmm0
mulsd %xmm4, %xmm0
divsd %xmm2, %xmm0
jmp 0x480d
pushq $0x1
popq %rsi
movq %r14, %rdi
callq 0x8004
addq $0x81, %r12
xorl %ebx, %ebx
cmpq $0x2, %rbx
je 0x482e
cmpb $0x1, (%r12)
jne 0x47c9
movq -0x79(%r12), %rax
movq 0x18(%rax), %rax
jmp 0x47cf
movzbl -0x1(%r12), %eax
testq %rax, %rax
jne 0x47dd
incq %rbx
subq $-0x80, %r12
jmp 0x47b1
movq %rbp, %rdi
movq %r13, %rsi
callq 0x8144
movq (%r14), %xmm0
pcmpeqd %xmm1, %xmm1
paddd %xmm0, %xmm1
movq %xmm1, (%r14)
movabsq $-0x100000000, %rax     # imm = 0xFFFFFFFF00000000
orq %rax, %rbx
jmp 0x481c
divsd %xmm3, %xmm0
callq 0x2130
addsd (%r15), %xmm0
movsd %xmm0, (%r15)
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x50d5(%rip), %rdi      # 0x990a
leaq 0x514d(%rip), %rsi      # 0x9989
leaq 0x525b(%rip), %rcx      # 0x9a9e
movl $0xb1, %edx
callq 0x20d0
leaq 0x4f35(%rip), %rdi      # 0x9789
leaq 0x512e(%rip), %rsi      # 0x9989
leaq 0x523c(%rip), %rcx      # 0x9a9e
movl $0xab, %edx
callq 0x20d0