// File: /workspace/github_c_makefile_star2_O1/nilyang[P]redis-tdd-annotation/deps/jemalloc/src/arena.c
// Function: arena_palloc
void *
arena_palloc(arena_t *arena, size_t size, size_t alignment, bool zero)
{
	void *ret;
	size_t alloc_size, leadsize, trailsize;
	arena_run_t *run;
	arena_chunk_t *chunk;

	assert((size & PAGE_MASK) == 0);

	alignment = PAGE_CEILING(alignment);
	alloc_size = size + alignment - PAGE;

	malloc_mutex_lock(&arena->lock);
	run = arena_run_alloc(arena, alloc_size, true, BININD_INVALID, zero);
	if (run == NULL) {
		malloc_mutex_unlock(&arena->lock);
		return (NULL);
	}
	chunk = (arena_chunk_t *)CHUNK_ADDR2BASE(run);

	leadsize = ALIGNMENT_CEILING((uintptr_t)run, alignment) -
	    (uintptr_t)run;
	assert(alloc_size >= leadsize + size);
	trailsize = alloc_size - leadsize - size;
	ret = (void *)((uintptr_t)run + leadsize);
	if (leadsize != 0) {
		arena_run_trim_head(arena, chunk, run, alloc_size, alloc_size -
		    leadsize);
	}
	if (trailsize != 0) {
		arena_run_trim_tail(arena, chunk, ret, size + trailsize, size,
		    false);
	}

	if (config_stats) {
		arena->stats.nmalloc_large++;
		arena->stats.nrequests_large++;
		arena->stats.allocated_large += size;
		arena->stats.lstats[(size >> LG_PAGE) - 1].nmalloc++;
		arena->stats.lstats[(size >> LG_PAGE) - 1].nrequests++;
		arena->stats.lstats[(size >> LG_PAGE) - 1].curruns++;
	}
	malloc_mutex_unlock(&arena->lock);

	if (config_fill && zero == false) {
		if (opt_junk)
			memset(ret, 0xa5, size);
		else if (opt_zero)
			memset(ret, 0, size);
	}
	return (ret);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %ecx, %r13d
movq %rdx, %rbx
movq %rsi, %r14
movq %rdi, %r12
addq $0xfff, %rbx            # imm = 0xFFF
movq $-0x1000, %rbp          # imm = 0xF000
andq %rbp, %rbx
addq %rsi, %rbp
addq %rbx, %rbp
leaq 0x8(%rdi), %r15
movq %r15, %rdi
callq 0x1faa0
movl $0xff, %ecx
movq %r12, %rdi
movq %rbp, %rsi
movl $0x1, %edx
movl %r13d, %r8d
callq 0x80cbf
testq %rax, %rax
je 0x80ef0
movl %r13d, 0x4(%rsp)
leaq 0x5eac6(%rip), %rcx     # 0xdf880
movq (%rcx), %r13
notq %r13
andq %rax, %r13
leaq (%rbx,%rax), %rcx
decq %rcx
negq %rbx
andq %rcx, %rbx
movq %rax, %rcx
subq %rbx, %rcx
leaq (%rcx,%rbp), %rbp
je 0x80e81
movq %rax, %r8
subq %r13, %r8
shrq $0xc, %r8
negq %rcx
movq %rcx, %rsi
shrq $0xc, %rsi
leaq 0x5eb2d(%rip), %rdi     # 0xdf928
movq (%rdi), %r9
movq %r8, %rdx
subq %r9, %rdx
leaq (%rdx,%rdx,2), %rdx
movq 0x40(%r13,%rdx,8), %rdx
andl $0x8, %edx
addq %r8, %rsi
notq %r9
addq %rsi, %r9
leaq (%r9,%r9,2), %r10
movq 0x40(%r13,%r10,8), %r11
andl $0x4, %r11d
orq %rdx, %r11
movl $0xff3, %r9d            # imm = 0xFF3
orq %r9, %r11
movq %r11, 0x40(%r13,%r10,8)
subq (%rdi), %r8
leaq (%r8,%r8,2), %r8
movq 0x40(%r13,%r8,8), %r10
andl $0x4, %r10d
orq %rdx, %rcx
orq %r9, %rcx
orq %r10, %rcx
movq %rcx, 0x40(%r13,%r8,8)
subq (%rdi), %rsi
leaq (%rsi,%rsi,2), %rcx
movq 0x40(%r13,%rcx,8), %rsi
andl $0x4, %esi
orq %rdx, %rsi
orq %rbp, %r9
orq %rsi, %r9
movq %r9, 0x40(%r13,%rcx,8)
movq %r12, %rdi
movq %rax, %rsi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0x81526
cmpq %r14, %rbp
je 0x80e9d
movq %r12, %rdi
movq %r13, %rsi
movq %rbx, %rdx
movq %rbp, %rcx
movq %r14, %r8
xorl %r9d, %r9d
callq 0x80f33
incq 0x58(%r12)
incq 0x68(%r12)
addq %r14, 0x50(%r12)
movq 0x70(%r12), %rax
movq %r14, %rcx
shrq $0x7, %rcx
andq $-0x20, %rcx
incq -0x20(%rcx,%rax)
incq -0x10(%rcx,%rax)
incq -0x8(%rcx,%rax)
movq %r15, %rdi
callq 0x1fbb0
cmpb $0x0, 0x4(%rsp)
jne 0x80efa
leaq 0x5dc7a(%rip), %rax     # 0xdeb5b
cmpb $0x1, (%rax)
jne 0x80f0c
movq %rbx, %rdi
movl $0xa5, %esi
jmp 0x80f1d
movq %r15, %rdi
callq 0x1fbb0
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x5dc59(%rip), %rax     # 0xdeb6c
cmpb $0x1, (%rax)
jne 0x80efa
movq %rbx, %rdi
xorl %esi, %esi
movq %r14, %rdx
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x1f110