// File: /workspace/github_c_makefile_star2_O0/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 %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x8(%rbp)
callq 0x18780
movq -0x8(%rbp), %rax
addq $-0x10, %rax
movq %rax, -0x10(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rcx
movq 0x1ba4d(%rip), %rax     # 0x34398
subq %rcx, %rax
movq %rax, 0x1ba43(%rip)     # 0x34398
movq -0x10(%rbp), %rax
movq -0x10(%rbp), %rdx
xorl %ecx, %ecx
subq 0x8(%rdx), %rcx
addq %rcx, %rax
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rax
cmpq $0x0, (%rax)
jne 0x189a9
movq -0x10(%rbp), %rax
movq (%rax), %rcx
movq -0x18(%rbp), %rax
addq 0x20(%rax), %rcx
movq %rcx, 0x20(%rax)
movq -0x18(%rbp), %rax
movq -0x18(%rbp), %rcx
addq 0x20(%rcx), %rax
movq %rax, -0x10(%rbp)
movq -0x18(%rbp), %rax
movq 0x20(%rax), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x8(%rax)
jmp 0x189c1
movq -0x10(%rbp), %rax
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rdi
movq -0x10(%rbp), %rax
movq (%rax), %rsi
callq 0x188b0
movq -0x18(%rbp), %rax
movq -0x18(%rbp), %rcx
addq 0x20(%rcx), %rax
movq %rax, -0x10(%rbp)
movq -0x10(%rbp), %rax
cmpq $0x0, (%rax)
jne 0x18a18
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rcx
movq -0x18(%rbp), %rax
addq 0x20(%rax), %rcx
movq %rcx, 0x20(%rax)
movq -0x10(%rbp), %rdi
callq 0x187a0
movq -0x18(%rbp), %rax
movq -0x18(%rbp), %rcx
addq 0x20(%rcx), %rax
movq %rax, -0x10(%rbp)
movq -0x18(%rbp), %rax
movq 0x20(%rax), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x18(%rbp), %rax
cmpq $0x0, 0x8(%rax)
jne 0x18a85
movq -0x10(%rbp), %rax
cmpq $0x1, (%rax)
jne 0x18a85
movq 0x1b96c(%rip), %rax     # 0x343a0
movq -0x18(%rbp), %rcx
subq 0x20(%rcx), %rax
imulq $0x3, 0x1b954(%rip), %rcx # 0x34398
shrq %rcx
cmpq %rcx, %rax
jbe 0x18a83
movq -0x18(%rbp), %rax
movq 0x20(%rax), %rcx
movq 0x1b945(%rip), %rax     # 0x343a0
subq %rcx, %rax
movq %rax, 0x1b93b(%rip)     # 0x343a0
movq -0x18(%rbp), %rdi
callq 0x187a0
movq -0x18(%rbp), %rdi
movq -0x18(%rbp), %rax
movq 0x20(%rax), %rsi
addq $0x10, %rsi
callq 0x18a90
jmp 0x18a85
callq 0x18830
addq $0x20, %rsp
popq %rbp
retq