// File: /workspace/github_cpp_makefile_star2_O3/ef-gy[P]libefgy/include/ef.gy/markov.h
// Function: efgy::markov::chain<char, 2u, std::mersenne_twister_engine<unsigned long, 32ul, 624ul, 397ul, 31ul, 2567483615ul, 11ul, 4294967295ul, 7ul, 2636928640ul, 15ul, 4022730752ul, 18ul, 1812433253ul>, unsigned long>::operator()()
output operator()(void) {
    output rv;
    memory m;

    for (typename std::map<memory, transition>::iterator it =
             transitions.find(m);
         it != transitions.end(); it = transitions.find(m)) {
      counter c = std::accumulate(
          it->second.begin(), it->second.end(), 0,
          [](const counter &v, const std::pair<std::optional<T>, counter> &t)
              -> counter { return v + t.second; });

      c = RNG() % c;

      for (const std::pair<std::optional<T>, counter> &t : it->second) {
        if (c > t.second) {
          c -= t.second;
        } else if (t.first) {
          rv.push_back(*t.first);

          std::transform(
              m.begin() + 1, m.end(), m.begin(),
              [](std::optional<T> &i) -> std::optional<T> { return i; });

          *(m.end() - 1) = t.first;
          break;
        } else {
          return rv;
        }
      }
    }

    throw std::runtime_error("impossible memory state in markov chain.");

    return output();
  }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rsi, %r14
movq %rdi, 0x30(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0x10(%rsp)
movq $0x0, 0x20(%rsp)
xorl %eax, %eax
leaq 0xc(%rsp), %rsi
movb %al, 0x1(%rsi)
movb %al, 0x3(%rsi)
leaq 0x1388(%r14), %r15
movq %r15, %rdi
callq 0x15a40
movq %rax, %rbx
leaq 0x1390(%r14), %r13
cmpq %r13, %rbx
je 0x159d6
movq 0x40(%rbx), %rax
leaq 0x30(%rbx), %rbp
cmpq %rbp, %rax
je 0x1591c
xorl %r12d, %r12d
addl 0x28(%rax), %r12d
movq %rax, %rdi
callq 0x41b0
cmpq %rbp, %rax
jne 0x15906
movslq %r12d, %r12
jmp 0x1591f
xorl %r12d, %r12d
movq %r14, %rdi
callq 0x14f1c
movq 0x40(%rbx), %rdi
cmpq %rbp, %rdi
je 0x1599c
xorl %edx, %edx
divq %r12
movq %rdx, %rbx
movzwl 0x20(%rdi), %eax
movw %ax, 0x38(%rsp)
movq 0x28(%rdi), %rcx
movq %rcx, 0x40(%rsp)
subq %rcx, %rbx
jbe 0x1595e
callq 0x41b0
movq %rax, %rdi
cmpq %rbp, %rax
jne 0x15938
jmp 0x1599c
btl $0x8, %eax
jae 0x159b1
movq 0x18(%rsp), %rsi
cmpq 0x20(%rsp), %rsi
je 0x15979
movb %al, (%rsi)
incq 0x18(%rsp)
jmp 0x15988
leaq 0x10(%rsp), %rdi
leaq 0x38(%rsp), %rdx
callq 0x150fe
movzwl 0xe(%rsp), %eax
movw %ax, 0xc(%rsp)
movzwl 0x38(%rsp), %eax
movw %ax, 0xe(%rsp)
movq %r15, %rdi
leaq 0xc(%rsp), %rsi
callq 0x15a40
movq %rax, %rbx
jmp 0x158ed
movaps 0x10(%rsp), %xmm0
movq 0x30(%rsp), %rax
movups %xmm0, (%rax)
movq 0x20(%rsp), %rcx
movq %rcx, 0x10(%rax)
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0x10, %edi
callq 0x4110
movq %rax, %r14
leaq 0x211f(%rip), %rsi      # 0x17b09
movq %rax, %rdi
callq 0x40d0
movq 0xb5f7(%rip), %rsi      # 0x20ff0
movq 0xb598(%rip), %rdx      # 0x20f98
movq %r14, %rdi
callq 0x43a0
jmp 0x15a1d
jmp 0x15a1d
jmp 0x15a1d
movq %rax, %rbx
movq %r14, %rdi
callq 0x41d0
jmp 0x15a20
jmp 0x15a1d
movq %rax, %rbx
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x15a37
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x4250
movq %rbx, %rdi
callq 0x43c0
nop