// File: /workspace/github_c_makefile_star2_O0/haxlang[P]hax/haxUnixAZ.c
// Function: Hax_ReadCmd
int
Hax_ReadCmd(
    ClientData clientData,		/* Unix ClientData */
    Hax_Interp *interp,			/* Current interpreter. */
    int argc,				/* Number of arguments. */
    char **argv				/* Argument strings. */)
{
    UnixClientData *clientDataPtr;
    OpenFile *filePtr;
    long int bytesLeft, bytesRead, count;
#define READ_BUF_SIZE 4096
    char buffer[READ_BUF_SIZE+1];
    int newline, i;

    if ((argc != 2) && (argc != 3)) {
	Hax_AppendResult(interp, "wrong # args: should be \"", argv[0],
		" fileId ?numBytes?\" or \"", argv[0],
		" ?-nonewline? fileId\"", (char *) NULL);
	return HAX_ERROR;
    }
    i = 1;
    newline = 1;
    if ((argc == 3) && (strcmp(argv[1], "-nonewline") == 0)) {
	newline = 0;
	i++;
    }

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

    /*
     * Compute how many bytes to read, and see whether the final
     * newline should be dropped.
     */

    if ((argc >= (i + 2)) && isdigit(argv[i+1][0])) {
	if (Hax_GetLong(interp, argv[i+1], &bytesLeft) != HAX_OK) {
	    return HAX_ERROR;
	}
    } else {
	bytesLeft = 1LL<<62;

	/*
	 * The code below provides backward compatibility for an
	 * archaic earlier version of this command.
	 */

	if (argc >= (i + 2)) {
	    if (strncmp(argv[i+1], "nonewline", strlen(argv[i+1])) == 0) {
		newline = 0;
	    } else {
		Hax_AppendResult(interp, "bad argument \"", argv[i+1],
			"\": should be \"nonewline\"", (char *) NULL);
		return HAX_ERROR;
	    }
	}
    }

    /*
     * Read the file in one or more chunks.
     */

    bytesRead = 0;
    while (bytesLeft > 0) {
	count = READ_BUF_SIZE;
	if (bytesLeft < READ_BUF_SIZE) {
	    count = bytesLeft;
	}
	count = fread(buffer, 1, count, filePtr->f);
	if (ferror(filePtr->f)) {
	    Hax_ResetResult(interp);
	    Hax_AppendResult(interp, "error reading \"", argv[i],
		    "\": ", Hax_UnixError(interp), (char *) NULL);
	    clearerr(filePtr->f);
	    return HAX_ERROR;
	}
	if (count == 0) {
	    break;
	}
	buffer[count] = 0;
	Hax_AppendResult(interp, buffer, (char *) NULL);
	bytesLeft -= count;
	bytesRead += count;
    }
    if ((newline == 0) && (bytesRead > 0)
	    && (interp->result[bytesRead-1] == '\n')) {
	interp->result[bytesRead-1] = 0;
    }
    return HAX_OK;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x1090, %rsp           # imm = 0x1090
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl %edx, -0x1c(%rbp)
movq %rcx, -0x28(%rbp)
cmpl $0x2, -0x1c(%rbp)
je 0x799a
cmpl $0x3, -0x1c(%rbp)
je 0x799a
movq -0x18(%rbp), %rdi
movq -0x28(%rbp), %rax
movq (%rax), %rdx
movq -0x28(%rbp), %rax
movq (%rax), %r8
leaq 0x37d4(%rip), %rsi      # 0xb143
leaq 0x3cb6(%rip), %rcx      # 0xb62c
leaq 0x3cc8(%rip), %r9       # 0xb645
xorl %eax, %eax
movq $0x0, (%rsp)
movb $0x0, %al
callq 0x3510
movl $0x1, -0x4(%rbp)
jmp 0x7cf9
movl $0x1, -0x1068(%rbp)
movl $0x1, -0x1064(%rbp)
cmpl $0x3, -0x1c(%rbp)
jne 0x79e6
movq -0x28(%rbp), %rax
movq 0x8(%rax), %rdi
leaq 0x3c00(%rip), %rsi      # 0xb5c3
callq 0x3320
cmpl $0x0, %eax
jne 0x79e6
movl $0x0, -0x1064(%rbp)
movl -0x1068(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1068(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x30(%rbp)
movq -0x18(%rbp), %rdi
movq -0x30(%rbp), %rsi
movq -0x28(%rbp), %rax
movslq -0x1068(%rbp), %rcx
movq (%rax,%rcx,8), %rdx
leaq -0x38(%rbp), %rcx
callq 0x3060
cmpl $0x0, %eax
je 0x7a1f
movl $0x1, -0x4(%rbp)
jmp 0x7cf9
movq -0x38(%rbp), %rax
cmpl $0x0, 0x10(%rax)
jne 0x7a62
movq -0x18(%rbp), %rdi
movq -0x28(%rbp), %rax
movslq -0x1068(%rbp), %rcx
movq (%rax,%rcx,8), %rdx
leaq 0x36dd(%rip), %rsi      # 0xb120
leaq 0x3a1f(%rip), %rcx      # 0xb469
xorl %eax, %eax
movl %eax, %r8d
movb $0x0, %al
callq 0x3510
movl $0x1, -0x4(%rbp)
jmp 0x7cf9
movl -0x1c(%rbp), %eax
movl -0x1068(%rbp), %ecx
addl $0x2, %ecx
cmpl %ecx, %eax
jl 0x7ad9
callq 0x3630
movq (%rax), %rax
movq -0x28(%rbp), %rcx
movl -0x1068(%rbp), %edx
addl $0x1, %edx
movslq %edx, %rdx
movq (%rcx,%rdx,8), %rcx
movsbl (%rcx), %ecx
movslq %ecx, %rcx
movzwl (%rax,%rcx,2), %eax
andl $0x800, %eax            # imm = 0x800
cmpl $0x0, %eax
je 0x7ad9
movq -0x18(%rbp), %rdi
movq -0x28(%rbp), %rax
movl -0x1068(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rsi
leaq -0x40(%rbp), %rdx
callq 0x3480
cmpl $0x0, %eax
je 0x7ad4
movl $0x1, -0x4(%rbp)
jmp 0x7cf9
jmp 0x7b98
movabsq $0x4000000000000000, %rax # imm = 0x4000000000000000
movq %rax, -0x40(%rbp)
movl -0x1c(%rbp), %eax
movl -0x1068(%rbp), %ecx
addl $0x2, %ecx
cmpl %ecx, %eax
jl 0x7b96
movq -0x28(%rbp), %rax
movl -0x1068(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x1070(%rbp)
movq -0x28(%rbp), %rax
movl -0x1068(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rdi
callq 0x3190
movq -0x1070(%rbp), %rdi
movq %rax, %rdx
leaq 0x3a84(%rip), %rsi      # 0xb5c4
callq 0x30b0
cmpl $0x0, %eax
jne 0x7b56
movl $0x0, -0x1064(%rbp)
jmp 0x7b94
movq -0x18(%rbp), %rdi
movq -0x28(%rbp), %rax
movl -0x1068(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rdx
leaq 0x3a78(%rip), %rsi      # 0xb5ed
leaq 0x3a80(%rip), %rcx      # 0xb5fc
xorl %eax, %eax
movl %eax, %r8d
movb $0x0, %al
callq 0x3510
movl $0x1, -0x4(%rbp)
jmp 0x7cf9
jmp 0x7b96
jmp 0x7b98
movq $0x0, -0x48(%rbp)
cmpq $0x0, -0x40(%rbp)
jle 0x7cb7
movq $0x1000, -0x50(%rbp)    # imm = 0x1000
cmpq $0x1000, -0x40(%rbp)    # imm = 0x1000
jge 0x7bc5
movq -0x40(%rbp), %rax
movq %rax, -0x50(%rbp)
leaq -0x1060(%rbp), %rdi
movq -0x50(%rbp), %rdx
movq -0x38(%rbp), %rax
movq (%rax), %rcx
movl $0x1, %esi
callq 0x3120
movq %rax, -0x50(%rbp)
movq -0x38(%rbp), %rax
movq (%rax), %rdi
callq 0x3110
cmpl $0x0, %eax
je 0x7c6c
movq -0x18(%rbp), %rdi
callq 0x3270
movq -0x18(%rbp), %rax
movq %rax, -0x1080(%rbp)
movq -0x28(%rbp), %rax
movslq -0x1068(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x1078(%rbp)
movq -0x18(%rbp), %rdi
callq 0x31b0
movq -0x1080(%rbp), %rdi
movq -0x1078(%rbp), %rdx
movq %rax, %r8
leaq 0x3844(%rip), %rsi      # 0xb485
leaq 0x35a3(%rip), %rcx      # 0xb1eb
xorl %eax, %eax
movl %eax, %r9d
movb $0x0, %al
callq 0x3510
movq -0x38(%rbp), %rax
movq (%rax), %rdi
callq 0x33a0
movl $0x1, -0x4(%rbp)
jmp 0x7cf9
cmpq $0x0, -0x50(%rbp)
jne 0x7c75
jmp 0x7cb7
movq -0x50(%rbp), %rax
movb $0x0, -0x1060(%rbp,%rax)
movq -0x18(%rbp), %rdi
leaq -0x1060(%rbp), %rsi
xorl %eax, %eax
movl %eax, %edx
movb $0x0, %al
callq 0x3510
movq -0x50(%rbp), %rcx
movq -0x40(%rbp), %rax
subq %rcx, %rax
movq %rax, -0x40(%rbp)
movq -0x50(%rbp), %rax
addq -0x48(%rbp), %rax
movq %rax, -0x48(%rbp)
jmp 0x7ba0
cmpl $0x0, -0x1064(%rbp)
jne 0x7cf2
cmpq $0x0, -0x48(%rbp)
jle 0x7cf2
movq -0x18(%rbp), %rax
movq (%rax), %rax
movq -0x48(%rbp), %rcx
subq $0x1, %rcx
movsbl (%rax,%rcx), %eax
cmpl $0xa, %eax
jne 0x7cf2
movq -0x18(%rbp), %rax
movq (%rax), %rax
movq -0x48(%rbp), %rcx
subq $0x1, %rcx
movb $0x0, (%rax,%rcx)
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x1090, %rsp           # imm = 0x1090
popq %rbp
retq
nopw %cs:(%rax,%rax)