// File: /workspace/github_c_makefile_star2_O1/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 $0x108, %rsp            # imm = 0x108
movq %rcx, %r15
movq %rsi, %rbp
movq %rdx, 0x28(%rsp)
leal -0x4(%rdx), %eax
cmpl $-0x3, %eax
ja 0x5ce6
movq (%r15), %rdx
leaq 0x3478(%rip), %rsi      # 0x9143
leaq 0x37ed(%rip), %rcx      # 0x94bf
movq %rbp, %rdi
xorl %r8d, %r8d
xorl %eax, %eax
callq 0x3510
movl $0x1, %ebx
jmp 0x5d03
movq %rdi, %rsi
movq 0x8(%r15), %rdx
leaq 0x18(%rsp), %rcx
movq %rbp, %rdi
callq 0x3060
movl $0x1, %ebx
testl %eax, %eax
je 0x5d17
movl %ebx, %eax
addq $0x108, %rsp            # imm = 0x108
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x18(%rsp), %rax
cmpl $0x0, 0x10(%rax)
je 0x5eae
movq %r15, 0x20(%rsp)
movq (%rax), %r13
xorl %r14d, %r14d
xorl %ebx, %ebx
movl $0x0, 0x8(%rsp)
movq %rbp, 0x10(%rsp)
testl %ebx, %ebx
jne 0x5ed2
movl %ebx, 0xc(%rsp)
xorl %r12d, %r12d
leaq 0x30(%rsp), %rbp
movq %r13, %rdi
callq 0x3600
movl %eax, %ebx
cmpl $-0x1, %eax
je 0x5d6d
cmpl $0xa, %ebx
jne 0x5d9a
jmp 0x5e2f
movq 0x18(%rsp), %rax
movq (%rax), %r15
movq %r15, %rdi
callq 0x3110
testl %eax, %eax
jne 0x5dc2
movq %r15, %rdi
callq 0x3370
testl %eax, %eax
jne 0x5e1a
cmpl $0xa, %ebx
je 0x5e37
movb %bl, 0x30(%rsp,%r12)
incq %r12
incq %rbp
cmpl $0xc7, %r12d
jne 0x5d54
leaq (%rsp,%r12), %rbp
addq $0x30, %rbp
movl $0xc7, %r12d
movl 0xc(%rsp), %ebx
jmp 0x5e3c
movq 0x10(%rsp), %rbp
movq %rbp, %rdi
callq 0x3270
movq 0x20(%rsp), %rax
movq 0x8(%rax), %rbx
movq %rbp, %rdi
callq 0x31b0
xorl %r15d, %r15d
movq %rbp, %rdi
leaq 0x3701(%rip), %rsi      # 0x94ee
movq %rbx, %rdx
leaq 0x33f4(%rip), %rcx      # 0x91eb
movq %rax, %r8
xorl %r9d, %r9d
xorl %eax, %eax
callq 0x3510
movq 0x18(%rsp), %rax
movq (%rax), %rdi
callq 0x33a0
movl 0xc(%rsp), %ebx
jmp 0x5e9b
movl %r12d, %eax
movl 0x8(%rsp), %ecx
orl %ecx, %eax
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
cmovel %eax, %ecx
movl %ecx, 0x8(%rsp)
leaq (%rsp,%r12), %rbp
addq $0x30, %rbp
movl $0x1, %ebx
movb $0x0, (%rbp)
cmpl $0x2, 0x28(%rsp)
jne 0x5e62
movq 0x10(%rsp), %rbp
movq %rbp, %rdi
leaq 0x30(%rsp), %rsi
xorl %edx, %edx
xorl %eax, %eax
callq 0x3510
movl %r14d, %ecx
jmp 0x5e90
movq 0x20(%rsp), %rax
movq 0x10(%rax), %rsi
movl %r14d, %ecx
orl $0x200, %ecx            # imm = 0x200
movq 0x10(%rsp), %rbp
movq %rbp, %rdi
leaq 0x30(%rsp), %rdx
callq 0x3430
movl $0x2, %ecx
testq %rax, %rax
je 0x5ea9
addl %r12d, 0x8(%rsp)
movb $0x1, %r15b
movl %ecx, %r14d
testb %r15b, %r15b
jne 0x5d40
jmp 0x5cdf
xorl %r15d, %r15d
jmp 0x5e9b
movq 0x8(%r15), %rdx
leaq 0x3267(%rip), %rsi      # 0x9120
leaq 0x3612(%rip), %rcx      # 0x94d2
movq %rbp, %rdi
xorl %r8d, %r8d
xorl %eax, %eax
callq 0x3510
jmp 0x5d03
xorl %ebx, %ebx
cmpl $0x3, 0x28(%rsp)
jne 0x5d03
movq (%rbp), %rdi
leaq 0x36f5(%rip), %rsi      # 0x95df
xorl %ebx, %ebx
movl 0x8(%rsp), %edx
xorl %eax, %eax
callq 0x35a0
jmp 0x5d03