// File: /workspace/github_c_makefile_star2_O0/Oric4ever[P]lcc65/6502/build/../src/tree.c
// Function: allocate
char *allocate(int n, Arena *p) {
	Arena ap = *p;

	while (ap->avail + n > ap->limit)
		if (ap->next) {		/* move to next arena */
			ap = ap->next;
			ap->avail = (char *)ap + roundup(sizeof *ap, sizeof (double));
		} else if (freearenas) {
		    ap->next = freearenas;
			freearenas = freearenas->next;
			ap = ap->next;
			ap->avail = (char *)ap + roundup(sizeof *ap, sizeof (double));
			ap->first = (*p)->first;
			ap->next = 0;
		} else {		/* allocate a new arena */
			int m = n + MEMINCR*1024 + roundup(sizeof *ap, sizeof (double));
			ap->next = (Arena) malloc(m);
			assert(ap->next);
			if ((char *)ap->next == ap->limit) /* extend previous arena? */
				ap->limit = (char *)ap->next + m;
			else {			/* link to a new arena */
				ap = ap->next;
				ap->limit = (char *)ap + m;
				ap->avail = (char *)ap + roundup(sizeof *ap, sizeof (double));
			}
			ap->first = (*p)->first;
			ap->next = 0;
		}
	*p = ap;
	ap->avail += n;
	return ap->avail - n;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movl %edi, -0x4(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rax
movslq -0x4(%rbp), %rcx
addq %rcx, %rax
movq -0x18(%rbp), %rcx
cmpq 0x10(%rcx), %rax
jbe 0x2556f
movq -0x18(%rbp), %rax
cmpq $0x0, 0x20(%rax)
je 0x25433
movq -0x18(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rcx
addq $0x28, %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x8(%rax)
jmp 0x2556a
cmpq $0x0, 0x1bb95(%rip)     # 0x40fd0
je 0x2549e
movq 0x1bb8c(%rip), %rcx     # 0x40fd0
movq -0x18(%rbp), %rax
movq %rcx, 0x20(%rax)
movq 0x1bb7d(%rip), %rax     # 0x40fd0
movq 0x20(%rax), %rax
movq %rax, 0x1bb72(%rip)     # 0x40fd0
movq -0x18(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rcx
addq $0x28, %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq 0x18(%rax), %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x18(%rax)
movq -0x18(%rbp), %rax
movq $0x0, 0x20(%rax)
jmp 0x25568
movl -0x4(%rbp), %eax
addl $0x2800, %eax           # imm = 0x2800
cltq
addq $0x28, %rax
movl %eax, -0x1c(%rbp)
movslq -0x1c(%rbp), %rdi
callq 0x3130
movq %rax, %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x20(%rax)
movq -0x18(%rbp), %rax
cmpq $0x0, 0x20(%rax)
je 0x254d0
jmp 0x254ef
leaq 0xcd8c(%rip), %rdi      # 0x32263
leaq 0xcd8e(%rip), %rsi      # 0x3226c
movl $0x21, %edx
leaq 0xcd90(%rip), %rcx      # 0x3227a
callq 0x30c0
movq -0x18(%rbp), %rax
movq 0x20(%rax), %rax
movq -0x18(%rbp), %rcx
cmpq 0x10(%rcx), %rax
jne 0x2551a
movq -0x18(%rbp), %rax
movq 0x20(%rax), %rcx
movslq -0x1c(%rbp), %rax
addq %rax, %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x10(%rax)
jmp 0x25549
movq -0x18(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rcx
movslq -0x1c(%rbp), %rax
addq %rax, %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x18(%rbp), %rcx
addq $0x28, %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq 0x18(%rax), %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x18(%rax)
movq -0x18(%rbp), %rax
movq $0x0, 0x20(%rax)
jmp 0x2556a
jmp 0x253ea
movq -0x18(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, (%rax)
movl -0x4(%rbp), %edx
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rcx
movslq %edx, %rdx
addq %rdx, %rcx
movq %rcx, 0x8(%rax)
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rax
movslq -0x4(%rbp), %rdx
xorl %ecx, %ecx
subq %rdx, %rcx
addq %rcx, %rax
addq $0x20, %rsp
popq %rbp
retq
nopl (%rax)