// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x60, %rsp
movb %cl, %al
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
andb $0x1, %al
movb %al, -0x21(%rbp)
jmp 0xb691d
movq -0x20(%rbp), %rax
addq $0xfff, %rax            # imm = 0xFFF
andq $-0x1000, %rax          # imm = 0xF000
movq %rax, -0x20(%rbp)
movq -0x18(%rbp), %rax
addq -0x20(%rbp), %rax
subq $0x1000, %rax           # imm = 0x1000
movq %rax, -0x38(%rbp)
movq -0x10(%rbp), %rdi
addq $0x8, %rdi
callq 0xb5d20
movq -0x10(%rbp), %rdi
movq -0x38(%rbp), %rsi
movb -0x21(%rbp), %al
movl $0x1, %edx
movl $0xff, %ecx
andb $0x1, %al
movzbl %al, %r8d
callq 0xb6800
movq %rax, -0x50(%rbp)
cmpq $0x0, -0x50(%rbp)
jne 0xb6995
movq -0x10(%rbp), %rdi
addq $0x8, %rdi
callq 0xb5ee0
movq $0x0, -0x8(%rbp)
jmp 0xb6b3e
movq -0x50(%rbp), %rax
leaq 0x72830(%rip), %rcx     # 0x1291d0
movq (%rcx), %rcx
xorq $-0x1, %rcx
andq %rcx, %rax
movq %rax, -0x58(%rbp)
movq -0x50(%rbp), %rax
movq -0x20(%rbp), %rcx
subq $0x1, %rcx
addq %rcx, %rax
xorl %ecx, %ecx
subq -0x20(%rbp), %rcx
andq %rcx, %rax
movq -0x50(%rbp), %rcx
subq %rcx, %rax
movq %rax, -0x40(%rbp)
jmp 0xb69d3
movq -0x38(%rbp), %rax
subq -0x40(%rbp), %rax
subq -0x18(%rbp), %rax
movq %rax, -0x48(%rbp)
movq -0x50(%rbp), %rax
addq -0x40(%rbp), %rax
movq %rax, -0x30(%rbp)
cmpq $0x0, -0x40(%rbp)
je 0xb6a13
movq -0x10(%rbp), %rdi
movq -0x58(%rbp), %rsi
movq -0x50(%rbp), %rdx
movq -0x38(%rbp), %rcx
movq -0x38(%rbp), %r8
subq -0x40(%rbp), %r8
callq 0xb6b50
cmpq $0x0, -0x48(%rbp)
je 0xb6a3a
movq -0x10(%rbp), %rdi
movq -0x58(%rbp), %rsi
movq -0x30(%rbp), %rdx
movq -0x18(%rbp), %rcx
addq -0x48(%rbp), %rcx
movq -0x18(%rbp), %r8
xorl %r9d, %r9d
callq 0xb6c10
movq -0x10(%rbp), %rax
movq 0x58(%rax), %rcx
addq $0x1, %rcx
movq %rcx, 0x58(%rax)
movq -0x10(%rbp), %rax
movq 0x68(%rax), %rcx
addq $0x1, %rcx
movq %rcx, 0x68(%rax)
movq -0x18(%rbp), %rcx
movq -0x10(%rbp), %rax
addq 0x50(%rax), %rcx
movq %rcx, 0x50(%rax)
movq -0x10(%rbp), %rax
movq 0x70(%rax), %rax
movq -0x18(%rbp), %rcx
shrq $0xc, %rcx
subq $0x1, %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movq (%rax), %rcx
addq $0x1, %rcx
movq %rcx, (%rax)
movq -0x10(%rbp), %rax
movq 0x70(%rax), %rax
movq -0x18(%rbp), %rcx
shrq $0xc, %rcx
subq $0x1, %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movq 0x10(%rax), %rcx
addq $0x1, %rcx
movq %rcx, 0x10(%rax)
movq -0x10(%rbp), %rax
movq 0x70(%rax), %rax
movq -0x18(%rbp), %rcx
shrq $0xc, %rcx
subq $0x1, %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movq 0x18(%rax), %rcx
addq $0x1, %rcx
movq %rcx, 0x18(%rax)
movq -0x10(%rbp), %rdi
addq $0x8, %rdi
callq 0xb5ee0
movb -0x21(%rbp), %al
andb $0x1, %al
movzbl %al, %eax
cmpl $0x0, %eax
jne 0xb6b36
leaq 0x719ad(%rip), %rax     # 0x1284ab
testb $0x1, (%rax)
je 0xb6b17
movq -0x30(%rbp), %rdi
movq -0x18(%rbp), %rdx
movl $0xa5, %esi
callq 0x1f110
jmp 0xb6b34
leaq 0x7199e(%rip), %rax     # 0x1284bc
testb $0x1, (%rax)
je 0xb6b32
movq -0x30(%rbp), %rdi
movq -0x18(%rbp), %rdx
xorl %esi, %esi
callq 0x1f110
jmp 0xb6b34
jmp 0xb6b36
movq -0x30(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x60, %rsp
popq %rbp
retq
nopl (%rax,%rax)