// File: /workspace/github_c_makefile_star2_O3/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 0x90fe2
leaq 0x28(%rbx), %r13
movl $0x188, %ebp            # imm = 0x188
xorl %r14d, %r14d
movq %r13, %r15
movq %r15, %rdi
movq %r14, %rsi
xorl %edx, %edx
movq %rbx, %rcx
callq 0x90bee
cmpq $0x0, (%r15)
je 0x91290
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 $0x20, %r15
addq $0x98, %rbp
cmpq $0x1c, %r14
jne 0x91256
cmpq $0x1d, 0x5f8ec(%rip)    # 0xf0b98
jb 0x91319
movl $0x1c, %esi
movl $0x1d, %r12d
movq %rsi, %r15
shlq $0x5, %r15
leaq (%r15,%r13), %r14
movq %r14, %rdi
xorl %edx, %edx
movq %rbx, %rcx
callq 0x90dea
cmpq $0x0, (%r13,%r15)
je 0x9130a
movq 0x18(%rbx), %rbp
leaq 0x8(%rbp), %r15
movq %r15, %rdi
callq 0x1faa0
movq (%r14), %rax
addq %rax, 0x68(%rbp)
movq 0x70(%rbp), %rcx
leal -0x1d(%r12), %edx
shlq $0x5, %rdx
addq %rax, 0x10(%rcx,%rdx)
movq %r15, %rdi
callq 0x1fbb0
movl %r12d, %esi
incl %r12d
cmpq %rsi, 0x5f881(%rip)     # 0xf0b98
ja 0x912b9
leaq 0x4e560(%rip), %rax     # 0xdf880
movq (%rax), %rsi
notq %rsi
andq %rbx, %rsi
movq %rbx, %rcx
subq %rsi, %rcx
shrq $0xc, %rcx
leaq 0x4e5ee(%rip), %rax     # 0xdf928
movq %rcx, %rdx
subq (%rax), %rdx
leaq (%rdx,%rdx,2), %rdx
movq 0x40(%rsi,%rdx,8), %rax
movl %eax, %edi
shrl $0x4, %edi
movl $0xff, %r8d
andl %r8d, %edi
cmpl %r8d, %edi
jne 0x91368
movq %rax, %rdi
andq $-0x1000, %rdi          # imm = 0xF000
jmp 0x91377
imulq $0x68, %rdi, %rdi
leaq 0x4d88d(%rip), %r8      # 0xdec00
movq (%r8,%rdi), %rdi
cmpq $0xe00, %rdi            # imm = 0xE00
ja 0x913a1
leaq 0x30(%rsi), %rax
movq (%rsi), %rdi
leaq (%rax,%rdx,8), %r8
movq %rbx, %rdx
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x8173d
cmpq 0x5f800(%rip), %rdi     # 0xf0ba8
jbe 0x913cc
cmpq %rbx, %rsi
je 0x913e5
movq (%rsi), %rdi
testb $0x2, %al
jne 0x913cf
movq %rbx, %rdx
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x817a1
movq (%rsi), %rdi
movq %rbx, %rdx
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x81c48
movq %rbx, %rdi
movl $0x1, %esi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x8bdfd