// File: /workspace/github_c_makefile_star2_O2/gplessis[P]dotdeb-redis/deps/jemalloc/src/jemalloc.c
// Function: je_arena_get_hard
arena_t *
arena_get_hard(tsd_t *tsd, unsigned ind, bool init_if_missing)
{
	arena_t *arena;
	arena_t **arenas_cache = tsd_arenas_cache_get(tsd);
	unsigned narenas_cache = tsd_narenas_cache_get(tsd);
	unsigned narenas_actual = narenas_total_get();

	/* Deallocate old cache if it's too small. */
	if (arenas_cache != NULL && narenas_cache < narenas_actual) {
		a0dalloc(arenas_cache);
		arenas_cache = NULL;
		narenas_cache = 0;
		tsd_arenas_cache_set(tsd, arenas_cache);
		tsd_narenas_cache_set(tsd, narenas_cache);
	}

	/* Allocate cache if it's missing. */
	if (arenas_cache == NULL) {
		bool *arenas_cache_bypassp = tsd_arenas_cache_bypassp_get(tsd);
		assert(ind < narenas_actual || !init_if_missing);
		narenas_cache = (ind < narenas_actual) ? narenas_actual : ind+1;

		if (tsd_nominal(tsd) && !*arenas_cache_bypassp) {
			*arenas_cache_bypassp = true;
			arenas_cache = (arena_t **)a0malloc(sizeof(arena_t *) *
			    narenas_cache);
			*arenas_cache_bypassp = false;
		}
		if (arenas_cache == NULL) {
			/*
			 * This function must always tell the truth, even if
			 * it's slow, so don't let OOM, thread cleanup (note
			 * tsd_nominal check), nor recursive allocation
			 * avoidance (note arenas_cache_bypass check) get in the
			 * way.
			 */
			if (ind >= narenas_actual)
				return (NULL);
			malloc_mutex_lock(&arenas_lock);
			arena = arenas[ind];
			malloc_mutex_unlock(&arenas_lock);
			return (arena);
		}
		assert(tsd_nominal(tsd) && !*arenas_cache_bypassp);
		tsd_arenas_cache_set(tsd, arenas_cache);
		tsd_narenas_cache_set(tsd, narenas_cache);
	}

	/*
	 * Copy to cache.  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.
	 */
	malloc_mutex_lock(&arenas_lock);
	memcpy(arenas_cache, arenas, sizeof(arena_t *) * narenas_actual);
	malloc_mutex_unlock(&arenas_lock);
	if (narenas_cache > narenas_actual) {
		memset(&arenas_cache[narenas_actual], 0, sizeof(arena_t *) *
		    (narenas_cache - narenas_actual));
	}

	/* Read the refreshed cache, and init the arena if necessary. */
	arena = arenas_cache[ind];
	if (init_if_missing && arena == NULL)
		arena = arenas_cache[ind] = arena_init(ind);
	return (arena);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %edx, %ebp
movl %esi, %ebx
movq %rdi, %r13
movq 0x30(%rdi), %r14
movl 0x38(%rdi), %r15d
callq 0x1c653
movl %eax, %r12d
testq %r14, %r14
je 0x1c742
cmpl %r12d, %r15d
jae 0x1c7b6
movq %r14, %rdi
callq 0x1c41b
andq $0x0, 0x30(%r13)
andl $0x0, 0x38(%r13)
leal 0x1(%rbx), %r15d
cmpl %ebx, %r12d
cmoval %r12d, %r15d
cmpl $0x1, (%r13)
jne 0x1c787
cmpb $0x0, 0x3c(%r13)
jne 0x1c787
movb $0x1, 0x3c(%r13)
movl %r15d, %edi
shlq $0x3, %rdi
callq 0x1c2a0
movb $0x0, 0x3c(%r13)
testq %rax, %rax
je 0x1c787
movq %rax, %r14
movl %ebp, 0x4(%rsp)
movq %rax, 0x30(%r13)
movl %r15d, 0x38(%r13)
jmp 0x1c7ba
cmpl %ebx, %r12d
jbe 0x1c825
leaq 0x39eb1(%rip), %r14     # 0x56648
movq %r14, %rdi
callq 0x106d0
movq 0x39ed2(%rip), %rax     # 0x56678
movl %ebx, %ecx
movq (%rax,%rcx,8), %r15
movq %r14, %rdi
callq 0x10440
jmp 0x1c828
movl %ebp, 0x4(%rsp)
leaq 0x39e87(%rip), %r13     # 0x56648
movq %r13, %rdi
callq 0x106d0
movq 0x39ea8(%rip), %rsi     # 0x56678
movl %r12d, %ebp
leaq (,%rbp,8), %rdx
movq %r14, %rdi
callq 0x10400
movq %r13, %rdi
callq 0x10440
subl %r12d, %r15d
jbe 0x1c802
leaq (%r14,%rbp,8), %rdi
shlq $0x3, %r15
xorl %esi, %esi
movq %r15, %rdx
callq 0x10270
movl %ebx, %r12d
movq (%r14,%r12,8), %r15
cmpb $0x0, 0x4(%rsp)
je 0x1c828
testq %r15, %r15
jne 0x1c828
movl %ebx, %edi
callq 0x1c564
movq %rax, %r15
movq %rax, (%r14,%r12,8)
jmp 0x1c828
xorl %r15d, %r15d
movq %r15, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq