// File: /workspace/github_cpp_makefile_star2_O1/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 0x52c9
fldl 0x4d73(%rip)            # 0xa058
fld %st(1)
fstpt 0x14(%rsp)
fxch %st(1)
fucompi %st(1), %st
fstp %st(0)
ja 0x54cc
leaq 0x8(%rbx), %rdi
callq 0x83b2
movq %rax, %r14
movl (%rax), %eax
testl %eax, %eax
je 0x539b
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 0x8700
fldt 0x44(%rsp)
fldt 0x38(%rsp)
fdivp %st, %st(1)
fxch %st(1)
fucompi %st(1), %st
fstp %st(0)
jbe 0x539b
movq 0x40(%rbx), %xmm0
movq %r14, %rdi
movq %r13, %rsi
callq 0x8294
movq %rbx, %rdi
movl %eax, %esi
callq 0x832e
xorl %r15d, %r15d
jmp 0x54ab
movq %r13, %rdi
callq 0x78bf
xorpd %xmm1, %xmm1
addsd %xmm0, %xmm1
movsd %xmm1, 0x20(%rsp)
fldt 0x14(%rsp)
fmull 0x20(%rsp)
xorl %eax, %eax
fldz
fldt (%r12)
fmull (%r15,%rax,8)
fsubrp %st, %st(2)
fucomi %st(1), %st
jae 0x53df
addq $0x10, %r12
incq %rax
cmpl $0x1, %eax
je 0x53bd
fstp %st(1)
fstp %st(0)
xorl %eax, %eax
jmp 0x53e3
fstp %st(1)
fstp %st(0)
movl %eax, %r15d
movq %r15, %rax
shlq $0x7, %rax
leaq (%r14,%rax), %r12
addq $0x8, %r12
movl $0x1, 0x10(%rsp)
cmpb $0x0, 0x81(%r14,%rax)
je 0x5418
movq (%r12), %rdi
leaq 0x10(%rsp), %rsi
callq 0x7126
jmp 0x5486
movzbl 0x78(%r12), %ecx
testq %rcx, %rcx
setne %dl
je 0x5465
cmpl $0x1, (%r12)
jne 0x5433
movb $0x1, %dl
xorl %eax, %eax
jmp 0x5459
leaq (%rax,%r14), %rdx
addq $0x10, %rdx
leaq -0x1(%rcx), %rsi
xorl %edi, %edi
cmpq %rdi, %rsi
je 0x5463
leaq 0x1(%rdi), %rax
cmpl $0x1, (%rdx,%rdi,8)
movq %rax, %rdi
jne 0x5441
cmpq %rcx, %rax
setb %dl
leaq (%r12,%rax,8), %rax
addq $0x4, %rax
jmp 0x5465
xorl %edx, %edx
testb %dl, %dl
jne 0x5486
cmpb $0xe, %cl
ja 0x54bf
leal 0x1(%rcx), %eax
movb %al, 0x78(%r12)
leaq (%r12,%rcx,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 0x832e
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 %r12, %rdi
callq 0x7036
jmp 0x5408
movq 0x8b1d(%rip), %rdi      # 0xdff0
leaq 0x5525(%rip), %rsi      # 0xa9ff
callq 0x21a0
fldt 0x14(%rsp)
fstpt (%rsp)
movq %rax, %rdi
callq 0x21d0
movq %rax, %rdi
callq 0x2090
callq 0x20d0
nop