// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x240, %rsp            # imm = 0x240
movl %edi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
leaq 0x53f8(%rip), %rax      # 0x11340
cmpl $0x0, (%rax)
jne 0xbf67
leaq 0x188d(%rip), %rdi      # 0xd7e1
movb $0x0, %al
callq 0x5970
movl $0x0, -0x4(%rbp)
jmp 0xc1b7
xorl %edi, %edi
movl $0x1, %esi
callq 0x2b00
leaq 0x58fe(%rip), %rax      # 0x11878
movq (%rax), %rax
movq 0x18(%rax), %rax
movq (%rax), %rax
movq %rax, -0x18(%rbp)
xorl %edi, %edi
movl $0x1, %esi
callq 0x2940
leaq 0x58dd(%rip), %rax      # 0x11878
movq (%rax), %rax
movq 0x20(%rax), %rax
movl %eax, -0x22c(%rbp)
cmpl $0x0, -0x22c(%rbp)
je 0xbfd2
leaq 0x58c0(%rip), %rax      # 0x11878
movq (%rax), %rax
movq 0x18(%rax), %rax
movsbl 0x18(%rax), %eax
cmpl $0x9, %eax
jne 0xbfd2
movl $0x8, -0x22c(%rbp)
movl $0x0, -0x228(%rbp)
movl $0x1, -0x23c(%rbp)
movl $0x0, -0x238(%rbp)
cmpl $0x0, -0x238(%rbp)
setne %al
xorb $-0x1, %al
testb $0x1, %al
jne 0xc005
jmp 0xc1ad
leaq 0x586c(%rip), %rax      # 0x11878
movq (%rax), %rax
movq 0x20(%rax), %rax
leaq 0x585e(%rip), %rcx      # 0x11878
movq (%rcx), %rcx
movq 0x18(%rcx), %rcx
movslq 0x14(%rcx), %rcx
cmpq %rcx, %rax
jne 0xc057
movl $0x20, -0x224(%rbp)
leaq 0x583d(%rip), %rax      # 0x11878
movq (%rax), %rax
movq 0x18(%rax), %rax
movq (%rax), %rax
cmpq -0x18(%rbp), %rax
jne 0xc055
movl $0x1, -0x238(%rbp)
jmp 0xc083
leaq 0x581a(%rip), %rax      # 0x11878
movq (%rax), %rax
movq 0x18(%rax), %rax
leaq 0x580c(%rip), %rcx      # 0x11878
movq (%rcx), %rcx
movq 0x20(%rcx), %rcx
movsbl 0x18(%rax,%rcx), %eax
andl $0xff, %eax
movl %eax, -0x224(%rbp)
movl $0x1, %edi
xorl %esi, %esi
callq 0x7750
cmpl $0x20, -0x224(%rbp)
je 0xc0d4
cmpl $0x9, -0x224(%rbp)
je 0xc0d4
cmpl $0x1ff, -0x228(%rbp)    # imm = 0x1FF
jge 0xc0cf
movl -0x224(%rbp), %eax
movb %al, %cl
movl -0x228(%rbp), %eax
movl %eax, %edx
addl $0x1, %edx
movl %edx, -0x228(%rbp)
cltq
movb %cl, -0x220(%rbp,%rax)
jmp 0xc1a8
cmpl $0x0, -0x228(%rbp)
je 0xc1a6
movl -0x22c(%rbp), %eax
addl $0x1, %eax
addl -0x228(%rbp), %eax
movl %eax, -0x234(%rbp)
movl -0x234(%rbp), %eax
leaq 0x523d(%rip), %rcx      # 0x11340
cmpl (%rcx), %eax
jg 0xc13a
cmpl $0x0, -0x23c(%rbp)
jne 0xc12e
movl $0x1, %edi
movl $0x20, %esi
callq 0x7150
movl -0x22c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x22c(%rbp)
movl $0x0, -0x23c(%rbp)
jmp 0xc14b
movb $0x0, %al
callq 0x7540
movl $0x0, -0x22c(%rbp)
movl $0x0, -0x230(%rbp)
movl -0x230(%rbp), %eax
cmpl -0x228(%rbp), %eax
jge 0xc19c
movslq -0x230(%rbp), %rax
movsbl -0x220(%rbp,%rax), %esi
movl $0x1, %edi
callq 0x7150
movl -0x22c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x22c(%rbp)
movl -0x230(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x230(%rbp)
jmp 0xc155
movl $0x0, -0x228(%rbp)
jmp 0xc1a8
jmp 0xbff0
movb $0x0, %al
callq 0x7540
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x240, %rsp            # imm = 0x240
popq %rbp
retq