// File: /workspace/github_c_makefile_star2_O2/zhou-yuxin[P]redis-aof-no-cow/deps/jemalloc/src/tcache.c
// Function: je_tcache_create
tcache_t *
tcache_create(tsdn_t *tsdn, arena_t *arena)
{
	tcache_t *tcache;
	size_t size, stack_offset;
	unsigned i;

	size = offsetof(tcache_t, tbins) + (sizeof(tcache_bin_t) * nhbins);
	/* Naturally align the pointer stacks. */
	size = PTR_CEILING(size);
	stack_offset = size;
	size += stack_nelms * sizeof(void *);
	/* Avoid false cacheline sharing. */
	size = sa2u(size, CACHELINE);

	tcache = ipallocztm(tsdn, size, CACHELINE, true, NULL, true,
	    arena_get(TSDN_NULL, 0, true));
	if (tcache == NULL)
		return (NULL);

	tcache_arena_associate(tsdn, tcache, arena);

	ticker_init(&tcache->gc_ticker, TCACHE_GC_INCR);

	assert((TCACHE_NSLOTS_SMALL_MAX & 1U) == 0);
	for (i = 0; i < nhbins; i++) {
		tcache->tbins[i].lg_fill_div = 1;
		stack_offset += tcache_bin_info[i].ncached_max * sizeof(void *);
		/*
		 * avail points past the available space.  Allocations will
		 * access the slots toward higher addresses (for the benefit of
		 * prefetch).
		 */
		tcache->tbins[i].avail = (void **)((uintptr_t)tcache +
		    (uintptr_t)stack_offset);
	}

	return (tcache);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %rbx
movq %rdi, %r14
movl 0x18c80(%rip), %r13d    # 0x49480
shll $0x5, %r13d
addl $0x2f, %r13d
andl $-0x18, %r13d
movl 0x18c72(%rip), %eax     # 0x49484
leaq (,%rax,8), %rax
addq %r13, %rax
pushq $-0x1
popq %rdx
pushq $0x7
popq %rsi
cmpq $0x3800, %rax           # imm = 0x3800
ja 0x3086b
leal 0x3f(%rax), %edi
andl $0x7fc0, %edi           # imm = 0x7FC0
cmpl $0x1000, %edi           # imm = 0x1000
ja 0x30a9c
leaq -0x1(%rdi), %rcx
shrq $0x3, %rcx
leaq 0x6171(%rip), %rdi      # 0x369c0
movzbl (%rdi,%rcx), %ecx
leaq 0x59e6(%rip), %rdi      # 0x36240
movq (%rdi,%rcx,8), %r15
cmpq $0x4000, %r15           # imm = 0x4000
jb 0x3093a
leaq 0x1872e(%rip), %rcx     # 0x48fa0
leaq 0x1884f(%rip), %rdi     # 0x490c8
movq (%rdi), %rdi
pushq $-0x41
popq %r8
cmpq %rax, (%rcx)
jb 0x308e0
cmpq $0x41, %rdi
jb 0x308e0
movl $0x4000, %r15d          # imm = 0x4000
cmpq $0x4001, %rax           # imm = 0x4001
jb 0x308c6
leaq -0x1(,%rax,2), %rcx
bsrq %rcx, %r8
movl %r8d, %ecx
addb $-0x3, %cl
movq %rdx, %r15
shlq %cl, %r15
cmpl $0x6, %r8d
notq %r15
cmovbq %rsi, %r15
leaq (%r15,%rax), %rcx
notq %r15
andq %rcx, %r15
leaq 0x1000(%r15), %rcx
leaq 0x186fc(%rip), %r9      # 0x48fd0
movq $-0x1001, %r8           # imm = 0xEFFF
cmpq (%r9), %rcx
jbe 0x3093a
leaq 0x187e9(%rip), %rcx     # 0x490d0
movq (%rcx), %r9
cmpq %rax, %rdi
jae 0x30923
cmpq $0x1000, %rax           # imm = 0x1000
ja 0x30ace
leaq -0x1(%rax), %rcx
shrq $0x3, %rcx
leaq 0x60b6(%rip), %rdx      # 0x369c0
movzbl (%rdx,%rcx), %ecx
leaq 0x592b(%rip), %rdx      # 0x36240
movq (%rdx,%rcx,8), %rdi
cmpq %rax, %rdi
jae 0x30923
xorl %r15d, %r15d
jmp 0x3093a
subq %r9, %r8
orq %r9, %r8
addq $0x1000, %r8            # imm = 0x1000
xorl %r15d, %r15d
cmpq %rdi, %r8
cmovaeq %rdi, %r15
leaq 0x17c6f(%rip), %rax     # 0x485b0
movq (%rax), %rax
movq (%rax), %rsi
testq %rsi, %rsi
je 0x30a3d
pushq $0x40
popq %rcx
pushq $0x1
popq %r8
movq %r14, %rdi
movq %r15, %rdx
xorl %r9d, %r9d
callq 0x1be89
movq %rax, %r15
testq %rax, %rax
je 0x30a2b
leaq 0x18758(%rip), %rbp     # 0x490d0
movq (%rbp), %rax
notq %rax
andq %r15, %rax
cmpq %rax, %r15
je 0x30a5e
movq (%rax), %r12
cmpq %rax, %r15
je 0x30a78
movq %r15, %rcx
subq %rax, %rcx
shrq $0xc, %rcx
leaq 0x18618(%rip), %rdx     # 0x48fc0
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 0x30a88
movl %ecx, %eax
leaq 0x5873(%rip), %rcx      # 0x36240
movq (%rcx,%rax,8), %rax
lock
xaddq %rax, 0x90(%r12)
movq %r15, %rdi
movq %rbx, %rsi
callq 0x30678
movabsq $0xd3000000d3, %rax     # imm = 0xD3000000D3
movq %rax, 0x18(%r15)
leaq 0x34(%r15), %rax
xorl %ecx, %ecx
movl 0x18a80(%rip), %edx     # 0x49480
cmpq %rdx, %rcx
jae 0x30a2b
movl $0x1, (%rax)
movq 0x18a66(%rip), %rdx     # 0x49478
movl (%rdx,%rcx,4), %edx
leaq (%r13,%rdx,8), %r13
leaq (%r15,%r13), %rdx
movq %rdx, 0xc(%rax)
incq %rcx
addq $0x20, %rax
jmp 0x309fa
movq %r15, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
xorl %esi, %esi
lock
xaddq %rsi, (%rax)
testq %rsi, %rsi
jne 0x30950
xorl %edi, %edi
xorl %esi, %esi
callq 0x12af5
movq %rax, %rsi
jmp 0x30950
movq %r15, %rdi
callq 0x28ce3
movq %rax, %r12
movq (%rbp), %rax
notq %rax
andq %r15, %rax
jmp 0x3098e
movq %r14, %rdi
movq %r15, %rsi
callq 0x292e1
jmp 0x309d1
shrq %rax
andq $-0x1000, %rax          # imm = 0xF000
addq $-0x1000, %rax          # imm = 0xF000
jmp 0x309d1
leaq -0x1(,%rdi,2), %rcx
bsrq %rcx, %r8
movl %r8d, %ecx
addb $-0x3, %cl
movq %rdx, %r15
shlq %cl, %r15
cmpl $0x6, %r8d
notq %r15
cmovbq %rsi, %r15
leaq (%r15,%rdi), %rcx
notq %r15
andq %rcx, %r15
jmp 0x3085e
leaq -0x1(,%rax,2), %rcx
bsrq %rcx, %rdi
movl %edi, %ecx
addb $-0x3, %cl
shlq %cl, %rdx
cmpl $0x6, %edi
notq %rdx
cmovbq %rsi, %rdx
leaq (%rdx,%rax), %rcx
notq %rdx
andq %rcx, %rdx
movq %rdx, %rdi
jmp 0x30919