// File: /workspace/github_cpp_makefile_star2_O2/WojciechMula[P]utf16utf8/benchmarks/benchmark_from_utf8.cpp
// Function: Benchmark::run_from_utf8(RandomUTF8&, unsigned long)
void run_from_utf8(RandomUTF8& generator, size_t repeat) {

        const auto UTF8 = generator.generate(size);
        size_t volume = UTF8.size() * sizeof(UTF8[0]);

        std::vector<uint16_t> scalar_out;
        std::vector<uint16_t> sse_out;
        std::vector<uint16_t> pext_out;
        scalar_out.resize(4 * size + 32);
        sse_out.resize(4 * size + 32);
        pext_out.resize(4 * size + 32);

        auto scalar = [&UTF8, &scalar_out]() {
            utf8_to_utf16(UTF8.data(), scalar_out.data());
        };

        auto scalar_utf8lib = [&UTF8, &scalar_out]() {
            scalar_out.clear();
            utf8::utf8to16(UTF8.begin(), UTF8.end(), back_inserter(scalar_out));
        };

        auto sse = [&UTF8, &sse_out, size=size]() {
            sse_convert_valid_utf8_to_utf16_lemire(UTF8.data(), size, sse_out.data());
        };

        auto pext = [&UTF8, &pext_out, size=size]() {
            pext_convert_utf8_to_utf16(UTF8.data(), size, pext_out.data());
        };

        RUN("scalar", scalar);
        RUN("scalar_utf8lib", scalar_utf8lib);
        RUN("SSE",    sse);
        RUN("PEXT",   pext);
    }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x238, %rsp            # imm = 0x238
