// File: /workspace/github_c_makefile_star2_O3/zhou-yuxin[P]redis-aof-no-cow/deps/jemalloc/src/quarantine.c
// Function: je_quarantine
void
quarantine(tsd_t *tsd, void *ptr)
{
	quarantine_t *quarantine;
	size_t usize = isalloc(tsd_tsdn(tsd), ptr, config_prof);

	cassert(config_fill);
	assert(opt_quarantine);

	if ((quarantine = tsd_quarantine_get(tsd)) == NULL) {
		idalloctm(tsd_tsdn(tsd), ptr, NULL, false, true);
		return;
	}
	/*
	 * Drain one or more objects if the quarantine size limit would be
	 * exceeded by appending ptr.
	 */
	if (quarantine->curbytes + usize > opt_quarantine) {
		size_t upper_bound = (opt_quarantine >= usize) ? opt_quarantine
		    - usize : 0;
		quarantine_drain(tsd_tsdn(tsd), quarantine, upper_bound);
	}
	/* Grow the quarantine ring buffer if it's full. */
	if (quarantine->curobjs == (ZU(1) << quarantine->lg_maxobjs))
		quarantine = quarantine_grow(tsd, quarantine);
	/* quarantine_grow() must free a slot if it fails to grow. */
	assert(quarantine->curobjs < (ZU(1) << quarantine->lg_maxobjs));
	/* Append ptr if its size doesn't exceed the quarantine size. */
	if (quarantine->curbytes + usize <= opt_quarantine) {
		size_t offset = (quarantine->first + quarantine->curobjs) &
		    ((ZU(1) << quarantine->lg_maxobjs) - 1);
		quarantine_obj_t *obj = &quarantine->objs[offset];
		obj->ptr = ptr;
		obj->usize = usize;
		quarantine->curbytes += usize;
		quarantine->curobjs++;
		if (config_fill && unlikely(opt_junk_free)) {
			/*
			 * Only do redzone validation if Valgrind isn't in
			 * operation.
			 */
			if ((!config_valgrind || likely(!in_valgrind))
			    && usize <= SMALL_MAXCLASS)
				arena_quarantine_junk_small(ptr, usize);
			else
				memset(ptr, JEMALLOC_FREE_JUNK, usize);
		}
	} else {
		assert(quarantine->curbytes == 0);
		idalloctm(tsd_tsdn(tsd), ptr, NULL, false, true);
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rsi, %rbx
movq %rdi, %r14
leaq 0x1d2bb(%rip), %rbp     # 0x4d0d0
movq (%rbp), %rax
notq %rax
andq %rsi, %rax
cmpq %rsi, %rax
je 0x300f2
movq %rbx, %rcx
subq %rax, %rcx
shrq $0xc, %rcx
leaq 0x1d187(%rip), %rdx     # 0x4cfc0
subq (%rdx), %rcx
movq 0x78(%rax,%rcx,8), %r15
movl %r15d, %eax
shrl $0x5, %eax
movl $0xff, %ecx
andl %ecx, %eax
cmpl %ecx, %eax
je 0x30105
movl %eax, %eax
leaq 0xb861(%rip), %rcx      # 0x3b6c0
movq (%rcx,%rax,8), %r15
movq 0x50(%r14), %r12
testq %r12, %r12
je 0x2fed9
movq (%r12), %rax
leaq (%rax,%r15), %rdx
leaq 0x1c6ad(%rip), %rcx     # 0x4c528
movq (%rcx), %rcx
cmpq %rcx, %rdx
jbe 0x2feab
xorl %r13d, %r13d
subq %r15, %rcx
cmovaeq %rcx, %r13
cmpq %r13, %rax
jbe 0x2feab
cmpq $0x0, 0x8(%r12)
je 0x2feab
movq %r14, %rdi
movq %r12, %rsi
callq 0x302f0
cmpq %r13, (%r12)
ja 0x2fe92
movq 0x18(%r12), %rcx
movl $0x1, %eax
shlq %cl, %rax
cmpq %rax, 0x8(%r12)
je 0x2ff81
movq %r12, %r13
movq (%r13), %rax
addq %r15, %rax
leaq 0x1c654(%rip), %rcx     # 0x4c528
cmpq (%rcx), %rax
jbe 0x2ff2a
movq (%rbp), %rdx
notq %rdx
andq %rbx, %rdx
cmpq %rbx, %rdx
je 0x3011b
movq %rbx, %r8
subq %rdx, %r8
shrq $0xc, %r8
leaq 0x1d0c3(%rip), %rax     # 0x4cfc0
movq %r8, %rcx
subq (%rax), %rcx
testb $0x2, 0x78(%rdx,%rcx,8)
movq (%rdx), %rsi
movq %r14, %rdi
movq %rbx, %rcx
jne 0x30134
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xd9f4
movq 0x8(%r13), %rdx
movq 0x10(%r13), %rsi
movb 0x18(%r13), %cl
movq $-0x1, %rdi
shlq %cl, %rdi
addq %rdx, %rsi
notq %rdi
andq %rsi, %rdi
shlq $0x4, %rdi
movq %rbx, 0x20(%r13,%rdi)
movq %r15, 0x28(%r13,%rdi)
movq %rax, (%r13)
incq %rdx
movq %rdx, 0x8(%r13)
leaq 0x1c5b9(%rip), %rax     # 0x4c522
cmpb $0x1, (%rax)
je 0x30147
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
incq %rcx
movq %r14, %rdi
movq %rcx, %rsi
callq 0x10ce0
testq %rax, %rax
je 0x30018
movq %rax, %r13
movq (%r12), %rax
movq %rax, (%r13)
movq 0x8(%r12), %rdx
movq %rdx, 0x8(%r13)
movq 0x10(%r12), %rax
leaq (%rax,%rdx), %rdi
movb 0x18(%r12), %cl
movl $0x1, %esi
shlq %cl, %rsi
cmpq %rsi, %rdi
jbe 0x30028
subq %rax, %rsi
subq %rsi, %rdx
movq %rdx, 0x10(%rsp)
leaq 0x20(%r13), %rdi
leaq 0x20(%r12), %rcx
movq %rcx, (%rsp)
shlq $0x4, %rax
movq %rsi, %rdx
leaq (%r12,%rax), %rsi
addq $0x20, %rsi
shlq $0x4, %rdx
movq %rdx, 0x8(%rsp)
callq 0xb340
movq 0x8(%rsp), %rax
leaq (%rax,%r13), %rdi
addq $0x20, %rdi
movq 0x10(%rsp), %rdx
shlq $0x4, %rdx
movq (%rsp), %rsi
jmp 0x3003f
movq %r14, %rdi
movq %r12, %rsi
callq 0x302f0
jmp 0x2fec3
movq %r13, %rdi
addq $0x20, %rdi
shlq $0x4, %rax
leaq (%r12,%rax), %rsi
addq $0x20, %rsi
shlq $0x4, %rdx
callq 0xb340
movq (%rbp), %rax
notq %rax
andq %r12, %rax
cmpq %rax, %r12
je 0x30157
movq (%rax), %rsi
cmpq %r12, %rax
je 0x30171
movq %r12, %rcx
subq %rax, %rcx
shrq $0xc, %rcx
leaq 0x1cf4c(%rip), %rdx     # 0x4cfc0
subq (%rdx), %rcx
movq 0x78(%rax,%rcx,8), %rax
movl %eax, %ecx
shrl $0x5, %ecx
movl $0xff, %edx
andl %edx, %ecx
cmpl %edx, %ecx
je 0x30199
movl %ecx, %eax
leaq 0xb627(%rip), %rcx      # 0x3b6c0
movq (%rcx,%rax,8), %rax
negq %rax
lock
xaddq %rax, 0x90(%rsi)
movq (%rbp), %rdx
notq %rdx
andq %r12, %rdx
movq %r12, %r8
subq %rdx, %r8
je 0x30189
shrq $0xc, %r8
leaq 0x1cef6(%rip), %rax     # 0x4cfc0
movq %r8, %rcx
subq (%rax), %rcx
testb $0x2, 0x78(%rdx,%rcx,8)
movq (%rdx), %rsi
movq %r14, %rdi
movq %r12, %rcx
jne 0x301ad
callq 0xd9f4
movq %r13, 0x50(%r14)
jmp 0x2fec6
movq %r14, %rdi
movq %rbx, %rsi
callq 0x2e344
movq %rax, %r15
jmp 0x2fe63
shrq %r15
andq $-0x1000, %r15          # imm = 0xF000
addq $-0x1000, %r15          # imm = 0xF000
jmp 0x2fe63
movq %r14, %rdi
movq %rbx, %rsi
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x10a30
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xda57
movq %r15, %rdi
movq %rbx, %rsi
callq 0x10e93
jmp 0x2ff72
movq %r12, %rdi
callq 0x2e203
movq %rax, %rsi
movq (%rbp), %rax
notq %rax
andq %r12, %rax
jmp 0x3005a
movq %r14, %rdi
movq %rsi, (%rsp)
movq %r12, %rsi
callq 0x2e344
movq (%rsp), %rsi
jmp 0x3009d
movq %r14, %rdi
movq %r12, %rsi
callq 0x10a30
jmp 0x300e9
shrq %rax
andq $-0x1000, %rax          # imm = 0xF000
addq $-0x1000, %rax          # imm = 0xF000
jmp 0x3009d
callq 0xda57
jmp 0x300e9