// File: /workspace/github_c_makefile_star2_O1/hughbarney[P]pEmacs/file.c
// Function: readin
int readin (char fname[])
{
  LINE *lp1, *lp2;
  WINDOW *wp;
  BUFFER *bp;
  char line[NLINE];
  int nbytes, nline, s, i;
  int lflag;			/* any lines longer than allowed? */

  bp = curbp;			/* Cheap */
  if ((s = bclear (bp)) != TRUE) /* Might be old */
    return (s);
  bp->b_flag &= ~(BFTEMP | BFCHG);
  strncpy (bp->b_fname, fname, NFILEN);
  if ((s = ffropen (fname)) == FIOERR) /* Hard file open */
    goto out;
  if (s == FIOFNF)
    {				/* File not found */
      mlwrite ("[New file]");
      goto out;
    }
  mlwrite ("[Reading file]");
  nline = 0;
  lflag = FALSE;
  while ((s = ffgetline (line, NLINE)) == FIOSUC || s == FIOLNG)
    {
      if (s == FIOLNG)
	lflag = TRUE;
      nbytes = strlen (line);
      if ((lp1 = lalloc (nbytes)) == NULL)
	{
	  s = FIOERR;		/* Keep message on the display */
	  break;
	}
      lp2 = lback (curbp->b_linep);
      lp2->l_fp = lp1;
      lp1->l_fp = curbp->b_linep;
      lp1->l_bp = lp2;
      curbp->b_linep->l_bp = lp1;
      for (i = 0; i < nbytes; ++i)
	lputc (lp1, i, line[i]);
      ++nline;
    }
  ffclose ();			/* Ignore errors */
  if (s == FIOEOF)
    {				/* Don't zap message! */
      if (nline == 1)
	mlwrite ("[Read 1 line]");
      else
	mlwrite ("[Read %d lines]", nline);
    }
  if (lflag)
    mlwrite ("[Read %d line(s), Long lines wrapped]", nline);
 out:
  for (wp = wheadp; wp != NULL; wp = wp->w_wndp)
    {
      if (wp->w_bufp == curbp)
	{
	  wp->w_linep = lforw (curbp->b_linep);
	  wp->w_dotp = lforw (curbp->b_linep);
	  wp->w_doto = 0;
	  wp->w_markp = NULL;
	  wp->w_marko = 0;
	  wp->w_flag |= WFMODE | WFHARD;
	}
    }
  if (s == FIOERR || s == FIOFNF) /* False if error */
    return (FALSE);
  return (TRUE);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x208, %rsp            # imm = 0x208
movq %rdi, %rbx
leaq 0x8ec9(%rip), %r12      # 0xda38
movq (%r12), %r14
movq %r14, %rdi
callq 0x2bf3
cmpl $0x1, %eax
jne 0x4d02
andb $-0x4, 0x32(%r14)
addq $0x33, %r14
movl $0x50, %edx
movq %r14, %rdi
movq %rbx, %rsi
callq 0x2070
movq %rbx, %rdi
callq 0x4ea4
movl %eax, %ebp
cmpl $0x3, %eax
je 0x4cb4
cmpl $0x1, %ebp
jne 0x4bcd
leaq 0x460f(%rip), %rdi      # 0x91cb
xorl %eax, %eax
callq 0x43cc
movl $0x1, %ebp
jmp 0x4cb4
leaq 0x4602(%rip), %rdi      # 0x91d6
xorl %eax, %eax
callq 0x43cc
movq %rsp, %r14
xorl %ebx, %ebx
xorl %r13d, %r13d
movq %r14, %rdi
movl $0x200, %esi            # imm = 0x200
callq 0x4f8a
testl %eax, %eax
je 0x4c01
movl %eax, %ebp
cmpl $0x4, %eax
jne 0x4c6e
movl $0x1, %r13d
movq %r14, %rdi
callq 0x20d0
movq %rax, %r15
movl %r15d, %edi
xorl %eax, %eax
callq 0x503c
testq %rax, %rax
je 0x4c69
movq (%r12), %rcx
movq 0x28(%rcx), %rcx
movq 0x8(%rcx), %rcx
movq %rax, (%rcx)
movq (%r12), %rdx
movq 0x28(%rdx), %rdx
movq %rdx, (%rax)
movq %rcx, 0x8(%rax)
movq (%r12), %rcx
movq 0x28(%rcx), %rcx
movq %rax, 0x8(%rcx)
testl %r15d, %r15d
jle 0x4c62
andl $0x7fffffff, %r15d      # imm = 0x7FFFFFFF
xorl %ecx, %ecx
movb (%rsp,%rcx), %dl
movb %dl, 0x18(%rax,%rcx)
incq %rcx
cmpq %rcx, %r15
jne 0x4c53
incl %ebx
jmp 0x4be3
movl $0x3, %ebp
xorl %eax, %eax
callq 0x4ef7
cmpl $0x2, %ebp
jne 0x4c9f
cmpl $0x1, %ebx
jne 0x4c8f
leaq 0x455f(%rip), %rdi      # 0x91e5
xorl %eax, %eax
callq 0x43cc
jmp 0x4c9f
leaq 0x455d(%rip), %rdi      # 0x91f3
movl %ebx, %esi
xorl %eax, %eax
callq 0x43cc
testl %r13d, %r13d
je 0x4cb4
leaq 0x4558(%rip), %rdi      # 0x9203
movl %ebx, %esi
xorl %eax, %eax
callq 0x43cc
leaq 0x8da5(%rip), %rax      # 0xda60
movq (%rax), %rax
testq %rax, %rax
je 0x4cf7
movq (%r12), %rcx
xorps %xmm0, %xmm0
cmpq %rcx, 0x8(%rax)
jne 0x4cef
movq 0x28(%rcx), %rdx
movq (%rdx), %rdx
movq %rdx, 0x10(%rax)
movq %rdx, 0x18(%rax)
movups %xmm0, 0x20(%rax)
movq $0x0, 0x30(%rax)
orb $0x18, 0x3b(%rax)
movq (%rax), %rax
testq %rax, %rax
jne 0x4cca
andl $-0x3, %ebp
xorl %eax, %eax
cmpl $0x1, %ebp
setne %al
addq $0x208, %rsp            # imm = 0x208
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq