// File: /workspace/github_c_makefile_star2_O2/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, %r15
movl %edx, %r12d
movq %rsi, %r14
leal -0x4(%r12), %eax
cmpl $-0x3, %eax
ja 0x5b45
movq (%r15), %rdx
leaq 0x2617(%rip), %rsi      # 0x8143
leaq 0x29b0(%rip), %rcx      # 0x84e3
movq %r14, %rdi
xorl %r8d, %r8d
xorl %eax, %eax
callq 0x3500
pushq $0x1
popq %rbx
jmp 0x5b60
movq %rdi, %rsi
movq 0x8(%r15), %rdx
leaq 0x10(%rsp), %rcx
movq %r14, %rdi
callq 0x3060
pushq $0x1
popq %rbx
testl %eax, %eax
je 0x5b74
movl %ebx, %eax
addq $0xf8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x10(%rsp), %rax
cmpl $0x0, 0x10(%rax)
je 0x5cb6
movq %r15, 0x18(%rsp)
movq %r14, 0x8(%rsp)
movq (%rax), %r13
xorl %ebp, %ebp
xorl %ebx, %ebx
xorl %edx, %edx
testl %ebx, %ebx
jne 0x5cda
movl %edx, 0x4(%rsp)
xorl %r14d, %r14d
cmpl $0xc7, %r14d
je 0x5bf2
movq %r13, %rdi
callq 0x35f0
movl %eax, %ebx
cmpl $-0x1, %eax
je 0x5bc4
cmpl $0xa, %ebx
jne 0x5be8
jmp 0x5c09
movq 0x10(%rsp), %rax
movq (%rax), %r15
movq %r15, %rdi
callq 0x3110
testl %eax, %eax
jne 0x5c65
movq %r15, %rdi
callq 0x3360
testl %eax, %eax
jne 0x5bf6
movb %bl, 0x20(%rsp,%r14)
incq %r14
jmp 0x5ba5
xorl %ebx, %ebx
jmp 0x5c0c
movl %r14d, %eax
movl 0x4(%rsp), %ecx
orl %ecx, %eax
pushq $-0x1
popq %rax
cmovel %eax, %ecx
movl %ecx, 0x4(%rsp)
pushq $0x1
popq %rbx
movb $0x0, 0x20(%rsp,%r14)
cmpl $0x2, %r12d
jne 0x5c2d
movq 0x8(%rsp), %rdi
leaq 0x20(%rsp), %rsi
xorl %edx, %edx
xorl %eax, %eax
callq 0x3500
jmp 0x5c59
movq 0x18(%rsp), %rax
movq 0x10(%rax), %rsi
orl $0x200, %ebp            # imm = 0x200
movq 0x8(%rsp), %rdi
leaq 0x20(%rsp), %rdx
movl %ebp, %ecx
callq 0x3420
pushq $0x2
popq %rbp
testq %rax, %rax
je 0x5b40
movl 0x4(%rsp), %edx
addl %r14d, %edx
jmp 0x5b96
movq 0x8(%rsp), %r14
movq %r14, %rdi
callq 0x3260
movq 0x18(%rsp), %rax
movq 0x8(%rax), %rbx
movq %r14, %rdi
callq 0x31b0
leaq 0x2888(%rip), %rsi      # 0x8512
leaq 0x255a(%rip), %rcx      # 0x81eb
movq %r14, %rdi
movq %rbx, %rdx
movq %rax, %r8
xorl %r9d, %r9d
xorl %eax, %eax
callq 0x3500
movq 0x10(%rsp), %rax
movq (%rax), %rdi
callq 0x3390
jmp 0x5b40
movq 0x8(%r15), %rdx
leaq 0x245f(%rip), %rsi      # 0x8120
leaq 0x282e(%rip), %rcx      # 0x84f6
movq %r14, %rdi
xorl %r8d, %r8d
xorl %eax, %eax
callq 0x3500
jmp 0x5b60
xorl %ebx, %ebx
cmpl $0x3, %r12d
jne 0x5b60
movq 0x8(%rsp), %rax
movq (%rax), %rdi
leaq 0x290e(%rip), %rsi      # 0x8603
xorl %ebx, %ebx
xorl %eax, %eax
callq 0x3590
jmp 0x5b60