// File: /workspace/github_c_makefile_star2_O2/nilyang[P]redis-tdd-annotation/deps/jemalloc/src/quarantine.c
// Function: quarantine
void
quarantine(void *ptr)
{
	quarantine_t *quarantine;
	size_t usize = isalloc(ptr, config_prof);

	cassert(config_fill);
	assert(opt_quarantine);

	quarantine = *quarantine_tsd_get();
	if ((uintptr_t)quarantine <= (uintptr_t)QUARANTINE_STATE_MAX) {
		if (quarantine == NULL) {
			if ((quarantine = quarantine_init(LG_MAXOBJS_INIT)) ==
			    NULL) {
				idalloc(ptr);
				return;
			}
		} else {
			if (quarantine == QUARANTINE_STATE_PURGATORY) {
				/*
				 * Make a note that quarantine() was called
				 * after quarantine_cleanup() was called.
				 */
				quarantine = QUARANTINE_STATE_REINCARNATED;
				quarantine_tsd_set(&quarantine);
			}
			idalloc(ptr);
			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(quarantine, upper_bound);
	}
	/* Grow the quarantine ring buffer if it's full. */
	if (quarantine->curobjs == (ZU(1) << quarantine->lg_maxobjs))
		quarantine = quarantine_grow(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 (opt_junk)
			memset(ptr, 0x5a, usize);
	} else {
		assert(quarantine->curbytes == 0);
		idalloc(ptr);
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %rbx
leaq 0x58593(%rip), %rax     # 0xdc880
movq (%rax), %rax
notq %rax
andq %rdi, %rax
cmpq %rdi, %rax
je 0x84332
movq %rbx, %rcx
subq %rax, %rcx
shrq $0xc, %rcx
leaq 0x5861c(%rip), %rdx     # 0xdc928
subq (%rdx), %rcx
imulq $0x18, %rcx, %rcx
movq 0x40(%rax,%rcx), %r14
movl %r14d, %eax
shrl $0x4, %eax
movl $0xff, %ecx
andl %ecx, %eax
cmpl %ecx, %eax
jne 0x8433f
andq $-0x1000, %r14          # imm = 0xF000
jmp 0x8434e
movq %rbx, %rdi
callq 0x829cd
movq %rax, %r14
jmp 0x8434e
imulq $0x68, %rax, %rax
leaq 0x578b6(%rip), %rcx     # 0xdbc00
movq (%rcx,%rax), %r14
movq %fs:-0x10, %r15
cmpq $0x2, %r15
ja 0x84380
je 0x8442f
testq %r15, %r15
jne 0x84473
pushq $0xa
popq %rdi
callq 0x844f8
movq %rax, %r15
testq %rax, %rax
je 0x84473
movq (%r15), %rcx
addq %r14, %rcx
leaq 0x577d3(%rip), %rbp     # 0xdbb60
movq (%rbp), %rax
cmpq %rax, %rcx
jbe 0x843a7
xorl %esi, %esi
subq %r14, %rax
cmovaeq %rax, %rsi
movq %r15, %rdi
callq 0x848f5
movq 0x18(%r15), %rcx
pushq $0x1
popq %r13
movq %r13, %rax
shlq %cl, %rax
cmpq %rax, 0x8(%r15)
jne 0x8442a
incq %rcx
movq %rcx, %rdi
callq 0x844f8
testq %rax, %rax
je 0x8442a
movq %rax, %r12
movq (%r15), %rax
movq %rax, (%r12)
movq 0x8(%r15), %rbp
movq %rbp, 0x8(%r12)
movq 0x10(%r15), %rax
leaq (%rax,%rbp), %rdx
movb 0x18(%r15), %cl
shlq %cl, %r13
cmpq %r13, %rdx
jbe 0x84440
subq %rax, %r13
subq %r13, %rbp
leaq 0x20(%r12), %rdi
shlq $0x4, %rax
leaq (%r15,%rax), %rsi
addq $0x20, %rsi
addq $0x20, %r15
shlq $0x4, %r13
movq %r13, %rdx
callq 0x1fbd0
leaq (%r12,%r13), %rdi
addq $0x20, %rdi
shlq $0x4, %rbp
movq %r15, %rsi
jmp 0x84457
movq %r15, %r12
jmp 0x84466
movq %rsp, %rdi
movq $0x1, (%rdi)
callq 0x848aa
jmp 0x84473
movq %r12, %rdi
addq $0x20, %rdi
shlq $0x4, %rax
leaq (%r15,%rax), %rsi
addq $0x20, %rsi
shlq $0x4, %rbp
movq %rbp, %rdx
callq 0x1fbd0
leaq 0x576fa(%rip), %rbp     # 0xdbb60
movq (%r12), %rax
addq %r14, %rax
cmpq (%rbp), %rax
jbe 0x84489
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x846cd
movq 0x8(%r12), %rdx
movq 0x10(%r12), %rsi
movb 0x18(%r12), %cl
pushq $-0x1
popq %rdi
shlq %cl, %rdi
addq %rdx, %rsi
notq %rdi
andq %rsi, %rdi
shlq $0x4, %rdi
movq %rbx, 0x20(%r12,%rdi)
movq %r14, 0x28(%r12,%rdi)
movq %rax, (%r12)
incq %rdx
movq %rdx, 0x8(%r12)
leaq 0x57693(%rip), %rax     # 0xdbb5b
cmpb $0x1, (%rax)
jne 0x844e9
pushq $0x5a
popq %rsi
movq %rbx, %rdi
movq %r14, %rdx
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x1f110
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq