// 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>>::increment<long double*, double*, cpyp::MT19937>(unsigned int const&, long double*, double*, cpyp::MT19937&)
std::pair<unsigned,int> increment(const Dish& dish, InputIterator p0i, InputIterator2 lambdas, Engine& eng) {
    typedef decltype(*p0i + 0.0) F;

    const F marginal_p0 = std::inner_product(p0i, p0i + NumFloors, lambdas, F(0.0));
    if (marginal_p0 > F(1.000001)) {
      std::cerr << "bad marginal: " << marginal_p0 << std::endl;
      abort();
    }

    crp_table_manager<NumFloors>& loc = dish_locs_[dish];
    bool share_table = false;
    if (loc.num_customers()) {
      const F p_empty = F(strength_ + num_tables_ * discount_) * marginal_p0;
      const F p_share = F(loc.num_customers() - loc.num_tables() * discount_);
      share_table = sample_bernoulli(p_empty, p_share, eng);
    }

    unsigned floor = 0;
    if (share_table) {
      unsigned n = loc.share_table(discount_, eng);
      update_llh_add_customer_to_table_seating(n);
    } else {
      if (NumFloors > 1) { // sample floor
        F r = F(sample_uniform01<double>(eng)) * marginal_p0;
        for (unsigned i = 0; i < NumFloors; ++i) {
          r -= (*p0i) * (*lambdas);
          ++p0i;
          ++lambdas;
          if (r <= F(0.0)) { floor = i; break; }
        }
      }
      loc.create_table(floor);
      update_llh_add_customer_to_table_seating(0);
      ++num_tables_;
    }
    ++num_customers_;
    return std::make_pair(floor, share_table ? 0 : 1);
  }

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x50, %rsp
movq %r8, %r13
movq %rcx, %r14
movq %rdx, %r15
movq %rsi, %r12
movq %rdi, %rbx
leaq 0x20(%rdx), %rsi
fldz
fstpt (%rsp)
movq %rdx, %rdi
movq %rcx, %rdx
callq 0x781c
fldl 0x4adc(%rip)            # 0x9058
fld %st(1)
fstpt 0x2c(%rsp)
fxch %st(1)
fucompi %st(1), %st
fstp %st(0)
ja 0x468f
leaq 0x8(%rbx), %rdi
movq %r12, %rsi
callq 0x79ca
movq %rax, %r12
movl (%rax), %eax
testl %eax, %eax
je 0x461a
movl (%rbx), %ecx
cvtsi2sd %rcx, %xmm0
movsd 0x40(%rbx), %xmm1
mulsd %xmm1, %xmm0
addsd 0x48(%rbx), %xmm0
movsd %xmm0, 0x48(%rsp)
fldt 0x2c(%rsp)
fmull 0x48(%rsp)
movl %eax, %eax
cvtsi2sd %rax, %xmm0
movl 0x4(%r12), %eax
cvtsi2sd %rax, %xmm2
mulsd %xmm1, %xmm2
subsd %xmm2, %xmm0
movsd %xmm0, 0x40(%rsp)
fldl 0x40(%rsp)
fstpt 0x10(%rsp)
fstpt (%rsp)
movq %r13, %rdi
callq 0x7836
testl %eax, %eax
je 0x461a
movsd 0x40(%rbx), %xmm0
movq %r12, %rdi
movq %r13, %rsi
callq 0x786c
movq %rbx, %rdi
movl %eax, %esi
callq 0x78fc
xorl %eax, %eax
jmp 0x467e
movq %r13, %rdi
callq 0x427a
movsd %xmm0, 0x38(%rsp)
fldt 0x2c(%rsp)
fmull 0x38(%rsp)
xorl %r13d, %r13d
xorl %eax, %eax
fldz
cmpl $0x2, %eax
je 0x4652
fldt (%r15)
fmull (%r14,%rax,8)
fsubrp %st, %st(2)
fucomi %st(1), %st
jae 0x4658
addq $0x10, %r15
incq %rax
jmp 0x4637
fstp %st(1)
fstp %st(0)
jmp 0x465f
fstp %st(1)
fstp %st(0)
movl %eax, %r13d
movq %r12, %rdi
movl %r13d, %esi
callq 0x797a
movq %rbx, %rdi
xorl %esi, %esi
callq 0x78fc
incl (%rbx)
movl %r13d, %eax
btsq $0x20, %rax
incl 0x4(%rbx)
addq $0x50, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
movq 0x995a(%rip), %rdi      # 0xdff0
leaq 0x53a0(%rip), %rsi      # 0x9a3d
callq 0x2170
fldt 0x2c(%rsp)
fstpt (%rsp)
movq %rax, %rdi
callq 0x2190
movq %rax, %rdi
callq 0x2080
callq 0x20c0