// File: /workspace/github_cpp_makefile_star2_O1/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 $0x68, %rsp
movq %rsi, %r13
movq %rdi, %r14
xorps %xmm0, %xmm0
movaps %xmm0, 0x20(%rsp)
movq $0x0, 0x30(%rsp)
movl $0x1, %eax
movb $0x0, 0x4(%rsp,%rax)
addq $0x2, %rax
cmpq $0x5, %rax
jne 0x15af4
leaq 0x1388(%r13), %rdi
leaq 0x4(%rsp), %rsi
movq %rdi, 0x58(%rsp)
callq 0x15d62
movq %rax, %rbx
leaq 0x1390(%r13), %rax
movq %rax, 0x60(%rsp)
movq (%r14), %rax
movq %rax, 0x10(%rsp)
movq %r14, %rax
movq 0x8(%r14), %r14
movq %rax, 0x18(%rsp)
movq 0x10(%rax), %rax
movq %rax, 0x8(%rsp)
movq %r13, 0x50(%rsp)
cmpq 0x60(%rsp), %rbx
je 0x15cc1
movq 0x40(%rbx), %rax
leaq 0x30(%rbx), %r15
cmpq %r15, %rax
je 0x15b79
xorl %ebp, %ebp
addl 0x28(%rax), %ebp
movq %rax, %rdi
callq 0x41b0
cmpq %r15, %rax
jne 0x15b64
movslq %ebp, %r12
jmp 0x15b7c
xorl %r12d, %r12d
movq %r13, %rdi
callq 0x15028
movq 0x40(%rbx), %rbx
cmpq %r15, %rbx
je 0x15c61
xorl %edx, %edx
divq %r12
movq %rdx, %r12
movq %rdx, %r13
movzwl 0x20(%rbx), %eax
movw %ax, 0x40(%rsp)
movq 0x28(%rbx), %rbp
movq %rbp, 0x48(%rsp)
subq %rbp, %r13
jbe 0x15bb7
xorl %eax, %eax
jmp 0x15c33
cmpb $0x1, 0x41(%rsp)
jne 0x15bd7
movq 0x28(%rsp), %rsi
cmpq 0x30(%rsp), %rsi
je 0x15c08
movb 0x40(%rsp), %al
movb %al, (%rsi)
incq 0x28(%rsp)
jmp 0x15c17
movq 0x20(%rsp), %rax
movq %rax, 0x10(%rsp)
movq 0x28(%rsp), %r14
movq 0x30(%rsp), %rax
movq %rax, 0x8(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0x20(%rsp)
movq $0x0, 0x30(%rsp)
movl $0x1, %eax
jmp 0x15c30
leaq 0x20(%rsp), %rdi
leaq 0x40(%rsp), %rdx
callq 0x151d6
movzwl 0x6(%rsp), %eax
movw %ax, 0x4(%rsp)
movzwl 0x40(%rsp), %eax
movw %ax, 0x6(%rsp)
movl $0x5, %eax
movq %r12, %r13
cmpq %rbp, %r12
jbe 0x15c54
movq %rbx, %rdi
callq 0x41b0
movq %rax, %rbx
movq %r13, %r12
cmpq %r15, %rax
jne 0x15b9c
movl $0x5, %eax
cmpl $0x5, %eax
sete %al
movq 0x50(%rsp), %r13
jmp 0x15c63
movb $0x1, %al
testb %al, %al
je 0x15c7e
movq 0x58(%rsp), %rdi
leaq 0x4(%rsp), %rsi
callq 0x15d62
movq %rax, %rbx
jmp 0x15b4a
movq 0x18(%rsp), %rbx
movq %r14, 0x8(%rbx)
movq 0x8(%rsp), %rax
movq %rax, 0x10(%rbx)
movq 0x10(%rsp), %rax
movq %rax, (%rbx)
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0x15caf
movq 0x30(%rsp), %rsi
subq %rdi, %rsi
callq 0x4250
movq %rbx, %rax
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x18(%rsp), %rax
movq %r14, 0x8(%rax)
movq 0x8(%rsp), %rcx
movq %rcx, 0x10(%rax)
movq 0x10(%rsp), %rcx
movq %rcx, (%rax)
movl $0x10, %edi
callq 0x4110
movq %rax, %r14
leaq 0x1dea(%rip), %rsi      # 0x17ad9
movq %rax, %rdi
callq 0x40d0
movq 0xb2f2(%rip), %rsi      # 0x20ff0
movq 0xb293(%rip), %rdx      # 0x20f98
movq %r14, %rdi
callq 0x43a0
jmp 0x15d0f
movq %rax, %rbx
jmp 0x15d42
movq %rax, %rbx
movq %r14, %rdi
callq 0x41d0
jmp 0x15d42
jmp 0x15d25
jmp 0x15d25
movq %rax, %rbx
movq 0x18(%rsp), %rax
movq %r14, 0x8(%rax)
movq 0x8(%rsp), %rcx
movq %rcx, 0x10(%rax)
movq 0x10(%rsp), %rcx
movq %rcx, (%rax)
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0x15d59
movq 0x30(%rsp), %rsi
subq %rdi, %rsi
callq 0x4250
movq %rbx, %rdi
callq 0x43c0
nop