// File: /workspace/github_c_makefile_star2_O3/ThomasMadappattu[P]Sandmacs/word.c
// Function: fillpara
int fillpara (int f, int n)
{
  LINE *eopline;		/* pointer to line just past EOP */
  char wbuf[NLINE];		/* buffer for current word */
  int c;			/* current char during scan */
  int wordlen;			/* length of current word */
  int clength;			/* position on line during fill */
  int i;			/* index during word copy */
  int newlength;		/* tentative new line length */
  int eopflag;			/* Are we at the End-Of-Paragraph? */
  int firstflag;		/* first word? (needs no space) */

  if (fillcol == 0)
    {				/* no fill column set */
      mlwrite ("No fill column set");
      return (FALSE);
    }
  /* record the pointer to the line just past the EOP */
  gotoeop (FALSE, 1);
  eopline = lforw (curwp->w_dotp);

  /* and back top the begining of the paragraph */
  gotobop (FALSE, 1);

  /* initialize various info */
  clength = curwp->w_doto;
  if (clength && curwp->w_dotp->l_text[0] == TAB)
    clength = 8;
  wordlen = 0;

  /* scan through lines, filling words */
  firstflag = TRUE;
  eopflag = FALSE;
  while (!eopflag)
    {
      /* get the next character in the paragraph */
      if (curwp->w_doto == llength (curwp->w_dotp))
	{
	  c = ' ';
	  if (lforw (curwp->w_dotp) == eopline)
	    eopflag = TRUE;
	}
      else
	c = lgetc (curwp->w_dotp, curwp->w_doto);

      ldelete (1, FALSE);	/* and then delete it */

      /* if not a separator, just add it in */
      if (c != ' ' && c != '	')
	{
	  if (wordlen < (NLINE - 1))
	    wbuf[wordlen++] = c;
	}
      else if (wordlen)
	{
	  /* at a word break with a word waiting */
	  /* calculate tantitive new length with word added */
	  newlength = clength + 1 + wordlen;
	  if (newlength <= fillcol)
	    {
	      /* add word to current line */
	      if (!firstflag)
		{
		  linsert (1, ' '); /* the space */
		  ++clength;
		}
	      firstflag = FALSE;
	    }
	  else
	    {
	      lnewline ();	/* start a new line */
	      clength = 0;
	    }

	  /* and add the word in in either case */
	  for (i = 0; i < wordlen; i++)
	    {
	      linsert (1, wbuf[i]);
	      ++clength;
	    }
	  wordlen = 0;
	}
    }
  /* and add a last newline for the end of our new paragraph */
  return (lnewline ());
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x218, %rsp            # imm = 0x218
leaq 0x54d1(%rip), %rax      # 0xd320
cmpl $0x0, (%rax)
je 0x7fd8
xorl %r13d, %r13d
movl $0x1, %r14d
xorl %edi, %edi
movl $0x1, %esi
callq 0x26b0
leaq 0x59e4(%rip), %r12      # 0xd858
movq (%r12), %rax
movq 0x18(%rax), %rax
movq (%rax), %rax
movq %rax, 0x8(%rsp)
xorl %edi, %edi
movl $0x1, %esi
callq 0x25d9
movq (%r12), %rcx
movl 0x20(%rcx), %eax
movl $0x0, %edx
movq %rdx, (%rsp)
testl %eax, %eax
je 0x7eb8
movq 0x18(%rcx), %rcx
cmpb $0x9, 0x18(%rcx)
movl $0x8, %ecx
cmovel %ecx, %eax
movq %rax, (%rsp)
movq (%r12), %rcx
movq 0x18(%rcx), %rax
movq 0x20(%rcx), %rcx
movslq 0x14(%rax), %rdx
cmpq %rdx, %rcx
jne 0x7ee8
xorl %ebx, %ebx
movq 0x8(%rsp), %rcx
cmpq %rcx, (%rax)
sete %bl
movl $0x1, %edi
xorl %esi, %esi
callq 0x53f3
jmp 0x7f09
movzbl 0x18(%rax,%rcx), %ebp
xorl %ebx, %ebx
movl $0x1, %edi
xorl %esi, %esi
callq 0x53f3
cmpl $0x9, %ebp
je 0x7f09
cmpl $0x20, %ebp
jne 0x7f9c
xorl %r15d, %r15d
testl %r13d, %r13d
je 0x7fb5
movq (%rsp), %rax
addl %r13d, %eax
incl %eax
leaq 0x53fb(%rip), %rcx      # 0xd320
cmpl (%rcx), %eax
jle 0x7f3d
movq $0x0, (%rsp)
xorl %eax, %eax
callq 0x52ef
movl %r14d, %ebp
jmp 0x7f5d
xorl %ebp, %ebp
testl %r14d, %r14d
jne 0x7f5d
movq (%rsp), %rax
incl %eax
movq %rax, (%rsp)
movl $0x1, %edi
movl $0x20, %esi
callq 0x50c0
testl %r13d, %r13d
jle 0x7f97
movl %r13d, %r14d
xorl %r12d, %r12d
movsbl 0x10(%rsp,%r12), %esi
movl $0x1, %edi
callq 0x50c0
incq %r12
cmpq %r12, %r14
jne 0x7f68
movq (%rsp), %rax
addl %r13d, %eax
movq %rax, (%rsp)
movl %ebp, %r14d
leaq 0x58c3(%rip), %r12      # 0xd858
jmp 0x7fb5
movl %ebp, %r14d
jmp 0x7fb5
xorl %ebx, %ebx
cmpl $0x1fe, %r13d           # imm = 0x1FE
jg 0x7fb2
movslq %r13d, %rax
incl %r13d
movb %bpl, 0x10(%rsp,%rax)
movl %r13d, %r15d
movl %r15d, %r13d
testl %ebx, %ebx
je 0x7eb8
xorl %eax, %eax
addq $0x218, %rsp            # imm = 0x218
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x52ef
leaq 0x1712(%rip), %rdi      # 0x96f1
xorl %eax, %eax
callq 0x4352
xorl %eax, %eax
addq $0x218, %rsp            # imm = 0x218
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq