// File: /workspace/github_c_makefile_star2_O2/nilyang[P]redis-tdd-annotation/deps/jemalloc/src/tcache.c
// Function: tcache_destroy
void
tcache_destroy(tcache_t *tcache)
{
	unsigned i;
	size_t tcache_size;

	tcache_arena_dissociate(tcache);

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

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

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

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

	if (config_prof && tcache->prof_accumbytes > 0) {
		malloc_mutex_lock(&tcache->arena->lock);
		arena_prof_accum(tcache->arena, tcache->prof_accumbytes);
		malloc_mutex_unlock(&tcache->arena->lock);
	}

	tcache_size = arena_salloc(tcache, false);
	if (tcache_size <= SMALL_MAXCLASS) {
		arena_chunk_t *chunk = CHUNK_ADDR2BASE(tcache);
		arena_t *arena = chunk->arena;
		size_t pageind = ((uintptr_t)tcache - (uintptr_t)chunk) >>
		    LG_PAGE;
		arena_chunk_map_t *mapelm = arena_mapp_get(chunk, pageind);

		arena_dalloc_bin(arena, chunk, tcache, pageind, mapelm);
	} else if (tcache_size <= tcache_maxclass) {
		arena_chunk_t *chunk = CHUNK_ADDR2BASE(tcache);
		arena_t *arena = chunk->arena;

		arena_dalloc_large(arena, chunk, tcache);
	} else
		idallocx(tcache, false);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %rbx
callq 0x874ae
leaq 0x28(%rbx), %r13
movl $0x188, %ebp            # imm = 0x188
xorl %r14d, %r14d
movq %r13, %r15
cmpq $0x1228, %rbp           # imm = 0x1228
je 0x87763
movq %r15, %rdi
movq %r14, %rsi
xorl %edx, %edx
movq %rbx, %rcx
callq 0x870f5
cmpq $0x0, (%r15)
je 0x87753
movq 0x18(%rbx), %rax
leaq (%rax,%rbp), %r12
addq $-0x68, %r12
movq %r12, %rdi
callq 0x1faa0
movq (%r15), %rax
addq %rax, 0x68(%r12)
movq %r12, %rdi
callq 0x1fbb0
incq %r14
addq $0x98, %rbp
addq $0x20, %r15
jmp 0x87710
xorl %r12d, %r12d
leal 0x1c(%r12), %esi
cmpq %rsi, 0x66426(%rip)     # 0xedb98
jbe 0x877c8
movq %rsi, %r15
shlq $0x5, %r15
leaq (%r15,%r13), %r14
movq %r14, %rdi
xorl %edx, %edx
movq %rbx, %rcx
callq 0x872d5
cmpq $0x0, (%r13,%r15)
je 0x877c3
movq 0x18(%rbx), %rbp
leaq 0x8(%rbp), %r15
movq %r15, %rdi
callq 0x1faa0
movq (%r14), %rax
addq %rax, 0x68(%rbp)
movq 0x70(%rbp), %rcx
movl %r12d, %edx
shlq $0x5, %rdx
addq %rax, 0x10(%rcx,%rdx)
movq %r15, %rdi
callq 0x1fbb0
incl %r12d
jmp 0x87766
movq %rbx, %rdi
callq 0x86ffe
cmpq $0xe00, %rax            # imm = 0xE00
ja 0x87824
leaq 0x550a1(%rip), %rax     # 0xdc880
movq (%rax), %rsi
notq %rsi
andq %rbx, %rsi
movq %rbx, %rcx
subq %rsi, %rcx
shrq $0xc, %rcx
leaq 0x5512f(%rip), %rax     # 0xdc928
movq %rcx, %rdx
subq (%rax), %rdx
movq (%rsi), %rdi
imulq $0x18, %rdx, %rax
leaq (%rsi,%rax), %r8
addq $0x30, %r8
movq %rbx, %rdx
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x78df9
leaq 0x55055(%rip), %rcx     # 0xdc880
movq (%rcx), %rsi
notq %rsi
andq %rbx, %rsi
cmpq 0x6636d(%rip), %rax     # 0xedba8
jbe 0x8787d
cmpq %rbx, %rsi
je 0x87896
movq %rbx, %rcx
subq %rsi, %rcx
shrq $0xc, %rcx
leaq 0x550d5(%rip), %rax     # 0xdc928
movq %rcx, %rdx
subq (%rax), %rdx
movq (%rsi), %rdi
imulq $0x18, %rdx, %rax
testb $0x2, 0x40(%rsi,%rax)
jne 0x87880
movq %rbx, %rdx
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x78e5d
movq (%rsi), %rdi
movq %rbx, %rdx
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x792f7
pushq $0x1
popq %rsi
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x82936