// File: /workspace/github_c_makefile_star2_O1/mmcco[P]sljit/sljit_src/sljitExecAllocator.c
// Function: sljit_free_exec
void sljit_free_exec(void* ptr)
{
	struct block_header *header;
	struct free_block* free_block;

	allocator_grab_lock();
	header = AS_BLOCK_HEADER(ptr, -(long)sizeof(struct block_header));
	allocated_size -= header->size;

	/* Connecting free blocks together if possible. */

	/* If header->prev_size == 0, free_block will equal to header.
	   In this case, free_block->header.size will be > 0. */
	free_block = AS_FREE_BLOCK(header, -(long)header->prev_size);
	if (!free_block->header.size) {
		free_block->size += header->size;
		header = AS_BLOCK_HEADER(free_block, free_block->size);
		header->prev_size = free_block->size;
	}
	else {
		free_block = (struct free_block*)header;
		sljit_insert_free_block(free_block, header->size);
	}

	header = AS_BLOCK_HEADER(free_block, free_block->size);
	if (!header->size) {
		free_block->size += ((struct free_block*)header)->size;
		sljit_remove_free_block((struct free_block*)header);
		header = AS_BLOCK_HEADER(free_block, free_block->size);
		header->prev_size = free_block->size;
	}

	/* The whole chunk is free. */
	if (!free_block->header.prev_size && header->size == 1) {
		/* If this block is freed, we still have (allocated_size / 2) free space. */
		if (total_size - free_block->size > (allocated_size * 3 / 2)) {
			total_size -= free_block->size;
			sljit_remove_free_block(free_block);
			free_chunk(free_block, free_block->size + sizeof(struct block_header));
		}
	}

	allocator_release_lock();
}

// Assembly:
pushq %rbx
movq %rdi, %rbx
leaq 0x13b1f(%rip), %rdi     # 0x28138
callq 0x2130
leaq -0x10(%rbx), %rdi
movq -0x10(%rbx), %rcx
movq 0x13aeb(%rip), %rax     # 0x28118
subq %rcx, %rax
movq %rax, 0x13ae1(%rip)     # 0x28118
movq -0x8(%rbx), %rdx
movq %rdx, %rsi
negq %rsi
cmpq $0x0, -0x10(%rbx,%rsi)
je 0x14673
xorl %edx, %edx
movq %rdx, -0x10(%rbx)
movq %rcx, 0x10(%rbx)
movq 0x13ab6(%rip), %rcx     # 0x28110
movq %rcx, (%rbx)
movq %rdx, 0x8(%rbx)
testq %rcx, %rcx
je 0x1466a
movq %rdi, 0x18(%rcx)
movq %rdi, 0x13a9f(%rip)     # 0x28110
jmp 0x14683
subq %rdx, %rdi
addq 0x20(%rdi), %rcx
movq %rcx, 0x20(%rdi)
movq %rcx, 0x8(%rdi,%rcx)
movq 0x20(%rdi), %rsi
leaq (%rdi,%rsi), %rcx
cmpq $0x0, (%rdi,%rsi)
jne 0x146df
movq 0x20(%rdi,%rsi), %rdx
addq %rsi, %rdx
movq %rdx, 0x20(%rdi)
movq 0x10(%rdi,%rsi), %rsi
testq %rsi, %rsi
je 0x146b0
movq 0x18(%rcx), %r8
movq %r8, 0x18(%rsi)
movq 0x18(%rcx), %r8
testq %r8, %r8
je 0x146bf
addq $0x10, %r8
jmp 0x146d3
cmpq %rcx, 0x13a4a(%rip)     # 0x28110
jne 0x14756
leaq 0x13a3d(%rip), %r8      # 0x28110
movq %rsi, (%r8)
leaq (%rdi,%rdx), %rcx
movq %rdx, 0x8(%rdi,%rdx)
cmpq $0x0, 0x8(%rdi)
jne 0x14749
cmpq $0x1, (%rcx)
jne 0x14749
movq 0x13a2d(%rip), %rcx     # 0x28120
movq 0x20(%rdi), %rsi
subq %rsi, %rcx
leaq (%rax,%rax,2), %rax
shrq %rax
cmpq %rax, %rcx
jbe 0x14749
movq %rcx, 0x13a13(%rip)     # 0x28120
movq 0x10(%rdi), %rax
testq %rax, %rax
je 0x1471e
movq 0x18(%rdi), %rcx
movq %rcx, 0x18(%rax)
movq 0x18(%rdi), %rcx
testq %rcx, %rcx
je 0x1472d
addq $0x10, %rcx
jmp 0x1473d
cmpq %rdi, 0x139dc(%rip)     # 0x28110
jne 0x14756
leaq 0x139d3(%rip), %rcx     # 0x28110
movq %rax, (%rcx)
addq $0x10, %rsi
callq 0x20e0
leaq 0x139e8(%rip), %rdi     # 0x28138
popq %rbx
jmp 0x20c0
leaq 0xea45(%rip), %rdi      # 0x231a2
movl $0xaa, %esi
xorl %eax, %eax
callq 0x2080
callq 0x2040