// File: /workspace/github_c_makefile_star2_O2/zhou-yuxin[P]redis-aof-no-cow/deps/jemalloc/src/huge.c
// Function: je_huge_palloc
void *
huge_palloc(tsdn_t *tsdn, arena_t *arena, size_t usize, size_t alignment,
    bool zero)
{
	void *ret;
	size_t ausize;
	arena_t *iarena;
	extent_node_t *node;
	size_t sn;
	bool is_zeroed;

	/* Allocate one or more contiguous chunks for this request. */

	assert(!tsdn_null(tsdn) || arena != NULL);

	ausize = sa2u(usize, alignment);
	if (unlikely(ausize == 0 || ausize > HUGE_MAXCLASS))
		return (NULL);
	assert(ausize >= chunksize);

	/* Allocate an extent node with which to track the chunk. */
	iarena = (!tsdn_null(tsdn)) ? arena_ichoose(tsdn_tsd(tsdn), NULL) :
	    a0get();
	node = ipallocztm(tsdn, CACHELINE_CEILING(sizeof(extent_node_t)),
	    CACHELINE, false, NULL, true, iarena);
	if (node == NULL)
		return (NULL);

	/*
	 * Copy zero into is_zeroed and pass the copy to chunk_alloc(), so that
	 * it is possible to make correct junk/zero fill decisions below.
	 */
	is_zeroed = zero;
	if (likely(!tsdn_null(tsdn)))
		arena = arena_choose(tsdn_tsd(tsdn), arena);
	if (unlikely(arena == NULL) || (ret = arena_chunk_alloc_huge(tsdn,
	    arena, usize, alignment, &sn, &is_zeroed)) == NULL) {
		idalloctm(tsdn, node, NULL, true, true);
		return (NULL);
	}

	extent_node_init(node, arena, ret, usize, sn, is_zeroed, true);

	if (huge_node_set(tsdn, ret, node)) {
		arena_chunk_dalloc_huge(tsdn, arena, ret, usize, sn);
		idalloctm(tsdn, node, NULL, true, true);
		return (NULL);
	}

	/* Insert node into huge. */
	malloc_mutex_lock(tsdn, &arena->huge_mtx);
	ql_elm_new(node, ql_link);
	ql_tail_insert(&arena->huge, node, ql_link);
	malloc_mutex_unlock(tsdn, &arena->huge_mtx);

	if (zero || (config_fill && unlikely(opt_zero))) {
		if (!is_zeroed)
			memset(ret, 0, usize);
	} else if (config_fill && unlikely(opt_junk_alloc))
		memset(ret, JEMALLOC_ALLOC_JUNK, usize);

	arena_decay_tick(tsdn, arena);
	return (ret);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movl %r8d, 0x1c(%rsp)
movq %rcx, %r12
movq %rdx, %r15
movq %rsi, %r14
movq %rdi, %rbp
cmpq $0x3801, %rdx           # imm = 0x3801
setae %al
cmpq $0x1000, %rcx           # imm = 0x1000
setae %cl
orb %al, %cl
movabsq $0x7000000000000000, %rsi # imm = 0x7000000000000000
pushq $-0x1
popq %rax
pushq $0x7
popq %rdx
jne 0x2812c
leaq (%r15,%r12), %rcx
decq %rcx
movq %r12, %rdi
negq %rdi
andq %rcx, %rdi
cmpq $0x1000, %rdi           # imm = 0x1000
ja 0x285a1
decq %rdi
shrq $0x3, %rdi
leaq 0xe8b0(%rip), %rcx      # 0x369c0
movzbl (%rcx,%rdi), %ecx
leaq 0xe125(%rip), %rdi      # 0x36240
movq (%rdi,%rcx,8), %r9
cmpq $0x4000, %r9            # imm = 0x4000
jb 0x28218
leaq 0x20e6d(%rip), %rcx     # 0x48fa0
leaq 0x20f8e(%rip), %rdi     # 0x490c8
movq (%rdi), %r8
movq %r12, %rdi
cmpq %r15, (%rcx)
jb 0x281b1
movq %r12, %rdi
cmpq %r12, %r8
jbe 0x281b1
leaq 0xfff(%r12), %rdi
andq $-0x1000, %rdi          # imm = 0xF000
movl $0x4000, %r9d           # imm = 0x4000
cmpq $0x4001, %r15           # imm = 0x4001
jb 0x281a1
cmpq %rsi, %r15
ja 0x285db
leaq -0x1(,%r15,2), %rcx
bsrq %rcx, %r10
movl %r10d, %ecx
addb $-0x3, %cl
movq %rax, %r9
shlq %cl, %r9
cmpl $0x6, %r10d
notq %r9
cmovbq %rdx, %r9
leaq (%r9,%r15), %rcx
notq %r9
andq %rcx, %r9
leaq (%r9,%rdi), %rcx
leaq 0x20e24(%rip), %r10     # 0x48fd0
cmpq (%r10), %rcx
jbe 0x28218
cmpq %rsi, %rdi
ja 0x2847a
leaq 0x20f0f(%rip), %rcx     # 0x490d0
movq (%rcx), %r9
cmpq %r15, %r8
jae 0x281fd
cmpq $0x1000, %r15           # imm = 0x1000
ja 0x28652
leaq -0x1(%r15), %rax
shrq $0x3, %rax
leaq 0xe7db(%rip), %rcx      # 0x369c0
movzbl (%rcx,%rax), %eax
leaq 0xe050(%rip), %rcx      # 0x36240
movq (%rcx,%rax,8), %r8
cmpq %r15, %r8
jb 0x2847a
addq %r9, %rdi
notq %r9
andq %rdi, %r9
movl $0xfff, %eax            # imm = 0xFFF
subq %r9, %rax
xorl %r9d, %r9d
cmpq %r8, %rax
cmovaeq %r8, %r9
movabsq $-0x7000000000000001, %rax # imm = 0x8FFFFFFFFFFFFFFF
addq %rax, %r9
incq %rax
cmpq %rax, %r9
jb 0x2847a
testq %rbp, %rbp
je 0x28245
pushq $0x1
popq %rdx
movq %rbp, %rdi
xorl %esi, %esi
callq 0x2938c
jmp 0x2824a
callq 0x12834
xorl %ebx, %ebx
pushq $0x40
popq %rcx
movl $0x80, %edx
movq %rbp, %rdi
movq %rax, %rsi
xorl %r8d, %r8d
xorl %r9d, %r9d
callq 0x1be89
testq %rax, %rax
je 0x2853f
movq %rax, %r13
movq %rbp, 0x10(%rsp)
movq %rax, %rbp
leaq 0x20e50(%rip), %rax     # 0x490d0
movq (%rax), %rax
notq %rax
andq %r13, %rax
movq %r13, %rcx
subq %rax, %rcx
je 0x28551
movq (%rax), %rbx
shrq $0xc, %rcx
leaq 0x20d1d(%rip), %rdx     # 0x48fc0
subq (%rdx), %rcx
movq 0x78(%rax,%rcx,8), %rax
movl %eax, %ecx
shrl $0x5, %ecx
movl $0xff, %edx
andl %edx, %ecx
cmpl %edx, %ecx
je 0x28569
movl %ecx, %eax
leaq 0xdf78(%rip), %rcx      # 0x36240
movq (%rcx,%rax,8), %rax
lock
xaddq %rax, 0x90(%rbx)
movl 0x1c(%rsp), %eax
movb %al, 0xf(%rsp)
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x282f4
movq %r14, %rsi
xorl %edx, %edx
callq 0x2938c
movq %rax, %r14
testq %r14, %r14
je 0x283da
leaq 0x20(%rsp), %r8
leaq 0xf(%rsp), %r9
movq 0x10(%rsp), %rdi
movq %r14, %rsi
movq %r15, %rdx
movq %r12, %rcx
callq 0x19f31
testq %rax, %rax
je 0x283da
movq %rax, %rbx
movq 0x20(%rsp), %rax
movb 0xf(%rsp), %cl
movq %r14, (%rbp)
movq %rbx, 0x8(%rbp)
movq %r15, 0x10(%rbp)
movq %rax, 0x18(%rbp)
movb %cl, 0x20(%rbp)
movw $0x1, 0x21(%rbp)
movq 0x10(%rsp), %r12
movq %r12, %rdi
movq %rbx, %rsi
movq %rbp, %rdx
callq 0x21302
testb %al, %al
je 0x28481
movq 0x20(%rsp), %r8
movq %r12, %rdi
movq %r14, %rsi
movq %rbx, %rdx
movq %r15, %rcx
callq 0x1a145
leaq 0x20d50(%rip), %r14     # 0x490d0
movq (%r14), %rax
notq %rax
andq %r13, %rax
movq %r13, %rcx
subq %rax, %rcx
je 0x2860f
movq (%rax), %rbx
shrq $0xc, %rcx
leaq 0x20c1d(%rip), %rdx     # 0x48fc0
subq (%rdx), %rcx
movq 0x78(%rax,%rcx,8), %rax
movl %eax, %ecx
shrl $0x5, %ecx
movl $0xff, %edx
andl %edx, %ecx
cmpl %edx, %ecx
je 0x28627
movl %ecx, %eax
leaq 0xde78(%rip), %rcx      # 0x36240
movq (%rcx,%rax,8), %rax
negq %rax
lock
xaddq %rax, 0x90(%rbx)
jmp 0x28439
leaq 0x20cef(%rip), %r14     # 0x490d0
movq (%r14), %rax
notq %rax
andq %r13, %rax
movq %r13, %rcx
subq %rax, %rcx
je 0x285e3
movq (%rax), %rbx
shrq $0xc, %rcx
leaq 0x20bbc(%rip), %rdx     # 0x48fc0
subq (%rdx), %rcx
movq 0x78(%rax,%rcx,8), %rax
movl %eax, %ecx
shrl $0x5, %ecx
movl $0xff, %edx
andl %edx, %ecx
cmpl %edx, %ecx
je 0x285fb
movl %ecx, %eax
leaq 0xde17(%rip), %rcx      # 0x36240
movq (%rcx,%rax,8), %rax
negq %rax
lock
xaddq %rax, 0x90(%rbx)
movq (%r14), %rdx
notq %rdx
andq %r13, %rdx
subq %rdx, %r13
je 0x2857d
shrq $0xc, %r13
leaq 0x20b6a(%rip), %rax     # 0x48fc0
movq %r13, %rcx
subq (%rax), %rcx
testb $0x2, 0x78(%rdx,%rcx,8)
movq (%rdx), %rsi
jne 0x2858f
movq 0x10(%rsp), %rdi
movq %rbp, %rcx
movq %r13, %r8
callq 0x1ca94
xorl %ebx, %ebx
jmp 0x2853f
leaq 0x830(%r14), %r12
movq %r12, %rdi
callq 0xb5a0
movq %rbp, 0x50(%rbp)
movq %rbp, 0x58(%rbp)
movq 0x828(%r14), %rax
testq %rax, %rax
je 0x284ca
movq 0x58(%rax), %rax
movq %rax, 0x58(%rbp)
movq 0x828(%r14), %rcx
movq %rcx, 0x50(%rbp)
movq %rbp, 0x50(%rax)
movq 0x828(%r14), %rax
movq %rbp, 0x58(%rax)
movq 0x50(%rbp), %rbp
movq %rbp, 0x828(%r14)
movq %r12, %rdi
callq 0xb380
cmpb $0x0, 0x1c(%rsp)
je 0x284fb
cmpb $0x0, 0xf(%rsp)
movq 0x10(%rsp), %r12
jne 0x2851c
movq %rbx, %rdi
xorl %esi, %esi
movq %r15, %rdx
callq 0xb230
jmp 0x2851c
leaq 0x20031(%rip), %rax     # 0x48533
cmpb $0x1, (%rax)
je 0x284e0
leaq 0x20013(%rip), %rax     # 0x48521
cmpb $0x1, (%rax)
movq 0x10(%rsp), %r12
je 0x28687
testq %r12, %r12
je 0x2853f
movl (%r14), %esi
movq %r12, %rdi
callq 0x293fd
testq %rax, %rax
je 0x2853f
movl (%rax), %ecx
testl %ecx, %ecx
jle 0x2863b
decl %ecx
movl %ecx, (%rax)
movq %rbx, %rax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rbp, %rdi
callq 0x28ce3
movq %rax, %rbx
movq %rbp, %rsi
callq 0x292e1
jmp 0x282cc
shrq %rax
andq $-0x1000, %rax          # imm = 0xF000
addq $-0x1000, %rax          # imm = 0xF000
jmp 0x282cc
movq 0x10(%rsp), %rdi
movq %rbp, %rsi
callq 0x28fb2
jmp 0x2847a
movq 0x10(%rsp), %rdi
movq %rbp, %rcx
callq 0x1cc1f
jmp 0x2847a
cmpq %rsi, %rdi
ja 0x2847a
leaq -0x1(,%rdi,2), %rcx
bsrq %rcx, %r8
movl %r8d, %ecx
addb $-0x3, %cl
movq %rax, %r9
shlq %cl, %r9
cmpl $0x6, %r8d
notq %r9
cmovbq %rdx, %r9
addq %r9, %rdi
notq %r9
andq %rdi, %r9
jmp 0x2811f
xorl %r9d, %r9d
jmp 0x281a1
movq %rbp, %rdi
callq 0x28ce3
movq %rax, %rbx
movq %rbp, %rsi
callq 0x292e1
jmp 0x2842d
shrq %rax
andq $-0x1000, %rax          # imm = 0xF000
addq $-0x1000, %rax          # imm = 0xF000
jmp 0x2842d
movq %rbp, %rdi
callq 0x28ce3
movq %rax, %rbx
movq %rbp, %rsi
callq 0x292e1
jmp 0x283cc
shrq %rax
andq $-0x1000, %rax          # imm = 0xF000
addq $-0x1000, %rax          # imm = 0xF000
jmp 0x283cc
movl 0x4(%rax), %ecx
movl %ecx, (%rax)
movq %r12, %rdi
movq %r14, %rsi
xorl %edx, %edx
callq 0x1aac4
jmp 0x2853f
cmpq %rsi, %r15
ja 0x28694
leaq -0x1(,%r15,2), %rcx
bsrq %rcx, %rsi
movl %esi, %ecx
addb $-0x3, %cl
shlq %cl, %rax
cmpl $0x6, %esi
notq %rax
cmovbq %rdx, %rax
leaq (%rax,%r15), %rcx
notq %rax
andq %rcx, %rax
movq %rax, %r8
jmp 0x281f4
movq %rbx, %rdi
movl $0xa5, %esi
jmp 0x284f1
xorl %r8d, %r8d
jmp 0x281f4