// File: /workspace/github_cpp_makefile_star2_O1/lemire[P]validateutf8-experiments/benchmarks/random_utf8.cpp
// Function: RandomUTF8::generate(unsigned long)
std::vector<uint8_t> RandomUTF8::generate(size_t output_bytes) {
  std::vector<uint8_t> result;
  result.reserve(output_bytes);
  uint8_t candidate, head;
  while (result.size() < output_bytes) {
    switch (bytes_count(gen)) {
    case 0: // 1 byte
      candidate = val_7bit(gen);
      while (candidate == 0) { // though strictly speaking, a stream of nulls is
                               // UTF8, it tends to break some code
        candidate = val_7bit(gen);
      }
      result.push_back(candidate);
      break;
    case 1: // 2 bytes
      candidate = 0xc0 | val_5bit(gen);
      while (candidate < 0xC2) {
        candidate = 0xc0 | val_5bit(gen);
      }
      result.push_back(candidate);
      result.push_back(0x80 | val_6bit(gen));
      break;
    case 2: // 3 bytes
      head = 0xe0 | val_4bit(gen);
      result.push_back(head);
      candidate = 0x80 | val_6bit(gen);
      if (head == 0xE0) {
        while (candidate < 0xA0) {
          candidate = 0x80 | val_6bit(gen);
        }
      } else if (head == 0xED) {
        while (candidate > 0x9F) {
          candidate = 0x80 | val_6bit(gen);
        }
      }
      result.push_back(candidate);
      result.push_back(0x80 | val_6bit(gen));
      break;
    case 3: // 4 bytes
      head = 0xf0 | val_3bit(gen);
      while (head > 0xF4) {
        head = 0xf0 | val_3bit(gen);
      }
      result.push_back(head);
      candidate = 0x80 | val_6bit(gen);
      if (head == 0xF0) {
        while (candidate < 0x90) {
          candidate = 0x80 | val_6bit(gen);
        }
      } else if (head == 0xF4) {
        while (candidate > 0x8F) {
          candidate = 0x80 | val_6bit(gen);
        }
      }
      result.push_back(candidate);
      result.push_back(0x80 | val_6bit(gen));
      result.push_back(0x80 | val_6bit(gen));
      break;
    }
  }
  result.push_back(0); // EOS for scalar code

  return result;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rdx, %r14
movq %rsi, %r15
movq %rdi, %rbx
xorps %xmm0, %xmm0
movups %xmm0, (%rdi)
movq $0x0, 0x10(%rdi)
movq %rdx, %rsi
callq 0x7018
movq 0x8(%rbx), %rax
subq (%rbx), %rax
movq %r14, 0x20(%rsp)
cmpq %r14, %rax
jae 0x6f74
leaq 0x1388(%r15), %rax
movq %rax, 0x18(%rsp)
leaq 0x13c0(%r15), %r13
leaq 0x13ba(%r15), %rbp
leaq 0x13be(%r15), %rax
movq %rax, 0x10(%rsp)
leaq 0x13bc(%r15), %r14
leaq 0x13b8(%r15), %r12
movq 0x18(%rsp), %rdi
movq %r15, %rsi
movq %rdi, %rdx
callq 0x74d8
cmpl $0x3, %eax
ja 0x6f62
movl %eax, %eax
leaq 0x1eb0(%rip), %rcx      # 0x8b44
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq %r12, %rdi
movq %r15, %rsi
movq %r12, %rdx
callq 0x77c4
movb %al, 0x9(%rsp)
testb %al, %al
jne 0x6d5f
movq %r12, %rdi
movq %r15, %rsi
movq %r12, %rdx
callq 0x77c4
jmp 0x6cab
movq 0x10(%rsp), %rdi
movq %r15, %rsi
movq %rdi, %rdx
callq 0x77c4
orb $-0x20, %al
movb %al, 0xa(%rsp)
movq 0x8(%rbx), %rsi
cmpq 0x10(%rbx), %rsi
je 0x6d91
movb %al, (%rsi)
incq 0x8(%rbx)
jmp 0x6d9e
movq %r13, %rdi
movq %r15, %rsi
movq %r13, %rdx
callq 0x77c4
orb $-0x10, %al
movb %al, 0xa(%rsp)
cmpb $-0xb, %al
jb 0x6d46
movq %r13, %rdi
movq %r15, %rsi
movq %r13, %rdx
callq 0x77c4
jmp 0x6d04
movq %r14, %rdi
movq %r15, %rsi
movq %r14, %rdx
callq 0x77c4
orb $-0x40, %al
movb %al, 0x9(%rsp)
cmpb $-0x3f, %al
ja 0x6d78
movq %r14, %rdi
movq %r15, %rsi
movq %r14, %rdx
callq 0x77c4
jmp 0x6d2c
movq 0x8(%rbx), %rsi
cmpq 0x10(%rbx), %rsi
je 0x6e4c
movb %al, (%rsi)
incq 0x8(%rbx)
jmp 0x6e59
movq 0x8(%rbx), %rsi
cmpq 0x10(%rbx), %rsi
je 0x6ed4
movb %al, (%rsi)
incq 0x8(%rbx)
jmp 0x6f62
movq 0x8(%rbx), %rsi
cmpq 0x10(%rbx), %rsi
je 0x6ee3
movb %al, (%rsi)
incq 0x8(%rbx)
jmp 0x6ef0
movq %rbx, %rdi
leaq 0xa(%rsp), %rdx
callq 0x7892
movq %rbp, %rdi
movq %r15, %rsi
movq %rbp, %rdx
callq 0x77c4
orb $-0x80, %al
movb %al, 0x9(%rsp)
movb 0xa(%rsp), %cl
cmpb $-0x20, %cl
jne 0x6ddc
cmpb $-0x61, 0x9(%rsp)
ja 0x6e03
movq %rbp, %rdi
movq %r15, %rsi
movq %rbp, %rdx
callq 0x77c4
orb $-0x80, %al
movb %al, 0x9(%rsp)
cmpb $-0x60, %al
jb 0x6dc2
jmp 0x6e03
cmpb $-0x13, %cl
setne %cl
cmpb $-0x60, %al
setb %al
orb %cl, %al
jne 0x6e03
movq %rbp, %rdi
movq %r15, %rsi
movq %rbp, %rdx
callq 0x77c4
orb $-0x80, %al
movb %al, 0x9(%rsp)
cmpb $-0x61, %al
ja 0x6deb
movq 0x8(%rbx), %rsi
cmpq 0x10(%rbx), %rsi
je 0x6e19
movb 0x9(%rsp), %al
movb %al, (%rsi)
incq 0x8(%rbx)
jmp 0x6e26
movq %rbx, %rdi
leaq 0x9(%rsp), %rdx
callq 0x7892
movq %rbp, %rdi
movq %r15, %rsi
movq %rbp, %rdx
callq 0x77c4
orb $-0x80, %al
movb %al, 0xd(%rsp)
movq %rbx, %rdi
leaq 0xd(%rsp), %rsi
callq 0x7984
jmp 0x6f62
movq %rbx, %rdi
leaq 0xa(%rsp), %rdx
callq 0x7892
movq %rbp, %rdi
movq %r15, %rsi
movq %rbp, %rdx
callq 0x77c4
orb $-0x80, %al
movb %al, 0x9(%rsp)
movb 0xa(%rsp), %cl
cmpb $-0x10, %cl
jne 0x6e97
cmpb $-0x71, 0x9(%rsp)
ja 0x6ebe
movq %rbp, %rdi
movq %r15, %rsi
movq %rbp, %rdx
callq 0x77c4
orb $-0x80, %al
movb %al, 0x9(%rsp)
cmpb $-0x70, %al
jb 0x6e7d
jmp 0x6ebe
cmpb $-0xc, %cl
setne %cl
cmpb $-0x70, %al
setb %al
orb %cl, %al
jne 0x6ebe
movq %rbp, %rdi
movq %r15, %rsi
movq %rbp, %rdx
callq 0x77c4
orb $-0x80, %al
movb %al, 0x9(%rsp)
cmpb $-0x71, %al
ja 0x6ea6
movq 0x8(%rbx), %rsi
cmpq 0x10(%rbx), %rsi
je 0x6f13
movb 0x9(%rsp), %al
movb %al, (%rsi)
incq 0x8(%rbx)
jmp 0x6f20
movq %rbx, %rdi
leaq 0x9(%rsp), %rdx
callq 0x7892
jmp 0x6f62
movq %rbx, %rdi
leaq 0x9(%rsp), %rdx
callq 0x7892
movq %rbp, %rdi
movq %r15, %rsi
movq %rbp, %rdx
callq 0x77c4
orb $-0x80, %al
movb %al, 0xe(%rsp)
movq %rbx, %rdi
leaq 0xe(%rsp), %rsi
callq 0x7984
jmp 0x6f62
movq %rbx, %rdi
leaq 0x9(%rsp), %rdx
callq 0x7892
movq %rbp, %rdi
movq %r15, %rsi
movq %rbp, %rdx
callq 0x77c4
orb $-0x80, %al
movb %al, 0xc(%rsp)
movq %rbx, %rdi
leaq 0xc(%rsp), %rsi
callq 0x7984
movq %rbp, %rdi
movq %r15, %rsi
movq %rbp, %rdx
callq 0x77c4
orb $-0x80, %al
movb %al, 0xb(%rsp)
movq %rbx, %rdi
leaq 0xb(%rsp), %rsi
callq 0x7984
movq 0x8(%rbx), %rax
subq (%rbx), %rax
cmpq 0x20(%rsp), %rax
jb 0x6c72
leaq 0xf(%rsp), %rsi
movb $0x0, (%rsi)
movq %rbx, %rdi
callq 0x7984
movq %rbx, %rax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x6fb0
jmp 0x6fb0
jmp 0x6fb0
jmp 0x6fb0
jmp 0x6fb0
jmp 0x6fb0
jmp 0x6fb0
jmp 0x6fb0
jmp 0x6fb0
jmp 0x6fb0
jmp 0x6fb0
jmp 0x6fb0
jmp 0x6fb0
movq %rax, %r14
movq (%rbx), %rdi
testq %rdi, %rdi
je 0x6fc7
movq 0x10(%rbx), %rsi
subq %rdi, %rsi
callq 0x2130
movq %r14, %rdi
callq 0x21b0
nop