// File: /workspace/github_c_makefile_star2_O0/zhou-yuxin[P]redis-aof-no-cow/deps/jemalloc/src/arena.c
// Function: arena_stash_dirty
static size_t
arena_stash_dirty(tsdn_t *tsdn, arena_t *arena, chunk_hooks_t *chunk_hooks,
    size_t ndirty_limit, 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 runs/chunks according to ndirty_limit. */
	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;
			size_t sn;
			bool zero, commit;
			UNUSED void *chunk;

			npages = extent_node_size_get(chunkselm) >> LG_PAGE;
			if (opt_purge == purge_mode_decay && arena->ndirty -
			    (nstashed + npages) < ndirty_limit)
				break;

			chunkselm_next = qr_next(chunkselm, cc_link);
			/*
			 * Allocate.  chunkselm remains valid due to the
			 * dalloc_node=false argument to chunk_alloc_cache().
			 */
			zero = false;
			commit = false;
			chunk = chunk_alloc_cache(tsdn, arena, chunk_hooks,
			    extent_node_addr_get(chunkselm),
			    extent_node_size_get(chunkselm), chunksize, &sn,
			    &zero, &commit, 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);
			assert(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;
			if (opt_purge == purge_mode_decay && arena->ndirty -
			    (nstashed + npages) < ndirty_limit)
				break;

			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(tsdn, 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 (opt_purge == purge_mode_ratio && arena->ndirty - nstashed <=
		    ndirty_limit)
			break;
	}

	return (nstashed);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
subq $0x188, %rsp            # imm = 0x188
movq %rdi, -0xa8(%rbp)
movq %rsi, -0xb0(%rbp)
movq %rdx, -0xb8(%rbp)
movq %rcx, -0xc0(%rbp)
movq %r8, -0xc8(%rbp)
movq %r9, -0xd0(%rbp)
movq $0x0, -0xf0(%rbp)
movq -0xb0(%rbp), %rax
movq 0x138(%rax), %rax
movq %rax, -0xd8(%rbp)
movq -0xb0(%rbp), %rax
movq 0x188(%rax), %rax
movq %rax, -0xe8(%rbp)
movq -0xd8(%rbp), %rax
movq -0xb0(%rbp), %rcx
addq $0x138, %rcx            # imm = 0x138
cmpq %rcx, %rax
je 0x4546d
movq -0xd8(%rbp), %rax
movq (%rax), %rax
movq %rax, -0xe0(%rbp)
movq -0xd8(%rbp), %rax
movq -0xe8(%rbp), %rcx
addq $0x30, %rcx
cmpq %rcx, %rax
jne 0x451b2
movq -0xe8(%rbp), %rdi
callq 0x44740
shrq $0xc, %rax
movq %rax, -0xf8(%rbp)
cmpl $0x1, 0x5e52d(%rip)     # 0xa35b0
jne 0x450b2
movq -0xb0(%rbp), %rax
movq 0x130(%rax), %rax
movq -0xf0(%rbp), %rcx
addq -0xf8(%rbp), %rcx
subq %rcx, %rax
cmpq -0xc0(%rbp), %rax
jae 0x450b2
jmp 0x4546d
movq -0xe8(%rbp), %rax
movq 0x40(%rax), %rax
movq %rax, -0x100(%rbp)
movb $0x0, -0x109(%rbp)
movb $0x0, -0x10a(%rbp)
movq -0xa8(%rbp), %rax
movq %rax, -0x168(%rbp)
movq -0xb0(%rbp), %rax
movq %rax, -0x160(%rbp)
movq -0xb8(%rbp), %rax
movq %rax, -0x158(%rbp)
movq -0xe8(%rbp), %rdi
callq 0x3c370
movq %rax, -0x150(%rbp)
movq -0xe8(%rbp), %rdi
callq 0x44740
movq -0x168(%rbp), %rdi
movq -0x160(%rbp), %rsi
movq -0x158(%rbp), %rdx
movq -0x150(%rbp), %rcx
movq %rax, %r8
leaq 0x5ef67(%rip), %rax     # 0xa40a8
movq (%rax), %r9
leaq -0x108(%rbp), %r11
leaq -0x109(%rbp), %r10
leaq -0x10a(%rbp), %rax
xorl %ebx, %ebx
movq %r11, (%rsp)
movq %r10, 0x8(%rsp)
movq %rax, 0x10(%rsp)
movl $0x0, 0x18(%rsp)
callq 0x518e0
movq %rax, -0x118(%rbp)
jmp 0x4517f
jmp 0x45181
jmp 0x45183
movq -0xe8(%rbp), %rdi
movq -0xc8(%rbp), %rsi
movq -0xd0(%rbp), %rdx
callq 0x3a320
jmp 0x4519f
movq -0x100(%rbp), %rax
movq %rax, -0xe8(%rbp)
jmp 0x4541a
movq -0xd8(%rbp), %rax
leaq 0x5eef0(%rip), %rcx     # 0xa40b0
movq (%rcx), %rcx
xorq $-0x1, %rcx
andq %rcx, %rax
movq %rax, -0x120(%rbp)
movq -0xd8(%rbp), %rax
movq %rax, -0x98(%rbp)
movq -0x98(%rbp), %rax
subq $0x18, %rax
movq %rax, -0xa0(%rbp)
movq -0xa0(%rbp), %rax
movq %rax, -0x128(%rbp)
movq -0x128(%rbp), %rax
movq %rax, -0x80(%rbp)
movq -0x80(%rbp), %rax
leaq 0x5ee9b(%rip), %rcx     # 0xa40b0
movq (%rcx), %rcx
xorq $-0x1, %rcx
andq %rcx, %rax
movq %rax, -0x88(%rbp)
movq -0x80(%rbp), %rax
movq -0x88(%rbp), %rcx
addq 0x5ed70(%rip), %rcx     # 0xa3fa8
subq %rcx, %rax
movl $0x60, %ecx
xorl %edx, %edx
divq %rcx
addq 0x5ed54(%rip), %rax     # 0xa3fa0
movq %rax, -0x90(%rbp)
movq -0x90(%rbp), %rax
movq %rax, -0x130(%rbp)
movq -0x128(%rbp), %rax
addq $0x18, %rax
movq %rax, -0x138(%rbp)
movq -0x120(%rbp), %rcx
movq -0x130(%rbp), %rax
movq %rcx, -0x68(%rbp)
movq %rax, -0x70(%rbp)
movq -0x68(%rbp), %rcx
movq -0x70(%rbp), %rax
movq %rcx, -0x58(%rbp)
movq %rax, -0x60(%rbp)
movq -0x58(%rbp), %rcx
movq -0x60(%rbp), %rax
movq %rcx, -0x30(%rbp)
movq %rax, -0x38(%rbp)
movq -0x30(%rbp), %rcx
movq -0x38(%rbp), %rax
movq %rcx, -0x20(%rbp)
movq %rax, -0x28(%rbp)
movq -0x20(%rbp), %rcx
movq -0x28(%rbp), %rax
movq %rcx, -0x10(%rbp)
movq %rax, -0x18(%rbp)
movq -0x10(%rbp), %rax
addq $0x78, %rax
movq -0x18(%rbp), %rcx
subq 0x5ecc4(%rip), %rcx     # 0xa3fa0
shlq $0x3, %rcx
addq %rcx, %rax
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x78(%rbp)
movq -0x78(%rbp), %rax
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rax
andq $-0x2000, %rax          # imm = 0xE000
shrq %rax
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rax
movq %rax, -0x140(%rbp)
movq -0x140(%rbp), %rax
shrq $0xc, %rax
movq %rax, -0xf8(%rbp)
cmpl $0x1, 0x5e281(%rip)     # 0xa35b0
jne 0x4535e
movq -0xb0(%rbp), %rax
movq 0x130(%rax), %rax
movq -0xf0(%rbp), %rcx
addq -0xf8(%rbp), %rcx
subq %rcx, %rax
cmpq -0xc0(%rbp), %rax
jae 0x4535e
jmp 0x4546d
jmp 0x45360
jmp 0x45362
jmp 0x45364
jmp 0x45366
movq -0x120(%rbp), %rax
movq -0xb0(%rbp), %rcx
cmpq 0x110(%rcx), %rax
jne 0x45390
movq -0xa8(%rbp), %rdi
movq -0xb0(%rbp), %rsi
callq 0x45ee0
movq -0xb0(%rbp), %rdi
movq -0x138(%rbp), %rsi
movq -0x140(%rbp), %rdx
xorl %ecx, %ecx
callq 0x46000
jmp 0x453ae
jmp 0x453b0
jmp 0x453b2
jmp 0x453b4
movq -0xd8(%rbp), %rcx
movq -0xc8(%rbp), %rax
movq 0x8(%rax), %rax
movq %rcx, (%rax)
movq -0xc8(%rbp), %rcx
movq -0xd8(%rbp), %rax
movq 0x8(%rax), %rax
movq %rcx, (%rax)
movq -0xc8(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x148(%rbp)
movq -0xd8(%rbp), %rax
movq 0x8(%rax), %rcx
movq -0xc8(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x148(%rbp), %rcx
movq -0xd8(%rbp), %rax
movq %rcx, 0x8(%rax)
jmp 0x4541a
movq -0xf8(%rbp), %rax
addq -0xf0(%rbp), %rax
movq %rax, -0xf0(%rbp)
cmpl $0x0, 0x5e17a(%rip)     # 0xa35b0
jne 0x45458
movq -0xb0(%rbp), %rax
movq 0x130(%rax), %rax
subq -0xf0(%rbp), %rax
cmpq -0xc0(%rbp), %rax
ja 0x45458
jmp 0x4546d
jmp 0x4545a
movq -0xe0(%rbp), %rax
movq %rax, -0xd8(%rbp)
jmp 0x4501b
movq -0xf0(%rbp), %rax
addq $0x188, %rsp            # imm = 0x188
popq %rbx
popq %rbp
retq
nop