// File: /workspace/github_cpp_makefile_star2_O1/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 $0x1f8, %rsp            # imm = 0x1F8
movq %rdx, %rbx
movq %rdi, %r14
movq (%rdi), %rdx
leaq 0xe8(%rsp), %r15
movq %r15, %rdi
callq 0x3192
movq 0x8(%r15), %rax
subq (%r15), %rax
movq %rax, 0x30(%rsp)
xorl %eax, %eax
leaq 0xc0(%rsp), %r12
movq %rax, 0x10(%r12)
vxorpd %xmm0, %xmm0, %xmm0
vmovapd %xmm0, (%r12)
movq %rax, 0xb0(%rsp)
vmovapd %xmm0, 0xa0(%rsp)
movq (%r14), %rax
leaq 0x20(,%rax,4), %rsi
movq %r12, %rdi
callq 0x57be
movq (%r14), %rax
leaq 0x20(,%rax,4), %rsi
leaq 0xa0(%rsp), %rdi
callq 0x57be
movq %r15, 0x100(%rsp)
movq %r12, 0x108(%rsp)
movq (%r14), %rax
movq %rax, 0xe0(%rsp)
leaq 0x7397(%rip), %rdi      # 0xc25a
leaq 0x7399(%rip), %rsi      # 0xc263
xorl %eax, %eax
callq 0x2050
movq 0xa0e0(%rip), %rax      # 0xefb8
movq (%rax), %rdi
callq 0x2200
leaq 0x110(%rsp), %rdi
callq 0x57ea
leaq 0x38(%rsp), %rdi
callq 0x58ca
movq %rbx, 0x8(%rsp)
testq %rbx, %rbx
je 0x4fb5
leaq 0x138(%rsp), %r14
leaq 0x118(%rsp), %r15
leaq 0x38(%rsp), %rbp
leaq 0x10(%rsp), %r12
movq 0x8(%rsp), %rbx
movq %r14, %rdi
callq 0x65bc
callq 0x2210
movq %rax, 0x130(%rsp)
leaq 0x100(%rsp), %rdi
callq 0x59bc
callq 0x2210
movq %rax, %r13
movq %r14, %rdi
movq %r15, %rsi
callq 0x66bc
subq 0x130(%rsp), %r13
vcvtsi2sd %r13, %xmm1, %xmm0
vdivsd 0x71d2(%rip), %xmm0, %xmm0 # 0xc140
vmovsd %xmm0, 0x110(%rsp)
vmovsd %xmm0, 0x10(%rsp)
leaq 0x18(%rsp), %rdi
movq %r15, %rsi
callq 0x6800
movq %rbp, %rdi
movq %r12, %rsi
callq 0x5bf2
movq 0x18(%rsp), %rdi
testq %rdi, %rdi
je 0x4fac
movq 0x28(%rsp), %rsi
subq %rdi, %rsi
callq 0x21d0
decq %rbx
jne 0x4f24
vmovsd 0x60(%rsp), %xmm1
vcvtusi2sdq 0x30(%rsp), %xmm2, %xmm3
vmulsd 0x7175(%rip), %xmm1, %xmm0 # 0xc140
vdivsd %xmm0, %xmm3, %xmm2
cmpb $0x0, 0x13c(%rsp)
vmovsd %xmm3, 0x30(%rsp)
je 0x5011
movq 0x68(%rsp), %rax
vcvtusi2sdq 0x8(%rax), %xmm4, %xmm0
vdivsd %xmm3, %xmm0, %xmm0
vcvtusi2sdq (%rax), %xmm4, %xmm3
vdivsd %xmm1, %xmm3, %xmm1
vdivsd 0x713f(%rip), %xmm1, %xmm1 # 0xc140
leaq 0x7262(%rip), %rdi      # 0xc26a
movb $0x3, %al
callq 0x2050
jmp 0x5023
leaq 0x7299(%rip), %rdi      # 0xc2b1
vmovapd %xmm2, %xmm0
movb $0x1, %al
callq 0x2050
movq 0x8(%rsp), %rbx
movq 0x88(%rsp), %rdi
testq %rdi, %rdi
je 0x5045
movq 0x98(%rsp), %rsi
subq %rdi, %rsi
callq 0x21d0
movq 0x68(%rsp), %rdi
testq %rdi, %rdi
je 0x505c
movq 0x78(%rsp), %rsi
subq %rdi, %rsi
callq 0x21d0
movq 0x48(%rsp), %rdi
testq %rdi, %rdi
je 0x5073
movq 0x58(%rsp), %rsi
subq %rdi, %rsi
callq 0x21d0
leaq 0x138(%rsp), %r14
movq %r14, %rdi
callq 0x6a9e
movq -0x20(%r14), %rdi
testq %rdi, %rdi
je 0x509c
movq 0x128(%rsp), %rsi
subq %rdi, %rsi
callq 0x21d0
leaq 0x71b7(%rip), %rdi      # 0xc25a
leaq 0x7233(%rip), %rsi      # 0xc2dd
xorl %eax, %eax
callq 0x2050
movq 0x9f00(%rip), %rax      # 0xefb8
movq (%rax), %rdi
callq 0x2200
leaq 0x110(%rsp), %rdi
callq 0x57ea
leaq 0x38(%rsp), %rdi
callq 0x58ca
testq %rbx, %rbx
je 0x51ba
leaq 0x138(%rsp), %r15
leaq 0x118(%rsp), %r12
leaq 0x38(%rsp), %r14
leaq 0x10(%rsp), %r13
movq 0x8(%rsp), %rbx
movq %r15, %rdi
callq 0x65bc
callq 0x2210
movq %rax, 0x130(%rsp)
movq 0xc0(%rsp), %rax
cmpq %rax, 0xc8(%rsp)
je 0x512e
movq %rax, 0xc8(%rsp)
movq 0xe8(%rsp), %rdi
movq 0xf0(%rsp), %rsi
leaq 0xc0(%rsp), %rdx
callq 0x6aef
callq 0x2210
movq %rax, %rbp
movq %r15, %rdi
movq %r12, %rsi
callq 0x66bc
subq 0x130(%rsp), %rbp
vcvtsi2sd %rbp, %xmm4, %xmm0
vdivsd 0x6fcd(%rip), %xmm0, %xmm0 # 0xc140
vmovsd %xmm0, 0x110(%rsp)
vmovsd %xmm0, 0x10(%rsp)
leaq 0x18(%rsp), %rdi
movq %r12, %rsi
callq 0x6800
movq %r14, %rdi
movq %r13, %rsi
callq 0x5bf2
movq 0x18(%rsp), %rdi
testq %rdi, %rdi
je 0x51b1
movq 0x28(%rsp), %rsi
subq %rdi, %rsi
callq 0x21d0
decq %rbx
jne 0x50ff
vmovsd 0x60(%rsp), %xmm1
vmulsd 0x6f78(%rip), %xmm1, %xmm0 # 0xc140
vmovsd 0x30(%rsp), %xmm3
vdivsd %xmm0, %xmm3, %xmm2
cmpb $0x0, 0x13c(%rsp)
je 0x520e
movq 0x68(%rsp), %rax
vcvtusi2sdq 0x8(%rax), %xmm4, %xmm0
vdivsd %xmm3, %xmm0, %xmm0
vcvtusi2sdq (%rax), %xmm4, %xmm3
vdivsd %xmm1, %xmm3, %xmm1
vdivsd 0x6f42(%rip), %xmm1, %xmm1 # 0xc140
leaq 0x7065(%rip), %rdi      # 0xc26a
movb $0x3, %al
callq 0x2050
jmp 0x5220
leaq 0x709c(%rip), %rdi      # 0xc2b1
vmovapd %xmm2, %xmm0
movb $0x1, %al
callq 0x2050
movq 0x8(%rsp), %rbx
movq 0x88(%rsp), %rdi
testq %rdi, %rdi
je 0x5242
movq 0x98(%rsp), %rsi
subq %rdi, %rsi
callq 0x21d0
movq 0x68(%rsp), %rdi
testq %rdi, %rdi
je 0x5259
movq 0x78(%rsp), %rsi
subq %rdi, %rsi
callq 0x21d0
movq 0x48(%rsp), %rdi
testq %rdi, %rdi
je 0x5270
movq 0x58(%rsp), %rsi
subq %rdi, %rsi
callq 0x21d0
leaq 0x138(%rsp), %r14
movq %r14, %rdi
callq 0x6a9e
movq -0x20(%r14), %rdi
testq %rdi, %rdi
je 0x5299
movq 0x128(%rsp), %rsi
subq %rdi, %rsi
callq 0x21d0
leaq 0x6fba(%rip), %rdi      # 0xc25a
leaq 0x7045(%rip), %rsi      # 0xc2ec
xorl %eax, %eax
callq 0x2050
movq 0x9d03(%rip), %rax      # 0xefb8
movq (%rax), %rdi
callq 0x2200
leaq 0x110(%rsp), %rdi
callq 0x57ea
leaq 0x38(%rsp), %rdi
callq 0x58ca
testq %rbx, %rbx
je 0x539d
leaq 0x138(%rsp), %r14
leaq 0x118(%rsp), %r15
leaq 0x38(%rsp), %r13
leaq 0x10(%rsp), %rbp
movq 0x8(%rsp), %rbx
movq %r14, %rdi
callq 0x65bc
callq 0x2210
movq %rax, 0x130(%rsp)
movq 0xe8(%rsp), %rdi
movq 0xa0(%rsp), %rdx
movq 0xe0(%rsp), %rsi
callq 0x24dc
callq 0x2210
movq %rax, %r12
movq %r14, %rdi
movq %r15, %rsi
callq 0x66bc
subq 0x130(%rsp), %r12
vcvtsi2sd %r12, %xmm4, %xmm0
vdivsd 0x6dea(%rip), %xmm0, %xmm0 # 0xc140
vmovsd %xmm0, 0x110(%rsp)
vmovsd %xmm0, 0x10(%rsp)
leaq 0x18(%rsp), %rdi
movq %r15, %rsi
callq 0x6800
movq %r13, %rdi
movq %rbp, %rsi
callq 0x5bf2
movq 0x18(%rsp), %rdi
testq %rdi, %rdi
je 0x5394
movq 0x28(%rsp), %rsi
subq %rdi, %rsi
callq 0x21d0
decq %rbx
jne 0x52fc
vmovsd 0x60(%rsp), %xmm1
vmulsd 0x6d95(%rip), %xmm1, %xmm0 # 0xc140
vmovsd 0x30(%rsp), %xmm3
vdivsd %xmm0, %xmm3, %xmm2
cmpb $0x0, 0x13c(%rsp)
je 0x53f1
movq 0x68(%rsp), %rax
vcvtusi2sdq 0x8(%rax), %xmm4, %xmm0
vdivsd %xmm3, %xmm0, %xmm0
vcvtusi2sdq (%rax), %xmm4, %xmm3
vdivsd %xmm1, %xmm3, %xmm1
vdivsd 0x6d5f(%rip), %xmm1, %xmm1 # 0xc140
leaq 0x6e82(%rip), %rdi      # 0xc26a
movb $0x3, %al
callq 0x2050
jmp 0x5403
leaq 0x6eb9(%rip), %rdi      # 0xc2b1
vmovapd %xmm2, %xmm0
movb $0x1, %al
callq 0x2050
movq 0x8(%rsp), %rbx
movq 0x88(%rsp), %rdi
testq %rdi, %rdi
je 0x5425
movq 0x98(%rsp), %rsi
subq %rdi, %rsi
callq 0x21d0
movq 0x68(%rsp), %rdi
testq %rdi, %rdi
je 0x543c
movq 0x78(%rsp), %rsi
subq %rdi, %rsi
callq 0x21d0
movq 0x48(%rsp), %rdi
testq %rdi, %rdi
je 0x5453
movq 0x58(%rsp), %rsi
subq %rdi, %rsi
callq 0x21d0
leaq 0x138(%rsp), %r14
movq %r14, %rdi
callq 0x6a9e
movq -0x20(%r14), %rdi
testq %rdi, %rdi
je 0x547c
movq 0x128(%rsp), %rsi
subq %rdi, %rsi
callq 0x21d0
leaq 0x6dd7(%rip), %rdi      # 0xc25a
leaq 0x6e66(%rip), %rsi      # 0xc2f0
xorl %eax, %eax
callq 0x2050
movq 0x9b20(%rip), %rax      # 0xefb8
movq (%rax), %rdi
callq 0x2200
leaq 0x110(%rsp), %rdi
callq 0x57ea
leaq 0x38(%rsp), %rdi
callq 0x58ca
testq %rbx, %rbx
je 0x557b
leaq 0x138(%rsp), %r14
leaq 0x118(%rsp), %r15
leaq 0x38(%rsp), %r13
leaq 0x10(%rsp), %rbp
movq %r14, %rdi
callq 0x65bc
callq 0x2210
movq %rax, 0x130(%rsp)
movq 0xe8(%rsp), %rdi
movq 0xa0(%rsp), %rdx
movq 0xe0(%rsp), %rsi
callq 0x2853
callq 0x2210
movq %rax, %r12
movq %r14, %rdi
movq %r15, %rsi
callq 0x66bc
subq 0x130(%rsp), %r12
vcvtsi2sd %r12, %xmm4, %xmm0
vdivsd 0x6c0c(%rip), %xmm0, %xmm0 # 0xc140
vmovsd %xmm0, 0x110(%rsp)
vmovsd %xmm0, 0x10(%rsp)
leaq 0x18(%rsp), %rdi
movq %r15, %rsi
callq 0x6800
movq %r13, %rdi
movq %rbp, %rsi
callq 0x5bf2
movq 0x18(%rsp), %rdi
testq %rdi, %rdi
je 0x5572
movq 0x28(%rsp), %rsi
subq %rdi, %rsi
callq 0x21d0
decq %rbx
jne 0x54da
vmovsd 0x60(%rsp), %xmm1
vmulsd 0x6bb7(%rip), %xmm1, %xmm0 # 0xc140
vmovsd 0x30(%rsp), %xmm3
vdivsd %xmm0, %xmm3, %xmm2
cmpb $0x0, 0x13c(%rsp)
je 0x55cf
movq 0x68(%rsp), %rax
vcvtusi2sdq 0x8(%rax), %xmm4, %xmm0
vdivsd %xmm3, %xmm0, %xmm0
vcvtusi2sdq (%rax), %xmm4, %xmm3
vdivsd %xmm1, %xmm3, %xmm1
vdivsd 0x6b81(%rip), %xmm1, %xmm1 # 0xc140
leaq 0x6ca4(%rip), %rdi      # 0xc26a
movb $0x3, %al
callq 0x2050
jmp 0x55e1
leaq 0x6cdb(%rip), %rdi      # 0xc2b1
vmovapd %xmm2, %xmm0
movb $0x1, %al
callq 0x2050
movq 0x88(%rsp), %rdi
testq %rdi, %rdi
je 0x55fe
movq 0x98(%rsp), %rsi
subq %rdi, %rsi
callq 0x21d0
movq 0x68(%rsp), %rdi
testq %rdi, %rdi
je 0x5615
movq 0x78(%rsp), %rsi
subq %rdi, %rsi
callq 0x21d0
movq 0x48(%rsp), %rdi
testq %rdi, %rdi
je 0x562c
movq 0x58(%rsp), %rsi
subq %rdi, %rsi
callq 0x21d0
leaq 0x138(%rsp), %rbx
movq %rbx, %rdi
callq 0x6a9e
movq -0x20(%rbx), %rdi
testq %rdi, %rdi
je 0x5655
movq 0x128(%rsp), %rsi
subq %rdi, %rsi
callq 0x21d0
movq 0xa0(%rsp), %rdi
testq %rdi, %rdi
je 0x5672
movq 0xb0(%rsp), %rsi
subq %rdi, %rsi
callq 0x21d0
movq 0xc0(%rsp), %rdi
testq %rdi, %rdi
je 0x568f
movq 0xd0(%rsp), %rsi
subq %rdi, %rsi
callq 0x21d0
movq 0xe8(%rsp), %rdi
testq %rdi, %rdi
je 0x56ac
movq 0xf8(%rsp), %rsi
subq %rdi, %rsi
callq 0x21d0
addq $0x1f8, %rsp            # imm = 0x1F8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x56ca
jmp 0x56d1
jmp 0x56ca
jmp 0x56d1
jmp 0x56ca
jmp 0x56d1
movq %rax, %rbx
jmp 0x5713
jmp 0x56d1
movq %rax, %rbx
jmp 0x5720
jmp 0x56dc
jmp 0x56dc
jmp 0x56dc
movq %rax, %rbx
movq 0x18(%rsp), %rdi
testq %rdi, %rdi
je 0x5709
movq 0x28(%rsp), %rsi
subq %rdi, %rsi
callq 0x21d0
jmp 0x5709
jmp 0x5706
jmp 0x5706
jmp 0x5706
jmp 0x5706
jmp 0x5706
jmp 0x5706
jmp 0x5706
movq %rax, %rbx
leaq 0x38(%rsp), %rdi
callq 0x5c60
leaq 0x110(%rsp), %rdi
callq 0x5ca6
movq 0xa0(%rsp), %rdi
testq %rdi, %rdi
je 0x573d
movq 0xb0(%rsp), %rsi
subq %rdi, %rsi
callq 0x21d0
movq 0xc0(%rsp), %rdi
testq %rdi, %rdi
je 0x575a
movq 0xd0(%rsp), %rsi
subq %rdi, %rsi
callq 0x21d0
movq 0xe8(%rsp), %rdi
testq %rdi, %rdi
je 0x5777
movq 0xf8(%rsp), %rsi
subq %rdi, %rsi
callq 0x21d0
movq %rbx, %rdi
callq 0x22b0
nop