// File: /workspace/github_c_makefile_star2_O0/nilyang[P]redis-tdd-annotation/deps/jemalloc/src/jemalloc.c
// Function: choose_arena_hard
arena_t *
choose_arena_hard(void)
{
	arena_t *ret;

	if (narenas_auto > 1) {
		unsigned i, choose, first_null;

		choose = 0;
		first_null = narenas_auto;
		malloc_mutex_lock(&arenas_lock);
		assert(arenas[0] != NULL);
		for (i = 1; i < narenas_auto; i++) {
			if (arenas[i] != NULL) {
				/*
				 * Choose the first arena that has the lowest
				 * number of threads assigned to it.
				 */
				if (arenas[i]->nthreads <
				    arenas[choose]->nthreads)
					choose = i;
			} else if (first_null == narenas_auto) {
				/*
				 * Record the index of the first uninitialized
				 * arena, in case all extant arenas are in use.
				 *
				 * NB: It is possible for there to be
				 * discontinuities in terms of initialized
				 * versus uninitialized arenas, due to the
				 * "thread.arena" mallctl.
				 */
				first_null = i;
			}
		}

		if (arenas[choose]->nthreads == 0
		    || first_null == narenas_auto) {
			/*
			 * Use an unloaded arena, or the least loaded arena if
			 * all arenas are already initialized.
			 */
			ret = arenas[choose];
		} else {
			/* Initialize a new arena. */
			ret = arenas_extend(first_null);
		}
		ret->nthreads++;
		malloc_mutex_unlock(&arenas_lock);
	} else {
		ret = arenas[0];
		malloc_mutex_lock(&arenas_lock);
		ret->nthreads++;
		malloc_mutex_unlock(&arenas_lock);
	}

	arenas_tsd_set(&ret);

	return (ret);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
cmpl $0x1, 0x77291(%rip)     # 0x1284d0
jbe 0xb132c
movl $0x0, -0x10(%rbp)
movl 0x7727e(%rip), %eax     # 0x1284d0
movl %eax, -0x14(%rbp)
leaq 0x7727c(%rip), %rdi     # 0x1284d8
callq 0xb1380
jmp 0xb1263
movl $0x1, -0xc(%rbp)
movl -0xc(%rbp), %eax
cmpl 0x7725d(%rip), %eax     # 0x1284d0
jae 0xb12d2
movq 0x7724c(%rip), %rax     # 0x1284c8
movl -0xc(%rbp), %ecx
cmpq $0x0, (%rax,%rcx,8)
je 0xb12b2
movq 0x7723b(%rip), %rax     # 0x1284c8
movl -0xc(%rbp), %ecx
movq (%rax,%rcx,8), %rax
movl 0x4(%rax), %eax
movq 0x7722a(%rip), %rcx     # 0x1284c8
movl -0x10(%rbp), %edx
movq (%rcx,%rdx,8), %rcx
cmpl 0x4(%rcx), %eax
jae 0xb12b0
movl -0xc(%rbp), %eax
movl %eax, -0x10(%rbp)
jmp 0xb12c5
movl -0x14(%rbp), %eax
cmpl 0x77215(%rip), %eax     # 0x1284d0
jne 0xb12c3
movl -0xc(%rbp), %eax
movl %eax, -0x14(%rbp)
jmp 0xb12c5
jmp 0xb12c7
movl -0xc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc(%rbp)
jmp 0xb126a
movq 0x771ef(%rip), %rax     # 0x1284c8
movl -0x10(%rbp), %ecx
movq (%rax,%rcx,8), %rax
cmpl $0x0, 0x4(%rax)
je 0xb12f1
movl -0x14(%rbp), %eax
cmpl 0x771e1(%rip), %eax     # 0x1284d0
jne 0xb1305
movq 0x771d0(%rip), %rax     # 0x1284c8
movl -0x10(%rbp), %ecx
movq (%rax,%rcx,8), %rax
movq %rax, -0x8(%rbp)
jmp 0xb1311
movl -0x14(%rbp), %edi
callq 0xb11a0
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
movl 0x4(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x4(%rax)
leaq 0x771b3(%rip), %rdi     # 0x1284d8
callq 0xb13a0
jmp 0xb135f
movq 0x77195(%rip), %rax     # 0x1284c8
movq (%rax), %rax
movq %rax, -0x8(%rbp)
leaq 0x77197(%rip), %rdi     # 0x1284d8
callq 0xb1380
movq -0x8(%rbp), %rax
movl 0x4(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x4(%rax)
leaq 0x7717e(%rip), %rdi     # 0x1284d8
callq 0xb13a0
leaq -0x8(%rbp), %rdi
callq 0xb13c0
movq -0x8(%rbp), %rax
addq $0x20, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)