// File: /workspace/github_c_makefile_star2_O0/Enes1313[P]DataStructures/DS/eaDSCircularBuffer.c
// Function: eaDSCircularBufferGet
int eaDSCircularBufferGet(eaDSCircularBuffer circularBuffer, void * data, size_t numberOfData)
{
	if (numberOfData > circularBuffer->Capacity)
	{
		return EXIT_FAILURE;
	}

	if (circularBuffer->Tail < circularBuffer->Head)
	{
		if (numberOfData <= (circularBuffer->Capacity - circularBuffer->Head))
		{
			circularBuffer->dataCopy(data, (char *)circularBuffer->Data + circularBuffer->SizeOfData * circularBuffer->Head, circularBuffer->SizeOfData * numberOfData);
			circularBuffer->Head += numberOfData;

			if (circularBuffer->Head == circularBuffer->Capacity)
			{
				circularBuffer->Head = 0;
			}
		}
		else
		{
			if (numberOfData > (circularBuffer->Tail + circularBuffer->Capacity - circularBuffer->Head))
			{
				return EXIT_FAILURE;
			}
			else
			{
				circularBuffer->dataCopy(data, (char *)circularBuffer->Data + circularBuffer->SizeOfData * circularBuffer->Head, circularBuffer->SizeOfData * (circularBuffer->Capacity - circularBuffer->Head));
				circularBuffer->dataCopy((char *)data + circularBuffer->SizeOfData * (circularBuffer->Capacity - circularBuffer->Head),circularBuffer->Data, circularBuffer->SizeOfData * (numberOfData - circularBuffer->Capacity + circularBuffer->Head));
				circularBuffer->Head = numberOfData - circularBuffer->Capacity + circularBuffer->Head;
			}
		}
	}
	else
	{
		if (numberOfData > (circularBuffer->Tail - circularBuffer->Head))
		{
			return EXIT_FAILURE;
		}
		else
		{
			circularBuffer->dataCopy(data, (char *)circularBuffer->Data + circularBuffer->SizeOfData * circularBuffer->Head, circularBuffer->SizeOfData * numberOfData);
			circularBuffer->Head += numberOfData;
		}
	}

	return EXIT_SUCCESS;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq -0x20(%rbp), %rax
movq -0x10(%rbp), %rcx
cmpq 0x18(%rcx), %rax
jbe 0x15de
movl $0x1, -0x4(%rbp)
jmp 0x17cd
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x10(%rbp), %rcx
cmpq 0x8(%rcx), %rax
jae 0x175c
movq -0x20(%rbp), %rax
movq -0x10(%rbp), %rcx
movq 0x18(%rcx), %rcx
movq -0x10(%rbp), %rdx
subq 0x8(%rdx), %rcx
cmpq %rcx, %rax
ja 0x1676
movq -0x10(%rbp), %rax
movq 0x38(%rax), %rax
movq -0x18(%rbp), %rdi
movq -0x10(%rbp), %rcx
movq (%rcx), %rsi
movq -0x10(%rbp), %rcx
movq 0x28(%rcx), %rcx
movq -0x10(%rbp), %rdx
imulq 0x8(%rdx), %rcx
addq %rcx, %rsi
movq -0x10(%rbp), %rcx
movq 0x28(%rcx), %rdx
imulq -0x20(%rbp), %rdx
callq *%rax
movq -0x20(%rbp), %rcx
movq -0x10(%rbp), %rax
addq 0x8(%rax), %rcx
movq %rcx, 0x8(%rax)
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq -0x10(%rbp), %rcx
cmpq 0x18(%rcx), %rax
jne 0x1671
movq -0x10(%rbp), %rax
movq $0x0, 0x8(%rax)
jmp 0x175a
movq -0x20(%rbp), %rax
movq -0x10(%rbp), %rcx
movq 0x10(%rcx), %rcx
movq -0x10(%rbp), %rdx
addq 0x18(%rdx), %rcx
movq -0x10(%rbp), %rdx
subq 0x8(%rdx), %rcx
cmpq %rcx, %rax
jbe 0x16a3
movl $0x1, -0x4(%rbp)
jmp 0x17cd
movq -0x10(%rbp), %rax
movq 0x38(%rax), %rax
movq -0x18(%rbp), %rdi
movq -0x10(%rbp), %rcx
movq (%rcx), %rsi
movq -0x10(%rbp), %rcx
movq 0x28(%rcx), %rcx
movq -0x10(%rbp), %rdx
imulq 0x8(%rdx), %rcx
addq %rcx, %rsi
movq -0x10(%rbp), %rcx
movq 0x28(%rcx), %rdx
movq -0x10(%rbp), %rcx
movq 0x18(%rcx), %rcx
movq -0x10(%rbp), %r8
subq 0x8(%r8), %rcx
imulq %rcx, %rdx
callq *%rax
movq -0x10(%rbp), %rax
movq 0x38(%rax), %rax
movq -0x18(%rbp), %rdi
movq -0x10(%rbp), %rcx
movq 0x28(%rcx), %rcx
movq -0x10(%rbp), %rdx
movq 0x18(%rdx), %rdx
movq -0x10(%rbp), %rsi
subq 0x8(%rsi), %rdx
imulq %rdx, %rcx
addq %rcx, %rdi
movq -0x10(%rbp), %rcx
movq (%rcx), %rsi
movq -0x10(%rbp), %rcx
movq 0x28(%rcx), %rdx
movq -0x20(%rbp), %rcx
movq -0x10(%rbp), %r8
subq 0x18(%r8), %rcx
movq -0x10(%rbp), %r8
addq 0x8(%r8), %rcx
imulq %rcx, %rdx
callq *%rax
movq -0x20(%rbp), %rcx
movq -0x10(%rbp), %rax
subq 0x18(%rax), %rcx
movq -0x10(%rbp), %rax
addq 0x8(%rax), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x8(%rax)
jmp 0x175a
jmp 0x17c6
movq -0x20(%rbp), %rax
movq -0x10(%rbp), %rcx
movq 0x10(%rcx), %rcx
movq -0x10(%rbp), %rdx
subq 0x8(%rdx), %rcx
cmpq %rcx, %rax
jbe 0x177e
movl $0x1, -0x4(%rbp)
jmp 0x17cd
movq -0x10(%rbp), %rax
movq 0x38(%rax), %rax
movq -0x18(%rbp), %rdi
movq -0x10(%rbp), %rcx
movq (%rcx), %rsi
movq -0x10(%rbp), %rcx
movq 0x28(%rcx), %rcx
movq -0x10(%rbp), %rdx
imulq 0x8(%rdx), %rcx
addq %rcx, %rsi
movq -0x10(%rbp), %rcx
movq 0x28(%rcx), %rdx
imulq -0x20(%rbp), %rdx
callq *%rax
movq -0x20(%rbp), %rcx
movq -0x10(%rbp), %rax
addq 0x8(%rax), %rcx
movq %rcx, 0x8(%rax)
jmp 0x17c6
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x20, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)