// File: /workspace/github_c_makefile_star2_O2/gplessis[P]dotdeb-redis/deps/jemalloc/src/arena.c
// Function: arena_run_trim_tail
static void
arena_run_trim_tail(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(chunk, pageind + head_npages);
	tail_run = &tail_miscelm->run;
	arena_run_dalloc(arena, tail_run, dirty, false, (flag_decommitted !=
	    0));
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
leaq -0x10(%rdx), %rax
leaq 0x2f0d2(%rip), %rdx     # 0x576b0
movq (%rdx), %rdx
notq %rdx
andq %rax, %rdx
addq 0x2ef72(%rip), %rdx     # 0x57560
subq %rdx, %rax
xorl %r11d, %r11d
movabsq $0x60, %r10
xorl %edx, %edx
divq %r10
movq 0x2ef4e(%rip), %r15     # 0x57558
movq %r8, %rdx
shrq $0xc, %rdx
movq 0x68(%rsi,%rax,8), %r12
addq %r15, %rax
movl %r12d, %ebx
andl $0x10, %ebx
movl %r12d, %r10d
andl $0x4, %r10d
xorl %r14d, %r14d
testb $0x14, %r12b
sete %r14b
shll $0x3, %r14d
addq %rax, %rdx
notq %r15
addq %rdx, %r15
movl 0x68(%rsi,%r15,8), %r13d
andl %r14d, %r13d
orq %rbx, %r13
movl $0x1fe3, %r12d          # imm = 0x1FE3
orq %r12, %r13
movq %r13, 0x68(%rsi,%r15,8)
subq 0x2eefa(%rip), %rax     # 0x57558
movl 0x68(%rsi,%rax,8), %r15d
andl %r14d, %r15d
leaq (%r8,%r8), %r13
orq %rbx, %r13
orq %r12, %r13
orq %r15, %r13
movq %r13, 0x68(%rsi,%rax,8)
imulq $0x60, %rdx, %rax
subq 0x2eed5(%rip), %rdx     # 0x57558
andl 0x68(%rsi,%rdx,8), %r14d
subq %r8, %rcx
addq %rcx, %rcx
orq %rbx, %rcx
orq %r12, %rcx
orq %r14, %rcx
movq %rcx, 0x68(%rsi,%rdx,8)
addq 0x2eebd(%rip), %rsi     # 0x57560
addq %rax, %rsi
movq 0x2eeab(%rip), %rax     # 0x57558
subq %rax, %r11
imulq $0x60, %r11, %rax
addq %rax, %rsi
addq $0x10, %rsi
shrl $0x2, %r10d
movl %r9d, %edx
xorl %ecx, %ecx
movl %r10d, %r8d
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
jmp 0x2761e