// File: /workspace/github_c_makefile_star2_O1/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 0x35a47
movq %r14, %rdi
movq %rbx, %rsi
movq %r15, %rdx
callq 0x35648
leaq 0x28(%rbx), %r12
leaq 0x980(%r15), %r13
xorl %ebp, %ebp
movq %r14, %rdi
movq %r12, %rdx
movl %ebp, %ecx
xorl %r8d, %r8d
callq 0x35162
cmpq $0x0, (%r12)
je 0x358e5
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 0x358b6
movq %r15, 0x10(%rsp)
movq %rbx, 0x8(%rsp)
cmpl $0x28, 0x17b76(%rip)    # 0x4d480
jb 0x35983
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 0x353a2
cmpq $0x0, (%rbx,%r15)
je 0x35971
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 0x17b06(%rip), %eax     # 0x4d480
addq $0x20, %r15
cmpq %rax, %r13
jb 0x3592a
leaq 0x17746(%rip), %r12     # 0x4d0d0
movq (%r12), %rax
notq %rax
movq 0x8(%rsp), %rbx
andq %rbx, %rax
cmpq %rbx, %rax
je 0x35a59
movq (%rax), %r15
movq (%r12), %rax
notq %rax
andq %rbx, %rax
cmpq %rbx, %rax
je 0x35a69
movq %rbx, %rcx
subq %rax, %rcx
shrq $0xc, %rcx
leaq 0x175f7(%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 0x35a92
movl %ecx, %eax
leaq 0x5c52(%rip), %rcx      # 0x3b640
movq (%rcx,%rax,8), %rax
negq %rax
lock
xaddq %rax, 0x90(%r15)
movq (%r12), %rdx
notq %rdx
andq %rbx, %rdx
cmpq %rbx, %rdx
je 0x35a79
movq %rbx, %r8
subq %rdx, %r8
shrq $0xc, %r8
leaq 0x175a2(%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 0x35aa6
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xdf6b
movq %r14, %rdi
xorl %esi, %esi
callq 0x1b0d1
movq %rax, %r15
jmp 0x3589b
movq %rbx, %rdi
callq 0x2e39f
movq %rax, %r15
jmp 0x359a5
movq %r14, %rdi
movq %rbx, %rsi
callq 0x2e4e2
jmp 0x359f2
movq %r14, %rdi
movq %rbx, %rsi
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x11227
shrq %rax
andq $-0x1000, %rax          # imm = 0xF000
addq $-0x1000, %rax          # imm = 0xF000
jmp 0x359f2
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xdfd3