// File: /workspace/github_c_makefile_star2_O1/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), %eax
xorl %r15d, %r15d
xorl %ebp, %ebp
lock
xaddl %ebp, 0x31579(%rip)     # 0x4c540
testq %r12, %r12
setne %cl
cmpl %ebp, %eax
setb %dl
andb %cl, %dl
cmpb $0x1, %dl
jne 0x1aff3
movl %eax, %ebx
movq $0x0, 0x38(%r13)
movl $0x0, 0x40(%r13)
movq %r12, %r14
xorl %r12d, %r12d
jmp 0x1affb
xorl %r14d, %r14d
xorl %ebx, %ebx
movl %eax, %r15d
testq %r12, %r12
jne 0x1b02d
leal 0x1(%r8), %r15d
cmpl %r8d, %ebp
cmoval %ebp, %r15d
cmpl $0x1, (%r13)
jne 0x1b01d
cmpb $0x0, 0x44(%r13)
je 0x1b0a6
xorl %r12d, %r12d
testq %r12, %r12
je 0x1b0a2
movq %r12, 0x38(%r13)
movl %r15d, 0x40(%r13)
movl %ebp, %eax
testl %ebp, %ebp
je 0x1b05a
xorl %ecx, %ecx
movabsq $0x3e8000003e8, %rdx    # imm = 0x3E8000003E8
cmpq %rbx, %rcx
jae 0x1b04e
movq (%r14,%rcx,8), %rsi
movq %rsi, (%r12,%rcx,8)
jmp 0x1b052
movq %rdx, (%r12,%rcx,8)
incq %rcx
cmpq %rcx, %rax
jne 0x1b03f
subl %ebp, %r15d
jbe 0x1b077
leaq (%r12,%rax,8), %rdi
shlq $0x3, %r15
xorl %esi, %esi
movq %r15, %rdx
movq %r8, %rbx
callq 0xb230
movq %rbx, %r8
movl %r8d, %eax
leaq (%r12,%rax,8), %rbx
testq %r14, %r14
je 0x1b090
movq %r14, %rdi
movl $0x1, %esi
callq 0x1ad63
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
xorl %ebx, %ebx
jmp 0x1b07e
movb $0x1, 0x44(%r13)
movl %r15d, %edi
shlq $0x3, %rdi
xorl %esi, %esi
movl $0x1, %edx
movq %r8, %r12
callq 0xb758
movq %r12, %r8
movq %rax, %r12
movb $0x0, 0x44(%r13)
jmp 0x1b020