// File: /workspace/github_c_makefile_star2_O1/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x88, %rsp
movl %r8d, %ebx
movq %rcx, %r11
movq %rdx, %rbp
movq %rsi, 0x40(%rsp)
movl $0x1, %r13d
movl %ebx, %ecx
shlq %cl, %r13
cmpl $0x100, %r8d            # imm = 0x100
jae 0x7e7ad
movb $0x1, 0x7(%rsp)
movq $0x0, 0x10(%rsp)
jmp 0x7e7f8
movl %ebx, %eax
sarl $0x8, %eax
decl %eax
movq (%rdi), %rdx
leaq 0x610c2(%rip), %rcx     # 0xdf880
movq (%rcx), %rcx
notq %rcx
andq %rdx, %rcx
movl %eax, %eax
cmpq %rcx, %rdx
je 0x7e7e3
movq (%rcx), %rcx
movq 0x603a0(%rip), %rdx     # 0xdeb78
cmpq (%rdx,%rax,8), %rcx
setne 0x7(%rsp)
jmp 0x7e7e8
movb $0x1, 0x7(%rsp)
movq 0x60389(%rip), %rcx     # 0xdeb78
movq (%rcx,%rax,8), %rax
movq %rax, 0x10(%rsp)
movq %rdi, 0x48(%rsp)
movq (%rdi), %r15
leaq 0x61079(%rip), %r12     # 0xdf880
movq (%r12), %rax
notq %rax
andq %r15, %rax
movq %r15, %rcx
subq %rax, %rcx
je 0x7e84a
shrq $0xc, %rcx
leaq 0x61104(%rip), %rdx     # 0xdf928
subq (%rdx), %rcx
leaq (%rcx,%rcx,2), %rcx
movq 0x40(%rax,%rcx,8), %r14
movl %r14d, %eax
shrl $0x4, %eax
movl $0xff, %ecx
andl %ecx, %eax
cmpl %ecx, %eax
jne 0x7e85d
andq $-0x1000, %r14          # imm = 0xF000
jmp 0x7e86c
movq %r15, %rdi
movq %r11, %r14
callq 0x8bc15
movq %r14, %r11
movq %rax, %r14
jmp 0x7e86c
imulq $0x68, %rax, %rax
leaq 0x60398(%rip), %rcx     # 0xdec00
movq (%rcx,%rax), %r14
xorl %eax, %eax
cmpb $0x1, 0x602f5(%rip)     # 0xdeb6a
jne 0x7e8a3
cmpq $0xe00, %r14            # imm = 0xE00
ja 0x7e8a3
leaq -0x1(%r14), %rax
shrq $0x3, %rax
leaq 0x24831(%rip), %rcx     # 0xa30c0
movzbl (%rcx,%rax), %eax
imulq $0x68, %rax, %rax
leaq 0x60362(%rip), %rcx     # 0xdec00
movq 0x8(%rcx,%rax), %rax
movq %rax, 0x38(%rsp)
andq $-0x2, %r13
movq (%r12), %rax
notq %rax
andq %r15, %rax
movq %r15, %rcx
subq %rax, %rcx
je 0x7e8ef
shrq $0xc, %rcx
leaq 0x6105f(%rip), %rdx     # 0xdf928
subq (%rdx), %rcx
leaq (%rcx,%rcx,2), %rcx
movq 0x40(%rax,%rcx,8), %r12
movl %r12d, %eax
shrl $0x4, %eax
movl $0xff, %ecx
andl %ecx, %eax
cmpl %ecx, %eax
jne 0x7e902
andq $-0x1000, %r12          # imm = 0xF000
jmp 0x7e911
movq %r15, %rdi
movq %r11, %r12
callq 0x8bc15
movq %r12, %r11
movq %rax, %r12
jmp 0x7e911
imulq $0x68, %rax, %rax
leaq 0x602f3(%rip), %rcx     # 0xdec00
movq (%rcx,%rax), %r12
testq %r13, %r13
je 0x7e9aa
leaq -0x1(%r13), %rdi
testq %r15, %rdi
je 0x7e9aa
testb %bl, %bl
js 0x7ec1c
movq %rbp, 0x18(%rsp)
leaq (%r11,%rbp), %rcx
leaq (%rcx,%r13), %rbp
decq %rbp
movq %r13, %rax
negq %rax
movq %rax, 0x20(%rsp)
andq %rax, %rbp
cmpq %rcx, %rbp
jae 0x7ea66
xorl %ebp, %ebp
testq %rbp, %rbp
je 0x7ec1c
leaq 0x60fc8(%rip), %rax     # 0xdf930
movq (%rax), %rax
cmpq $0x1000, %r13           # imm = 0x1000
movq %r11, 0x30(%rsp)
movq %rdi, 0x28(%rsp)
ja 0x7eab9
cmpq %rbp, %rax
jb 0x7eab9
movl %ebx, %edx
andl $0x40, %edx
shrl $0x6, %edx
movq 0x10(%rsp), %rdi
movq %rbp, %rsi
movl $0x1, %ecx
callq 0x7f908
jmp 0x7eb97
testb %bl, %bl
js 0x7e9ed
leaq (%r11,%rbp), %rax
leaq 0x60f77(%rip), %rcx     # 0xdf930
cmpq (%rcx), %rax
jbe 0x7ea0c
movl %ebx, %r9d
andl $0x40, %r9d
shrl $0x6, %r9d
subq $0x8, %rsp
movzbl 0xf(%rsp), %eax
movq %r15, %rdi
movq %r12, %rsi
movq %rbp, %rdx
movq %r11, %rcx
movq %r13, %r8
pushq %rax
callq 0x8b829
addq $0x10, %rsp
jmp 0x7ea5e
leaq 0x60f3c(%rip), %rax     # 0xdf930
cmpq %rbp, (%rax)
jae 0x7ea42
movq %r15, %rdi
movq %r12, %rsi
movq %rbp, %rdx
movq %r11, %rcx
callq 0x8b7b8
jmp 0x7ea5e
movl %ebx, %eax
andl $0x40, %eax
shrl $0x6, %eax
subq $0x8, %rsp
movzbl 0xf(%rsp), %r10d
movq 0x18(%rsp), %rdi
movq %r15, %rsi
movq %r12, %rdx
movq %rbp, %rcx
movq %r11, %r8
movq %r13, %r9
pushq %r10
pushq $0x1
pushq %rax
callq 0x81cd4
addq $0x20, %rsp
jmp 0x7ea5e
movl %ebx, %r8d
andl $0x40, %r8d
shrl $0x6, %r8d
movq %r15, %rdi
movq %r12, %rsi
movq %rbp, %rdx
movq %r11, %rcx
callq 0x8195e
movq %rax, %rbp
jmp 0x7ec1e
leaq 0x60ec3(%rip), %rax     # 0xdf930
movq (%rax), %rax
cmpq %rax, %rbp
seta %dl
cmpq $0x1001, %r13           # imm = 0x1001
setae %sil
orb %dl, %sil
jne 0x7eafd
cmpq $0xe00, %rbp            # imm = 0xE00
ja 0x7eb74
decq %rbp
shrq $0x3, %rbp
leaq 0x2461f(%rip), %rax     # 0xa30c0
movzbl (%rax,%rbp), %eax
imulq $0x68, %rax, %rax
leaq 0x60150(%rip), %rcx     # 0xdec00
movq (%rcx,%rax), %rbp
jmp 0x7e958
cmpq %rbp, %rax
jb 0x7eb53
movq 0x10(%rsp), %rax
movq %rax, %rdi
testq %rax, %rax
jne 0x7eae5
movq %fs:-0x30, %rdi
testq %rdi, %rdi
jne 0x7eae5
callq 0x7c332
movq %rax, %rdi
movl %ebx, %ecx
andl $0x40, %ecx
shrl $0x6, %ecx
movq %rbp, %rsi
movq %r13, %rdx
callq 0x80d53
jmp 0x7eb97
leaq 0xfff(%rcx), %rbp
andq $-0x1000, %rbp          # imm = 0xF000
cmpq %rcx, %rbp
jb 0x7e956
leaq 0xfff(%r13), %rcx
andq $-0x1000, %rcx          # imm = 0xF000
addq %rbp, %rcx
jb 0x7e956
addq $-0x1000, %rcx          # imm = 0xF000
cmpq %rax, %rcx
jbe 0x7e958
leaq 0x60d3e(%rip), %rax     # 0xdf880
movq (%rax), %rax
addq %rax, %rbp
notq %rax
andq %rax, %rbp
jmp 0x7e958
leaq 0x60d06(%rip), %rax     # 0xdf860
cmpq %r13, (%rax)
jae 0x7eb87
movl %ebx, %edx
andl $0x40, %edx
shrl $0x6, %edx
movq %rbp, %rdi
movq %r13, %rsi
callq 0x8b6b5
jmp 0x7eb97
addq $0xfff, %rbp            # imm = 0xFFF
andq $-0x1000, %rbp          # imm = 0xF000
jmp 0x7e958
movl %ebx, %esi
andl $0x40, %esi
shrl $0x6, %esi
movq %rbp, %rdi
callq 0x8b6a4
movq %rax, %rbp
testq %rax, %rax
movq 0x30(%rsp), %rax
movq 0x28(%rsp), %rdi
je 0x7ebd8
movq 0x18(%rsp), %rdx
cmpq %rdx, %r12
cmovbq %r12, %rdx
movq %rbp, %rdi
movq %r15, %rsi
callq 0x1fbd0
cmpq $0x0, 0x5ff98(%rip)     # 0xdeb60
je 0x7ef3a
movq %r15, %rdi
callq 0x8d814
jmp 0x7ec1e
testq %rax, %rax
je 0x7ec1c
movq 0x18(%rsp), %rsi
addq %rsi, %rdi
andq 0x20(%rsp), %rdi
cmpq %rsi, %rdi
jae 0x7ef64
xorl %edi, %edi
testq %rdi, %rdi
je 0x7ec1c
movl %ebx, %edx
andl $0x40, %edx
shrl $0x6, %edx
movq %r13, %rsi
movl $0x1, %ecx
movq 0x10(%rsp), %r8
callq 0x7fce2
movq %rax, %rbp
testq %rax, %rax
jne 0x7eba9
xorl %ebp, %ebp
testq %rbp, %rbp
je 0x7ec6c
leaq 0x60c56(%rip), %rax     # 0xdf880
movq (%rax), %rax
notq %rax
andq %rbp, %rax
movq %rbp, %rcx
subq %rax, %rcx
je 0x7ec7a
shrq $0xc, %rcx
leaq 0x60ce2(%rip), %rdx     # 0xdf928
subq (%rdx), %rcx
leaq (%rcx,%rcx,2), %rcx
movq 0x40(%rax,%rcx,8), %r12
movl %r12d, %eax
shrl $0x4, %eax
movl $0xff, %ecx
andl %ecx, %eax
cmpl %ecx, %eax
jne 0x7ec87
andq $-0x1000, %r12          # imm = 0xF000
jmp 0x7ec96
xorl %ecx, %ecx
testb %bl, %bl
sets %cl
incl %ecx
jmp 0x7ef26
movq %rbp, %rdi
callq 0x8bc15
movq %rax, %r12
jmp 0x7ec96
imulq $0x68, %rax, %rax
leaq 0x5ff6e(%rip), %rcx     # 0xdec00
movq (%rcx,%rax), %r12
movq 0x40(%rsp), %rax
testq %rax, %rax
je 0x7eca3
movq %r12, (%rax)
movq 0x48(%rsp), %rax
movq %rbp, (%rax)
addq %r12, %fs:-0x28
addq %r14, %fs:-0x20
xorl %ecx, %ecx
cmpb $0x1, 0x5fea4(%rip)     # 0xdeb6a
jne 0x7ef26
leaq 0x60bad(%rip), %rax     # 0xdf880
movq (%rax), %rax
notq %rax
andq %rbp, %rax
movq %rbp, %rcx
subq %rax, %rcx
je 0x7ed13
shrq $0xc, %rcx
leaq 0x60c39(%rip), %rdx     # 0xdf928
subq (%rdx), %rcx
leaq (%rcx,%rcx,2), %rcx
movq 0x40(%rax,%rcx,8), %rax
movl %eax, %ecx
shrl $0x4, %ecx
movl $0xff, %edx
andl %edx, %ecx
cmpl %edx, %ecx
jne 0x7ed1d
andq $-0x1000, %rax          # imm = 0xF000
jmp 0x7ed2c
movq %rbp, %rdi
callq 0x8bc15
jmp 0x7ed2c
imulq $0x68, %rcx, %rax
leaq 0x5fed8(%rip), %rcx     # 0xdec00
movq (%rcx,%rax), %rax
cmpq $0xe00, %rax            # imm = 0xE00
ja 0x7ed58
decq %rax
shrq $0x3, %rax
leaq 0x2437e(%rip), %rcx     # 0xa30c0
movzbl (%rcx,%rax), %eax
imulq $0x68, %rax, %rax
leaq 0x5feaf(%rip), %rcx     # 0xdec00
movq 0x8(%rcx,%rax), %rcx
jmp 0x7ed5a
xorl %ecx, %ecx
cmpq %r15, %rbp
je 0x7ee93
testq %r15, %r15
je 0x7edae
leaq 0x50(%rsp), %rax
movq $0x1302, (%rax)         # imm = 0x1302
movq %r15, 0x8(%rax)
movq 0x38(%rsp), %rdx
movq %rdx, 0x10(%rax)
xorl %edx, %edx
movq %rdx, 0x18(%rax)
movq %rdx, 0x20(%rax)
movq %rdx, 0x28(%rax)
xorl %edx, %edx
rolq $0x3, %rdi
rolq $0xd, %rdi
rolq $0x3d, %rdi
rolq $0x33, %rdi
xchgq %rbx, %rbx
movq %rdx, 0x8(%rsp)
movq 0x8(%rsp), %rax
cmpq %r12, %r14
movq %r12, %rsi
cmovbq %r14, %rsi
leaq 0x50(%rsp), %rax
movq $0x1301, (%rax)         # imm = 0x1301
movq %rbp, 0x8(%rax)
movq %r12, 0x10(%rax)
movq %rcx, 0x18(%rax)
xorl %ecx, %ecx
movq %rcx, 0x20(%rax)
movq %rcx, 0x28(%rax)
xorl %edx, %edx
rolq $0x3, %rdi
rolq $0xd, %rdi
rolq $0x3d, %rdi
rolq $0x33, %rdi
xchgq %rbx, %rbx
movq %rdx, 0x8(%rsp)
movq 0x8(%rsp), %rax
testq %rsi, %rsi
je 0x7ee3f
leaq 0x50(%rsp), %rax
movq $0x4d430002, (%rax)     # imm = 0x4D430002
movq %rbp, 0x8(%rax)
movq %rsi, 0x10(%rax)
xorl %edx, %edx
movq %rdx, 0x18(%rax)
movq %rdx, 0x20(%rax)
movq %rdx, 0x28(%rax)
xorl %edx, %edx
rolq $0x3, %rdi
rolq $0xd, %rdi
rolq $0x3d, %rdi
rolq $0x33, %rdi
xchgq %rbx, %rbx
movq %rdx, 0x8(%rsp)
movq 0x8(%rsp), %rax
testb $0x40, %bl
je 0x7ef26
cmpq %r14, %r12
jbe 0x7ef26
subq %rsi, %r12
leaq 0x50(%rsp), %rax
movq $0x4d430002, (%rax)     # imm = 0x4D430002
addq %rsi, %rbp
movq %rbp, 0x8(%rax)
movq %r12, 0x10(%rax)
xorl %ecx, %ecx
movq %rcx, 0x18(%rax)
movq %rcx, 0x20(%rax)
movq %rcx, 0x28(%rax)
xorl %edx, %edx
rolq $0x3, %rdi
rolq $0xd, %rdi
rolq $0x3d, %rdi
rolq $0x33, %rdi
xchgq %rbx, %rbx
jmp 0x7ef1c
leaq 0x50(%rsp), %rax
movq $0x130b, (%rax)         # imm = 0x130B
movq %rbp, 0x8(%rax)
movq %r14, 0x10(%rax)
movq %r12, 0x18(%rax)
movq %rcx, 0x20(%rax)
movq $0x0, 0x28(%rax)
xorl %ecx, %ecx
xorl %edx, %edx
rolq $0x3, %rdi
rolq $0xd, %rdi
rolq $0x3d, %rdi
rolq $0x33, %rdi
xchgq %rbx, %rbx
movq %rdx, 0x8(%rsp)
movq 0x8(%rsp), %rax
testb $0x40, %bl
je 0x7ef26
subq %r14, %r12
jbe 0x7ef26
leaq 0x50(%rsp), %rax
movq $0x4d430002, (%rax)     # imm = 0x4D430002
addq %rbp, %r14
movq %r14, 0x8(%rax)
movq %r12, 0x10(%rax)
xorl %ecx, %ecx
movq %rcx, 0x18(%rax)
movq %rcx, 0x20(%rax)
movq %rcx, 0x28(%rax)
xorl %edx, %edx
rolq $0x3, %rdi
rolq $0xd, %rdi
rolq $0x3d, %rdi
rolq $0x33, %rdi
xchgq %rbx, %rbx
movq %rdx, 0x8(%rsp)
movq 0x8(%rsp), %rax
movl %ecx, %eax
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x6093f(%rip), %rax     # 0xdf880
movq (%rax), %rsi
notq %rsi
andq %r15, %rsi
cmpq %rsi, %r15
je 0x7efbc
movq (%rsi), %rdi
movzbl 0x7(%rsp), %ecx
movq %r15, %rdx
callq 0x7f5fb
jmp 0x7ec1e
cmpq $0x1001, %r13           # imm = 0x1001
setae %cl
leaq 0x609bb(%rip), %rax     # 0xdf930
movq (%rax), %rax
cmpq %rax, %rdi
seta %dl
orb %cl, %dl
leaq 0x608f9(%rip), %rdx     # 0xdf880
jne 0x7efce
cmpq $0xe00, %rdi            # imm = 0xE00
ja 0x7f01d
decq %rdi
shrq $0x3, %rdi
leaq 0x2411c(%rip), %rax     # 0xa30c0
movzbl (%rax,%rdi), %eax
imulq $0x68, %rax, %rax
leaq 0x5fc4d(%rip), %rcx     # 0xdec00
movq (%rcx,%rax), %rdi
jmp 0x7ebf5
movq %r15, %rdi
movl $0x1, %esi
callq 0x8bb7e
jmp 0x7ec1e
leaq 0xfff(%rsi), %rdi
andq $-0x1000, %rdi          # imm = 0xF000
cmpq %rsi, %rdi
jb 0x7ebf3
leaq 0xfff(%r13), %rcx
andq $-0x1000, %rcx          # imm = 0xF000
addq %rdi, %rcx
jb 0x7ebf3
addq $-0x1000, %rcx          # imm = 0xF000
cmpq %rax, %rcx
jbe 0x7ebf5
movq (%rdx), %rax
addq %rax, %rdi
notq %rax
andq %rax, %rdi
jmp 0x7ebf5
addq $0xfff, %rdi            # imm = 0xFFF
andq $-0x1000, %rdi          # imm = 0xF000
jmp 0x7ebf5