movq %rdx, %rbp
movq (%rdi), %rdx
leaq 0x138(%rsp), %r15
movq %rdi, %rbx
movq %r15, %rdi
callq 0x3da8
movq 0x8(%r15), %rax
vxorpd %xmm0, %xmm0, %xmm0
leaq 0x120(%rsp), %r14
andq $0x0, 0xc0(%rsp)
andq $0x0, 0xa0(%rsp)
subq (%r15), %rax
vmovapd %xmm0, (%r14)
andq $0x0, 0x10(%r14)
vmovapd %xmm0, 0xb0(%rsp)
vmovapd %xmm0, 0x90(%rsp)
movq %rax, (%rsp)
movq (%rbx), %rax
leaq 0x20(,%rax,4), %rsi
movq %r14, %rdi
callq 0x506c
movq (%rbx), %rax
leaq 0x20(,%rax,4), %rsi
leaq 0xb0(%rsp), %r13
movq %r13, %rdi
callq 0x506c
movq (%rbx), %rax
leaq 0x20(,%rax,4), %rsi
leaq 0x90(%rsp), %r12
movq %r12, %rdi
callq 0x506c
movq %r15, 0xe0(%rsp)
movq %r15, 0xd0(%rsp)
movq %r15, 0x108(%rsp)
movq %r14, 0xe8(%rsp)
movq %r14, 0xd8(%rsp)
movq %r13, 0x110(%rsp)
leaq 0x7776(%rip), %rdi      # 0xc295
leaq 0x7778(%rip), %rsi      # 0xc29e
movq (%rbx), %rax
movq %r15, 0xf0(%rsp)
movq %r12, 0xf8(%rsp)
movq %rax, 0x118(%rsp)
movq %rax, 0x100(%rsp)
xorl %eax, %eax
callq 0x2040
movq 0xb461(%rip), %rax      # 0xffb8
movq (%rax), %rdi
callq 0x21a0
leaq 0x150(%rsp), %rdi
callq 0x509c
leaq 0x28(%rsp), %rdi
callq 0x5120
leaq 0x150(%rsp), %r15
leaq 0xe0(%rsp), %r14
leaq 0x8(%rsp), %r13
leaq 0x28(%rsp), %r12
movq %rbp, %rbx
subq $0x1, %rbx
jb 0x4bd3
movq %r15, %rdi
callq 0x5172
movq %r14, %rdi
callq 0x518a
movq %r15, %rdi
callq 0x52c4
movq %r13, %rdi
movq %rax, %rsi
callq 0x5300
movq %r12, %rdi
movq %r13, %rsi
callq 0x5314
leaq 0x10(%rsp), %rdi
callq 0x57ca
jmp 0x4b93
vcvtusi2sdq (%rsp), %xmm1, %xmm3
vmovsd 0x50(%rsp), %xmm1
cmpb $0x1, 0x17c(%rsp)
vmulsd 0x7578(%rip), %xmm1, %xmm0 # 0xc168
vdivsd %xmm0, %xmm3, %xmm2
vmovsd %xmm3, (%rsp)
jne 0x4c2d
movq 0x58(%rsp), %rax
vcvtusi2sdq 0x8(%rax), %xmm4, %xmm0
leaq 0x7697(%rip), %rdi      # 0xc2a5
vdivsd %xmm3, %xmm0, %xmm0
vcvtusi2sdq (%rax), %xmm4, %xmm3
movb $0x3, %al
vdivsd %xmm1, %xmm3, %xmm1
vdivsd 0x7542(%rip), %xmm1, %xmm1 # 0xc168
callq 0x2040
jmp 0x4c3f
leaq 0x76b8(%rip), %rdi      # 0xc2ec
movb $0x1, %al
vmovapd %xmm2, %xmm0
callq 0x2040
leaq 0x28(%rsp), %rdi
callq 0x537a
leaq 0x150(%rsp), %rdi
callq 0x539e
leaq 0x7638(%rip), %rdi      # 0xc295
leaq 0x76b4(%rip), %rsi      # 0xc318
xorl %eax, %eax
callq 0x2040
movq 0xb346(%rip), %rax      # 0xffb8
movq (%rax), %rdi
callq 0x21a0
leaq 0x150(%rsp), %rdi
callq 0x509c
leaq 0x28(%rsp), %rdi
callq 0x5120
leaq 0x150(%rsp), %r15
leaq 0xd0(%rsp), %rbx
leaq 0x8(%rsp), %r13
leaq 0x28(%rsp), %r12
movq %rbp, %r14
subq $0x1, %r14
jb 0x4cee
movq %r15, %rdi
callq 0x5172
movq %rbx, %rdi
callq 0x53b8
movq %r15, %rdi
callq 0x52c4
movq %r13, %rdi
movq %rax, %rsi
callq 0x5300
movq %r12, %rdi
movq %r13, %rsi
callq 0x5314
leaq 0x10(%rsp), %rdi
callq 0x57ca
jmp 0x4cae
vmovsd 0x50(%rsp), %xmm1
vmovsd (%rsp), %xmm3
cmpb $0x1, 0x17c(%rsp)
vmulsd 0x745f(%rip), %xmm1, %xmm0 # 0xc168
vdivsd %xmm0, %xmm3, %xmm2
jne 0x4d41
movq 0x58(%rsp), %rax
vcvtusi2sdq 0x8(%rax), %xmm4, %xmm0
leaq 0x7583(%rip), %rdi      # 0xc2a5
vdivsd %xmm3, %xmm0, %xmm0
vcvtusi2sdq (%rax), %xmm4, %xmm3
movb $0x3, %al
vdivsd %xmm1, %xmm3, %xmm1
vdivsd 0x742e(%rip), %xmm1, %xmm1 # 0xc168
callq 0x2040
jmp 0x4d53
leaq 0x75a4(%rip), %rdi      # 0xc2ec
movb $0x1, %al
vmovapd %xmm2, %xmm0
callq 0x2040
leaq 0x28(%rsp), %rdi
callq 0x537a
leaq 0x150(%rsp), %rdi
callq 0x539e
leaq 0x7524(%rip), %rdi      # 0xc295
leaq 0x75af(%rip), %rsi      # 0xc327
xorl %eax, %eax
callq 0x2040
movq 0xb232(%rip), %rax      # 0xffb8
movq (%rax), %rdi
callq 0x21a0
leaq 0x150(%rsp), %rdi
callq 0x509c
leaq 0x28(%rsp), %rdi
callq 0x5120
leaq 0x150(%rsp), %r15
leaq 0x108(%rsp), %r14
leaq 0x8(%rsp), %r13
leaq 0x28(%rsp), %rbx
movq %rbp, %r12
subq $0x1, %r12
jb 0x4e02
movq %r15, %rdi
callq 0x5172
movq %r14, %rdi
callq 0x53d8
movq %r15, %rdi
callq 0x52c4
movq %r13, %rdi
movq %rax, %rsi
callq 0x5300
movq %rbx, %rdi
movq %r13, %rsi
callq 0x5314
leaq 0x10(%rsp), %rdi
callq 0x57ca
jmp 0x4dc2
vmovsd 0x50(%rsp), %xmm1
vmovsd (%rsp), %xmm3
cmpb $0x1, 0x17c(%rsp)
vmulsd 0x734b(%rip), %xmm1, %xmm0 # 0xc168
vdivsd %xmm0, %xmm3, %xmm2
jne 0x4e55
movq 0x58(%rsp), %rax
vcvtusi2sdq 0x8(%rax), %xmm4, %xmm0
leaq 0x746f(%rip), %rdi      # 0xc2a5
vdivsd %xmm3, %xmm0, %xmm0
vcvtusi2sdq (%rax), %xmm4, %xmm3
movb $0x3, %al
vdivsd %xmm1, %xmm3, %xmm1
vdivsd 0x731a(%rip), %xmm1, %xmm1 # 0xc168
callq 0x2040
jmp 0x4e67
leaq 0x7490(%rip), %rdi      # 0xc2ec
movb $0x1, %al
vmovapd %xmm2, %xmm0
callq 0x2040
leaq 0x28(%rsp), %rdi
callq 0x537a
leaq 0x150(%rsp), %rdi
callq 0x539e
leaq 0x7410(%rip), %rdi      # 0xc295
leaq 0x749f(%rip), %rsi      # 0xc32b
xorl %eax, %eax
callq 0x2040
movq 0xb11e(%rip), %rax      # 0xffb8
movq (%rax), %rdi
callq 0x21a0
leaq 0x150(%rsp), %rdi
callq 0x509c
leaq 0x28(%rsp), %rdi
callq 0x5120
leaq 0x10(%rsp), %rbx
leaq 0x150(%rsp), %r15
leaq 0xf0(%rsp), %r14
leaq 0x8(%rsp), %r13
leaq 0x28(%rsp), %r12
subq $0x1, %rbp
jb 0x4f16
movq %r15, %rdi
callq 0x5172
movq %r14, %rdi
callq 0x53f2
movq %r15, %rdi
callq 0x52c4
movq %r13, %rdi
movq %rax, %rsi
callq 0x5300
movq %r12, %rdi
movq %r13, %rsi
callq 0x5314
movq %rbx, %rdi
callq 0x57ca
jmp 0x4ed8
vmovsd 0x50(%rsp), %xmm1
vmovsd (%rsp), %xmm3
cmpb $0x1, 0x17c(%rsp)
vmulsd 0x7237(%rip), %xmm1, %xmm0 # 0xc168
vdivsd %xmm0, %xmm3, %xmm2
jne 0x4f69
movq 0x58(%rsp), %rax
vcvtusi2sdq 0x8(%rax), %xmm4, %xmm0
leaq 0x735b(%rip), %rdi      # 0xc2a5
vdivsd %xmm3, %xmm0, %xmm0
vcvtusi2sdq (%rax), %xmm4, %xmm3
movb $0x3, %al
vdivsd %xmm1, %xmm3, %xmm1
vdivsd 0x7206(%rip), %xmm1, %xmm1 # 0xc168
callq 0x2040
jmp 0x4f7b
leaq 0x737c(%rip), %rdi      # 0xc2ec
movb $0x1, %al
vmovapd %xmm2, %xmm0
callq 0x2040
leaq 0x28(%rsp), %rdi
callq 0x537a
leaq 0x150(%rsp), %rdi
callq 0x539e
leaq 0x90(%rsp), %rdi
callq 0x3972
leaq 0xb0(%rsp), %rdi
callq 0x3972
leaq 0x120(%rsp), %rdi
callq 0x3972
leaq 0x138(%rsp), %rdi
callq 0x417a
addq $0x238, %rsp            # imm = 0x238
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x4fe4
jmp 0x4feb
jmp 0x4fe4
jmp 0x4feb
jmp 0x4fe4
jmp 0x4feb
movq %rax, %r14
jmp 0x5023
jmp 0x4feb
movq %rax, %r14
jmp 0x5030
movq %rbx, %rdi
jmp 0x4ffe
jmp 0x4ff9
jmp 0x4ff9
leaq 0x10(%rsp), %rdi
movq %rax, %r14
callq 0x57ca
jmp 0x5019
jmp 0x5016
jmp 0x5016
jmp 0x5016
jmp 0x5016
jmp 0x5016
jmp 0x5016
jmp 0x5016
movq %rax, %r14
leaq 0x28(%rsp), %rdi
callq 0x537a
leaq 0x150(%rsp), %rdi
callq 0x539e
leaq 0x90(%rsp), %rdi
callq 0x3972
leaq 0xb0(%rsp), %rdi
callq 0x3972
leaq 0x120(%rsp), %rdi
callq 0x3972
leaq 0x138(%rsp), %rdi
callq 0x417a
movq %r14, %rdi
callq 0x22a0