// File: /workspace/github_c_makefile_star2_O1/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 0x53b7(%rip), %rax      # 0xd320
cmpl $0x0, (%rax)
je 0x80eb
xorl %r14d, %r14d
movl $0x1, %r13d
xorl %edi, %edi
movl $0x1, %esi
callq 0x26b0
leaq 0x58ca(%rip), %rbx      # 0xd858
movq (%rbx), %rax
movq 0x18(%rax), %rax
movq (%rax), %rax
movq %rax, 0x8(%rsp)
xorl %edi, %edi
movl $0x1, %esi
callq 0x25d9
movq (%rbx), %rcx
movl 0x20(%rcx), %eax
movl $0x0, %edx
movq %rdx, (%rsp)
testl %eax, %eax
je 0x7fd0
movq 0x18(%rcx), %rcx
cmpb $0x9, 0x18(%rcx)
movl $0x8, %ecx
cmovel %ecx, %eax
movq %rax, (%rsp)
movl $0x1, %r15d
xorl %ebx, %ebx
leaq 0x5879(%rip), %rax      # 0xd858
movq (%rax), %rcx
movq 0x18(%rcx), %rax
movq 0x20(%rcx), %rcx
movslq 0x14(%rax), %rdx
cmpq %rdx, %rcx
jne 0x8004
movq 0x8(%rsp), %rcx
cmpq %rcx, (%rax)
cmovel %r13d, %r14d
movb $0x20, %bpl
jmp 0x8009
movb 0x18(%rax,%rcx), %bpl
movl $0x1, %edi
xorl %esi, %esi
callq 0x54cf
cmpb $0x9, %bpl
je 0x8024
movzbl %bpl, %eax
cmpl $0x20, %eax
jne 0x8056
xorl %r12d, %r12d
testl %ebx, %ebx
je 0x80c7
movq (%rsp), %rax
addl %ebx, %eax
incl %eax
leaq 0x52e2(%rip), %rcx      # 0xd320
cmpl (%rcx), %eax
jle 0x806d
movq $0x0, (%rsp)
xorl %eax, %eax
callq 0x53d0
movl %r15d, %ebp
jmp 0x808d
cmpl $0x1fe, %ebx            # imm = 0x1FE
jg 0x8068
movslq %ebx, %rax
incl %ebx
movb %bpl, 0x10(%rsp,%rax)
movl %ebx, %r12d
jmp 0x80c7
xorl %ebp, %ebp
testl %r15d, %r15d
jne 0x808d
movq (%rsp), %rax
incl %eax
movq %rax, (%rsp)
movl $0x1, %edi
movl $0x20, %esi
callq 0x51ad
testl %ebx, %ebx
jle 0x80c4
movl %ebx, %r15d
xorl %r13d, %r13d
movsbl 0x10(%rsp,%r13), %esi
movl $0x1, %edi
callq 0x51ad
incq %r13
cmpq %r13, %r15
jne 0x8097
movq (%rsp), %rax
addl %ebx, %eax
movq %rax, (%rsp)
movl %ebp, %r15d
movl $0x1, %r13d
jmp 0x80c7
movl %ebp, %r15d
movl %r12d, %ebx
testl %r14d, %r14d
je 0x7fd8
xorl %eax, %eax
addq $0x218, %rsp            # imm = 0x218
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x53d0
leaq 0x15ff(%rip), %rdi      # 0x96f1
xorl %eax, %eax
callq 0x446e
xorl %eax, %eax
addq $0x218, %rsp            # imm = 0x218
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq