// File: /workspace/github_c_makefile_star2_O1/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 0x3bd68(%rip), %r13d    # 0x4d480
shll $0x5, %r13d
addl $0x2f, %r13d
andl $-0x18, %r13d
movl 0x3bd5a(%rip), %eax     # 0x4d484
leaq (,%rax,8), %rax
addq %r13, %rax
pushq $-0x1
popq %rdx
pushq $0x7
popq %rsi
cmpq $0x3800, %rax           # imm = 0x3800
ja 0x11783
leal 0x3f(%rax), %edi
andl $0x7fc0, %edi           # imm = 0x7FC0
cmpl $0x1000, %edi           # imm = 0x1000
ja 0x119c8
leaq -0x1(%rdi), %rcx
shrq $0x3, %rcx
leaq 0x2a659(%rip), %rdi     # 0x3bdc0
movzbl (%rdi,%rcx), %ecx
leaq 0x29ece(%rip), %rdi     # 0x3b640
movq (%rdi,%rcx,8), %r15
cmpq $0x4000, %r15           # imm = 0x4000
jb 0x11852
leaq 0x3b816(%rip), %rcx     # 0x4cfa0
leaq 0x3b937(%rip), %rdi     # 0x4d0c8
movq (%rdi), %rdi
pushq $-0x41
popq %r8
cmpq %rax, (%rcx)
jb 0x117f8
cmpq $0x41, %rdi
jb 0x117f8
movl $0x4000, %r15d          # imm = 0x4000
cmpq $0x4001, %rax           # imm = 0x4001
jb 0x117de
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 0x3b7e4(%rip), %r9      # 0x4cfd0
movq $-0x1001, %r8           # imm = 0xEFFF
cmpq (%r9), %rcx
jbe 0x11852
leaq 0x3b8d1(%rip), %rcx     # 0x4d0d0
movq (%rcx), %r9
cmpq %rax, %rdi
jae 0x1183b
cmpq $0x1000, %rax           # imm = 0x1000
ja 0x119fa
leaq -0x1(%rax), %rcx
shrq $0x3, %rcx
leaq 0x2a59e(%rip), %rdx     # 0x3bdc0
movzbl (%rdx,%rcx), %ecx
leaq 0x29e13(%rip), %rdx     # 0x3b640
movq (%rdx,%rcx,8), %rdi
cmpq %rax, %rdi
jae 0x1183b
xorl %r15d, %r15d
jmp 0x11852
subq %r9, %r8
orq %r9, %r8
addq $0x1000, %r8            # imm = 0x1000
xorl %r15d, %r15d
cmpq %rdi, %r8
cmovaeq %rdi, %r15
leaq 0x3ad57(%rip), %rax     # 0x4c5b0
movq (%rax), %rax
movq (%rax), %rsi
testq %rsi, %rsi
je 0x11973
xorl %r12d, %r12d
pushq $0x40
popq %rcx
pushq $0x1
popq %r8
movq %r14, %rdi
movq %r15, %rdx
xorl %r9d, %r9d
callq 0xd4f0
testq %rax, %rax
je 0x11961
movq %rax, %r15
leaq 0x3b83d(%rip), %rbp     # 0x4d0d0
movq (%rbp), %rax
notq %rax
andq %r15, %rax
cmpq %rax, %r15
je 0x11994
movq (%rax), %r12
movq (%rbp), %rax
notq %rax
andq %r15, %rax
movq %r15, %rcx
subq %rax, %rcx
je 0x119a4
shrq $0xc, %rcx
leaq 0x3b6f6(%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 0x119b4
movl %ecx, %eax
leaq 0x29d51(%rip), %rcx     # 0x3b640
movq (%rcx,%rax,8), %rax
lock
xaddq %rax, 0x90(%r12)
testq %r15, %r15
je 0x1195e
movq %r15, %rdi
movq %rbx, %rsi
callq 0x356bb
movabsq $0xd3000000d3, %rax     # imm = 0xD3000000D3
movq %rax, 0x18(%r15)
cmpl $0x0, 0x3bb5e(%rip)     # 0x4d480
je 0x11959
leaq 0x34(%r15), %rax
xorl %ecx, %ecx
movl $0x1, (%rax)
movq 0x3bb41(%rip), %rdx     # 0x4d478
movl (%rdx,%rcx,4), %edx
leaq (%r13,%rdx,8), %r13
leaq (%r15,%r13), %rdx
movq %rdx, 0xc(%rax)
incq %rcx
movl 0x3bb30(%rip), %edx     # 0x4d480
addq $0x20, %rax
cmpq %rdx, %rcx
jb 0x1192a
movq %r15, %r12
jmp 0x11961
xorl %r12d, %r12d
movq %r12, %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 0x11868
xorl %edi, %edi
xorl %esi, %esi
callq 0x1ae84
movq %rax, %rsi
jmp 0x11868
movq %r15, %rdi
callq 0x2e39f
movq %rax, %r12
jmp 0x118a9
movq %r14, %rdi
movq %r15, %rsi
callq 0x2e4e2
jmp 0x118f3
shrq %rax
andq $-0x1000, %rax          # imm = 0xF000
addq $-0x1000, %rax          # imm = 0xF000
jmp 0x118f3
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 0x11776
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 0x11831