// File: lemire[P]validateutf8-experiments/benchmarks/benchmark.cpp
// Function: Benchmark::run()
void run() {
    printf("\n");
    printf("Running UTF8 validation benchmark.\n");
    printf("The speed is normalized by the number of input bytes.\n");
    const size_t repeat = 1000;
    RandomUTF8 gen_1byte(rd, 1, 0, 0, 0);
    RandomUTF8 gen_2bytes(rd, 0, 1, 0, 0);
    RandomUTF8 gen_1_2(rd, 1, 1, 0, 0);
    RandomUTF8 gen_1_2_3(rd, 1, 1, 1, 0);
    RandomUTF8 gen_1_2_3_4(rd, 1, 1, 1, 1);
    RandomUTF8 gen_3bytes(rd, 0, 0, 1, 0);
    RandomUTF8 gen_4bytes(rd, 0, 0, 0, 1);
    printf("Input size: (UTF8) %lu\n", size);

    puts("- ASCII characters");
    run(gen_1byte, repeat);

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

    puts("- 1, 2, 3 UTF8 bytes");
    run(gen_1_2_3, repeat);

    puts("- 1, 2, 3, 4 UTF8 bytes");
    run(gen_1_2_3_4, repeat);
  }

// Assembly:
subq $0x8ab8, %rsp           # imm = 0x8AB8
movq %rdi, 0x8ab0(%rsp)
movq 0x8ab0(%rsp), %rax
movq %rax, 0x8(%rsp)
leaq 0x193fc(%rip), %rdi     # 0x11228f
xorl %eax, %eax
movl %eax, 0x1c(%rsp)
movb %al, 0x7(%rsp)
callq 0x2030
movb 0x7(%rsp), %al
leaq 0x1928b(%rip), %rdi     # 0x112138
callq 0x2030
movb 0x7(%rsp), %al
leaq 0x1929f(%rip), %rdi     # 0x11215c
callq 0x2030
movq 0x8(%rsp), %rsi
movl 0x1c(%rsp), %r9d
movq $0x3e8, 0x8aa8(%rsp) # imm = 0x3E8
addq $0x8, %rsi
movq %rsi, 0x10(%rsp)
leaq 0x76e0(%rsp), %rdi
movl $0x1, %edx
movl %edx, 0x18(%rsp)
movl %r9d, %ecx
movl %r9d, %r8d
callq 0x10e880
movq 0x10(%rsp), %rsi
movl 0x18(%rsp), %ecx
movl 0x1c(%rsp), %r9d
leaq 0x6318(%rsp), %rdi
movl %r9d, %edx
movl %r9d, %r8d
callq 0x10e880
jmp 0xf8f20
movq 0x8(%rsp), %rsi
addq $0x8, %rsi
leaq 0x4f40(%rsp), %rdi
movl $0x1, %ecx
xorl %r9d, %r9d
movl %ecx, %edx
movl %r9d, %r8d
callq 0x10e880
jmp 0xf8f45
movq 0x8(%rsp), %rsi
addq $0x8, %rsi
leaq 0x3b78(%rsp), %rdi
movl $0x1, %r8d
xorl %r9d, %r9d
movl %r8d, %edx
movl %r8d, %ecx
callq 0x10e880
jmp 0xf8f6c
movq 0x8(%rsp), %rsi
addq $0x8, %rsi
leaq 0x27b0(%rsp), %rdi
movl $0x1, %r9d
movl %r9d, %edx
movl %r9d, %ecx
movl %r9d, %r8d
callq 0x10e880
jmp 0xf8f93
movq 0x8(%rsp), %rsi
addq $0x8, %rsi
leaq 0x13e8(%rsp), %rdi
movl $0x1, %r8d
xorl %r9d, %r9d
movl %r9d, %edx
movl %r9d, %ecx
callq 0x10e880
jmp 0xf8fba
movq 0x8(%rsp), %rsi
addq $0x8, %rsi
leaq 0x20(%rsp), %rdi
xorl %r8d, %r8d
movl $0x1, %r9d
movl %r8d, %edx
movl %r8d, %ecx
callq 0x10e880
jmp 0xf8fde
movq 0x8(%rsp), %rax
movq (%rax), %rsi
leaq 0x193f8(%rip), %rdi     # 0x1123e5
xorl %eax, %eax
callq 0x2030
jmp 0xf8ff6
leaq 0x19400(%rip), %rdi     # 0x1123fd
callq 0x22f0
jmp 0xf9004
movq 0x8(%rsp), %rdi
leaq 0x76e0(%rsp), %rsi
movl $0x3e8, %edx            # imm = 0x3E8
callq 0x1067d0
jmp 0xf901d
leaq 0x193ec(%rip), %rdi     # 0x112410
callq 0x22f0
jmp 0xf902b
movq 0x8(%rsp), %rdi
leaq 0x4f40(%rsp), %rsi
movl $0x3e8, %edx            # imm = 0x3E8
callq 0x1067d0
jmp 0xf9044
leaq 0x193d9(%rip), %rdi     # 0x112424
callq 0x22f0
jmp 0xf9052
movq 0x8(%rsp), %rdi
leaq 0x3b78(%rsp), %rsi
movl $0x3e8, %edx            # imm = 0x3E8
callq 0x1067d0
jmp 0xf906b
leaq 0x193c7(%rip), %rdi     # 0x112439
callq 0x22f0
jmp 0xf9079
movq 0x8(%rsp), %rdi
leaq 0x27b0(%rsp), %rsi
movl $0x3e8, %edx            # imm = 0x3E8
callq 0x1067d0
jmp 0xf9092
leaq 0x20(%rsp), %rdi
callq 0x10c020
leaq 0x13e8(%rsp), %rdi
callq 0x10c020
leaq 0x27b0(%rsp), %rdi
callq 0x10c020
leaq 0x3b78(%rsp), %rdi
callq 0x10c020
leaq 0x4f40(%rsp), %rdi
callq 0x10c020
leaq 0x6318(%rsp), %rdi
callq 0x10c020
leaq 0x76e0(%rsp), %rdi
callq 0x10c020
addq $0x8ab8, %rsp           # imm = 0x8AB8
retq
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x6310(%rsp)
movl %eax, 0x630c(%rsp)
jmp 0xf91de
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x6310(%rsp)
movl %eax, 0x630c(%rsp)
jmp 0xf91d1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x6310(%rsp)
movl %eax, 0x630c(%rsp)
jmp 0xf91c4
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x6310(%rsp)
movl %eax, 0x630c(%rsp)
jmp 0xf91b7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x6310(%rsp)
movl %eax, 0x630c(%rsp)
jmp 0xf91aa
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x6310(%rsp)
movl %eax, 0x630c(%rsp)
jmp 0xf919d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x6310(%rsp)
movl %eax, 0x630c(%rsp)
leaq 0x20(%rsp), %rdi
callq 0x10c020
leaq 0x13e8(%rsp), %rdi
callq 0x10c020
leaq 0x27b0(%rsp), %rdi
callq 0x10c020
leaq 0x3b78(%rsp), %rdi
callq 0x10c020
leaq 0x4f40(%rsp), %rdi
callq 0x10c020
leaq 0x6318(%rsp), %rdi
callq 0x10c020
leaq 0x76e0(%rsp), %rdi
callq 0x10c020
movq 0x6310(%rsp), %rdi
callq 0x2340
nopl (%rax,%rax)