// File: /workspace/github_c_makefile_star2_O3/gplessis[P]dotdeb-redis/deps/jemalloc/src/arena.c
// Function: arena_run_dalloc
static void
arena_run_dalloc(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_cactive_update(arena, 0, run_pages);
	arena->nactive -= 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(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(arena);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movl %edx, %ebx
movq %rdi, %r13
movabsq $0x7ffffffffffff000, %r11 # imm = 0x7FFFFFFFFFFFF000
leaq 0x2ecb4(%rip), %rax     # 0x5b6b0
movq (%rax), %r9
movq %r9, %rdi
notq %rdi
movq %rdi, %r14
andq %rsi, %r14
leaq -0x10(%rsi), %rax
andq %rdi, %rax
addq 0x2eb47(%rip), %rax     # 0x5b560
negq %rax
addq %rsi, %rax
addq $-0x10, %rax
movabsq $-0x5555555555555555, %rdx # imm = 0xAAAAAAAAAAAAAAAB
mulq %rdx
movq %rdx, %r15
shrq $0x6, %r15
movq 0x68(%r14,%r15,8), %r10
testb $0x2, %r10b
jne 0x2ca5a
movl (%rsi), %eax
leaq (%rax,%rax,2), %rax
shlq $0x5, %rax
leaq 0x2dc4d(%rip), %rdx     # 0x5a6a0
movq 0x18(%rax,%rdx), %r10
jmp 0x2ca60
shrq %r10
andq %r11, %r10
addq 0x2eaf1(%rip), %r15     # 0x5b558
movq %r10, %r11
shrq $0xc, %r11
movq 0xe0(%r13), %rsi
movq %rsi, %rax
subq %r11, %rax
movq %rax, %rdx
shlq $0xc, %rdx
addq %r9, %rdx
andq %rdi, %rdx
shlq $0xc, %rsi
addq %r9, %rsi
andq %rdi, %rsi
subq %rsi, %rdx
je 0x2caad
leaq 0x2f30a(%rip), %rax     # 0x5bda8
lock
xaddq %rdx, (%rax)
movq 0xe0(%r13), %rax
subq %r11, %rax
movq %rax, 0xe0(%r13)
orb %r8b, %cl
jne 0x2cad1
movq %r15, %rax
subq 0x2ea95(%rip), %rax     # 0x5b558
movb 0x68(%r14,%rax,8), %al
andb $0x10, %al
shrb $0x4, %al
orb %bl, %al
movl %eax, %ebx
movzbl %bl, %esi
shll $0x4, %esi
movzbl %r8b, %ebp
shll $0x2, %ebp
orb %bl, %r8b
movq %r15, %rax
subq 0x2ea6d(%rip), %rax     # 0x5b558
cmpb $0x1, %r8b
jne 0x2cb22
leaq (%r10,%r10), %rcx
movq %rbp, %rdx
orq %rsi, %rdx
orq %rcx, %rdx
orq $0x1fe0, %rdx           # imm = 0x1FE0
movq %rdx, 0x68(%r14,%rax,8)
leaq (%r11,%r15), %r12
movq 0x2ea43(%rip), %rax     # 0x5b558
notq %rax
addq %r12, %rax
movq %rdx, 0x68(%r14,%rax,8)
jmp 0x2cb5e
movq 0x68(%r14,%rax,8), %rcx
andl $0x8, %ecx
leaq (%r10,%r10), %rdx
orq $0x1fe0, %rdx           # imm = 0x1FE0
orq %rdx, %rcx
movq %rcx, 0x68(%r14,%rax,8)
leaq (%r11,%r15), %r12
movq 0x2ea10(%rip), %rax     # 0x5b558
notq %rax
addq %r12, %rax
movq 0x68(%r14,%rax,8), %rcx
andl $0x8, %ecx
orq %rdx, %rcx
movq %rcx, 0x68(%r14,%rax,8)
leaq 0x2eb53(%rip), %rcx     # 0x5b6b8
movq 0x2e9ec(%rip), %rax     # 0x5b558
cmpq (%rcx), %r12
movl %ebx, 0xc(%rsp)
jae 0x2cca6
movq %r12, %rcx
subq %rax, %rcx
movq 0x68(%r14,%rcx,8), %rbx
movl %ebx, %ecx
andl $0x4, %ecx
cmpl %ebp, %ecx
jne 0x2cca2
movl %ebx, %ecx
andl $0x1, %ecx
jne 0x2cca2
movl %ebx, %ecx
andl $0x10, %ecx
cmpl %esi, %ecx
jne 0x2cca2
movq %rsi, 0x28(%rsp)
movq %r11, 0x10(%rsp)
movq %r10, 0x18(%rsp)
movq %r13, %rdi
movq %rbx, %r13
shrq %r13
movabsq $0x7ffffffffffff000, %rax # imm = 0x7FFFFFFFFFFFF000
andq %rax, %r13
shrq $0xd, %rbx
movq %rdi, 0x20(%rsp)
movq %r14, %rsi
movq %r12, %rdx
callq 0x2c402
cmpb $0x0, 0xc(%rsp)
je 0x2cc3b
movq 0x2e970(%rip), %rax     # 0x5b560
addq %r14, %rax
leaq (%r12,%r12,2), %rcx
shlq $0x5, %rcx
addq %rax, %rcx
xorl %eax, %eax
subq 0x2e951(%rip), %rax     # 0x5b558
leaq (%rax,%rax,2), %rax
shlq $0x5, %rax
addq %rcx, %rax
addq $0x10, %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 0x20(%rsp), %rax
subq %rbx, 0xe8(%rax)
movq 0x18(%rsp), %r10
addq %r13, %r10
movq 0x10(%rsp), %r11
addq %rbx, %r11
movq %r15, %rax
subq 0x2e903(%rip), %rax     # 0x5b558
leaq (%r10,%r10), %rcx
movl $0x1fff, %edx           # imm = 0x1FFF
movq 0x68(%r14,%rax,8), %rsi
andq %rdx, %rsi
orq %rcx, %rsi
movq %rsi, 0x68(%r14,%rax,8)
movq 0x2e8e3(%rip), %rax     # 0x5b558
notq %rax
addq %r15, %rax
addq %r11, %rax
andq 0x68(%r14,%rax,8), %rdx
orq %rcx, %rdx
movq %rdx, 0x68(%r14,%rax,8)
movq 0x2e8c6(%rip), %rax     # 0x5b558
movq 0x20(%rsp), %r13
movl 0xc(%rsp), %ebx
movq 0x28(%rsp), %rsi
jmp 0x2cca6
movl 0xc(%rsp), %ebx
movq %r11, 0x10(%rsp)
movq %r10, 0x18(%rsp)
cmpq %rax, %r15
jbe 0x2cdc3
notq %rax
addq %r15, %rax
movq 0x68(%r14,%rax,8), %rbx
movl %ebx, %eax
andl $0x4, %eax
cmpl %ebp, %eax
jne 0x2cdc8
movl %ebx, %eax
andl $0x1, %eax
jne 0x2cdc8
movl %ebx, %eax
andl $0x10, %eax
cmpl %esi, %eax
jne 0x2cdc8
movq %rbx, %rbp
shrq %rbp
movabsq $0x7ffffffffffff000, %rax # imm = 0x7FFFFFFFFFFFF000
andq %rax, %rbp
shrq $0xd, %rbx
movq %r15, %r12
subq %rbx, %r12
movq %r13, %rdi
movq %r14, %rsi
movq %r12, %rdx
callq 0x2c402
cmpb $0x0, 0xc(%rsp)
je 0x2cd68
movq 0x2e83e(%rip), %rax     # 0x5b560
addq %r14, %rax
leaq (%r12,%r12,2), %rcx
shlq $0x5, %rcx
addq %rax, %rcx
xorl %eax, %eax
subq 0x2e81f(%rip), %rax     # 0x5b558
leaq (%rax,%rax,2), %rax
shlq $0x5, %rax
addq %rcx, %rax
addq $0x10, %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)
subq %rbx, 0xe8(%r13)
movq 0x18(%rsp), %rcx
addq %rbp, %rcx
movq %r12, %rax
subq 0x2e7de(%rip), %rax     # 0x5b558
movq %rcx, 0x18(%rsp)
addq %rcx, %rcx
movl $0x1fff, %edx           # imm = 0x1FFF
movq 0x68(%r14,%rax,8), %rsi
andq %rdx, %rsi
orq %rcx, %rsi
movq %rsi, 0x68(%r14,%rax,8)
movq 0x10(%rsp), %rsi
addq %rsi, %r15
movq 0x2e7b2(%rip), %rax     # 0x5b558
notq %rax
addq %r15, %rax
andq 0x68(%r14,%rax,8), %rdx
addq %rsi, %rbx
orq %rcx, %rdx
movq %rdx, 0x68(%r14,%rax,8)
movq %rbx, 0x10(%rsp)
jmp 0x2cdcb
movq %r15, %r12
jmp 0x2cdcf
movq %r15, %r12
movl 0xc(%rsp), %ebx
movq %r13, %rdi
movq %r14, %rsi
movq %r12, %rdx
callq 0x2bc79
testb %bl, %bl
je 0x2ce48
movq 0x2e778(%rip), %rax     # 0x5b560
addq %r14, %rax
leaq (%r12,%r12,2), %rcx
shlq $0x5, %rcx
addq %rax, %rcx
xorl %eax, %eax
subq 0x2e759(%rip), %rax     # 0x5b558
leaq (%rax,%rax,2), %rax
shlq $0x5, %rax
addq %rcx, %rax
addq $0x10, %rax
movq %rax, (%rax)
movq %rax, 0x8(%rax)
leaq 0x158(%r13), %rcx
movq 0x160(%r13), %rdx
movq %rax, (%rdx)
movq 0x8(%rax), %rsi
movq %rcx, (%rsi)
movq 0x8(%rax), %rcx
movq %rcx, 0x160(%r13)
movq %rdx, 0x8(%rax)
movq 0x10(%rsp), %rax
addq %rax, 0xe8(%r13)
movq 0x18(%rsp), %rax
cmpq 0x2e714(%rip), %rax     # 0x5b568
jne 0x2cf71
movq 0x2e6f7(%rip), %rdx     # 0x5b558
movq %r13, %rdi
movq %r14, %rsi
callq 0x2c402
movq 0xc8(%r13), %r15
testq %r15, %r15
je 0x2cf6a
xorps %xmm0, %xmm0
movaps %xmm0, 0x50(%rsp)
movaps %xmm0, 0x40(%rsp)
movaps %xmm0, 0x30(%rsp)
movq $0x0, 0x60(%rsp)
movq %r14, 0xc8(%r13)
testb $0x10, 0x68(%r15)
je 0x2cee4
movq 0x2e6ac(%rip), %rax     # 0x5b558
leaq 0x2e805(%rip), %rcx     # 0x5b6b8
subq (%rcx), %rax
movq 0x2e6a3(%rip), %rcx     # 0x5b560
addq %r15, %rcx
addq $0x10, %rcx
movq (%rcx), %rdx
movq 0x8(%rcx), %rsi
movq %rdx, (%rsi)
movq 0x8(%rcx), %rsi
movq %rsi, 0x8(%rdx)
movq %rcx, (%rcx)
movq %rcx, 0x8(%rcx)
addq %rax, 0xe8(%r13)
movq %r15, %rdi
movq %r15, %rsi
callq 0x2e5a5
movq 0x68(%r15), %rbx
testb $0x4, %bl
je 0x2cf2a
leaq 0x30(%rsp), %r14
movq %r14, %rdi
movq %r13, %rsi
callq 0x2e354
leaq 0x2e799(%rip), %rax     # 0x5b6a8
movq (%rax), %rsi
movq 0x2e63f(%rip), %rcx     # 0x5b558
shlq $0xc, %rcx
movl (%r13), %r8d
movq %r15, %rdi
xorl %edx, %edx
callq *0x18(%r14)
xorl %r8d, %r8d
testb $0x4, %bl
sete %r8b
leaq 0x2e76d(%rip), %rbx     # 0x5b6a8
movq (%rbx), %rcx
leaq 0x30(%rsp), %rsi
movq %r13, %rdi
movq %r15, %rdx
callq 0x2ebea
movq (%rbx), %rax
subq %rax, 0x30(%r13)
movq 0x2e5fc(%rip), %rax     # 0x5b558
shlq $0xc, %rax
subq %rax, 0x50(%r13)
movl 0xc(%rsp), %ebx
jmp 0x2cf71
movq %r14, 0xc8(%r13)
testb %bl, %bl
je 0x2cf7d
movq %r13, %rdi
callq 0x278db
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq