// File: /workspace/github_c_makefile_star2_O1/zhou-yuxin[P]redis-aof-no-cow/deps/jemalloc/src/arena.c
// Function: je_arena_new
arena_t *
arena_new(tsdn_t *tsdn, unsigned ind)
{
	arena_t *arena;
	unsigned i;

	/*
	 * Allocate arena, arena->lstats, and arena->hstats contiguously, mainly
	 * because there is no way to clean up if base_alloc() OOMs.
	 */
	if (config_stats) {
		arena = (arena_t *)base_alloc(tsdn,
		    CACHELINE_CEILING(sizeof(arena_t)) +
		    QUANTUM_CEILING((nlclasses * sizeof(malloc_large_stats_t)))
		    + (nhclasses * sizeof(malloc_huge_stats_t)));
	} else
		arena = (arena_t *)base_alloc(tsdn, sizeof(arena_t));
	if (arena == NULL)
		return (NULL);

	arena->ind = ind;
	arena->nthreads[0] = arena->nthreads[1] = 0;
	if (malloc_mutex_init(&arena->lock, "arena", WITNESS_RANK_ARENA))
		return (NULL);

	if (config_stats) {
		memset(&arena->stats, 0, sizeof(arena_stats_t));
		arena->stats.lstats = (malloc_large_stats_t *)((uintptr_t)arena
		    + CACHELINE_CEILING(sizeof(arena_t)));
		memset(arena->stats.lstats, 0, nlclasses *
		    sizeof(malloc_large_stats_t));
		arena->stats.hstats = (malloc_huge_stats_t *)((uintptr_t)arena
		    + CACHELINE_CEILING(sizeof(arena_t)) +
		    QUANTUM_CEILING(nlclasses * sizeof(malloc_large_stats_t)));
		memset(arena->stats.hstats, 0, nhclasses *
		    sizeof(malloc_huge_stats_t));
		if (config_tcache)
			ql_new(&arena->tcache_ql);
	}

	if (config_prof)
		arena->prof_accumbytes = 0;

	if (config_cache_oblivious) {
		/*
		 * A nondeterministic seed based on the address of arena reduces
		 * the likelihood of lockstep non-uniform cache index
		 * utilization among identical concurrent processes, but at the
		 * cost of test repeatability.  For debug builds, instead use a
		 * deterministic seed.
		 */
		arena->offset_state = config_debug ? ind :
		    (size_t)(uintptr_t)arena;
	}

	arena->dss_prec = chunk_dss_prec_get();

	ql_new(&arena->achunks);

	arena->extent_sn_next = 0;

	arena->spare = NULL;

	arena->lg_dirty_mult = arena_lg_dirty_mult_default_get();
	arena->purging = false;
	arena->nactive = 0;
	arena->ndirty = 0;

	for (i = 0; i < NPSIZES; i++)
		arena_run_heap_new(&arena->runs_avail[i]);

	qr_new(&arena->runs_dirty, rd_link);
	qr_new(&arena->chunks_cache, cc_link);

	if (opt_purge == purge_mode_decay)
		arena_decay_init(arena, arena_decay_time_default_get());

	ql_new(&arena->huge);
	if (malloc_mutex_init(&arena->huge_mtx, "arena_huge",
	    WITNESS_RANK_ARENA_HUGE))
		return (NULL);

	extent_tree_szsnad_new(&arena->chunks_szsnad_cached);
	extent_tree_ad_new(&arena->chunks_ad_cached);
	extent_tree_szsnad_new(&arena->chunks_szsnad_retained);
	extent_tree_ad_new(&arena->chunks_ad_retained);
	if (malloc_mutex_init(&arena->chunks_mtx, "arena_chunks",
	    WITNESS_RANK_ARENA_CHUNKS))
		return (NULL);
	ql_new(&arena->node_cache);
	if (malloc_mutex_init(&arena->node_cache_mtx, "arena_node_cache",
	    WITNESS_RANK_ARENA_NODE_CACHE))
		return (NULL);

	arena->chunk_hooks = chunk_hooks_default;

	/* Initialize bins. */
	for (i = 0; i < NBINS; i++) {
		arena_bin_t *bin = &arena->bins[i];
		if (malloc_mutex_init(&bin->lock, "arena_bin",
		    WITNESS_RANK_ARENA_BIN))
			return (NULL);
		bin->runcur = NULL;
		arena_run_heap_new(&bin->runs);
		if (config_stats)
			memset(&bin->stats, 0, sizeof(malloc_bin_stats_t));
	}

	return (arena);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movl %esi, %ebp
movl 0x2872c(%rip), %eax     # 0x4c5d4
shlq $0x5, %rax
movl 0x29106(%rip), %ecx     # 0x4cfb8
leaq (%rcx,%rcx,2), %rcx
leaq (%rax,%rcx,8), %rsi
addq $0x2980, %rsi           # imm = 0x2980
callq 0xff71
testq %rax, %rax
je 0x240bf
movq %rax, %rbx
movl %ebp, (%rax)
movq $0x0, 0x4(%rax)
leaq 0x10(%rax), %rdi
leaq 0x18321(%rip), %rsi     # 0x3c208
movl $0x8, %edx
callq 0x2e5dc
testb %al, %al
jne 0x240bf
xorps %xmm0, %xmm0
movups %xmm0, 0xd0(%rbx)
movups %xmm0, 0xc0(%rbx)
movups %xmm0, 0xb0(%rbx)
movups %xmm0, 0xa0(%rbx)
movups %xmm0, 0x90(%rbx)
movups %xmm0, 0x80(%rbx)
movups %xmm0, 0x70(%rbx)
movups %xmm0, 0x60(%rbx)
leaq 0x2980(%rbx), %rdi
movq %rdi, 0xd0(%rbx)
movl 0x28692(%rip), %edx     # 0x4c5d4
shlq $0x5, %rdx
xorl %r14d, %r14d
xorl %esi, %esi
callq 0xb230
movl 0x2867e(%rip), %eax     # 0x4c5d4
shlq $0x5, %rax
leaq (%rax,%rbx), %rdi
addq $0x2980, %rdi           # imm = 0x2980
movq %rdi, 0xd8(%rbx)
movl 0x29046(%rip), %eax     # 0x4cfb8
shlq $0x3, %rax
leaq (%rax,%rax,2), %rdx
xorl %esi, %esi
callq 0xb230
movq %r14, 0xe0(%rbx)
movq %rbx, 0xf0(%rbx)
callq 0x2759c
movl %eax, 0xf8(%rbx)
xorps %xmm0, %xmm0
movups %xmm0, 0x100(%rbx)
movq %r14, 0x110(%rbx)
lock
xaddq %r14, 0x28ff4(%rip)     # 0x4cfa8
movq %r14, 0x118(%rbx)
movb $0x0, 0x120(%rbx)
leaq 0x2318(%rbx), %rdi
movl $0x638, %edx            # imm = 0x638
xorl %esi, %esi
callq 0xb230
xorps %xmm0, %xmm0
movups %xmm0, 0x128(%rbx)
leaq 0x138(%rbx), %rax
movq %rax, 0x138(%rbx)
movq %rax, 0x140(%rbx)
leaq 0x148(%rbx), %rax
movq %rax, 0x188(%rbx)
movq %rax, 0x190(%rbx)
cmpl $0x1, 0x285c0(%rip)     # 0x4c5d0
jne 0x24025
xorl %esi, %esi
lock
xaddq %rsi, 0x28f93(%rip)     # 0x4cfb0
movq %rbx, %rdi
callq 0x22644
movq $0x0, 0x828(%rbx)
leaq 0x830(%rbx), %rdi
leaq 0x181d0(%rip), %rsi     # 0x3c20e
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x2e5dc
testb %al, %al
jne 0x240bf
leaq 0x880(%rbx), %rdi
callq 0x2c3ec
leaq 0x888(%rbx), %rdi
callq 0x2d773
leaq 0x890(%rbx), %rdi
callq 0x2c3ec
leaq 0x898(%rbx), %rdi
callq 0x2d773
leaq 0x8a0(%rbx), %rdi
leaq 0x1818f(%rip), %rsi     # 0x3c219
movl $0x9, %edx
callq 0x2e5dc
testb %al, %al
jne 0x240bf
movq $0x0, 0x8f0(%rbx)
leaq 0x8f8(%rbx), %rdi
leaq 0x18175(%rip), %rsi     # 0x3c226
movl $0xa, %edx
callq 0x2e5dc
testb %al, %al
je 0x240cd
xorl %ebx, %ebx
movq %rbx, %rax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
leaq 0x261cc(%rip), %rax     # 0x4a2a0
movq 0x30(%rax), %rcx
movq %rcx, 0x978(%rbx)
movups (%rax), %xmm0
movups 0x10(%rax), %xmm1
movups 0x20(%rax), %xmm2
movups %xmm2, 0x968(%rbx)
movups %xmm1, 0x958(%rbx)
movups %xmm0, 0x948(%rbx)
movq %rbx, %r14
addq $0x980, %r14            # imm = 0x980
movl $0x27, %r12d
leaq 0x18121(%rip), %r15     # 0x3c237
movq %r14, %rdi
movq %r15, %rsi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x2e5dc
testb %al, %al
jne 0x240bf
xorps %xmm0, %xmm0
movups %xmm0, 0x90(%r14)
movups %xmm0, 0x80(%r14)
movups %xmm0, 0x70(%r14)
movups %xmm0, 0x60(%r14)
movups %xmm0, 0x50(%r14)
movq $0x0, 0xa0(%r14)
addq $0xa8, %r14
decq %r12
jne 0x24116
jmp 0x240c1