// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movl %ecx, -0x18(%rbp)
movq %r8, -0x20(%rbp)
movb $0x0, -0x3d(%rbp)
jmp 0x797e0
jmp 0x797e2
jmp 0x797e4
movq -0x8(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x79ae0
movq %rax, -0x28(%rbp)
jmp 0x797f7
movq -0x10(%rbp), %rax
movl 0x10(%rax), %eax
subl -0x18(%rbp), %eax
movl %eax, -0x38(%rbp)
cmpl $0x0, -0x38(%rbp)
jbe 0x79947
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rax
movq (%rax), %rax
leaq 0x28f10(%rip), %rcx     # 0xa2730
movq (%rcx), %rcx
xorq $-0x1, %rcx
andq %rcx, %rax
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rdi
callq 0x79b60
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rdi
addq $0x8, %rdi
callq 0x79b80
movq -0x50(%rbp), %rax
cmpq -0x28(%rbp), %rax
jne 0x7989d
movb $0x1, -0x3d(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rcx
movq -0x28(%rbp), %rax
addq 0x78(%rax), %rcx
movq %rcx, 0x78(%rax)
movq -0x10(%rbp), %rax
movq (%rax), %rcx
movq -0x28(%rbp), %rax
movq 0x98(%rax), %rax
movl -0x14(%rbp), %edx
subl $0x27, %edx
movl %edx, %edx
shlq $0x5, %rdx
addq %rdx, %rax
addq 0x10(%rax), %rcx
movq %rcx, 0x10(%rax)
movq -0x10(%rbp), %rax
movq $0x0, (%rax)
movl $0x0, -0x3c(%rbp)
movl $0x0, -0x34(%rbp)
movl -0x34(%rbp), %eax
cmpl -0x38(%rbp), %eax
jae 0x7992f
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rax
movl -0x34(%rbp), %ecx
movq (%rax,%rcx,8), %rax
movq %rax, -0x30(%rbp)
jmp 0x798c8
movq -0x30(%rbp), %rax
leaq 0x28e5d(%rip), %rcx     # 0xa2730
movq (%rcx), %rcx
xorq $-0x1, %rcx
andq %rcx, %rax
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rdi
callq 0x79b60
cmpq -0x50(%rbp), %rax
jne 0x79903
movq -0x50(%rbp), %rdi
movq -0x48(%rbp), %rsi
movq -0x30(%rbp), %rdx
callq 0x3fff0
jmp 0x7991f
movq -0x30(%rbp), %rdx
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rax
movl -0x3c(%rbp), %ecx
movq %rdx, (%rax,%rcx,8)
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x79921
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x798ab
movq -0x50(%rbp), %rdi
addq $0x8, %rdi
callq 0x79ba0
movl -0x3c(%rbp), %eax
movl %eax, -0x38(%rbp)
jmp 0x79804
testb $0x1, -0x3d(%rbp)
jne 0x799ae
movq -0x28(%rbp), %rdi
addq $0x8, %rdi
callq 0x79b80
movq -0x10(%rbp), %rax
movq (%rax), %rcx
movq -0x28(%rbp), %rax
addq 0x78(%rax), %rcx
movq %rcx, 0x78(%rax)
movq -0x10(%rbp), %rax
movq (%rax), %rcx
movq -0x28(%rbp), %rax
movq 0x98(%rax), %rax
movl -0x14(%rbp), %edx
subl $0x27, %edx
movl %edx, %edx
shlq $0x5, %rdx
addq %rdx, %rax
addq 0x10(%rax), %rcx
movq %rcx, 0x10(%rax)
movq -0x10(%rbp), %rax
movq $0x0, (%rax)
movq -0x28(%rbp), %rdi
addq $0x8, %rdi
callq 0x79ba0
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rsi
movq -0x10(%rbp), %rax
movl 0x10(%rax), %eax
subl -0x18(%rbp), %eax
movl %eax, %eax
shlq $0x3, %rax
addq %rax, %rsi
movl -0x18(%rbp), %eax
movl %eax, %edx
shlq $0x3, %rdx
callq 0x10500
movl -0x18(%rbp), %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x10(%rax)
movq -0x10(%rbp), %rax
movl 0x10(%rax), %eax
movq -0x10(%rbp), %rcx
cmpl 0x8(%rcx), %eax
jge 0x79a07
movq -0x10(%rbp), %rax
movl 0x10(%rax), %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x8(%rax)
addq $0x60, %rsp
popq %rbp
retq
nopl (%rax)