// File: /workspace/github_cpp_makefile_star2_O2/WojciechMula[P]utf16utf8/benchmarks/benchmark_from_utf16.cpp
// Function: Benchmark::run_from_utf16()
void run_from_utf16() {
        printf("\n");
        printf("Running UTF16 => UTF8 benchmark.\n");
        printf("The speed is normalized by the number of input bytes.\n");

        const size_t repeat = 10000;
        RandomUTF16 gen_1byte (rd, 1, 0, 0, 0);
        RandomUTF16 gen_2bytes(rd, 0, 1, 0, 0);
        RandomUTF16 gen_3bytes(rd, 0, 0, 1, 0);
        RandomUTF16 gen_4bytes(rd, 0, 0, 0, 1);
        RandomUTF16 gen_1_2(rd, 1, 1, 0, 0);
        RandomUTF16 gen_1_2_3(rd, 1, 1, 1, 0);
        RandomUTF16 anylength (rd, 1, 1, 1, 1);

        printf("Input size: (UTF16) %lu\n", size);

        puts("- Output ASCII characters");
        run_from_utf16(gen_1byte, repeat);

        puts("- Output exactly 2 UTF8 bytes");
        run_from_utf16(gen_2bytes, repeat);

        puts("- Output exactly 3 UTF8 bytes");
        run_from_utf16(gen_3bytes, repeat);

        //puts("- Output exactly 4 UTF8 bytes");
        // Given that we do not optimize this case at
        // all, it is not a relevant benchmark.
        //run(gen_4bytes, repeat);

        puts("- Output 1 or 2 UTF8 bytes");
        run_from_utf16(gen_1_2, repeat);

        puts("- Output 1, 2 or 3 UTF8 bytes");
        run_from_utf16(gen_1_2_3, repeat);

        // Results from this benchmark appear bogus: SSE is too fast!!!
        //puts("- Output 1, 2, 3 or 4 UTF8 bytes");
        //run(anylength, repeat);
    }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x8b28, %rsp           # imm = 0x8B28
movq %rdi, %rbx
pushq $0xa
popq %rdi
callq 0x2200
leaq 0x7cc8(%rip), %rdi      # 0xc363
callq 0x2250
leaq 0x7cdd(%rip), %rdi      # 0xc384
callq 0x2250
leaq 0x8(%rbx), %r15
movq %rbx, %r14
leaq 0x8(%rsp), %rdi
pushq $0x1
popq %rbx
movq %r15, %rsi
movl %ebx, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
xorl %r9d, %r9d
callq 0x2efc
leaq 0x6368(%rsp), %rdi
movq %r15, %rsi
xorl %edx, %edx
movl %ebx, %ecx
xorl %r8d, %r8d
xorl %r9d, %r9d
callq 0x2efc
leaq 0x4f88(%rsp), %rdi
pushq $0x1
popq %r8
movq %r15, %rsi
xorl %edx, %edx
xorl %ecx, %ecx
xorl %r9d, %r9d
callq 0x2efc
leaq 0x3ba8(%rsp), %rdi
pushq $0x1
popq %r9
movq %r15, %rsi
xorl %edx, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
callq 0x2efc
movq %r14, %rbx
leaq 0x27c8(%rsp), %rdi
pushq $0x1
popq %rcx
movq %r15, %rsi
movl %ecx, %edx
xorl %r8d, %r8d
xorl %r9d, %r9d
callq 0x2efc
leaq 0x13e8(%rsp), %rdi
pushq $0x1
popq %rcx
movq %r15, %rsi
movl %ecx, %edx
movl %ecx, %r8d
xorl %r9d, %r9d
callq 0x2efc
leaq 0x7748(%rsp), %r12
pushq $0x1
popq %rcx
movq %r12, %rdi
movq %r15, %rsi
movl %ecx, %edx
movl %ecx, %r8d
movl %ecx, %r9d
callq 0x2efc
movq (%rbx), %rsi
leaq 0x79fa(%rip), %rdi      # 0xc178
xorl %eax, %eax
callq 0x2040
leaq 0x7a05(%rip), %rdi      # 0xc191
callq 0x2250
leaq 0x8(%rsp), %rsi
movl $0x2710, %edx           # imm = 0x2710
movq %rbx, %rdi
callq 0x497a
leaq 0x7a01(%rip), %rdi      # 0xc1ab
callq 0x2250
leaq 0x6368(%rsp), %r13
movl $0x2710, %edx           # imm = 0x2710
movq %rbx, %rdi
movq %r13, %rsi
callq 0x497a
leaq 0x79fb(%rip), %rdi      # 0xc1c9
callq 0x2250
leaq 0x4f88(%rsp), %rbp
movl $0x2710, %edx           # imm = 0x2710
movq %rbx, %rdi
movq %rbp, %rsi
callq 0x497a
leaq 0x79f5(%rip), %rdi      # 0xc1e7
callq 0x2250
leaq 0x27c8(%rsp), %r14
movl $0x2710, %edx           # imm = 0x2710
movq %rbx, %rdi
movq %r14, %rsi
callq 0x497a
leaq 0x79ec(%rip), %rdi      # 0xc202
callq 0x2250
movq %rbx, %rdi
leaq 0x13e8(%rsp), %rbx
movl $0x2710, %edx           # imm = 0x2710
movq %rbx, %rsi
callq 0x497a
movl $0x1388, %r15d          # imm = 0x1388
addq %r15, %r12
movq %r12, %rdi
callq 0x61ba
addq %r15, %rbx
movq %rbx, %rdi
callq 0x61ba
addq %r15, %r14
movq %r14, %rdi
callq 0x61ba
leaq 0x3ba8(%rsp), %rdi
addq %r15, %rdi
callq 0x61ba
addq %r15, %rbp
movq %rbp, %rdi
callq 0x61ba
addq %r15, %r13
movq %r13, %rdi
callq 0x61ba
leaq 0x8(%rsp), %rdi
addq %r15, %rdi
callq 0x61ba
addq $0x8b28, %rsp           # imm = 0x8B28
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
jmp 0x48cd
movq %rax, %rbx
jmp 0x48da
movq %rax, %rbx
jmp 0x48e7
movq %rax, %rbx
jmp 0x48f4
movq %rax, %rbx
jmp 0x4901
movq %rax, %rbx
jmp 0x490e
leaq 0x8ad0(%rsp), %rdi
movq %rax, %rbx
callq 0x61ba
leaq 0x2770(%rsp), %rdi
callq 0x61ba
leaq 0x3b50(%rsp), %rdi
callq 0x61ba
leaq 0x4f30(%rsp), %rdi
callq 0x61ba
leaq 0x6310(%rsp), %rdi
callq 0x61ba
leaq 0x76f0(%rsp), %rdi
callq 0x61ba
leaq 0x1390(%rsp), %rdi
callq 0x61ba
movq %rbx, %rdi
callq 0x22b0
nop