// File: /workspace/github_c_makefile_star2_O3/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 0x3c59e(%rip), %r13d    # 0x4d480
shll $0x5, %r13d
addl $0x2f, %r13d
andl $-0x18, %r13d
movl 0x3c590(%rip), %eax     # 0x4d484
leaq (,%rax,8), %rax
addq %r13, %rax
pushq $-0x1
popq %rdx
pushq $0x7
popq %rsi
cmpq $0x3800, %rax           # imm = 0x3800
ja 0x10f4d
leal 0x3f(%rax), %edi
andl $0x7fc0, %edi           # imm = 0x7FC0
cmpl $0x1000, %edi           # imm = 0x1000
ja 0x11185
leaq -0x1(%rdi), %rcx
shrq $0x3, %rcx
leaq 0x2af0f(%rip), %rdi     # 0x3be40
movzbl (%rdi,%rcx), %ecx
leaq 0x2a784(%rip), %rdi     # 0x3b6c0
movq (%rdi,%rcx,8), %r15
cmpq $0x4000, %r15           # imm = 0x4000
jb 0x1101c
leaq 0x3c04c(%rip), %rcx     # 0x4cfa0
leaq 0x3c16d(%rip), %rdi     # 0x4d0c8
movq (%rdi), %rdi
pushq $-0x41
popq %r8
cmpq %rax, (%rcx)
jb 0x10fc2
cmpq $0x41, %rdi
jb 0x10fc2
movl $0x4000, %r15d          # imm = 0x4000
cmpq $0x4001, %rax           # imm = 0x4001
jb 0x10fa8
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 0x3c01a(%rip), %r9      # 0x4cfd0
movq $-0x1001, %r8           # imm = 0xEFFF
cmpq (%r9), %rcx
jbe 0x1101c
leaq 0x3c107(%rip), %rcx     # 0x4d0d0
movq (%rcx), %r9
cmpq %rax, %rdi
jae 0x11005
cmpq $0x1000, %rax           # imm = 0x1000
ja 0x111b7
leaq -0x1(%rax), %rcx
shrq $0x3, %rcx
leaq 0x2ae54(%rip), %rdx     # 0x3be40
movzbl (%rdx,%rcx), %ecx
leaq 0x2a6c9(%rip), %rdx     # 0x3b6c0
movq (%rdx,%rcx,8), %rdi
cmpq %rax, %rdi
jae 0x11005
xorl %r15d, %r15d
jmp 0x1101c
subq %r9, %r8
orq %r9, %r8
addq $0x1000, %r8            # imm = 0x1000
xorl %r15d, %r15d
cmpq %rdi, %r8
cmovaeq %rdi, %r15
leaq 0x3b58d(%rip), %rax     # 0x4c5b0
movq (%rax), %rax
movq (%rax), %rsi
testq %rsi, %rsi
je 0x11126
pushq $0x40
popq %rcx
pushq $0x1
popq %r8
movq %r14, %rdi
movq %r15, %rdx
xorl %r9d, %r9d
callq 0xcfd4
movq %rax, %r15
testq %rax, %rax
je 0x11114
leaq 0x3c076(%rip), %rbp     # 0x4d0d0
movq (%rbp), %rax
notq %rax
andq %r15, %rax
cmpq %rax, %r15
je 0x11147
movq (%rax), %r12
cmpq %rax, %r15
je 0x11161
movq %r15, %rcx
subq %rax, %rcx
shrq $0xc, %rcx
leaq 0x3bf36(%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 0x11171
movl %ecx, %eax
leaq 0x2a611(%rip), %rcx     # 0x3b6c0
movq (%rcx,%rax,8), %rax
lock
xaddq %rax, 0x90(%r12)
movq %r15, %rdi
movq %rbx, %rsi
callq 0x35b5a
movabsq $0xd3000000d3, %rax     # imm = 0xD3000000D3
movq %rax, 0x18(%r15)
cmpl $0x0, 0x3c3a3(%rip)     # 0x4d480
je 0x11114
leaq 0x34(%r15), %rax
xorl %ecx, %ecx
movl $0x1, (%rax)
movq 0x3c386(%rip), %rdx     # 0x4d478
movl (%rdx,%rcx,4), %edx
leaq (%r13,%rdx,8), %r13
leaq (%r15,%r13), %rdx
movq %rdx, 0xc(%rax)
incq %rcx
movl 0x3c375(%rip), %edx     # 0x4d480
addq $0x20, %rax
cmpq %rdx, %rcx
jb 0x110e5
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 0x11032
xorl %edi, %edi
xorl %esi, %esi
callq 0x1acc9
movq %rax, %rsi
jmp 0x11032
movq %r15, %rdi
callq 0x2e203
movq %rax, %r12
movq (%rbp), %rax
notq %rax
andq %r15, %rax
jmp 0x11070
movq %r14, %rdi
movq %r15, %rsi
callq 0x2e344
jmp 0x110b3
shrq %rax
andq $-0x1000, %rax          # imm = 0xF000
addq $-0x1000, %rax          # imm = 0xF000
jmp 0x110b3
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 0x10f40
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 0x10ffb