// File: /workspace/github_cpp_makefile_star2_O3/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), %rdx
leaq 0xe8(%rsp), %r15
movq %rdi, %r14
movq %r15, %rdi
callq 0x30fe
movq 0x8(%r15), %rax
vxorpd %xmm0, %xmm0, %xmm0
leaq 0xc0(%rsp), %r12
subq (%r15), %rax
vmovapd %xmm0, (%r12)
vmovapd %xmm0, 0xa0(%rsp)
movq %rax, 0x30(%rsp)
xorl %eax, %eax
movq %rax, 0x10(%r12)
movq %rax, 0xb0(%rsp)
movq (%r14), %rax
leaq 0x20(,%rax,4), %rsi
movq %r12, %rdi
callq 0x57e4
movq (%r14), %rax
leaq 0x20(,%rax,4), %rsi
leaq 0xa0(%rsp), %rdi
callq 0x57e4
movq %r15, 0x100(%rsp)
movq %r12, 0x108(%rsp)
leaq 0x751c(%rip), %rdi      # 0xc3fa
leaq 0x751e(%rip), %rsi      # 0xc403
movq (%r14), %rax
movq %rax, 0xe0(%rsp)
xorl %eax, %eax
callq 0x2050
movq 0xa0ba(%rip), %rax      # 0xefb8
movq (%rax), %rdi
callq 0x2200
leaq 0x110(%rsp), %rdi
callq 0x5810
leaq 0x38(%rsp), %rdi
callq 0x58f0
movq %rbx, 0x8(%rsp)
testq %rbx, %rbx
je 0x4fdb
movq 0x8(%rsp), %rbx
leaq 0x138(%rsp), %r14
leaq 0x118(%rsp), %r15
leaq 0x38(%rsp), %rbp
leaq 0x10(%rsp), %r12
movq %r14, %rdi
callq 0x657e
callq 0x2210
movq %rax, 0x130(%rsp)
leaq 0x100(%rsp), %rdi
callq 0x59e2
callq 0x2210
movq %rax, %r13
movq %r14, %rdi
movq %r15, %rsi
callq 0x667e
subq 0x130(%rsp), %r13
vcvtsi2sd %r13, %xmm1, %xmm0
vdivsd 0x7354(%rip), %xmm0, %xmm0 # 0xc2e8
vmovsd %xmm0, 0x110(%rsp)
vmovsd %xmm0, 0x10(%rsp)
leaq 0x18(%rsp), %rdi
movq %r15, %rsi
callq 0x67c2
movq %rbp, %rdi
movq %r12, %rsi
callq 0x5baa
movq 0x18(%rsp), %rdi
testq %rdi, %rdi
je 0x4fd2
movq 0x28(%rsp), %rsi
subq %rdi, %rsi
callq 0x21d0
decq %rbx
jne 0x4f4a
vcvtusi2sdq 0x30(%rsp), %xmm1, %xmm3
vmovsd 0x60(%rsp), %xmm1
cmpb $0x1, 0x13c(%rsp)
vmulsd 0x72ef(%rip), %xmm1, %xmm0 # 0xc2e8
vdivsd %xmm0, %xmm3, %xmm2
vmovsd %xmm3, 0x30(%rsp)
jne 0x5037
movq 0x68(%rsp), %rax
vcvtusi2sdq 0x8(%rax), %xmm4, %xmm0
leaq 0x73f2(%rip), %rdi      # 0xc40a
vdivsd %xmm3, %xmm0, %xmm0
vcvtusi2sdq (%rax), %xmm4, %xmm3
movb $0x3, %al
vdivsd %xmm1, %xmm3, %xmm1
vdivsd 0x72b8(%rip), %xmm1, %xmm1 # 0xc2e8
callq 0x2050
jmp 0x5049
leaq 0x7413(%rip), %rdi      # 0xc451
movb $0x1, %al
vmovapd %xmm2, %xmm0
callq 0x2050
movq 0x8(%rsp), %rbx
movq 0x88(%rsp), %rdi
testq %rdi, %rdi
je 0x506b
movq 0x98(%rsp), %rsi
subq %rdi, %rsi
callq 0x21d0
movq 0x68(%rsp), %rdi
testq %rdi, %rdi
je 0x5082
movq 0x78(%rsp), %rsi
subq %rdi, %rsi
callq 0x21d0
movq 0x48(%rsp), %rdi
testq %rdi, %rdi
je 0x5099
movq 0x58(%rsp), %rsi
subq %rdi, %rsi
callq 0x21d0
leaq 0x138(%rsp), %r14
movq %r14, %rdi
callq 0x6a50
movq -0x20(%r14), %rdi
testq %rdi, %rdi
je 0x50c2
movq 0x128(%rsp), %rsi
subq %rdi, %rsi
callq 0x21d0
leaq 0x7331(%rip), %rdi      # 0xc3fa
leaq 0x73ad(%rip), %rsi      # 0xc47d
xorl %eax, %eax
callq 0x2050
movq 0x9eda(%rip), %rax      # 0xefb8
movq (%rax), %rdi
callq 0x2200
leaq 0x110(%rsp), %rdi
callq 0x5810
leaq 0x38(%rsp), %rdi
callq 0x58f0
testq %rbx, %rbx
je 0x51e0
movq 0x8(%rsp), %rbx
leaq 0x138(%rsp), %r15
leaq 0x118(%rsp), %r12
leaq 0x38(%rsp), %r14
leaq 0x10(%rsp), %r13
movq %r15, %rdi
callq 0x657e
callq 0x2210
movq %rax, 0x130(%rsp)
movq 0xc0(%rsp), %rax
cmpq %rax, 0xc8(%rsp)
je 0x5154
movq %rax, 0xc8(%rsp)
movq 0xe8(%rsp), %rdi
movq 0xf0(%rsp), %rsi
leaq 0xc0(%rsp), %rdx
callq 0x6aa1
callq 0x2210
movq %rax, %rbp
movq %r15, %rdi
movq %r12, %rsi
callq 0x667e
subq 0x130(%rsp), %rbp
vcvtsi2sd %rbp, %xmm4, %xmm0
vdivsd 0x714f(%rip), %xmm0, %xmm0 # 0xc2e8
vmovsd %xmm0, 0x110(%rsp)
vmovsd %xmm0, 0x10(%rsp)
leaq 0x18(%rsp), %rdi
movq %r12, %rsi
callq 0x67c2
movq %r14, %rdi
movq %r13, %rsi
callq 0x5baa
movq 0x18(%rsp), %rdi
testq %rdi, %rdi
je 0x51d7
movq 0x28(%rsp), %rsi
subq %rdi, %rsi
callq 0x21d0
decq %rbx
jne 0x5125
vmovsd 0x60(%rsp), %xmm1
vmovsd 0x30(%rsp), %xmm3
cmpb $0x1, 0x13c(%rsp)
vmulsd 0x70ec(%rip), %xmm1, %xmm0 # 0xc2e8
vdivsd %xmm0, %xmm3, %xmm2
jne 0x5234
movq 0x68(%rsp), %rax
vcvtusi2sdq 0x8(%rax), %xmm4, %xmm0
leaq 0x71f5(%rip), %rdi      # 0xc40a
vdivsd %xmm3, %xmm0, %xmm0
vcvtusi2sdq (%rax), %xmm4, %xmm3
movb $0x3, %al
vdivsd %xmm1, %xmm3, %xmm1
vdivsd 0x70bb(%rip), %xmm1, %xmm1 # 0xc2e8
callq 0x2050
jmp 0x5246
leaq 0x7216(%rip), %rdi      # 0xc451
movb $0x1, %al
vmovapd %xmm2, %xmm0
callq 0x2050
movq 0x8(%rsp), %rbx
movq 0x88(%rsp), %rdi
testq %rdi, %rdi
je 0x5268
movq 0x98(%rsp), %rsi
subq %rdi, %rsi
callq 0x21d0
movq 0x68(%rsp), %rdi
testq %rdi, %rdi
je 0x527f
movq 0x78(%rsp), %rsi
subq %rdi, %rsi
callq 0x21d0
movq 0x48(%rsp), %rdi
testq %rdi, %rdi
je 0x5296
movq 0x58(%rsp), %rsi
subq %rdi, %rsi
callq 0x21d0
leaq 0x138(%rsp), %r14
movq %r14, %rdi
callq 0x6a50
movq -0x20(%r14), %rdi
testq %rdi, %rdi
je 0x52bf
movq 0x128(%rsp), %rsi
subq %rdi, %rsi
callq 0x21d0
leaq 0x7134(%rip), %rdi      # 0xc3fa
leaq 0x71bf(%rip), %rsi      # 0xc48c
xorl %eax, %eax
callq 0x2050
movq 0x9cdd(%rip), %rax      # 0xefb8
movq (%rax), %rdi
callq 0x2200
leaq 0x110(%rsp), %rdi
callq 0x5810
leaq 0x38(%rsp), %rdi
callq 0x58f0
testq %rbx, %rbx
je 0x53c3
movq 0x8(%rsp), %rbx
leaq 0x138(%rsp), %r14
leaq 0x118(%rsp), %r15
leaq 0x38(%rsp), %r13
leaq 0x10(%rsp), %rbp
movq %r14, %rdi
callq 0x657e
callq 0x2210
movq 0xa0(%rsp), %rdx
movq 0xe8(%rsp), %rdi
movq %rax, 0x130(%rsp)
movq 0xe0(%rsp), %rsi
callq 0x24dc
callq 0x2210
movq %rax, %r12
movq %r14, %rdi
movq %r15, %rsi
callq 0x667e
subq 0x130(%rsp), %r12
vcvtsi2sd %r12, %xmm4, %xmm0
vdivsd 0x6f6c(%rip), %xmm0, %xmm0 # 0xc2e8
vmovsd %xmm0, 0x110(%rsp)
vmovsd %xmm0, 0x10(%rsp)
leaq 0x18(%rsp), %rdi
movq %r15, %rsi
callq 0x67c2
movq %r13, %rdi
movq %rbp, %rsi
callq 0x5baa
movq 0x18(%rsp), %rdi
testq %rdi, %rdi
je 0x53ba
movq 0x28(%rsp), %rsi
subq %rdi, %rsi
callq 0x21d0
decq %rbx
jne 0x5322
vmovsd 0x60(%rsp), %xmm1
vmovsd 0x30(%rsp), %xmm3
cmpb $0x1, 0x13c(%rsp)
vmulsd 0x6f09(%rip), %xmm1, %xmm0 # 0xc2e8
vdivsd %xmm0, %xmm3, %xmm2
jne 0x5417
movq 0x68(%rsp), %rax
vcvtusi2sdq 0x8(%rax), %xmm4, %xmm0
leaq 0x7012(%rip), %rdi      # 0xc40a
vdivsd %xmm3, %xmm0, %xmm0
vcvtusi2sdq (%rax), %xmm4, %xmm3
movb $0x3, %al
vdivsd %xmm1, %xmm3, %xmm1
vdivsd 0x6ed8(%rip), %xmm1, %xmm1 # 0xc2e8
callq 0x2050
jmp 0x5429
leaq 0x7033(%rip), %rdi      # 0xc451
movb $0x1, %al
vmovapd %xmm2, %xmm0
callq 0x2050
movq 0x8(%rsp), %rbx
movq 0x88(%rsp), %rdi
testq %rdi, %rdi
je 0x544b
movq 0x98(%rsp), %rsi
subq %rdi, %rsi
callq 0x21d0
movq 0x68(%rsp), %rdi
testq %rdi, %rdi
je 0x5462
movq 0x78(%rsp), %rsi
subq %rdi, %rsi
callq 0x21d0
movq 0x48(%rsp), %rdi
testq %rdi, %rdi
je 0x5479
movq 0x58(%rsp), %rsi
subq %rdi, %rsi
callq 0x21d0
leaq 0x138(%rsp), %r14
movq %r14, %rdi
callq 0x6a50
movq -0x20(%r14), %rdi
testq %rdi, %rdi
je 0x54a2
movq 0x128(%rsp), %rsi
subq %rdi, %rsi
callq 0x21d0
leaq 0x6f51(%rip), %rdi      # 0xc3fa
leaq 0x6fe0(%rip), %rsi      # 0xc490
xorl %eax, %eax
callq 0x2050
movq 0x9afa(%rip), %rax      # 0xefb8
movq (%rax), %rdi
callq 0x2200
leaq 0x110(%rsp), %rdi
callq 0x5810
leaq 0x38(%rsp), %rdi
callq 0x58f0
testq %rbx, %rbx
je 0x55a1
leaq 0x138(%rsp), %r14
leaq 0x118(%rsp), %r15
leaq 0x38(%rsp), %r13
leaq 0x10(%rsp), %rbp
movq %r14, %rdi
callq 0x657e
callq 0x2210
movq 0xa0(%rsp), %rdx
movq 0xe8(%rsp), %rdi
movq %rax, 0x130(%rsp)
movq 0xe0(%rsp), %rsi
callq 0x2806
callq 0x2210
movq %rax, %r12
movq %r14, %rdi
movq %r15, %rsi
callq 0x667e
subq 0x130(%rsp), %r12
vcvtsi2sd %r12, %xmm4, %xmm0
vdivsd 0x6d8e(%rip), %xmm0, %xmm0 # 0xc2e8
vmovsd %xmm0, 0x110(%rsp)
vmovsd %xmm0, 0x10(%rsp)
leaq 0x18(%rsp), %rdi
movq %r15, %rsi
callq 0x67c2
movq %r13, %rdi
movq %rbp, %rsi
callq 0x5baa
movq 0x18(%rsp), %rdi
testq %rdi, %rdi
je 0x5598
movq 0x28(%rsp), %rsi
subq %rdi, %rsi
callq 0x21d0
decq %rbx
jne 0x5500
vmovsd 0x60(%rsp), %xmm1
vmovsd 0x30(%rsp), %xmm3
cmpb $0x1, 0x13c(%rsp)
vmulsd 0x6d2b(%rip), %xmm1, %xmm0 # 0xc2e8
vdivsd %xmm0, %xmm3, %xmm2
jne 0x55f5
movq 0x68(%rsp), %rax
vcvtusi2sdq 0x8(%rax), %xmm4, %xmm0
leaq 0x6e34(%rip), %rdi      # 0xc40a
vdivsd %xmm3, %xmm0, %xmm0
vcvtusi2sdq (%rax), %xmm4, %xmm3
movb $0x3, %al
vdivsd %xmm1, %xmm3, %xmm1
vdivsd 0x6cfa(%rip), %xmm1, %xmm1 # 0xc2e8
callq 0x2050
jmp 0x5607
leaq 0x6e55(%rip), %rdi      # 0xc451
movb $0x1, %al
vmovapd %xmm2, %xmm0
callq 0x2050
movq 0x88(%rsp), %rdi
testq %rdi, %rdi
je 0x5624
movq 0x98(%rsp), %rsi
subq %rdi, %rsi
callq 0x21d0
movq 0x68(%rsp), %rdi
testq %rdi, %rdi
je 0x563b
movq 0x78(%rsp), %rsi
subq %rdi, %rsi
callq 0x21d0
movq 0x48(%rsp), %rdi
testq %rdi, %rdi
je 0x5652
movq 0x58(%rsp), %rsi
subq %rdi, %rsi
callq 0x21d0
leaq 0x138(%rsp), %rbx
movq %rbx, %rdi
callq 0x6a50
movq -0x20(%rbx), %rdi
testq %rdi, %rdi
je 0x567b
movq 0x128(%rsp), %rsi
subq %rdi, %rsi
callq 0x21d0
movq 0xa0(%rsp), %rdi
testq %rdi, %rdi
je 0x5698
movq 0xb0(%rsp), %rsi
subq %rdi, %rsi
callq 0x21d0
movq 0xc0(%rsp), %rdi
testq %rdi, %rdi
je 0x56b5
movq 0xd0(%rsp), %rsi
subq %rdi, %rsi
callq 0x21d0
movq 0xe8(%rsp), %rdi
testq %rdi, %rdi
je 0x56d2
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 0x56f0
jmp 0x56f7
jmp 0x56f0
jmp 0x56f7
jmp 0x56f0
jmp 0x56f7
movq %rax, %rbx
jmp 0x5739
jmp 0x56f7
movq %rax, %rbx
jmp 0x5746
jmp 0x5702
jmp 0x5702
jmp 0x5702
movq 0x18(%rsp), %rdi
movq %rax, %rbx
testq %rdi, %rdi
je 0x572f
movq 0x28(%rsp), %rsi
subq %rdi, %rsi
callq 0x21d0
jmp 0x572f
jmp 0x572c
jmp 0x572c
jmp 0x572c
jmp 0x572c
jmp 0x572c
jmp 0x572c
jmp 0x572c
movq %rax, %rbx
leaq 0x38(%rsp), %rdi
callq 0x5c32
leaq 0x110(%rsp), %rdi
callq 0x5c78
movq 0xa0(%rsp), %rdi
testq %rdi, %rdi
je 0x5763
movq 0xb0(%rsp), %rsi
subq %rdi, %rsi
callq 0x21d0
movq 0xc0(%rsp), %rdi
testq %rdi, %rdi
je 0x5780
movq 0xd0(%rsp), %rsi
subq %rdi, %rsi
callq 0x21d0
movq 0xe8(%rsp), %rdi
testq %rdi, %rdi
je 0x579d
movq 0xf8(%rsp), %rsi
subq %rdi, %rsi
callq 0x21d0
movq %rbx, %rdi
callq 0x22b0
nop