// File: /workspace/github_c_makefile_star2_O2/zhou-yuxin[P]redis-aof-no-cow/deps/jemalloc/src/arena.c
// Function: arena_run_dalloc
static void
arena_run_dalloc(tsdn_t *tsdn, arena_t *arena, arena_run_t *run, bool dirty,
    bool cleaned, bool decommitted)
{
	arena_chunk_t *chunk;
	arena_chunk_map_misc_t *miscelm;
	size_t size, run_ind, run_pages, flag_dirty, flag_decommitted;

	chunk = (arena_chunk_t *)CHUNK_ADDR2BASE(run);
	miscelm = arena_run_to_miscelm(run);
	run_ind = arena_miscelm_to_pageind(miscelm);
	assert(run_ind >= map_bias);
	assert(run_ind < chunk_npages);
	size = arena_run_size_get(arena, chunk, run, run_ind);
	run_pages = (size >> LG_PAGE);
	arena_nactive_sub(arena, run_pages);

	/*
	 * The run is dirty if the caller claims to have dirtied it, as well as
	 * if it was already dirty before being allocated and the caller
	 * doesn't claim to have cleaned it.
	 */
	assert(arena_mapbits_dirty_get(chunk, run_ind) ==
	    arena_mapbits_dirty_get(chunk, run_ind+run_pages-1));
	if (!cleaned && !decommitted && arena_mapbits_dirty_get(chunk, run_ind)
	    != 0)
		dirty = true;
	flag_dirty = dirty ? CHUNK_MAP_DIRTY : 0;
	flag_decommitted = decommitted ? CHUNK_MAP_DECOMMITTED : 0;

	/* Mark pages as unallocated in the chunk map. */
	if (dirty || decommitted) {
		size_t flags = flag_dirty | flag_decommitted;
		arena_mapbits_unallocated_set(chunk, run_ind, size, flags);
		arena_mapbits_unallocated_set(chunk, run_ind+run_pages-1, size,
		    flags);
	} else {
		arena_mapbits_unallocated_set(chunk, run_ind, size,
		    arena_mapbits_unzeroed_get(chunk, run_ind));
		arena_mapbits_unallocated_set(chunk, run_ind+run_pages-1, size,
		    arena_mapbits_unzeroed_get(chunk, run_ind+run_pages-1));
	}

	arena_run_coalesce(arena, chunk, &size, &run_ind, &run_pages,
	    flag_dirty, flag_decommitted);

	/* Insert into runs_avail, now that coalescing is complete. */
	assert(arena_mapbits_unallocated_size_get(chunk, run_ind) ==
	    arena_mapbits_unallocated_size_get(chunk, run_ind+run_pages-1));
	assert(arena_mapbits_dirty_get(chunk, run_ind) ==
	    arena_mapbits_dirty_get(chunk, run_ind+run_pages-1));
	assert(arena_mapbits_decommitted_get(chunk, run_ind) ==
	    arena_mapbits_decommitted_get(chunk, run_ind+run_pages-1));
	arena_avail_insert(arena, chunk, run_ind, run_pages);

	if (dirty)
		arena_run_dirty_insert(arena, chunk, run_ind, run_pages);

	/* Deallocate chunk if it is now completely unused. */
	if (size == arena_maxrun) {
		assert(run_ind == map_bias);
		assert(run_pages == (arena_maxrun >> LG_PAGE));
		arena_chunk_dalloc(tsdn, arena, chunk);
	}

	/*
	 * It is okay to do dirty page processing here even if the chunk was
	 * deallocated above, since in that case it is the spare.  Waiting
	 * until after possible chunk deallocation to do dirty processing
	 * allows for an old spare to be fully deallocated, thus decreasing the
	 * chances of spuriously crossing the dirty page purging threshold.
	 */
	if (dirty)
		arena_maybe_purge(tsdn, arena);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movl %r9d, %r14d
movl %r8d, %r12d
movl %ecx, 0xc(%rsp)
movq %rdx, %rcx
movq %rsi, %rbx
movq %rdi, 0x20(%rsp)
movabsq $0x7ffffffffffff000, %rdi # imm = 0x7FFFFFFFFFFFF000
leaq 0x2930b(%rip), %rax     # 0x490d0
movq (%rax), %r15
notq %r15
leaq -0x18(%rdx), %rax
andq %r15, %rax
andq %rdx, %r15
addq 0x291ec(%rip), %rax     # 0x48fc8
negq %rax
addq %rdx, %rax
addq $-0x18, %rax
pushq $0x60
popq %rsi
xorl %edx, %edx
divq %rsi
movq %rax, %r13
movq 0x78(%r15,%rax,8), %rbp
testb $0x2, %bpl
jne 0x1fe10
movl (%rcx), %eax
shlq $0x6, %rax
leaq 0x287d7(%rip), %rcx     # 0x485e0
movq 0x18(%rax,%rcx), %rbp
jmp 0x1fe16
shrq %rbp
andq %rdi, %rbp
addq 0x291a3(%rip), %r13     # 0x48fc0
movq %rbp, %rsi
shrq $0xc, %rsi
movq %rbx, %rdi
movq %rsi, 0x10(%rsp)
callq 0x1a267
orb %r14b, %r12b
je 0x1fe3d
movl 0xc(%rsp), %r12d
jmp 0x1fe58
movq %r13, %rax
subq 0x29179(%rip), %rax     # 0x48fc0
movb 0x78(%r15,%rax,8), %al
andb $0x10, %al
shrb $0x4, %al
orb 0xc(%rsp), %al
movl %eax, %r12d
movzbl %r12b, %esi
shll $0x4, %esi
movzbl %r14b, %edi
shll $0x2, %edi
orb %r12b, %r14b
movq %r13, %rax
subq 0x2914d(%rip), %rax     # 0x48fc0
cmpb $0x1, %r14b
jne 0x1feb3
leaq (,%rbp,2), %rcx
movq %rdi, %rdx
orq %rsi, %rdx
orq %rcx, %rdx
orq $0x1fe0, %rdx           # imm = 0x1FE0
movq %rdx, 0x78(%r15,%rax,8)
movq 0x10(%rsp), %rax
leaq (%rax,%r13), %r14
movq 0x2911a(%rip), %rax     # 0x48fc0
notq %rax
addq %r14, %rax
movq %rdx, 0x78(%r15,%rax,8)
jmp 0x1fef8
movq 0x78(%r15,%rax,8), %rcx
andl $0x8, %ecx
leaq (,%rbp,2), %rdx
orq $0x1fe0, %rdx           # imm = 0x1FE0
orq %rdx, %rcx
movq %rcx, 0x78(%r15,%rax,8)
movq 0x10(%rsp), %rax
leaq (%rax,%r13), %r14
movq 0x290de(%rip), %rax     # 0x48fc0
notq %rax
addq %r14, %rax
movq 0x78(%r15,%rax,8), %rcx
andl $0x8, %ecx
orq %rdx, %rcx
movq %rcx, 0x78(%r15,%rax,8)
leaq 0x291d9(%rip), %rcx     # 0x490d8
movq 0x290ba(%rip), %rax     # 0x48fc0
cmpq (%rcx), %r14
movl %r12d, 0xc(%rsp)
jae 0x2000b
movq %r14, %rcx
subq %rax, %rcx
movq 0x78(%r15,%rcx,8), %r12
movl %r12d, %ecx
andl $0x4, %ecx
cmpl %edi, %ecx
jne 0x20006
movl %r12d, %ecx
andl $0x1, %ecx
jne 0x20006
movl %r12d, %ecx
andl $0x10, %ecx
cmpl %esi, %ecx
jne 0x20006
movq %rdi, 0x28(%rsp)
movq %rsi, 0x30(%rsp)
movq %rbx, %rdi
movq %r12, %rbx
shrq %rbx
movabsq $0x7ffffffffffff000, %rax # imm = 0x7FFFFFFFFFFFF000
andq %rax, %rbx
shrq $0xd, %r12
movq %rdi, 0x18(%rsp)
movq %r15, %rsi
movq %r14, %rdx
callq 0x1f6b0
cmpb $0x0, 0xc(%rsp)
je 0x1ff95
movq 0x18(%rsp), %rdi
movq %r15, %rsi
movq %r14, %rdx
movq %r12, %rcx
callq 0x1f70c
addq %rbx, %rbp
movq 0x10(%rsp), %rdi
addq %r12, %rdi
movq %r13, %rax
subq 0x29016(%rip), %rax     # 0x48fc0
leaq (,%rbp,2), %rcx
movl $0x1fff, %edx           # imm = 0x1FFF
movq 0x78(%r15,%rax,8), %rsi
andq %rdx, %rsi
orq %rcx, %rsi
movq %rsi, 0x78(%r15,%rax,8)
movq 0x28ff2(%rip), %rax     # 0x48fc0
notq %rax
addq %r13, %rax
movq %rdi, 0x10(%rsp)
addq %rdi, %rax
andq 0x78(%r15,%rax,8), %rdx
orq %rcx, %rdx
movq %rdx, 0x78(%r15,%rax,8)
movq 0x28fd0(%rip), %rax     # 0x48fc0
movq 0x18(%rsp), %rbx
movl 0xc(%rsp), %r12d
movq 0x30(%rsp), %rsi
movq 0x28(%rsp), %rdi
jmp 0x2000b
movl 0xc(%rsp), %r12d
cmpq %rax, %r13
jbe 0x200ec
notq %rax
addq %r13, %rax
movq 0x78(%r15,%rax,8), %r12
movl %r12d, %eax
andl $0x4, %eax
cmpl %edi, %eax
jne 0x200f1
movl %r12d, %eax
andl $0x1, %eax
jne 0x200f1
movl %r12d, %eax
andl $0x10, %eax
cmpl %esi, %eax
jne 0x200f1
movq %rbx, %rdi
movq %r12, %rbx
shrq %rbx
movabsq $0x7ffffffffffff000, %rax # imm = 0x7FFFFFFFFFFFF000
andq %rax, %rbx
shrq $0xd, %r12
movq %r13, %r14
subq %r12, %r14
movq %rdi, 0x18(%rsp)
movq %r15, %rsi
movq %r14, %rdx
callq 0x1f6b0
cmpb $0x0, 0xc(%rsp)
je 0x20091
movq 0x18(%rsp), %rdi
movq %r15, %rsi
movq %r14, %rdx
movq %r12, %rcx
callq 0x1f70c
addq %rbx, %rbp
movq %r14, %rax
subq 0x28f22(%rip), %rax     # 0x48fc0
leaq (,%rbp,2), %rcx
movl $0x1fff, %edx           # imm = 0x1FFF
movq 0x78(%r15,%rax,8), %rsi
andq %rdx, %rsi
orq %rcx, %rsi
movq %rsi, 0x78(%r15,%rax,8)
movq 0x10(%rsp), %rsi
addq %rsi, %r13
movq 0x28ef6(%rip), %rax     # 0x48fc0
notq %rax
addq %r13, %rax
andq 0x78(%r15,%rax,8), %rdx
addq %rsi, %r12
orq %rcx, %rdx
movq %rdx, 0x78(%r15,%rax,8)
movq %r12, 0x10(%rsp)
movq 0x18(%rsp), %rbx
jmp 0x200f4
movq %r13, %r14
jmp 0x200f9
movq %r13, %r14
movl 0xc(%rsp), %r12d
movq %rbx, %rdi
movq %r15, %rsi
movq %r14, %rdx
callq 0x1f1c9
testb %r12b, %r12b
je 0x2011f
movq %rbx, %rdi
movq %r15, %rsi
movq %r14, %rdx
movq 0x10(%rsp), %rcx
callq 0x1f74f
cmpq 0x28eaa(%rip), %rbp     # 0x48fd0
jne 0x201c9
movq 0x28e8d(%rip), %rdx     # 0x48fc0
movq %rbx, %rdi
movq %r15, %rsi
callq 0x1f6b0
movq 0x100(%rbx), %rax
cmpq %r15, %rax
jne 0x20155
movq 0x50(%rax), %rax
movq %rax, 0x100(%rbx)
cmpq %r15, %rax
je 0x20178
movq 0x50(%r15), %rax
movq 0x58(%r15), %rcx
movq %rax, 0x50(%rcx)
movq 0x58(%r15), %rcx
movq %rcx, 0x58(%rax)
movq %r15, 0x50(%r15)
movq %r15, 0x58(%r15)
jmp 0x20180
andq $0x0, 0x100(%rbx)
movq 0x110(%rbx), %r14
movq %r15, 0x110(%rbx)
testq %r14, %r14
je 0x201c9
testb $0x10, 0x78(%r14)
je 0x201b9
movq 0x28e1f(%rip), %rdx     # 0x48fc0
leaq 0x28f30(%rip), %rax     # 0x490d8
movq (%rax), %rcx
subq %rdx, %rcx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x1f70c
movq 0x20(%rsp), %rdi
movq %rbx, %rsi
movq %r14, %rdx
callq 0x1b338
testb %r12b, %r12b
je 0x201e9
movq 0x20(%rsp), %rdi
movq %rbx, %rsi
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x1a76f
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq