// File: /workspace/github_c_makefile_star2_O1/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, %r15
movq %rsi, %r14
movzwl (%rcx), %ebp
testb $0xc, %bpl
je 0x411a
andl $0x8, %ebp
cmpl %edi, 0x90da(%rip)      # 0xd160
jne 0x4091
cmpl $0x0, 0x90d5(%rip)      # 0xd164
je 0x40af
movl %edi, 0x90c9(%rip)      # 0xd160
movl $0x0, 0x90c3(%rip)      # 0xd164
leaq 0x97c0(%rip), %rcx      # 0xd868
xorl %esi, %esi
xorl %eax, %eax
callq *0x38(%rcx)
leaq 0x97b2(%rip), %r12      # 0xd868
movl %ebp, %edi
shrl $0x3, %edi
xorl %eax, %eax
callq *0x58(%r12)
movslq 0x4(%r12), %r13
testq %r13, %r13
jle 0x40f1
addq %r14, %r13
movsbl (%r14), %edi
xorl %eax, %eax
callq *0x28(%r12)
incl 0x9084(%rip)            # 0xd164
movb (%r14), %al
incq %r14
movb %al, (%r15)
incq %r15
cmpq %r13, %r14
jb 0x40cf
xorl %edi, %edi
xorl %eax, %eax
callq *0x58(%r12)
movzwl (%rbx), %ecx
andl $-0x6, %ecx
leal 0x4(%rcx), %eax
testl %ebp, %ebp
cmovel %ecx, %eax
movw %ax, (%rbx)
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x9747(%rip), %rax      # 0xd868
movq %rax, %r9
movslq 0x4(%rax), %rax
testq %rax, %rax
sete %cl
je 0x410b
movb (%r14), %dl
movq %r14, %r12
movq %r15, %rbp
cmpb (%r15), %dl
jne 0x4167
leaq -0x1(%rax), %rdx
movq %r15, %rsi
movq %r14, %r12
testq %rdx, %rdx
sete %cl
je 0x410b
incq %r12
leaq 0x1(%rsi), %rbp
movb (%r12), %r8b
decq %rdx
cmpb 0x1(%rsi), %r8b
movq %rbp, %rsi
je 0x4148
testb %cl, %cl
jne 0x410b
leaq (%r14,%rax), %r13
movb -0x1(%r13), %cl
movb $0x1, %dl
cmpb -0x1(%r15,%rax), %cl
jne 0x41a8
leaq (%rax,%r15), %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 0x418b
testl %eax, %eax
sete %dl
movq %r13, %r15
testb %dl, %dl
je 0x41e3
leaq 0x91ba(%rip), %rax      # 0xd370
cmpl $0x1, (%rax)
movq %r13, %r15
jne 0x41e3
xorl %ecx, %ecx
movq %rcx, %rax
leaq (%rcx,%r13), %r15
cmpq %r12, %r15
je 0x41d8
leaq -0x1(%rax), %rcx
cmpb $0x20, -0x1(%r13,%rax)
je 0x41c0
negq %rax
cmpq $0x4, %rax
cmovlq %r13, %r15
movl %r12d, %esi
subl %r14d, %esi
cmpl %edi, 0x8f71(%rip)      # 0xd160
movq %r9, %r14
jne 0x41fc
cmpl %esi, 0x8f6a(%rip)      # 0xd164
je 0x422e
movl %edi, 0x8f5e(%rip)      # 0xd160
movl %esi, 0x8f5c(%rip)      # 0xd164
xorl %eax, %eax
callq *0x38(%r14)
jmp 0x422e
movsbl (%r12), %edi
xorl %eax, %eax
callq *0x28(%r14)
incl 0x8f43(%rip)            # 0xd164
movb (%r12), %al
incq %r12
movb %al, (%rbp)
incq %rbp
cmpq %r15, %r12
jne 0x4210
cmpq %r13, %r15
je 0x4252
xorl %eax, %eax
callq *0x40(%r14)
cmpq %r13, %r12
je 0x4252
movb (%r12), %al
incq %r12
movb %al, (%rbp)
incq %rbp
jmp 0x423e
movzwl (%rbx), %eax
andl $-0x2, %eax
jmp 0x4108