// File: /workspace/github_c_makefile_star2_O0/haxlang[P]hax/haxUnixUtil.c
// Function: HaxMakeFileTable
void
HaxMakeFileTable(
    Hax_Interp *interp,
    UnixClientData *clientDataPtr,
				/* Unix ClientData whose table of
				 * files is to be manipulated. */
    int index			/* Make sure table is large enough to
				 * hold at least this index. */)
{
    Hax_Memoryp *memoryp;

    memoryp = Hax_GetMemoryp(interp);

    /*
     * If the table doesn't even exist, then create it and initialize
     * entries for standard files.
     */

    if (clientDataPtr->numFiles == 0) {
	OpenFile *filePtr;
	int i;

	if (index < 2) {
	    clientDataPtr->numFiles = 3;
	} else {
	    clientDataPtr->numFiles = index+1;
	}
	clientDataPtr->filePtrArray = (OpenFile **) ckalloc(memoryp, (unsigned)
		((clientDataPtr->numFiles)*sizeof(OpenFile *)));
	for (i = clientDataPtr->numFiles-1; i >= 0; i--) {
	    clientDataPtr->filePtrArray[i] = NULL;
	}

	filePtr = (OpenFile *) ckalloc(memoryp, sizeof(OpenFile));
	filePtr->f = stdin;
	filePtr->f2 = NULL;
	filePtr->readable = 1;
	filePtr->writable = 0;
	filePtr->numPids = 0;
	filePtr->pidPtr = NULL;
	filePtr->errorId = -1;
	clientDataPtr->filePtrArray[0] = filePtr;

	filePtr = (OpenFile *) ckalloc(memoryp, sizeof(OpenFile));
	filePtr->f = stdout;
	filePtr->f2 = NULL;
	filePtr->readable = 0;
	filePtr->writable = 1;
	filePtr->numPids = 0;
	filePtr->pidPtr = NULL;
	filePtr->errorId = -1;
	clientDataPtr->filePtrArray[1] = filePtr;

	filePtr = (OpenFile *) ckalloc(memoryp, sizeof(OpenFile));
	filePtr->f = stderr;
	filePtr->f2 = NULL;
	filePtr->readable = 0;
	filePtr->writable = 1;
	filePtr->numPids = 0;
	filePtr->pidPtr = NULL;
	filePtr->errorId = -1;
	clientDataPtr->filePtrArray[2] = filePtr;
    } else if (index >= clientDataPtr->numFiles) {
	int newSize;
	OpenFile **newPtrArray;
	int i;

	newSize = index+1;
	newPtrArray = (OpenFile **) ckalloc(memoryp, (unsigned)
		((newSize)*sizeof(OpenFile *)));
	memcpy(newPtrArray, clientDataPtr->filePtrArray,
		clientDataPtr->numFiles*sizeof(OpenFile *));
	for (i = clientDataPtr->numFiles; i < newSize; i++) {
	    newPtrArray[i] = NULL;
	}
	ckfree(memoryp, (char *) clientDataPtr->filePtrArray);
	clientDataPtr->numFiles = newSize;
	clientDataPtr->filePtrArray = newPtrArray;
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movq -0x8(%rbp), %rdi
callq 0x3540
movq %rax, -0x20(%rbp)
movq -0x10(%rbp), %rax
cmpl $0x0, (%rax)
jne 0xa828
cmpl $0x2, -0x14(%rbp)
jge 0xa62f
movq -0x10(%rbp), %rax
movl $0x3, (%rax)
jmp 0xa63b
movl -0x14(%rbp), %ecx
addl $0x1, %ecx
movq -0x10(%rbp), %rax
movl %ecx, (%rax)
movq -0x20(%rbp), %rdi
movq -0x10(%rbp), %rax
movslq (%rax), %rax
shlq $0x3, %rax
movl %eax, %eax
movl %eax, %esi
leaq 0x1bf9(%rip), %rdx      # 0xc24e
movl $0x371, %ecx            # imm = 0x371
callq 0x34c0
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x10(%rbp), %rax
movl (%rax), %eax
subl $0x1, %eax
movl %eax, -0x2c(%rbp)
cmpl $0x0, -0x2c(%rbp)
jl 0xa69b
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movslq -0x2c(%rbp), %rcx
movq $0x0, (%rax,%rcx,8)
movl -0x2c(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0xa676
movq -0x20(%rbp), %rdi
movl $0x30, %esi
leaq 0x1ba3(%rip), %rdx      # 0xc24e
movl $0x376, %ecx            # imm = 0x376
callq 0x34c0
movq %rax, -0x28(%rbp)
movq 0x3908(%rip), %rax      # 0xdfc8
movq (%rax), %rcx
movq -0x28(%rbp), %rax
movq %rcx, (%rax)
movq -0x28(%rbp), %rax
movq $0x0, 0x8(%rax)
movq -0x28(%rbp), %rax
movl $0x1, 0x10(%rax)
movq -0x28(%rbp), %rax
movl $0x0, 0x14(%rax)
movq -0x28(%rbp), %rax
movl $0x0, 0x18(%rax)
movq -0x28(%rbp), %rax
movq $0x0, 0x20(%rax)
movq -0x28(%rbp), %rax
movl $0xffffffff, 0x28(%rax) # imm = 0xFFFFFFFF
movq -0x28(%rbp), %rcx
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq %rcx, (%rax)
movq -0x20(%rbp), %rdi
movl $0x30, %esi
leaq 0x1b21(%rip), %rdx      # 0xc24e
movl $0x380, %ecx            # imm = 0x380
callq 0x34c0
movq %rax, -0x28(%rbp)
movq 0x387e(%rip), %rax      # 0xdfc0
movq (%rax), %rcx
movq -0x28(%rbp), %rax
movq %rcx, (%rax)
movq -0x28(%rbp), %rax
movq $0x0, 0x8(%rax)
movq -0x28(%rbp), %rax
movl $0x0, 0x10(%rax)
movq -0x28(%rbp), %rax
movl $0x1, 0x14(%rax)
movq -0x28(%rbp), %rax
movl $0x0, 0x18(%rax)
movq -0x28(%rbp), %rax
movq $0x0, 0x20(%rax)
movq -0x28(%rbp), %rax
movl $0xffffffff, 0x28(%rax) # imm = 0xFFFFFFFF
movq -0x28(%rbp), %rcx
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq %rcx, 0x8(%rax)
movq -0x20(%rbp), %rdi
movl $0x30, %esi
leaq 0x1a9e(%rip), %rdx      # 0xc24e
movl $0x38a, %ecx            # imm = 0x38A
callq 0x34c0
movq %rax, -0x28(%rbp)
movq 0x3833(%rip), %rax      # 0xdff8
movq (%rax), %rcx
movq -0x28(%rbp), %rax
movq %rcx, (%rax)
movq -0x28(%rbp), %rax
movq $0x0, 0x8(%rax)
movq -0x28(%rbp), %rax
movl $0x0, 0x10(%rax)
movq -0x28(%rbp), %rax
movl $0x1, 0x14(%rax)
movq -0x28(%rbp), %rax
movl $0x0, 0x18(%rax)
movq -0x28(%rbp), %rax
movq $0x0, 0x20(%rax)
movq -0x28(%rbp), %rax
movl $0xffffffff, 0x28(%rax) # imm = 0xFFFFFFFF
movq -0x28(%rbp), %rcx
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq %rcx, 0x10(%rax)
jmp 0xa8e1
movl -0x14(%rbp), %eax
movq -0x10(%rbp), %rcx
cmpl (%rcx), %eax
jl 0xa8df
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
movq -0x20(%rbp), %rdi
movslq -0x30(%rbp), %rax
shlq $0x3, %rax
movl %eax, %eax
movl %eax, %esi
leaq 0x19f7(%rip), %rdx      # 0xc24e
movl $0x39a, %ecx            # imm = 0x39A
callq 0x34c0
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rsi
movq -0x10(%rbp), %rax
movslq (%rax), %rdx
shlq $0x3, %rdx
callq 0x33c0
movq -0x10(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x3c(%rbp)
movl -0x3c(%rbp), %eax
cmpl -0x30(%rbp), %eax
jge 0xa8ad
movq -0x38(%rbp), %rax
movslq -0x3c(%rbp), %rcx
movq $0x0, (%rax,%rcx,8)
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0xa88a
movq -0x20(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rsi
leaq 0x198e(%rip), %rdx      # 0xc24e
movl $0x3a0, %ecx            # imm = 0x3A0
callq 0x31f0
movl -0x30(%rbp), %ecx
movq -0x10(%rbp), %rax
movl %ecx, (%rax)
movq -0x38(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x8(%rax)
jmp 0xa8e1
addq $0x40, %rsp
popq %rbp
retq
nopw (%rax,%rax)