// File: /workspace/github_c_makefile_star2_O0/gplessis[P]dotdeb-redis/deps/jemalloc/src/chunk_dss.c
// Function: je_chunk_alloc_dss
void *
chunk_alloc_dss(arena_t *arena, void *new_addr, size_t size, size_t alignment,
    bool *zero, bool *commit)
{
	cassert(have_dss);
	assert(size > 0 && (size & chunksize_mask) == 0);
	assert(alignment > 0 && (alignment & chunksize_mask) == 0);

	/*
	 * sbrk() uses a signed increment argument, so take care not to
	 * interpret a huge allocation request as a negative increment.
	 */
	if ((intptr_t)size < 0)
		return (NULL);

	malloc_mutex_lock(&dss_mtx);
	if (dss_prev != (void *)-1) {

		/*
		 * The loop is necessary to recover from races with other
		 * threads that are using the DSS for something other than
		 * malloc.
		 */
		do {
			void *ret, *cpad, *dss_next;
			size_t gap_size, cpad_size;
			intptr_t incr;
			/* Avoid an unnecessary system call. */
			if (new_addr != NULL && dss_max != new_addr)
				break;

			/* Get the current end of the DSS. */
			dss_max = chunk_dss_sbrk(0);

			/* Make sure the earlier condition still holds. */
			if (new_addr != NULL && dss_max != new_addr)
				break;

			/*
			 * Calculate how much padding is necessary to
			 * chunk-align the end of the DSS.
			 */
			gap_size = (chunksize - CHUNK_ADDR2OFFSET(dss_max)) &
			    chunksize_mask;
			/*
			 * Compute how much chunk-aligned pad space (if any) is
			 * necessary to satisfy alignment.  This space can be
			 * recycled for later use.
			 */
			cpad = (void *)((uintptr_t)dss_max + gap_size);
			ret = (void *)ALIGNMENT_CEILING((uintptr_t)dss_max,
			    alignment);
			cpad_size = (uintptr_t)ret - (uintptr_t)cpad;
			dss_next = (void *)((uintptr_t)ret + size);
			if ((uintptr_t)ret < (uintptr_t)dss_max ||
			    (uintptr_t)dss_next < (uintptr_t)dss_max) {
				/* Wrap-around. */
				malloc_mutex_unlock(&dss_mtx);
				return (NULL);
			}
			incr = gap_size + cpad_size + size;
			dss_prev = chunk_dss_sbrk(incr);
			if (dss_prev == dss_max) {
				/* Success. */
				dss_max = dss_next;
				malloc_mutex_unlock(&dss_mtx);
				if (cpad_size != 0) {
					chunk_hooks_t chunk_hooks =
					    CHUNK_HOOKS_INITIALIZER;
					chunk_dalloc_wrapper(arena,
					    &chunk_hooks, cpad, cpad_size,
					    true);
				}
				if (*zero) {
					JEMALLOC_VALGRIND_MAKE_MEM_UNDEFINED(
					    ret, size);
					memset(ret, 0, size);
				}
				if (!*commit)
					*commit = pages_decommit(ret, size);
				return (ret);
			}
		} while (dss_prev != (void *)-1);
	}
	malloc_mutex_unlock(&dss_mtx);

	return (NULL);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xa0, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movq %r8, -0x30(%rbp)
movq %r9, -0x38(%rbp)
jmp 0x52385
jmp 0x52387
jmp 0x52389
jmp 0x5238b
jmp 0x5238d
cmpq $0x0, -0x20(%rbp)
jge 0x523a1
movq $0x0, -0x8(%rbp)
jmp 0x525d0
leaq 0x50398(%rip), %rdi     # 0xa2740
callq 0x522e0
movq $-0x1, %rax
cmpq %rax, 0x503ad(%rip)     # 0xa2768
je 0x525bc
jmp 0x523c3
cmpq $0x0, -0x18(%rbp)
je 0x523dc
movq 0x5039f(%rip), %rax     # 0xa2770
cmpq -0x18(%rbp), %rax
je 0x523dc
jmp 0x525ba
xorl %eax, %eax
movl %eax, %edi
callq 0x525e0
movq %rax, 0x50384(%rip)     # 0xa2770
cmpq $0x0, -0x18(%rbp)
je 0x52405
movq 0x50376(%rip), %rax     # 0xa2770
cmpq -0x18(%rbp), %rax
je 0x52405
jmp 0x525ba
leaq 0x5031c(%rip), %rax     # 0xa2728
movq (%rax), %rax
movq 0x5035a(%rip), %rcx     # 0xa2770
leaq 0x50313(%rip), %rdx     # 0xa2730
andq (%rdx), %rcx
subq %rcx, %rax
leaq 0x50306(%rip), %rcx     # 0xa2730
andq (%rcx), %rax
movq %rax, -0x58(%rbp)
movq 0x50338(%rip), %rax     # 0xa2770
addq -0x58(%rbp), %rax
movq %rax, -0x48(%rbp)
movq 0x50329(%rip), %rax     # 0xa2770
movq -0x28(%rbp), %rcx
subq $0x1, %rcx
addq %rcx, %rax
xorl %ecx, %ecx
subq -0x28(%rbp), %rcx
andq %rcx, %rax
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rax
movq -0x48(%rbp), %rcx
subq %rcx, %rax
movq %rax, -0x60(%rbp)
movq -0x40(%rbp), %rax
addq -0x20(%rbp), %rax
movq %rax, -0x50(%rbp)
movq -0x40(%rbp), %rax
movq 0x502eb(%rip), %rcx     # 0xa2770
cmpq %rcx, %rax
jb 0x5249a
movq -0x50(%rbp), %rax
movq 0x502db(%rip), %rcx     # 0xa2770
cmpq %rcx, %rax
jae 0x524b3
leaq 0x5029f(%rip), %rdi     # 0xa2740
callq 0x52300
movq $0x0, -0x8(%rbp)
jmp 0x525d0
movq -0x58(%rbp), %rax
addq -0x60(%rbp), %rax
addq -0x20(%rbp), %rax
movq %rax, -0x68(%rbp)
movq -0x68(%rbp), %rdi
callq 0x525e0
movq %rax, 0x50295(%rip)     # 0xa2768
movq 0x5028e(%rip), %rax     # 0xa2768
cmpq 0x5028f(%rip), %rax     # 0xa2770
jne 0x525a4
movq -0x50(%rbp), %rax
movq %rax, 0x5027e(%rip)     # 0xa2770
leaq 0x50247(%rip), %rdi     # 0xa2740
callq 0x52300
cmpq $0x0, -0x60(%rbp)
je 0x52536
leaq -0xa0(%rbp), %rdi
xorl %esi, %esi
movl $0x38, %edx
callq 0x10250
movq -0x10(%rbp), %rdi
movq -0x48(%rbp), %rdx
movq -0x60(%rbp), %rcx
leaq -0xa0(%rbp), %rsi
movl $0x1, %r8d
callq 0x515c0
movq -0x30(%rbp), %rax
testb $0x1, (%rax)
je 0x52579
jmp 0x52541
leaq 0x4f1bc(%rip), %rax     # 0xa1704
movb (%rax), %al
xorb $-0x1, %al
xorb $-0x1, %al
andb $0x1, %al
movzbl %al, %eax
cltq
cmpq $0x0, %rax
je 0x52568
movq -0x40(%rbp), %rdi
movq -0x20(%rbp), %rsi
callq 0x7faa0
jmp 0x5256a
movq -0x40(%rbp), %rdi
movq -0x20(%rbp), %rdx
xorl %esi, %esi
callq 0x10250
movq -0x38(%rbp), %rax
testb $0x1, (%rax)
jne 0x5259a
movq -0x40(%rbp), %rdi
movq -0x20(%rbp), %rsi
callq 0x64680
movb %al, %cl
movq -0x38(%rbp), %rax
andb $0x1, %cl
movb %cl, (%rax)
movq -0x40(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x525d0
jmp 0x525a6
movq $-0x1, %rax
cmpq %rax, 0x501b4(%rip)     # 0xa2768
jne 0x523c3
jmp 0x525bc
leaq 0x5017d(%rip), %rdi     # 0xa2740
callq 0x52300
movq $0x0, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0xa0, %rsp
popq %rbp
retq
nopl (%rax)