// File: /workspace/github_c_makefile_star2_O3/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 %rdi, %rbx
testq %rsi, %rsi
je 0x7dc01
movq %rsi, %r15
testq %rbx, %rbx
je 0x7dc61
leaq 0x61cd0(%rip), %rbp     # 0xdf880
movq (%rbp), %rax
notq %rax
andq %rbx, %rax
cmpq %rbx, %rax
je 0x7dc9c
movq %rbx, %rcx
subq %rax, %rcx
shrq $0xc, %rcx
leaq 0x61d54(%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 0x7dd04
andq $-0x1000, %r14          # imm = 0xF000
jmp 0x7dd13
testq %rbx, %rbx
je 0x7dca9
leaq 0x61c6f(%rip), %r15     # 0xdf880
movq (%r15), %rax
notq %rax
andq %rbx, %rax
cmpq %rbx, %rax
je 0x7dec7
movq %rbx, %rcx
subq %rax, %rcx
shrq $0xc, %rcx
leaq 0x61cf4(%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 0x7ded4
andq $-0x1000, %r14          # imm = 0xF000
jmp 0x7dee3
callq 0x7c7b5
testb %al, %al
jne 0x7dcb8
cmpq $0xe00, %r15            # imm = 0xE00
jbe 0x7dcc0
leaq 0x61cb6(%rip), %rax     # 0xdf930
movq (%rax), %rax
cmpq %r15, %rax
jae 0x7e133
leaq 0x61bf3(%rip), %rcx     # 0xdf880
movq (%rcx), %r12
leaq (%r12,%r15), %rcx
notq %r12
andq %rcx, %r12
jmp 0x7dcec
movq %rbx, %rdi
callq 0x8be94
movq %rax, %r14
jmp 0x7dd13
movl $0x1, %r15d
callq 0x7c7b5
testb %al, %al
je 0x7dcc0
xorl %r12d, %r12d
jmp 0x7deab
leaq -0x1(%r15), %rax
shrq $0x3, %rax
leaq 0x254f1(%rip), %rcx     # 0xa31c0
movzbl (%rcx,%rax), %eax
imulq $0x68, %rax, %rax
leaq 0x60f22(%rip), %rcx     # 0xdec00
movq (%rcx,%rax), %r12
leaq 0x61c47(%rip), %rax     # 0xdf930
movq (%rax), %rax
cmpq %r15, %rax
jae 0x7de73
movq %r15, %rdi
xorl %esi, %esi
callq 0x8b91c
jmp 0x7de84
imulq $0x68, %rax, %rax
leaq 0x60ef1(%rip), %rcx     # 0xdec00
movq (%rcx,%rax), %r14
xorl %r13d, %r13d
cmpb $0x1, 0x60e4d(%rip)     # 0xdeb6a
jne 0x7dd4b
cmpq $0xe00, %r14            # imm = 0xE00
ja 0x7dd4b
leaq -0x1(%r14), %rax
shrq $0x3, %rax
leaq 0x25489(%rip), %rcx     # 0xa31c0
movzbl (%rcx,%rax), %eax
imulq $0x68, %rax, %rax
leaq 0x60eba(%rip), %rcx     # 0xdec00
movq 0x8(%rcx,%rax), %r13
cmpq $0xe00, %r15            # imm = 0xE00
ja 0x7dd78
leaq -0x1(%r15), %rax
shrq $0x3, %rax
leaq 0x2545d(%rip), %rcx     # 0xa31c0
movzbl (%rcx,%rax), %eax
imulq $0x68, %rax, %rax
leaq 0x60e8e(%rip), %rcx     # 0xdec00
movq (%rcx,%rax), %r12
jmp 0x7dda2
leaq 0x61bb1(%rip), %rax     # 0xdf930
cmpq %r15, (%rax)
jae 0x7dd94
movq (%rbp), %r12
leaq (%r12,%r15), %rax
notq %r12
andq %rax, %r12
jmp 0x7dda2
leaq 0xfff(%r15), %r12
andq $-0x1000, %r12          # imm = 0xF000
movq (%rbp), %rax
notq %rax
andq %rbx, %rax
cmpq %rbx, %rax
je 0x7dde7
movq %rbx, %rcx
subq %rax, %rcx
shrq $0xc, %rcx
leaq 0x61b66(%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 0x7ddf4
andq $-0x1000, %rdx          # imm = 0xF000
jmp 0x7de03
movq %rbx, %rdi
callq 0x8be94
movq %rax, %rdx
jmp 0x7de03
imulq $0x68, %rax, %rax
leaq 0x60e01(%rip), %rcx     # 0xdec00
movq (%rcx,%rax), %rdx
leaq 0x61b26(%rip), %rax     # 0xdf930
cmpq %r15, (%rax)
jae 0x7de31
subq $0x8, %rsp
movq %rbx, %rdi
movq %rdx, %rsi
movq %r15, %rdx
xorl %ecx, %ecx
xorl %r8d, %r8d
xorl %r9d, %r9d
pushq $0x1
callq 0x8baa1
addq $0x10, %rsp
jmp 0x7de55
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 0x82021
addq $0x20, %rsp
movq %rax, %r15
testq %rax, %rax
jne 0x7de92
callq 0x1f810
movl $0xc, (%rax)
movb $0x1, %bpl
xorl %r15d, %r15d
jmp 0x7df65
xorl %edi, %edi
movq %r15, %rsi
xorl %edx, %edx
movl $0x1, %ecx
callq 0x7fb8c
movq %rax, %r15
testq %rax, %rax
je 0x7deab
xorl %r13d, %r13d
xorl %r14d, %r14d
addq %r12, %fs:-0x28
addq %r14, %fs:-0x20
xorl %ebp, %ebp
jmp 0x7df65
callq 0x1f810
movl $0xc, (%rax)
movb $0x1, %bpl
xorl %r15d, %r15d
xorl %r14d, %r14d
xorl %r13d, %r13d
jmp 0x7df65
movq %rbx, %rdi
callq 0x8be94
movq %rax, %r14
jmp 0x7dee3
imulq $0x68, %rax, %rax
leaq 0x60d21(%rip), %rcx     # 0xdec00
movq (%rcx,%rax), %r14
xorl %r13d, %r13d
cmpb $0x1, 0x60c7d(%rip)     # 0xdeb6a
jne 0x7df1b
cmpq $0xe00, %r14            # imm = 0xE00
ja 0x7df1b
leaq -0x1(%r14), %rax
shrq $0x3, %rax
leaq 0x252b9(%rip), %rcx     # 0xa31c0
movzbl (%rcx,%rax), %eax
imulq $0x68, %rax, %rax
leaq 0x60cea(%rip), %rcx     # 0xdec00
movq 0x8(%rcx,%rax), %r13
cmpq $0x0, 0x60c3d(%rip)     # 0xdeb60
je 0x7df2f
movq %rbx, %rdi
callq 0x8da50
jmp 0x7df5c
movq (%r15), %rsi
notq %rsi
andq %rbx, %rsi
cmpq %rbx, %rsi
je 0x7df4f
movq (%rsi), %rdi
movq %rbx, %rdx
movl $0x1, %ecx
callq 0x7f86f
jmp 0x7df5c
movq %rbx, %rdi
movl $0x1, %esi
callq 0x8bdfd
movb $0x1, %bpl
xorl %r15d, %r15d
xorl %r12d, %r12d
cmpb $0x1, 0x60bfe(%rip)     # 0xdeb6a
jne 0x7e121
leaq 0x61907(%rip), %rax     # 0xdf880
movq (%rax), %rax
notq %rax
andq %r15, %rax
movq %r15, %rcx
subq %rax, %rcx
je 0x7dfb9
shrq $0xc, %rcx
leaq 0x61993(%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 0x7dfc3
andq $-0x1000, %rax          # imm = 0xF000
jmp 0x7dfd2
movq %r15, %rdi
callq 0x8be94
jmp 0x7dfd2
imulq $0x68, %rcx, %rax
leaq 0x60c32(%rip), %rcx     # 0xdec00
movq (%rcx,%rax), %rax
cmpq $0xe00, %rax            # imm = 0xE00
ja 0x7dffe
decq %rax
shrq $0x3, %rax
leaq 0x251d8(%rip), %rcx     # 0xa31c0
movzbl (%rcx,%rax), %eax
imulq $0x68, %rax, %rax
leaq 0x60c09(%rip), %rcx     # 0xdec00
movq 0x8(%rcx,%rax), %rcx
jmp 0x7e000
xorl %ecx, %ecx
cmpq %rbx, %r15
je 0x7e0de
testq %rbx, %rbx
je 0x7e04f
leaq 0x10(%rsp), %rax
movq $0x1302, (%rax)         # imm = 0x1302
movq %rbx, 0x8(%rax)
movq %r13, 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 %bpl, %bpl
jne 0x7e121
cmpq %r12, %r14
cmovaeq %r12, %r14
leaq 0x10(%rsp), %rax
movq $0x1301, (%rax)         # imm = 0x1301
movq %r15, 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 %r14, %r14
je 0x7e121
leaq 0x10(%rsp), %rax
movq $0x4d430002, (%rax)     # imm = 0x4D430002
movq %r15, 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 0x7e117
leaq 0x10(%rsp), %rax
movq $0x130b, (%rax)         # imm = 0x130B
movq %r15, 0x8(%rax)
movq %r14, 0x10(%rax)
movq %r12, 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 %r15, %rax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xfff(%r15), %r12
andq $-0x1000, %r12          # imm = 0xF000
jmp 0x7dcec