// File: /workspace/github_c_makefile_star2_O2/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 0x4e04(%rip), %rbp      # 0xc310
cmpl $0x0, (%rbp)
je 0x7685
pushq $0x1
popq %rbx
xorl %edi, %edi
movl %ebx, %esi
callq 0x2658
leaq 0x531f(%rip), %r12      # 0xc848
movq (%r12), %rax
movq 0x18(%rax), %rax
movq (%rax), %r13
xorl %edi, %edi
movl %ebx, %esi
callq 0x25a1
movq (%r12), %rcx
movl 0x20(%rcx), %eax
movl $0x0, %edx
movq %rdx, (%rsp)
testl %eax, %eax
je 0x7563
movq 0x18(%rcx), %rcx
cmpb $0x9, 0x18(%rcx)
pushq $0x8
popq %rcx
cmovel %ecx, %eax
movq %rax, (%rsp)
xorl %r14d, %r14d
movl %ebx, 0xc(%rsp)
xorl %eax, %eax
testl %r14d, %r14d
jne 0x766d
movl %eax, %r15d
movq (%r12), %rcx
movq 0x18(%rcx), %rax
movq 0x20(%rcx), %rcx
movslq 0x14(%rax), %rdx
cmpq %rdx, %rcx
je 0x75c9
movzbl 0x18(%rax,%rcx), %r14d
movl %ebx, %edi
xorl %esi, %esi
callq 0x4dec
cmpl $0x9, %r14d
je 0x75c4
cmpl $0x20, %r14d
je 0x75c4
cmpl $0x1fe, %r15d           # imm = 0x1FE
jg 0x7578
movslq %r15d, %rax
incl %r15d
movb %r14b, 0x10(%rsp,%rax)
xorl %r14d, %r14d
movl %r15d, %eax
jmp 0x756c
xorl %r14d, %r14d
jmp 0x75dc
xorl %r14d, %r14d
cmpq %r13, (%rax)
sete %r14b
movl %ebx, %edi
xorl %esi, %esi
callq 0x4dec
movl $0x0, %eax
testl %r15d, %r15d
je 0x756c
movq (%rsp), %rax
addl %r15d, %eax
incl %eax
cmpl (%rbp), %eax
jle 0x7605
movq $0x0, (%rsp)
xorl %eax, %eax
callq 0x4d0a
jmp 0x7632
cmpl $0x0, 0xc(%rsp)
je 0x7616
movl $0x0, 0xc(%rsp)
jmp 0x7632
movl $0x0, 0xc(%rsp)
movq (%rsp), %rax
incl %eax
movq %rax, (%rsp)
movl %ebx, %edi
pushq $0x20
popq %rsi
callq 0x4b10
testl %r15d, %r15d
movl $0x0, %eax
cmovlel %eax, %r15d
xorl %ebp, %ebp
cmpq %rbp, %r15
je 0x7656
movsbl 0x10(%rsp,%rbp), %esi
movl %ebx, %edi
callq 0x4b10
incq %rbp
jmp 0x7640
movq (%rsp), %rax
addl %r15d, %eax
movq %rax, (%rsp)
leaq 0x4ca8(%rip), %rbp      # 0xc310
jmp 0x756a
xorl %eax, %eax
addq $0x218, %rsp            # imm = 0x218
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x4d0a
leaq 0x1065(%rip), %rdi      # 0x86f1
xorl %eax, %eax
callq 0x3e83
xorl %eax, %eax
addq $0x218, %rsp            # imm = 0x218
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq