// File: /workspace/github_c_makefile_star2_O1/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 $0x38, %rsp
movl %r8d, 0x24(%rsp)
movq %rcx, %r12
movq %rdx, %r15
movq %rdi, %r14
cmpq $0x3801, %rdx           # imm = 0x3801
setae %al
cmpq $0x1000, %rcx           # imm = 0x1000
setae %cl
orb %al, %cl
movabsq $0x7000000000000000, %r11 # imm = 0x7000000000000000
pushq $-0x1
popq %rax
pushq $0x7
popq %rdx
jne 0x10339
leaq (%r15,%r12), %rcx
decq %rcx
movq %r12, %rdi
negq %rdi
andq %rcx, %rdi
cmpq $0x1000, %rdi           # imm = 0x1000
ja 0x1081e
decq %rdi
shrq $0x3, %rdi
leaq 0x2baa3(%rip), %rcx     # 0x3bdc0
movzbl (%rcx,%rdi), %ecx
leaq 0x2b318(%rip), %rdi     # 0x3b640
movq (%rdi,%rcx,8), %r9
cmpq $0x4000, %r9            # imm = 0x4000
jb 0x10422
leaq 0x3cc60(%rip), %rcx     # 0x4cfa0
leaq 0x3cd81(%rip), %rdi     # 0x4d0c8
movq (%rdi), %r8
movq %r12, %rdi
cmpq %r15, (%rcx)
jb 0x103be
movq %r12, %rdi
cmpq %r12, %r8
jbe 0x103be
leaq 0xfff(%r12), %rdi
andq $-0x1000, %rdi          # imm = 0xF000
movl $0x4000, %r9d           # imm = 0x4000
cmpq $0x4001, %r15           # imm = 0x4001
jb 0x103ae
cmpq %r11, %r15
ja 0x10881
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 0x3cc17(%rip), %r10     # 0x4cfd0
cmpq (%r10), %rcx
jbe 0x10422
cmpq %r11, %rdi
ja 0x10402
leaq 0x3cd06(%rip), %rcx     # 0x4d0d0
movq (%rcx), %r9
cmpq %r15, %r8
jae 0x10407
cmpq $0x1000, %r15           # imm = 0x1000
ja 0x1092c
leaq -0x1(%r15), %rax
shrq $0x3, %rax
leaq 0x2b9d2(%rip), %rcx     # 0x3bdc0
movzbl (%rcx,%rax), %eax
leaq 0x2b247(%rip), %rcx     # 0x3b640
movq (%rcx,%rax,8), %r8
cmpq %r15, %r8
jae 0x10407
xorl %r9d, %r9d
jmp 0x10422
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 0x106df
movq %rsi, %rbp
testq %r14, %r14
je 0x10459
movq 0x28(%r14), %rsi
testq %rsi, %rsi
jne 0x10461
pushq $0x1
popq %rsi
movq %r14, %rdi
callq 0x1b0d1
jmp 0x1045e
callq 0x1ad48
movq %rax, %rsi
xorl %ebx, %ebx
pushq $0x40
popq %rcx
movl $0x80, %edx
movq %r14, %rdi
xorl %r8d, %r8d
xorl %r9d, %r9d
callq 0xd4f0
testq %rax, %rax
je 0x106e1
movq %rax, %r13
movq %r14, 0x10(%rsp)
movq %rax, %rdi
leaq 0x3cc3c(%rip), %rax     # 0x4d0d0
movq (%rax), %r14
notq %r14
andq %r13, %r14
movq %r14, %rax
cmpq %r14, %r13
je 0x107e7
movq %r13, %rcx
movq (%rax), %rbx
subq %r14, %rcx
je 0x107f7
shrq $0xc, %rcx
leaq 0x3cafd(%rip), %rax     # 0x4cfc0
subq (%rax), %rcx
movq 0x78(%r14,%rcx,8), %rax
movl %eax, %ecx
shrl $0x5, %ecx
movl $0xff, %edx
andl %edx, %ecx
cmpl %edx, %ecx
je 0x1080a
movl %ecx, %eax
leaq 0x2b158(%rip), %rcx     # 0x3b640
movq (%rcx,%rax,8), %rax
movq 0x10(%rsp), %r14
lock
xaddq %rax, 0x90(%rbx)
testq %r13, %r13
je 0x106df
movq %rdi, 0x18(%rsp)
testq %r14, %r14
sete %al
movl 0x24(%rsp), %ecx
movb %cl, 0xf(%rsp)
testq %rbp, %rbp
setne %cl
orb %al, %cl
jne 0x1052d
movq 0x30(%r14), %rbp
testq %rbp, %rbp
je 0x10889
testq %rbp, %rbp
je 0x10631
leaq 0x30(%rsp), %r8
leaq 0xf(%rsp), %r9
movq %r14, %rdi
movq %rbp, %rsi
movq %r15, %rdx
movq %r12, %rcx
movq %rbp, 0x28(%rsp)
callq 0x21b6d
movq 0x28(%rsp), %r12
testq %rax, %rax
je 0x10631
movq %rax, %rbx
movq 0x30(%rsp), %rax
movb 0xf(%rsp), %cl
movq 0x18(%rsp), %rbp
movq %r12, (%rbp)
movq %rbx, 0x8(%rbp)
movq %r15, 0x10(%rbp)
movq %rax, 0x18(%rbp)
movb %cl, 0x20(%rbp)
movw $0x1, 0x21(%rbp)
movq %r14, %rdi
movq %rbx, %rsi
movq %rbp, %rdx
callq 0x266bc
testb %al, %al
je 0x106f3
movq 0x30(%rsp), %r8
movq %r14, %rdi
movq %r12, %rsi
movq %rbx, %rdx
movq %r15, %rcx
callq 0x21d63
leaq 0x3cb0f(%rip), %r8      # 0x4d0d0
movq (%r8), %r14
notq %r14
andq %r13, %r14
movq %r14, %rax
cmpq %r14, %r13
je 0x108e1
movq %r13, %rdx
movq (%rax), %rbx
subq %r14, %rdx
movq 0x18(%rsp), %rcx
je 0x108f7
shrq $0xc, %rdx
leaq 0x3c9cb(%rip), %rax     # 0x4cfc0
subq (%rax), %rdx
movq 0x78(%r14,%rdx,8), %rax
movl %eax, %esi
shrl $0x5, %esi
movl $0xff, %edx
andl %edx, %esi
cmpl %edx, %esi
je 0x10910
movl %esi, %eax
leaq 0x2b026(%rip), %rdx     # 0x3b640
movq (%rdx,%rax,8), %rax
movq 0x10(%rsp), %rdi
negq %rax
lock
xaddq %rax, 0x90(%rbx)
jmp 0x106a6
leaq 0x3ca98(%rip), %r8      # 0x4d0d0
movq (%r8), %r14
notq %r14
andq %r13, %r14
movq %r14, %rax
cmpq %r14, %r13
je 0x1089b
movq %r13, %rcx
movq (%rax), %rbx
subq %r14, %rcx
je 0x108b1
shrq $0xc, %rcx
leaq 0x3c959(%rip), %rax     # 0x4cfc0
subq (%rax), %rcx
movq 0x78(%r14,%rcx,8), %rax
movl %eax, %esi
shrl $0x5, %esi
movl $0xff, %edx
andl %edx, %esi
cmpl %edx, %esi
movq 0x18(%rsp), %rcx
je 0x108cd
movl %esi, %eax
leaq 0x2afaf(%rip), %rdx     # 0x3b640
movq (%rdx,%rax,8), %rax
movq 0x10(%rsp), %rdi
negq %rax
lock
xaddq %rax, 0x90(%rbx)
movq (%r8), %rdx
notq %rdx
andq %r13, %rdx
subq %rdx, %r13
je 0x10858
shrq $0xc, %r13
leaq 0x3c8fd(%rip), %rax     # 0x4cfc0
movq %r13, %rsi
subq (%rax), %rsi
testb $0x2, 0x78(%rdx,%rsi,8)
movq (%rdx), %rsi
jne 0x10865
movq %r13, %r8
callq 0xdf6b
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x830(%r12), %r13
movq %r13, %rdi
callq 0xb5a0
movq %rbp, 0x50(%rbp)
movq %rbp, 0x58(%rbp)
movq 0x828(%r12), %rax
testq %rax, %rax
je 0x1073c
movq 0x58(%rax), %rax
movq %rax, 0x58(%rbp)
movq 0x828(%r12), %rcx
movq %rcx, 0x50(%rbp)
movq %rbp, 0x50(%rax)
movq 0x828(%r12), %rax
movq %rbp, 0x58(%rax)
movq 0x50(%rbp), %rax
movq %rax, 0x828(%r12)
movq %r13, %rdi
callq 0xb380
cmpb $0x0, 0x24(%rsp)
je 0x1076d
cmpb $0x0, 0xf(%rsp)
jne 0x10789
movq %rbx, %rdi
xorl %esi, %esi
movq %r15, %rdx
callq 0xb230
jmp 0x10789
leaq 0x3bdbf(%rip), %rax     # 0x4c533
cmpb $0x1, (%rax)
je 0x10757
leaq 0x3bda1(%rip), %rax     # 0x4c521
cmpb $0x1, (%rax)
je 0x10963
testq %r14, %r14
je 0x106e1
movq 0x28(%rsp), %r8
movl (%r8), %esi
movq 0x38(%r14), %rax
testq %rax, %rax
je 0x1086f
cmpl %esi, 0x40(%r14)
jbe 0x1086f
leaq (%rax,%rsi,8), %rax
testq %rax, %rax
je 0x106e1
movl (%rax), %ecx
testl %ecx, %ecx
jle 0x10924
leal -0x1(%rcx), %edx
movl %edx, (%rax)
testl %ecx, %ecx
jg 0x106e1
movq %r14, %rdi
movq %r8, %rsi
xorl %edx, %edx
callq 0x226c8
jmp 0x106e1
movq %rdi, %rbx
callq 0x2e3aa
movq %rbx, %rdi
jmp 0x104a9
movq %rdi, %rsi
movq %rdi, %r14
callq 0x2e4e2
movq %r14, %rdi
jmp 0x104ec
shrq %rax
andq $-0x1000, %rax          # imm = 0xF000
addq $-0x1000, %rax          # imm = 0xF000
jmp 0x104ec
cmpq %r11, %rdi
ja 0x10970
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 0x1032c
movq %rcx, %rsi
callq 0x11227
jmp 0x106df
callq 0xdfd3
jmp 0x106df
movq %r14, %rdi
callq 0x1afa2
movq 0x28(%rsp), %r8
jmp 0x107b5
xorl %r9d, %r9d
jmp 0x103ae
movq %r14, %rdi
xorl %esi, %esi
callq 0x1b0d1
movq %rax, %rbp
jmp 0x1052d
movq 0x18(%rsp), %rdi
callq 0x2e3aa
leaq 0x3c824(%rip), %r8      # 0x4d0d0
jmp 0x1064d
movq 0x18(%rsp), %r14
movq %r14, %rsi
callq 0x2e4e2
leaq 0x3c80b(%rip), %r8      # 0x4d0d0
movq %r14, %rcx
jmp 0x10695
shrq %rax
andq $-0x1000, %rax          # imm = 0xF000
addq $-0x1000, %rax          # imm = 0xF000
jmp 0x10695
movq 0x18(%rsp), %rdi
callq 0x2e3aa
leaq 0x3c7de(%rip), %r8      # 0x4d0d0
jmp 0x105d6
movq %rcx, %rsi
callq 0x2e4e2
leaq 0x3c7ca(%rip), %r8      # 0x4d0d0
movq 0x18(%rsp), %rcx
jmp 0x1061e
shrq %rax
andq $-0x1000, %rax          # imm = 0xF000
addq $-0x1000, %rax          # imm = 0xF000
jmp 0x1061e
movl 0x4(%rax), %edx
jmp 0x107cb
cmpq %r11, %r15
ja 0x10978
leaq -0x1(,%r15,2), %rcx
bsrq %rcx, %r8
movl %r8d, %ecx
addb $-0x3, %cl
shlq %cl, %rax
cmpl $0x6, %r8d
notq %rax
cmovbq %rdx, %rax
leaq (%rax,%r15), %rcx
notq %rax
andq %rcx, %rax
movq %rax, %r8
jmp 0x103fd
movq %rbx, %rdi
movl $0xa5, %esi
jmp 0x10763
xorl %r9d, %r9d
jmp 0x1032c
xorl %r8d, %r8d
jmp 0x103fd