// File: /workspace/github_c_makefile_star2_O3/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
subq $0x18, %rsp
movq %rsi, %rbx
movq %rdi, %r14
movq 0x30(%rdi), %r15
testq %r15, %r15
je 0x35edc
movq %r14, %rdi
movq %rbx, %rsi
movq %r15, %rdx
callq 0x35aee
leaq 0x28(%rbx), %r12
leaq 0x980(%r15), %r13
xorl %ebp, %ebp
movq %r14, %rdi
movq %r12, %rdx
movl %ebp, %ecx
xorl %r8d, %r8d
callq 0x3561b
cmpq $0x0, (%r12)
je 0x35d84
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
cmpq $0x27, %rbp
jne 0x35d55
movq %r15, 0x10(%rsp)
movq %rbx, 0x8(%rsp)
cmpl $0x28, 0x176d7(%rip)    # 0x4d480
jb 0x35e22
movq 0x10(%rsp), %rax
leaq 0x10(%rax), %r12
movq 0x8(%rsp), %rax
leaq 0x508(%rax), %rbx
movl $0x27, %r13d
xorl %r15d, %r15d
leaq (%rbx,%r15), %rbp
movq %r14, %rdi
movq %rbp, %rsi
movl %r13d, %edx
xorl %ecx, %ecx
callq 0x35853
cmpq $0x0, (%rbx,%r15)
je 0x35e10
movq %r12, %rdi
callq 0xb5a0
movq (%rbp), %rax
movq 0x10(%rsp), %rcx
addq %rax, 0xb0(%rcx)
movq 0xd0(%rcx), %rcx
addq %rax, 0x10(%rcx,%r15)
movq %r12, %rdi
callq 0xb380
incq %r13
movl 0x17667(%rip), %eax     # 0x4d480
addq $0x20, %r15
cmpq %rax, %r13
jb 0x35dc9
leaq 0x172a7(%rip), %r12     # 0x4d0d0
movq (%r12), %rax
notq %rax
movq 0x8(%rsp), %rbx
andq %rbx, %rax
cmpq %rbx, %rax
je 0x35eee
movq (%rax), %r15
cmpq %rbx, %rax
je 0x35f08
movq %rbx, %rcx
subq %rax, %rcx
shrq $0xc, %rcx
leaq 0x17162(%rip), %rdx     # 0x4cfc0
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 0x35f31
movl %ecx, %eax
leaq 0x583d(%rip), %rcx      # 0x3b6c0
movq (%rcx,%rax,8), %rax
negq %rax
lock
xaddq %rax, 0x90(%r15)
movq (%r12), %rdx
notq %rdx
andq %rbx, %rdx
cmpq %rbx, %rdx
je 0x35f18
movq %rbx, %r8
subq %rdx, %r8
shrq $0xc, %r8
leaq 0x1710d(%rip), %rax     # 0x4cfc0
movq %r8, %rcx
subq (%rax), %rcx
testb $0x2, 0x78(%rdx,%rcx,8)
movq (%rdx), %rsi
movq %r14, %rdi
movq %rbx, %rcx
jne 0x35f45
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xd9f4
movq %r14, %rdi
xorl %esi, %esi
callq 0x1af15
movq %rax, %r15
jmp 0x35d3a
movq %rbx, %rdi
callq 0x2e203
movq %rax, %r15
movq (%r12), %rax
notq %rax
andq %rbx, %rax
jmp 0x35e44
movq %r14, %rdi
movq %rbx, %rsi
callq 0x2e344
jmp 0x35e87
movq %r14, %rdi
movq %rbx, %rsi
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x10a30
shrq %rax
andq $-0x1000, %rax          # imm = 0xF000
addq $-0x1000, %rax          # imm = 0xF000
jmp 0x35e87
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xda57