// File: /workspace/github_c_makefile_star2_O2/haxlang[P]hax/haxUtil.c
// Function: SetupAppendBuffer
static void
SetupAppendBuffer(
    Interp *iPtr,	/* Interpreter whose result is being set up. */
    int newSpace		/* Make sure that at least this many bytes
				 * of new information may be added. */)
{
    Hax_Memoryp *memoryp = iPtr->memoryp;
    int totalSpace;

    /*
     * Make the append buffer larger, if that's necessary, then
     * copy the current result into the append buffer and make the
     * append buffer the official Hax result.
     */

    if (iPtr->result != iPtr->appendResult) {
	/*
	 * If an oversized buffer was used recently, then free it up
	 * so we go back to a smaller buffer.  This avoids tying up
	 * memory forever after a large operation.
	 */

	if (iPtr->appendAvl > 500) {
	    ckfree(memoryp, iPtr->appendResult);
	    iPtr->appendResult = NULL;
	    iPtr->appendAvl = 0;
	}
	iPtr->appendUsed = strlen(iPtr->result);
    }
    totalSpace = newSpace + iPtr->appendUsed;
    if (totalSpace >= iPtr->appendAvl) {
	char *newPtr;

	if (totalSpace < 100) {
	    totalSpace = 200;
	} else {
	    totalSpace *= 2;
	}
	newPtr = (char *) ckalloc(memoryp, (unsigned) totalSpace);
	strcpy(newPtr, iPtr->result);
	if (iPtr->appendResult != NULL) {
	    ckfree(memoryp, iPtr->appendResult);
	}
	iPtr->appendResult = newPtr;
	iPtr->appendAvl = totalSpace;
    } else if (iPtr->result != iPtr->appendResult) {
	strcpy(iPtr->appendResult, iPtr->result);
    }
    Hax_FreeResult((Hax_Interp *) iPtr);
    iPtr->result = iPtr->appendResult;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %esi, %ebp
movq %rdi, %rbx
movq 0x280(%rdi), %r14
movq (%rdi), %r12
movq 0x118(%rdi), %r15
cmpq %r15, %r12
je 0x1077b
movl 0x120(%rbx), %r13d
cmpl $0x1f5, %r13d           # imm = 0x1F5
jl 0x1076b
leaq 0x49cb(%rip), %rdx      # 0x1510e
movq %r14, %rdi
movq %r15, %rsi
movl $0x493, %ecx            # imm = 0x493
callq 0x4280
andq $0x0, 0x118(%rbx)
andl $0x0, 0x120(%rbx)
movq (%rbx), %r12
xorl %r15d, %r15d
xorl %r13d, %r13d
movq %r12, %rdi
callq 0x41d0
movl %eax, 0x124(%rbx)
jmp 0x10788
movl 0x120(%rbx), %r13d
movl 0x124(%rbx), %eax
addl %ebp, %eax
cmpl %r13d, %eax
jge 0x107a1
cmpq %r15, %r12
je 0x10804
movq %r15, %rdi
movq %r12, %rsi
callq 0x40f0
jmp 0x10804
leal (%rax,%rax), %ecx
cmpl $0x64, %eax
movl $0xc8, %r15d
cmovgel %ecx, %r15d
leaq 0x4956(%rip), %rdx      # 0x1510e
movq %r14, %rdi
movq %r15, %rsi
movl $0x4a2, %ecx            # imm = 0x4A2
callq 0x44e0
movq %rax, %r12
movq (%rbx), %rsi
movq %rax, %rdi
callq 0x40f0
movq 0x118(%rbx), %rsi
testq %rsi, %rsi
je 0x107f6
leaq 0x4925(%rip), %rdx      # 0x1510e
movq %r14, %rdi
movl $0x4a5, %ecx            # imm = 0x4A5
callq 0x4280
movq %r12, 0x118(%rbx)
movl %r15d, 0x120(%rbx)
movq 0x8(%rbx), %rax
testq %rax, %rax
je 0x10841
cmpq 0xa78c(%rip), %rax      # 0x1afa0
je 0x1081d
movq (%rbx), %rdi
callq *%rax
jmp 0x1083c
movq %rbx, %rdi
callq 0x4560
movq (%rbx), %rsi
leaq 0x48df(%rip), %rdx      # 0x1510e
movq %rax, %rdi
movl $0x4ac, %ecx            # imm = 0x4AC
callq 0x4280
andq $0x0, 0x8(%rbx)
movq 0x118(%rbx), %rax
movq %rax, (%rbx)
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq