// File: /workspace/github_c_makefile_star2_O3/gplessis[P]dotdeb-redis/deps/jemalloc/src/arena.c
// Function: arena_run_split_remove
static void
arena_run_split_remove(arena_t *arena, arena_chunk_t *chunk, size_t run_ind,
    size_t flag_dirty, size_t flag_decommitted, size_t need_pages)
{
	size_t total_pages, rem_pages;

	assert(flag_dirty == 0 || flag_decommitted == 0);

	total_pages = arena_mapbits_unallocated_size_get(chunk, run_ind) >>
	    LG_PAGE;
	assert(arena_mapbits_dirty_get(chunk, run_ind+total_pages-1) ==
	    flag_dirty);
	assert(need_pages <= total_pages);
	rem_pages = total_pages - need_pages;

	arena_avail_remove(arena, chunk, run_ind, total_pages);
	if (flag_dirty != 0)
		arena_run_dirty_remove(arena, chunk, run_ind, total_pages);
	arena_cactive_update(arena, need_pages, 0);
	arena->nactive += need_pages;

	/* Keep track of trailing unused pages for later use. */
	if (rem_pages > 0) {
		size_t flags = flag_dirty | flag_decommitted;
		size_t flag_unzeroed_mask = (flags == 0) ?  CHUNK_MAP_UNZEROED :
		    0;

		arena_mapbits_unallocated_set(chunk, run_ind+need_pages,
		    (rem_pages << LG_PAGE), flags |
		    (arena_mapbits_unzeroed_get(chunk, run_ind+need_pages) &
		    flag_unzeroed_mask));
		arena_mapbits_unallocated_set(chunk, run_ind+total_pages-1,
		    (rem_pages << LG_PAGE), flags |
		    (arena_mapbits_unzeroed_get(chunk, run_ind+total_pages-1) &
		    flag_unzeroed_mask));
		if (flag_dirty != 0) {
			arena_run_dirty_insert(arena, chunk, run_ind+need_pages,
			    rem_pages);
		}
		arena_avail_insert(arena, chunk, run_ind+need_pages, rem_pages);
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %r9, %rbx
movq %r8, (%rsp)
movq %rcx, %r13
movq %rdx, %rbp
movq %rsi, %r14
movq %rdi, %r15
movq %rdx, %rax
subq 0x2f307(%rip), %rax     # 0x5b558
movq 0x68(%rsi,%rax,8), %r12
shrq $0xd, %r12
callq 0x2c402
testq %r13, %r13
je 0x2c2b8
movq 0x2f2f5(%rip), %rax     # 0x5b560
addq %r14, %rax
leaq (,%rbp,2), %rcx
addq %rbp, %rcx
shlq $0x5, %rcx
addq %rax, %rcx
xorl %eax, %eax
subq 0x2f2cf(%rip), %rax     # 0x5b558
leaq (%rax,%rax,2), %rax
shlq $0x5, %rax
addq %rcx, %rax
addq $0x10, %rax
movq (%rax), %rcx
movq 0x8(%rax), %rdx
movq %rcx, (%rdx)
movq 0x8(%rax), %rdx
movq %rdx, 0x8(%rcx)
movq %rax, (%rax)
movq %rax, 0x8(%rax)
subq %r12, 0xe8(%r15)
movq 0xe0(%r15), %rdx
leaq (%rdx,%rbx), %rax
movq %rax, %rcx
shlq $0xc, %rcx
leaq 0x2f3df(%rip), %rsi     # 0x5b6b0
movq (%rsi), %rsi
addq %rsi, %rcx
shlq $0xc, %rdx
addq %rsi, %rdx
notq %rsi
andq %rsi, %rcx
andq %rsi, %rdx
subq %rdx, %rcx
je 0x2c302
leaq 0x2fab5(%rip), %rax     # 0x5bda8
lock
xaddq %rcx, (%rax)
movq 0xe0(%r15), %rax
addq %rbx, %rax
movq %rax, 0xe0(%r15)
cmpq %rbx, %r12
jne 0x2c31d
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %r12, %rax
subq %rbx, %rax
xorl %ecx, %ecx
movq (%rsp), %r8
orq %r13, %r8
sete %cl
shll $0x3, %ecx
addq %rbp, %rbx
movq %rax, %rdx
shlq $0xd, %rdx
movq %rbx, %rsi
subq 0x2f212(%rip), %rsi     # 0x5b558
movl 0x68(%r14,%rsi,8), %edi
andl %ecx, %edi
orq %rdx, %rdi
orq $0x1fe0, %r8            # imm = 0x1FE0
orq %r8, %rdi
movq %rdi, 0x68(%r14,%rsi,8)
addq %rbp, %r12
movq 0x2f1ef(%rip), %rsi     # 0x5b558
notq %rsi
addq %r12, %rsi
andl 0x68(%r14,%rsi,8), %ecx
orq %rdx, %rcx
orq %r8, %rcx
movq %rcx, 0x68(%r14,%rsi,8)
testq %r13, %r13
je 0x2c3e6
movq 0x2f1d5(%rip), %rcx     # 0x5b560
addq %r14, %rcx
leaq (%rbx,%rbx,2), %rdx
shlq $0x5, %rdx
addq %rcx, %rdx
xorl %ecx, %ecx
subq 0x2f1b6(%rip), %rcx     # 0x5b558
leaq (%rcx,%rcx,2), %rcx
shlq $0x5, %rcx
addq %rdx, %rcx
addq $0x10, %rcx
movq %rcx, (%rcx)
movq %rcx, 0x8(%rcx)
leaq 0x158(%r15), %rdx
movq 0x160(%r15), %rsi
movq %rcx, (%rsi)
movq 0x8(%rcx), %rdi
movq %rdx, (%rdi)
movq 0x8(%rcx), %rdx
movq %rdx, 0x160(%r15)
movq %rsi, 0x8(%rcx)
addq %rax, 0xe8(%r15)
movq %r15, %rdi
movq %r14, %rsi
movq %rbx, %rdx
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x2bc79