// File: /workspace/github_c_makefile_star2_O3/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 0x49cb
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 0x49ef
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 0x4936
callq 0x3160
cmpl $-0x1, %eax
jne 0x4936
movq 0x8(%r12), %r13
movq %r14, %rdi
callq 0x31b0
movq $0x0, (%rsp)
leaq 0x39b8(%rip), %rsi      # 0x82cb
leaq 0x38d1(%rip), %rcx      # 0x81eb
leaq 0x3f73(%rip), %r9       # 0x8894
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 0x4987
movq 0x8(%r12), %r12
movq %r14, %rdi
callq 0x31b0
movq $0x0, (%rsp)
leaq 0x3967(%rip), %rsi      # 0x82cb
leaq 0x3880(%rip), %rcx      # 0x81eb
leaq 0x3f22(%rip), %r9       # 0x8894
movq %r14, %rdi
movq %r12, %rdx
movq %rax, %r8
xorl %eax, %eax
callq 0x3510
movl $0x1, %ebp
movq 0x10(%rsp), %rsi
movl 0x18(%rsi), %edx
testl %edx, %edx
jle 0x49b5
movq 0x20(%rsi), %rcx
movl 0x28(%rsi), %r8d
movq %r14, %rdi
movq %r15, %rsi
callq 0x4a00
testl %eax, %eax
movl $0x1, %eax
cmovnel %eax, %ebp
movq 0x10(%rsp), %rsi
leaq 0x38dc(%rip), %rdx      # 0x8298
movq %rbx, %rdi
movl $0xcf, %ecx
callq 0x31f0
jmp 0x49ef
movq (%r12), %rdx
leaq 0x376d(%rip), %rsi      # 0x8143
leaq 0x3d02(%rip), %rcx      # 0x86df
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