// File: /workspace/github_c_makefile_star2_O0/aerospike[P]aerospike-common/src/main/citrusleaf/cf_queue.c
// Function: cf_queue_delete_offset
void
cf_queue_delete_offset(cf_queue *q, uint32_t index)
{
	q->n_eles--;

	index %= q->alloc_sz;

	uint32_t r_index = q->read_offset % q->alloc_sz;
	uint32_t w_index = q->write_offset % q->alloc_sz;

	// Assumes index is validated!

	// If we're deleting the one at the head, just increase the read offset.
	if (index == r_index) {
		q->read_offset++;
		return;
	}

	// If we're deleting the tail just decrease the write offset.
	if (w_index && (index == w_index - 1)) {
		q->write_offset--;
		return;
	}

	if (index > r_index) {
		// The memory copy is overlapping, so must use memmove().
		memmove(&q->elements[(r_index + 1) * q->element_sz],
				&q->elements[r_index * q->element_sz],
				(index - r_index) * q->element_sz);
		q->read_offset++;
		return;
	}

	if (index < w_index) {
		// The memory copy is overlapping, so must use memmove().
		memmove(&q->elements[index * q->element_sz],
				&q->elements[(index + 1) * q->element_sz],
				(w_index - index - 1) * q->element_sz);
		q->write_offset--;
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq -0x8(%rbp), %rax
movl 0x10(%rax), %ecx
addl $-0x1, %ecx
movl %ecx, 0x10(%rax)
movq -0x8(%rbp), %rax
movl 0x4(%rax), %ecx
movl -0xc(%rbp), %eax
xorl %edx, %edx
divl %ecx
movl %edx, -0xc(%rbp)
movq -0x8(%rbp), %rax
movl 0x8(%rax), %eax
movq -0x8(%rbp), %rcx
xorl %edx, %edx
divl 0x4(%rcx)
movl %edx, -0x10(%rbp)
movq -0x8(%rbp), %rax
movl 0xc(%rax), %eax
movq -0x8(%rbp), %rcx
xorl %edx, %edx
divl 0x4(%rcx)
movl %edx, -0x14(%rbp)
movl -0xc(%rbp), %eax
cmpl -0x10(%rbp), %eax
jne 0x25f4d
movq -0x8(%rbp), %rax
movl 0x8(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x8(%rax)
jmp 0x26037
cmpl $0x0, -0x14(%rbp)
je 0x25f72
movl -0xc(%rbp), %eax
movl -0x14(%rbp), %ecx
subl $0x1, %ecx
cmpl %ecx, %eax
jne 0x25f72
movq -0x8(%rbp), %rax
movl 0xc(%rax), %ecx
addl $-0x1, %ecx
movl %ecx, 0xc(%rax)
jmp 0x26037
movl -0xc(%rbp), %eax
cmpl -0x10(%rbp), %eax
jbe 0x25fd4
movq -0x8(%rbp), %rax
movq 0x78(%rax), %rdi
movl -0x10(%rbp), %eax
addl $0x1, %eax
movl %eax, %eax
movq -0x8(%rbp), %rcx
imulq 0x18(%rcx), %rax
addq %rax, %rdi
movq -0x8(%rbp), %rax
movq 0x78(%rax), %rsi
movl -0x10(%rbp), %eax
movq -0x8(%rbp), %rcx
imulq 0x18(%rcx), %rax
addq %rax, %rsi
movl -0xc(%rbp), %eax
subl -0x10(%rbp), %eax
movl %eax, %eax
movl %eax, %edx
movq -0x8(%rbp), %rax
imulq 0x18(%rax), %rdx
callq 0x8970
movq -0x8(%rbp), %rax
movl 0x8(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x8(%rax)
jmp 0x26037
movl -0xc(%rbp), %eax
cmpl -0x14(%rbp), %eax
jae 0x26037
movq -0x8(%rbp), %rax
movq 0x78(%rax), %rdi
movl -0xc(%rbp), %eax
movq -0x8(%rbp), %rcx
imulq 0x18(%rcx), %rax
addq %rax, %rdi
movq -0x8(%rbp), %rax
movq 0x78(%rax), %rsi
movl -0xc(%rbp), %eax
addl $0x1, %eax
movl %eax, %eax
movq -0x8(%rbp), %rcx
imulq 0x18(%rcx), %rax
addq %rax, %rsi
movl -0x14(%rbp), %eax
subl -0xc(%rbp), %eax
subl $0x1, %eax
movl %eax, %eax
movl %eax, %edx
movq -0x8(%rbp), %rax
imulq 0x18(%rax), %rdx
callq 0x8970
movq -0x8(%rbp), %rax
movl 0xc(%rax), %ecx
addl $-0x1, %ecx
movl %ecx, 0xc(%rax)
addq $0x20, %rsp
popq %rbp
retq
nopl (%rax)