// File: /workspace/github_c_makefile_star2_O1/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 0x5c4a(%rip), %r14      # 0xda48
movq (%r14), %r15
movsbl 0x39(%r15), %ebx
cmpl $0x2, %ebx
jg 0x7e22
leaq 0x192e(%rip), %rdi      # 0x9740
xorl %ebp, %ebp
movl %ebx, %esi
xorl %eax, %eax
callq 0x43cc
jmp 0x7f30
movl $0x40, %edi
callq 0x21a0
testq %rax, %rax
je 0x7ee6
leaq 0x5bfc(%rip), %rcx      # 0xda38
movq (%rcx), %rcx
incb 0x31(%rcx)
movq %rcx, 0x8(%rax)
movq 0x18(%r15), %rcx
movq %rcx, 0x18(%rax)
movq 0x20(%r15), %rcx
movq %rcx, 0x20(%rax)
movq 0x28(%r15), %rcx
movq %rcx, 0x28(%rax)
movq 0x30(%r15), %rcx
movq %rcx, 0x30(%rax)
movw $0x0, 0x3a(%rax)
movl %ebx, %ecx
decl %ebx
movl %ebx, %edx
shrl $0x1f, %edx
addl %edx, %ecx
decl %ecx
sarl %ecx
leaq 0x10(%r15), %rdx
movq 0x18(%r15), %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
movq %rdx, %r8
movq (%r8), %r8
incl %esi
cmpq %rdi, %r8
jne 0x7e8b
subl %ecx, %ebx
movq (%rdx), %rdx
cmpl %ecx, %esi
jle 0x7ef8
leaq 0x5bbb(%rip), %r8       # 0xda60
xorl %edi, %edi
movq %rdi, %rsi
movq (%r8), %rdi
movq %rdi, %r8
cmpq %r15, %rdi
jne 0x7ea7
testq %rsi, %rsi
jne 0x7ec1
leaq 0x5b9f(%rip), %rsi      # 0xda60
movq %rax, (%rsi)
movq (%r14), %rsi
movq %rsi, (%rax)
movb 0x38(%rsi), %dil
movb %dil, 0x38(%rax)
movb %cl, 0x39(%rax)
incl %ecx
addb %cl, 0x38(%rsi)
movb %bl, 0x39(%rsi)
movq (%rdx), %rdx
decl %ecx
jne 0x7edd
jmp 0x7f18
leaq 0x1871(%rip), %rdi      # 0x975e
xorl %ebp, %ebp
xorl %eax, %eax
callq 0x43cc
jmp 0x7f30
jne 0x7efd
movq (%rdx), %rdx
movb %cl, 0x39(%r15)
movq (%r15), %rsi
movq %rsi, (%rax)
movq %rax, (%r15)
movq (%r14), %rsi
addb 0x38(%rsi), %cl
incb %cl
movb %cl, 0x38(%rax)
movb %bl, 0x39(%rax)
movq (%r14), %rcx
movq %rdx, 0x10(%rcx)
movq %rdx, 0x10(%rax)
orb $0x18, 0x3b(%rcx)
orb $0x18, 0x3b(%rax)
movl $0x1, %ebp
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq