// File: /workspace/github_c_makefile_star2_O0/gplessis[P]dotdeb-redis/deps/jemalloc/src/arena.c
// Function: arena_stash_dirty
static size_t
arena_stash_dirty(arena_t *arena, chunk_hooks_t *chunk_hooks, bool all,
    size_t npurge, arena_runs_dirty_link_t *purge_runs_sentinel,
    extent_node_t *purge_chunks_sentinel)
{
	arena_runs_dirty_link_t *rdelm, *rdelm_next;
	extent_node_t *chunkselm;
	size_t nstashed = 0;

	/* Stash at least npurge pages. */
	for (rdelm = qr_next(&arena->runs_dirty, rd_link),
	    chunkselm = qr_next(&arena->chunks_cache, cc_link);
	    rdelm != &arena->runs_dirty; rdelm = rdelm_next) {
		size_t npages;
		rdelm_next = qr_next(rdelm, rd_link);

		if (rdelm == &chunkselm->rd) {
			extent_node_t *chunkselm_next;
			bool zero;
			UNUSED void *chunk;

			chunkselm_next = qr_next(chunkselm, cc_link);
			/*
			 * Allocate.  chunkselm remains valid due to the
			 * dalloc_node=false argument to chunk_alloc_cache().
			 */
			zero = false;
			chunk = chunk_alloc_cache(arena, chunk_hooks,
			    extent_node_addr_get(chunkselm),
			    extent_node_size_get(chunkselm), chunksize, &zero,
			    false);
			assert(chunk == extent_node_addr_get(chunkselm));
			assert(zero == extent_node_zeroed_get(chunkselm));
			extent_node_dirty_insert(chunkselm, purge_runs_sentinel,
			    purge_chunks_sentinel);
			npages = extent_node_size_get(chunkselm) >> LG_PAGE;
			chunkselm = chunkselm_next;
		} else {
			arena_chunk_t *chunk =
			    (arena_chunk_t *)CHUNK_ADDR2BASE(rdelm);
			arena_chunk_map_misc_t *miscelm =
			    arena_rd_to_miscelm(rdelm);
			size_t pageind = arena_miscelm_to_pageind(miscelm);
			arena_run_t *run = &miscelm->run;
			size_t run_size =
			    arena_mapbits_unallocated_size_get(chunk, pageind);

			npages = run_size >> LG_PAGE;

			assert(pageind + npages <= chunk_npages);
			assert(arena_mapbits_dirty_get(chunk, pageind) ==
			    arena_mapbits_dirty_get(chunk, pageind+npages-1));

			/*
			 * If purging the spare chunk's run, make it available
			 * prior to allocation.
			 */
			if (chunk == arena->spare)
				arena_chunk_alloc(arena);

			/* Temporarily allocate the free dirty run. */
			arena_run_split_large(arena, run, run_size, false);
			/* Stash. */
			if (false)
				qr_new(rdelm, rd_link); /* Redundant. */
			else {
				assert(qr_next(rdelm, rd_link) == rdelm);
				assert(qr_prev(rdelm, rd_link) == rdelm);
			}
			qr_meld(purge_runs_sentinel, rdelm, rd_link);
		}

		nstashed += npages;
		if (!all && nstashed >= npurge)
			break;
	}

	return (nstashed);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x150, %rsp            # imm = 0x150
movb %dl, %al
movq %rdi, -0x90(%rbp)
movq %rsi, -0x98(%rbp)
andb $0x1, %al
movb %al, -0x99(%rbp)
movq %rcx, -0xa8(%rbp)
movq %r8, -0xb0(%rbp)
movq %r9, -0xb8(%rbp)
movq $0x0, -0xd8(%rbp)
movq -0x90(%rbp), %rax
movq 0x158(%rax), %rax
movq %rax, -0xc0(%rbp)
movq -0x90(%rbp), %rax
movq 0x1a0(%rax), %rax
movq %rax, -0xd0(%rbp)
movq -0xc0(%rbp), %rax
movq -0x90(%rbp), %rcx
addq $0x158, %rcx            # imm = 0x158
cmpq %rcx, %rax
je 0x451cf
movq -0xc0(%rbp), %rax
movq (%rax), %rax
movq %rax, -0xc8(%rbp)
movq -0xc0(%rbp), %rax
movq -0xd0(%rbp), %rcx
addq $0x28, %rcx
cmpq %rcx, %rax
jne 0x44f83
movq -0xd0(%rbp), %rax
movq 0x38(%rax), %rax
movq %rax, -0xe8(%rbp)
movb $0x0, -0xe9(%rbp)
movq -0x90(%rbp), %rax
movq %rax, -0x140(%rbp)
movq -0x98(%rbp), %rax
movq %rax, -0x138(%rbp)
movq -0xd0(%rbp), %rdi
callq 0x45b70
movq %rax, -0x130(%rbp)
movq -0xd0(%rbp), %rdi
callq 0x44ab0
movq -0x140(%rbp), %rdi
movq -0x138(%rbp), %rsi
movq -0x130(%rbp), %rdx
movq %rax, %rcx
leaq 0x5d80e(%rip), %rax     # 0xa2728
movq (%rax), %r8
leaq -0xe9(%rbp), %r9
xorl %eax, %eax
movl $0x0, (%rsp)
callq 0x50480
movq %rax, -0xf8(%rbp)
jmp 0x44f3b
jmp 0x44f3d
jmp 0x44f3f
movq -0xd0(%rbp), %rdi
movq -0xb0(%rbp), %rsi
movq -0xb8(%rbp), %rdx
callq 0x3c070
movq -0xd0(%rbp), %rdi
callq 0x44ab0
shrq $0xc, %rax
movq %rax, -0xe0(%rbp)
movq -0xe8(%rbp), %rax
movq %rax, -0xd0(%rbp)
jmp 0x4518a
movq -0xc0(%rbp), %rax
leaq 0x5d79f(%rip), %rcx     # 0xa2730
movq (%rcx), %rcx
xorq $-0x1, %rcx
andq %rcx, %rax
movq %rax, -0x100(%rbp)
movq -0xc0(%rbp), %rax
movq %rax, -0x80(%rbp)
movq -0x80(%rbp), %rax
subq $0x10, %rax
movq %rax, -0x88(%rbp)
movq -0x88(%rbp), %rax
movq %rax, -0x108(%rbp)
movq -0x108(%rbp), %rax
movq %rax, -0x68(%rbp)
movq -0x68(%rbp), %rax
leaq 0x5d750(%rip), %rcx     # 0xa2730
movq (%rcx), %rcx
xorq $-0x1, %rcx
andq %rcx, %rax
movq %rax, -0x70(%rbp)
movq -0x68(%rbp), %rax
movq -0x70(%rbp), %rcx
addq 0x5d5e3(%rip), %rcx     # 0xa25e0
subq %rcx, %rax
movl $0x60, %ecx
xorl %edx, %edx
divq %rcx
addq 0x5d5c7(%rip), %rax     # 0xa25d8
movq %rax, -0x78(%rbp)
movq -0x78(%rbp), %rax
movq %rax, -0x110(%rbp)
movq -0x108(%rbp), %rax
addq $0x10, %rax
movq %rax, -0x118(%rbp)
movq -0x100(%rbp), %rcx
movq -0x110(%rbp), %rax
movq %rcx, -0x50(%rbp)
movq %rax, -0x58(%rbp)
movq -0x50(%rbp), %rcx
movq -0x58(%rbp), %rax
movq %rcx, -0x40(%rbp)
movq %rax, -0x48(%rbp)
movq -0x40(%rbp), %rcx
movq -0x48(%rbp), %rax
movq %rcx, -0x18(%rbp)
movq %rax, -0x20(%rbp)
movq -0x18(%rbp), %rcx
movq -0x20(%rbp), %rax
movq %rcx, -0x8(%rbp)
movq %rax, -0x10(%rbp)
movq -0x8(%rbp), %rax
addq $0x68, %rax
movq -0x10(%rbp), %rcx
subq 0x5d54d(%rip), %rcx     # 0xa25d8
shlq $0x3, %rcx
addq %rcx, %rax
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x60(%rbp)
movq -0x60(%rbp), %rax
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
andq $-0x2000, %rax          # imm = 0xE000
shrq %rax
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rax
movq %rax, -0x120(%rbp)
movq -0x120(%rbp), %rax
shrq $0xc, %rax
movq %rax, -0xe0(%rbp)
jmp 0x450d9
jmp 0x450db
jmp 0x450dd
movq -0x100(%rbp), %rax
movq -0x90(%rbp), %rcx
cmpq 0xc8(%rcx), %rax
jne 0x45100
movq -0x90(%rbp), %rdi
callq 0x45b90
movq -0x90(%rbp), %rdi
movq -0x118(%rbp), %rsi
movq -0x120(%rbp), %rdx
xorl %ecx, %ecx
callq 0x45c10
jmp 0x4511e
jmp 0x45120
jmp 0x45122
jmp 0x45124
movq -0xc0(%rbp), %rcx
movq -0xb0(%rbp), %rax
movq 0x8(%rax), %rax
movq %rcx, (%rax)
movq -0xb0(%rbp), %rcx
movq -0xc0(%rbp), %rax
movq 0x8(%rax), %rax
movq %rcx, (%rax)
movq -0xb0(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x128(%rbp)
movq -0xc0(%rbp), %rax
movq 0x8(%rax), %rcx
movq -0xb0(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x128(%rbp), %rcx
movq -0xc0(%rbp), %rax
movq %rcx, 0x8(%rax)
jmp 0x4518a
movq -0xe0(%rbp), %rax
addq -0xd8(%rbp), %rax
movq %rax, -0xd8(%rbp)
testb $0x1, -0x99(%rbp)
jne 0x451ba
movq -0xd8(%rbp), %rax
cmpq -0xa8(%rbp), %rax
jb 0x451ba
jmp 0x451cf
jmp 0x451bc
movq -0xc8(%rbp), %rax
movq %rax, -0xc0(%rbp)
jmp 0x44e5d
movq -0xd8(%rbp), %rax
addq $0x150, %rsp            # imm = 0x150
popq %rbp
retq
nop