// File: /workspace/github_c_makefile_star2_O1/zhou-yuxin[P]redis-aof-no-cow/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 - 1));
		arena_t *locked_arena = extent_node_arena_get(&chunk->node);
		UNUSED bool idump;

		if (config_prof)
			idump = false;
		malloc_mutex_lock(tsd_tsdn(tsd), &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 - 1 - 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(tsd_tsdn(tsd),
				    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 - 1 - ndeferred) = ptr;
				ndeferred++;
			}
		}
		malloc_mutex_unlock(tsd_tsdn(tsd), &locked_arena->lock);
		if (config_prof && idump)
			prof_idump(tsd_tsdn(tsd));
		arena_decay_ticks(tsd_tsdn(tsd), locked_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.
		 */
		malloc_mutex_lock(tsd_tsdn(tsd), &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(tsd_tsdn(tsd), &arena->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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movl %ecx, %ebp
movl %edx, %r15d
movq %rsi, %r14
movq %rdi, %rbx
movq 0x30(%rdi), %rax
movq %rax, 0x10(%rsp)
testq %rax, %rax
je 0x355ba
movl 0x10(%r14), %r12d
subl %ebp, %r12d
je 0x3553c
movl %ebp, 0x18(%rsp)
movq %r15, 0x20(%rsp)
leal -0x27(%r15), %eax
movl $0x0, 0xc(%rsp)
leaq 0x17cda(%rip), %rcx     # 0x4d0d0
shlq $0x5, %rax
movq %rax, 0x28(%rsp)
movq %rbx, %r15
movq 0x18(%r14), %rax
movq (%rcx), %rcx
notq %rcx
andq -0x8(%rax), %rcx
movq (%rcx), %rbp
leaq 0x10(%rbp), %rdi
movq %rdi, 0x30(%rsp)
callq 0xb5a0
cmpq 0x10(%rsp), %rbp
jne 0x35455
movq (%r14), %rax
movq 0x10(%rsp), %rcx
addq %rax, 0xb0(%rcx)
movq 0xd0(%rcx), %rcx
movq 0x28(%rsp), %rdx
addq %rax, 0x10(%rcx,%rdx)
movq $0x0, (%r14)
movb $0x1, %al
movl %eax, 0xc(%rsp)
cmpl $0x1, %r12d
movl %r12d, 0x1c(%rsp)
movl %r12d, %ebx
adcl $0x0, %ebx
negq %rbx
xorl %r13d, %r13d
xorl %r12d, %r12d
leaq 0x17c5c(%rip), %rsi     # 0x4d0d0
movq 0x18(%r14), %rax
movq -0x8(%rax,%r13,8), %rcx
movq (%rsi), %rdx
notq %rdx
andq %rcx, %rdx
cmpq %rbp, (%rdx)
je 0x3549e
movl %r12d, %edx
shlq $0x3, %rdx
subq %rdx, %rax
movq %rcx, -0x8(%rax)
incl %r12d
jmp 0x354b0
movq %r15, %rdi
movq %rbp, %rsi
callq 0x23967
leaq 0x17c20(%rip), %rsi     # 0x4d0d0
decq %r13
cmpq %r13, %rbx
jne 0x35474
movq 0x30(%rsp), %rdi
callq 0xb380
movq %r15, %rbx
testq %r15, %r15
movl 0x1c(%rsp), %r15d
je 0x354fc
movl (%rbp), %esi
movq 0x38(%rbx), %rax
testq %rax, %rax
je 0x3550e
cmpl %esi, 0x40(%rbx)
jbe 0x3550e
leaq (%rax,%rsi,8), %rax
testq %rax, %rax
je 0x354fc
subl %r12d, %r15d
movl (%rax), %ecx
movl %ecx, %edx
subl %r15d, %edx
jl 0x35518
movl %edx, (%rax)
cmpl %r15d, %ecx
jl 0x3551d
testl %r12d, %r12d
leaq 0x17bca(%rip), %rcx     # 0x4d0d0
jne 0x353ff
jmp 0x3552c
movq %rbx, %rdi
callq 0x1afa2
jmp 0x354e4
movl 0x4(%rax), %edx
jmp 0x354f5
movq %rbx, %rdi
movq %rbp, %rsi
xorl %edx, %edx
callq 0x226c8
jmp 0x354fc
testb $0x1, 0xc(%rsp)
movl 0x18(%rsp), %ebp
movq 0x20(%rsp), %r15
jne 0x3557d
movq 0x10(%rsp), %r12
leaq 0x10(%r12), %rbx
movq %rbx, %rdi
callq 0xb5a0
movq (%r14), %rax
addq %rax, 0xb0(%r12)
movq 0xd0(%r12), %rcx
addl $-0x27, %r15d
shlq $0x5, %r15
addq %rax, 0x10(%rcx,%r15)
movq $0x0, (%r14)
movq %rbx, %rdi
callq 0xb380
movq 0x18(%r14), %rsi
movl %ebp, %edx
shlq $0x3, %rdx
movq %rsi, %rdi
subq %rdx, %rdi
movl 0x10(%r14), %eax
shlq $0x3, %rax
subq %rax, %rsi
callq 0xb450
movl %ebp, 0x10(%r14)
cmpl %ebp, 0x8(%r14)
jle 0x355ab
movl %ebp, 0x8(%r14)
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rbx, %rdi
xorl %esi, %esi
callq 0x1b0d1
movq %rax, 0x10(%rsp)
jmp 0x353cd