// File: /workspace/github_c_makefile_star2_O1/erikdubbelboer[P]discnt/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 %r12
pushq %rbx
movq %r8, %r10
leaq -0x10(%rdx), %rax
leaq 0x44a7d(%rip), %rdx     # 0x846a0
movq (%rdx), %rdx
notq %rdx
andq %rax, %rdx
addq 0x4491d(%rip), %rdx     # 0x84550
subq %rdx, %rax
movabsq $-0x5555555555555555, %rdx # imm = 0xAAAAAAAAAAAAAAAB
mulq %rdx
shrq $0x6, %rdx
movq 0x448fa(%rip), %r14     # 0x84548
movq %r8, %rax
shrq $0xc, %rax
movq 0x68(%rsi,%rdx,8), %r15
addq %r14, %rdx
movl %r15d, %r11d
andl $0x10, %r11d
movl %r15d, %r8d
andl $0x4, %r8d
xorl %ebx, %ebx
testb $0x14, %r15b
sete %bl
shll $0x3, %ebx
addq %rdx, %rax
notq %r14
addq %rax, %r14
movl 0x68(%rsi,%r14,8), %r12d
andl %ebx, %r12d
orq %r11, %r12
movl $0x1fe3, %r15d          # imm = 0x1FE3
orq %r15, %r12
movq %r12, 0x68(%rsi,%r14,8)
subq 0x448a8(%rip), %rdx     # 0x84548
movl 0x68(%rsi,%rdx,8), %r14d
andl %ebx, %r14d
leaq (%r10,%r10), %r12
orq %r11, %r12
orq %r15, %r12
orq %r14, %r12
movq %r12, 0x68(%rsi,%rdx,8)
leaq (%rax,%rax,2), %rdx
subq 0x44883(%rip), %rax     # 0x84548
subq %r10, %rcx
andl 0x68(%rsi,%rax,8), %ebx
addq %rcx, %rcx
orq %r11, %rcx
orq %r15, %rcx
orq %rbx, %rcx
movq %rcx, 0x68(%rsi,%rax,8)
addq 0x4486c(%rip), %rsi     # 0x84550
shlq $0x5, %rdx
addq %rsi, %rdx
xorl %eax, %eax
movq 0x44854(%rip), %rcx     # 0x84548
subq %rcx, %rax
leaq (%rax,%rax,2), %rax
shlq $0x5, %rax
leaq (%rax,%rdx), %rsi
addq $0x10, %rsi
shrl $0x2, %r8d
movl %r9d, %edx
xorl %ecx, %ecx
popq %rbx
popq %r12
popq %r14
popq %r15
jmp 0x3eaa3