// File: /workspace/github_c_makefile_star2_O1/lh3[P]fermi-lite/mrope.c
// Function: mr_rank2a
void mr_rank2a(const mrope_t *mr, int64_t x, int64_t y, int64_t *cx, int64_t *cy)
{
	int a, b;
	int64_t z, c[6], l;
	memset(c, 0, 48);
	for (a = 0, z = 0; a < 6; ++a) {
		const int64_t *ca = mr->r[a]->c;
		l = ca[0] + ca[1] + ca[2] + ca[3] + ca[4] + ca[5];
		if (z + l >= x) break;
		for (b = 0; b < 6; ++b) c[b] += ca[b];
		z += l;
	}
	assert(a != 6);
	if (y >= 0 && z + l >= y) { // [x,y) is in the same bucket
		rope_rank2a(mr->r[a], x - z, y - z, cx, cy);
		for (b = 0; b < 6; ++b)
			cx[b] += c[b], cy[b] += c[b];
		return;
	}
	if (x != z) rope_rank1a(mr->r[a], x - z, cx);
	else memset(cx, 0, 48);
	for (b = 0; b < 6; ++b)
		cx[b] += c[b], c[b] += mr->r[a]->c[b];
	if (y < 0) return;
	for (++a, z += l; a < 6; ++a) {
		const int64_t *ca = mr->r[a]->c;
		l = ca[0] + ca[1] + ca[2] + ca[3] + ca[4] + ca[5];
		if (z + l >= y) break;
		for (b = 0; b < 6; ++b) c[b] += ca[b];
		z += l;
	}
	assert(a != 6);
	if (y != z + l) rope_rank1a(mr->r[a], y - z, cy);
	else for (b = 0; b < 6; ++b) cy[b] = mr->r[a]->c[b];
	for (b = 0; b < 6; ++b) cy[b] += c[b];
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %r8, %rbx
movq %rcx, %r12
movq %rdx, %r14
movq %rdi, %r15
xorps %xmm0, %xmm0
movaps %xmm0, 0x30(%rsp)
movaps %xmm0, 0x20(%rsp)
movaps %xmm0, 0x10(%rsp)
xorl %r13d, %r13d
xorl %eax, %eax
movq 0x8(%r15,%r13,8), %rcx
movq 0x10(%rcx), %rbp
addq 0x8(%rcx), %rbp
addq 0x18(%rcx), %rbp
addq 0x20(%rcx), %rbp
addq 0x28(%rcx), %rbp
addq 0x30(%rcx), %rbp
leaq (%rax,%rbp), %rdx
cmpq %rsi, %rdx
jge 0x782a
xorl %eax, %eax
movq 0x8(%rcx,%rax,8), %rdi
addq %rdi, 0x10(%rsp,%rax,8)
incq %rax
cmpq $0x6, %rax
jne 0x7814
movq %rdx, %rax
cmpq %rsi, %rdx
jge 0x783e
incq %r13
cmpq $0x6, %r13
jne 0x77ec
movl $0x6, %r13d
cmpl $0x6, %r13d
je 0x79c8
leaq (%rax,%rbp), %r8
testq %r14, %r14
js 0x788f
cmpq %r14, %r8
jl 0x788f
movl %r13d, %ecx
movq 0x8(%r15,%rcx,8), %rdi
subq %rax, %rsi
subq %rax, %r14
movq %r14, %rdx
movq %r12, %rcx
movq %rbx, %r8
callq 0x15296
xorl %eax, %eax
movq 0x10(%rsp,%rax,8), %rcx
addq %rcx, (%r12,%rax,8)
addq %rcx, (%rbx,%rax,8)
incq %rax
cmpq $0x6, %rax
jne 0x7874
jmp 0x79b9
subq %rax, %rsi
jne 0x78aa
xorps %xmm0, %xmm0
movups %xmm0, 0x20(%r12)
movups %xmm0, 0x10(%r12)
movups %xmm0, (%r12)
jmp 0x78ce
movl %r13d, %eax
movq 0x8(%r15,%rax,8), %rdi
movq $-0x1, %rdx
movq %r12, %rcx
movq %r8, 0x8(%rsp)
xorl %r8d, %r8d
callq 0x15296
movq 0x8(%rsp), %r8
movl %r13d, %eax
movq 0x8(%r15,%rax,8), %rax
xorl %ecx, %ecx
movq 0x10(%rsp,%rcx,8), %rdx
addq %rdx, (%r12,%rcx,8)
addq 0x8(%rax,%rcx,8), %rdx
movq %rdx, 0x10(%rsp,%rcx,8)
incq %rcx
cmpq $0x6, %rcx
jne 0x78d8
testq %r14, %r14
js 0x79b9
cmpl $0x4, %r13d
ja 0x795a
incl %r13d
movq 0x8(%r15,%r13,8), %rax
movq 0x10(%rax), %rbp
addq 0x8(%rax), %rbp
addq 0x18(%rax), %rbp
addq 0x20(%rax), %rbp
addq 0x28(%rax), %rbp
addq 0x30(%rax), %rbp
leaq (%r8,%rbp), %rcx
cmpq %r14, %rcx
jge 0x7944
xorl %edx, %edx
movq 0x8(%rax,%rdx,8), %rsi
addq %rsi, 0x10(%rsp,%rdx,8)
incq %rdx
cmpq $0x6, %rdx
jne 0x792e
movq %rcx, %r8
cmpq %r14, %rcx
jge 0x795d
incq %r13
cmpq $0x6, %r13
jne 0x7906
movl $0x6, %r13d
jmp 0x795d
incl %r13d
cmpl $0x6, %r13d
je 0x79e7
addq %r8, %rbp
movl %r13d, %eax
movq 0x8(%r15,%rax,8), %rdi
cmpq %r14, %rbp
jne 0x798d
xorl %eax, %eax
movq 0x8(%rdi,%rax,8), %rcx
movq %rcx, (%rbx,%rax,8)
incq %rax
cmpq $0x6, %rax
jne 0x7979
jmp 0x79a5
subq %r8, %r14
movq %r14, %rsi
movq $-0x1, %rdx
movq %rbx, %rcx
xorl %r8d, %r8d
callq 0x15296
xorl %eax, %eax
movq 0x10(%rsp,%rax,8), %rcx
addq %rcx, (%rbx,%rax,8)
incq %rax
cmpq $0x6, %rax
jne 0x79a7
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xfc57(%rip), %rdi      # 0x17626
leaq 0xfc28(%rip), %rsi      # 0x175fe
leaq 0xfc50(%rip), %rcx      # 0x1762d
movl $0x52, %edx
callq 0x20e0
leaq 0xfc38(%rip), %rdi      # 0x17626
leaq 0xfc09(%rip), %rsi      # 0x175fe
leaq 0xfc31(%rip), %rcx      # 0x1762d
movl $0x65, %edx
callq 0x20e0