// File: /workspace/github_c_makefile_star2_O0/hoobaa[P]ficl/fileaccess.c
// Function: ficlPrimitiveReadLine
static void ficlPrimitiveReadLine(ficlVm *vm) /* ( c-addr u1 fileid -- u2 flag ior ) */
{
    ficlFile *ff = (ficlFile *)ficlStackPopPointer(vm->dataStack);
    int length = ficlStackPopInteger(vm->dataStack);
    char *address = (char *)ficlStackPopPointer(vm->dataStack);
    int error;
    int flag;

    if (feof(ff->f))
        {
        ficlStackPushInteger(vm->dataStack, -1);
        ficlStackPushInteger(vm->dataStack, 0);
        ficlStackPushInteger(vm->dataStack, 0);
        return;
        }

    clearerr(ff->f);
    *address = 0;
    fgets(address, length, ff->f);

    error = ferror(ff->f);
    if (error != 0)
        {
        ficlStackPushInteger(vm->dataStack, -1);
        ficlStackPushInteger(vm->dataStack, 0);
        ficlStackPushInteger(vm->dataStack, error);
        return;
        }

    length = strlen(address);
    flag = (length > 0);
    if (length && ((address[length - 1] == '\r') || (address[length - 1] == '\n')))
        length--;
    
    ficlStackPushInteger(vm->dataStack, length);
    ficlStackPushInteger(vm->dataStack, flag);
    ficlStackPushInteger(vm->dataStack, 0); /* ior */
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq 0x60(%rax), %rdi
callq 0x4b30
movq %rax, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq 0x60(%rax), %rdi
callq 0x4b70
movl %eax, -0x14(%rbp)
movq -0x8(%rbp), %rax
movq 0x60(%rax), %rdi
callq 0x4b30
movq %rax, -0x20(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rdi
callq 0x31b0
cmpl $0x0, %eax
je 0x1297a
movq -0x8(%rbp), %rax
movq 0x60(%rax), %rdi
movq $-0x1, %rsi
callq 0x4c90
movq -0x8(%rbp), %rax
movq 0x60(%rax), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x4c90
movq -0x8(%rbp), %rax
movq 0x60(%rax), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x4c90
jmp 0x12a79
movq -0x10(%rbp), %rax
movq (%rax), %rdi
callq 0x31d0
movq -0x20(%rbp), %rax
movb $0x0, (%rax)
movq -0x20(%rbp), %rdi
movl -0x14(%rbp), %esi
movq -0x10(%rbp), %rax
movq (%rax), %rdx
callq 0x3150
movq -0x10(%rbp), %rax
movq (%rax), %rdi
callq 0x3080
movl %eax, -0x24(%rbp)
cmpl $0x0, -0x24(%rbp)
je 0x129f0
movq -0x8(%rbp), %rax
movq 0x60(%rax), %rdi
movq $-0x1, %rsi
callq 0x4c90
movq -0x8(%rbp), %rax
movq 0x60(%rax), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x4c90
movq -0x8(%rbp), %rax
movq 0x60(%rax), %rdi
movslq -0x24(%rbp), %rsi
callq 0x4c90
jmp 0x12a79
movq -0x20(%rbp), %rdi
callq 0x30d0
movl %eax, -0x14(%rbp)
cmpl $0x0, -0x14(%rbp)
setg %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x28(%rbp)
cmpl $0x0, -0x14(%rbp)
je 0x12a46
movq -0x20(%rbp), %rax
movl -0x14(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movsbl (%rax,%rcx), %eax
cmpl $0xd, %eax
je 0x12a3d
movq -0x20(%rbp), %rax
movl -0x14(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movsbl (%rax,%rcx), %eax
cmpl $0xa, %eax
jne 0x12a46
movl -0x14(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x14(%rbp)
movq -0x8(%rbp), %rax
movq 0x60(%rax), %rdi
movslq -0x14(%rbp), %rsi
callq 0x4c90
movq -0x8(%rbp), %rax
movq 0x60(%rax), %rdi
movslq -0x28(%rbp), %rsi
callq 0x4c90
movq -0x8(%rbp), %rax
movq 0x60(%rax), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x4c90
addq $0x30, %rsp
popq %rbp
retq
nop