// File: /workspace/github_c_makefile_star2_O1/erikdubbelboer[P]discnt/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 0x4ee68(%rip), %r13     # 0x83758
movq %r13, %rdi
callq 0x12960
movl 0x4ee82(%rip), %ebp     # 0x83780
movq %r13, %rdi
callq 0x125c0
testq %r14, %r14
je 0x34937
cmpl %ebp, %r15d
jae 0x3493a
movq %r14, %rdi
movl $0x1, %esi
callq 0x3468b
movq $0x0, 0x30(%r12)
movl $0x0, 0x38(%r12)
xorl %r14d, %r14d
xorl %r15d, %r15d
jmp 0x3493a
xorl %r14d, %r14d
testq %r14, %r14
jne 0x349a6
leal 0x1(%rbx), %r15d
cmpl %ebx, %ebp
cmoval %ebp, %r15d
cmpl $0x1, (%r12)
jne 0x3495c
cmpb $0x0, 0x3c(%r12)
je 0x34a38
xorl %r14d, %r14d
testq %r14, %r14
je 0x34970
movq %r14, 0x30(%r12)
movl %r15d, 0x38(%r12)
jmp 0x3499d
cmpl %ebx, %ebp
jbe 0x3499a
leaq 0x4eddd(%rip), %r13     # 0x83758
movq %r13, %rdi
callq 0x12960
movq 0x4edfe(%rip), %rax     # 0x83788
movl %ebx, %ecx
movq (%rax,%rcx,8), %r12
movq %r13, %rdi
callq 0x125c0
jmp 0x3499d
xorl %r12d, %r12d
testq %r14, %r14
je 0x34a26
leaq 0x4edab(%rip), %r12     # 0x83758
movq %r12, %rdi
callq 0x12960
movq 0x4edcc(%rip), %rsi     # 0x83788
leaq (,%rbp,8), %rdx
movq %r14, %rdi
callq 0x12520
movq %r12, %rdi
callq 0x125c0
cmpl %ebp, %r15d
jbe 0x349ee
leaq (%r14,%rbp,8), %rdi
subl %ebp, %r15d
shlq $0x3, %r15
xorl %esi, %esi
movq %r15, %rdx
callq 0x12380
movl %ebx, %r13d
movq (%r14,%r13,8), %r12
cmpb $0x0, 0x4(%rsp)
je 0x34a26
testq %r12, %r12
jne 0x34a26
leaq 0x4ed50(%rip), %r15     # 0x83758
movq %r15, %rdi
callq 0x12960
movl %ebx, %edi
callq 0x347c9
movq %rax, %r12
movq %r15, %rdi
callq 0x125c0
movq %r12, (%r14,%r13,8)
movq %r12, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movb $0x1, 0x3c(%r12)
movl %r15d, %edi
shlq $0x3, %rdi
xorl %esi, %esi
movl $0x1, %edx
callq 0x12b06
movq %rax, %r14
movb $0x0, 0x3c(%r12)
jmp 0x3495f