// File: /workspace/github_c_makefile_star2_O3/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, %ebp
movl %ecx, 0x18(%rsp)
movq %rdx, %rcx
movq %rsi, %rbx
movq %rdi, 0x20(%rsp)
movabsq $0x7ffffffffffff000, %rdi # imm = 0x7FFFFFFFFFFFF000
leaq 0x3e2ff(%rip), %rax     # 0x4d0d0
movq (%rax), %r15
notq %r15
leaq -0x18(%rdx), %rax
andq %r15, %rax
andq %rdx, %r15
addq 0x3e1e0(%rip), %rax     # 0x4cfc8
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), %rsi
testb $0x2, %sil
jne 0xee1c
movl (%rcx), %eax
shlq $0x6, %rax
leaq 0x3d7cb(%rip), %rcx     # 0x4c5e0
movq 0x18(%rax,%rcx), %rsi
jmp 0xee22
shrq %rsi
andq %rdi, %rsi
addq 0x3e197(%rip), %r13     # 0x4cfc0
movq %rsi, %r12
shrq $0xc, %rsi
movq %rbx, %rdi
movq %rsi, 0x10(%rsp)
callq 0x21d13
orb %r14b, %bpl
je 0xee48
movl 0x18(%rsp), %ebp
jmp 0xee62
movq %r13, %rax
subq 0x3e16e(%rip), %rax     # 0x4cfc0
movb 0x78(%r15,%rax,8), %al
andb $0x10, %al
shrb $0x4, %al
orb 0x18(%rsp), %al
movl %eax, %ebp
movzbl %bpl, %edi
shll $0x4, %edi
movzbl %r14b, %r8d
shll $0x2, %r8d
orb %bpl, %r14b
movq %r13, %rax
subq 0x3e142(%rip), %rax     # 0x4cfc0
cmpb $0x1, %r14b
movabsq $0x7ffffffffffff000, %rsi # imm = 0x7FFFFFFFFFFFF000
jne 0xeec4
leaq (%r12,%r12), %rcx
movq %r8, %rdx
orq %rdi, %rdx
orq %rcx, %rdx
orq $0x1fe0, %rdx           # imm = 0x1FE0
movq %rdx, 0x78(%r15,%rax,8)
movq 0x10(%rsp), %rax
leaq (%rax,%r13), %r14
movq 0x3e109(%rip), %rax     # 0x4cfc0
notq %rax
addq %r14, %rax
movq %rdx, 0x78(%r15,%rax,8)
jmp 0xef05
movq 0x78(%r15,%rax,8), %rcx
andl $0x8, %ecx
leaq (%r12,%r12), %rdx
orq $0x1fe0, %rdx           # imm = 0x1FE0
orq %rdx, %rcx
movq %rcx, 0x78(%r15,%rax,8)
movq 0x10(%rsp), %rax
leaq (%rax,%r13), %r14
movq 0x3e0d1(%rip), %rax     # 0x4cfc0
notq %rax
addq %r14, %rax
movq 0x78(%r15,%rax,8), %rcx
andl $0x8, %ecx
orq %rdx, %rcx
movq %rcx, 0x78(%r15,%rax,8)
leaq 0x3e1cc(%rip), %rcx     # 0x4d0d8
movq 0x3e0ad(%rip), %rax     # 0x4cfc0
cmpq (%rcx), %r14
movq %rbx, 0x8(%rsp)
jae 0xf051
movq %r14, %rcx
subq %rax, %rcx
movq 0x78(%r15,%rcx,8), %rbx
movl %ebx, %ecx
andl $0x4, %ecx
cmpl %r8d, %ecx
jne 0xf04c
movl %ebx, %ecx
andl $0x1, %ecx
jne 0xf04c
movl %ebx, %ecx
andl $0x10, %ecx
cmpl %edi, %ecx
jne 0xf04c
movq %r12, 0x28(%rsp)
movq %r8, 0x30(%rsp)
movq %rdi, 0x18(%rsp)
movl %ebp, %r12d
movq %rbx, %rbp
shrq %rbp
andq %rsi, %rbp
shrq $0xd, %rbx
movq 0x8(%rsp), %rdi
movq %r15, %rsi
movq %r14, %rdx
callq 0xecd4
movl %r12d, %edi
testb %r12b, %r12b
je 0xefd3
movq 0x3e038(%rip), %rax     # 0x4cfc8
addq %r15, %rax
imulq $0x60, %r14, %rcx
addq %rax, %rcx
xorl %eax, %eax
subq 0x3e01d(%rip), %rax     # 0x4cfc0
imulq $0x60, %rax, %rax
addq %rcx, %rax
addq $0x18, %rax
movq (%rax), %rcx
movq 0x8(%rax), %rdx
movq %rcx, (%rdx)
movq 0x8(%rax), %rdx
movq %rdx, 0x8(%rcx)
movq %rax, (%rax)
movq %rax, 0x8(%rax)
movq 0x8(%rsp), %rax
subq %rbx, 0x130(%rax)
movq 0x28(%rsp), %r12
addq %rbp, %r12
movq 0x10(%rsp), %r8
addq %rbx, %r8
movq %r13, %rax
subq 0x3dfd3(%rip), %rax     # 0x4cfc0
leaq (%r12,%r12), %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 0x3dfb3(%rip), %rax     # 0x4cfc0
notq %rax
addq %r13, %rax
movq %r8, 0x10(%rsp)
addq %r8, %rax
andq 0x78(%r15,%rax,8), %rdx
orq %rcx, %rdx
movq %rdx, 0x78(%r15,%rax,8)
movq 0x3df91(%rip), %rax     # 0x4cfc0
movq 0x8(%rsp), %rbx
movl %edi, %ebp
movabsq $0x7ffffffffffff000, %rsi # imm = 0x7FFFFFFFFFFFF000
movq 0x18(%rsp), %rdi
movq 0x30(%rsp), %r8
jmp 0xf051
movq 0x8(%rsp), %rbx
cmpq %rax, %r13
jbe 0xf15f
notq %rax
addq %r13, %rax
movq 0x78(%r15,%rax,8), %rbx
movl %ebx, %eax
andl $0x4, %eax
cmpl %r8d, %eax
jne 0xf164
movl %ebx, %eax
andl $0x1, %eax
jne 0xf164
movl %ebx, %eax
andl $0x10, %eax
cmpl %edi, %eax
jne 0xf164
movl %ebp, 0x18(%rsp)
movq %rbx, %rbp
shrq %rbp
andq %rsi, %rbp
shrq $0xd, %rbx
movq %r13, %r14
subq %rbx, %r14
movq 0x8(%rsp), %rdi
movq %r15, %rsi
movq %r14, %rdx
callq 0xecd4
movl 0x18(%rsp), %eax
movl %eax, %edi
testb %al, %al
je 0xf106
movq 0x3df05(%rip), %rax     # 0x4cfc8
addq %r15, %rax
imulq $0x60, %r14, %rcx
addq %rax, %rcx
xorl %eax, %eax
subq 0x3deea(%rip), %rax     # 0x4cfc0
imulq $0x60, %rax, %rax
addq %rcx, %rax
addq $0x18, %rax
movq (%rax), %rcx
movq 0x8(%rax), %rdx
movq %rcx, (%rdx)
movq 0x8(%rax), %rdx
movq %rdx, 0x8(%rcx)
movq %rax, (%rax)
movq %rax, 0x8(%rax)
movq 0x8(%rsp), %rax
subq %rbx, 0x130(%rax)
addq %rbp, %r12
movq %r14, %rax
subq 0x3dead(%rip), %rax     # 0x4cfc0
leaq (%r12,%r12), %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 0x3de85(%rip), %rax     # 0x4cfc0
notq %rax
addq %r13, %rax
andq 0x78(%r15,%rax,8), %rdx
addq %rsi, %rbx
orq %rcx, %rdx
movq %rdx, 0x78(%r15,%rax,8)
movq %rbx, 0x10(%rsp)
movq 0x8(%rsp), %rbx
movl %edi, %ebp
jmp 0xf16c
movq %r13, %r14
jmp 0xf16c
movq %r13, %r14
movq 0x8(%rsp), %rbx
movq %rbx, %rdi
movq %r15, %rsi
movq %r14, %rdx
callq 0xebde
testb %bpl, %bpl
je 0xf1de
movq 0x3de42(%rip), %rax     # 0x4cfc8
addq %r15, %rax
imulq $0x60, %r14, %rcx
xorl %edx, %edx
subq 0x3de2a(%rip), %rdx     # 0x4cfc0
addq %rax, %rcx
imulq $0x60, %rdx, %rax
addq %rcx, %rax
addq $0x18, %rax
movq %rax, (%rax)
movq %rax, 0x8(%rax)
leaq 0x138(%rbx), %rcx
movq 0x140(%rbx), %rdx
movq %rax, (%rdx)
movq 0x8(%rax), %rsi
movq %rcx, (%rsi)
movq 0x8(%rax), %rcx
movq %rcx, 0x140(%rbx)
movq %rdx, 0x8(%rax)
movq 0x10(%rsp), %rax
addq %rax, 0x130(%rbx)
cmpq 0x3ddeb(%rip), %r12     # 0x4cfd0
je 0xf216
testb %bpl, %bpl
je 0xf207
movq 0x20(%rsp), %rdi
movq %rbx, %rsi
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x2221b
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x3dda3(%rip), %rdx     # 0x4cfc0
movq %rbx, %rdi
movq %r15, %rsi
callq 0xecd4
movq 0x100(%rbx), %rax
cmpq %r15, %rax
jne 0xf23f
movq 0x50(%rax), %rax
movq %rax, 0x100(%rbx)
cmpq %r15, %rax
je 0xf262
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 0xf26a
andq $0x0, 0x100(%rbx)
movq 0x110(%rbx), %rdx
movq %r15, 0x110(%rbx)
testq %rdx, %rdx
je 0xf1e7
testb $0x10, 0x78(%rdx)
je 0xf2c6
movq 0x3dd32(%rip), %rax     # 0x4cfc0
leaq 0x3de43(%rip), %rcx     # 0x4d0d8
subq (%rcx), %rax
movq 0x3dd29(%rip), %rcx     # 0x4cfc8
addq %rdx, %rcx
addq $0x18, %rcx
movq (%rcx), %rsi
movq 0x8(%rcx), %rdi
movq %rsi, (%rdi)
movq 0x8(%rcx), %rdi
movq %rdi, 0x8(%rsi)
movq %rcx, (%rcx)
movq %rcx, 0x8(%rcx)
addq %rax, 0x130(%rbx)
movq 0x20(%rsp), %rdi
movq %rbx, %rsi
callq 0x22f15
jmp 0xf1e7