// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x170, %rsp            # imm = 0x170
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq $0x0, -0x20(%rbp)
movq $0x0, -0x28(%rbp)
movq $0x0, -0x30(%rbp)
movq $0x0, -0x38(%rbp)
movq $0x0, -0x40(%rbp)
cmpq $0x0, -0x10(%rbp)
jne 0xb1c6e
cmpq $0x0, -0x8(%rbp)
je 0xb1c64
movq -0x8(%rbp), %rdi
xorl %esi, %esi
callq 0xb18e0
movq %rax, -0x28(%rbp)
testb $0x1, 0x7687b(%rip)     # 0x1284ba
je 0xb1c4e
movq -0x28(%rbp), %rdi
callq 0xb1fc0
movq %rax, -0x30(%rbp)
movq -0x8(%rbp), %rdi
callq 0xb2020
movq $0x0, -0x18(%rbp)
jmp 0xb1d20
movq $0x1, -0x10(%rbp)
jmp 0xb1c6e
cmpq $0x0, -0x8(%rbp)
je 0xb1cdc
jmp 0xb1c77
jmp 0xb1c79
movq -0x8(%rbp), %rdi
xorl %esi, %esi
callq 0xb18e0
movq %rax, -0x28(%rbp)
testb $0x1, 0x7682b(%rip)     # 0x1284ba
je 0xb1c9e
movq -0x28(%rbp), %rdi
callq 0xb1fc0
movq %rax, -0x30(%rbp)
movq -0x10(%rbp), %rdi
callq 0xb15d0
movq %rax, -0x20(%rbp)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
xorl %eax, %eax
movl %eax, %ecx
xorl %r9d, %r9d
movq %rcx, %rdx
movl %r9d, %r8d
callq 0xb2040
movq %rax, -0x18(%rbp)
cmpq $0x0, -0x18(%rbp)
jne 0xb1cda
movl $0xc, %edi
callq 0xb16a0
jmp 0xb1d1e
callq 0xb1590
testb $0x1, %al
jne 0xb1ce7
jmp 0xb1cf1
movq $0x0, -0x18(%rbp)
jmp 0xb1d0b
movq -0x10(%rbp), %rdi
callq 0xb15d0
movq %rax, -0x20(%rbp)
movq -0x10(%rbp), %rdi
callq 0xb1670
movq %rax, -0x18(%rbp)
cmpq $0x0, -0x18(%rbp)
jne 0xb1d1c
movl $0xc, %edi
callq 0xb16a0
jmp 0xb1d1e
jmp 0xb1d20
cmpq $0x0, -0x18(%rbp)
je 0xb1d52
jmp 0xb1d29
jmp 0xb1d2b
callq 0xb16d0
movq %rax, -0x48(%rbp)
movq -0x20(%rbp), %rcx
movq -0x48(%rbp), %rax
addq (%rax), %rcx
movq %rcx, (%rax)
movq -0x28(%rbp), %rcx
movq -0x48(%rbp), %rax
addq 0x8(%rax), %rcx
movq %rcx, 0x8(%rax)
jmp 0xb1d54
testb $0x1, 0x7675f(%rip)     # 0x1284ba
je 0xb1fa9
movq -0x18(%rbp), %rdi
callq 0xb16f0
movq %rax, -0x50(%rbp)
movq -0x18(%rbp), %rax
cmpq -0x8(%rbp), %rax
jne 0xb1ddf
jmp 0xb1d7a
movq $0x130b, -0x80(%rbp)    # imm = 0x130B
movq -0x18(%rbp), %rax
movq %rax, -0x78(%rbp)
movq -0x28(%rbp), %rax
movq %rax, -0x70(%rbp)
movq -0x20(%rbp), %rax
movq %rax, -0x68(%rbp)
movq -0x50(%rbp), %rax
movq %rax, -0x60(%rbp)
movq $0x0, -0x58(%rbp)
leaq -0x80(%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, -0x88(%rbp)
movq -0x88(%rbp), %rax
movq %rax, -0x90(%rbp)
jmp 0xb1fa7
cmpq $0x0, -0x8(%rbp)
je 0xb1e5f
jmp 0xb1de8
movq $0x1302, -0xc0(%rbp) # imm = 0x1302
movq -0x8(%rbp), %rax
movq %rax, -0xb8(%rbp)
movq -0x30(%rbp), %rax
movq %rax, -0xb0(%rbp)
movq $0x0, -0xa8(%rbp)
movq $0x0, -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)
jmp 0xb1e5f
cmpq $0x0, -0x18(%rbp)
je 0xb1fa5
movq -0x28(%rbp), %rax
cmpq -0x20(%rbp), %rax
jae 0xb1e81
movq -0x28(%rbp), %rax
movq %rax, -0x168(%rbp)
jmp 0xb1e8c
movq -0x20(%rbp), %rax
movq %rax, -0x168(%rbp)
movq -0x168(%rbp), %rax
movq %rax, -0xd8(%rbp)
movq -0x20(%rbp), %rax
subq -0xd8(%rbp), %rax
movq %rax, -0xe0(%rbp)
movq $0x1301, -0x110(%rbp) # imm = 0x1301
movq -0x18(%rbp), %rax
movq %rax, -0x108(%rbp)
movq -0x20(%rbp), %rax
movq %rax, -0x100(%rbp)
movq -0x50(%rbp), %rax
movq %rax, -0xf8(%rbp)
movq $0x0, -0xf0(%rbp)
movq $0x0, -0xe8(%rbp)
leaq -0x110(%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, -0x118(%rbp)
movq -0x118(%rbp), %rax
movq %rax, -0x120(%rbp)
cmpq $0x0, -0xd8(%rbp)
jbe 0xb1fa3
movq $0x4d430002, -0x150(%rbp) # imm = 0x4D430002
movq -0x18(%rbp), %rax
movq %rax, -0x148(%rbp)
movq -0xd8(%rbp), %rax
movq %rax, -0x140(%rbp)
movq $0x0, -0x138(%rbp)
movq $0x0, -0x130(%rbp)
movq $0x0, -0x128(%rbp)
leaq -0x150(%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, -0x158(%rbp)
movq -0x158(%rbp), %rax
movq %rax, -0x160(%rbp)
jmp 0xb1fa5
jmp 0xb1fa7
jmp 0xb1fa9
jmp 0xb1fab
movq -0x18(%rbp), %rax
addq $0x170, %rsp            # imm = 0x170
popq %rbp
retq
nopl (%rax,%rax)