// File: /workspace/github_c_makefile_star2_O0/lh3[P]fermi-lite/rle.c
// Function: rle_rank2a
void rle_rank2a(const uint8_t *block, int64_t x, int64_t y, int64_t *cx, int64_t *cy, const int64_t ec[6])
{
	int a;
	int64_t tot, cnt[6];
	const uint8_t *p;

	y = y >= x? y : x;
	tot = ec[0] + ec[1] + ec[2] + ec[3] + ec[4] + ec[5];
	if (tot == 0) return;
	if (x <= (tot - y) + (tot>>3)) {
		int c = 0;
		int64_t l, z = 0;
		memset(cnt, 0, 48);
		p = block + 2;
		while (z < x) {
			rle_dec1(p, c, l);
			z += l; cnt[c] += l;
		}
		for (a = 0; a != 6; ++a) cx[a] += cnt[a];
		cx[c] -= z - x;
		if (cy) {
			while (z < y) {
				rle_dec1(p, c, l);
				z += l; cnt[c] += l;
			}
			for (a = 0; a != 6; ++a) cy[a] += cnt[a];
			cy[c] -= z - y;
		}
	} else {
#define move_backward(_x) \
		while (z >= (_x)) { \
			--p; \
			if (*p>>6 != 2) { \
				l |= *p>>7? (int64_t)rle_auxtab[*p>>3&7]>>4 << t : *p>>3; \
				z -= l; cnt[*p&7] -= l; \
				l = 0; t = 0; \
			} else { \
				l |= (*p&0x3fL) << t; \
				t += 6; \
			} \
		} \

		int t = 0;
		int64_t l = 0, z = tot;
		memcpy(cnt, ec, 48);
		p = block + 2 + *(const uint16_t*)block;
		if (cy) {
			move_backward(y)
			for (a = 0; a != 6; ++a) cy[a] += cnt[a];
			cy[*p&7] += y - z;
		}
		move_backward(x)
		for (a = 0; a != 6; ++a) cx[a] += cnt[a];
		cx[*p&7] += x - z;

#undef move_backward
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xd0, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
movq %r9, -0x30(%rbp)
movq -0x18(%rbp), %rax
cmpq -0x10(%rbp), %rax
jl 0x244ba
movq -0x18(%rbp), %rax
movq %rax, -0xb8(%rbp)
jmp 0x244c5
movq -0x10(%rbp), %rax
movq %rax, -0xb8(%rbp)
movq -0xb8(%rbp), %rax
movq %rax, -0x18(%rbp)
movq -0x30(%rbp), %rax
movq (%rax), %rax
movq -0x30(%rbp), %rcx
addq 0x8(%rcx), %rax
movq -0x30(%rbp), %rcx
addq 0x10(%rcx), %rax
movq -0x30(%rbp), %rcx
addq 0x18(%rcx), %rax
movq -0x30(%rbp), %rcx
addq 0x20(%rcx), %rax
movq -0x30(%rbp), %rcx
addq 0x28(%rcx), %rax
movq %rax, -0x40(%rbp)
cmpq $0x0, -0x40(%rbp)
jne 0x2450f
jmp 0x24c09
movq -0x10(%rbp), %rax
movq -0x40(%rbp), %rcx
subq -0x18(%rbp), %rcx
movq -0x40(%rbp), %rdx
sarq $0x3, %rdx
addq %rdx, %rcx
cmpq %rcx, %rax
jg 0x248cb
movl $0x0, -0x7c(%rbp)
movq $0x0, -0x90(%rbp)
leaq -0x70(%rbp), %rdi
xorl %esi, %esi
movl $0x30, %edx
callq 0x2110
movq -0x8(%rbp), %rax
addq $0x2, %rax
movq %rax, -0x78(%rbp)
movq -0x90(%rbp), %rax
cmpq -0x10(%rbp), %rax
jge 0x246bc
jmp 0x24570
movq -0x78(%rbp), %rax
movzbl (%rax), %eax
andl $0x7, %eax
movl %eax, -0x7c(%rbp)
movq -0x78(%rbp), %rax
movzbl (%rax), %eax
andl $0x80, %eax
cmpl $0x0, %eax
sete %al
andb $0x1, %al
movzbl %al, %eax
cltq
cmpq $0x0, %rax
je 0x245bf
movq -0x78(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x78(%rbp)
movzbl (%rax), %eax
sarl $0x3, %eax
cltq
movq %rax, -0x88(%rbp)
jmp 0x2468b
movq -0x78(%rbp), %rax
movzbl (%rax), %eax
sarl $0x5, %eax
cmpl $0x6, %eax
sete %al
andb $0x1, %al
movzbl %al, %eax
cltq
cmpq $0x0, %rax
je 0x2460f
movq -0x78(%rbp), %rax
movzbl (%rax), %eax
andq $0x18, %rax
shlq $0x3, %rax
movq -0x78(%rbp), %rcx
movzbl 0x1(%rcx), %ecx
andq $0x3f, %rcx
orq %rcx, %rax
movq %rax, -0x88(%rbp)
movq -0x78(%rbp), %rax
addq $0x2, %rax
movq %rax, -0x78(%rbp)
jmp 0x24689
movq -0x78(%rbp), %rax
movzbl (%rax), %eax
andl $0x10, %eax
sarl $0x2, %eax
addl $0x4, %eax
movl %eax, -0x94(%rbp)
movq -0x78(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x78(%rbp)
movzbl (%rax), %eax
sarl $0x3, %eax
andl $0x1, %eax
cltq
movq %rax, -0x88(%rbp)
movl -0x94(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x94(%rbp)
cmpl $0x0, %eax
je 0x24687
movq -0x88(%rbp), %rax
shlq $0x6, %rax
movq -0x78(%rbp), %rcx
movq %rcx, %rdx
addq $0x1, %rdx
movq %rdx, -0x78(%rbp)
movzbl (%rcx), %ecx
andq $0x3f, %rcx
orq %rcx, %rax
movq %rax, -0x88(%rbp)
jmp 0x24646
jmp 0x24689
jmp 0x2468b
jmp 0x2468d
movq -0x88(%rbp), %rax
addq -0x90(%rbp), %rax
movq %rax, -0x90(%rbp)
movq -0x88(%rbp), %rcx
movslq -0x7c(%rbp), %rax
addq -0x70(%rbp,%rax,8), %rcx
movq %rcx, -0x70(%rbp,%rax,8)
jmp 0x2455d
movl $0x0, -0x34(%rbp)
cmpl $0x6, -0x34(%rbp)
je 0x246ed
movslq -0x34(%rbp), %rax
movq -0x70(%rbp,%rax,8), %rdx
movq -0x20(%rbp), %rax
movslq -0x34(%rbp), %rcx
addq (%rax,%rcx,8), %rdx
movq %rdx, (%rax,%rcx,8)
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x246c3
movq -0x90(%rbp), %rsi
subq -0x10(%rbp), %rsi
movq -0x20(%rbp), %rax
movslq -0x7c(%rbp), %rcx
movq (%rax,%rcx,8), %rdx
subq %rsi, %rdx
movq %rdx, (%rax,%rcx,8)
cmpq $0x0, -0x28(%rbp)
je 0x248c6
jmp 0x24718
movq -0x90(%rbp), %rax
cmpq -0x18(%rbp), %rax
jge 0x24877
jmp 0x2472b
movq -0x78(%rbp), %rax
movzbl (%rax), %eax
andl $0x7, %eax
movl %eax, -0x7c(%rbp)
movq -0x78(%rbp), %rax
movzbl (%rax), %eax
andl $0x80, %eax
cmpl $0x0, %eax
sete %al
andb $0x1, %al
movzbl %al, %eax
cltq
cmpq $0x0, %rax
je 0x2477a
movq -0x78(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x78(%rbp)
movzbl (%rax), %eax
sarl $0x3, %eax
cltq
movq %rax, -0x88(%rbp)
jmp 0x24846
movq -0x78(%rbp), %rax
movzbl (%rax), %eax
sarl $0x5, %eax
cmpl $0x6, %eax
sete %al
andb $0x1, %al
movzbl %al, %eax
cltq
cmpq $0x0, %rax
je 0x247ca
movq -0x78(%rbp), %rax
movzbl (%rax), %eax
andq $0x18, %rax
shlq $0x3, %rax
movq -0x78(%rbp), %rcx
movzbl 0x1(%rcx), %ecx
andq $0x3f, %rcx
orq %rcx, %rax
movq %rax, -0x88(%rbp)
movq -0x78(%rbp), %rax
addq $0x2, %rax
movq %rax, -0x78(%rbp)
jmp 0x24844
movq -0x78(%rbp), %rax
movzbl (%rax), %eax
andl $0x10, %eax
sarl $0x2, %eax
addl $0x4, %eax
movl %eax, -0x98(%rbp)
movq -0x78(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x78(%rbp)
movzbl (%rax), %eax
sarl $0x3, %eax
andl $0x1, %eax
cltq
movq %rax, -0x88(%rbp)
movl -0x98(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x98(%rbp)
cmpl $0x0, %eax
je 0x24842
movq -0x88(%rbp), %rax
shlq $0x6, %rax
movq -0x78(%rbp), %rcx
movq %rcx, %rdx
addq $0x1, %rdx
movq %rdx, -0x78(%rbp)
movzbl (%rcx), %ecx
andq $0x3f, %rcx
orq %rcx, %rax
movq %rax, -0x88(%rbp)
jmp 0x24801
jmp 0x24844
jmp 0x24846
jmp 0x24848
movq -0x88(%rbp), %rax
addq -0x90(%rbp), %rax
movq %rax, -0x90(%rbp)
movq -0x88(%rbp), %rcx
movslq -0x7c(%rbp), %rax
addq -0x70(%rbp,%rax,8), %rcx
movq %rcx, -0x70(%rbp,%rax,8)
jmp 0x24718
movl $0x0, -0x34(%rbp)
cmpl $0x6, -0x34(%rbp)
je 0x248a8
movslq -0x34(%rbp), %rax
movq -0x70(%rbp,%rax,8), %rdx
movq -0x28(%rbp), %rax
movslq -0x34(%rbp), %rcx
addq (%rax,%rcx,8), %rdx
movq %rdx, (%rax,%rcx,8)
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x2487e
movq -0x90(%rbp), %rsi
subq -0x18(%rbp), %rsi
movq -0x28(%rbp), %rax
movslq -0x7c(%rbp), %rcx
movq (%rax,%rcx,8), %rdx
subq %rsi, %rdx
movq %rdx, (%rax,%rcx,8)
jmp 0x24c09
movl $0x0, -0x9c(%rbp)
movq $0x0, -0xa8(%rbp)
movq -0x40(%rbp), %rax
movq %rax, -0xb0(%rbp)
leaq -0x70(%rbp), %rdi
movq -0x30(%rbp), %rsi
movl $0x30, %edx
callq 0x2190
movq -0x8(%rbp), %rax
addq $0x2, %rax
movq -0x8(%rbp), %rcx
movzwl (%rcx), %ecx
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, -0x78(%rbp)
cmpq $0x0, -0x28(%rbp)
je 0x24a95
jmp 0x24923
movq -0xb0(%rbp), %rax
cmpq -0x18(%rbp), %rax
jl 0x24a40
movq -0x78(%rbp), %rax
addq $-0x1, %rax
movq %rax, -0x78(%rbp)
movq -0x78(%rbp), %rax
movzbl (%rax), %eax
sarl $0x6, %eax
cmpl $0x2, %eax
je 0x24a0a
movq -0x78(%rbp), %rax
movzbl (%rax), %eax
sarl $0x7, %eax
cmpl $0x0, %eax
je 0x24993
movq -0x78(%rbp), %rax
movzbl (%rax), %eax
sarl $0x3, %eax
andl $0x7, %eax
movslq %eax, %rcx
leaq 0x1540(%rip), %rax      # 0x25eb9
movzbl (%rax,%rcx), %eax
sarq $0x4, %rax
movl -0x9c(%rbp), %ecx
shlq %cl, %rax
movq %rax, -0xc0(%rbp)
jmp 0x249a6
movq -0x78(%rbp), %rax
movzbl (%rax), %eax
sarl $0x3, %eax
cltq
movq %rax, -0xc0(%rbp)
movq -0xc0(%rbp), %rax
orq -0xa8(%rbp), %rax
movq %rax, -0xa8(%rbp)
movq -0xa8(%rbp), %rcx
movq -0xb0(%rbp), %rax
subq %rcx, %rax
movq %rax, -0xb0(%rbp)
movq -0xa8(%rbp), %rdx
movq -0x78(%rbp), %rax
movzbl (%rax), %eax
andl $0x7, %eax
cltq
movq -0x70(%rbp,%rax,8), %rcx
subq %rdx, %rcx
movq %rcx, -0x70(%rbp,%rax,8)
movq $0x0, -0xa8(%rbp)
movl $0x0, -0x9c(%rbp)
jmp 0x24a3b
movq -0x78(%rbp), %rax
movzbl (%rax), %eax
andq $0x3f, %rax
movl -0x9c(%rbp), %ecx
shlq %cl, %rax
orq -0xa8(%rbp), %rax
movq %rax, -0xa8(%rbp)
movl -0x9c(%rbp), %eax
addl $0x6, %eax
movl %eax, -0x9c(%rbp)
jmp 0x24923
movl $0x0, -0x34(%rbp)
cmpl $0x6, -0x34(%rbp)
je 0x24a71
movslq -0x34(%rbp), %rax
movq -0x70(%rbp,%rax,8), %rdx
movq -0x28(%rbp), %rax
movslq -0x34(%rbp), %rcx
addq (%rax,%rcx,8), %rdx
movq %rdx, (%rax,%rcx,8)
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x24a47
movq -0x18(%rbp), %rdx
subq -0xb0(%rbp), %rdx
movq -0x28(%rbp), %rax
movq -0x78(%rbp), %rcx
movzbl (%rcx), %ecx
andl $0x7, %ecx
movslq %ecx, %rcx
addq (%rax,%rcx,8), %rdx
movq %rdx, (%rax,%rcx,8)
jmp 0x24a97
movq -0xb0(%rbp), %rax
cmpq -0x10(%rbp), %rax
jl 0x24bb4
movq -0x78(%rbp), %rax
addq $-0x1, %rax
movq %rax, -0x78(%rbp)
movq -0x78(%rbp), %rax
movzbl (%rax), %eax
sarl $0x6, %eax
cmpl $0x2, %eax
je 0x24b7e
movq -0x78(%rbp), %rax
movzbl (%rax), %eax
sarl $0x7, %eax
cmpl $0x0, %eax
je 0x24b07
movq -0x78(%rbp), %rax
movzbl (%rax), %eax
sarl $0x3, %eax
andl $0x7, %eax
movslq %eax, %rcx
leaq 0x13cc(%rip), %rax      # 0x25eb9
movzbl (%rax,%rcx), %eax
sarq $0x4, %rax
movl -0x9c(%rbp), %ecx
shlq %cl, %rax
movq %rax, -0xc8(%rbp)
jmp 0x24b1a
movq -0x78(%rbp), %rax
movzbl (%rax), %eax
sarl $0x3, %eax
cltq
movq %rax, -0xc8(%rbp)
movq -0xc8(%rbp), %rax
orq -0xa8(%rbp), %rax
movq %rax, -0xa8(%rbp)
movq -0xa8(%rbp), %rcx
movq -0xb0(%rbp), %rax
subq %rcx, %rax
movq %rax, -0xb0(%rbp)
movq -0xa8(%rbp), %rdx
movq -0x78(%rbp), %rax
movzbl (%rax), %eax
andl $0x7, %eax
cltq
movq -0x70(%rbp,%rax,8), %rcx
subq %rdx, %rcx
movq %rcx, -0x70(%rbp,%rax,8)
movq $0x0, -0xa8(%rbp)
movl $0x0, -0x9c(%rbp)
jmp 0x24baf
movq -0x78(%rbp), %rax
movzbl (%rax), %eax
andq $0x3f, %rax
movl -0x9c(%rbp), %ecx
shlq %cl, %rax
orq -0xa8(%rbp), %rax
movq %rax, -0xa8(%rbp)
movl -0x9c(%rbp), %eax
addl $0x6, %eax
movl %eax, -0x9c(%rbp)
jmp 0x24a97
movl $0x0, -0x34(%rbp)
cmpl $0x6, -0x34(%rbp)
je 0x24be5
movslq -0x34(%rbp), %rax
movq -0x70(%rbp,%rax,8), %rdx
movq -0x20(%rbp), %rax
movslq -0x34(%rbp), %rcx
addq (%rax,%rcx,8), %rdx
movq %rdx, (%rax,%rcx,8)
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x24bbb
movq -0x10(%rbp), %rdx
subq -0xb0(%rbp), %rdx
movq -0x20(%rbp), %rax
movq -0x78(%rbp), %rcx
movzbl (%rcx), %ecx
andl $0x7, %ecx
movslq %ecx, %rcx
addq (%rax,%rcx,8), %rdx
movq %rdx, (%rax,%rcx,8)
addq $0xd0, %rsp
popq %rbp
retq