// File: /workspace/github_c_makefile_star2_O2/zhou-yuxin[P]redis-aof-no-cow/deps/jemalloc/src/jemalloc.c
// Function: je_arena_tdata_get_hard
arena_tdata_t *
arena_tdata_get_hard(tsd_t *tsd, unsigned ind)
{
	arena_tdata_t *tdata, *arenas_tdata_old;
	arena_tdata_t *arenas_tdata = tsd_arenas_tdata_get(tsd);
	unsigned narenas_tdata_old, i;
	unsigned narenas_tdata = tsd_narenas_tdata_get(tsd);
	unsigned narenas_actual = narenas_total_get();

	/*
	 * Dissociate old tdata array (and set up for deallocation upon return)
	 * if it's too small.
	 */
	if (arenas_tdata != NULL && narenas_tdata < narenas_actual) {
		arenas_tdata_old = arenas_tdata;
		narenas_tdata_old = narenas_tdata;
		arenas_tdata = NULL;
		narenas_tdata = 0;
		tsd_arenas_tdata_set(tsd, arenas_tdata);
		tsd_narenas_tdata_set(tsd, narenas_tdata);
	} else {
		arenas_tdata_old = NULL;
		narenas_tdata_old = 0;
	}

	/* Allocate tdata array if it's missing. */
	if (arenas_tdata == NULL) {
		bool *arenas_tdata_bypassp = tsd_arenas_tdata_bypassp_get(tsd);
		narenas_tdata = (ind < narenas_actual) ? narenas_actual : ind+1;

		if (tsd_nominal(tsd) && !*arenas_tdata_bypassp) {
			*arenas_tdata_bypassp = true;
			arenas_tdata = (arena_tdata_t *)a0malloc(
			    sizeof(arena_tdata_t) * narenas_tdata);
			*arenas_tdata_bypassp = false;
		}
		if (arenas_tdata == NULL) {
			tdata = NULL;
			goto label_return;
		}
		assert(tsd_nominal(tsd) && !*arenas_tdata_bypassp);
		tsd_arenas_tdata_set(tsd, arenas_tdata);
		tsd_narenas_tdata_set(tsd, narenas_tdata);
	}

	/*
	 * Copy to tdata array.  It's possible that the actual number of arenas
	 * has increased since narenas_total_get() was called above, but that
	 * causes no correctness issues unless two threads concurrently execute
	 * the arenas.extend mallctl, which we trust mallctl synchronization to
	 * prevent.
	 */

	/* Copy/initialize tickers. */
	for (i = 0; i < narenas_actual; i++) {
		if (i < narenas_tdata_old) {
			ticker_copy(&arenas_tdata[i].decay_ticker,
			    &arenas_tdata_old[i].decay_ticker);
		} else {
			ticker_init(&arenas_tdata[i].decay_ticker,
			    DECAY_NTICKS_PER_UPDATE);
		}
	}
	if (narenas_tdata > narenas_actual) {
		memset(&arenas_tdata[narenas_actual], 0, sizeof(arena_tdata_t)
		    * (narenas_tdata - narenas_actual));
	}

	/* Read the refreshed tdata array. */
	tdata = &arenas_tdata[ind];
label_return:
	if (arenas_tdata_old != NULL)
		a0dalloc(arenas_tdata_old);
	return (tdata);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %esi, %r8d
movq %rdi, %r13
movq 0x38(%rdi), %r12
movl 0x40(%rdi), %r15d
xorl %ebp, %ebp
lock
xaddl %ebp, 0x35907(%rip)     # 0x48540
testq %r12, %r12
setne %al
cmpl %ebp, %r15d
setb %cl
andb %al, %cl
cmpb $0x1, %cl
jne 0x12c5e
movl %r15d, %r14d
andq $0x0, 0x38(%r13)
andl $0x0, 0x40(%r13)
movq %r12, %rbx
jmp 0x12c6b
xorl %r14d, %r14d
movl $0x0, %ebx
testq %r12, %r12
jne 0x12cb2
leal 0x1(%r8), %r15d
cmpl %r8d, %ebp
cmoval %ebp, %r15d
cmpl $0x1, (%r13)
jne 0x12cdd
cmpb $0x0, 0x44(%r13)
jne 0x12cdd
movq %r8, (%rsp)
movb $0x1, 0x44(%r13)
movl %r15d, %edi
shlq $0x3, %rdi
callq 0x1283c
movb $0x0, 0x44(%r13)
testq %rax, %rax
je 0x12cdd
movq %rax, %r12
movq %rax, 0x38(%r13)
movl %r15d, 0x40(%r13)
movq (%rsp), %r8
movl %ebp, %eax
xorl %ecx, %ecx
movabsq $0x3e8000003e8, %rdx    # imm = 0x3E8000003E8
cmpq %rcx, %rax
je 0x12ce2
cmpq %r14, %rcx
jae 0x12cd4
movq (%rbx,%rcx,8), %rsi
movq %rsi, (%r12,%rcx,8)
jmp 0x12cd8
movq %rdx, (%r12,%rcx,8)
incq %rcx
jmp 0x12cc0
xorl %r14d, %r14d
jmp 0x12d06
subl %ebp, %r15d
jbe 0x12cff
leaq (%r12,%rax,8), %rdi
shlq $0x3, %r15
xorl %esi, %esi
movq %r15, %rdx
movq %r8, %r14
callq 0xb230
movq %r14, %r8
movl %r8d, %eax
leaq (%r12,%rax,8), %r14
testq %rbx, %rbx
je 0x12d13
movq %rbx, %rdi
callq 0x12997
movq %r14, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq