// File: /workspace/github_c_makefile_star2_O1/nilyang[P]redis-tdd-annotation/deps/jemalloc/src/arena.c
// Function: arena_dalloc_bin_run
static void
arena_dalloc_bin_run(arena_t *arena, arena_chunk_t *chunk, arena_run_t *run,
    arena_bin_t *bin)
{
	size_t binind;
	arena_bin_info_t *bin_info;
	size_t npages, run_ind, past;

	assert(run != bin->runcur);
	assert(arena_run_tree_search(&bin->runs,
	    arena_mapp_get(chunk, ((uintptr_t)run-(uintptr_t)chunk)>>LG_PAGE))
	    == NULL);

	binind = arena_bin_index(chunk->arena, run->bin);
	bin_info = &arena_bin_info[binind];

	malloc_mutex_unlock(&bin->lock);
	/******************************/
	npages = bin_info->run_size >> LG_PAGE;
	run_ind = (size_t)(((uintptr_t)run - (uintptr_t)chunk) >> LG_PAGE);
	past = (size_t)(PAGE_CEILING((uintptr_t)run +
	    (uintptr_t)bin_info->reg0_offset + (uintptr_t)(run->nextind *
	    bin_info->reg_interval - bin_info->redzone_size) -
	    (uintptr_t)chunk) >> LG_PAGE);
	malloc_mutex_lock(&arena->lock);

	/*
	 * If the run was originally clean, and some pages were never touched,
	 * trim the clean pages before deallocating the dirty portion of the
	 * run.
	 */
	assert(arena_mapbits_dirty_get(chunk, run_ind) ==
	    arena_mapbits_dirty_get(chunk, run_ind+npages-1));
	if (arena_mapbits_dirty_get(chunk, run_ind) == 0 && past - run_ind <
	    npages) {
		/* Trim clean pages.  Convert to large run beforehand. */
		assert(npages > 0);
		arena_mapbits_large_set(chunk, run_ind, bin_info->run_size, 0);
		arena_mapbits_large_set(chunk, run_ind+npages-1, 0, 0);
		arena_run_trim_tail(arena, chunk, run, (npages << LG_PAGE),
		    ((past - run_ind) << LG_PAGE), false);
		/* npages = past - run_ind; */
	}
	arena_run_dalloc(arena, run, true, false);
	malloc_mutex_unlock(&arena->lock);
	/****************************/
	malloc_mutex_lock(&bin->lock);
	if (config_stats)
		bin->stats.curruns--;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rdx, %r14
movq %rsi, %r13
movq %rdi, 0x8(%rsp)
movq (%rdx), %rax
subq (%rsi), %rax
addq $-0x120, %rax           # imm = 0xFEE0
shrq $0x3, %rax
movabsq $-0x435e50d79435e508, %rbx # imm = 0xBCA1AF286BCA1AF8
imulq %rax, %rbx
leaq 0x5d988(%rip), %r15     # 0xdec00
movq %rcx, 0x40(%rsp)
movq %rcx, %rdi
callq 0x1fbb0
movq 0x18(%rbx,%r15), %rax
movq %rax, 0x10(%rsp)
movq %r14, %r12
subq %r13, %r12
movq %r12, %rbp
shrq $0xc, %rbp
movl 0x64(%rbx,%r15), %eax
movq %rax, 0x28(%rsp)
movl 0x8(%r14), %eax
movq %rax, 0x18(%rsp)
movq 0x8(%rbx,%r15), %rax
movq %rax, 0x30(%rsp)
movq 0x10(%rbx,%r15), %rax
movq %rax, 0x20(%rsp)
movq 0x8(%rsp), %rax
leaq 0x8(%rax), %rdi
movq %rdi, 0x38(%rsp)
callq 0x1faa0
leaq 0x5e64b(%rip), %rax     # 0xdf928
movq %rbp, %rcx
subq (%rax), %rcx
leaq (%rcx,%rcx,2), %r8
movq 0x40(%r13,%r8,8), %rdx
testb $0x8, %dl
jne 0x81394
movq 0x10(%rsp), %rcx
shrq $0xc, %rcx
movq 0x20(%rsp), %rdi
imulq 0x18(%rsp), %rdi
addq 0x28(%rsp), %r12
addq %rdi, %r12
subq 0x30(%rsp), %r12
addq $0xfff, %r12            # imm = 0xFFF
shrq $0xc, %r12
subq %rbp, %r12
cmpq %rcx, %r12
jae 0x81394
addq %rbx, %r15
leaq 0x30(%r13), %rdi
leaq 0x40(,%r8,8), %r9
addq %r13, %r9
andl $0x4, %edx
orq 0x18(%r15), %rdx
movl $0xff3, %r8d            # imm = 0xFF3
orq %r8, %rdx
movq %rdx, (%r9)
addq %rbp, %rcx
movq (%rax), %rax
notq %rax
addq %rcx, %rax
leaq (%rax,%rax,2), %rax
movq 0x10(%rdi,%rax,8), %rcx
andl $0x4, %ecx
orq %r8, %rcx
movq %rcx, 0x10(%rdi,%rax,8)
movq 0x10(%rsp), %rcx
andq $-0x1000, %rcx          # imm = 0xF000
shlq $0xc, %r12
movq 0x8(%rsp), %rdi
movq %r13, %rsi
movq %r14, %rdx
movq %r12, %r8
xorl %r9d, %r9d
callq 0x80f33
movq 0x8(%rsp), %rdi
movq %r14, %rsi
movl $0x1, %edx
xorl %ecx, %ecx
callq 0x81526
movq 0x38(%rsp), %rdi
callq 0x1fbb0
movq 0x40(%rsp), %rbx
movq %rbx, %rdi
callq 0x1faa0
decq 0x90(%rbx)
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq