// File: /workspace/github_c_makefile_star2_O0/nilyang[P]redis-tdd-annotation/deps/jemalloc/src/tcache.c
// Function: tcache_create
tcache_t *
tcache_create(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 *);
	/*
	 * Round up to the nearest multiple of the cacheline size, in order to
	 * avoid the possibility of false cacheline sharing.
	 *
	 * That this works relies on the same logic as in ipalloc(), but we
	 * cannot directly call ipalloc() here due to tcache bootstrapping
	 * issues.
	 */
	size = (size + CACHELINE_MASK) & (-CACHELINE);

	if (size <= SMALL_MAXCLASS)
		tcache = (tcache_t *)arena_malloc_small(arena, size, true);
	else if (size <= tcache_maxclass)
		tcache = (tcache_t *)arena_malloc_large(arena, size, true);
	else
		tcache = (tcache_t *)icallocx(size, false, arena);

	if (tcache == NULL)
		return (NULL);

	tcache_arena_associate(tcache, arena);

	assert((TCACHE_NSLOTS_SMALL_MAX & 1U) == 0);
	for (i = 0; i < nhbins; i++) {
		tcache->tbins[i].lg_fill_div = 1;
		tcache->tbins[i].avail = (void **)((uintptr_t)tcache +
		    (uintptr_t)stack_offset);
		stack_offset += tcache_bin_info[i].ncached_max * sizeof(void *);
	}

	tcache_tsd_set(&tcache);

	return (tcache);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x10(%rbp)
movq 0x645bd(%rip), %rax     # 0x13a4f0
shlq $0x5, %rax
addq $0x28, %rax
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rax
addq $0x7, %rax
movabsq $0xfffffff8, %rcx       # imm = 0xFFFFFFF8
andq %rcx, %rax
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rax
movq %rax, -0x28(%rbp)
movl 0x64592(%rip), %eax     # 0x13a4f8
shlq $0x3, %rax
addq -0x20(%rbp), %rax
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rax
addq $0x3f, %rax
andq $-0x40, %rax
movq %rax, -0x20(%rbp)
cmpq $0xe00, -0x20(%rbp)     # imm = 0xE00
ja 0xd5fa4
movq -0x10(%rbp), %rdi
movq -0x20(%rbp), %rsi
movl $0x1, %edx
callq 0xb6460
movq %rax, -0x18(%rbp)
jmp 0xd5fde
movq -0x20(%rbp), %rax
cmpq 0x64551(%rip), %rax     # 0x13a500
ja 0xd5fc9
movq -0x10(%rbp), %rdi
movq -0x20(%rbp), %rsi
movl $0x1, %edx
callq 0xb6670
movq %rax, -0x18(%rbp)
jmp 0xd5fdc
movq -0x20(%rbp), %rdi
movq -0x10(%rbp), %rdx
xorl %esi, %esi
callq 0xd6090
movq %rax, -0x18(%rbp)
jmp 0xd5fde
cmpq $0x0, -0x18(%rbp)
jne 0xd5ff2
movq $0x0, -0x8(%rbp)
jmp 0xd6080
movq -0x18(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0xd5c70
jmp 0xd6001
movl $0x0, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
cmpq 0x644de(%rip), %rax     # 0x13a4f0
jae 0xd606f
movq -0x18(%rbp), %rax
addq $0x28, %rax
movl -0x2c(%rbp), %ecx
shlq $0x5, %rcx
addq %rcx, %rax
movl $0x1, 0xc(%rax)
movq -0x18(%rbp), %rcx
addq -0x28(%rbp), %rcx
movq -0x18(%rbp), %rax
addq $0x28, %rax
movl -0x2c(%rbp), %edx
shlq $0x5, %rdx
addq %rdx, %rax
movq %rcx, 0x18(%rax)
movq 0x64496(%rip), %rax     # 0x13a4e8
movl -0x2c(%rbp), %ecx
movl (%rax,%rcx,4), %eax
shlq $0x3, %rax
addq -0x28(%rbp), %rax
movq %rax, -0x28(%rbp)
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0xd6008
leaq -0x18(%rbp), %rdi
callq 0xd6100
movq -0x18(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x30, %rsp
popq %rbp
retq
nopw (%rax,%rax)