// File: /workspace/github_c_makefile_star2_O0/lucvoo[P]sparse-dev/allocate.c
// Function: allocate
void *allocate(struct allocator_struct *desc, unsigned int size)
{
	unsigned long alignment = desc->alignment;
	struct allocation_blob *blob = desc->blobs;
	void *retval;

	/*
	 * NOTE! The freelist only works with things that are
	 *  (a) sufficiently aligned
	 *  (b) use a constant size
	 * Don't try to free allocators that don't follow
	 * these rules.
	 */
	if (desc->freelist) {
		void **p = desc->freelist;
		retval = p;
		desc->freelist = *p;
		do {
			*p = NULL;
			p++;
		} while ((size -= sizeof(void *)) > 0);
		return retval;
	}

	desc->allocations++;
	desc->useful_bytes += size;
	size = (size + alignment - 1) & ~(alignment-1);
	if (!blob || blob->left < size) {
		unsigned int offset, chunking = desc->chunking;
		struct allocation_blob *newblob = blob_alloc(chunking);
		if (!newblob)
			die("out of memory");
		if (size > chunking)
			die("alloc too big");
		desc->total_bytes += chunking;
		newblob->next = blob;
		blob = newblob;
		desc->blobs = newblob;
		offset = offsetof(struct allocation_blob, data);
		offset = (offset + alignment - 1) & ~(alignment-1);
		blob->left = chunking - offset;
		blob->offset = offset - offsetof(struct allocation_blob, data);
	}
	retval = blob->data + blob->offset;
	blob->offset += size;
	blob->left -= size;
	return retval;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movq -0x10(%rbp), %rax
movl 0x10(%rax), %eax
movq %rax, -0x20(%rbp)
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x28(%rbp)
movq -0x10(%rbp), %rax
cmpq $0x0, 0x18(%rax)
je 0x46647
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rax
movq %rax, -0x30(%rbp)
movq -0x38(%rbp), %rax
movq (%rax), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x18(%rax)
movq -0x38(%rbp), %rax
movq $0x0, (%rax)
movq -0x38(%rbp), %rax
addq $0x8, %rax
movq %rax, -0x38(%rbp)
movl -0x14(%rbp), %eax
subq $0x8, %rax
movl %eax, -0x14(%rbp)
cmpl $0x0, %eax
ja 0x46614
movq -0x30(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x46787
movq -0x10(%rbp), %rax
movl 0x20(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x20(%rax)
movl -0x14(%rbp), %eax
movl %eax, %ecx
movq -0x10(%rbp), %rax
addq 0x30(%rax), %rcx
movq %rcx, 0x30(%rax)
movl -0x14(%rbp), %eax
addq -0x20(%rbp), %rax
subq $0x1, %rax
movq -0x20(%rbp), %rcx
subq $0x1, %rcx
xorq $-0x1, %rcx
andq %rcx, %rax
movl %eax, -0x14(%rbp)
cmpq $0x0, -0x28(%rbp)
je 0x46699
movq -0x28(%rbp), %rax
movl 0x8(%rax), %eax
cmpl -0x14(%rbp), %eax
jae 0x4674d
movq -0x10(%rbp), %rax
movl 0x14(%rax), %eax
movl %eax, -0x40(%rbp)
movl -0x40(%rbp), %eax
movl %eax, %edi
callq 0x493b0
movq %rax, -0x48(%rbp)
cmpq $0x0, -0x48(%rbp)
jne 0x466c6
leaq 0x23c49(%rip), %rdi     # 0x6a308
movb $0x0, %al
callq 0x17190
movl -0x14(%rbp), %eax
cmpl -0x40(%rbp), %eax
jbe 0x466dc
leaq 0x23c41(%rip), %rdi     # 0x6a316
movb $0x0, %al
callq 0x17190
movl -0x40(%rbp), %eax
movl %eax, %ecx
movq -0x10(%rbp), %rax
addq 0x28(%rax), %rcx
movq %rcx, 0x28(%rax)
movq -0x28(%rbp), %rcx
movq -0x48(%rbp), %rax
movq %rcx, (%rax)
movq -0x48(%rbp), %rax
movq %rax, -0x28(%rbp)
movq -0x48(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x8(%rax)
movl $0x10, -0x3c(%rbp)
movl -0x3c(%rbp), %eax
addq -0x20(%rbp), %rax
subq $0x1, %rax
movq -0x20(%rbp), %rcx
subq $0x1, %rcx
xorq $-0x1, %rcx
andq %rcx, %rax
movl %eax, -0x3c(%rbp)
movl -0x40(%rbp), %ecx
subl -0x3c(%rbp), %ecx
movq -0x28(%rbp), %rax
movl %ecx, 0x8(%rax)
movl -0x3c(%rbp), %eax
subq $0x10, %rax
movl %eax, %ecx
movq -0x28(%rbp), %rax
movl %ecx, 0xc(%rax)
movq -0x28(%rbp), %rax
addq $0x10, %rax
movq -0x28(%rbp), %rcx
movl 0xc(%rcx), %ecx
addq %rcx, %rax
movq %rax, -0x30(%rbp)
movl -0x14(%rbp), %ecx
movq -0x28(%rbp), %rax
addl 0xc(%rax), %ecx
movl %ecx, 0xc(%rax)
movl -0x14(%rbp), %edx
movq -0x28(%rbp), %rax
movl 0x8(%rax), %ecx
subl %edx, %ecx
movl %ecx, 0x8(%rax)
movq -0x30(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x50, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)