// File: /workspace/github_c_makefile_star2_O1/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, 0xc(%rsp)
movq %rdx, %rcx
movq %rsi, %rbx
movq %rdi, 0x20(%rsp)
movabsq $0x7ffffffffffff000, %rdi # imm = 0x7FFFFFFFFFFFF000
leaq 0x3dc43(%rip), %rax     # 0x4d0d0
movq (%rax), %r15
notq %r15
leaq -0x18(%rdx), %rax
andq %r15, %rax
andq %rdx, %r15
addq 0x3db24(%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), %r12
testb $0x2, %r12b
jne 0xf4d8
movl (%rcx), %eax
shlq $0x6, %rax
leaq 0x3d10f(%rip), %rcx     # 0x4c5e0
movq 0x18(%rax,%rcx), %r12
jmp 0xf4de
shrq %r12
andq %rdi, %r12
addq 0x3dadb(%rip), %r13     # 0x4cfc0
movq %r12, %rsi
shrq $0xc, %rsi
movq %rbx, %rdi
movq %rsi, 0x18(%rsp)
callq 0x21e7e
orb %r14b, %bpl
je 0xf504
movl 0xc(%rsp), %ebp
jmp 0xf51e
movq %r13, %rax
subq 0x3dab2(%rip), %rax     # 0x4cfc0
movb 0x78(%r15,%rax,8), %al
andb $0x10, %al
shrb $0x4, %al
orb 0xc(%rsp), %al
movl %eax, %ebp
movzbl %bpl, %esi
shll $0x4, %esi
movzbl %r14b, %edi
shll $0x2, %edi
orb %bpl, %r14b
movq %r13, %rax
subq 0x3da87(%rip), %rax     # 0x4cfc0
cmpb $0x1, %r14b
movq 0x18(%rsp), %r8
jne 0xf575
leaq (%r12,%r12), %rcx
movq %rdi, %rdx
orq %rsi, %rdx
orq %rcx, %rdx
orq $0x1fe0, %rdx           # imm = 0x1FE0
movq %rdx, 0x78(%r15,%rax,8)
leaq (%r8,%r13), %rax
movq 0x3da58(%rip), %rcx     # 0x4cfc0
notq %rcx
addq %rax, %rcx
movq %rdx, 0x78(%r15,%rcx,8)
jmp 0xf5b1
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)
leaq (%r8,%r13), %rax
movq 0x3da25(%rip), %rcx     # 0x4cfc0
notq %rcx
addq %rax, %rcx
movq 0x78(%r15,%rcx,8), %rax
andl $0x8, %eax
orq %rdx, %rax
movq %rax, 0x78(%r15,%rcx,8)
leaq (%r8,%r13), %r14
leaq 0x3db1c(%rip), %rax     # 0x4d0d8
cmpq (%rax), %r14
movq %rbx, 0x10(%rsp)
jae 0xf6ed
movq %r14, %rax
subq 0x3d9ec(%rip), %rax     # 0x4cfc0
movq 0x78(%r15,%rax,8), %rbx
movl %ebx, %eax
andl $0x4, %eax
cmpl %edi, %eax
jne 0xf6e8
movl %ebx, %eax
andl $0x1, %eax
jne 0xf6e8
movl %ebx, %eax
andl $0x10, %eax
cmpl %esi, %eax
jne 0xf6e8
movq %rdi, 0x28(%rsp)
movq %rsi, 0x30(%rsp)
movl %ebp, 0xc(%rsp)
movq %rbx, %rbp
shrq %rbp
movabsq $0x7ffffffffffff000, %rax # imm = 0x7FFFFFFFFFFFF000
andq %rax, %rbp
shrq $0xd, %rbx
movq 0x10(%rsp), %rdi
movq %r15, %rsi
movq %r14, %rdx
callq 0xf390
movl 0xc(%rsp), %eax
movl %eax, %edi
testb %al, %al
je 0xf68a
movq 0x3d984(%rip), %rax     # 0x4cfc8
addq %r15, %rax
imulq $0x60, %r14, %rcx
addq %rax, %rcx
xorl %eax, %eax
subq 0x3d969(%rip), %rax     # 0x4cfc0
imulq $0x60, %rax, %rax
addq %rcx, %rax
addq $0x18, %rax
movq (%rax), %rcx
movq 0x8(%rax), %rdx
movq %rcx, (%rdx)
movq (%rax), %rcx
movq 0x8(%rax), %rdx
movq %rdx, 0x8(%rcx)
movq %rax, (%rax)
movq %rax, 0x8(%rax)
movq 0x10(%rsp), %rax
subq %rbx, 0x130(%rax)
addq %rbp, %r12
movq 0x18(%rsp), %r8
addq %rbx, %r8
movq %r13, %rax
subq 0x3d921(%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 0x3d901(%rip), %rax     # 0x4cfc0
notq %rax
addq %r13, %rax
addq %r8, %rax
andq 0x78(%r15,%rax,8), %rdx
orq %rcx, %rdx
movq %rdx, 0x78(%r15,%rax,8)
movq 0x10(%rsp), %rbx
movl %edi, %ebp
movq 0x30(%rsp), %rsi
movq 0x28(%rsp), %rdi
jmp 0xf6ed
movq 0x10(%rsp), %rbx
movq %r8, 0x18(%rsp)
movq 0x3d8c7(%rip), %rax     # 0x4cfc0
cmpq %rax, %r13
jbe 0xf813
notq %rax
addq %r13, %rax
movq 0x78(%r15,%rax,8), %rbx
movl %ebx, %eax
andl $0x4, %eax
cmpl %edi, %eax
jne 0xf818
movl %ebx, %eax
andl $0x1, %eax
jne 0xf818
movl %ebx, %eax
andl $0x10, %eax
cmpl %esi, %eax
jne 0xf818
movl %ebp, 0xc(%rsp)
movq %rbx, %rbp
shrq %rbp
movabsq $0x7ffffffffffff000, %rax # imm = 0x7FFFFFFFFFFFF000
andq %rax, %rbp
shrq $0xd, %rbx
movq %r13, %r14
subq %rbx, %r14
movq 0x10(%rsp), %rdi
movq %r15, %rsi
movq %r14, %rdx
callq 0xf390
movl 0xc(%rsp), %eax
movl %eax, %edi
testb %al, %al
je 0xf7ba
movq 0x3d854(%rip), %rax     # 0x4cfc8
addq %r15, %rax
imulq $0x60, %r14, %rcx
addq %rax, %rcx
xorl %eax, %eax
subq 0x3d839(%rip), %rax     # 0x4cfc0
imulq $0x60, %rax, %rax
addq %rcx, %rax
addq $0x18, %rax
movq (%rax), %rcx
movq 0x8(%rax), %rdx
movq %rcx, (%rdx)
movq (%rax), %rcx
movq 0x8(%rax), %rdx
movq %rdx, 0x8(%rcx)
movq %rax, (%rax)
movq %rax, 0x8(%rax)
movq 0x10(%rsp), %rax
subq %rbx, 0x130(%rax)
addq %rbp, %r12
movq %r14, %rax
subq 0x3d7f9(%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 0x18(%rsp), %rsi
addq %rsi, %r13
movq 0x3d7d1(%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, 0x18(%rsp)
movq 0x10(%rsp), %rbx
movl %edi, %ebp
jmp 0xf820
movq %r13, %r14
jmp 0xf820
movq %r13, %r14
movq 0x10(%rsp), %rbx
movq %rbx, %rdi
movq %r15, %rsi
movq %r14, %rdx
callq 0xf21e
testb %bpl, %bpl
je 0xf892
movq 0x3d78e(%rip), %rax     # 0x4cfc8
addq %r15, %rax
imulq $0x60, %r14, %rcx
xorl %edx, %edx
subq 0x3d776(%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 0x18(%rsp), %rax
addq %rax, 0x130(%rbx)
cmpq 0x3d737(%rip), %r12     # 0x4cfd0
je 0xf8ca
testb %bpl, %bpl
je 0xf8bb
movq 0x20(%rsp), %rdi
movq %rbx, %rsi
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x22368
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x3d6ef(%rip), %rdx     # 0x4cfc0
movq %rbx, %rdi
movq %r15, %rsi
callq 0xf390
movq 0x100(%rbx), %rax
cmpq %r15, %rax
jne 0xf8f3
movq 0x50(%rax), %rax
movq %rax, 0x100(%rbx)
cmpq %r15, 0x100(%rbx)
je 0xf91e
movq 0x50(%r15), %rax
movq 0x58(%r15), %rcx
movq %rax, 0x50(%rcx)
movq 0x50(%r15), %rax
movq 0x58(%r15), %rcx
movq %rcx, 0x58(%rax)
movq %r15, 0x50(%r15)
movq %r15, 0x58(%r15)
jmp 0xf926
andq $0x0, 0x100(%rbx)
movq 0x110(%rbx), %rdx
movq %r15, 0x110(%rbx)
testq %rdx, %rdx
je 0xf89b
testb $0x10, 0x78(%rdx)
je 0xf985
movq 0x3d676(%rip), %rax     # 0x4cfc0
leaq 0x3d787(%rip), %rcx     # 0x4d0d8
subq (%rcx), %rax
movq 0x3d66d(%rip), %rcx     # 0x4cfc8
addq %rdx, %rcx
addq $0x18, %rcx
movq (%rcx), %rsi
movq 0x8(%rcx), %rdi
movq %rsi, (%rdi)
movq (%rcx), %rsi
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 0x22fe6
jmp 0xf89b