// File: /workspace/github_c_makefile_star2_O1/zhou-yuxin[P]redis-aof-no-cow/deps/jemalloc/src/jemalloc.c
// Function: je_xallocx
JEMALLOC_NOTHROW
je_xallocx(void *ptr, size_t size, size_t extra, int flags)
{
	tsd_t *tsd;
	size_t usize, old_usize;
	UNUSED size_t old_rzsize JEMALLOC_CC_SILENCE_INIT(0);
	size_t alignment = MALLOCX_ALIGN_GET(flags);
	bool zero = flags & MALLOCX_ZERO;

	assert(ptr != NULL);
	assert(size != 0);
	assert(SIZE_T_MAX - size >= extra);
	assert(malloc_initialized() || IS_INITIALIZER);
	malloc_thread_init();
	tsd = tsd_fetch();
	witness_assert_lockless(tsd_tsdn(tsd));

	old_usize = isalloc(tsd_tsdn(tsd), ptr, config_prof);

	/*
	 * The API explicitly absolves itself of protecting against (size +
	 * extra) numerical overflow, but we may need to clamp extra to avoid
	 * exceeding HUGE_MAXCLASS.
	 *
	 * Ordinarily, size limit checking is handled deeper down, but here we
	 * have to check as part of (size + extra) clamping, since we need the
	 * clamped value in the above helper functions.
	 */
	if (unlikely(size > HUGE_MAXCLASS)) {
		usize = old_usize;
		goto label_not_resized;
	}
	if (unlikely(HUGE_MAXCLASS - size < extra))
		extra = HUGE_MAXCLASS - size;

	if (config_valgrind && unlikely(in_valgrind))
		old_rzsize = u2rz(old_usize);

	if (config_prof && opt_prof) {
		usize = ixallocx_prof(tsd, ptr, old_usize, size, extra,
		    alignment, zero);
	} else {
		usize = ixallocx_helper(tsd_tsdn(tsd), ptr, old_usize, size,
		    extra, alignment, zero);
	}
	if (unlikely(usize == old_usize))
		goto label_not_resized;

	if (config_stats) {
		*tsd_thread_allocatedp_get(tsd) += usize;
		*tsd_thread_deallocatedp_get(tsd) += old_usize;
	}
	JEMALLOC_VALGRIND_REALLOC(no, tsd_tsdn(tsd), ptr, usize, no, ptr,
	    old_usize, old_rzsize, no, zero);
label_not_resized:
	UTRACE(ptr, size, ptr);
	witness_assert_lockless(tsd_tsdn(tsd));
	return (usize);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rdx, %r8
movl $0x1, %r13d
shlq %cl, %r13
movq %rsi, %rbp
movq %rdi, %r14
cmpq $0x0, 0x2d1d8(%rip)     # 0x4c528
jne 0x1f4c9
movq 0x2cc8b(%rip), %rdi     # 0x4bfe8
movq %fs:0x0, %rax
addq %rdi, %rax
movq %rax, (%rsp)
movl %fs:(%rdi), %eax
testl %eax, %eax
je 0x1f5cc
cmpl $0x2, %eax
je 0x1f605
leaq 0x2dd48(%rip), %r9      # 0x4d0d0
movq (%r9), %rax
notq %rax
andq %r14, %rax
cmpq %r14, %rax
je 0x1f4dd
movq %r14, %rsi
subq %rax, %rsi
shrq $0xc, %rsi
leaq 0x2dc15(%rip), %rdx     # 0x4cfc0
subq (%rdx), %rsi
movq 0x78(%rax,%rsi,8), %rbx
movl %ebx, %eax
shrl $0x5, %eax
movl $0xff, %edx
andl %edx, %eax
cmpl %edx, %eax
je 0x1f50d
movl %eax, %eax
leaq 0x1c270(%rip), %rdx     # 0x3b640
movq (%rdx,%rax,8), %rbx
movabsq $0x7000000000000000, %rax # imm = 0x7000000000000000
cmpq %rax, %rbp
ja 0x1f508
subq %rbp, %rax
cmpq %r8, %rax
jb 0x1f523
andq $-0x2, %r13
cmpb $0x1, 0x2d19e(%rip)     # 0x4c59c
je 0x1f52b
testq %r13, %r13
je 0x1f418
decq %r13
movq %rbx, %r12
testq %r14, %r13
jne 0x1f49b
movl %ecx, %r13d
movq %r9, %r12
movl %ecx, %r9d
andl $0x40, %r9d
shrl $0x6, %r9d
movq %rdi, %r15
movq (%rsp), %rdi
movq %r14, %rsi
movq %rbx, %rdx
movq %rbp, %rcx
callq 0xe06d
movq %r12, %rdx
movq %r15, %rdi
movl %r13d, %ecx
movq %rbx, %r12
testb %al, %al
jne 0x1f49b
movq (%rdx), %rax
notq %rax
andq %r14, %rax
cmpq %r14, %rax
je 0x1f5d5
movq %r14, %rsi
subq %rax, %rsi
shrq $0xc, %rsi
leaq 0x2db4f(%rip), %rdx     # 0x4cfc0
subq (%rdx), %rsi
movq 0x78(%rax,%rsi,8), %r12
movl %r12d, %eax
shrl $0x5, %eax
movl $0xff, %edx
andl %edx, %eax
cmpl %edx, %eax
je 0x1f5ef
movl %eax, %eax
leaq 0x1c1a9(%rip), %rdx     # 0x3b640
movq (%rdx,%rax,8), %r12
cmpq %rbx, %r12
je 0x1f4b7
addq %r12, %fs:0x10(%rdi)
addq %rbx, %fs:0x18(%rdi)
cmpb $0x1, 0x2d0eb(%rip)     # 0x4c59c
je 0x1f552
movq %r12, %rax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl %ecx, %ebx
movq %r8, %r15
callq 0xc5da
movq %r15, %r8
movl %ebx, %ecx
jmp 0x1f356
movq %rdi, %r15
movq (%rsp), %rdi
movq %r14, %rsi
movl %ecx, %ebx
movq %r8, %r12
callq 0x2e4e2
leaq 0x2dbd8(%rip), %r9      # 0x4d0d0
movq %r12, %r8
movq %r15, %rdi
movl %ebx, %ecx
movq %rax, %rbx
jmp 0x1f3d4
movq %rbx, %r12
jmp 0x1f4b7
shrq %rbx
andq $-0x1000, %rbx          # imm = 0xF000
addq $-0x1000, %rbx          # imm = 0xF000
jmp 0x1f3d4
movq %rax, %r8
jmp 0x1f3f3
movq %rbx, %rdi
movl %ecx, %r12d
movq %r8, %r15
callq 0x1d519
leaq 0x2db90(%rip), %r9      # 0x4d0d0
movq %r15, %r8
movq 0x2ca9e(%rip), %rdi     # 0x4bfe8
movl %r12d, %ecx
jmp 0x1f404
movq (%rsp), %rdi
movq %r14, %rsi
movl %ecx, %ebp
callq 0x1bc38
leaq 0x10(%rsp), %rcx
movq $0x130b, (%rcx)         # imm = 0x130B
movq %r14, 0x8(%rcx)
movq %rbx, 0x10(%rcx)
movq %r12, 0x18(%rcx)
movq %rax, 0x20(%rcx)
movq $0x0, 0x28(%rcx)
movq %rcx, %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, %bpl
je 0x1f4b7
movq %r12, %rsi
subq %rbx, %rsi
jbe 0x1f4b7
addq %r14, %rbx
movq %rbx, %rdi
callq 0x37158
jmp 0x1f4b7
movl $0x1, %fs:(%rdi)
jmp 0x1f60c
movq (%rsp), %rdi
movq %r14, %rsi
callq 0x2e4e2
movq %r15, %rdi
movl %r13d, %ecx
movq %rax, %r12
jmp 0x1f49b
shrq %r12
andq $-0x1000, %r12          # imm = 0xF000
addq $-0x1000, %r12          # imm = 0xF000
jmp 0x1f49b
movl $0x3, %fs:(%rdi)
leaq 0x2dec1(%rip), %rax     # 0x4d4d4
movq %rdi, %r15
movl (%rax), %edi
movq (%rsp), %rsi
movl %ecx, %ebx
movq %r8, %r12
callq 0xb5b0
movq %r12, %r8
movq %r15, %rdi
movl %ebx, %ecx
testl %eax, %eax
je 0x1f381
leaq 0x1cb44(%rip), %rdi     # 0x3c181
callq 0x35efc
movq %r12, %r8
movq %r15, %rdi
movl %ebx, %ecx
cmpb $0x1, 0x2cecf(%rip)     # 0x4c520
jne 0x1f381
callq 0xb070