// File: splatlab[P]debgr/threadsafe-gqf/gqf.c
// Function: shift_runends(quotient_filter*, long, unsigned long, unsigned long)
static inline void shift_runends(QF *qf, int64_t first, uint64_t last,
																 uint64_t distance)
{
	assert(last < qf->metadata->xnslots && distance < 64);
	uint64_t first_word = first / 64;
	uint64_t bstart = first % 64;
	uint64_t last_word = (last + distance + 1) / 64;
	uint64_t bend = (last + distance + 1) % 64;

	if (last_word != first_word) {
		METADATA_WORD(qf, runends, 64*last_word) = shift_into_b(METADATA_WORD(qf, runends, 64*(last_word-1)), 
																														METADATA_WORD(qf, runends, 64*last_word),
																														0, bend, distance);
		bend = 64;
		last_word--;
		while (last_word != first_word) {
			METADATA_WORD(qf, runends, 64*last_word) = shift_into_b(METADATA_WORD(qf, runends, 64*(last_word-1)), 
																															METADATA_WORD(qf, runends, 64*last_word),
																															0, bend, distance);
			last_word--;
		}
	}
	METADATA_WORD(qf, runends, 64*last_word) = shift_into_b(0, METADATA_WORD(qf,
																																					 runends,
																																					 64*last_word),
																													bstart, bend, distance);

}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq -0x10(%rbp), %rax
movl $0x40, %ecx
cqto
idivq %rcx
movq %rax, -0x28(%rbp)
movq -0x10(%rbp), %rax
movl $0x40, %ecx
cqto
idivq %rcx
movq %rdx, -0x30(%rbp)
movq -0x18(%rbp), %rax
addq -0x20(%rbp), %rax
addq $0x1, %rax
shrq $0x6, %rax
movq %rax, -0x38(%rbp)
movq -0x18(%rbp), %rax
addq -0x20(%rbp), %rax
addq $0x1, %rax
andq $0x3f, %rax
movq %rax, -0x40(%rbp)
movq -0x38(%rbp), %rax
cmpq -0x28(%rbp), %rax
je 0x2870b
movq -0x8(%rbp), %rdi
movq -0x38(%rbp), %rsi
subq $0x1, %rsi
shlq $0x6, %rsi
shrq $0x6, %rsi
callq 0x27590
movq -0x38(%rbp), %rcx
subq $0x1, %rcx
shlq $0x6, %rcx
andq $0x3f, %rcx
shrq $0x6, %rcx
movq 0x9(%rax,%rcx,8), %rax
movq %rax, -0x50(%rbp)
movq -0x8(%rbp), %rdi
movq -0x38(%rbp), %rsi
shlq $0x6, %rsi
shrq $0x6, %rsi
callq 0x27590
movq -0x50(%rbp), %rdi
movq -0x38(%rbp), %rcx
shlq $0x6, %rcx
andq $0x3f, %rcx
shrq $0x6, %rcx
movq 0x9(%rax,%rcx,8), %rsi
movq -0x40(%rbp), %rax
movl %eax, %ecx
movq -0x20(%rbp), %rax
movl %eax, %r8d
xorl %edx, %edx
callq 0x288e0
movq %rax, -0x48(%rbp)
movq -0x8(%rbp), %rdi
movq -0x38(%rbp), %rsi
shlq $0x6, %rsi
shrq $0x6, %rsi
callq 0x27590
movq -0x48(%rbp), %rdx
movq -0x38(%rbp), %rcx
shlq $0x6, %rcx
andq $0x3f, %rcx
shrq $0x6, %rcx
movq %rdx, 0x9(%rax,%rcx,8)
movq $0x40, -0x40(%rbp)
movq -0x38(%rbp), %rax
addq $-0x1, %rax
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rax
cmpq -0x28(%rbp), %rax
je 0x28709
movq -0x8(%rbp), %rdi
movq -0x38(%rbp), %rsi
subq $0x1, %rsi
shlq $0x6, %rsi
shrq $0x6, %rsi
callq 0x27590
movq -0x38(%rbp), %rcx
subq $0x1, %rcx
shlq $0x6, %rcx
andq $0x3f, %rcx
shrq $0x6, %rcx
movq 0x9(%rax,%rcx,8), %rax
movq %rax, -0x60(%rbp)
movq -0x8(%rbp), %rdi
movq -0x38(%rbp), %rsi
shlq $0x6, %rsi
shrq $0x6, %rsi
callq 0x27590
movq -0x60(%rbp), %rdi
movq -0x38(%rbp), %rcx
shlq $0x6, %rcx
andq $0x3f, %rcx
shrq $0x6, %rcx
movq 0x9(%rax,%rcx,8), %rsi
movq -0x40(%rbp), %rax
movl %eax, %ecx
movq -0x20(%rbp), %rax
movl %eax, %r8d
xorl %edx, %edx
callq 0x288e0
movq %rax, -0x58(%rbp)
movq -0x8(%rbp), %rdi
movq -0x38(%rbp), %rsi
shlq $0x6, %rsi
shrq $0x6, %rsi
callq 0x27590
movq -0x58(%rbp), %rdx
movq -0x38(%rbp), %rcx
shlq $0x6, %rcx
andq $0x3f, %rcx
shrq $0x6, %rcx
movq %rdx, 0x9(%rax,%rcx,8)
movq -0x38(%rbp), %rax
addq $-0x1, %rax
movq %rax, -0x38(%rbp)
jmp 0x28640
jmp 0x2870b
movq -0x8(%rbp), %rdi
movq -0x38(%rbp), %rsi
shlq $0x6, %rsi
shrq $0x6, %rsi
callq 0x27590
movq -0x38(%rbp), %rcx
shlq $0x6, %rcx
andq $0x3f, %rcx
shrq $0x6, %rcx
movq 0x9(%rax,%rcx,8), %rsi
movq -0x30(%rbp), %rax
movl %eax, %edx
movq -0x40(%rbp), %rax
movl %eax, %ecx
movq -0x20(%rbp), %rax
movl %eax, %r8d
xorl %eax, %eax
movl %eax, %edi
callq 0x288e0
movq %rax, -0x68(%rbp)
movq -0x8(%rbp), %rdi
movq -0x38(%rbp), %rsi
shlq $0x6, %rsi
shrq $0x6, %rsi
callq 0x27590
movq -0x68(%rbp), %rdx
movq -0x38(%rbp), %rcx
shlq $0x6, %rcx
andq $0x3f, %rcx
shrq $0x6, %rcx
movq %rdx, 0x9(%rax,%rcx,8)
addq $0x70, %rsp
popq %rbp
retq
nopl (%rax)