// File: /workspace/github_c_makefile_star2_O1/erikdubbelboer[P]discnt/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 0x45bd9(%rip), %rax     # 0x846a0
movq (%rax), %r9
movq %r9, %rdi
notq %rdi
movq %rdi, %r14
andq %rsi, %r14
leaq -0x10(%rsi), %rax
andq %rdi, %rax
addq 0x45a6c(%rip), %rax     # 0x84550
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 0x3eb25
movl (%rsi), %eax
leaq (%rax,%rax,2), %rax
shlq $0x5, %rax
leaq 0x44c92(%rip), %rdx     # 0x837b0
movq 0x18(%rax,%rdx), %r10
jmp 0x3eb2b
shrq %r10
andq %r11, %r10
addq 0x45a16(%rip), %r15     # 0x84548
movq %r10, %rbp
shrq $0xc, %rbp
movq 0xe0(%r13), %rdx
movq %rdx, %rax
subq %rbp, %rax
shlq $0xc, %rax
addq %r9, %rax
andq %rdi, %rax
shlq $0xc, %rdx
addq %r9, %rdx
andq %rdi, %rdx
subq %rdx, %rax
je 0x3eb6b
leaq 0x46232(%rip), %rdx     # 0x84d98
lock
xaddq %rax, (%rdx)
subq %rbp, 0xe0(%r13)
orb %r8b, %cl
jne 0x3eb8f
movq %r15, %rax
subq 0x459c7(%rip), %rax     # 0x84548
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, %edi
shll $0x2, %edi
orb %bl, %r8b
movq %r15, %rax
subq 0x4599f(%rip), %rax     # 0x84548
cmpb $0x1, %r8b
jne 0x3ebe0
leaq (%r10,%r10), %rcx
movq %rdi, %rdx
orq %rsi, %rdx
orq %rcx, %rdx
orq $0x1fe0, %rdx           # imm = 0x1FE0
movq %rdx, 0x68(%r14,%rax,8)
leaq (%r15,%rbp), %rax
movq 0x45975(%rip), %rcx     # 0x84548
notq %rcx
addq %rax, %rcx
movq %rdx, 0x68(%r14,%rcx,8)
jmp 0x3ec1c
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 (%r15,%rbp), %rax
movq 0x45942(%rip), %rcx     # 0x84548
notq %rcx
addq %rax, %rcx
movq 0x68(%r14,%rcx,8), %rax
andl $0x8, %eax
orq %rdx, %rax
movq %rax, 0x68(%r14,%rcx,8)
leaq (%r15,%rbp), %r12
leaq 0x45a81(%rip), %rax     # 0x846a8
cmpq (%rax), %r12
movq %r13, 0x8(%rsp)
jae 0x3ed68
movq %r12, %rax
subq 0x45909(%rip), %rax     # 0x84548
movq 0x68(%r14,%rax,8), %r13
movl %r13d, %eax
andl $0x4, %eax
cmpl %edi, %eax
jne 0x3ed63
movl %r13d, %eax
andl $0x1, %eax
jne 0x3ed63
movl %r13d, %eax
andl $0x10, %eax
cmpl %esi, %eax
jne 0x3ed63
movq %rdi, 0x20(%rsp)
movq %rsi, 0x28(%rsp)
movq %r10, 0x18(%rsp)
movl %ebx, 0x14(%rsp)
movq %r13, %rbx
shrq %rbx
andq %r11, %rbx
shrq $0xd, %r13
movq 0x8(%rsp), %rdi
movq %r14, %rsi
movq %r12, %rdx
callq 0x3e496
movl 0x14(%rsp), %eax
movl %eax, %edi
testb %al, %al
je 0x3ecfb
movq 0x458a3(%rip), %rax     # 0x84550
addq %r14, %rax
leaq (%r12,%r12,2), %rcx
shlq $0x5, %rcx
addq %rax, %rcx
xorl %eax, %eax
subq 0x45884(%rip), %rax     # 0x84548
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 (%rax), %rcx
movq 0x8(%rax), %rdx
movq %rdx, 0x8(%rcx)
movq %rax, (%rax)
movq %rax, 0x8(%rax)
movq 0x8(%rsp), %rax
subq %r13, 0xe8(%rax)
movq 0x18(%rsp), %r10
addq %rbx, %r10
addq %r13, %rbp
movq %r15, %rax
subq 0x45838(%rip), %rax     # 0x84548
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 0x45818(%rip), %rax     # 0x84548
notq %rax
addq %r15, %rax
addq %rbp, %rax
andq 0x68(%r14,%rax,8), %rdx
orq %rcx, %rdx
movq %rdx, 0x68(%r14,%rax,8)
movq 0x8(%rsp), %r13
movl %edi, %ebx
movabsq $0x7ffffffffffff000, %r11 # imm = 0x7FFFFFFFFFFFF000
movq 0x28(%rsp), %rsi
movq 0x20(%rsp), %rdi
jmp 0x3ed68
movq 0x8(%rsp), %r13
movq %r10, 0x18(%rsp)
movq 0x457d4(%rip), %rax     # 0x84548
cmpq %rax, %r15
jbe 0x3ee91
notq %rax
addq %r15, %rax
movq 0x68(%r14,%rax,8), %r13
movl %r13d, %eax
andl $0x4, %eax
cmpl %edi, %eax
jne 0x3ee96
movl %r13d, %eax
andl $0x1, %eax
jne 0x3ee96
movl %r13d, %eax
andl $0x10, %eax
cmpl %esi, %eax
jne 0x3ee96
movl %ebx, 0x14(%rsp)
movq %r13, %rbx
shrq %rbx
andq %r11, %rbx
shrq $0xd, %r13
movq %r15, %r12
subq %r13, %r12
movq 0x8(%rsp), %rdi
movq %r14, %rsi
movq %r12, %rdx
callq 0x3e496
movl 0x14(%rsp), %eax
movl %eax, %edi
testb %al, %al
je 0x3ee36
movq 0x45768(%rip), %rax     # 0x84550
addq %r14, %rax
leaq (%r12,%r12,2), %rcx
shlq $0x5, %rcx
addq %rax, %rcx
xorl %eax, %eax
subq 0x45749(%rip), %rax     # 0x84548
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 (%rax), %rcx
movq 0x8(%rax), %rdx
movq %rdx, 0x8(%rcx)
movq %rax, (%rax)
movq %rax, 0x8(%rax)
movq 0x8(%rsp), %rax
subq %r13, 0xe8(%rax)
movq 0x18(%rsp), %rcx
addq %rbx, %rcx
movq %r12, %rax
subq 0x45700(%rip), %rax     # 0x84548
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)
addq %rbp, %r15
movq 0x456d9(%rip), %rax     # 0x84548
notq %rax
addq %r15, %rax
andq 0x68(%r14,%rax,8), %rdx
addq %rbp, %r13
orq %rcx, %rdx
movq %rdx, 0x68(%r14,%rax,8)
movq %r13, %rbp
movq 0x8(%rsp), %r13
movl %edi, %ebx
jmp 0x3ee9e
movq %r15, %r12
jmp 0x3ee9e
movq %r15, %r12
movq 0x8(%rsp), %r13
movq %r13, %rdi
movq %r14, %rsi
movq %r12, %rdx
callq 0x3dd1e
testb %bl, %bl
je 0x3ef12
movq 0x45699(%rip), %rax     # 0x84550
addq %r14, %rax
leaq (%r12,%r12,2), %rcx
shlq $0x5, %rcx
addq %rax, %rcx
xorl %eax, %eax
subq 0x4567a(%rip), %rax     # 0x84548
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)
addq %rbp, 0xe8(%r13)
movq 0x18(%rsp), %rax
cmpq 0x4563a(%rip), %rax     # 0x84558
jne 0x3f03e
movq 0x4561d(%rip), %rdx     # 0x84548
movq %r13, %rdi
movq %r14, %rsi
callq 0x3e496
movq 0xc8(%r13), %r15
testq %r15, %r15
je 0x3f037
movl %ebx, %ebp
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 0x3efb3
movq 0x455d0(%rip), %rax     # 0x84548
leaq 0x45729(%rip), %rcx     # 0x846a8
subq (%rcx), %rax
movq 0x455c7(%rip), %rcx     # 0x84550
addq %r15, %rcx
addq $0x10, %rcx
movq (%rcx), %rdx
movq 0x8(%rcx), %rsi
movq %rdx, (%rsi)
movq (%rcx), %rdx
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 0x4064c
movq 0x68(%r15), %rbx
testb $0x4, %bl
je 0x3eff9
leaq 0x30(%rsp), %r14
movq %r14, %rdi
movq %r13, %rsi
callq 0x403f3
leaq 0x456ba(%rip), %rax     # 0x84698
movq (%rax), %rsi
movq 0x45560(%rip), %rcx     # 0x84548
shlq $0xc, %rcx
movl (%r13), %r8d
movq %r15, %rdi
xorl %edx, %edx
callq *0x18(%r14)
xorl %r8d, %r8d
testb $0x4, %bl
sete %r8b
leaq 0x4568e(%rip), %rbx     # 0x84698
movq (%rbx), %rcx
leaq 0x30(%rsp), %rsi
movq %r13, %rdi
movq %r15, %rdx
callq 0x40c92
movq (%rbx), %rax
subq %rax, 0x30(%r13)
movq 0x4551d(%rip), %rax     # 0x84548
shlq $0xc, %rax
subq %rax, 0x50(%r13)
movl %ebp, %ebx
jmp 0x3f03e
movq %r14, 0xc8(%r13)
testb %bl, %bl
je 0x3f04a
movq %r13, %rdi
callq 0x3a359
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq