// File: /workspace/github_c_makefile_star2_O1/zhou-yuxin[P]redis-aof-no-cow/deps/jemalloc/src/arena.c
// Function: arena_run_trim_tail
static void
arena_run_trim_tail(tsdn_t *tsdn, arena_t *arena, arena_chunk_t *chunk,
    arena_run_t *run, size_t oldsize, size_t newsize, bool dirty)
{
	arena_chunk_map_misc_t *miscelm = arena_run_to_miscelm(run);
	size_t pageind = arena_miscelm_to_pageind(miscelm);
	size_t head_npages = newsize >> LG_PAGE;
	size_t flag_dirty = arena_mapbits_dirty_get(chunk, pageind);
	size_t flag_decommitted = arena_mapbits_decommitted_get(chunk, pageind);
	size_t flag_unzeroed_mask = (flag_dirty | flag_decommitted) == 0 ?
	    CHUNK_MAP_UNZEROED : 0;
	arena_chunk_map_misc_t *tail_miscelm;
	arena_run_t *tail_run;

	assert(oldsize > newsize);

	/*
	 * Update the chunk map so that arena_run_dalloc() can treat the
	 * trailing run as separately allocated.  Set the last element of each
	 * run first, in case of single-page runs.
	 */
	assert(arena_mapbits_large_size_get(chunk, pageind) == oldsize);
	arena_mapbits_large_set(chunk, pageind+head_npages-1, 0, flag_dirty |
	    (flag_unzeroed_mask & arena_mapbits_unzeroed_get(chunk,
	    pageind+head_npages-1)));
	arena_mapbits_large_set(chunk, pageind, newsize, flag_dirty |
	    (flag_unzeroed_mask & arena_mapbits_unzeroed_get(chunk, pageind)));

	if (config_debug) {
		UNUSED size_t tail_npages = (oldsize - newsize) >> LG_PAGE;
		assert(arena_mapbits_large_size_get(chunk,
		    pageind+head_npages+tail_npages-1) == 0);
		assert(arena_mapbits_dirty_get(chunk,
		    pageind+head_npages+tail_npages-1) == flag_dirty);
	}
	arena_mapbits_large_set(chunk, pageind+head_npages, oldsize-newsize,
	    flag_dirty | (flag_unzeroed_mask & arena_mapbits_unzeroed_get(chunk,
	    pageind+head_npages)));

	tail_miscelm = arena_miscelm_get_mutable(chunk, pageind + head_npages);
	tail_run = &tail_miscelm->run;
	arena_run_dalloc(tsdn, arena, tail_run, dirty, false, (flag_decommitted
	    != 0));
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movq %rdx, %r11
movb 0x38(%rsp), %bl
leaq -0x18(%rcx), %rax
leaq 0x3d259(%rip), %rcx     # 0x4d0d0
movq (%rcx), %rcx
notq %rcx
andq %rax, %rcx
addq 0x3d141(%rip), %rcx     # 0x4cfc8
subq %rcx, %rax
xorl %ecx, %ecx
movabsq $0x60, %r10
xorl %edx, %edx
divq %r10
movq 0x3d11e(%rip), %r12     # 0x4cfc0
movq %r9, %rdx
shrq $0xc, %rdx
movq 0x78(%r11,%rax,8), %r13
addq %r12, %rax
movl %r13d, %r14d
andl $0x10, %r14d
movl %r13d, %r10d
andl $0x4, %r10d
xorl %r15d, %r15d
testb $0x14, %r13b
sete %r15b
shll $0x3, %r15d
addq %rax, %rdx
notq %r12
addq %rdx, %r12
movl 0x78(%r11,%r12,8), %ebp
andl %r15d, %ebp
orq %r14, %rbp
movl $0x1fe3, %r13d          # imm = 0x1FE3
orq %r13, %rbp
movq %rbp, 0x78(%r11,%r12,8)
subq 0x3d0c9(%rip), %rax     # 0x4cfc0
movl 0x78(%r11,%rax,8), %r12d
andl %r15d, %r12d
leaq (%r9,%r9), %rbp
orq %r14, %rbp
orq %r13, %rbp
orq %r12, %rbp
movq %rbp, 0x78(%r11,%rax,8)
subq %r9, %r8
imulq $0x60, %rdx, %rax
subq 0x3d0a1(%rip), %rdx     # 0x4cfc0
andl 0x78(%r11,%rdx,8), %r15d
addq %r8, %r8
orq %r14, %r8
orq %r13, %r8
orq %r15, %r8
movq %r8, 0x78(%r11,%rdx,8)
addq 0x3d08c(%rip), %r11     # 0x4cfc8
addq %rax, %r11
movq 0x3d07a(%rip), %rax     # 0x4cfc0
subq %rax, %rcx
imulq $0x60, %rcx, %rax
leaq (%rax,%r11), %rdx
addq $0x18, %rdx
shrl $0x2, %r10d
movzbl %bl, %ecx
xorl %r8d, %r8d
movl %r10d, %r9d
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xf459