// File: /workspace/github_c_makefile_star2_O2/haxlang[P]hax/haxUnixAZ.c
// Function: Hax_CloseCmd
int
Hax_CloseCmd(
    ClientData clientData,		/* Unix ClientData */
    Hax_Interp *interp,			/* Current interpreter. */
    int argc,				/* Number of arguments. */
    char **argv				/* Argument strings. */)
{
    Hax_Memoryp *memoryp;
    UnixClientData *clientDataPtr;
    OpenFile *filePtr;
    int result = HAX_OK;

    memoryp = Hax_GetMemoryp(interp);

    if (argc != 2) {
	Hax_AppendResult(interp, "wrong # args: should be \"", argv[0],
		" fileId\"", (char *) NULL);
	return HAX_ERROR;
    }

    clientDataPtr = (UnixClientData *) clientData;
    if (HaxGetOpenFile(interp, clientDataPtr, argv[1], &filePtr) != HAX_OK) {
	return HAX_ERROR;
    }

    clientDataPtr->filePtrArray[fileno(filePtr->f)] = NULL;

    /*
     * First close the file (in the case of a process pipeline, there may
     * be two files, one for the pipe at each end of the pipeline).
     */

    if (filePtr->f2 != NULL) {
	if (fclose(filePtr->f2) == EOF) {
	    Hax_AppendResult(interp, "error closing \"", argv[1],
		    "\": ", Hax_UnixError(interp), "\n", (char *) NULL);
	    result = HAX_ERROR;
	}
    }
    if (fclose(filePtr->f) == EOF) {
	Hax_AppendResult(interp, "error closing \"", argv[1],
		"\": ", Hax_UnixError(interp), "\n", (char *) NULL);
	result = HAX_ERROR;
    }

    /*
     * If the file was a connection to a pipeline, clean up everything
     * associated with the child processes.
     */

    if (filePtr->numPids > 0) {
	if (CleanupChildren(interp, clientData, filePtr->numPids, filePtr->pidPtr,
		filePtr->errorId) != HAX_OK) {
	    result = HAX_ERROR;
	}
    }

    ckfree(memoryp, (char *) filePtr);
    return result;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rcx, %r12
movl %edx, %ebp
movq %rsi, %r14
movq %rdi, %r15
movq %rsi, %rdi
callq 0x3530
cmpl $0x2, %ebp
jne 0x492a
movq %rax, %rbx
movq 0x8(%r12), %rdx
leaq 0x10(%rsp), %rcx
movq %r14, %rdi
movq %r15, %rsi
callq 0x3060
testl %eax, %eax
jne 0x4949
movq 0x8(%r15), %r13
movq 0x10(%rsp), %rax
movq (%rax), %rdi
callq 0x33d0
cltq
andq $0x0, (%r13,%rax,8)
movq 0x10(%rsp), %rax
movq 0x8(%rax), %rdi
xorl %ebp, %ebp
testq %rdi, %rdi
je 0x489c
callq 0x3160
cmpl $-0x1, %eax
jne 0x489c
movq 0x8(%r12), %r13
movq %r14, %rdi
callq 0x31b0
andq $0x0, (%rsp)
leaq 0x3a50(%rip), %rsi      # 0x82cb
leaq 0x3969(%rip), %rcx      # 0x81eb
leaq 0x400b(%rip), %r9       # 0x8894
movq %r14, %rdi
movq %r13, %rdx
movq %rax, %r8
xorl %eax, %eax
callq 0x3500
pushq $0x1
popq %rbp
movq 0x10(%rsp), %rax
movq (%rax), %rdi
callq 0x3160
cmpl $-0x1, %eax
jne 0x48e8
movq 0x8(%r12), %r12
movq %r14, %rdi
callq 0x31b0
andq $0x0, (%rsp)
leaq 0x3a04(%rip), %rsi      # 0x82cb
leaq 0x391d(%rip), %rcx      # 0x81eb
leaq 0x3fbf(%rip), %r9       # 0x8894
movq %r14, %rdi
movq %r12, %rdx
movq %rax, %r8
xorl %eax, %eax
callq 0x3500
pushq $0x1
popq %rbp
movq 0x10(%rsp), %rsi
movl 0x18(%rsi), %edx
testl %edx, %edx
jle 0x4914
movq 0x20(%rsi), %rcx
movl 0x28(%rsi), %r8d
movq %r14, %rdi
movq %r15, %rsi
callq 0x495d
testl %eax, %eax
pushq $0x1
popq %rax
cmovnel %eax, %ebp
movq 0x10(%rsp), %rsi
leaq 0x397d(%rip), %rdx      # 0x8298
movq %rbx, %rdi
movl $0xcf, %ecx
callq 0x31f0
jmp 0x494c
movq (%r12), %rdx
leaq 0x380e(%rip), %rsi      # 0x8143
leaq 0x3da3(%rip), %rcx      # 0x86df
movq %r14, %rdi
xorl %r8d, %r8d
xorl %eax, %eax
callq 0x3500
pushq $0x1
popq %rbp
movl %ebp, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq