// File: /workspace/github_c_makefile_star2_O0/gplessis[P]dotdeb-redis/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[0]);
		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(arena, tcache->prof_accumbytes))
				prof_idump();
			tcache->prof_accumbytes = 0;
		}

		malloc_mutex_lock(&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[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(chunk, pageind);
				arena_dalloc_bin_junked_locked(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[ndeferred] = ptr;
				ndeferred++;
			}
		}
		malloc_mutex_unlock(&bin->lock);
	}
	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(&bin->lock);
		bin->stats.nflushes++;
		bin->stats.nrequests += tbin->tstats.nrequests;
		tbin->tstats.nrequests = 0;
		malloc_mutex_unlock(&bin->lock);
	}

	memmove(tbin->avail, &tbin->avail[tbin->ncached - rem],
	    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 $0x80, %rsp
movq %rdi, -0x18(%rbp)
movq %rsi, -0x20(%rbp)
movq %rdx, -0x28(%rbp)
movl %ecx, -0x2c(%rbp)
movl %r8d, -0x30(%rbp)
movb $0x0, -0x4d(%rbp)
jmp 0x79534
jmp 0x79536
jmp 0x79538
movq -0x18(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x79ae0
movq %rax, -0x38(%rbp)
jmp 0x7954b
movq -0x28(%rbp), %rax
movl 0x10(%rax), %eax
subl -0x30(%rbp), %eax
movl %eax, -0x48(%rbp)
cmpl $0x0, -0x48(%rbp)
jbe 0x796f1
movq -0x28(%rbp), %rax
movq 0x18(%rax), %rax
movq (%rax), %rax
leaq 0x291bc(%rip), %rcx     # 0xa2730
movq (%rcx), %rcx
xorq $-0x1, %rcx
andq %rcx, %rax
movq %rax, -0x58(%rbp)
movq -0x58(%rbp), %rdi
callq 0x79b60
movq %rax, -0x60(%rbp)
movq -0x60(%rbp), %rax
addq $0x450, %rax            # imm = 0x450
movl -0x2c(%rbp), %ecx
imulq $0xe0, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x68(%rbp)
movq -0x68(%rbp), %rdi
callq 0x79b80
movq -0x60(%rbp), %rax
cmpq -0x38(%rbp), %rax
jne 0x795ff
jmp 0x795bf
jmp 0x795c1
movb $0x1, -0x4d(%rbp)
movq -0x68(%rbp), %rax
movq 0xc0(%rax), %rcx
addq $0x1, %rcx
movq %rcx, 0xc0(%rax)
movq -0x28(%rbp), %rax
movq (%rax), %rcx
movq -0x68(%rbp), %rax
addq 0xa8(%rax), %rcx
movq %rcx, 0xa8(%rax)
movq -0x28(%rbp), %rax
movq $0x0, (%rax)
movl $0x0, -0x4c(%rbp)
movl $0x0, -0x44(%rbp)
movl -0x44(%rbp), %eax
cmpl -0x48(%rbp), %eax
jae 0x796dd
movq -0x28(%rbp), %rax
movq 0x18(%rax), %rax
movl -0x44(%rbp), %ecx
movq (%rax,%rcx,8), %rax
movq %rax, -0x40(%rbp)
jmp 0x7962e
movq -0x40(%rbp), %rax
leaq 0x290f7(%rip), %rcx     # 0xa2730
movq (%rcx), %rcx
xorq $-0x1, %rcx
andq %rcx, %rax
movq %rax, -0x58(%rbp)
movq -0x58(%rbp), %rdi
callq 0x79b60
cmpq -0x60(%rbp), %rax
jne 0x796b1
movq -0x40(%rbp), %rax
movq -0x58(%rbp), %rcx
subq %rcx, %rax
shrq $0xc, %rax
movq %rax, -0x70(%rbp)
movq -0x58(%rbp), %rcx
movq -0x70(%rbp), %rax
movq %rcx, -0x8(%rbp)
movq %rax, -0x10(%rbp)
movq -0x8(%rbp), %rax
addq $0x68, %rax
movq -0x10(%rbp), %rcx
leaq 0x28f4c(%rip), %rdx     # 0xa25d8
subq (%rdx), %rcx
shlq $0x3, %rcx
addq %rcx, %rax
movq %rax, -0x78(%rbp)
movq -0x60(%rbp), %rdi
movq -0x58(%rbp), %rsi
movq -0x40(%rbp), %rdx
movq -0x78(%rbp), %rcx
callq 0x3fb40
jmp 0x796cd
movq -0x40(%rbp), %rdx
movq -0x28(%rbp), %rax
movq 0x18(%rax), %rax
movl -0x4c(%rbp), %ecx
movq %rdx, (%rax,%rcx,8)
movl -0x4c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4c(%rbp)
jmp 0x796cf
movl -0x44(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x44(%rbp)
jmp 0x7960d
movq -0x68(%rbp), %rdi
callq 0x79ba0
movl -0x4c(%rbp), %eax
movl %eax, -0x48(%rbp)
jmp 0x79558
testb $0x1, -0x4d(%rbp)
jne 0x7975e
movq -0x38(%rbp), %rax
addq $0x450, %rax            # imm = 0x450
movl -0x2c(%rbp), %ecx
imulq $0xe0, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x80(%rbp)
movq -0x80(%rbp), %rdi
callq 0x79b80
movq -0x80(%rbp), %rax
movq 0xc0(%rax), %rcx
addq $0x1, %rcx
movq %rcx, 0xc0(%rax)
movq -0x28(%rbp), %rax
movq (%rax), %rcx
movq -0x80(%rbp), %rax
addq 0xa8(%rax), %rcx
movq %rcx, 0xa8(%rax)
movq -0x28(%rbp), %rax
movq $0x0, (%rax)
movq -0x80(%rbp), %rdi
callq 0x79ba0
movq -0x28(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x28(%rbp), %rax
movq 0x18(%rax), %rsi
movq -0x28(%rbp), %rax
movl 0x10(%rax), %eax
subl -0x30(%rbp), %eax
movl %eax, %eax
shlq $0x3, %rax
addq %rax, %rsi
movl -0x30(%rbp), %eax
movl %eax, %edx
shlq $0x3, %rdx
callq 0x10500
movl -0x30(%rbp), %ecx
movq -0x28(%rbp), %rax
movl %ecx, 0x10(%rax)
movq -0x28(%rbp), %rax
movl 0x10(%rax), %eax
movq -0x28(%rbp), %rcx
cmpl 0x8(%rcx), %eax
jge 0x797b7
movq -0x28(%rbp), %rax
movl 0x10(%rax), %ecx
movq -0x28(%rbp), %rax
movl %ecx, 0x8(%rax)
addq $0x80, %rsp
popq %rbp
retq