// File: /workspace/github_c_makefile_star2_O3/hughbarney[P]pEmacs/display.c
// Function: update
void update ()
{
  VIDEO *vp1, *vp2;
  LINE *lp;
  WINDOW *wp;
  int i, j, c;

  if (typahead())
    return;

  /* update the reverse video flags for any mode lines out there */
  for (i = 0; i < term.t_nrow; ++i)
    vscreen[i]->v_flag &= ~VFREQ;

  wp = wheadp;
  while (wp != NULL)
    {
      vscreen[wp->w_toprow + wp->w_ntrows]->v_flag |= VFREQ;
      wp = wp->w_wndp;
    }

  wp = wheadp;
  while (wp != NULL)
    {
      /* Look at any window with update flags set on */
      if (wp->w_flag != 0)
	{
	  /* If not force reframe, check the framing */
	  if ((wp->w_flag & WFFORCE) == 0)
	    {
	      lp = wp->w_linep;
	      for (i = 0; i < wp->w_ntrows; ++i)
		{
		  if (lp == wp->w_dotp)
		    goto out;
		  if (lp == wp->w_bufp->b_linep)
		    break;
		  lp = lforw (lp);
		}
	    }
	  /* Not acceptable, better compute a new value for the line at the top
	   * of the window. Then set the "WFHARD" flag to force full redraw */
	  i = wp->w_force;
	  if (i > 0)
	    {
	      --i;
	      if (i >= wp->w_ntrows)
		i = wp->w_ntrows - 1;
	    }
	  else if (i < 0)
	    {
	      i += wp->w_ntrows;
	      if (i < 0)
		i = 0;
	    }
	  else
	    i = wp->w_ntrows / 2;
	  lp = wp->w_dotp;
	  while (i != 0 && lback (lp) != wp->w_bufp->b_linep)
	    {
	      --i;
	      lp = lback (lp);
	    }
	  wp->w_linep = lp;
	  wp->w_flag |= WFHARD;	   /* Force full */

	out:
	  /* Try to use reduced update. Mode line update has its own special
	   * flag. The fast update is used if the only thing to do is within
	   * the line editing */
	  lp = wp->w_linep;
	  i = wp->w_toprow;
	  if ((wp->w_flag & ~WFMODE) == WFEDIT)
	    {
	      while (lp != wp->w_dotp)
		{
		  ++i;
		  lp = lforw (lp);
		}
	      vscreen[i]->v_flag |= VFCHG;
	      vtmove (i, 0);
	      for (j = 0; j < llength (lp); ++j)
		vtputc (lgetc (lp, j));
	      vteeol ();
	    }
	  else if ((wp->w_flag & (WFEDIT | WFHARD)) != 0)
	    {
	      while (i < wp->w_toprow + wp->w_ntrows)
		{
		  vscreen[i]->v_flag |= VFCHG;
		  vtmove (i, 0);
		  /* if line has been changed */
		  if (lp != wp->w_bufp->b_linep)
		    {
		      for (j = 0; j < llength (lp); ++j)
			vtputc (lgetc (lp, j));
		      lp = lforw (lp);
		    }
		  vteeol ();
		  ++i;
		}
	    }
	}
      if (wp->w_flag & WFMODE)
	modeline(wp);
      wp->w_flag = 0;
      wp->w_force = 0;

      wp = wp->w_wndp;		/* and onward to the next window */
    }

  /* Always recompute the row and column number of the hardware cursor. This
   * is the only update for simple moves */
  lp = curwp->w_linep;
  currow = curwp->w_toprow;
  while (lp != curwp->w_dotp)
    {
      ++currow;
      lp = lforw (lp);
    }

  curcol = 0;
  i = 0;
  while (i < curwp->w_doto)
    {
      c = lgetc (lp, i++);
      if (c == '\t')
	curcol |= 0x07;
      else if (c < 0x20 || c == 0x7F)
	++curcol;
      ++curcol;
    }
  if (curcol >= term.t_ncol - 1)
    {				 /* extended line */
      /* flag we are extended and changed */
      vscreen[currow]->v_flag |= VFEXT | VFCHG;
      updext ();		 /* and output extended line */
    }
  else
    lbound = 0;			/* not extended line */

  /* make sure no lines need to be de-extended because the cursor is no
   * longer on them */

  wp = wheadp;

  while (wp != NULL)
    {
      lp = wp->w_linep;
      i = wp->w_toprow;

      while (i < wp->w_toprow + wp->w_ntrows)
	{
	  if (vscreen[i]->v_flag & VFEXT)
	    {
	      /* always flag extended lines as changed */
	      vscreen[i]->v_flag |= VFCHG;
	      if ((wp != curwp) || (lp != wp->w_dotp) ||
		  (curcol < term.t_ncol - 1))
		{
		  vtmove (i, 0);
		  for (j = 0; j < llength (lp); ++j)
		    vtputc (lgetc (lp, j));
		  vteeol ();
		  /* this line no longer is extended */
		  vscreen[i]->v_flag &= ~VFEXT;
		}
	    }
	  lp = lforw (lp);
	  ++i;
	}
      /* and onward to the next window */
      wp = wp->w_wndp;
    }

  /* Special hacking if the screen is garbage. Clear the hardware screen, and
   * update your copy to agree with it. Set all the virtual screen change
   * bits, to force a full update */
  if (sgarbf != FALSE)
    {
      for (i = 0; i < term.t_nrow; ++i)
	{
	  vscreen[i]->v_flag |= VFCHG;
	  vp1 = pscreen[i];
	  for (j = 0; j < term.t_ncol; ++j)
	    vp1->v_text[j] = ' ';
	}

      movecursor (0, 0);	 /* Erase the screen */
      (*term.t_eeop) ();
      sgarbf = FALSE;		 /* Erase-page clears */
      mpresf = FALSE;		 /* the message area */
    }
  /* Make sure that the physical and virtual displays agree. Unlike before,
   * the "updateline" code is only called with a line that has been updated
   * for sure */
  for (i = 0; i < term.t_nrow; ++i)
    {
      vp1 = vscreen[i];

      /* for each line that needs to be updated, or that needs its reverse
       * video status changed, call the line updater */
      j = vp1->v_flag;
      if (((j & VFCHG) != 0) || (((j & VFREV) == 0) != ((j & VFREQ) == 0)))
	{
	  if (typahead ())
	    return;
	  vp2 = pscreen[i];
	  updateline (i, &vp1->v_text[0], &vp2->v_text[0], &vp1->v_flag);
	}
    }

  /* Finally, update the hardware cursor and flush out buffers */
  movecursor (currow, curcol - lbound);
  (*term.t_flush) ();
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
xorl %eax, %eax
callq 0x7c95
testl %eax, %eax
je 0x3734
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xa12d(%rip), %r11      # 0xd868
movslq (%r11), %rax
testq %rax, %rax
jle 0x375c
movq 0xa1b6(%rip), %rcx      # 0xd900
xorl %edx, %edx
movq (%rcx,%rdx,8), %rsi
andw $-0x9, (%rsi)
incq %rdx
cmpq %rdx, %rax
jne 0x374c
leaq 0xa2fd(%rip), %r14      # 0xda60
movq (%r14), %rbx
testq %rbx, %rbx
je 0x39f6
movq 0xa18a(%rip), %rax      # 0xd900
movq %rbx, %rcx
movsbq 0x38(%rcx), %rdx
movsbq 0x39(%rcx), %rsi
leaq (%rax,%rdx,8), %rdx
movq (%rdx,%rsi,8), %rdx
orw $0x8, (%rdx)
movq (%rcx), %rcx
testq %rcx, %rcx
jne 0x3779
testq %rbx, %rbx
je 0x39f6
xorl %r15d, %r15d
movb 0x3b(%rbx), %al
testb %al, %al
je 0x39cf
testb $0x1, %al
jne 0x37e5
movsbl 0x39(%rbx), %edx
testl %edx, %edx
jle 0x37e5
leaq 0x10(%rbx), %rsi
movq 0x18(%rbx), %rcx
decl %edx
movq %rsi, %rdi
movq (%rdi), %rdi
cmpq %rcx, %rdi
je 0x3812
movq 0x8(%rbx), %r9
subl $0x1, %edx
setb %r8b
cmpq 0x28(%r9), %rdi
je 0x37e5
testb %r8b, %r8b
je 0x37c7
movsbl 0x3a(%rbx), %esi
movsbl 0x39(%rbx), %edx
testl %esi, %esi
jle 0x37fb
cmpb %dl, %sil
jle 0x380e
leal -0x1(%rdx), %esi
jmp 0x3822
testb %sil, %sil
js 0x381a
movl %edx, %ecx
shrb $0x7, %cl
addb %dl, %cl
sarb %cl
movsbl %cl, %esi
jmp 0x3822
decl %esi
jmp 0x3822
movq (%rsi), %r12
movb $0x1, %sil
jmp 0x385a
addl %edx, %esi
testl %esi, %esi
cmovlel %r15d, %esi
movq 0x18(%rbx), %rcx
movq %rcx, %r12
testl %esi, %esi
je 0x384b
movq 0x8(%rbx), %rdi
movq 0x28(%rdi), %rdi
movq %rcx, %r8
movq %r8, %r12
movq 0x8(%r8), %r8
cmpq %rdi, %r8
je 0x384b
movq %r8, %r12
decl %esi
jne 0x3838
movq %r12, 0x10(%rbx)
orb $0x8, %al
movb %al, 0x3b(%rbx)
testb %dl, %dl
setg %sil
movsbl 0x38(%rbx), %edx
movsbl %al, %edi
andl $-0x11, %edi
cmpl $0x4, %edi
jne 0x387a
cmpq %rcx, %r12
je 0x3945
incl %edx
movq (%r12), %r12
jmp 0x3869
testb $0xc, %al
je 0x39cf
testb %sil, %sil
je 0x39cf
movslq %edx, %r13
movq 0xa06b(%rip), %rax      # 0xd900
movq (%rax,%r13,8), %rax
orw $0x1, (%rax)
movl %r13d, 0xa04c(%rip)     # 0xd8f0
movl $0x0, 0xa046(%rip)      # 0xd8f4
movq 0x8(%rbx), %rax
cmpq 0x28(%rax), %r12
je 0x38e9
cmpl $0x0, 0x14(%r12)
jle 0x38ed
xorl %ebp, %ebp
movzbl 0x18(%r12,%rbp), %edi
callq 0x3559
incq %rbp
movslq 0x14(%r12), %rax
cmpq %rax, %rbp
jl 0x38c2
movl 0xa014(%rip), %eax      # 0xd8f4
leaq 0x9f81(%rip), %r11      # 0xd868
jmp 0x38ef
xorl %eax, %eax
jmp 0x38f3
xorl %eax, %eax
movq (%r12), %r12
cmpl 0x4(%r11), %eax
jge 0x3927
movq 0xa000(%rip), %rcx      # 0xd900
movslq 0x9fe9(%rip), %rdx      # 0xd8f0
movq (%rcx,%rdx,8), %rcx
leal 0x1(%rax), %edx
movl %edx, 0x9fe0(%rip)      # 0xd8f4
cltq
movb $0x20, 0x2(%rcx,%rax)
movl 0x9fd3(%rip), %eax      # 0xd8f4
cmpl 0x4(%r11), %eax
jl 0x390b
incq %r13
movsbq 0x38(%rbx), %rax
movsbq 0x39(%rbx), %rcx
addq %rax, %rcx
cmpq %rcx, %r13
jl 0x388e
jmp 0x39cf
movq 0x9fb4(%rip), %rax      # 0xd900
movslq %edx, %rcx
movq (%rax,%rcx,8), %rax
orw $0x1, (%rax)
movl %ecx, 0x9f93(%rip)      # 0xd8f0
movl $0x0, 0x9f8d(%rip)      # 0xd8f4
cmpl $0x0, 0x14(%r12)
jle 0x3999
xorl %r13d, %r13d
movzbl 0x18(%r12,%r13), %edi
callq 0x3559
incq %r13
movslq 0x14(%r12), %rax
cmpq %rax, %r13
jl 0x3972
movl 0x9f64(%rip), %eax      # 0xd8f4
leaq 0x9ed1(%rip), %r11      # 0xd868
jmp 0x399b
xorl %eax, %eax
cmpl 0x4(%r11), %eax
jge 0x39cf
movq 0x9f58(%rip), %rcx      # 0xd900
movslq 0x9f41(%rip), %rdx      # 0xd8f0
movq (%rcx,%rdx,8), %rcx
leal 0x1(%rax), %edx
movl %edx, 0x9f38(%rip)      # 0xd8f4
cltq
movb $0x20, 0x2(%rcx,%rax)
movl 0x9f2b(%rip), %eax      # 0xd8f4
cmpl 0x4(%r11), %eax
jl 0x39b3
testb $0x10, 0x3b(%rbx)
je 0x39e4
movq %rbx, %rdi
callq 0x3d31
leaq 0x9e84(%rip), %r11      # 0xd868
movw $0x0, 0x3a(%rbx)
movq (%rbx), %rbx
testq %rbx, %rbx
jne 0x37a3
leaq 0xa04b(%rip), %rbx      # 0xda48
movq (%rbx), %rdx
movq 0x10(%rdx), %rcx
movsbl 0x38(%rdx), %eax
leaq 0xa111(%rip), %rdi      # 0xdb20
movl %eax, (%rdi)
movq 0x18(%rdx), %rsi
cmpq %rsi, %rcx
je 0x3a26
incl %eax
movq (%rcx), %rcx
cmpq %rsi, %rcx
jne 0x3a1a
movl %eax, (%rdi)
movq 0x20(%rdx), %rdx
leaq 0xa0f3(%rip), %r12      # 0xdb24
movl $0x0, (%r12)
testq %rdx, %rdx
jle 0x3a7c
xorl %edi, %edi
xorl %esi, %esi
movb 0x18(%rcx,%rdi), %r8b
cmpb $0x9, %r8b
jne 0x3a52
orl $0x7, %esi
jmp 0x3a6c
cmpb $0x20, %r8b
setb %r9b
cmpb $0x7f, %r8b
sete %r8b
orb %r9b, %r8b
movzbl %r8b, %r8d
addl %r8d, %esi
incq %rdi
incl %esi
movl %esi, (%r12)
cmpq %rdi, %rdx
jne 0x3a42
jmp 0x3a7e
xorl %esi, %esi
movl 0x4(%r11), %ecx
decl %ecx
cmpl %ecx, %esi
jge 0x3a97
movl $0x0, 0x9e66(%rip)      # 0xd8f8
jmp 0x3bb3
movq 0x9e62(%rip), %rcx      # 0xd900
cltq
movq (%rcx,%rax,8), %rax
orw $0x3, (%rax)
callq 0x40d3
leaq 0x9db4(%rip), %r11      # 0xd868
jmp 0x3bb3
movb 0x39(%r14), %cl
testb %cl, %cl
jle 0x3bb3
movb 0x38(%r14), %dl
leaq 0x10(%r14), %r13
movsbq %dl, %rbp
movq 0x9e28(%rip), %rax      # 0xd900
movq (%r13), %r13
movq (%rax,%rbp,8), %rsi
movzwl (%rsi), %edi
testb $0x2, %dil
je 0x3b9c
orl $0x1, %edi
movw %di, (%rsi)
cmpq (%rbx), %r14
jne 0x3b0e
cmpq 0x18(%r14), %r13
jne 0x3b0e
movl 0x4(%r11), %esi
decl %esi
cmpl %esi, (%r12)
jge 0x3b9c
movl %ebp, 0x9ddc(%rip)      # 0xd8f0
movl $0x0, 0x9dd6(%rip)      # 0xd8f4
cmpl $0x0, 0x14(%r13)
jle 0x3b55
xorl %r15d, %r15d
movzbl 0x18(%r13,%r15), %edi
callq 0x3559
incq %r15
movslq 0x14(%r13), %rax
cmpq %rax, %r15
jl 0x3b28
movl 0x9daf(%rip), %ecx      # 0xd8f4
movq 0x9db4(%rip), %rax      # 0xd900
leaq 0x9d15(%rip), %r11      # 0xd868
jmp 0x3b57
xorl %ecx, %ecx
cmpl 0x4(%r11), %ecx
jge 0x3b8c
movslq 0x9d8c(%rip), %rdx      # 0xd8f0
movq (%rax,%rdx,8), %rax
leal 0x1(%rcx), %edx
movl %edx, 0x9d83(%rip)      # 0xd8f4
movslq %ecx, %rcx
movb $0x20, 0x2(%rax,%rcx)
movl 0x9d75(%rip), %ecx      # 0xd8f4
cmpl 0x4(%r11), %ecx
jl 0x3b68
movq 0x9d74(%rip), %rax      # 0xd900
movq (%rax,%rbp,8), %rcx
andw $-0x3, (%rcx)
movb 0x38(%r14), %dl
movb 0x39(%r14), %cl
incq %rbp
movsbq %dl, %rsi
movsbq %cl, %rdi
addq %rsi, %rdi
cmpq %rdi, %rbp
jl 0x3ad8
movq (%r14), %r14
testq %r14, %r14
jne 0x3ab9
leaq 0x97ae(%rip), %rbx      # 0xd374
cmpl $0x0, (%rbx)
movl (%r11), %eax
je 0x3c6a
testl %eax, %eax
jle 0x3c1b
movl 0x4(%r11), %edx
xorl %ecx, %ecx
movq 0x9d1d(%rip), %rsi      # 0xd900
movq (%rsi,%rcx,8), %rsi
orw $0x1, (%rsi)
testl %edx, %edx
jle 0x3c10
movq 0x9d12(%rip), %rax      # 0xd908
movq (%rax,%rcx,8), %rax
xorl %esi, %esi
movb $0x20, 0x2(%rax,%rsi)
incq %rsi
movslq 0x4(%r11), %rdx
cmpq %rdx, %rsi
jl 0x3bfc
movl (%r11), %eax
incq %rcx
movslq %eax, %rsi
cmpq %rsi, %rcx
jl 0x3bdc
movl 0x9543(%rip), %eax      # 0xd164
orl 0x9539(%rip), %eax      # 0xd160
je 0x3c47
xorl %eax, %eax
movl %eax, 0x952f(%rip)      # 0xd160
movl %eax, 0x952d(%rip)      # 0xd164
xorl %edi, %edi
xorl %esi, %esi
xorl %eax, %eax
leaq 0x9c24(%rip), %rcx      # 0xd868
callq *0x38(%rcx)
xorl %ebp, %ebp
xorl %eax, %eax
leaq 0x9c16(%rip), %rcx      # 0xd868
callq *0x48(%rcx)
leaq 0x9c0c(%rip), %r11      # 0xd868
movl %ebp, (%rbx)
leaq 0x9dcf(%rip), %rax      # 0xda34
movl %ebp, (%rax)
movl (%r11), %eax
testl %eax, %eax
jle 0x3cdb
movq 0x9c8b(%rip), %rcx      # 0xd900
xorl %ebx, %ebx
movq (%rcx,%rbx,8), %r14
movzwl (%r14), %edx
testb $0x1, %dl
jne 0x3c93
movl %edx, %esi
shrl $0x2, %esi
shrl $0x3, %edx
xorl %esi, %edx
testb $0x1, %dl
je 0x3cd0
xorl %eax, %eax
callq 0x7c95
testl %eax, %eax
jne 0x3725
movq 0x9c5f(%rip), %rax      # 0xd908
movq (%rax,%rbx,8), %rdx
leaq 0x2(%r14), %rsi
addq $0x2, %rdx
movl %ebx, %edi
movq %r14, %rcx
callq 0x3eeb
movq 0x9c3a(%rip), %rcx      # 0xd900
leaq 0x9b9b(%rip), %r11      # 0xd868
movl (%r11), %eax
incq %rbx
movslq %eax, %rdx
cmpq %rdx, %rbx
jl 0x3c77
leaq 0x9e3e(%rip), %rax      # 0xdb20
movl (%rax), %edi
movl (%r12), %esi
subl 0x9c0a(%rip), %esi      # 0xd8f8
cmpl %edi, 0x946c(%rip)      # 0xd160
jne 0x3cfe
cmpl %esi, 0x9468(%rip)      # 0xd164
je 0x3d1d
movl %edi, 0x945c(%rip)      # 0xd160
movl %esi, 0x945a(%rip)      # 0xd164
xorl %eax, %eax
leaq 0x9b55(%rip), %rcx      # 0xd868
callq *0x38(%rcx)
leaq 0x9b4b(%rip), %r11      # 0xd868
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmpq *0x30(%r11)