// File: /workspace/github_c_makefile_star2_O2/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 0x2a482(%rip), %eax     # 0x485d4
shlq $0x5, %rax
movl 0x2ae5c(%rip), %ecx     # 0x48fb8
imulq $0x18, %rcx, %rcx
leaq (%rax,%rcx), %rsi
addq $0x2980, %rsi           # imm = 0x2980
callq 0x20d5c
testq %rax, %rax
je 0x1e350
movq %rax, %rbx
movl %ebp, (%rax)
andq $0x0, 0x4(%rax)
leaq 0x10(%rax), %rdi
leaq 0x18cc2(%rip), %rsi     # 0x36e50
pushq $0x8
popq %rdx
callq 0x2941c
testb %al, %al
jne 0x1e350
xorps %xmm0, %xmm0
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 0x2a3f4(%rip), %edx     # 0x485d4
shlq $0x5, %rdx
xorl %r14d, %r14d
xorl %esi, %esi
callq 0xb230
movl 0x2a3e0(%rip), %eax     # 0x485d4
shlq $0x5, %rax
leaq (%rax,%rbx), %rdi
addq $0x2980, %rdi           # imm = 0x2980
movq %rdi, 0xd8(%rbx)
movl 0x2ada8(%rip), %eax     # 0x48fb8
imulq $0x18, %rax, %rdx
xorl %esi, %esi
callq 0xb230
andq $0x0, 0xe0(%rbx)
movq %rbx, 0xf0(%rbx)
callq 0x22118
movl %eax, 0xf8(%rbx)
xorps %xmm0, %xmm0
movups %xmm0, 0x100(%rbx)
andq $0x0, 0x110(%rbx)
lock
xaddq %r14, 0x2ad58(%rip)     # 0x48fa8
movq %r14, 0x118(%rbx)
movb $0x0, 0x120(%rbx)
movups %xmm0, 0x128(%rbx)
movl $0x463, %eax            # imm = 0x463
cmpq $0x52a, %rax            # imm = 0x52A
je 0x1e27c
andq $0x0, (%rbx,%rax,8)
incq %rax
jmp 0x1e26a
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, 0x2a323(%rip)     # 0x485d0
jne 0x1e2c2
xorl %esi, %esi
lock
xaddq %rsi, 0x2acf6(%rip)     # 0x48fb0
movq %rbx, %rdi
callq 0x1aa40
andq $0x0, 0x828(%rbx)
leaq 0x830(%rbx), %rdi
leaq 0x18b7e(%rip), %rsi     # 0x36e56
pushq $-0x1
popq %rdx
callq 0x2941c
testb %al, %al
jne 0x1e350
leaq 0x880(%rbx), %rdi
callq 0x26b08
leaq 0x888(%rbx), %rdi
callq 0x2765b
leaq 0x890(%rbx), %rdi
callq 0x26b08
leaq 0x898(%rbx), %rdi
callq 0x2765b
leaq 0x8a0(%rbx), %rdi
leaq 0x18b3f(%rip), %rsi     # 0x36e61
pushq $0x9
popq %rdx
callq 0x2941c
testb %al, %al
jne 0x1e350
andq $0x0, 0x8f0(%rbx)
leaq 0x8f8(%rbx), %rdi
leaq 0x18b2a(%rip), %rsi     # 0x36e6e
pushq $0xa
popq %rdx
callq 0x2941c
testb %al, %al
je 0x1e35e
xorl %ebx, %ebx
movq %rbx, %rax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
leaq 0x27f3b(%rip), %rax     # 0x462a0
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
pushq $0x27
popq %r12
leaq 0x18ada(%rip), %r15     # 0x36e7f
pushq $-0x1
popq %rbp
subq $0x1, %r12
jb 0x1e352
movq %r14, %rdi
movq %r15, %rsi
movl %ebp, %edx
callq 0x2941c
testb %al, %al
jne 0x1e350
xorps %xmm0, %xmm0
movups %xmm0, 0x90(%r14)
movups %xmm0, 0x80(%r14)
movups %xmm0, 0x70(%r14)
movups %xmm0, 0x60(%r14)
movups %xmm0, 0x50(%r14)
andq $0x0, 0xa0(%r14)
addq $0xa8, %r14
jmp 0x1e3a8