// File: 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:
subq $0x78, %rsp
movq %rdi, 0x68(%rsp)
movq %rsi, 0x60(%rsp)
movq %rdx, 0x58(%rsp)
movq %rcx, 0x50(%rsp)
movq 0x68(%rsp), %rdi
movq %rdi, 0x18(%rsp)
addq $0x8, %rdi
movq 0x60(%rsp), %rsi
callq 0x12450
movq %rax, 0x48(%rsp)
movq 0x48(%rsp), %rdi
callq 0x12480
cmpl $0x0, %eax
je 0x7076
jmp 0x7095
leaq 0xe74c(%rip), %rdi      # 0x157c9
leaq 0xe9b9(%rip), %rsi      # 0x15a3d
movl $0xab, %edx
leaq 0xeac2(%rip), %rcx      # 0x15b52
callq 0x20e0
movq 0x48(%rsp), %rdi
callq 0x12480
cmpl $0x1, %eax
jne 0x7165
movq 0x18(%rsp), %rdi
movl $0x1, %esi
callq 0x13cc0
movl $0x0, 0x44(%rsp)
cmpl $0x2, 0x44(%rsp)
jae 0x70f4
movq 0x48(%rsp), %rdi
addq $0x8, %rdi
movl 0x44(%rsp), %eax
shlq $0x7, %rax
addq %rax, %rdi
callq 0x13de0
testb $0x1, %al
jne 0x70e5
jmp 0x70f4
jmp 0x70e7
movl 0x44(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x44(%rsp)
jmp 0x70bf
cmpl $0x2, 0x44(%rsp)
jae 0x70fd
jmp 0x711c
leaq 0xe8ba(%rip), %rdi      # 0x159be
leaq 0xe932(%rip), %rsi      # 0x15a3d
movl $0xb1, %edx
leaq 0xea3b(%rip), %rcx      # 0x15b52
callq 0x20e0
movq 0x18(%rsp), %rdi
addq $0x8, %rdi
movq 0x60(%rsp), %rsi
callq 0x13e00
movq 0x18(%rsp), %rax
movl (%rax), %ecx
addl $-0x1, %ecx
movl %ecx, (%rax)
movl 0x4(%rax), %ecx
addl $-0x1, %ecx
movl %ecx, 0x4(%rax)
movl $0xffffffff, 0x40(%rsp) # imm = 0xFFFFFFFF
leaq 0x44(%rsp), %rdi
leaq 0x40(%rsp), %rsi
callq 0x12760
movq %rax, 0x70(%rsp)
jmp 0x7348
movl $0x0, 0x3c(%rsp)
movq 0x48(%rsp), %rdi
movq 0x58(%rsp), %rsi
leaq 0x3c(%rsp), %rdx
callq 0x13e30
movq 0x18(%rsp), %rdi
movq %rax, 0x70(%rsp)
movl 0x3c(%rsp), %esi
addl $0x1, %esi
callq 0x13cc0
movq 0x18(%rsp), %rax
movl 0x4(%rax), %ecx
addl $-0x1, %ecx
movl %ecx, 0x4(%rax)
cmpl $0x0, 0x74(%rsp)
je 0x71b8
movq 0x18(%rsp), %rax
movl (%rax), %ecx
addl $-0x1, %ecx
movl %ecx, (%rax)
cmpq $0x0, 0x50(%rsp)
je 0x7346
movq 0x18(%rsp), %rax
movsd 0x48(%rax), %xmm1
movl (%rax), %ecx
cvtsi2sd %rcx, %xmm0
movsd 0x40(%rax), %xmm2
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, 0x30(%rsp)
movq 0x48(%rsp), %rdi
callq 0x12480
movl %eax, %eax
cvtsi2sd %rax, %xmm0
movsd %xmm0, 0x10(%rsp)
movq 0x48(%rsp), %rdi
callq 0x122f0
movsd 0x10(%rsp), %xmm1
movl %eax, %ecx
movq 0x18(%rsp), %rax
movl %ecx, %ecx
cvtsi2sd %rcx, %xmm0
movsd 0x40(%rax), %xmm2
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, 0x28(%rsp)
movsd 0x30(%rsp), %xmm0
addsd 0x28(%rsp), %xmm0
movsd %xmm0, 0x20(%rsp)
movsd 0x20(%rsp), %xmm1
movsd 0x30(%rsp), %xmm0
divsd %xmm1, %xmm0
movsd %xmm0, 0x30(%rsp)
movsd 0x20(%rsp), %xmm1
movsd 0x28(%rsp), %xmm0
divsd %xmm1, %xmm0
movsd %xmm0, 0x28(%rsp)
cmpl $0x0, 0x3c(%rsp)
je 0x732c
movq 0x18(%rsp), %rax
movsd 0x28(%rsp), %xmm0
movl 0x3c(%rsp), %ecx
cvtsi2sd %rcx, %xmm1
movsd 0x40(%rax), %xmm2
subsd %xmm2, %xmm1
mulsd %xmm1, %xmm0
movsd %xmm0, 0x8(%rsp)
movq 0x48(%rsp), %rdi
callq 0x12480
movl %eax, %eax
cvtsi2sd %rax, %xmm0
movsd %xmm0, (%rsp)
movq 0x48(%rsp), %rdi
callq 0x122f0
movsd (%rsp), %xmm2
movsd 0x8(%rsp), %xmm0
movl %eax, %ecx
movq 0x18(%rsp), %rax
movl %ecx, %ecx
cvtsi2sd %rcx, %xmm1
movsd 0x40(%rax), %xmm3
movq %xmm1, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm1
mulsd %xmm3, %xmm1
addsd %xmm2, %xmm1
divsd %xmm1, %xmm0
callq 0x2130
movq 0x50(%rsp), %rax
addsd (%rax), %xmm0
movsd %xmm0, (%rax)
jmp 0x7344
movsd 0x30(%rsp), %xmm0
callq 0x2130
movq 0x50(%rsp), %rax
addsd (%rax), %xmm0
movsd %xmm0, (%rax)
jmp 0x7346
jmp 0x7348
movq 0x70(%rsp), %rax
addq $0x78, %rsp
retq
nopw %cs:(%rax,%rax)
nopl (%rax)