// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x40, %rsp
movl %edi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
leaq 0x5743(%rip), %rax      # 0x10a58
movq (%rax), %rax
movsbl 0x39(%rax), %eax
cmpl $0x3, %eax
jge 0xb349
leaq 0x5730(%rip), %rax      # 0x10a58
movq (%rax), %rax
movsbl 0x39(%rax), %esi
leaq 0x155e(%rip), %rdi      # 0xc894
movb $0x0, %al
callq 0x56d0
movl $0x0, -0x4(%rbp)
jmp 0xb631
movl $0x40, %edi
callq 0x21c0
movq %rax, -0x20(%rbp)
cmpq $0x0, %rax
jne 0xb377
leaq 0x154e(%rip), %rdi      # 0xc8b2
movb $0x0, %al
callq 0x56d0
movl $0x0, -0x4(%rbp)
jmp 0xb631
leaq 0x56ca(%rip), %rax      # 0x10a48
movq (%rax), %rax
movb 0x31(%rax), %cl
addb $0x1, %cl
movb %cl, 0x31(%rax)
leaq 0x56b7(%rip), %rax      # 0x10a48
movq (%rax), %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x8(%rax)
leaq 0x56b5(%rip), %rax      # 0x10a58
movq (%rax), %rax
movq 0x18(%rax), %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x18(%rax)
leaq 0x569f(%rip), %rax      # 0x10a58
movq (%rax), %rax
movq 0x20(%rax), %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x20(%rax)
leaq 0x5689(%rip), %rax      # 0x10a58
movq (%rax), %rax
movq 0x28(%rax), %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x28(%rax)
leaq 0x5673(%rip), %rax      # 0x10a58
movq (%rax), %rax
movq 0x30(%rax), %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x30(%rax)
movq -0x20(%rbp), %rax
movb $0x0, 0x3b(%rax)
movq -0x20(%rbp), %rax
movb $0x0, 0x3a(%rax)
leaq 0x564d(%rip), %rax      # 0x10a58
movq (%rax), %rax
movsbl 0x39(%rax), %eax
subl $0x1, %eax
movl $0x2, %ecx
cltd
idivl %ecx
movl %eax, -0x34(%rbp)
leaq 0x5631(%rip), %rax      # 0x10a58
movq (%rax), %rax
movsbl 0x39(%rax), %eax
subl $0x1, %eax
subl -0x34(%rbp), %eax
movl %eax, -0x38(%rbp)
leaq 0x561a(%rip), %rax      # 0x10a58
movq (%rax), %rax
movq 0x10(%rax), %rax
movq %rax, -0x18(%rbp)
movl $0x0, -0x3c(%rbp)
movq -0x18(%rbp), %rax
leaq 0x55fd(%rip), %rcx      # 0x10a58
movq (%rcx), %rcx
cmpq 0x18(%rcx), %rax
je 0xb47a
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
movq -0x18(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x18(%rbp)
jmp 0xb450
leaq 0x55d7(%rip), %rax      # 0x10a58
movq (%rax), %rax
movq 0x10(%rax), %rax
movq %rax, -0x18(%rbp)
movl -0x3c(%rbp), %eax
cmpl -0x34(%rbp), %eax
jg 0xb50c
movl -0x3c(%rbp), %eax
cmpl -0x34(%rbp), %eax
jne 0xb4a7
movq -0x18(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x18(%rbp)
movl -0x34(%rbp), %eax
movb %al, %cl
leaq 0x55a5(%rip), %rax      # 0x10a58
movq (%rax), %rax
movb %cl, 0x39(%rax)
leaq 0x5598(%rip), %rax      # 0x10a58
movq (%rax), %rax
movq (%rax), %rcx
movq -0x20(%rbp), %rax
movq %rcx, (%rax)
movq -0x20(%rbp), %rcx
leaq 0x5580(%rip), %rax      # 0x10a58
movq (%rax), %rax
movq %rcx, (%rax)
leaq 0x5573(%rip), %rax      # 0x10a58
movq (%rax), %rax
movsbl 0x38(%rax), %eax
addl -0x34(%rbp), %eax
addl $0x1, %eax
movb %al, %cl
movq -0x20(%rbp), %rax
movb %cl, 0x38(%rax)
movl -0x38(%rbp), %eax
movb %al, %cl
movq -0x20(%rbp), %rax
movb %cl, 0x39(%rax)
jmp 0xb5ea
movq $0x0, -0x28(%rbp)
leaq 0x5555(%rip), %rax      # 0x10a70
movq (%rax), %rax
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
leaq 0x552b(%rip), %rcx      # 0x10a58
cmpq (%rcx), %rax
je 0xb547
movq -0x30(%rbp), %rax
movq %rax, -0x28(%rbp)
movq -0x30(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x30(%rbp)
jmp 0xb522
cmpq $0x0, -0x28(%rbp)
jne 0xb55e
movq -0x20(%rbp), %rcx
leaq 0x5517(%rip), %rax      # 0x10a70
movq %rcx, (%rax)
jmp 0xb569
movq -0x20(%rbp), %rcx
movq -0x28(%rbp), %rax
movq %rcx, (%rax)
leaq 0x54e8(%rip), %rax      # 0x10a58
movq (%rax), %rcx
movq -0x20(%rbp), %rax
movq %rcx, (%rax)
leaq 0x54d7(%rip), %rax      # 0x10a58
movq (%rax), %rax
movb 0x38(%rax), %cl
movq -0x20(%rbp), %rax
movb %cl, 0x38(%rax)
movl -0x34(%rbp), %eax
movb %al, %cl
movq -0x20(%rbp), %rax
movb %cl, 0x39(%rax)
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
movl -0x34(%rbp), %edx
leaq 0x54ab(%rip), %rax      # 0x10a58
movq (%rax), %rax
movsbl 0x38(%rax), %ecx
addl %edx, %ecx
movb %cl, 0x38(%rax)
movl -0x38(%rbp), %eax
movb %al, %cl
leaq 0x5493(%rip), %rax      # 0x10a58
movq (%rax), %rax
movb %cl, 0x39(%rax)
movl -0x34(%rbp), %eax
movl %eax, %ecx
addl $-0x1, %ecx
movl %ecx, -0x34(%rbp)
cmpl $0x0, %eax
je 0xb5e8
movq -0x18(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x18(%rbp)
jmp 0xb5cb
jmp 0xb5ea
movq -0x18(%rbp), %rcx
leaq 0x5463(%rip), %rax      # 0x10a58
movq (%rax), %rax
movq %rcx, 0x10(%rax)
movq -0x18(%rbp), %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x10(%rax)
leaq 0x5449(%rip), %rax      # 0x10a58
movq (%rax), %rax
movsbl 0x3b(%rax), %ecx
orl $0x18, %ecx
movb %cl, 0x3b(%rax)
movq -0x20(%rbp), %rax
movsbl 0x3b(%rax), %ecx
orl $0x18, %ecx
movb %cl, 0x3b(%rax)
movl $0x1, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x40, %rsp
popq %rbp
retq
nopw (%rax,%rax)