// File: /workspace/github_c_makefile_star2_O3/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 0x13d52(%rip), %rdi     # 0x28148
callq 0x2140
cmpq $0x29, %rbx
movl $0x28, %r15d
cmovaeq %rbx, %r15
addq $0x17, %r15
andq $-0x8, %r15
movq 0x13d08(%rip), %rcx     # 0x28120
testq %rcx, %rcx
je 0x14435
movq %rcx, %rbx
movq 0x20(%rbx), %rax
movq %rax, %rdx
subq %r15, %rdx
jae 0x1447f
movq 0x10(%rbx), %rbx
testq %rbx, %rbx
jne 0x14420
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 0x144a5
leaq 0x13cd5(%rip), %rdi     # 0x28148
callq 0x20d0
xorl %ebx, %ebx
jmp 0x14576
leaq 0x40(%r15), %rsi
cmpq %rsi, %rax
jbe 0x14512
movq %rdx, 0x20(%rbx)
movq %rdx, 0x8(%rbx,%rdx)
movq %r15, 0x8(%rbx,%rax)
addq %rdx, %rbx
movq %r15, %rax
jmp 0x1455c
addq $-0x10, %r14
addq %r14, 0x13c80(%rip)     # 0x28130
movq $0x0, 0x8(%rbx)
leaq 0x40(%r15), %rcx
movq 0x13c65(%rip), %rax     # 0x28128
cmpq %rcx, %r14
jbe 0x1452e
addq %r15, %rax
movq %rax, 0x13c56(%rip)     # 0x28128
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 0x13c2a(%rip), %rdx     # 0x28120
movq %rdx, 0x10(%rbx,%r15)
movq %rsi, 0x18(%rbx,%r15)
testq %rdx, %rdx
je 0x14509
movq %rcx, 0x18(%rdx)
movq %rcx, 0x13c10(%rip)     # 0x28120
jmp 0x1453e
movq 0x10(%rbx), %rdx
movq 0x18(%rbx), %rsi
testq %rdx, %rdx
je 0x14523
movq %rsi, 0x18(%rdx)
testq %rsi, %rsi
je 0x1454d
addq $0x10, %rsi
jmp 0x14559
addq %r14, %rax
movq %rax, 0x13bf0(%rip)     # 0x28128
movq %r14, (%rbx)
movq %r14, %rax
movq $0x1, (%rbx,%r14)
movq %rax, 0x8(%rbx,%r14)
jmp 0x14566
cmpq %rbx, %rcx
jne 0x1457f
leaq 0x13bc7(%rip), %rsi     # 0x28120
movq %rdx, (%rsi)
addq %rax, 0x13bc5(%rip)     # 0x28128
movq %rax, (%rbx)
leaq 0x13bdb(%rip), %rdi     # 0x28148
callq 0x20d0
addq $0x10, %rbx
movq %rbx, %rax
popq %rbx
popq %r14
popq %r15
retq
leaq 0xecec(%rip), %rdi      # 0x23272
movl $0xaa, %esi
xorl %eax, %eax
callq 0x2080
callq 0x2040