// File: WojciechMula[P]utf16utf8/tests/unittest.cpp
// Function: validate(std::vector<unsigned short, std::allocator<unsigned short>> const&, unsigned long)
bool validate(const std::vector<uint16_t>& input, size_t size) {
    // reference
    std::string tmp;
    tmp.resize(4 * size);
    utf16_to_utf8(input.data(), (uint8_t*)tmp.data());
    const std::string reference{tmp.c_str()};

    // SSE
    tmp.assign("");
    tmp.resize(8 * size);
    const size_t output_size = sse_convert_utf16_to_utf8(input.data(), size, (uint8_t*)tmp.data());
    const std::string sse{tmp.data(), output_size};

    if(! compare_strings(reference, sse) ) {
        display<uint16_t>(input);
        return false;
    }
    return true;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x100, %rsp            # imm = 0x100
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
leaq -0x38(%rbp), %rdi
movq %rdi, -0xa8(%rbp)
callq 0x21f0
movq -0xa8(%rbp), %rdi
movq -0x18(%rbp), %rsi
shlq $0x2, %rsi
callq 0x21e0
jmp 0xc5a9
movq -0x10(%rbp), %rdi
callq 0xe060
movq %rax, -0xb0(%rbp)
leaq -0x38(%rbp), %rdi
callq 0x21b0
movq -0xb0(%rbp), %rdi
movq %rax, %rsi
callq 0xc7f0
jmp 0xc5d3
leaq -0x38(%rbp), %rdi
callq 0x2080
movq %rax, -0xc0(%rbp)
leaq -0x69(%rbp), %rdi
movq %rdi, -0xb8(%rbp)
callq 0x2290
movq -0xc0(%rbp), %rsi
movq -0xb8(%rbp), %rdx
leaq -0x68(%rbp), %rdi
callq 0x21d0
jmp 0xc60c
leaq -0x69(%rbp), %rdi
callq 0x2180
leaq 0x8d8b(%rip), %rsi      # 0x153a7
leaq -0x38(%rbp), %rdi
callq 0x22a0
jmp 0xc627
movq -0x18(%rbp), %rsi
shlq $0x3, %rsi
leaq -0x38(%rbp), %rdi
callq 0x21e0
jmp 0xc63a
movq -0x10(%rbp), %rdi
callq 0xe060
movq %rax, -0xd8(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0xd0(%rbp)
leaq -0x38(%rbp), %rdi
callq 0x21b0
movq -0xd8(%rbp), %rdi
movq -0xd0(%rbp), %rsi
movq %rax, %rdx
callq 0x74e0
movq %rax, -0xc8(%rbp)
jmp 0xc67d
movq -0xc8(%rbp), %rax
movq %rax, -0x78(%rbp)
leaq -0x38(%rbp), %rdi
callq 0x21b0
movq %rax, -0xf0(%rbp)
movq -0x78(%rbp), %rax
movq %rax, -0xe8(%rbp)
leaq -0x99(%rbp), %rdi
movq %rdi, -0xe0(%rbp)
callq 0x2290
movq -0xf0(%rbp), %rsi
movq -0xe8(%rbp), %rdx
movq -0xe0(%rbp), %rcx
leaq -0x98(%rbp), %rdi
callq 0x21a0
jmp 0xc6d9
leaq -0x99(%rbp), %rdi
callq 0x2180
leaq -0x68(%rbp), %rdi
leaq -0x98(%rbp), %rsi
callq 0xc410
movb %al, -0xf1(%rbp)
jmp 0xc6fd
movb -0xf1(%rbp), %al
testb $0x1, %al
jne 0xc795
jmp 0xc70d
movq -0x10(%rbp), %rdi
callq 0xe080
jmp 0xc718
movb $0x0, -0x1(%rbp)
movl $0x1, -0xa0(%rbp)
jmp 0xc7a3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0xc7d8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x69(%rbp), %rdi
callq 0x2180
jmp 0xc7d8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0xc7cf
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x99(%rbp), %rdi
callq 0x2180
jmp 0xc7cf
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x98(%rbp), %rdi
callq 0x20d0
jmp 0xc7cf
movb $0x1, -0x1(%rbp)
movl $0x1, -0xa0(%rbp)
leaq -0x98(%rbp), %rdi
callq 0x20d0
leaq -0x68(%rbp), %rdi
callq 0x20d0
leaq -0x38(%rbp), %rdi
callq 0x20d0
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0x100, %rsp            # imm = 0x100
popq %rbp
retq
leaq -0x68(%rbp), %rdi
callq 0x20d0
leaq -0x38(%rbp), %rdi
callq 0x20d0
movq -0x40(%rbp), %rdi
callq 0x2280
nopw (%rax,%rax)