// File: /workspace/github_c_makefile_star2_O3/haxlang[P]hax/haxUnixAZ.c
// Function: Hax_GetsCmd
int
Hax_GetsCmd(
    ClientData clientData,		/* Unix ClientData */
    Hax_Interp *interp,			/* Current interpreter. */
    int argc,				/* Number of arguments. */
    char **argv				/* Argument strings. */)
{
#   define BUF_SIZE 200
    char buffer[BUF_SIZE+1];
    int totalCount, done, flags;
    UnixClientData *clientDataPtr;
    OpenFile *filePtr;
    FILE *f;

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

    clientDataPtr = (UnixClientData *) clientData;
    if (HaxGetOpenFile(interp, clientDataPtr, argv[1], &filePtr) != HAX_OK) {
	return HAX_ERROR;
    }
    if (!filePtr->readable) {
	Hax_AppendResult(interp, "\"", argv[1],
		"\" wasn't opened for reading", (char *) NULL);
	return HAX_ERROR;
    }

    /*
     * We can't predict how large a line will be, so read it in
     * pieces, appending to the current result or to a variable.
     */

    totalCount = 0;
    done = 0;
    flags = 0;
    f = filePtr->f;
    while (!done) {
	int c, count;
	char *p;

	for (p = buffer, count = 0; count < BUF_SIZE-1; count++, p++) {
	    c = getc(f);
	    if (c == EOF) {
		if (ferror(filePtr->f)) {
		    Hax_ResetResult(interp);
		    Hax_AppendResult(interp, "error reading \"", argv[1],
			    "\": ", Hax_UnixError(interp), (char *) NULL);
		    clearerr(filePtr->f);
		    return HAX_ERROR;
		} else if (feof(filePtr->f)) {
		    if ((totalCount == 0) && (count == 0)) {
			totalCount = -1;
		    }
		    done = 1;
		    break;
		}
	    }
	    if (c == '\n') {
		done = 1;
		break;
	    }
	    *p = c;
	}
	*p = 0;
	if (argc == 2) {
	    Hax_AppendResult(interp, buffer, (char *) NULL);
	} else {
	    if (Hax_SetVar(interp, argv[2], buffer, flags|HAX_LEAVE_ERR_MSG)
		    == NULL) {
		return HAX_ERROR;
	    }
	    flags = HAX_APPEND_VALUE;
	}
	totalCount += count;
    }

    if (argc == 3) {
	sprintf(interp->result, "%d", totalCount);
    }
    return HAX_OK;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xf8, %rsp
movq %rcx, %rbp
movl %edx, %r15d
movq %rsi, %rbx
leal -0x4(%r15), %eax
cmpl $-0x3, %eax
ja 0x5c23
movq (%rbp), %rdx
leaq 0x2539(%rip), %rsi      # 0x8143
leaq 0x28d2(%rip), %rcx      # 0x84e3
movq %rbx, %rdi
xorl %r8d, %r8d
xorl %eax, %eax
callq 0x3510
jmp 0x5daf
movq %rdi, %rsi
movq 0x8(%rbp), %rdx
leaq 0x8(%rsp), %rcx
movq %rbx, %rdi
callq 0x3060
testl %eax, %eax
jne 0x5daf
movq 0x8(%rsp), %rax
cmpl $0x0, 0x10(%rax)
je 0x5dc8
movq %rbx, (%rsp)
movq (%rax), %r13
movl $0x200, %eax            # imm = 0x200
xorl %r12d, %r12d
movq %rbp, 0x18(%rsp)
movl %eax, 0x14(%rsp)
xorl %ebx, %ebx
movq %r13, %rdi
callq 0x3600
movl %eax, %ebp
cmpl $-0x1, %eax
je 0x5c7e
cmpl $0xa, %ebp
jne 0x5ca2
jmp 0x5cd2
movq 0x8(%rsp), %rax
movq (%rax), %r14
movq %r14, %rdi
callq 0x3110
testl %eax, %eax
jne 0x5d64
movq %r14, %rdi
callq 0x3370
testl %eax, %eax
jne 0x5cc4
movb %bpl, 0x20(%rsp,%rbx)
incq %rbx
cmpl $0xc7, %ebx
jne 0x5c68
leaq (%rsp,%rbx), %rax
addq $0x20, %rax
movb $0x1, %r14b
movl $0xc7, %ebx
jmp 0x5cdd
movl %ebx, %eax
orl %r12d, %eax
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
cmovel %eax, %r12d
leaq (%rsp,%rbx), %rax
addq $0x20, %rax
xorl %r14d, %r14d
movb $0x0, (%rax)
cmpl $0x2, %r15d
jne 0x5d0b
xorl %ebp, %ebp
movq (%rsp), %rdi
leaq 0x20(%rsp), %rsi
xorl %edx, %edx
xorl %eax, %eax
callq 0x3510
addl %ebx, %r12d
testb %r14b, %r14b
jne 0x5c66
jmp 0x5db4
movq 0x18(%rsp), %rbp
movq 0x10(%rbp), %rsi
movq (%rsp), %rdi
leaq 0x20(%rsp), %rdx
movl 0x14(%rsp), %ecx
callq 0x3430
testq %rax, %rax
je 0x5daf
addl %ebx, %r12d
movl $0x202, %eax            # imm = 0x202
testb %r14b, %r14b
jne 0x5c62
xorl %ebp, %ebp
cmpl $0x3, %r15d
jne 0x5db4
movq (%rsp), %rax
movq (%rax), %rdi
leaq 0x28ad(%rip), %rsi      # 0x8603
xorl %ebp, %ebp
movl %r12d, %edx
xorl %eax, %eax
callq 0x35a0
jmp 0x5db4
movq (%rsp), %rbx
movq %rbx, %rdi
callq 0x3270
movq 0x18(%rsp), %rax
movq 0x8(%rax), %r14
movq %rbx, %rdi
callq 0x31b0
leaq 0x278a(%rip), %rsi      # 0x8512
leaq 0x245c(%rip), %rcx      # 0x81eb
movq %rbx, %rdi
movq %r14, %rdx
movq %rax, %r8
xorl %r9d, %r9d
xorl %eax, %eax
callq 0x3510
movq 0x8(%rsp), %rax
movq (%rax), %rdi
callq 0x33a0
movl $0x1, %ebp
movl %ebp, %eax
addq $0xf8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x8(%rbp), %rdx
leaq 0x234d(%rip), %rsi      # 0x8120
leaq 0x271c(%rip), %rcx      # 0x84f6
jmp 0x5c11