// File: /workspace/github_c_makefile_star2_O1/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 0x90cb8
leaq 0x28(%rbx), %r14
movl $0x188, %r13d           # imm = 0x188
xorl %r15d, %r15d
movq %r14, %rdi
movq %r15, %rsi
xorl %edx, %edx
movq %rbx, %rcx
callq 0x908bd
cmpq $0x0, (%r14)
je 0x90f6c
movq 0x18(%rbx), %rax
leaq (%rax,%r13), %r12
addq $-0x68, %r12
movq %r12, %rdi
callq 0x1faa0
movq (%r14), %rax
addq %rax, 0x68(%r12)
movq %r12, %rdi
callq 0x1fbb0
incq %r15
addq $0x20, %r14
addq $0x98, %r13
cmpq $0x1c, %r15
jne 0x90f32
cmpq $0x1d, 0x5fc10(%rip)    # 0xf0b98
jb 0x90ff7
leaq 0x28(%rbx), %r12
movl $0x1c, %esi
movl $0x1d, %r13d
movq %rsi, %r15
shlq $0x5, %r15
leaq (%r12,%r15), %r14
movq %r14, %rdi
xorl %edx, %edx
movq %rbx, %rcx
callq 0x90ac1
cmpq $0x0, (%r12,%r15)
je 0x90fe8
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(%r13), %edx
shlq $0x5, %rdx
addq %rax, 0x10(%rcx,%rdx)
movq %r15, %rdi
callq 0x1fbb0
movl %r13d, %esi
incl %r13d
cmpq %rsi, 0x5fba3(%rip)     # 0xf0b98
ja 0x90f99
leaq 0x4e882(%rip), %rax     # 0xdf880
movq (%rax), %rsi
notq %rsi
andq %rbx, %rsi
movq %rbx, %rcx
subq %rsi, %rcx
shrq $0xc, %rcx
leaq 0x4e910(%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 0x91046
movq %rax, %rdi
andq $-0x1000, %rdi          # imm = 0xF000
jmp 0x91055
imulq $0x68, %rdi, %rdi
leaq 0x4dbaf(%rip), %r8      # 0xdec00
movq (%r8,%rdi), %rdi
cmpq $0xe00, %rdi            # imm = 0xE00
ja 0x9107f
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 0x8141b
cmpq 0x5fb22(%rip), %rdi     # 0xf0ba8
jbe 0x910aa
cmpq %rbx, %rsi
je 0x910c3
movq (%rsi), %rdi
testb $0x2, %al
jne 0x910ad
movq %rbx, %rdx
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x8147f
movq (%rsi), %rdi
movq %rbx, %rdx
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x81920
movq %rbx, %rdi
movl $0x1, %esi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x8bb7e