// File: /workspace/github_c_makefile_star2_O3/gplessis[P]dotdeb-redis/deps/jemalloc/src/tcache.c
// Function: je_tcache_bin_flush_large
void
tcache_bin_flush_large(tsd_t *tsd, tcache_bin_t *tbin, szind_t binind,
    unsigned rem, tcache_t *tcache)
{
	arena_t *arena;
	void *ptr;
	unsigned i, nflush, ndeferred;
	bool merged_stats = false;

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

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

		if (config_prof)
			idump = false;
		malloc_mutex_lock(&locked_arena->lock);
		if ((config_prof || config_stats) && locked_arena == arena) {
			if (config_prof) {
				idump = arena_prof_accum_locked(arena,
				    tcache->prof_accumbytes);
				tcache->prof_accumbytes = 0;
			}
			if (config_stats) {
				merged_stats = true;
				arena->stats.nrequests_large +=
				    tbin->tstats.nrequests;
				arena->stats.lstats[binind - NBINS].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) ==
			    locked_arena) {
				arena_dalloc_large_junked_locked(locked_arena,
				    chunk, ptr);
			} else {
				/*
				 * This object was allocated via a different
				 * arena 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(&locked_arena->lock);
		if (config_prof && idump)
			prof_idump();
	}
	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.
		 */
		malloc_mutex_lock(&arena->lock);
		arena->stats.nrequests_large += tbin->tstats.nrequests;
		arena->stats.lstats[binind - NBINS].nrequests +=
		    tbin->tstats.nrequests;
		tbin->tstats.nrequests = 0;
		malloc_mutex_unlock(&arena->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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movl %ecx, %ebp
movl %edx, %r12d
movq %rsi, %r14
movq 0x28(%rdi), %rax
movq %rax, 0x10(%rsp)
testq %rax, %rax
je 0x3cbc2
movl 0x10(%r14), %ebx
subl %ebp, %ebx
je 0x3cb51
movl %ebp, 0x1c(%rsp)
addl $-0x27, %r12d
movl $0x0, 0xc(%rsp)
leaq 0x1ec1e(%rip), %r15     # 0x5b6b0
movq %r12, 0x20(%rsp)
shlq $0x5, %r12
movq %r12, 0x28(%rsp)
movq 0x18(%r14), %rax
movq (%r15), %rcx
notq %rcx
andq (%rax), %rcx
movq (%rcx), %rbp
leaq 0x8(%rbp), %rdi
movq %rdi, 0x30(%rsp)
callq 0x106d0
cmpq 0x10(%rsp), %rbp
jne 0x3caef
movq (%r14), %rax
movq 0x10(%rsp), %rcx
addq %rax, 0x78(%rcx)
movq 0x98(%rcx), %rcx
movq 0x28(%rsp), %rdx
addq %rax, 0x10(%rcx,%rdx)
movq $0x0, (%r14)
movb $0x1, %al
movl %eax, 0xc(%rsp)
movl %ebx, %r12d
movq (%r15), %rax
xorl %r13d, %r13d
xorl %ebx, %ebx
movq 0x18(%r14), %rcx
movq (%rcx,%r13,8), %rdx
movq %rax, %rsi
notq %rsi
andq %rdx, %rsi
cmpq %rbp, (%rsi)
je 0x3cb1a
movl %ebx, %esi
movq %rdx, (%rcx,%rsi,8)
incl %ebx
jmp 0x3cb25
movq %rbp, %rdi
callq 0x298ce
movq (%r15), %rax
incq %r13
cmpq %r13, %r12
jne 0x3cafa
movq 0x30(%rsp), %rdi
callq 0x10440
testl %ebx, %ebx
jne 0x3caa0
testb $0x1, 0xc(%rsp)
movl 0x1c(%rsp), %ebp
movq 0x20(%rsp), %r12
je 0x3cb55
jmp 0x3cb8c
addl $-0x27, %r12d
movq 0x10(%rsp), %rbx
leaq 0x8(%rbx), %r13
movq %r13, %rdi
callq 0x106d0
movq (%r14), %rax
addq %rax, 0x78(%rbx)
movq 0x98(%rbx), %rcx
shlq $0x5, %r12
addq %rax, 0x10(%rcx,%r12)
movq $0x0, (%r14)
movq %r13, %rdi
callq 0x10440
movq 0x18(%r14), %rdi
movl 0x10(%r14), %eax
subl %ebp, %eax
leaq (%rdi,%rax,8), %rsi
movl %ebp, %edx
shlq $0x3, %rdx
callq 0x10540
movl %ebp, 0x10(%r14)
cmpl %ebp, 0x8(%r14)
jle 0x3cbb3
movl %ebp, 0x8(%r14)
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x22135
movq %rax, 0x10(%rsp)
jmp 0x3ca6f