// File: /workspace/github_c_makefile_star2_O1/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 0x52057(%rip), %rax     # 0xdf880
movq (%rax), %rax
notq %rax
andq %rdi, %rax
cmpq %rdi, %rax
je 0x8d86e
movq %rbx, %rcx
subq %rax, %rcx
shrq $0xc, %rcx
leaq 0x520e0(%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 0x8d87b
andq $-0x1000, %r14          # imm = 0xF000
jmp 0x8d88a
movq %rbx, %rdi
callq 0x8bc15
movq %rax, %r14
jmp 0x8d88a
imulq $0x68, %rax, %rax
leaq 0x5137a(%rip), %rcx     # 0xdec00
movq (%rcx,%rax), %r14
movq %fs:-0x10, %r15
cmpq $0x2, %r15
ja 0x8d8be
je 0x8d978
testq %r15, %r15
jne 0x8d9f4
movl $0xa, %edi
callq 0x8da7f
movq %rax, %r15
testq %rax, %rax
je 0x8d9f4
movq (%r15), %rcx
addq %r14, %rcx
leaq 0x51295(%rip), %r13     # 0xdeb60
movq (%r13), %rax
cmpq %rax, %rcx
jbe 0x8d8e5
xorl %esi, %esi
subq %r14, %rax
cmovaeq %rax, %rsi
movq %r15, %rdi
callq 0x8dfec
movq 0x18(%r15), %rcx
movl $0x1, %eax
shlq %cl, %rax
cmpq %rax, 0x8(%r15)
jne 0x8d973
incq %rcx
movq %rcx, %rdi
callq 0x8da7f
testq %rax, %rax
je 0x8d973
movq %rax, %r12
movq (%r15), %rax
movq %rax, (%r12)
movq 0x8(%r15), %rax
movq %rax, 0x8(%r12)
movq 0x8(%r15), %r13
movq 0x10(%r15), %rax
leaq (%rax,%r13), %rdx
movb 0x18(%r15), %cl
movl $0x1, %ebp
shlq %cl, %rbp
cmpq %rbp, %rdx
jbe 0x8d9c1
subq %rax, %rbp
subq %rbp, %r13
leaq 0x20(%r12), %rdi
shlq $0x4, %rax
leaq (%r15,%rax), %rsi
addq $0x20, %rsi
addq $0x20, %r15
shlq $0x4, %rbp
movq %rbp, %rdx
callq 0x1fbd0
leaq (%r12,%rbp), %rdi
addq $0x20, %rdi
shlq $0x4, %r13
movq %r15, %rsi
jmp 0x8d9d8
movq %r15, %r12
jmp 0x8d9e7
movq %fs:0x0, %rax
leaq -0x10(%rax), %rsi
movq $0x1, %fs:-0x10
movl 0x631d9(%rip), %edi     # 0xf0b74
callq 0x1f1c0
testl %eax, %eax
je 0x8d9f4
leaq 0x15cee(%rip), %rdi     # 0xa3699
callq 0x9124c
leaq 0x511a3(%rip), %rax     # 0xdeb5a
cmpb $0x1, (%rax)
jne 0x8d9f4
callq 0x1f1b0
movq %r12, %rdi
addq $0x20, %rdi
shlq $0x4, %rax
leaq (%r15,%rax), %rsi
addq $0x20, %rsi
shlq $0x4, %r13
movq %r13, %rdx
callq 0x1fbd0
leaq 0x51179(%rip), %r13     # 0xdeb60
movq (%r12), %rax
addq %r14, %rax
cmpq (%r13), %rax
jbe 0x8da0a
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x8dd43
movq 0x8(%r12), %rdx
movq 0x10(%r12), %rsi
movb 0x18(%r12), %cl
movq $-0x1, %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 0x5110e(%rip), %rax     # 0xdeb5b
cmpb $0x1, (%rax)
jne 0x8da70
movq %rbx, %rdi
movl $0x5a, %esi
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