// File: /workspace/github_c_makefile_star2_O1/nilyang[P]redis-tdd-annotation/deps/jemalloc/src/ctl.c
// Function: thread_arena_ctl
static int
thread_arena_ctl(const size_t *mib, size_t miblen, void *oldp, size_t *oldlenp,
    void *newp, size_t newlen)
{
	int ret;
	unsigned newind, oldind;

	malloc_mutex_lock(&ctl_mtx);
	newind = oldind = choose_arena(NULL)->ind;
	WRITE(newind, unsigned);
	READ(oldind, unsigned);
	if (newind != oldind) {
		arena_t *arena;

		if (newind >= ctl_stats.narenas) {
			/* New arena index is out of range. */
			ret = EFAULT;
			goto label_return;
		}

		/* Initialize arena if necessary. */
		malloc_mutex_lock(&arenas_lock);
		if ((arena = arenas[newind]) == NULL && (arena =
		    arenas_extend(newind)) == NULL) {
			malloc_mutex_unlock(&arenas_lock);
			ret = EAGAIN;
			goto label_return;
		}
		assert(arena == arenas[newind]);
		arenas[oldind]->nthreads--;
		arenas[newind]->nthreads++;
		malloc_mutex_unlock(&arenas_lock);

		/* Set new arena association. */
		if (config_tcache) {
			tcache_t *tcache;
			if ((uintptr_t)(tcache = *tcache_tsd_get()) >
			    (uintptr_t)TCACHE_STATE_MAX) {
				tcache_arena_dissociate(tcache);
				tcache_arena_associate(tcache, arena);
			}
		}
		arenas_tsd_set(&arena);
	}

	ret = 0;
label_return:
	malloc_mutex_unlock(&ctl_mtx);
	return (ret);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %r9, %r12
movq %r8, %r15
movq %rcx, %r14
movq %rdx, %rbx
leaq 0x59203(%rip), %rdi     # 0xdf980
callq 0x1faa0
movq 0x3f7af(%rip), %rdx     # 0xc5f38
movq %fs:(%rdx), %rax
testq %rax, %rax
jne 0x8679d
movq %rdx, %r13
callq 0x7c332
movq %r13, %rdx
movl (%rax), %r13d
movl %r13d, 0x4(%rsp)
movl %r13d, %ebp
testq %r15, %r15
je 0x867bf
movl $0x16, %ebp
cmpq $0x4, %r12
jne 0x868db
movl (%r15), %ebp
testq %rbx, %rbx
sete %al
testq %r14, %r14
sete %cl
orb %al, %cl
jne 0x867df
movq (%r14), %rax
cmpq $0x4, %rax
jne 0x868af
movl %r13d, (%rbx)
cmpl %r13d, %ebp
je 0x868d9
cmpl 0x59202(%rip), %ebp     # 0xdf9f0
jae 0x868cc
movq %rdx, %r12
leaq 0x5838a(%rip), %rdi     # 0xdeb88
callq 0x1faa0
leaq 0x5836e(%rip), %r15     # 0xdeb78
movq (%r15), %rax
movl %ebp, %r14d
movq (%rax,%r14,8), %rbx
testq %rbx, %rbx
jne 0x8682c
movl %ebp, %edi
callq 0x7c2d0
movq %rax, %rbx
testq %rax, %rax
je 0x868f8
movq (%r15), %rax
movq (%rax,%r13,8), %rcx
decl 0x4(%rcx)
movq (%rax,%r14,8), %rax
incl 0x4(%rax)
leaq 0x58344(%rip), %rdi     # 0xdeb88
callq 0x1fbb0
movq 0x3f708(%rip), %rax     # 0xc5f58
movq %fs:(%rax), %r14
cmpq $0x4, %r14
jb 0x8686d
movq %r14, %rdi
callq 0x90cb8
movq %r14, %rdi
movq %rbx, %rsi
callq 0x90c66
movq %fs:0x0, %rsi
addq %r12, %rsi
movq %rbx, %fs:(%r12)
leaq 0x5832f(%rip), %rax     # 0xdebb4
movl (%rax), %edi
callq 0x1f1c0
movb $0x1, %bl
testl %eax, %eax
je 0x868d5
leaq 0x1c661(%rip), %rdi     # 0xa2efa
callq 0x9124c
leaq 0x582b5(%rip), %rax     # 0xdeb5a
cmpb $0x1, (%rax)
jne 0x868d5
callq 0x1f1b0
movl $0x4, %edx
cmovbq %rax, %rdx
leaq 0x4(%rsp), %rsi
movq %rbx, %rdi
callq 0x1fbd0
movl $0x16, %ebp
jmp 0x868db
movl $0xe, %ebp
xorl %ebx, %ebx
jmp 0x868d5
testb %bl, %bl
je 0x868db
xorl %ebp, %ebp
leaq 0x5909e(%rip), %rdi     # 0xdf980
callq 0x1fbb0
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x58289(%rip), %rdi     # 0xdeb88
callq 0x1fbb0
movl $0xb, %ebp
jmp 0x868d1