// File: /workspace/github_c_makefile_star2_O2/ThomasMadappattu[P]Sandmacs/file.c
// Function: ifile
int ifile (char fname[])
{
  LINE *lp0, *lp1, *lp2;
  BUFFER *bp;
  char line[NLINE];
  int i, s, nbytes, nline;
  int lflag;			/* any lines longer than allowed? */

  bp = curbp;			/* Cheap */
  bp->b_flag |= BFCHG;		/* we have changed */
  bp->b_flag &= ~BFTEMP;	/* and are not temporary */
  if ((s = ffropen (fname)) == FIOERR) /* Hard file open */
    goto out;
  if (s == FIOFNF)
    {				/* File not found */
      mlwrite ("[No such file]");
      return (FALSE);
    }
  mlwrite ("[Inserting file]");

  /* back up a line and save the mark here */
  curwp->w_dotp = lback (curwp->w_dotp);
  curwp->w_doto = 0;
  curwp->w_markp = curwp->w_dotp;
  curwp->w_marko = 0;

  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 */
	  break;		/* display */
	}
      lp0 = curwp->w_dotp;	/* line previous to insert */
      lp2 = lp0->l_fp;		/* line after insert */

      /* re-link new line between lp0 and lp2 */
      lp2->l_bp = lp1;
      lp0->l_fp = lp1;
      lp1->l_bp = lp0;
      lp1->l_fp = lp2;

      /* and advance and write out the current line */
      curwp->w_dotp = lp1;
      for (i = 0; i < nbytes; ++i)
	lputc (lp1, i, line[i]);
      ++nline;
    }
  ffclose ();			/* Ignore errors */
  curwp->w_markp = lforw (curwp->w_markp);
  if (s == FIOEOF)
    {				/* Don't zap message! */
      if (nline == 1)
	mlwrite ("[Inserted 1 line]");
      else
	mlwrite ("[Inserted %d lines]", nline);
    }
  if (lflag)
    mlwrite ("[Inserted %d line(s), Long lines wrapped]", nline);
 out:
  /* advance to the next line and mark the window for changes */
  curwp->w_dotp = lforw (curwp->w_dotp);
  curwp->w_flag |= WFHARD;

  /* copy window parameters back to the buffer structure */
  curbp->b_dotp = curwp->w_dotp;
  curbp->b_doto = curwp->w_doto;
  curbp->b_markp = curwp->w_markp;
  curbp->b_marko = curwp->w_marko;

  if (s == FIOERR)		/* 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
leaq 0x8587(%rip), %rbx      # 0xc838
movq (%rbx), %rax
movb 0x32(%rax), %cl
andb $-0x4, %cl
orb $0x2, %cl
movb %cl, 0x32(%rax)
callq 0x4868
movl %eax, %r14d
cmpl $0x3, %eax
je 0x4402
cmpl $0x1, %r14d
jne 0x42ec
leaq 0x3f21(%rip), %rdi      # 0x81ff
xorl %ebp, %ebp
xorl %eax, %eax
callq 0x3e83
jmp 0x4444
leaq 0x3f1b(%rip), %rdi      # 0x820e
xorl %ebx, %ebx
xorl %eax, %eax
callq 0x3e83
leaq 0x8545(%rip), %r12      # 0xc848
movq (%r12), %rax
movq 0x18(%rax), %rcx
movq 0x8(%rcx), %rcx
movq %rcx, 0x18(%rax)
andq $0x0, 0x20(%rax)
movq %rcx, 0x28(%rax)
andq $0x0, 0x30(%rax)
movq %rsp, %r14
xorl %ebp, %ebp
xorl %r13d, %r13d
movq %r14, %rdi
movl $0x200, %esi            # imm = 0x200
callq 0x4949
testl %eax, %eax
je 0x4343
cmpl $0x4, %eax
jne 0x43a2
pushq $0x1
popq %r13
movq %r14, %rdi
callq 0x20c0
movq %rax, %r15
movl %r15d, %edi
xorl %eax, %eax
callq 0x49f4
testq %rax, %rax
je 0x439c
movq (%r12), %rcx
movq 0x18(%rcx), %rcx
movq (%rcx), %rdx
movq %rax, 0x8(%rdx)
movq %rax, (%rcx)
movq %rcx, 0x8(%rax)
movq %rdx, (%rax)
movq (%r12), %rcx
movq %rax, 0x18(%rcx)
testl %r15d, %r15d
cmovlel %ebx, %r15d
xorl %ecx, %ecx
cmpq %rcx, %r15
je 0x4398
movb (%rsp,%rcx), %dl
movb %dl, 0x18(%rax,%rcx)
incq %rcx
jmp 0x4387
incl %ebp
jmp 0x4329
pushq $0x3
popq %r14
jmp 0x43a5
movl %eax, %r14d
xorl %eax, %eax
callq 0x48b9
movq (%r12), %rax
movq 0x28(%rax), %rcx
movq (%rcx), %rcx
movq %rcx, 0x28(%rax)
cmpl $0x2, %r14d
leaq 0x8472(%rip), %rbx      # 0xc838
jne 0x43ed
cmpl $0x1, %ebp
jne 0x43dd
leaq 0x3e4b(%rip), %rdi      # 0x821f
xorl %eax, %eax
callq 0x3e83
jmp 0x43ed
leaq 0x3e4d(%rip), %rdi      # 0x8231
movl %ebp, %esi
xorl %eax, %eax
callq 0x3e83
testl %r13d, %r13d
je 0x4402
leaq 0x3e4c(%rip), %rdi      # 0x8245
movl %ebp, %esi
xorl %eax, %eax
callq 0x3e83
leaq 0x843f(%rip), %rax      # 0xc848
movq (%rax), %rax
movq 0x18(%rax), %rcx
movq (%rcx), %rcx
movq %rcx, 0x18(%rax)
orb $0x8, 0x3b(%rax)
movq (%rbx), %rdx
movq %rcx, 0x8(%rdx)
movq 0x20(%rax), %rcx
movq %rcx, 0x10(%rdx)
movq 0x28(%rax), %rcx
movq %rcx, 0x18(%rdx)
movq 0x30(%rax), %rax
movq %rax, 0x20(%rdx)
xorl %ebp, %ebp
cmpl $0x3, %r14d
setne %bpl
movl %ebp, %eax
addq $0x208, %rsp            # imm = 0x208
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq