// File: /workspace/github_c_makefile_star2_O0/nilyang[P]redis-tdd-annotation/deps/jemalloc/src/jemalloc.c
// Function: je_rallocm
int
je_rallocm(void **ptr, size_t *rsize, size_t size, size_t extra, int flags)
{
	void *p, *q;
	size_t usize;
	size_t old_size;
	size_t old_rzsize JEMALLOC_CC_SILENCE_INIT(0);
	size_t alignment = (ZU(1) << (flags & ALLOCM_LG_ALIGN_MASK)
	    & (SIZE_T_MAX-1));
	bool zero = flags & ALLOCM_ZERO;
	bool no_move = flags & ALLOCM_NO_MOVE;
	unsigned arena_ind = ((unsigned)(flags >> 8)) - 1;
	bool try_tcache_alloc, try_tcache_dalloc;
	arena_t *arena;

	assert(ptr != NULL);
	assert(*ptr != NULL);
	assert(size != 0);
	assert(SIZE_T_MAX - size >= extra);
	assert(malloc_initialized || IS_INITIALIZER);

	if (arena_ind != UINT_MAX) {
		arena_chunk_t *chunk;
		try_tcache_alloc = true;
		chunk = (arena_chunk_t *)CHUNK_ADDR2BASE(*ptr);
		try_tcache_dalloc = (chunk == *ptr || chunk->arena !=
		    arenas[arena_ind]);
		arena = arenas[arena_ind];
	} else {
		try_tcache_alloc = true;
		try_tcache_dalloc = true;
		arena = NULL;
	}

	p = *ptr;
	if (config_prof && opt_prof) {
		prof_thr_cnt_t *cnt;

		/*
		 * usize isn't knowable before iralloc() returns when extra is
		 * non-zero.  Therefore, compute its maximum possible value and
		 * use that in PROF_ALLOC_PREP() to decide whether to capture a
		 * backtrace.  prof_realloc() will use the actual usize to
		 * decide whether to sample.
		 */
		size_t max_usize = (alignment == 0) ? s2u(size+extra) :
		    sa2u(size+extra, alignment);
		prof_ctx_t *old_ctx = prof_ctx_get(p);
		old_size = isalloc(p, true);
		if (config_valgrind && opt_valgrind)
			old_rzsize = p2rz(p);
		PROF_ALLOC_PREP(1, max_usize, cnt);
		if (cnt == NULL)
			goto label_oom;
		/*
		 * Use minimum usize to determine whether promotion may happen.
		 */
		if (prof_promote && (uintptr_t)cnt != (uintptr_t)1U
		    && ((alignment == 0) ? s2u(size) : sa2u(size, alignment))
		    <= SMALL_MAXCLASS) {
			q = irallocx(p, SMALL_MAXCLASS+1, (SMALL_MAXCLASS+1 >=
			    size+extra) ? 0 : size+extra - (SMALL_MAXCLASS+1),
			    alignment, zero, no_move, try_tcache_alloc,
			    try_tcache_dalloc, arena);
			if (q == NULL)
				goto label_err;
			if (max_usize < PAGE) {
				usize = max_usize;
				arena_prof_promoted(q, usize);
			} else
				usize = isalloc(q, config_prof);
		} else {
			q = irallocx(p, size, extra, alignment, zero, no_move,
			    try_tcache_alloc, try_tcache_dalloc, arena);
			if (q == NULL)
				goto label_err;
			usize = isalloc(q, config_prof);
		}
		prof_realloc(q, usize, cnt, old_size, old_ctx);
		if (rsize != NULL)
			*rsize = usize;
	} else {
		if (config_stats) {
			old_size = isalloc(p, false);
			if (config_valgrind && opt_valgrind)
				old_rzsize = u2rz(old_size);
		} else if (config_valgrind && opt_valgrind) {
			old_size = isalloc(p, false);
			old_rzsize = u2rz(old_size);
		}
		q = irallocx(p, size, extra, alignment, zero, no_move,
		    try_tcache_alloc, try_tcache_dalloc, arena);
		if (q == NULL)
			goto label_err;
		if (config_stats)
			usize = isalloc(q, config_prof);
		if (rsize != NULL) {
			if (config_stats == false)
				usize = isalloc(q, config_prof);
			*rsize = usize;
		}
	}

	*ptr = q;
	if (config_stats) {
		thread_allocated_t *ta;
		ta = thread_allocated_tsd_get();
		ta->allocated += usize;
		ta->deallocated += old_size;
	}
	UTRACE(p, size, q);
	JEMALLOC_VALGRIND_REALLOC(q, usize, p, old_size, old_rzsize, zero);
	return (ALLOCM_SUCCESS);
label_err:
	if (no_move) {
		UTRACE(p, size, q);
		return (ALLOCM_ERR_NOT_MOVED);
	}
label_oom:
	if (config_xmalloc && opt_xmalloc) {
		malloc_write("<jemalloc>: Error in rallocm(): "
		    "out of memory\n");
		abort();
	}
	UTRACE(p, size, 0);
	return (ALLOCM_ERR_OOM);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x250, %rsp            # imm = 0x250
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movl %r8d, -0x2c(%rbp)
movq $0x0, -0x58(%rbp)
movl -0x2c(%rbp), %eax
andl $0x3f, %eax
movl %eax, %eax
movl %eax, %ecx
movl $0x1, %eax
shlq %cl, %rax
andq $-0x2, %rax
movq %rax, -0x60(%rbp)
movl -0x2c(%rbp), %eax
andl $0x40, %eax
cmpl $0x0, %eax
setne %al
andb $0x1, %al
movb %al, -0x61(%rbp)
movl -0x2c(%rbp), %eax
andl $0x80, %eax
cmpl $0x0, %eax
setne %al
andb $0x1, %al
movb %al, -0x62(%rbp)
movl -0x2c(%rbp), %eax
sarl $0x8, %eax
subl $0x1, %eax
movl %eax, -0x68(%rbp)
jmp 0xb2903
jmp 0xb2905
jmp 0xb2907
jmp 0xb2909
jmp 0xb290b
jmp 0xb290d
jmp 0xb290f
jmp 0xb2911
jmp 0xb2913
cmpl $-0x1, -0x68(%rbp)
je 0xb298b
movb $0x1, -0x69(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rax
leaq 0x768a5(%rip), %rcx     # 0x1291d0
movq (%rcx), %rcx
xorq $-0x1, %rcx
andq %rcx, %rax
movq %rax, -0x80(%rbp)
movq -0x80(%rbp), %rcx
movq -0x10(%rbp), %rdx
movb $0x1, %al
cmpq (%rdx), %rcx
movb %al, -0x221(%rbp)
je 0xb296c
movq -0x80(%rbp), %rax
movq (%rax), %rax
movq 0x75b6c(%rip), %rcx     # 0x1284c8
movl -0x68(%rbp), %edx
cmpq (%rcx,%rdx,8), %rax
setne %al
movb %al, -0x221(%rbp)
movb -0x221(%rbp), %al
andb $0x1, %al
movb %al, -0x6a(%rbp)
movq 0x75b4a(%rip), %rax     # 0x1284c8
movl -0x68(%rbp), %ecx
movq (%rax,%rcx,8), %rax
movq %rax, -0x78(%rbp)
jmp 0xb299b
movb $0x1, -0x69(%rbp)
movb $0x1, -0x6a(%rbp)
movq $0x0, -0x78(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rdi
xorl %esi, %esi
callq 0xb18e0
movq %rax, -0x50(%rbp)
testb $0x1, 0x75afe(%rip)     # 0x1284ba
je 0xb29cb
movq -0x50(%rbp), %rdi
callq 0xb1fc0
movq %rax, -0x58(%rbp)
movq -0x38(%rbp), %rdi
movq -0x20(%rbp), %rsi
movq -0x28(%rbp), %rdx
movq -0x60(%rbp), %rcx
movb -0x61(%rbp), %r8b
movb -0x62(%rbp), %r9b
movb -0x69(%rbp), %r11b
movb -0x6a(%rbp), %r10b
movq -0x78(%rbp), %rax
andb $0x1, %r8b
andb $0x1, %r9b
andb $0x1, %r11b
andb $0x1, %r10b
movzbl %r8b, %r8d
movzbl %r9b, %r9d
movzbl %r11b, %r11d
movl %r11d, (%rsp)
movzbl %r10b, %r10d
movl %r10d, 0x8(%rsp)
movq %rax, 0x10(%rsp)
callq 0xb2e60
movq %rax, -0x40(%rbp)
cmpq $0x0, -0x40(%rbp)
jne 0xb2a32
jmp 0xb2e34
movq -0x40(%rbp), %rdi
xorl %esi, %esi
callq 0xb18e0
movq %rax, -0x48(%rbp)
cmpq $0x0, -0x18(%rbp)
je 0xb2a53
movq -0x48(%rbp), %rcx
movq -0x18(%rbp), %rax
movq %rcx, (%rax)
movq -0x40(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, (%rax)
callq 0xb16d0
movq %rax, -0x88(%rbp)
movq -0x48(%rbp), %rcx
movq -0x88(%rbp), %rax
addq (%rax), %rcx
movq %rcx, (%rax)
movq -0x50(%rbp), %rcx
movq -0x88(%rbp), %rax
addq 0x8(%rax), %rcx
movq %rcx, 0x8(%rax)
testb $0x1, 0x75a25(%rip)     # 0x1284ba
je 0xb2e29
movq -0x40(%rbp), %rdi
callq 0xb16f0
movq %rax, -0x90(%rbp)
movq -0x40(%rbp), %rax
cmpq -0x38(%rbp), %rax
jne 0xb2bc9
jmp 0xb2abb
movq $0x130b, -0xc0(%rbp) # imm = 0x130B
movq -0x40(%rbp), %rax
movq %rax, -0xb8(%rbp)
movq -0x50(%rbp), %rax
movq %rax, -0xb0(%rbp)
movq -0x48(%rbp), %rax
movq %rax, -0xa8(%rbp)
movq -0x90(%rbp), %rax
movq %rax, -0xa0(%rbp)
movq $0x0, -0x98(%rbp)
leaq -0xc0(%rbp), %rax
xorl %ecx, %ecx
movl %ecx, %edx
rolq $0x3, %rdi
rolq $0xd, %rdi
rolq $0x3d, %rdi
rolq $0x33, %rdi
xchgq %rbx, %rbx
movq %rdx, -0xc8(%rbp)
movq -0xc8(%rbp), %rax
movq %rax, -0xd0(%rbp)
testb $0x1, -0x61(%rbp)
je 0xb2bc4
movq -0x50(%rbp), %rax
cmpq -0x48(%rbp), %rax
jae 0xb2bc4
movq $0x4d430002, -0x100(%rbp) # imm = 0x4D430002
movq -0x40(%rbp), %rax
addq -0x50(%rbp), %rax
movq %rax, -0xf8(%rbp)
movq -0x48(%rbp), %rax
subq -0x50(%rbp), %rax
movq %rax, -0xf0(%rbp)
movq $0x0, -0xe8(%rbp)
movq $0x0, -0xe0(%rbp)
movq $0x0, -0xd8(%rbp)
leaq -0x100(%rbp), %rax
xorl %ecx, %ecx
movl %ecx, %edx
rolq $0x3, %rdi
rolq $0xd, %rdi
rolq $0x3d, %rdi
rolq $0x33, %rdi
xchgq %rbx, %rbx
movq %rdx, -0x108(%rbp)
movq -0x108(%rbp), %rax
movq %rax, -0x110(%rbp)
jmp 0xb2e27
cmpq $0x0, -0x38(%rbp)
je 0xb2c49
jmp 0xb2bd2
movq $0x1302, -0x140(%rbp) # imm = 0x1302
movq -0x38(%rbp), %rax
movq %rax, -0x138(%rbp)
movq -0x58(%rbp), %rax
movq %rax, -0x130(%rbp)
movq $0x0, -0x128(%rbp)
movq $0x0, -0x120(%rbp)
movq $0x0, -0x118(%rbp)
leaq -0x140(%rbp), %rax
xorl %ecx, %ecx
movl %ecx, %edx
rolq $0x3, %rdi
rolq $0xd, %rdi
rolq $0x3d, %rdi
rolq $0x33, %rdi
xchgq %rbx, %rbx
movq %rdx, -0x148(%rbp)
movq -0x148(%rbp), %rax
movq %rax, -0x150(%rbp)
jmp 0xb2c49
cmpq $0x0, -0x40(%rbp)
je 0xb2e25
movq -0x50(%rbp), %rax
cmpq -0x48(%rbp), %rax
jae 0xb2c6b
movq -0x50(%rbp), %rax
movq %rax, -0x230(%rbp)
jmp 0xb2c76
movq -0x48(%rbp), %rax
movq %rax, -0x230(%rbp)
movq -0x230(%rbp), %rax
movq %rax, -0x158(%rbp)
movq -0x48(%rbp), %rax
subq -0x158(%rbp), %rax
movq %rax, -0x160(%rbp)
movq $0x1301, -0x190(%rbp) # imm = 0x1301
movq -0x40(%rbp), %rax
movq %rax, -0x188(%rbp)
movq -0x48(%rbp), %rax
movq %rax, -0x180(%rbp)
movq -0x90(%rbp), %rax
movq %rax, -0x178(%rbp)
movq $0x0, -0x170(%rbp)
movq $0x0, -0x168(%rbp)
leaq -0x190(%rbp), %rax
xorl %ecx, %ecx
movl %ecx, %edx
rolq $0x3, %rdi
rolq $0xd, %rdi
rolq $0x3d, %rdi
rolq $0x33, %rdi
xchgq %rbx, %rbx
movq %rdx, -0x198(%rbp)
movq -0x198(%rbp), %rax
movq %rax, -0x1a0(%rbp)
cmpq $0x0, -0x158(%rbp)
jbe 0xb2d90
movq $0x4d430002, -0x1d0(%rbp) # imm = 0x4D430002
movq -0x40(%rbp), %rax
movq %rax, -0x1c8(%rbp)
movq -0x158(%rbp), %rax
movq %rax, -0x1c0(%rbp)
movq $0x0, -0x1b8(%rbp)
movq $0x0, -0x1b0(%rbp)
movq $0x0, -0x1a8(%rbp)
leaq -0x1d0(%rbp), %rax
xorl %ecx, %ecx
movl %ecx, %edx
rolq $0x3, %rdi
rolq $0xd, %rdi
rolq $0x3d, %rdi
rolq $0x33, %rdi
xchgq %rbx, %rbx
movq %rdx, -0x1d8(%rbp)
movq -0x1d8(%rbp), %rax
movq %rax, -0x1e0(%rbp)
testb $0x1, -0x61(%rbp)
je 0xb2e23
cmpq $0x0, -0x160(%rbp)
jbe 0xb2e23
movq $0x4d430002, -0x210(%rbp) # imm = 0x4D430002
movq -0x40(%rbp), %rax
addq -0x158(%rbp), %rax
movq %rax, -0x208(%rbp)
movq -0x160(%rbp), %rax
movq %rax, -0x200(%rbp)
movq $0x0, -0x1f8(%rbp)
movq $0x0, -0x1f0(%rbp)
movq $0x0, -0x1e8(%rbp)
leaq -0x210(%rbp), %rax
xorl %ecx, %ecx
movl %ecx, %edx
rolq $0x3, %rdi
rolq $0xd, %rdi
rolq $0x3d, %rdi
rolq $0x33, %rdi
xchgq %rbx, %rbx
movq %rdx, -0x218(%rbp)
movq -0x218(%rbp), %rax
movq %rax, -0x220(%rbp)
jmp 0xb2e25
jmp 0xb2e27
jmp 0xb2e29
jmp 0xb2e2b
movl $0x0, -0x4(%rbp)
jmp 0xb2e4c
testb $0x1, -0x62(%rbp)
je 0xb2e43
movl $0x2, -0x4(%rbp)
jmp 0xb2e4c
jmp 0xb2e45
movl $0x1, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x250, %rsp            # imm = 0x250
popq %rbp
retq
nopl (%rax,%rax)