// File: /workspace/github_cpp_makefile_star2_O3/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 0x8206
movq %rax, %r12
movl (%rax), %eax
cmpl $0x1, %eax
je 0x5542
testl %eax, %eax
je 0x55fa
leaq 0x4(%rsp), %r13
movl $0x0, (%r13)
movq %r12, %rdi
movq %rbx, %rsi
movq %r13, %rdx
callq 0x8826
movq %rax, %rbx
movl (%r13), %esi
incl %esi
movq %r14, %rdi
callq 0x8784
decl 0x4(%r14)
movq %rbx, %rax
shrq $0x20, %rax
je 0x54cf
decl (%r14)
testq %r15, %r15
je 0x55e8
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 0x55d5
movapd %xmm2, %xmm4
movl %eax, %eax
xorps %xmm0, %xmm0
cvtsi2sd %rax, %xmm0
divsd %xmm3, %xmm4
subsd %xmm1, %xmm0
mulsd %xmm4, %xmm0
divsd %xmm2, %xmm0
jmp 0x55d9
movq %r14, %rdi
movl $0x1, %esi
callq 0x8784
addq $0x8, %r12
movb $0x1, %al
xorl %ebx, %ebx
movq %rbx, %rdx
shlq $0x7, %rdx
leaq (%r12,%rdx), %rcx
cmpb $0x1, 0x79(%r12,%rdx)
jne 0x5573
movq (%rcx), %rcx
movq 0x18(%rcx), %rcx
jmp 0x5577
movzbl 0x78(%rcx), %ecx
testq %rcx, %rcx
jne 0x55a9
movl $0x1, %ebx
testb $0x1, %al
movl $0x0, %eax
jne 0x5557
leaq 0x43a8(%rip), %rdi      # 0x9939
leaq 0x43b3(%rip), %rsi      # 0x994b
leaq 0x446f(%rip), %rcx      # 0x9a0e
movl $0xb1, %edx
callq 0x20e0
movq %rbp, %rdi
movq %r13, %rsi
callq 0x8950
movq (%r14), %xmm0
pcmpeqd %xmm1, %xmm1
paddd %xmm0, %xmm1
movq %xmm1, (%r14)
movabsq $-0x100000000, %rax     # imm = 0xFFFFFFFF00000000
orq %rax, %rbx
jmp 0x55e8
divsd %xmm3, %xmm0
callq 0x2150
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 0x41b7(%rip), %rdi      # 0x97b8
leaq 0x4343(%rip), %rsi      # 0x994b
leaq 0x43ff(%rip), %rcx      # 0x9a0e
movl $0xab, %edx
callq 0x20e0
nop