// File: /workspace/github_c_makefile_star2_O3/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 %r14d, %r14d
lock
xaddl %r14d, 0x31734(%rip)    # 0x4c540
testq %r12, %r12
setne %al
cmpl %r14d, %r15d
setb %cl
andb %al, %cl
cmpb $0x1, %cl
jne 0x1ae37
movl %r15d, %ebp
movq $0x0, 0x38(%r13)
movl $0x0, 0x40(%r13)
movq %r12, %rbx
jmp 0x1ae43
xorl %ebp, %ebp
movl $0x0, %ebx
testq %r12, %r12
jne 0x1ae99
leal 0x1(%r8), %r15d
cmpl %r8d, %r14d
cmoval %r14d, %r15d
cmpl $0x1, (%r13)
jne 0x1aeee
cmpb $0x0, 0x44(%r13)
jne 0x1aeee
movq %r8, (%rsp)
movb $0x1, 0x44(%r13)
movl %r15d, %edi
shlq $0x3, %rdi
xorl %esi, %esi
movl $0x1, %edx
callq 0x1aa11
movb $0x0, 0x44(%r13)
testq %rax, %rax
je 0x1aeee
movq %rax, %r12
movq %rax, 0x38(%r13)
movl %r15d, 0x40(%r13)
movq (%rsp), %r8
movl %r14d, %eax
testl %r14d, %r14d
je 0x1aec8
xorl %ecx, %ecx
movabsq $0x3e8000003e8, %rdx    # imm = 0x3E8000003E8
cmpq %rbp, %rcx
jae 0x1aebc
movq (%rbx,%rcx,8), %rsi
movq %rsi, (%r12,%rcx,8)
jmp 0x1aec0
movq %rdx, (%r12,%rcx,8)
incq %rcx
cmpq %rcx, %rax
jne 0x1aead
subl %r14d, %r15d
jbe 0x1aee5
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
jmp 0x1aef1
xorl %r14d, %r14d
testq %rbx, %rbx
je 0x1af03
movq %rbx, %rdi
movl $0x1, %esi
callq 0x1ab77
movq %r14, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq