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

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


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

        auto scalar = [&UTF16, &scalar_out]() {
            utf16_to_utf8(UTF16.data(), (uint8_t*)scalar_out.data());
        };

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

        auto sse = [&UTF16, &sse_out, size=size]() {
            sse_convert_utf16_to_utf8(UTF16.data(), size, (uint8_t*)sse_out.data());
        };

        auto sse_hybrid= [&UTF16, &sse_out, size=size]() {
            sse_convert_utf16_to_utf8_hybrid(UTF16.data(), size, (uint8_t*)sse_out.data());
        };

        RUN("scalar", scalar);
        RUN("scalar_utf8lib", scalar_utf8lib);

        RUN("SSE",    sse);
        RUN("SSEH",   sse_hybrid);
    }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x218, %rsp            # imm = 0x218
movq %rdx, %rbp
movq (%rdi), %rdx
leaq 0x118(%rsp), %r15
movq %rdi, %rbx
movq %r15, %rdi
callq 0x2fd6
movq 0x8(%r15), %rax
vxorpd %xmm0, %xmm0, %xmm0
leaq 0x100(%rsp), %r14
andq $0x0, 0xa0(%rsp)
subq (%r15), %rax
vmovapd %xmm0, (%r14)
andq $0x0, 0x10(%r14)
vmovapd %xmm0, 0x90(%rsp)
movq %rax, (%rsp)
movq (%rbx), %rax
leaq 0x20(,%rax,4), %rsi
movq %r14, %rdi
callq 0x4f70
movq (%rbx), %rax
leaq 0x20(,%rax,4), %rsi
leaq 0x90(%rsp), %r13
movq %r13, %rdi
callq 0x4f70
movq %r15, 0xc0(%rsp)
movq %r15, 0xb0(%rsp)
movq %r15, 0xe8(%rsp)
movq %r14, 0xc8(%rsp)
movq %r14, 0xb8(%rsp)
movq %r13, 0xf0(%rsp)
leaq 0x77e4(%rip), %rdi      # 0xc220
leaq 0x77e6(%rip), %rsi      # 0xc229
movq (%rbx), %rax
movq %r15, 0xd0(%rsp)
movq %r13, 0xd8(%rsp)
movq %rax, 0xf8(%rsp)
movq %rax, 0xe0(%rsp)
xorl %eax, %eax
callq 0x2040
movq 0xb544(%rip), %rax      # 0xffb8
movq (%rax), %rdi
callq 0x21b0
leaq 0x130(%rsp), %rdi
callq 0x4f9c
leaq 0x28(%rsp), %rdi
callq 0x5020
leaq 0x130(%rsp), %r15
leaq 0xc0(%rsp), %r14
leaq 0x8(%rsp), %r13
leaq 0x28(%rsp), %r12
movq %rbp, %rbx
subq $0x1, %rbx
jb 0x4af0
movq %r15, %rdi
callq 0x5072
movq %r14, %rdi
callq 0x508a
movq %r15, %rdi
callq 0x51ca
movq %r13, %rdi
movq %rax, %rsi
callq 0x5206
movq %r12, %rdi
movq %r13, %rsi
callq 0x521a
leaq 0x10(%rsp), %rdi
callq 0x5676
jmp 0x4ab0
vcvtusi2sdq (%rsp), %xmm1, %xmm3
vmovsd 0x50(%rsp), %xmm1
cmpb $0x1, 0x15c(%rsp)
vmulsd 0x765b(%rip), %xmm1, %xmm0 # 0xc168
vdivsd %xmm0, %xmm3, %xmm2
vmovsd %xmm3, (%rsp)
jne 0x4b4a
movq 0x58(%rsp), %rax
vcvtusi2sdq 0x8(%rax), %xmm4, %xmm0
leaq 0x7705(%rip), %rdi      # 0xc230
vdivsd %xmm3, %xmm0, %xmm0
vcvtusi2sdq (%rax), %xmm4, %xmm3
movb $0x3, %al
vdivsd %xmm1, %xmm3, %xmm1
vdivsd 0x7625(%rip), %xmm1, %xmm1 # 0xc168
callq 0x2040
jmp 0x4b5c
leaq 0x7726(%rip), %rdi      # 0xc277
movb $0x1, %al
vmovapd %xmm2, %xmm0
callq 0x2040
leaq 0x28(%rsp), %rdi
callq 0x5280
leaq 0x130(%rsp), %rdi
callq 0x52a4
leaq 0x76a6(%rip), %rdi      # 0xc220
leaq 0x7722(%rip), %rsi      # 0xc2a3
xorl %eax, %eax
callq 0x2040
movq 0xb429(%rip), %rax      # 0xffb8
movq (%rax), %rdi
callq 0x21b0
leaq 0x130(%rsp), %rdi
callq 0x4f9c
leaq 0x28(%rsp), %rdi
callq 0x5020
leaq 0x130(%rsp), %r15
leaq 0xb0(%rsp), %rbx
leaq 0x8(%rsp), %r13
leaq 0x28(%rsp), %r12
movq %rbp, %r14
subq $0x1, %r14
jb 0x4c0b
movq %r15, %rdi
callq 0x5072
movq %rbx, %rdi
callq 0x52be
movq %r15, %rdi
callq 0x51ca
movq %r13, %rdi
movq %rax, %rsi
callq 0x5206
movq %r12, %rdi
movq %r13, %rsi
callq 0x521a
leaq 0x10(%rsp), %rdi
callq 0x5676
jmp 0x4bcb
vmovsd 0x50(%rsp), %xmm1
vmovsd (%rsp), %xmm3
cmpb $0x1, 0x15c(%rsp)
vmulsd 0x7542(%rip), %xmm1, %xmm0 # 0xc168
vdivsd %xmm0, %xmm3, %xmm2
jne 0x4c5e
movq 0x58(%rsp), %rax
vcvtusi2sdq 0x8(%rax), %xmm4, %xmm0
leaq 0x75f1(%rip), %rdi      # 0xc230
vdivsd %xmm3, %xmm0, %xmm0
vcvtusi2sdq (%rax), %xmm4, %xmm3
movb $0x3, %al
vdivsd %xmm1, %xmm3, %xmm1
vdivsd 0x7511(%rip), %xmm1, %xmm1 # 0xc168
callq 0x2040
jmp 0x4c70
leaq 0x7612(%rip), %rdi      # 0xc277
movb $0x1, %al
vmovapd %xmm2, %xmm0
callq 0x2040
leaq 0x28(%rsp), %rdi
callq 0x5280
leaq 0x130(%rsp), %rdi
callq 0x52a4
leaq 0x7592(%rip), %rdi      # 0xc220
leaq 0x761d(%rip), %rsi      # 0xc2b2
xorl %eax, %eax
callq 0x2040
movq 0xb315(%rip), %rax      # 0xffb8
movq (%rax), %rdi
callq 0x21b0
leaq 0x130(%rsp), %rdi
callq 0x4f9c
leaq 0x28(%rsp), %rdi
callq 0x5020
leaq 0x130(%rsp), %r15
leaq 0xe8(%rsp), %r14
leaq 0x8(%rsp), %r13
leaq 0x28(%rsp), %rbx
movq %rbp, %r12
subq $0x1, %r12
jb 0x4d1f
movq %r15, %rdi
callq 0x5072
movq %r14, %rdi
callq 0x52de
movq %r15, %rdi
callq 0x51ca
movq %r13, %rdi
movq %rax, %rsi
callq 0x5206
movq %rbx, %rdi
movq %r13, %rsi
callq 0x521a
leaq 0x10(%rsp), %rdi
callq 0x5676
jmp 0x4cdf
vmovsd 0x50(%rsp), %xmm1
vmovsd (%rsp), %xmm3
cmpb $0x1, 0x15c(%rsp)
vmulsd 0x742e(%rip), %xmm1, %xmm0 # 0xc168
vdivsd %xmm0, %xmm3, %xmm2
jne 0x4d72
movq 0x58(%rsp), %rax
vcvtusi2sdq 0x8(%rax), %xmm4, %xmm0
leaq 0x74dd(%rip), %rdi      # 0xc230
vdivsd %xmm3, %xmm0, %xmm0
vcvtusi2sdq (%rax), %xmm4, %xmm3
movb $0x3, %al
vdivsd %xmm1, %xmm3, %xmm1
vdivsd 0x73fd(%rip), %xmm1, %xmm1 # 0xc168
callq 0x2040
jmp 0x4d84
leaq 0x74fe(%rip), %rdi      # 0xc277
movb $0x1, %al
vmovapd %xmm2, %xmm0
callq 0x2040
leaq 0x28(%rsp), %rdi
callq 0x5280
leaq 0x130(%rsp), %rdi
callq 0x52a4
leaq 0x747e(%rip), %rdi      # 0xc220
leaq 0x750d(%rip), %rsi      # 0xc2b6
xorl %eax, %eax
callq 0x2040
movq 0xb201(%rip), %rax      # 0xffb8
movq (%rax), %rdi
callq 0x21b0
leaq 0x130(%rsp), %rdi
callq 0x4f9c
leaq 0x28(%rsp), %rdi
callq 0x5020
leaq 0x10(%rsp), %rbx
leaq 0x130(%rsp), %r15
leaq 0xd0(%rsp), %r14
leaq 0x8(%rsp), %r13
leaq 0x28(%rsp), %r12
subq $0x1, %rbp
jb 0x4e33
movq %r15, %rdi
callq 0x5072
movq %r14, %rdi
callq 0x52f8
movq %r15, %rdi
callq 0x51ca
movq %r13, %rdi
movq %rax, %rsi
callq 0x5206
movq %r12, %rdi
movq %r13, %rsi
callq 0x521a
movq %rbx, %rdi
callq 0x5676
jmp 0x4df5
vmovsd 0x50(%rsp), %xmm1
vmovsd (%rsp), %xmm3
cmpb $0x1, 0x15c(%rsp)
vmulsd 0x731a(%rip), %xmm1, %xmm0 # 0xc168
vdivsd %xmm0, %xmm3, %xmm2
jne 0x4e86
movq 0x58(%rsp), %rax
vcvtusi2sdq 0x8(%rax), %xmm4, %xmm0
leaq 0x73c9(%rip), %rdi      # 0xc230
vdivsd %xmm3, %xmm0, %xmm0
vcvtusi2sdq (%rax), %xmm4, %xmm3
movb $0x3, %al
vdivsd %xmm1, %xmm3, %xmm1
vdivsd 0x72e9(%rip), %xmm1, %xmm1 # 0xc168
callq 0x2040
jmp 0x4e98
leaq 0x73ea(%rip), %rdi      # 0xc277
movb $0x1, %al
vmovapd %xmm2, %xmm0
callq 0x2040
leaq 0x28(%rsp), %rdi
callq 0x5280
leaq 0x130(%rsp), %rdi
callq 0x52a4
leaq 0x90(%rsp), %rdi
callq 0x418a
leaq 0x100(%rsp), %rdi
callq 0x418a
leaq 0x118(%rsp), %rdi
callq 0x3982
addq $0x218, %rsp            # imm = 0x218
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x4ef4
jmp 0x4efb
jmp 0x4ef4
jmp 0x4efb
jmp 0x4ef4
jmp 0x4efb
movq %rax, %r14
jmp 0x4f33
jmp 0x4efb
movq %rax, %r14
jmp 0x4f40
movq %rbx, %rdi
jmp 0x4f0e
jmp 0x4f09
jmp 0x4f09
leaq 0x10(%rsp), %rdi
movq %rax, %r14
callq 0x5676
jmp 0x4f29
jmp 0x4f26
jmp 0x4f26
jmp 0x4f26
jmp 0x4f26
jmp 0x4f26
jmp 0x4f26
jmp 0x4f26
movq %rax, %r14
leaq 0x28(%rsp), %rdi
callq 0x5280
leaq 0x130(%rsp), %rdi
callq 0x52a4
leaq 0x90(%rsp), %rdi
callq 0x418a
leaq 0x100(%rsp), %rdi
callq 0x418a
leaq 0x118(%rsp), %rdi
callq 0x3982
movq %r14, %rdi
callq 0x22b0
nop