// File: /workspace/github_c_makefile_star2_O3/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, 0x4(%rsp)
movl %esi, %ebx
movq %rdi, %r12
movq 0x30(%rdi), %r14
movl 0x38(%rdi), %r15d
leaq 0x38669(%rip), %r13     # 0x5a648
movq %r13, %rdi
callq 0x106d0
movl 0x38683(%rip), %ebp     # 0x5a670
movq %r13, %rdi
callq 0x10440
testq %r14, %r14
je 0x2201e
cmpl %ebp, %r15d
jae 0x22074
movq %r14, %rdi
movl $0x1, %esi
callq 0x21cca
movq $0x0, 0x30(%r12)
movl $0x0, 0x38(%r12)
leal 0x1(%rbx), %r15d
cmpl %ebx, %ebp
cmoval %ebp, %r15d
cmpl $0x1, (%r12)
jne 0x220f6
cmpb $0x0, 0x3c(%r12)
jne 0x220f6
movb $0x1, 0x3c(%r12)
movl %r15d, %edi
shlq $0x3, %rdi
xorl %esi, %esi
movl $0x1, %edx
callq 0x21b5d
movb $0x0, 0x3c(%r12)
testq %rax, %rax
je 0x220f6
movq %rax, %r14
movq %rax, 0x30(%r12)
movl %r15d, 0x38(%r12)
leaq 0x385cd(%rip), %r12     # 0x5a648
movq %r12, %rdi
callq 0x106d0
movq 0x385ee(%rip), %rsi     # 0x5a678
leaq (,%rbp,8), %rdx
movq %r14, %rdi
callq 0x10400
movq %r12, %rdi
callq 0x10440
cmpl %ebp, %r15d
jbe 0x220bc
leaq (%r14,%rbp,8), %rdi
subl %ebp, %r15d
shlq $0x3, %r15
xorl %esi, %esi
movq %r15, %rdx
callq 0x10270
movl %ebx, %r13d
movq (%r14,%r13,8), %r15
cmpb $0x0, 0x4(%rsp)
je 0x22123
testq %r15, %r15
jne 0x22123
leaq 0x38572(%rip), %r12     # 0x5a648
movq %r12, %rdi
callq 0x106d0
movl %ebx, %edi
callq 0x21e39
movq %rax, %r15
movq %r12, %rdi
callq 0x10440
movq %r15, (%r14,%r13,8)
jmp 0x22123
cmpl %ebx, %ebp
jbe 0x22120
leaq 0x38547(%rip), %r14     # 0x5a648
movq %r14, %rdi
callq 0x106d0
movq 0x38568(%rip), %rax     # 0x5a678
movl %ebx, %ecx
movq (%rax,%rcx,8), %r15
movq %r14, %rdi
callq 0x10440
jmp 0x22123
xorl %r15d, %r15d
movq %r15, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq