// File: /workspace/github_c_makefile_star2_O0/zhou-yuxin[P]redis-aof-no-cow/deps/jemalloc/src/tcache.c
// Function: je_tcache_bin_flush_small
void
tcache_bin_flush_small(tsd_t *tsd, tcache_t *tcache, tcache_bin_t *tbin,
    szind_t binind, unsigned rem)
{
	arena_t *arena;
	void *ptr;
	unsigned i, nflush, ndeferred;
	bool merged_stats = false;

	assert(binind < NBINS);
	assert(rem <= tbin->ncached);

	arena = arena_choose(tsd, NULL);
	assert(arena != NULL);
	for (nflush = tbin->ncached - rem; nflush > 0; nflush = ndeferred) {
		/* Lock the arena bin associated with the first object. */
		arena_chunk_t *chunk = (arena_chunk_t *)CHUNK_ADDR2BASE(
		    *(tbin->avail - 1));
		arena_t *bin_arena = extent_node_arena_get(&chunk->node);
		arena_bin_t *bin = &bin_arena->bins[binind];

		if (config_prof && bin_arena == arena) {
			if (arena_prof_accum(tsd_tsdn(tsd), arena,
			    tcache->prof_accumbytes))
				prof_idump(tsd_tsdn(tsd));
			tcache->prof_accumbytes = 0;
		}

		malloc_mutex_lock(tsd_tsdn(tsd), &bin->lock);
		if (config_stats && bin_arena == arena) {
			assert(!merged_stats);
			merged_stats = true;
			bin->stats.nflushes++;
			bin->stats.nrequests += tbin->tstats.nrequests;
			tbin->tstats.nrequests = 0;
		}
		ndeferred = 0;
		for (i = 0; i < nflush; i++) {
			ptr = *(tbin->avail - 1 - i);
			assert(ptr != NULL);
			chunk = (arena_chunk_t *)CHUNK_ADDR2BASE(ptr);
			if (extent_node_arena_get(&chunk->node) == bin_arena) {
				size_t pageind = ((uintptr_t)ptr -
				    (uintptr_t)chunk) >> LG_PAGE;
				arena_chunk_map_bits_t *bitselm =
				    arena_bitselm_get_mutable(chunk, pageind);
				arena_dalloc_bin_junked_locked(tsd_tsdn(tsd),
				    bin_arena, chunk, ptr, bitselm);
			} else {
				/*
				 * This object was allocated via a different
				 * arena bin than the one that is currently
				 * locked.  Stash the object, so that it can be
				 * handled in a future pass.
				 */
				*(tbin->avail - 1 - ndeferred) = ptr;
				ndeferred++;
			}
		}
		malloc_mutex_unlock(tsd_tsdn(tsd), &bin->lock);
		arena_decay_ticks(tsd_tsdn(tsd), bin_arena, nflush - ndeferred);
	}
	if (config_stats && !merged_stats) {
		/*
		 * The flush loop didn't happen to flush to this thread's
		 * arena, so the stats didn't get merged.  Manually do so now.
		 */
		arena_bin_t *bin = &arena->bins[binind];
		malloc_mutex_lock(tsd_tsdn(tsd), &bin->lock);
		bin->stats.nflushes++;
		bin->stats.nrequests += tbin->tstats.nrequests;
		tbin->tstats.nrequests = 0;
		malloc_mutex_unlock(tsd_tsdn(tsd), &bin->lock);
	}

	memmove(tbin->avail - rem, tbin->avail - tbin->ncached, rem *
	    sizeof(void *));
	tbin->ncached = rem;
	if ((int)tbin->ncached < tbin->low_water)
		tbin->low_water = tbin->ncached;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xf0, %rsp
movq %rdi, -0x80(%rbp)
movq %rsi, -0x88(%rbp)
movq %rdx, -0x90(%rbp)
movl %ecx, -0x94(%rbp)
movl %r8d, -0x98(%rbp)
movb $0x0, -0xb5(%rbp)
jmp 0x7ece3
jmp 0x7ece5
jmp 0x7ece7
movq -0x80(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x7f610
movq %rax, -0xa0(%rbp)
jmp 0x7ecfd
movq -0x90(%rbp), %rax
movl 0x10(%rax), %eax
subl -0x98(%rbp), %eax
movl %eax, -0xb0(%rbp)
cmpl $0x0, -0xb0(%rbp)
jbe 0x7f004
movq -0x90(%rbp), %rax
movq 0x18(%rax), %rax
movq -0x8(%rax), %rax
leaq 0x2537a(%rip), %rcx     # 0xa40b0
movq (%rcx), %rcx
xorq $-0x1, %rcx
andq %rcx, %rax
movq %rax, -0xc0(%rbp)
movq -0xc0(%rbp), %rdi
callq 0x7f640
movq %rax, -0xc8(%rbp)
movq -0xc8(%rbp), %rax
addq $0x980, %rax            # imm = 0x980
movl -0x94(%rbp), %ecx
imulq $0xa8, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0xd0(%rbp)
movq -0x80(%rbp), %rax
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rdi
movq -0xd0(%rbp), %rsi
callq 0x7f660
movq -0xc8(%rbp), %rax
cmpq -0xa0(%rbp), %rax
jne 0x7edf1
jmp 0x7eda8
jmp 0x7edaa
movb $0x1, -0xb5(%rbp)
movq -0xd0(%rbp), %rax
movq 0x88(%rax), %rcx
addq $0x1, %rcx
movq %rcx, 0x88(%rax)
movq -0x90(%rbp), %rax
movq (%rax), %rcx
movq -0xd0(%rbp), %rax
addq 0x70(%rax), %rcx
movq %rcx, 0x70(%rax)
movq -0x90(%rbp), %rax
movq $0x0, (%rax)
movl $0x0, -0xb4(%rbp)
movl $0x0, -0xac(%rbp)
movl -0xac(%rbp), %eax
cmpl -0xb0(%rbp), %eax
jae 0x7ef43
movq -0x90(%rbp), %rax
movq 0x18(%rax), %rax
movl -0xac(%rbp), %ecx
movl %ecx, %edx
xorl %ecx, %ecx
subq %rdx, %rcx
movq -0x8(%rax,%rcx,8), %rax
movq %rax, -0xa8(%rbp)
jmp 0x7ee3d
movq -0xa8(%rbp), %rax
leaq 0x25265(%rip), %rcx     # 0xa40b0
movq (%rcx), %rcx
xorq $-0x1, %rcx
andq %rcx, %rax
movq %rax, -0xc0(%rbp)
movq -0xc0(%rbp), %rdi
callq 0x7f640
cmpq -0xc8(%rbp), %rax
jne 0x7eefa
movq -0xa8(%rbp), %rax
movq -0xc0(%rbp), %rcx
subq %rcx, %rax
shrq $0xc, %rax
movq %rax, -0xd8(%rbp)
movq -0xc0(%rbp), %rcx
movq -0xd8(%rbp), %rax
movq %rcx, -0x40(%rbp)
movq %rax, -0x48(%rbp)
movq -0x40(%rbp), %rax
addq $0x78, %rax
movq -0x48(%rbp), %rcx
leaq 0x250e6(%rip), %rdx     # 0xa3fa0
subq (%rdx), %rcx
shlq $0x3, %rcx
addq %rcx, %rax
movq %rax, -0xe0(%rbp)
movq -0x80(%rbp), %rax
movq %rax, -0x58(%rbp)
movq -0x58(%rbp), %rdi
movq -0xc8(%rbp), %rsi
movq -0xc0(%rbp), %rdx
movq -0xa8(%rbp), %rcx
movq -0xe0(%rbp), %r8
callq 0x3f550
jmp 0x7ef2d
movq -0xa8(%rbp), %rdx
movq -0x90(%rbp), %rax
movq 0x18(%rax), %rax
movl -0xb4(%rbp), %ecx
movl %ecx, %esi
xorl %ecx, %ecx
subq %rsi, %rcx
movq %rdx, -0x8(%rax,%rcx,8)
movl -0xb4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xb4(%rbp)
jmp 0x7ef2f
movl -0xac(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xac(%rbp)
jmp 0x7ee05
movq -0x80(%rbp), %rax
movq %rax, -0x60(%rbp)
movq -0x60(%rbp), %rdi
movq -0xd0(%rbp), %rsi
callq 0x7f6b0
movq -0x80(%rbp), %rax
movq %rax, -0x68(%rbp)
movq -0x68(%rbp), %rdx
movq -0xc8(%rbp), %rcx
movl -0xb0(%rbp), %eax
subl -0xb4(%rbp), %eax
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x10(%rbp)
cmpq $0x0, -0x10(%rbp)
sete %al
testb $0x1, %al
jne 0x7ef9b
jmp 0x7ef9d
jmp 0x7eff1
movq -0x18(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rdi
movq -0x20(%rbp), %rax
movl (%rax), %esi
callq 0x81ed0
movq %rax, -0x38(%rbp)
cmpq $0x0, -0x38(%rbp)
sete %al
testb $0x1, %al
jne 0x7efce
jmp 0x7efd0
jmp 0x7eff1
movq -0x38(%rbp), %rdi
movl -0x24(%rbp), %esi
callq 0x81f30
testb $0x1, %al
jne 0x7efe2
jmp 0x7eff1
movq -0x18(%rbp), %rdi
movq -0x20(%rbp), %rsi
xorl %edx, %edx
callq 0x3b8a0
jmp 0x7eff3
movl -0xb4(%rbp), %eax
movl %eax, -0xb0(%rbp)
jmp 0x7ed13
testb $0x1, -0xb5(%rbp)
jne 0x7f0a5
movq -0xa0(%rbp), %rax
addq $0x980, %rax            # imm = 0x980
movl -0x94(%rbp), %ecx
imulq $0xa8, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0xe8(%rbp)
movq -0x80(%rbp), %rax
movq %rax, -0x70(%rbp)
movq -0x70(%rbp), %rdi
movq -0xe8(%rbp), %rsi
callq 0x7f660
movq -0xe8(%rbp), %rax
movq 0x88(%rax), %rcx
addq $0x1, %rcx
movq %rcx, 0x88(%rax)
movq -0x90(%rbp), %rax
movq (%rax), %rcx
movq -0xe8(%rbp), %rax
addq 0x70(%rax), %rcx
movq %rcx, 0x70(%rax)
movq -0x90(%rbp), %rax
movq $0x0, (%rax)
movq -0x80(%rbp), %rax
movq %rax, -0x78(%rbp)
movq -0x78(%rbp), %rdi
movq -0xe8(%rbp), %rsi
callq 0x7f6b0
movq -0x90(%rbp), %rax
movq 0x18(%rax), %rdi
movl -0x98(%rbp), %eax
movl %eax, %ecx
xorl %eax, %eax
subq %rcx, %rax
shlq $0x3, %rax
addq %rax, %rdi
movq -0x90(%rbp), %rax
movq 0x18(%rax), %rsi
movq -0x90(%rbp), %rax
movl 0x10(%rax), %eax
movl %eax, %ecx
xorl %eax, %eax
subq %rcx, %rax
shlq $0x3, %rax
addq %rax, %rsi
movl -0x98(%rbp), %eax
movl %eax, %edx
shlq $0x3, %rdx
callq 0xb430
movl -0x98(%rbp), %ecx
movq -0x90(%rbp), %rax
movl %ecx, 0x10(%rax)
movq -0x90(%rbp), %rax
movl 0x10(%rax), %eax
movq -0x90(%rbp), %rcx
cmpl 0x8(%rcx), %eax
jge 0x7f132
movq -0x90(%rbp), %rax
movl 0x10(%rax), %ecx
movq -0x90(%rbp), %rax
movl %ecx, 0x8(%rax)
addq $0xf0, %rsp
popq %rbp
retq
nopl (%rax,%rax)