// File: /workspace/github_c_makefile_star2_O1/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 %r15
pushq %r14
pushq %rbx
movq %rdi, %rbx
leaq 0x13cca(%rip), %rdi     # 0x28138
callq 0x2130
cmpq $0x29, %rbx
movl $0x28, %r15d
cmovaeq %rbx, %r15
addq $0x17, %r15
andq $-0x8, %r15
movq 0x13c80(%rip), %rbx     # 0x28110
testq %rbx, %rbx
je 0x144a7
movq 0x20(%rbx), %rax
movq %rax, %rcx
subq %r15, %rcx
jae 0x144f1
movq 0x10(%rbx), %rbx
jmp 0x14490
leaq 0x1000f(%r15), %r14
andq $-0x10000, %r14         # imm = 0xFFFF0000
xorl %edi, %edi
movq %r14, %rsi
movl $0x7, %edx
movl $0x22, %ecx
movl $0xffffffff, %r8d       # imm = 0xFFFFFFFF
xorl %r9d, %r9d
callq 0x2060
movq %rax, %rbx
incq %rax
cmpq $0x1, %rax
ja 0x14514
leaq 0x13c53(%rip), %rdi     # 0x28138
callq 0x20c0
xorl %ebx, %ebx
jmp 0x145ed
leaq 0x40(%r15), %rdx
cmpq %rdx, %rax
jbe 0x14581
movq %rcx, 0x20(%rbx)
movq %rcx, 0x8(%rbx,%rcx)
movq %r15, 0x8(%rbx,%rax)
addq %rcx, %rbx
jmp 0x145d3
addq $-0x10, %r14
addq %r14, 0x13c01(%rip)     # 0x28120
movq $0x0, 0x8(%rbx)
leaq 0x40(%r15), %rcx
movq 0x13be6(%rip), %rax     # 0x28118
cmpq %rcx, %r14
jbe 0x145a1
addq %r15, %rax
movq %rax, 0x13bd7(%rip)     # 0x28118
movq %r15, (%rbx)
movq %r14, %rax
subq %r15, %rax
leaq (%rbx,%r15), %rcx
movq %r15, 0x8(%rbx,%r15)
xorl %esi, %esi
movq %rsi, (%rbx,%r15)
movq %rax, 0x20(%rbx,%r15)
movq 0x13bab(%rip), %rdx     # 0x28110
movq %rdx, 0x10(%rbx,%r15)
movq %rsi, 0x18(%rbx,%r15)
testq %rdx, %rdx
je 0x14578
movq %rcx, 0x18(%rdx)
movq %rcx, 0x13b91(%rip)     # 0x28110
jmp 0x145b1
movq 0x10(%rbx), %rcx
testq %rcx, %rcx
je 0x14592
movq 0x18(%rbx), %rdx
movq %rdx, 0x18(%rcx)
movq 0x18(%rbx), %rdx
testq %rdx, %rdx
je 0x145c0
movq %rcx, 0x10(%rdx)
jmp 0x145d0
addq %r14, %rax
movq %rax, 0x13b6d(%rip)     # 0x28118
movq %r14, (%rbx)
movq %r14, %rax
movq $0x1, (%rbx,%r14)
movq %rax, 0x8(%rbx,%r14)
jmp 0x145dd
cmpq %rbx, 0x13b49(%rip)     # 0x28110
jne 0x145f6
movq %rcx, 0x13b40(%rip)     # 0x28110
movq %rax, %r15
addq %r15, 0x13b3e(%rip)     # 0x28118
movq %r15, (%rbx)
leaq 0x13b54(%rip), %rdi     # 0x28138
callq 0x20c0
addq $0x10, %rbx
movq %rbx, %rax
popq %rbx
popq %r14
popq %r15
retq
leaq 0xeba5(%rip), %rdi      # 0x231a2
movl $0xaa, %esi
xorl %eax, %eax
callq 0x2080
callq 0x2040