// File: /workspace/github_c_makefile_star2_O1/nilyang[P]redis-tdd-annotation/deps/jemalloc/src/jemalloc.c
// Function: je_realloc
void *
je_realloc(void *ptr, size_t size)
{
	void *ret;
	size_t usize JEMALLOC_CC_SILENCE_INIT(0);
	size_t old_size = 0;
	size_t old_rzsize JEMALLOC_CC_SILENCE_INIT(0);
	prof_thr_cnt_t *cnt JEMALLOC_CC_SILENCE_INIT(NULL);
	prof_ctx_t *old_ctx JEMALLOC_CC_SILENCE_INIT(NULL);

	if (size == 0) {
		if (ptr != NULL) {
			/* realloc(ptr, 0) is equivalent to free(p). */
			if (config_prof) {
				old_size = isalloc(ptr, true);
				if (config_valgrind && opt_valgrind)
					old_rzsize = p2rz(ptr);
			} else if (config_stats) {
				old_size = isalloc(ptr, false);
				if (config_valgrind && opt_valgrind)
					old_rzsize = u2rz(old_size);
			} else if (config_valgrind && opt_valgrind) {
				old_size = isalloc(ptr, false);
				old_rzsize = u2rz(old_size);
			}
			if (config_prof && opt_prof) {
				old_ctx = prof_ctx_get(ptr);
				cnt = NULL;
			}
			iqalloc(ptr);
			ret = NULL;
			goto label_return;
		} else
			size = 1;
	}

	if (ptr != NULL) {
		assert(malloc_initialized || IS_INITIALIZER);

		if (config_prof) {
			old_size = isalloc(ptr, true);
			if (config_valgrind && opt_valgrind)
				old_rzsize = p2rz(ptr);
		} else if (config_stats) {
			old_size = isalloc(ptr, false);
			if (config_valgrind && opt_valgrind)
				old_rzsize = u2rz(old_size);
		} else if (config_valgrind && opt_valgrind) {
			old_size = isalloc(ptr, false);
			old_rzsize = u2rz(old_size);
		}
		if (config_prof && opt_prof) {
			usize = s2u(size);
			old_ctx = prof_ctx_get(ptr);
			PROF_ALLOC_PREP(1, usize, cnt);
			if (cnt == NULL) {
				old_ctx = NULL;
				ret = NULL;
				goto label_oom;
			}
			if (prof_promote && (uintptr_t)cnt != (uintptr_t)1U &&
			    usize <= SMALL_MAXCLASS) {
				ret = iralloc(ptr, SMALL_MAXCLASS+1, 0, 0,
				    false, false);
				if (ret != NULL)
					arena_prof_promoted(ret, usize);
				else
					old_ctx = NULL;
			} else {
				ret = iralloc(ptr, size, 0, 0, false, false);
				if (ret == NULL)
					old_ctx = NULL;
			}
		} else {
			if (config_stats || (config_valgrind && opt_valgrind))
				usize = s2u(size);
			ret = iralloc(ptr, size, 0, 0, false, false);
		}

label_oom:
		if (ret == NULL) {
			if (config_xmalloc && opt_xmalloc) {
				malloc_write("<jemalloc>: Error in realloc(): "
				    "out of memory\n");
				abort();
			}
			set_errno(ENOMEM);
		}
	} else {
		/* realloc(NULL, size) is equivalent to malloc(size). */
		if (config_prof && opt_prof)
			old_ctx = NULL;
		if (malloc_init()) {
			if (config_prof && opt_prof)
				cnt = NULL;
			ret = NULL;
		} else {
			if (config_prof && opt_prof) {
				usize = s2u(size);
				PROF_ALLOC_PREP(1, usize, cnt);
				if (cnt == NULL)
					ret = NULL;
				else {
					if (prof_promote && (uintptr_t)cnt !=
					    (uintptr_t)1U && usize <=
					    SMALL_MAXCLASS) {
						ret = imalloc(SMALL_MAXCLASS+1);
						if (ret != NULL) {
							arena_prof_promoted(ret,
							    usize);
						}
					} else
						ret = imalloc(size);
				}
			} else {
				if (config_stats || (config_valgrind &&
				    opt_valgrind))
					usize = s2u(size);
				ret = imalloc(size);
			}
		}

		if (ret == NULL) {
			if (config_xmalloc && opt_xmalloc) {
				malloc_write("<jemalloc>: Error in realloc(): "
				    "out of memory\n");
				abort();
			}
			set_errno(ENOMEM);
		}
	}

label_return:
	if (config_prof && opt_prof)
		prof_realloc(ret, usize, cnt, old_size, old_ctx);
	if (config_stats && ret != NULL) {
		thread_allocated_t *ta;
		assert(usize == isalloc(ret, config_prof));
		ta = thread_allocated_tsd_get();
		ta->allocated += usize;
		ta->deallocated += old_size;
	}
	UTRACE(ptr, size, ret);
	JEMALLOC_VALGRIND_REALLOC(ret, usize, ptr, old_size, old_rzsize, false);
	return (ret);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rsi, %r15
movq %rdi, %rbx
testq %rsi, %rsi
je 0x7d971
testq %rbx, %rbx
je 0x7d9d1
leaq 0x61f60(%rip), %r12     # 0xdf880
movq (%r12), %rax
notq %rax
andq %rbx, %rax
cmpq %rbx, %rax
je 0x7da1b
movq %rbx, %rcx
subq %rax, %rcx
shrq $0xc, %rcx
leaq 0x61fe4(%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 0x7da28
andq $-0x1000, %r14          # imm = 0xF000
jmp 0x7da37
testq %rbx, %rbx
je 0x7dab7
leaq 0x61eff(%rip), %r15     # 0xdf880
movq (%r15), %rax
notq %rax
andq %rbx, %rax
cmpq %rbx, %rax
je 0x7db9f
movq %rbx, %rcx
subq %rax, %rcx
shrq $0xc, %rcx
leaq 0x61f84(%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 0x7dbac
andq $-0x1000, %r14          # imm = 0xF000
jmp 0x7dbbb
xorl %r13d, %r13d
callq 0x7c61b
movl $0x0, %r12d
testb %al, %al
jne 0x7dc8c
cmpq $0xe00, %r15            # imm = 0xE00
ja 0x7dc30
leaq -0x1(%r15), %rax
shrq $0x3, %rax
leaq 0x256bd(%rip), %rcx     # 0xa30c0
movzbl (%rcx,%rax), %eax
imulq $0x68, %rax, %rax
leaq 0x611ee(%rip), %rcx     # 0xdec00
movq (%rcx,%rax), %r13
jmp 0x7dc60
movq %rbx, %rdi
callq 0x8bc15
movq %rax, %r14
jmp 0x7da37
imulq $0x68, %rax, %rax
leaq 0x611cd(%rip), %rcx     # 0xdec00
movq (%rcx,%rax), %r14
xorl %ebp, %ebp
cmpb $0x1, 0x6112a(%rip)     # 0xdeb6a
jne 0x7da6e
cmpq $0xe00, %r14            # imm = 0xE00
ja 0x7da6e
leaq -0x1(%r14), %rax
shrq $0x3, %rax
leaq 0x25666(%rip), %rcx     # 0xa30c0
movzbl (%rcx,%rax), %eax
imulq $0x68, %rax, %rax
leaq 0x61197(%rip), %rcx     # 0xdec00
movq 0x8(%rcx,%rax), %rbp
cmpq $0xe00, %r15            # imm = 0xE00
ja 0x7da9b
leaq -0x1(%r15), %rax
shrq $0x3, %rax
leaq 0x2563a(%rip), %rcx     # 0xa30c0
movzbl (%rcx,%rax), %eax
imulq $0x68, %rax, %rax
leaq 0x6116b(%rip), %rcx     # 0xdec00
movq (%rcx,%rax), %r13
jmp 0x7dad0
leaq 0x61e8e(%rip), %rax     # 0xdf930
cmpq %r15, (%rax)
jae 0x7dac2
movq (%r12), %r13
leaq (%r15,%r13), %rax
notq %r13
andq %rax, %r13
jmp 0x7dad0
movl $0x1, %r15d
jmp 0x7d910
leaq 0xfff(%r15), %r13
andq $-0x1000, %r13          # imm = 0xF000
movq (%r12), %rax
notq %rax
andq %rbx, %rax
cmpq %rbx, %rax
je 0x7db15
movq %rbx, %rcx
subq %rax, %rcx
shrq $0xc, %rcx
leaq 0x61e38(%rip), %rdx     # 0xdf928
subq (%rdx), %rcx
leaq (%rcx,%rcx,2), %rcx
movq 0x40(%rax,%rcx,8), %rdx
movl %edx, %eax
shrl $0x4, %eax
movl $0xff, %ecx
andl %ecx, %eax
cmpl %ecx, %eax
jne 0x7db22
andq $-0x1000, %rdx          # imm = 0xF000
jmp 0x7db31
movq %rbx, %rdi
callq 0x8bc15
movq %rax, %rdx
jmp 0x7db31
imulq $0x68, %rax, %rax
leaq 0x610d3(%rip), %rcx     # 0xdec00
movq (%rcx,%rax), %rdx
leaq 0x61df8(%rip), %rax     # 0xdf930
cmpq %r15, (%rax)
jae 0x7db5f
subq $0x8, %rsp
movq %rbx, %rdi
movq %rdx, %rsi
movq %r15, %rdx
xorl %ecx, %ecx
xorl %r8d, %r8d
xorl %r9d, %r9d
pushq $0x1
callq 0x8b829
addq $0x10, %rsp
jmp 0x7db83
subq $0x8, %rsp
movl $0x1, %eax
xorl %edi, %edi
movq %rbx, %rsi
movq %r15, %rcx
xorl %r8d, %r8d
xorl %r9d, %r9d
pushq %rax
pushq %rax
pushq $0x0
callq 0x81cd4
addq $0x20, %rsp
movq %rax, %r12
testq %rax, %rax
jne 0x7dcbd
callq 0x1f810
movl $0xc, (%rax)
jmp 0x7dcba
movq %rbx, %rdi
callq 0x8bc15
movq %rax, %r14
jmp 0x7dbbb
imulq $0x68, %rax, %rax
leaq 0x61049(%rip), %rcx     # 0xdec00
movq (%rcx,%rax), %r14
xorl %ebp, %ebp
cmpb $0x1, 0x60fa6(%rip)     # 0xdeb6a
jne 0x7dbf2
cmpq $0xe00, %r14            # imm = 0xE00
ja 0x7dbf2
leaq -0x1(%r14), %rax
shrq $0x3, %rax
leaq 0x254e2(%rip), %rcx     # 0xa30c0
movzbl (%rcx,%rax), %eax
imulq $0x68, %rax, %rax
leaq 0x61013(%rip), %rcx     # 0xdec00
movq 0x8(%rcx,%rax), %rbp
cmpq $0x0, 0x60f66(%rip)     # 0xdeb60
je 0x7dc09
movq %rbx, %rdi
callq 0x8d814
jmp 0x7dcb7
movq (%r15), %rsi
notq %rsi
andq %rbx, %rsi
cmpq %rbx, %rsi
je 0x7dcaa
movq (%rsi), %rdi
movq %rbx, %rdx
movl $0x1, %ecx
callq 0x7f5fb
jmp 0x7dcb7
leaq 0x61cf9(%rip), %rax     # 0xdf930
cmpq %r15, (%rax)
jae 0x7dc52
leaq 0x61c3d(%rip), %rax     # 0xdf880
movq (%rax), %r13
leaq (%r15,%r13), %rax
notq %r13
andq %rax, %r13
jmp 0x7dc60
leaq 0xfff(%r15), %r13
andq $-0x1000, %r13          # imm = 0xF000
leaq 0x61cc9(%rip), %rax     # 0xdf930
cmpq %r15, (%rax)
jae 0x7dc78
movq %r15, %rdi
xorl %esi, %esi
callq 0x8b6a4
jmp 0x7dc89
xorl %edi, %edi
movq %r15, %rsi
xorl %edx, %edx
movl $0x1, %ecx
callq 0x7f908
movq %rax, %r12
testq %r12, %r12
je 0x7dc98
xorl %ebp, %ebp
xorl %r14d, %r14d
jmp 0x7dcbd
callq 0x1f810
movl $0xc, (%rax)
xorl %ebp, %ebp
xorl %r14d, %r14d
jmp 0x7dcba
movq %rbx, %rdi
movl $0x1, %esi
callq 0x8bb7e
xorl %r13d, %r13d
xorl %r12d, %r12d
testq %r12, %r12
je 0x7dcd4
addq %r13, %fs:-0x28
addq %r14, %fs:-0x20
cmpb $0x1, 0x60e8f(%rip)     # 0xdeb6a
jne 0x7de90
leaq 0x61b98(%rip), %rax     # 0xdf880
movq (%rax), %rax
notq %rax
andq %r12, %rax
movq %r12, %rcx
subq %rax, %rcx
je 0x7dd28
shrq $0xc, %rcx
leaq 0x61c24(%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 0x7dd32
andq $-0x1000, %rax          # imm = 0xF000
jmp 0x7dd41
movq %r12, %rdi
callq 0x8bc15
jmp 0x7dd41
imulq $0x68, %rcx, %rax
leaq 0x60ec3(%rip), %rcx     # 0xdec00
movq (%rcx,%rax), %rax
cmpq $0xe00, %rax            # imm = 0xE00
ja 0x7dd6d
decq %rax
shrq $0x3, %rax
leaq 0x25369(%rip), %rcx     # 0xa30c0
movzbl (%rcx,%rax), %eax
imulq $0x68, %rax, %rax
leaq 0x60e9a(%rip), %rcx     # 0xdec00
movq 0x8(%rcx,%rax), %rcx
jmp 0x7dd6f
xorl %ecx, %ecx
cmpq %rbx, %r12
je 0x7de4d
testq %rbx, %rbx
je 0x7ddbe
leaq 0x10(%rsp), %rax
movq $0x1302, (%rax)         # imm = 0x1302
movq %rbx, 0x8(%rax)
movq %rbp, 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
testq %r12, %r12
je 0x7de90
cmpq %r13, %r14
cmovaeq %r13, %r14
leaq 0x10(%rsp), %rax
movq $0x1301, (%rax)         # imm = 0x1301
movq %r12, 0x8(%rax)
movq %r13, 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 %r14, %r14
je 0x7de90
leaq 0x10(%rsp), %rax
movq $0x4d430002, (%rax)     # imm = 0x4D430002
movq %r12, 0x8(%rax)
movq %r14, 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 0x7de86
leaq 0x10(%rsp), %rax
movq $0x130b, (%rax)         # imm = 0x130B
movq %r12, 0x8(%rax)
movq %r14, 0x10(%rax)
movq %r13, 0x18(%rax)
movq %rcx, 0x20(%rax)
movq $0x0, 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
movq %r12, %rax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq