// File: /workspace/github_c_makefile_star2_O2/hughbarney[P]pEmacs/display.c
// Function: updateline
void updateline (int row, char vline[], char pline[], short *flags)
{
  char *cp1, *cp2, *cp3, *cp4, *cp5;
  int nbflag;			/* non-blanks to the right flag? */
  int rev;			/* reverse video flag */
  int req;			/* reverse video request flag */

  /* set up pointers to virtual and physical lines */
  cp1 = &vline[0];
  cp2 = &pline[0];

  /* if we need to change the reverse video status of the current line, we
   * need to re-write the entire line */
  rev = *flags & VFREV;
  req = *flags & VFREQ;
  if (rev != req)
    {
      movecursor (row, 0);	 /* Go to start of line */
      (*term.t_rev) (req != FALSE);	  /* set rev video if needed */

      /* scan through the line and dump it to the screen and the virtual
       * screen array */
      cp3 = &vline[term.t_ncol];
      while (cp1 < cp3)
	{
	  (*term.t_putchar) (*cp1);
	  ++ttcol;
	  *cp2++ = *cp1++;
	}
      (*term.t_rev) (FALSE);	 /* turn rev video off */

      /* update the needed flags */
      *flags &= ~VFCHG;
      if (req)
	*flags |= VFREV;
      else
	*flags &= ~VFREV;
      return;
    }

  /* advance past any common chars at the left */
  while (cp1 != &vline[term.t_ncol] && cp1[0] == cp2[0])
    {
      ++cp1;
      ++cp2;
    }

  /* This can still happen, even though we only call this routine on changed
   * lines. A hard update is always done when a line splits, a massive change
   * is done, or a buffer is displayed twice. This optimizes out most of the
   * excess updating. A lot of computes are used, but these tend to be hard
   * operations that do a lot of update, so I don't really care */
  /* if both lines are the same, no update needs to be done */
  if (cp1 == &vline[term.t_ncol])
    return;

  /* find out if there is a match on the right */
  nbflag = FALSE;
  cp3 = &vline[term.t_ncol];
  cp4 = &pline[term.t_ncol];

  while (cp3[-1] == cp4[-1])
    {
      --cp3;
      --cp4;
      if (cp3[0] != ' ')	 /* Note if any nonblank */
	nbflag = TRUE;		 /* in right match */
    }

  cp5 = cp3;

  if (nbflag == FALSE && eolexist == TRUE)
    {				/* Erase to EOL ? */
      while (cp5 != cp1 && cp5[-1] == ' ')
	--cp5;
      if (cp3 - cp5 <= 3)	/* Use only if erase is */
	cp5 = cp3;		/* fewer characters */
    }
  movecursor (row, cp1 - &vline[0]); /* Go to start of line */

  while (cp1 != cp5)
    {				/* Ordinary */
      (*term.t_putchar) (*cp1);
      ++ttcol;
      *cp2++ = *cp1++;
    }

  if (cp5 != cp3)
    {				/* Erase */
      (*term.t_eeol) ();
      while (cp1 != cp3)
	*cp2++ = *cp1++;
    }
  *flags &= ~VFCHG;		/* flag this line is changed */
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rcx, %rbp
movq %rdx, %r14
movq %rsi, %r15
movzwl (%rcx), %ebx
testb $0xc, %bl
je 0x3b9a
andl $0x8, %ebx
xorl %esi, %esi
callq 0x3220
leaq 0x8d0f(%rip), %r12      # 0xc858
movl %ebx, %edi
shrl $0x3, %edi
xorl %eax, %eax
callq *0x58(%r12)
movslq 0x4(%r12), %r13
addq %r15, %r13
cmpq %r13, %r15
jae 0x3b81
movsbl (%r15), %edi
xorl %eax, %eax
callq *0x28(%r12)
incl 0x85e1(%rip)            # 0xc154
movb (%r15), %al
incq %r15
movb %al, (%r14)
incq %r14
jmp 0x3b5d
xorl %edi, %edi
xorl %eax, %eax
callq *0x58(%r12)
movzwl (%rbp), %eax
andl $-0x6, %eax
shrl %ebx
orl %eax, %ebx
jmp 0x3caa
leaq 0x8cb7(%rip), %r12      # 0xc858
movslq 0x4(%r12), %rax
xorl %esi, %esi
cmpq %rsi, %rax
je 0x3cae
movb (%r15,%rsi), %cl
cmpb (%r14,%rsi), %cl
jne 0x3bc0
incq %rsi
jmp 0x3ba8
movq %r15, %rcx
negq %rcx
leaq -0x1(%r14), %r9
addq %rsi, %r14
leaq (%r15,%rsi), %r13
xorl %r8d, %r8d
pushq $0x1
popq %r10
movq %rsi, %rdx
movb -0x1(%r15,%rax), %r11b
cmpb (%r9,%rax), %r11b
jne 0x3bfc
cmpb $0x20, %r11b
cmovnel %r10d, %r8d
incq %rdx
decq %r15
incq %rcx
decq %r9
jmp 0x3bdb
movq %rbp, (%rsp)
leaq (%r15,%rax), %rbx
movq %rbx, %rbp
testl %r8d, %r8d
jne 0x3c51
leaq 0x874d(%rip), %r8       # 0xc360
cmpl $0x1, (%r8)
movq %rbx, %rbp
jne 0x3c51
movq %rax, %r8
subq %rdx, %r8
leaq (%r15,%rax), %rdx
incq %rdx
testq %r8, %r8
je 0x3c40
leaq -0x1(%rdx), %rbp
decq %r8
cmpb $0x20, -0x2(%rdx)
movq %rbp, %rdx
je 0x3c29
jmp 0x3c43
movq %r13, %rbp
subq %rbp, %rax
subq %rcx, %rax
cmpq $0x4, %rax
cmovlq %rbx, %rbp
callq 0x3220
cmpq %rbp, %r13
je 0x3c7c
movsbl (%r13), %edi
xorl %eax, %eax
callq *0x28(%r12)
incl 0x84e7(%rip)            # 0xc154
movb (%r13), %al
incq %r13
movb %al, (%r14)
incq %r14
jmp 0x3c56
cmpq %rbp, %rbx
je 0x3c9f
xorl %r15d, %r15d
xorl %eax, %eax
callq *0x40(%r12)
leaq (%r15,%rbp), %rax
cmpq %rax, %rbx
je 0x3c9f
movb (%rax), %al
movb %al, (%r14,%r15)
incq %r15
jmp 0x3c8b
movq (%rsp), %rbp
movzwl (%rbp), %ebx
andl $-0x2, %ebx
movw %bx, (%rbp)
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq