// File: /workspace/github_c_makefile_star2_O2/hughbarney[P]pEmacs/line.c
// Function: linsert
int linsert (int n, int c)
{
  WINDOW *wp;
  LINE *lp1, *lp2, *lp3;
  char *cp1, *cp2;
  int i, doto;

  lchange (WFEDIT);
  lp1 = curwp->w_dotp;	       /* Current line */
  if (lp1 == curbp->b_linep)
    {			       /* At the end: special */
      if (curwp->w_doto != 0)
	{
	  mlwrite ("bug: linsert");
	  return (FALSE);
	}
      if ((lp2 = lalloc (n)) == NULL)	/* Allocate new line */
	return (FALSE);
      lp3 = lp1->l_bp;	       /* Previous line */
      lp3->l_fp = lp2;	       /* Link in */
      lp2->l_fp = lp1;
      lp1->l_bp = lp2;
      lp2->l_bp = lp3;
      for (i = 0; i < n; ++i)
	lp2->l_text[i] = c;
      curwp->w_dotp = lp2;
      curwp->w_doto = n;
      return (TRUE);
    }
  doto = curwp->w_doto;	       /* Save for later */
  if (lp1->l_used + n > lp1->l_size)
    {			       /* Hard: reallocate */
      if ((lp2 = lalloc (lp1->l_used + n)) == NULL)
	return (FALSE);
      cp1 = &lp1->l_text[0];
      cp2 = &lp2->l_text[0];
      while (cp1 != &lp1->l_text[doto])
	*cp2++ = *cp1++;
      cp2 += n;
      while (cp1 != &lp1->l_text[lp1->l_used])
	*cp2++ = *cp1++;
      lp1->l_bp->l_fp = lp2;
      lp2->l_fp = lp1->l_fp;
      lp1->l_fp->l_bp = lp2;
      lp2->l_bp = lp1->l_bp;
      free ((char *) lp1);
    }
  else
    {				/* Easy: in place */
      lp2 = lp1;		/* Pretend new line */
      lp2->l_used += n;
      cp2 = &lp1->l_text[lp1->l_used];
      cp1 = cp2 - n;
      while (cp1 != &lp1->l_text[doto])
	*--cp2 = *--cp1;
    }
  for (i = 0; i < n; ++i)	/* Add the characters */
    lp2->l_text[doto + i] = c;
  wp = wheadp;		       /* Update windows */
  while (wp != NULL)
    {
      if (wp->w_linep == lp1)
	wp->w_linep = lp2;
      if (wp->w_dotp == lp1)
	{
	  wp->w_dotp = lp2;
	  if (wp == curwp || wp->w_doto > doto)
	    wp->w_doto += n;
	}
      if (wp->w_markp == lp1)
	{
	  wp->w_markp = lp2;
	  if (wp->w_marko > doto)
	    wp->w_marko += n;
	}
      wp = wp->w_wndp;
    }
  return (TRUE);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %esi, %ebp
movl %edi, %r14d
pushq $0x4
popq %rdi
callq 0x4a3c
leaq 0x7f9d(%rip), %r8       # 0xca38
movq (%r8), %rax
movq 0x18(%rax), %rbx
movq 0x20(%rax), %r12
leaq 0x7f7b(%rip), %rax      # 0xca28
movq (%rax), %rax
cmpq 0x28(%rax), %rbx
je 0x4afc
movslq 0x14(%rbx), %rax
leal (%rax,%r14), %edi
movslq %r14d, %r13
cmpl 0x10(%rbx), %edi
jle 0x4b1a
callq 0x4960
testq %rax, %rax
je 0x4c50
movq %rax, %r15
leaq 0x18(%rbx), %rax
movslq %r12d, %rsi
leaq (%rbx,%rsi), %rcx
addq $0x18, %rcx
xorl %edx, %edx
cmpq %rdx, %rsi
je 0x4b40
movb 0x18(%rbx,%rdx), %dil
movb %dil, 0x18(%r15,%rdx)
incq %rdx
jmp 0x4ae8
testq %r12, %r12
je 0x4c11
leaq 0x37f8(%rip), %rdi      # 0x8304
xorl %ebp, %ebp
xorl %eax, %eax
callq 0x3dec
jmp 0x4c65
movl %edi, 0x14(%rbx)
movslq %r12d, %rcx
leaq (%rbx,%r13), %rdx
addq $0x17, %rdx
cmpq %rax, %rcx
je 0x4b3b
movb 0x17(%rbx,%rax), %sil
movb %sil, (%rdx,%rax)
decq %rax
jmp 0x4b28
movq %rbx, %r15
jmp 0x4b8f
movq %r15, %rsi
addq %r13, %rsi
addq %rsi, %rdx
addq $0x18, %rdx
movslq 0x14(%rbx), %rsi
addq %rax, %rsi
cmpq %rsi, %rcx
je 0x4b67
movb (%rcx), %sil
incq %rcx
movb %sil, (%rdx)
incq %rdx
jmp 0x4b4d
movq 0x8(%rbx), %rax
movq %r15, (%rax)
movq (%rbx), %rax
movq %rax, (%r15)
movq %r15, 0x8(%rax)
movq 0x8(%rbx), %rax
movq %rax, 0x8(%r15)
movq %rbx, %rdi
callq 0x2040
leaq 0x7ea9(%rip), %r8       # 0xca38
movslq %r12d, %rcx
xorl %eax, %eax
testl %r14d, %r14d
cmovlel %eax, %r14d
addq %r15, %rcx
addq $0x18, %rcx
cmpq %rax, %r14
je 0x4bb0
movb %bpl, (%rcx,%rax)
incq %rax
jmp 0x4ba2
movq (%r8), %rax
movslq %r12d, %rcx
leaq 0x7e93(%rip), %rdx      # 0xca50
pushq $0x1
popq %rbp
movq (%rdx), %rdx
testq %rdx, %rdx
je 0x4c65
cmpq %rbx, 0x10(%rdx)
jne 0x4bd6
movq %r15, 0x10(%rdx)
cmpq %rbx, 0x18(%rdx)
jne 0x4bf5
movq %r15, 0x18(%rdx)
movq 0x20(%rdx), %rsi
cmpq %rax, %rdx
je 0x4bee
cmpq %rcx, %rsi
jle 0x4bf5
addq %r13, %rsi
movq %rsi, 0x20(%rdx)
cmpq %rbx, 0x28(%rdx)
jne 0x4bc0
movq %r15, 0x28(%rdx)
movq 0x30(%rdx), %rsi
cmpq %rcx, %rsi
jle 0x4bc0
addq %r13, %rsi
movq %rsi, 0x30(%rdx)
jmp 0x4bc0
movq %r8, %r15
movl %r14d, %edi
callq 0x4960
testq %rax, %rax
je 0x4c50
movq 0x8(%rbx), %rcx
movq %rax, (%rcx)
movq %rbx, (%rax)
movq %rax, 0x8(%rbx)
movq %rcx, 0x8(%rax)
xorl %ecx, %ecx
testl %r14d, %r14d
movl $0x0, %edx
cmovgl %r14d, %edx
cmpq %rcx, %rdx
je 0x4c54
movb %bpl, 0x18(%rax,%rcx)
incq %rcx
jmp 0x4c41
xorl %ebp, %ebp
jmp 0x4c65
movq (%r15), %rcx
movq %rax, 0x18(%rcx)
movslq %r14d, %rax
movq %rax, 0x20(%rcx)
pushq $0x1
popq %rbp
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq