// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x250, %rsp            # imm = 0x250
movq %rdi, -0x10(%rbp)
leaq 0xb7a2(%rip), %rax      # 0x11868
movq (%rax), %rax
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
movsbl 0x32(%rax), %ecx
orl $0x2, %ecx
movb %cl, 0x32(%rax)
movq -0x30(%rbp), %rax
movsbl 0x32(%rax), %ecx
andl $-0x2, %ecx
movb %cl, 0x32(%rax)
movq -0x10(%rbp), %rdi
callq 0x6c40
movl %eax, -0x238(%rbp)
cmpl $0x3, %eax
jne 0x6102
jmp 0x636b
cmpl $0x1, -0x238(%rbp)
jne 0x6125
leaq 0x719b(%rip), %rdi      # 0xd2ad
movb $0x0, %al
callq 0x5970
movl $0x0, -0x4(%rbp)
jmp 0x6427
leaq 0x7190(%rip), %rdi      # 0xd2bc
movb $0x0, %al
callq 0x5970
leaq 0xb73e(%rip), %rax      # 0x11878
movq (%rax), %rax
movq 0x18(%rax), %rax
movq 0x8(%rax), %rcx
leaq 0xb72c(%rip), %rax      # 0x11878
movq (%rax), %rax
movq %rcx, 0x18(%rax)
leaq 0xb71e(%rip), %rax      # 0x11878
movq (%rax), %rax
movq $0x0, 0x20(%rax)
leaq 0xb70c(%rip), %rax      # 0x11878
movq (%rax), %rax
movq 0x18(%rax), %rcx
leaq 0xb6fe(%rip), %rax      # 0x11878
movq (%rax), %rax
movq %rcx, 0x28(%rax)
leaq 0xb6f0(%rip), %rax      # 0x11878
movq (%rax), %rax
movq $0x0, 0x30(%rax)
movl $0x0, -0x240(%rbp)
movl $0x0, -0x244(%rbp)
leaq -0x230(%rbp), %rdi
movl $0x200, %esi            # imm = 0x200
callq 0x6db0
movl %eax, %ecx
movl %ecx, -0x238(%rbp)
movb $0x1, %al
cmpl $0x0, %ecx
movb %al, -0x245(%rbp)
je 0x61dd
cmpl $0x4, -0x238(%rbp)
sete %al
movb %al, -0x245(%rbp)
movb -0x245(%rbp), %al
testb $0x1, %al
jne 0x61ec
jmp 0x62ee
cmpl $0x4, -0x238(%rbp)
jne 0x61ff
movl $0x1, -0x244(%rbp)
leaq -0x230(%rbp), %rdi
callq 0x20c0
movl %eax, -0x23c(%rbp)
movl -0x23c(%rbp), %edi
movb $0x0, %al
callq 0x6ed0
movq %rax, -0x20(%rbp)
cmpq $0x0, %rax
jne 0x6237
movl $0x3, -0x238(%rbp)
jmp 0x62ee
leaq 0xb63a(%rip), %rax      # 0x11878
movq (%rax), %rax
movq 0x18(%rax), %rax
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x28(%rbp)
movq -0x20(%rbp), %rcx
movq -0x28(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x20(%rbp), %rcx
movq -0x18(%rbp), %rax
movq %rcx, (%rax)
movq -0x18(%rbp), %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x28(%rbp), %rcx
movq -0x20(%rbp), %rax
movq %rcx, (%rax)
movq -0x20(%rbp), %rcx
leaq 0xb5eb(%rip), %rax      # 0x11878
movq (%rax), %rax
movq %rcx, 0x18(%rax)
movl $0x0, -0x234(%rbp)
movl -0x234(%rbp), %eax
cmpl -0x23c(%rbp), %eax
jge 0x62da
movslq -0x234(%rbp), %rax
movb -0x230(%rbp,%rax), %dl
movq -0x20(%rbp), %rax
movslq -0x234(%rbp), %rcx
movb %dl, 0x18(%rax,%rcx)
movl -0x234(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x234(%rbp)
jmp 0x629e
movl -0x240(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x240(%rbp)
jmp 0x61a7
movb $0x0, %al
callq 0x6ce0
leaq 0xb57c(%rip), %rax      # 0x11878
movq (%rax), %rax
movq 0x28(%rax), %rax
movq (%rax), %rcx
leaq 0xb56b(%rip), %rax      # 0x11878
movq (%rax), %rax
movq %rcx, 0x28(%rax)
cmpl $0x2, -0x238(%rbp)
jne 0x634c
cmpl $0x1, -0x240(%rbp)
jne 0x6336
leaq 0x6fa0(%rip), %rdi      # 0xd2cd
movb $0x0, %al
callq 0x5970
jmp 0x634a
movl -0x240(%rbp), %esi
leaq 0x6f9c(%rip), %rdi      # 0xd2df
movb $0x0, %al
callq 0x5970
jmp 0x634c
cmpl $0x0, -0x244(%rbp)
je 0x6369
movl -0x240(%rbp), %esi
leaq 0x6f91(%rip), %rdi      # 0xd2f3
movb $0x0, %al
callq 0x5970
jmp 0x636b
leaq 0xb506(%rip), %rax      # 0x11878
movq (%rax), %rax
movq 0x18(%rax), %rax
movq (%rax), %rcx
leaq 0xb4f5(%rip), %rax      # 0x11878
movq (%rax), %rax
movq %rcx, 0x18(%rax)
leaq 0xb4e7(%rip), %rax      # 0x11878
movq (%rax), %rax
movsbl 0x3b(%rax), %ecx
orl $0x8, %ecx
movb %cl, 0x3b(%rax)
leaq 0xb4d3(%rip), %rax      # 0x11878
movq (%rax), %rax
movq 0x18(%rax), %rcx
leaq 0xb4b5(%rip), %rax      # 0x11868
movq (%rax), %rax
movq %rcx, 0x8(%rax)
leaq 0xb4b7(%rip), %rax      # 0x11878
movq (%rax), %rax
movq 0x20(%rax), %rcx
leaq 0xb499(%rip), %rax      # 0x11868
movq (%rax), %rax
movq %rcx, 0x10(%rax)
leaq 0xb49b(%rip), %rax      # 0x11878
movq (%rax), %rax
movq 0x28(%rax), %rcx
leaq 0xb47d(%rip), %rax      # 0x11868
movq (%rax), %rax
movq %rcx, 0x18(%rax)
leaq 0xb47f(%rip), %rax      # 0x11878
movq (%rax), %rax
movq 0x30(%rax), %rcx
leaq 0xb461(%rip), %rax      # 0x11868
movq (%rax), %rax
movq %rcx, 0x20(%rax)
cmpl $0x3, -0x238(%rbp)
jne 0x6420
movl $0x0, -0x4(%rbp)
jmp 0x6427
movl $0x1, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x250, %rsp            # imm = 0x250
popq %rbp
retq
nopw %cs:(%rax,%rax)