// File: /workspace/github_c_makefile_star2_O3/hughbarney[P]pEmacs/window.c
// Function: splitwind
int splitwind (int f, int n)
{
  LINE *lp;
  WINDOW *wp, *wp1, *wp2;
  int ntru, ntrl, ntrd;

  if (curwp->w_ntrows < 3)
    {
      mlwrite ("Cannot split a %d line window", curwp->w_ntrows);
      return (FALSE);
    }
  if ((wp = (WINDOW *) malloc (sizeof (WINDOW))) == NULL)
    {
      mlwrite ("Cannot allocate WINDOW block");
      return (FALSE);
    }
  ++curbp->b_nwnd;		/* Displayed twice */
  wp->w_bufp = curbp;
  wp->w_dotp = curwp->w_dotp;
  wp->w_doto = curwp->w_doto;
  wp->w_markp = curwp->w_markp;
  wp->w_marko = curwp->w_marko;
  wp->w_flag = 0;
  wp->w_force = 0;
  ntru = (curwp->w_ntrows - 1) / 2; /* Upper size */
  ntrl = (curwp->w_ntrows - 1) - ntru; /* Lower size */
  lp = curwp->w_linep;
  ntrd = 0;
  while (lp != curwp->w_dotp)
    {
      ++ntrd;
      lp = lforw (lp);
    }
  lp = curwp->w_linep;
  if (ntrd <= ntru)
    {				/* Old is upper window */
      if (ntrd == ntru)		/* Hit mode line */
	lp = lforw (lp);
      curwp->w_ntrows = ntru;
      wp->w_wndp = curwp->w_wndp;
      curwp->w_wndp = wp;
      wp->w_toprow = curwp->w_toprow + ntru + 1;
      wp->w_ntrows = ntrl;
    }
  else
    {				/* Old is lower window */
      wp1 = NULL;
      wp2 = wheadp;
      while (wp2 != curwp)
	{
	  wp1 = wp2;
	  wp2 = wp2->w_wndp;
	}
      if (wp1 == NULL)
	wheadp = wp;
      else
	wp1->w_wndp = wp;
      wp->w_wndp = curwp;
      wp->w_toprow = curwp->w_toprow;
      wp->w_ntrows = ntru;
      ++ntru;			/* Mode line */
      curwp->w_toprow += ntru;
      curwp->w_ntrows = ntrl;
      while (ntru--)
	lp = lforw (lp);
    }
  curwp->w_linep = lp;		/* Adjust the top lines */
  wp->w_linep = lp;		/* if necessary */
  curwp->w_flag |= WFMODE | WFHARD;
  wp->w_flag |= WFMODE | WFHARD;
  return (TRUE);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
leaq 0x5bd3(%rip), %r15      # 0xda48
movq (%r15), %r14
movsbl 0x39(%r14), %ebx
cmpl $0x2, %ebx
jg 0x7e99
leaq 0x189f(%rip), %rdi      # 0x9728
xorl %ebp, %ebp
movl %ebx, %esi
xorl %eax, %eax
callq 0x4246
jmp 0x7fa9
movl $0x40, %edi
callq 0x21a0
testq %rax, %rax
je 0x7f32
leaq 0x5b85(%rip), %rcx      # 0xda38
movq (%rcx), %rcx
incb 0x31(%rcx)
movq %rcx, 0x8(%rax)
movq 0x18(%r14), %rdx
movq %rdx, 0x18(%rax)
movq 0x20(%r14), %rcx
movq %rcx, 0x20(%rax)
movq 0x28(%r14), %rcx
movq %rcx, 0x28(%rax)
movq 0x30(%r14), %rcx
movq %rcx, 0x30(%rax)
movw $0x0, 0x3a(%rax)
movzbl %bl, %esi
decl %esi
movl %esi, %ecx
shrl %ecx
leaq 0x10(%r14), %rdi
movl $0xffffffff, %r8d       # imm = 0xFFFFFFFF
movq %rdi, %r9
movq (%r9), %r9
incl %r8d
cmpq %rdx, %r9
jne 0x7ef9
subl %ecx, %esi
movq (%rdi), %rdx
cmpl %ecx, %r8d
jbe 0x7f44
leaq 0x5b4b(%rip), %r9       # 0xda60
xorl %edi, %edi
movq %rdi, %r8
movq (%r9), %rdi
movq %rdi, %r9
cmpq %r14, %rdi
jne 0x7f17
testq %r8, %r8
je 0x7f68
movq %rax, (%r8)
movq (%r15), %r14
jmp 0x7f72
leaq 0x180d(%rip), %rdi      # 0x9746
xorl %ebp, %ebp
xorl %eax, %eax
callq 0x4246
jmp 0x7fa9
jne 0x7f49
movq (%rdx), %rdx
movb %cl, 0x39(%r14)
movq (%r14), %rdi
movq %rdi, (%rax)
movq %rax, (%r14)
movq (%r15), %r14
addb 0x38(%r14), %cl
incb %cl
movb %cl, 0x38(%rax)
movb %sil, 0x39(%rax)
jmp 0x7f93
leaq 0x5af1(%rip), %rdi      # 0xda60
movq %rax, (%rdi)
movq %r14, (%rax)
movb 0x38(%r14), %dil
movb %dil, 0x38(%rax)
movb %cl, 0x39(%rax)
incl %ecx
addl %ecx, %edi
movb %dil, 0x38(%r14)
movb %sil, 0x39(%r14)
movq (%rdx), %rdx
decl %ecx
jne 0x7f8c
movq %rdx, 0x10(%r14)
movq %rdx, 0x10(%rax)
orb $0x18, 0x3b(%r14)
orb $0x18, 0x3b(%rax)
movl $0x1, %ebp
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq