// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x150, %rsp            # imm = 0x150
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl %edx, -0x1c(%rbp)
movq %rcx, -0x28(%rbp)
cmpl $0x2, -0x1c(%rbp)
je 0x6d07
cmpl $0x3, -0x1c(%rbp)
je 0x6d07
movq -0x18(%rbp), %rdi
movq -0x28(%rbp), %rax
movq (%rax), %rdx
leaq 0x445b(%rip), %rsi      # 0xb143
leaq 0x4767(%rip), %rcx      # 0xb456
xorl %eax, %eax
movl %eax, %r8d
movb $0x0, %al
callq 0x3510
movl $0x1, -0x4(%rbp)
jmp 0x6fc2
movq -0x10(%rbp), %rax
movq %rax, -0x118(%rbp)
movq -0x18(%rbp), %rdi
movq -0x118(%rbp), %rsi
movq -0x28(%rbp), %rax
movq 0x8(%rax), %rdx
leaq -0x120(%rbp), %rcx
callq 0x3060
cmpl $0x0, %eax
je 0x6d42
movl $0x1, -0x4(%rbp)
jmp 0x6fc2
movq -0x120(%rbp), %rax
cmpl $0x0, 0x10(%rax)
jne 0x6d81
movq -0x18(%rbp), %rdi
movq -0x28(%rbp), %rax
movq 0x8(%rax), %rdx
leaq 0x43be(%rip), %rsi      # 0xb120
leaq 0x4700(%rip), %rcx      # 0xb469
xorl %eax, %eax
movl %eax, %r8d
movb $0x0, %al
callq 0x3510
movl $0x1, -0x4(%rbp)
jmp 0x6fc2
movl $0x0, -0x104(%rbp)
movl $0x0, -0x108(%rbp)
movl $0x0, -0x10c(%rbp)
movq -0x120(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x128(%rbp)
cmpl $0x0, -0x108(%rbp)
setne %al
xorb $-0x1, %al
testb $0x1, %al
jne 0x6dc5
jmp 0x6f9a
leaq -0x100(%rbp), %rax
movq %rax, -0x138(%rbp)
movl $0x0, -0x130(%rbp)
cmpl $0xc7, -0x130(%rbp)
jge 0x6f1e
movq -0x128(%rbp), %rdi
callq 0x3600
movl %eax, -0x12c(%rbp)
cmpl $-0x1, -0x12c(%rbp)
jne 0x6ed2
movq -0x120(%rbp), %rax
movq (%rax), %rdi
callq 0x3110
cmpl $0x0, %eax
je 0x6e92
movq -0x18(%rbp), %rdi
callq 0x3270
movq -0x18(%rbp), %rax
movq %rax, -0x148(%rbp)
movq -0x28(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x140(%rbp)
movq -0x18(%rbp), %rdi
callq 0x31b0
movq -0x148(%rbp), %rdi
movq -0x140(%rbp), %rdx
movq %rax, %r8
leaq 0x4621(%rip), %rsi      # 0xb485
leaq 0x4380(%rip), %rcx      # 0xb1eb
xorl %eax, %eax
movl %eax, %r9d
movb $0x0, %al
callq 0x3510
movq -0x120(%rbp), %rax
movq (%rax), %rdi
callq 0x33a0
movl $0x1, -0x4(%rbp)
jmp 0x6fc2
movq -0x120(%rbp), %rax
movq (%rax), %rdi
callq 0x3370
cmpl $0x0, %eax
je 0x6ece
cmpl $0x0, -0x104(%rbp)
jne 0x6ec2
cmpl $0x0, -0x130(%rbp)
jne 0x6ec2
movl $0xffffffff, -0x104(%rbp) # imm = 0xFFFFFFFF
movl $0x1, -0x108(%rbp)
jmp 0x6f1e
jmp 0x6ed0
jmp 0x6ed2
cmpl $0xa, -0x12c(%rbp)
jne 0x6ee7
movl $0x1, -0x108(%rbp)
jmp 0x6f1e
movl -0x12c(%rbp), %eax
movb %al, %cl
movq -0x138(%rbp), %rax
movb %cl, (%rax)
movl -0x130(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x130(%rbp)
movq -0x138(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x138(%rbp)
jmp 0x6ddd
movq -0x138(%rbp), %rax
movb $0x0, (%rax)
cmpl $0x2, -0x1c(%rbp)
jne 0x6f46
movq -0x18(%rbp), %rdi
leaq -0x100(%rbp), %rsi
xorl %eax, %eax
movl %eax, %edx
movb $0x0, %al
callq 0x3510
jmp 0x6f83
movq -0x18(%rbp), %rdi
movq -0x28(%rbp), %rax
movq 0x10(%rax), %rsi
leaq -0x100(%rbp), %rdx
movl -0x10c(%rbp), %ecx
orl $0x200, %ecx            # imm = 0x200
callq 0x3430
cmpq $0x0, %rax
jne 0x6f79
movl $0x1, -0x4(%rbp)
jmp 0x6fc2
movl $0x2, -0x10c(%rbp)
movl -0x130(%rbp), %eax
addl -0x104(%rbp), %eax
movl %eax, -0x104(%rbp)
jmp 0x6db0
cmpl $0x3, -0x1c(%rbp)
jne 0x6fbb
movq -0x18(%rbp), %rax
movq (%rax), %rdi
movl -0x104(%rbp), %edx
leaq 0x45c2(%rip), %rsi      # 0xb576
movb $0x0, %al
callq 0x35a0
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x150, %rsp            # imm = 0x150
popq %rbp
retq
nop