// File: /workspace/github_c_makefile_star2_O0/mmcco[P]sljit/sljit_src/sljitExecAllocator.c
// Function: sljit_malloc_exec
void* sljit_malloc_exec(unsigned long size)
{
	struct block_header *header;
	struct block_header *next_header;
	struct free_block *free_block;
	unsigned long chunk_size;

	allocator_grab_lock();
	if (size < sizeof(struct free_block))
		size = sizeof(struct free_block);
	size = ALIGN_SIZE(size);

	free_block = free_blocks;
	while (free_block) {
		if (free_block->size >= size) {
			chunk_size = free_block->size;
			if (chunk_size > size + 64) {
				/* We just cut a block from the end of the free block. */
				chunk_size -= size;
				free_block->size = chunk_size;
				header = AS_BLOCK_HEADER(free_block, chunk_size);
				header->prev_size = chunk_size;
				AS_BLOCK_HEADER(header, size)->prev_size = size;
			}
			else {
				sljit_remove_free_block(free_block);
				header = (struct block_header*)free_block;
				size = chunk_size;
			}
			allocated_size += size;
			header->size = size;
			allocator_release_lock();
			return MEM_START(header);
		}
		free_block = free_block->next;
	}

	chunk_size = (size + sizeof(struct block_header) + CHUNK_SIZE - 1) & CHUNK_MASK;
	header = (struct block_header*)alloc_chunk(chunk_size);
	if (!header) {
		allocator_release_lock();
		return NULL;
	}

	chunk_size -= sizeof(struct block_header);
	total_size += chunk_size;

	header->prev_size = 0;
	if (chunk_size > size + 64) {
		/* Cut the allocated space into a free and a used block. */
		allocated_size += size;
		header->size = size;
		chunk_size -= size;

		free_block = AS_FREE_BLOCK(header, size);
		free_block->header.prev_size = size;
		sljit_insert_free_block(free_block, chunk_size);
		next_header = AS_BLOCK_HEADER(free_block, chunk_size);
	}
	else {
		/* All space belongs to this allocation. */
		allocated_size += chunk_size;
		header->size = chunk_size;
		next_header = AS_BLOCK_HEADER(header, chunk_size);
	}
	next_header->size = 1;
	next_header->prev_size = chunk_size;
	allocator_release_lock();
	return MEM_START(header);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x10(%rbp)
callq 0x18780
cmpq $0x28, -0x10(%rbp)
jae 0x18540
movq $0x28, -0x10(%rbp)
movq -0x10(%rbp), %rax
addq $0x10, %rax
addq $0x7, %rax
andq $-0x8, %rax
movq %rax, -0x10(%rbp)
movq 0x1be35(%rip), %rax     # 0x34390
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x28(%rbp)
je 0x1863c
movq -0x28(%rbp), %rax
movq 0x20(%rax), %rax
cmpq -0x10(%rbp), %rax
jb 0x1862b
movq -0x28(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
movq -0x10(%rbp), %rcx
addq $0x40, %rcx
cmpq %rcx, %rax
jbe 0x185df
movq -0x10(%rbp), %rcx
movq -0x30(%rbp), %rax
subq %rcx, %rax
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rcx
movq -0x28(%rbp), %rax
movq %rcx, 0x20(%rax)
movq -0x28(%rbp), %rax
addq -0x30(%rbp), %rax
movq %rax, -0x18(%rbp)
movq -0x30(%rbp), %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x10(%rbp), %rdx
movq -0x18(%rbp), %rax
movq -0x10(%rbp), %rcx
movq %rdx, 0x8(%rax,%rcx)
jmp 0x185f8
movq -0x28(%rbp), %rdi
callq 0x187a0
movq -0x28(%rbp), %rax
movq %rax, -0x18(%rbp)
movq -0x30(%rbp), %rax
movq %rax, -0x10(%rbp)
movq -0x10(%rbp), %rax
addq 0x1bd95(%rip), %rax     # 0x34398
movq %rax, 0x1bd8e(%rip)     # 0x34398
movq -0x10(%rbp), %rcx
movq -0x18(%rbp), %rax
movq %rcx, (%rax)
callq 0x18830
movq -0x18(%rbp), %rax
addq $0x10, %rax
movq %rax, -0x8(%rbp)
jmp 0x18769
movq -0x28(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x28(%rbp)
jmp 0x1855f
movq -0x10(%rbp), %rax
addq $0x10, %rax
addq $0x10000, %rax          # imm = 0x10000
subq $0x1, %rax
andq $-0x10000, %rax         # imm = 0xFFFF0000
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rdi
callq 0x18850
movq %rax, -0x18(%rbp)
cmpq $0x0, -0x18(%rbp)
jne 0x1867e
callq 0x18830
movq $0x0, -0x8(%rbp)
jmp 0x18769
movq -0x30(%rbp), %rax
subq $0x10, %rax
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
addq 0x1bd0b(%rip), %rax     # 0x343a0
movq %rax, 0x1bd04(%rip)     # 0x343a0
movq -0x18(%rbp), %rax
movq $0x0, 0x8(%rax)
movq -0x30(%rbp), %rax
movq -0x10(%rbp), %rcx
addq $0x40, %rcx
cmpq %rcx, %rax
jbe 0x18718
movq -0x10(%rbp), %rax
addq 0x1bcd4(%rip), %rax     # 0x34398
movq %rax, 0x1bccd(%rip)     # 0x34398
movq -0x10(%rbp), %rcx
movq -0x18(%rbp), %rax
movq %rcx, (%rax)
movq -0x10(%rbp), %rcx
movq -0x30(%rbp), %rax
subq %rcx, %rax
movq %rax, -0x30(%rbp)
movq -0x18(%rbp), %rax
addq -0x10(%rbp), %rax
movq %rax, -0x28(%rbp)
movq -0x10(%rbp), %rcx
movq -0x28(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x28(%rbp), %rdi
movq -0x30(%rbp), %rsi
callq 0x188b0
movq -0x28(%rbp), %rax
addq -0x30(%rbp), %rax
movq %rax, -0x20(%rbp)
jmp 0x18741
movq -0x30(%rbp), %rax
addq 0x1bc75(%rip), %rax     # 0x34398
movq %rax, 0x1bc6e(%rip)     # 0x34398
movq -0x30(%rbp), %rcx
movq -0x18(%rbp), %rax
movq %rcx, (%rax)
movq -0x18(%rbp), %rax
addq -0x30(%rbp), %rax
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rax
movq $0x1, (%rax)
movq -0x30(%rbp), %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x8(%rax)
callq 0x18830
movq -0x18(%rbp), %rax
addq $0x10, %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x30, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)