// File: /workspace/github_c_makefile_star2_O1/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 0x3540
cmpl $0x2, %ebp
jne 0x4a07
movq %rax, %rbx
movq 0x8(%r12), %rdx
leaq 0x10(%rsp), %rcx
movq %r14, %rdi
movq %r15, %rsi
callq 0x3060
movl $0x1, %ebp
testl %eax, %eax
jne 0x4a2b
movq 0x8(%r15), %r13
movq 0x10(%rsp), %rax
movq (%rax), %rdi
callq 0x33e0
cltq
movq $0x0, (%r13,%rax,8)
movq 0x10(%rsp), %rax
movq 0x8(%rax), %rdi
xorl %ebp, %ebp
testq %rdi, %rdi
je 0x4972
callq 0x3160
cmpl $-0x1, %eax
jne 0x4972
movq 0x8(%r12), %r13
movq %r14, %rdi
callq 0x31b0
movq $0x0, (%rsp)
leaq 0x4958(%rip), %rsi      # 0x92a7
leaq 0x4895(%rip), %rcx      # 0x91eb
leaq 0x4f13(%rip), %r9       # 0x9870
movq %r14, %rdi
movq %r13, %rdx
movq %rax, %r8
xorl %eax, %eax
callq 0x3510
movl $0x1, %ebp
movq 0x10(%rsp), %rax
movq (%rax), %rdi
callq 0x3160
cmpl $-0x1, %eax
jne 0x49c3
movq 0x8(%r12), %r12
movq %r14, %rdi
callq 0x31b0
movq $0x0, (%rsp)
leaq 0x4907(%rip), %rsi      # 0x92a7
leaq 0x4844(%rip), %rcx      # 0x91eb
leaq 0x4ec2(%rip), %r9       # 0x9870
movq %r14, %rdi
movq %r12, %rdx
movq %rax, %r8
xorl %eax, %eax
callq 0x3510
movl $0x1, %ebp
movq 0x10(%rsp), %rax
movl 0x18(%rax), %edx
testl %edx, %edx
jle 0x49ec
movq 0x20(%rax), %rcx
movl 0x28(%rax), %r8d
movq %r14, %rdi
movq %r15, %rsi
callq 0x4a3c
testl %eax, %eax
movl $0x1, %eax
cmovnel %eax, %ebp
movq 0x10(%rsp), %rsi
leaq 0x487c(%rip), %rdx      # 0x9274
movq %rbx, %rdi
movl $0xcf, %ecx
callq 0x31f0
jmp 0x4a2b
movq (%r12), %rdx
leaq 0x4731(%rip), %rsi      # 0x9143
leaq 0x4ca2(%rip), %rcx      # 0x96bb
movq %r14, %rdi
xorl %r8d, %r8d
xorl %eax, %eax
callq 0x3510
movl $0x1, %ebp
movl %ebp, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq