// File: /workspace/github_c_makefile_star2_O2/zhou-yuxin[P]redis-aof-no-cow/deps/jemalloc/src/tcache.c
// Function: tcache_destroy
static void
tcache_destroy(tsd_t *tsd, tcache_t *tcache)
{
	arena_t *arena;
	unsigned i;

	arena = arena_choose(tsd, NULL);
	tcache_arena_dissociate(tsd_tsdn(tsd), tcache, arena);

	for (i = 0; i < NBINS; i++) {
		tcache_bin_t *tbin = &tcache->tbins[i];
		tcache_bin_flush_small(tsd, tcache, tbin, i, 0);

		if (config_stats && tbin->tstats.nrequests != 0) {
			arena_bin_t *bin = &arena->bins[i];
			malloc_mutex_lock(tsd_tsdn(tsd), &bin->lock);
			bin->stats.nrequests += tbin->tstats.nrequests;
			malloc_mutex_unlock(tsd_tsdn(tsd), &bin->lock);
		}
	}

	for (; i < nhbins; i++) {
		tcache_bin_t *tbin = &tcache->tbins[i];
		tcache_bin_flush_large(tsd, tbin, i, 0, tcache);

		if (config_stats && tbin->tstats.nrequests != 0) {
			malloc_mutex_lock(tsd_tsdn(tsd), &arena->lock);
			arena->stats.nrequests_large += tbin->tstats.nrequests;
			arena->stats.lstats[i - NBINS].nrequests +=
			    tbin->tstats.nrequests;
			malloc_mutex_unlock(tsd_tsdn(tsd), &arena->lock);
		}
	}

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

	idalloctm(tsd_tsdn(tsd), tcache, NULL, true, true);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %rbx
movq %rdi, %r12
callq 0x305ea
movq %rax, %r15
movq %rax, %r14
movq %r12, (%rsp)
movq %r12, %rdi
movq %rbx, %rsi
movq %rax, %rdx
callq 0x3060f
leaq 0x28(%rbx), %r12
leaq 0x980(%r15), %r13
xorl %ebp, %ebp
cmpq $0x27, %rbp
je 0x30b98
movq (%rsp), %rdi
movq %r12, %rdx
movl %ebp, %ecx
xorl %r8d, %r8d
callq 0x301d3
cmpq $0x0, (%r12)
je 0x30b88
movq %r13, %rdi
callq 0xb5a0
movq (%r12), %rax
addq %rax, 0x70(%r13)
movq %r13, %rdi
callq 0xb380
incq %rbp
addq $0x20, %r12
addq $0xa8, %r13
jmp 0x30b52
addq $0x10, %r15
pushq $0x27
popq %r12
movl $0x508, %ebp            # imm = 0x508
movl 0x188d5(%rip), %eax     # 0x49480
cmpq %rax, %r12
jae 0x30bff
leaq (%rbx,%rbp), %r13
movq (%rsp), %rdi
movq %r13, %rsi
movl %r12d, %edx
xorl %ecx, %ecx
callq 0x303be
cmpq $0x0, (%rbx,%rbp)
je 0x30bf6
movq %r15, %rdi
callq 0xb5a0
movq (%r13), %rax
addq %rax, 0xb0(%r14)
movq 0xd0(%r14), %rcx
addq %rax, -0x4f8(%rcx,%rbp)
movq %r15, %rdi
callq 0xb380
incq %r12
addq $0x20, %rbp
jmp 0x30ba5
leaq 0x184ca(%rip), %r14     # 0x490d0
movq (%r14), %rax
notq %rax
andq %rbx, %rax
cmpq %rbx, %rax
je 0x30cb3
movq (%rax), %r15
cmpq %rbx, %rax
je 0x30ccc
movq %rbx, %rcx
subq %rax, %rcx
shrq $0xc, %rcx
leaq 0x1838b(%rip), %rdx     # 0x48fc0
subq (%rdx), %rcx
movq 0x78(%rax,%rcx,8), %rax
movl %eax, %ecx
shrl $0x5, %ecx
movl $0xff, %edx
andl %edx, %ecx
cmpl %edx, %ecx
je 0x30cf4
movl %ecx, %eax
leaq 0x55e6(%rip), %rcx      # 0x36240
movq (%rcx,%rax,8), %rax
negq %rax
lock
xaddq %rax, 0x90(%r15)
movq (%r14), %rdx
notq %rdx
andq %rbx, %rdx
cmpq %rbx, %rdx
je 0x30cda
movq %rbx, %r8
subq %rdx, %r8
shrq $0xc, %r8
leaq 0x18337(%rip), %rax     # 0x48fc0
movq %r8, %rcx
subq (%rax), %rcx
testb $0x2, 0x78(%rdx,%rcx,8)
movq (%rdx), %rsi
jne 0x30d08
movq (%rsp), %rdi
movq %rbx, %rcx
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x1ca94
movq %rbx, %rdi
callq 0x28ce3
movq %rax, %r15
movq (%r14), %rax
notq %rax
andq %rbx, %rax
jmp 0x30c1b
movq (%rsp), %rdi
movq %rbx, %rsi
callq 0x292e1
jmp 0x30c5e
movq (%rsp), %rdi
movq %rbx, %rsi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x28fb2
shrq %rax
andq $-0x1000, %rax          # imm = 0xF000
addq $-0x1000, %rax          # imm = 0xF000
jmp 0x30c5e
movq (%rsp), %rdi
movq %rbx, %rcx
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x1cc1f