// 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>>::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, %r15
movq %rdx, %r12
movq %rdi, %rbx
fldz
xorl %eax, %eax
fldt (%r12,%rax)
fmull (%rcx)
faddp %st, %st(1)
addq $0x10, %rax
addq $0x8, %rcx
cmpq $0x20, %rax
jne 0x524d
fldl 0x3def(%rip)            # 0x9058
fld %st(1)
fstpt 0x14(%rsp)
fxch %st(1)
fucompi %st(1), %st
fstp %st(0)
ja 0x542a
leaq 0x8(%rbx), %rdi
callq 0x8206
movq %rax, %r14
movl (%rax), %eax
testl %eax, %eax
je 0x531f
movl (%rbx), %ecx
cvtsi2sd %rcx, %xmm0
movsd 0x40(%rbx), %xmm1
mulsd %xmm1, %xmm0
addsd 0x48(%rbx), %xmm0
movsd %xmm0, 0x30(%rsp)
fldt 0x14(%rsp)
fmull 0x30(%rsp)
fld %st(0)
fstpt 0x38(%rsp)
movl %eax, %eax
xorps %xmm0, %xmm0
cvtsi2sd %rax, %xmm0
movl 0x4(%r14), %eax
cvtsi2sd %rax, %xmm2
mulsd %xmm1, %xmm2
subsd %xmm2, %xmm0
movsd %xmm0, 0x28(%rsp)
faddl 0x28(%rsp)
fstpt 0x44(%rsp)
movq %r13, %rdi
callq 0x853e
fldt 0x44(%rsp)
fldt 0x38(%rsp)
fdivp %st, %st(1)
fxch %st(1)
fucompi %st(1), %st
fstp %st(0)
jbe 0x531f
movq 0x40(%rbx), %xmm0
movq %r14, %rdi
movq %r13, %rsi
callq 0x80e8
movq %rbx, %rdi
movl %eax, %esi
callq 0x8182
xorl %r15d, %r15d
jmp 0x5416
movq %r13, %rdi
callq 0x770d
xorpd %xmm1, %xmm1
addsd %xmm0, %xmm1
movsd %xmm1, 0x20(%rsp)
fldt 0x14(%rsp)
fmull 0x20(%rsp)
fldt (%r12)
fmull (%r15)
fsubrp %st, %st(1)
fldz
fucomi %st(1), %st
jae 0x5364
fldt 0x10(%r12)
fmull 0x8(%r15)
fsubrp %st, %st(2)
xorl %r15d, %r15d
fucompi %st(1), %st
fstp %st(0)
setae %r15b
jmp 0x536b
fstp %st(0)
fstp %st(0)
xorl %r15d, %r15d
movl %r15d, %eax
shll $0x7, %eax
leaq (%r14,%rax), %r12
addq $0x8, %r12
movl $0x1, 0x10(%rsp)
cmpb $0x0, 0x81(%r14,%rax)
je 0x539c
movq (%r12), %rdi
leaq 0x10(%rsp), %rsi
callq 0x6fe2
jmp 0x53f1
movzbl 0x78(%r12), %ecx
testq %rcx, %rcx
je 0x53d8
movl %r15d, %eax
shll $0x7, %eax
addq %r14, %rax
addq $0xc, %rax
movq %rcx, %rdx
cmpl $0x1, -0x4(%rax)
je 0x53f1
addq $0x8, %rax
decq %rdx
jne 0x53b7
movq %rcx, %rax
cmpb $0xe, %cl
jbe 0x53da
movq %r12, %rdi
callq 0x6ef2
jmp 0x538c
xorl %eax, %eax
incb %cl
movb %cl, 0x78(%r12)
leaq (%r12,%rax,8), %rax
addq $0x4, %rax
movq $0x1, -0x4(%rax)
incl (%rax)
movq (%r14), %xmm0
pcmpeqd %xmm1, %xmm1
psubd %xmm1, %xmm0
movq %xmm0, (%r14)
movq %rbx, %rdi
xorl %esi, %esi
callq 0x8182
incl (%rbx)
btsq $0x20, %r15
incl 0x4(%rbx)
movq %r15, %rax
addq $0x50, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
movq 0x7bbf(%rip), %rdi      # 0xcff0
leaq 0x45c7(%rip), %rsi      # 0x99ff
callq 0x21a0
fldt 0x14(%rsp)
fstpt (%rsp)
movq %rax, %rdi
callq 0x21d0
movq %rax, %rdi
callq 0x2090
callq 0x20d0
nop