// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
movq %r9, -0x30(%rbp)
leaq 0x66cd9(%rip), %rdi     # 0x1292d0
callq 0xc19c0
xorl %eax, %eax
movl %eax, %edi
callq 0xc2ae0
movl (%rax), %eax
movl %eax, -0x3c(%rbp)
movl %eax, -0x38(%rbp)
cmpq $0x0, -0x28(%rbp)
je 0xc2630
cmpq $0x4, -0x30(%rbp)
je 0xc2627
movl $0x16, -0x34(%rbp)
jmp 0xc278f
movq -0x28(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x38(%rbp)
jmp 0xc2632
jmp 0xc2634
cmpq $0x0, -0x18(%rbp)
je 0xc26a0
cmpq $0x0, -0x20(%rbp)
je 0xc26a0
movq -0x20(%rbp), %rax
cmpq $0x4, (%rax)
je 0xc2695
movq -0x20(%rbp), %rcx
movl $0x4, %eax
cmpq (%rcx), %rax
ja 0xc2665
movl $0x4, %eax
movq %rax, -0x60(%rbp)
jmp 0xc2670
movq -0x20(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x60(%rbp)
movq -0x60(%rbp), %rax
movq %rax, -0x48(%rbp)
movq -0x18(%rbp), %rdi
movq -0x48(%rbp), %rdx
leaq -0x3c(%rbp), %rsi
callq 0x1fbf0
movl $0x16, -0x34(%rbp)
jmp 0xc278f
movl -0x3c(%rbp), %ecx
movq -0x18(%rbp), %rax
movl %ecx, (%rax)
jmp 0xc26a0
jmp 0xc26a2
movl -0x38(%rbp), %eax
cmpl -0x3c(%rbp), %eax
je 0xc2788
movl -0x38(%rbp), %eax
cmpl 0x66c89(%rip), %eax     # 0x129340
jb 0xc26c5
movl $0xe, -0x34(%rbp)
jmp 0xc278f
leaq 0x65e0c(%rip), %rdi     # 0x1284d8
callq 0xc19c0
leaq 0x65df0(%rip), %rax     # 0x1284c8
movq (%rax), %rax
movl -0x38(%rbp), %ecx
movq (%rax,%rcx,8), %rax
movq %rax, -0x50(%rbp)
cmpq $0x0, %rax
jne 0xc2713
movl -0x38(%rbp), %edi
callq 0xb11a0
movq %rax, -0x50(%rbp)
cmpq $0x0, %rax
jne 0xc2713
leaq 0x65dd3(%rip), %rdi     # 0x1284d8
callq 0xc1d60
movl $0xb, -0x34(%rbp)
jmp 0xc278f
jmp 0xc2715
jmp 0xc2717
leaq 0x65daa(%rip), %rax     # 0x1284c8
movq (%rax), %rax
movl -0x3c(%rbp), %ecx
movq (%rax,%rcx,8), %rax
movl 0x4(%rax), %ecx
addl $-0x1, %ecx
movl %ecx, 0x4(%rax)
leaq 0x65d90(%rip), %rax     # 0x1284c8
movq (%rax), %rax
movl -0x38(%rbp), %ecx
movq (%rax,%rcx,8), %rax
movl 0x4(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x4(%rax)
leaq 0x65d86(%rip), %rdi     # 0x1284d8
callq 0xc1d60
callq 0xc2b30
movq (%rax), %rax
movq %rax, -0x58(%rbp)
cmpq $0x3, %rax
jbe 0xc277f
movq -0x58(%rbp), %rdi
callq 0xd5d30
movq -0x58(%rbp), %rdi
movq -0x50(%rbp), %rsi
callq 0xd5c70
leaq -0x50(%rbp), %rdi
callq 0xc2b50
movl $0x0, -0x34(%rbp)
leaq 0x66b3a(%rip), %rdi     # 0x1292d0
callq 0xc1d60
movl -0x34(%rbp), %eax
addq $0x60, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)