// File: /workspace/github_c_makefile_star2_O3/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, %rbx
movq %rdx, %r14
movq %rsi, %r15
movzwl (%rcx), %ebp
testb $0xc, %bpl
je 0x3fa5
andl $0x8, %ebp
cmpl %edi, 0x924b(%rip)      # 0xd160
jne 0x3f20
cmpl $0x0, 0x9246(%rip)      # 0xd164
je 0x3f3e
movl %edi, 0x923a(%rip)      # 0xd160
movl $0x0, 0x9234(%rip)      # 0xd164
leaq 0x9931(%rip), %rcx      # 0xd868
xorl %esi, %esi
xorl %eax, %eax
callq *0x38(%rcx)
leaq 0x9923(%rip), %r12      # 0xd868
movl %ebp, %edi
shrl $0x3, %edi
xorl %eax, %eax
callq *0x58(%r12)
movslq 0x4(%r12), %r13
testq %r13, %r13
jle 0x3f80
addq %r15, %r13
movsbl (%r15), %edi
xorl %eax, %eax
callq *0x28(%r12)
incl 0x91f5(%rip)            # 0xd164
movb (%r15), %al
incq %r15
movb %al, (%r14)
incq %r14
cmpq %r13, %r15
jb 0x3f5e
xorl %edi, %edi
xorl %eax, %eax
callq *0x58(%r12)
movzwl (%rbx), %eax
andl $-0x6, %eax
shrl %ebp
orl %eax, %ebp
movw %bp, (%rbx)
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x98bc(%rip), %rax      # 0xd868
movslq 0x4(%rax), %rax
testq %rax, %rax
je 0x3f96
leaq (%r15,%rax), %r13
xorl %r12d, %r12d
movb (%r15,%r12), %cl
cmpb (%r14,%r12), %cl
jne 0x3fd0
incq %r12
cmpq %r12, %rax
jne 0x3fbc
jmp 0x3f96
movb -0x1(%r15,%rax), %cl
movb $0x1, %dl
cmpb -0x1(%r14,%rax), %cl
jne 0x400a
leaq (%rax,%r14), %rsi
addq $-0x2, %rsi
xorl %eax, %eax
movl $0x1, %edx
cmpb $0x20, %cl
cmovnel %edx, %eax
movb -0x2(%r13), %cl
leaq -0x1(%rsi), %r8
decq %r13
cmpb (%rsi), %cl
movq %r8, %rsi
je 0x3fed
testl %eax, %eax
sete %dl
addq %r12, %r15
movq %r13, %rbp
testb %dl, %dl
je 0x404e
leaq 0x9355(%rip), %rax      # 0xd370
cmpl $0x1, (%rax)
movq %r13, %rbp
jne 0x404e
movq %r13, %rax
cmpq %rax, %r15
je 0x403d
leaq -0x1(%rax), %rbp
cmpb $0x20, -0x1(%rax)
movq %rbp, %rax
je 0x4026
incq %rbp
jmp 0x4040
movq %r15, %rbp
movq %r13, %rax
subq %rbp, %rax
cmpq $0x4, %rax
cmovlq %r13, %rbp
cmpl %edi, 0x910c(%rip)      # 0xd160
jne 0x405f
cmpl %r12d, 0x9107(%rip)     # 0xd164
je 0x407b
movl %edi, 0x90fb(%rip)      # 0xd160
movl %r12d, 0x90f8(%rip)     # 0xd164
movl %r12d, %esi
xorl %eax, %eax
leaq 0x97f0(%rip), %rcx      # 0xd868
callq *0x38(%rcx)
addq %r12, %r14
leaq 0x97e3(%rip), %r12      # 0xd868
cmpq %rbp, %r15
je 0x40a9
movsbl (%r15), %edi
xorl %eax, %eax
callq *0x28(%r12)
incl 0x90c9(%rip)            # 0xd164
movb (%r15), %al
incq %r15
movb %al, (%r14)
incq %r14
jmp 0x4085
cmpq %r13, %rbp
je 0x40c8
xorl %eax, %eax
callq *0x40(%r12)
cmpq %r13, %r15
je 0x40c8
movb (%r15), %al
incq %r15
movb %al, (%r14)
incq %r14
jmp 0x40b5
movzwl (%rbx), %ebp
andl $-0x2, %ebp
jmp 0x3f93