// File: /workspace/github_c_makefile_star2_O3/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 0x51e1b(%rip), %rax     # 0xdf880
movq (%rax), %rax
notq %rax
andq %rdi, %rax
cmpq %rdi, %rax
je 0x8daaa
movq %rbx, %rcx
subq %rax, %rcx
shrq $0xc, %rcx
leaq 0x51ea4(%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 0x8dab7
andq $-0x1000, %r14          # imm = 0xF000
jmp 0x8dac6
movq %rbx, %rdi
callq 0x8be94
movq %rax, %r14
jmp 0x8dac6
imulq $0x68, %rax, %rax
leaq 0x5113e(%rip), %rcx     # 0xdec00
movq (%rcx,%rax), %r14
movq %fs:-0x10, %r15
cmpq $0x2, %r15
ja 0x8dafa
je 0x8dbb0
testq %r15, %r15
jne 0x8dc2c
movl $0xa, %edi
callq 0x8dcb7
movq %rax, %r15
testq %rax, %rax
je 0x8dc2c
movq (%r15), %rcx
addq %r14, %rcx
leaq 0x51059(%rip), %r13     # 0xdeb60
movq (%r13), %rax
cmpq %rax, %rcx
jbe 0x8db21
xorl %esi, %esi
subq %r14, %rax
cmovaeq %rax, %rsi
movq %r15, %rdi
callq 0x8e23b
movq 0x18(%r15), %rcx
movl $0x1, %eax
shlq %cl, %rax
cmpq %rax, 0x8(%r15)
jne 0x8dbab
incq %rcx
movq %rcx, %rdi
callq 0x8dcb7
testq %rax, %rax
je 0x8dbab
movq %rax, %r12
movq (%r15), %rax
movq %rax, (%r12)
movq 0x8(%r15), %r13
movq %r13, 0x8(%r12)
movq 0x10(%r15), %rax
leaq (%rax,%r13), %rdx
movb 0x18(%r15), %cl
movl $0x1, %ebp
shlq %cl, %rbp
cmpq %rbp, %rdx
jbe 0x8dbf9
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 0x8dc10
movq %r15, %r12
jmp 0x8dc1f
movq %fs:0x0, %rax
leaq -0x10(%rax), %rsi
movq $0x1, %fs:-0x10
movl 0x62fa1(%rip), %edi     # 0xf0b74
callq 0x1f1c0
testl %eax, %eax
je 0x8dc2c
leaq 0x15bb6(%rip), %rdi     # 0xa3799
callq 0x915d4
leaq 0x50f6b(%rip), %rax     # 0xdeb5a
cmpb $0x1, (%rax)
jne 0x8dc2c
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 0x50f41(%rip), %r13     # 0xdeb60
movq (%r12), %rax
addq %r14, %rax
cmpq (%r13), %rax
jbe 0x8dc42
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x8df80
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 0x50ed6(%rip), %rax     # 0xdeb5b
cmpb $0x1, (%rax)
jne 0x8dca8
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