// File: /workspace/github_c_makefile_star2_O0/zhou-yuxin[P]redis-aof-no-cow/deps/jemalloc/src/jemalloc.c
// Function: je_arena_choose_hard
arena_t *
arena_choose_hard(tsd_t *tsd, bool internal)
{
	arena_t *ret JEMALLOC_CC_SILENCE_INIT(NULL);

	if (narenas_auto > 1) {
		unsigned i, j, choose[2], first_null;

		/*
		 * Determine binding for both non-internal and internal
		 * allocation.
		 *
		 *   choose[0]: For application allocation.
		 *   choose[1]: For internal metadata allocation.
		 */

		for (j = 0; j < 2; j++)
			choose[j] = 0;

		first_null = narenas_auto;
		malloc_mutex_lock(tsd_tsdn(tsd), &arenas_lock);
		assert(arena_get(tsd_tsdn(tsd), 0, false) != NULL);
		for (i = 1; i < narenas_auto; i++) {
			if (arena_get(tsd_tsdn(tsd), i, false) != NULL) {
				/*
				 * Choose the first arena that has the lowest
				 * number of threads assigned to it.
				 */
				for (j = 0; j < 2; j++) {
					if (arena_nthreads_get(arena_get(
					    tsd_tsdn(tsd), i, false), !!j) <
					    arena_nthreads_get(arena_get(
					    tsd_tsdn(tsd), choose[j], false),
					    !!j))
						choose[j] = 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;
			}
		}

		for (j = 0; j < 2; j++) {
			if (arena_nthreads_get(arena_get(tsd_tsdn(tsd),
			    choose[j], false), !!j) == 0 || first_null ==
			    narenas_auto) {
				/*
				 * Use an unloaded arena, or the least loaded
				 * arena if all arenas are already initialized.
				 */
				if (!!j == internal) {
					ret = arena_get(tsd_tsdn(tsd),
					    choose[j], false);
				}
			} else {
				arena_t *arena;

				/* Initialize a new arena. */
				choose[j] = first_null;
				arena = arena_init_locked(tsd_tsdn(tsd),
				    choose[j]);
				if (arena == NULL) {
					malloc_mutex_unlock(tsd_tsdn(tsd),
					    &arenas_lock);
					return (NULL);
				}
				if (!!j == internal)
					ret = arena;
			}
			arena_bind(tsd, choose[j], !!j);
		}
		malloc_mutex_unlock(tsd_tsdn(tsd), &arenas_lock);
	} else {
		ret = arena_get(tsd_tsdn(tsd), 0, false);
		arena_bind(tsd, 0, false);
		arena_bind(tsd, 0, true);
	}

	return (ret);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xa0, %rsp
movb %sil, %al
movq %rdi, -0x60(%rbp)
andb $0x1, %al
movb %al, -0x61(%rbp)
movq $0x0, -0x70(%rbp)
cmpl $0x1, 0x890f2(%rip)     # 0xa3578
jbe 0x1a73a
movl $0x0, -0x78(%rbp)
cmpl $0x2, -0x78(%rbp)
jae 0x1a4af
movl -0x78(%rbp), %eax
movl $0x0, -0x80(%rbp,%rax,4)
movl -0x78(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x78(%rbp)
jmp 0x1a493
movl 0x890c3(%rip), %eax     # 0xa3578
movl %eax, -0x84(%rbp)
movq -0x60(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rdi
leaq 0x8905a(%rip), %rsi     # 0xa3528
callq 0x19ee0
jmp 0x1a4d5
movl $0x1, -0x74(%rbp)
movl -0x74(%rbp), %eax
cmpl 0x89093(%rip), %eax     # 0xa3578
jae 0x1a5d5
movq -0x60(%rbp), %rax
movq %rax, -0x10(%rbp)
movq -0x10(%rbp), %rdi
movl -0x74(%rbp), %esi
xorl %edx, %edx
callq 0x1a080
cmpq $0x0, %rax
je 0x1a5ac
movl $0x0, -0x78(%rbp)
cmpl $0x2, -0x78(%rbp)
jae 0x1a5aa
movq -0x60(%rbp), %rax
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rdi
movl -0x74(%rbp), %esi
xorl %edx, %edx
callq 0x1a080
movq %rax, %rdi
cmpl $0x0, -0x78(%rbp)
setne %al
xorb $-0x1, %al
xorb $-0x1, %al
movzbl %al, %esi
andl $0x1, %esi
callq 0x43440
movl %eax, -0x94(%rbp)
movq -0x60(%rbp), %rax
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rdi
movl -0x78(%rbp), %eax
movl -0x80(%rbp,%rax,4), %esi
xorl %edx, %edx
callq 0x1a080
movq %rax, %rdi
cmpl $0x0, -0x78(%rbp)
setne %al
xorb $-0x1, %al
xorb $-0x1, %al
movzbl %al, %esi
andl $0x1, %esi
callq 0x43440
movl %eax, %ecx
movl -0x94(%rbp), %eax
cmpl %ecx, %eax
jae 0x1a59a
movl -0x74(%rbp), %ecx
movl -0x78(%rbp), %eax
movl %ecx, -0x80(%rbp,%rax,4)
jmp 0x1a59c
movl -0x78(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x78(%rbp)
jmp 0x1a512
jmp 0x1a5c5
movl -0x84(%rbp), %eax
cmpl 0x88fc0(%rip), %eax     # 0xa3578
jne 0x1a5c3
movl -0x74(%rbp), %eax
movl %eax, -0x84(%rbp)
jmp 0x1a5c5
jmp 0x1a5c7
movl -0x74(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x74(%rbp)
jmp 0x1a4dc
movl $0x0, -0x78(%rbp)
cmpl $0x2, -0x78(%rbp)
jae 0x1a720
movq -0x60(%rbp), %rax
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rdi
movl -0x78(%rbp), %eax
movl -0x80(%rbp,%rax,4), %esi
xorl %edx, %edx
callq 0x1a080
movq %rax, %rdi
cmpl $0x0, -0x78(%rbp)
setne %al
xorb $-0x1, %al
xorb $-0x1, %al
movzbl %al, %esi
andl $0x1, %esi
callq 0x43440
cmpl $0x0, %eax
je 0x1a62c
movl -0x84(%rbp), %eax
cmpl 0x88f4e(%rip), %eax     # 0xa3578
jne 0x1a66c
cmpl $0x0, -0x78(%rbp)
setne %al
xorb $-0x1, %al
xorb $-0x1, %al
andb $0x1, %al
movzbl %al, %eax
movb -0x61(%rbp), %cl
andb $0x1, %cl
movzbl %cl, %ecx
cmpl %ecx, %eax
jne 0x1a667
movq -0x60(%rbp), %rax
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rdi
movl -0x78(%rbp), %eax
movl -0x80(%rbp,%rax,4), %esi
xorl %edx, %edx
callq 0x1a080
movq %rax, -0x70(%rbp)
jmp 0x1a6f1
movl -0x84(%rbp), %ecx
movl -0x78(%rbp), %eax
movl %ecx, -0x80(%rbp,%rax,4)
movq -0x60(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rdi
movl -0x78(%rbp), %eax
movl -0x80(%rbp,%rax,4), %esi
callq 0x19f30
movq %rax, -0x90(%rbp)
cmpq $0x0, -0x90(%rbp)
jne 0x1a6c7
movq -0x60(%rbp), %rax
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rdi
leaq 0x88e73(%rip), %rsi     # 0xa3528
callq 0x19fd0
movq $0x0, -0x58(%rbp)
jmp 0x1a778
cmpl $0x0, -0x78(%rbp)
setne %al
xorb $-0x1, %al
xorb $-0x1, %al
andb $0x1, %al
movzbl %al, %eax
movb -0x61(%rbp), %cl
andb $0x1, %cl
movzbl %cl, %ecx
cmpl %ecx, %eax
jne 0x1a6ef
movq -0x90(%rbp), %rax
movq %rax, -0x70(%rbp)
jmp 0x1a6f1
movq -0x60(%rbp), %rdi
movl -0x78(%rbp), %eax
movl -0x80(%rbp,%rax,4), %esi
cmpl $0x0, -0x78(%rbp)
setne %al
xorb $-0x1, %al
xorb $-0x1, %al
movzbl %al, %edx
andl $0x1, %edx
callq 0x1a790
movl -0x78(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x78(%rbp)
jmp 0x1a5dc
movq -0x60(%rbp), %rax
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rdi
leaq 0x88df5(%rip), %rsi     # 0xa3528
callq 0x19fd0
jmp 0x1a770
movq -0x60(%rbp), %rax
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rdi
xorl %edx, %edx
movl %edx, %esi
callq 0x1a080
movq %rax, -0x70(%rbp)
movq -0x60(%rbp), %rdi
xorl %edx, %edx
movl %edx, %esi
callq 0x1a790
movq -0x60(%rbp), %rdi
xorl %esi, %esi
movl $0x1, %edx
callq 0x1a790
movq -0x70(%rbp), %rax
movq %rax, -0x58(%rbp)
movq -0x58(%rbp), %rax
addq $0xa0, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)