// File: /workspace/github_c_makefile_star2_O0/svpv[P]rpmset/bench-base64unpack.c
// Function: bench_LOOP
void bench_LOOP(const char *name,
	void (*pack)(const uint32_t *v, char *s, unsigned e),
	uint64_t (*unpack_loop16)(const char *s, uint32_t *v, unsigned *e),
	unsigned m, unsigned n, unsigned c, unsigned em, unsigned o)
{
    uint32_t v[LOOP*n+1], w[LOOP*n+1];
    for (unsigned i = 0; i < LOOP*n; i++)
	v[i] = rand32(), w[i] = rand32();
    unsigned ev[LOOP], ew[LOOP];
    for (unsigned i = 0; i < LOOP; i++)
	ev[i] = rand32(), ew[i] = rand32();
    char s_[2+LOOP*c+2], *s = s_ + 2;
    s_[0] = 'b', s_[1] = 'M';
    for (unsigned i = 0; i < LOOP; i++)
	pack(v + n * i, s + c * i, ev[i]);
    s[LOOP*c] = 'x', s[LOOP*c+o] = '\0';
    uint64_t t = 0;
    for (unsigned i = 0; i < (1<<16); i++) {
	uint64_t x = unpack_loop16(s, w, ew);
	assert(x);
	t += x;
    }
    for (unsigned i = 0; i < LOOP*n; i++)
	v[i] &= (1 << m) - 1;
    assert(memcmp(v, w, LOOP*n * 4) == 0);
    if (em) {
	for (unsigned i = 0; i < LOOP; i++)
	    ev[i] &= (1 << em) - 1;
	assert(memcmp(ev, ew, LOOP * 4) == 0);
    }
    fprintf(stderr, "%s: %.2f cycles per integer\n",
	    name, (double) t / (LOOP*n) / (1<<16));
    // Must fail on invalid inputs.
    for (unsigned i = 0; i < LOOP*c; i++) {
	char fita; // Gogol's indecent letter
	do
	    fita = rand32();
	while ((int32_t)base64dec1(&fita) >= 0);
	char save = s[i];
	s[i] = fita;
	uint64_t x = unpack_loop16(s, w, ew);
	assert(x == 0);
	s[i] = save;
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x8b0, %rsp            # imm = 0x8B0
movl 0x18(%rbp), %eax
movl 0x10(%rbp), %eax
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movl %ecx, -0x1c(%rbp)
movl %r8d, -0x20(%rbp)
movl %r9d, -0x24(%rbp)
movl -0x20(%rbp), %eax
shll $0x8, %eax
movl %eax, %ecx
movq %rcx, %rax
incq %rax
movq %rsp, %rdx
movq %rdx, -0x30(%rbp)
leaq 0x13(,%rcx,4), %rdx
andq $-0x3f0, %rdx           # imm = 0xFC10
movq %rsp, %rcx
subq %rdx, %rcx
movq %rcx, -0x8b0(%rbp)
movq %rcx, %rsp
movq %rax, -0x38(%rbp)
movl -0x20(%rbp), %eax
shll $0x8, %eax
movl %eax, %ecx
movq %rcx, %rax
incq %rax
leaq 0x13(,%rcx,4), %rdx
andq $-0x3f0, %rdx           # imm = 0xFC10
movq %rsp, %rcx
subq %rdx, %rcx
movq %rcx, -0x8a8(%rbp)
movq %rcx, %rsp
movq %rax, -0x40(%rbp)
movl $0x0, -0x44(%rbp)
movl -0x44(%rbp), %eax
movl -0x20(%rbp), %ecx
shll $0x8, %ecx
cmpl %ecx, %eax
jae 0x13418
callq 0x13840
movl %eax, %edx
movq -0x8b0(%rbp), %rax
movl -0x44(%rbp), %ecx
movl %edx, (%rax,%rcx,4)
callq 0x13840
movl %eax, %edx
movq -0x8a8(%rbp), %rax
movl -0x44(%rbp), %ecx
movl %edx, (%rax,%rcx,4)
movl -0x44(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x44(%rbp)
jmp 0x133d8
movl $0x0, -0x854(%rbp)
cmpl $0x100, -0x854(%rbp)    # imm = 0x100
jae 0x13467
callq 0x13840
movl %eax, %ecx
movl -0x854(%rbp), %eax
movl %ecx, -0x450(%rbp,%rax,4)
callq 0x13840
movl %eax, %ecx
movl -0x854(%rbp), %eax
movl %ecx, -0x850(%rbp,%rax,4)
movl -0x854(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x854(%rbp)
jmp 0x13422
movl -0x24(%rbp), %eax
shll $0x8, %eax
movl %eax, %ecx
orl $0x4, %ecx
orl $0x10, %eax
movl %eax, %edx
movq %rsp, %rax
subq %rdx, %rax
movq %rax, %rsp
movq %rcx, -0x860(%rbp)
movq %rax, %rcx
addq $0x2, %rcx
movq %rcx, -0x868(%rbp)
movb $0x62, (%rax)
movb $0x4d, 0x1(%rax)
movl $0x0, -0x86c(%rbp)
cmpl $0x100, -0x86c(%rbp)    # imm = 0x100
jae 0x13506
movq -0x8b0(%rbp), %rdi
movq -0x10(%rbp), %rax
movl -0x20(%rbp), %ecx
imull -0x86c(%rbp), %ecx
movl %ecx, %ecx
shlq $0x2, %rcx
addq %rcx, %rdi
movq -0x868(%rbp), %rsi
movl -0x24(%rbp), %ecx
imull -0x86c(%rbp), %ecx
movl %ecx, %ecx
addq %rcx, %rsi
movl -0x86c(%rbp), %ecx
movl -0x450(%rbp,%rcx,4), %edx
callq *%rax
movl -0x86c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x86c(%rbp)
jmp 0x134a6
movq -0x868(%rbp), %rax
movl -0x24(%rbp), %ecx
shll $0x8, %ecx
movl %ecx, %ecx
movb $0x78, (%rax,%rcx)
movq -0x868(%rbp), %rax
movl -0x24(%rbp), %ecx
shll $0x8, %ecx
addl 0x18(%rbp), %ecx
movl %ecx, %ecx
movb $0x0, (%rax,%rcx)
movq $0x0, -0x878(%rbp)
movl $0x0, -0x87c(%rbp)
cmpl $0x10000, -0x87c(%rbp)  # imm = 0x10000
jae 0x135c3
movq -0x8a8(%rbp), %rsi
movq -0x18(%rbp), %rax
movq -0x868(%rbp), %rdi
leaq -0x850(%rbp), %rdx
callq *%rax
movq %rax, -0x888(%rbp)
cmpq $0x0, -0x888(%rbp)
je 0x1357e
jmp 0x1359d
leaq 0xb9fb(%rip), %rdi      # 0x1ef80
leaq 0xb9f6(%rip), %rsi      # 0x1ef82
movl $0x7b, %edx
leaq 0xb9ff(%rip), %rcx      # 0x1ef97
callq 0x1030
movq -0x888(%rbp), %rax
addq -0x878(%rbp), %rax
movq %rax, -0x878(%rbp)
movl -0x87c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x87c(%rbp)
jmp 0x13544
movl $0x0, -0x88c(%rbp)
movl -0x88c(%rbp), %eax
movl -0x20(%rbp), %ecx
shll $0x8, %ecx
cmpl %ecx, %eax
jae 0x1360e
movq -0x8b0(%rbp), %rax
movl -0x1c(%rbp), %ecx
movl $0x1, %edx
shll %cl, %edx
subl $0x1, %edx
movl -0x88c(%rbp), %ecx
andl (%rax,%rcx,4), %edx
movl %edx, (%rax,%rcx,4)
movl -0x88c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x88c(%rbp)
jmp 0x135cd
movq -0x8a8(%rbp), %rsi
movq -0x8b0(%rbp), %rdi
movl -0x20(%rbp), %eax
shll $0x8, %eax
shll $0x2, %eax
movl %eax, %eax
movl %eax, %edx
callq 0x1040
cmpl $0x0, %eax
jne 0x13635
jmp 0x13654
leaq 0xba29(%rip), %rdi      # 0x1f065
leaq 0xb93f(%rip), %rsi      # 0x1ef82
movl $0x80, %edx
leaq 0xb948(%rip), %rcx      # 0x1ef97
callq 0x1030
cmpl $0x0, 0x10(%rbp)
je 0x136e8
movl $0x0, -0x890(%rbp)
cmpl $0x100, -0x890(%rbp)    # imm = 0x100
jae 0x136a8
movl 0x10(%rbp), %ecx
movl $0x1, %eax
shll %cl, %eax
movl %eax, %ecx
subl $0x1, %ecx
movl -0x890(%rbp), %eax
andl -0x450(%rbp,%rax,4), %ecx
movl %ecx, -0x450(%rbp,%rax,4)
movl -0x890(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x890(%rbp)
jmp 0x13668
leaq -0x450(%rbp), %rdi
leaq -0x850(%rbp), %rsi
movl $0x400, %edx            # imm = 0x400
callq 0x1040
cmpl $0x0, %eax
jne 0x136c7
jmp 0x136e6
leaq 0xb9b5(%rip), %rdi      # 0x1f083
leaq 0xb8ad(%rip), %rsi      # 0x1ef82
movl $0x84, %edx
leaq 0xb8b6(%rip), %rcx      # 0x1ef97
callq 0x1030
jmp 0x136e8
movq 0xe909(%rip), %rax      # 0x21ff8
movq (%rax), %rdi
movq -0x8(%rbp), %rdx
vmovdqa 0xb862(%rip), %xmm1     # 0x1ef60
vmovq -0x878(%rbp), %xmm0
vpunpckldq %xmm1, %xmm0, %xmm0 # xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
vmovapd 0xb85e(%rip), %xmm1     # 0x1ef70
vsubpd %xmm1, %xmm0, %xmm0
vmovaps %xmm0, %xmm1
vpermilpd $0x1, %xmm0, %xmm0 # xmm0 = xmm0[1,0]
vaddsd %xmm1, %xmm0, %xmm0
movl -0x20(%rbp), %eax
shll $0x8, %eax
vcvtsi2sd %rax, %xmm1, %xmm1
vdivsd %xmm1, %xmm0, %xmm0
vmovsd 0xb815(%rip), %xmm1     # 0x1ef50
vdivsd %xmm1, %xmm0, %xmm0
leaq 0xb95b(%rip), %rsi      # 0x1f0a1
movb $0x1, %al
callq 0x1050
movl $0x0, -0x894(%rbp)
movl -0x894(%rbp), %eax
movl -0x24(%rbp), %ecx
shll $0x8, %ecx
cmpl %ecx, %eax
jae 0x1382c
jmp 0x1376d
callq 0x13840
movb %al, -0x895(%rbp)
leaq -0x895(%rbp), %rdi
callq 0x13870
cmpl $0x0, %eax
jge 0x1376d
movq -0x8a8(%rbp), %rsi
movq -0x868(%rbp), %rax
movl -0x894(%rbp), %ecx
movb (%rax,%rcx), %al
movb %al, -0x896(%rbp)
movb -0x895(%rbp), %dl
movq -0x868(%rbp), %rax
movl -0x894(%rbp), %ecx
movb %dl, (%rax,%rcx)
movq -0x18(%rbp), %rax
movq -0x868(%rbp), %rdi
leaq -0x850(%rbp), %rdx
callq *%rax
movq %rax, -0x8a0(%rbp)
cmpq $0x0, -0x8a0(%rbp)
jne 0x137e3
jmp 0x13802
leaq 0xb8d4(%rip), %rdi      # 0x1f0be
leaq 0xb791(%rip), %rsi      # 0x1ef82
movl $0x91, %edx
leaq 0xb79a(%rip), %rcx      # 0x1ef97
callq 0x1030
movb -0x896(%rbp), %dl
movq -0x868(%rbp), %rax
movl -0x894(%rbp), %ecx
movb %dl, (%rax,%rcx)
movl -0x894(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x894(%rbp)
jmp 0x13757
movq -0x30(%rbp), %rax
movq %rax, %rsp
movq %rbp, %rsp
popq %rbp
retq
nopl (%rax,%rax)