// File: /workspace/github_c_makefile_star2_O3/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 0x13ba6(%rip), %rdi     # 0x28148
callq 0x2140
leaq -0x10(%rbx), %rdi
movq -0x10(%rbx), %rcx
movq 0x13b72(%rip), %rax     # 0x28128
subq %rcx, %rax
movq %rax, 0x13b68(%rip)     # 0x28128
movq -0x8(%rbx), %rdx
movq %rdx, %rsi
negq %rsi
cmpq $0x0, -0x10(%rbx,%rsi)
je 0x145fc
xorl %esi, %esi
movq %rsi, -0x10(%rbx)
movq %rcx, 0x10(%rbx)
movq 0x13b3d(%rip), %rdx     # 0x28120
movq %rdx, (%rbx)
movq %rsi, 0x8(%rbx)
testq %rdx, %rdx
je 0x145f3
movq %rdi, 0x18(%rdx)
movq %rdi, 0x13b26(%rip)     # 0x28120
jmp 0x1460c
subq %rdx, %rdi
addq 0x20(%rdi), %rcx
movq %rcx, 0x20(%rdi)
movq %rcx, 0x8(%rdi,%rcx)
leaq (%rdi,%rcx), %rdx
cmpq $0x0, (%rdi,%rcx)
je 0x1461c
movq %rcx, %rsi
jmp 0x14666
movq 0x20(%rdi,%rcx), %rsi
addq %rcx, %rsi
movq %rsi, 0x20(%rdi)
movq 0x10(%rdi,%rcx), %r8
movq 0x18(%rdi,%rcx), %rcx
testq %r8, %r8
je 0x1463b
movq %rcx, 0x18(%r8)
testq %rcx, %rcx
je 0x14646
addq $0x10, %rcx
jmp 0x1465a
cmpq %rdx, 0x13ad3(%rip)     # 0x28120
jne 0x146d5
leaq 0x13ac6(%rip), %rcx     # 0x28120
movq %r8, (%rcx)
leaq (%rdi,%rsi), %rdx
movq %rsi, 0x8(%rdi,%rsi)
cmpq $0x0, 0x8(%rdi)
jne 0x146c8
cmpq $0x1, (%rdx)
jne 0x146c8
movq 0x13ab6(%rip), %rcx     # 0x28130
subq %rsi, %rcx
leaq (%rax,%rax,2), %rax
shrq %rax
cmpq %rax, %rcx
jbe 0x146c8
movq %rcx, 0x13aa0(%rip)     # 0x28130
movq 0x10(%rdi), %rax
movq 0x18(%rdi), %rcx
testq %rax, %rax
je 0x146a1
movq %rcx, 0x18(%rax)
testq %rcx, %rcx
je 0x146ac
addq $0x10, %rcx
jmp 0x146bc
cmpq %rdi, 0x13a6d(%rip)     # 0x28120
jne 0x146d5
leaq 0x13a64(%rip), %rcx     # 0x28120
movq %rax, (%rcx)
addq $0x10, %rsi
callq 0x20f0
leaq 0x13a79(%rip), %rdi     # 0x28148
popq %rbx
jmp 0x20d0
leaq 0xeb96(%rip), %rdi      # 0x23272
movl $0xaa, %esi
xorl %eax, %eax
callq 0x2080
callq 0x2040