// File: /workspace/github_c_makefile_star2_O0/hughbarney[P]zepl/zepl.c
// Function: display
void display()
{
	char_t *p;
	int i, j, k;
	buffer_t *bp = curbp;
	
	/* find start of screen, handle scroll up off page or top of file  */
	/* point is always within b_page and b_epage */
	if (bp->b_point < bp->b_page)
		bp->b_page = segstart(bp, lnstart(bp,bp->b_point), bp->b_point);

	/* reframe when scrolled off bottom */
	if (bp->b_epage <= bp->b_point) {
		/* Find end of screen plus one. */
		bp->b_page = dndn(bp, bp->b_point);
		/* if we scoll to EOF we show 1 blank line at bottom of screen */
		if (pos(bp, bp->b_ebuf) <= bp->b_page) {
			bp->b_page = pos(bp, bp->b_ebuf);
			i = bp->w_rows - 1;
		} else {
			i = bp->w_rows - 0;
		}
		/* Scan backwards the required number of lines. */
		while (0 < i--)
			bp->b_page = upup(bp, bp->b_page);
	}

	move(bp->w_top, 0); /* start from top of window */
	i = bp->w_top;
	j = 0;
	bp->b_epage = bp->b_page;
	
	/* paint screen from top of page until we hit maxline */ 
	while (1) {
		/* reached point - store the cursor position */
		if (bp->b_point == bp->b_epage) {
			bp->b_row = i;
			bp->b_col = j;
		}
		p = ptr(bp, bp->b_epage);
		if (bp->w_top + bp->w_rows <= i || bp->b_ebuf <= p) /* maxline */
			break;
		if (*p != '\r') {
			if (isprint(*p) || *p == '\t' || *p == '\n') {
				j += *p == '\t' ? 8-(j&7) : 1;
				addch(*p);
			} else {
				const char *ctrl = unctrl(*p);
				j += (int) strlen(ctrl);
				addstr(ctrl);
			}
		}
		if (*p == '\n' || COLS <= j) {
			j -= COLS;
			if (j < 0)
				j = 0;
			++i;
		}
		++bp->b_epage;
	}

	/* replacement for clrtobot() to bottom of window */
	for (k=i; k < bp->w_top + bp->w_rows; k++) {
		move(k, j); /* clear from very last char not start of line */
		clrtoeol();
		j = 0; /* thereafter start of line */
	}

	modeline(bp);
	dispmsg();
	move(bp->b_row, bp->b_col); /* set cursor */
	refresh();
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq 0xc7b9(%rip), %rax      # 0xfb48
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rax
movq -0x20(%rbp), %rcx
cmpq 0x10(%rcx), %rax
jge 0x33dd
movq -0x20(%rbp), %rax
movq %rax, -0x30(%rbp)
movq -0x20(%rbp), %rdi
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rsi
callq 0x2e20
movq -0x30(%rbp), %rdi
movq %rax, %rsi
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rdx
callq 0x2eb0
movq %rax, %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x20(%rbp), %rax
movq 0x18(%rax), %rax
movq -0x20(%rbp), %rcx
cmpq 0x8(%rcx), %rax
jg 0x3497
movq -0x20(%rbp), %rdi
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rsi
callq 0x3130
movq %rax, %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x20(%rbp), %rdi
movq -0x20(%rbp), %rax
movq 0x28(%rax), %rsi
callq 0x2690
movq -0x20(%rbp), %rcx
cmpq 0x10(%rcx), %rax
jg 0x3456
movq -0x20(%rbp), %rdi
movq -0x20(%rbp), %rax
movq 0x28(%rax), %rsi
callq 0x2690
movq %rax, %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x20(%rbp), %rax
movsbl 0x41(%rax), %eax
subl $0x1, %eax
movl %eax, -0xc(%rbp)
jmp 0x3464
movq -0x20(%rbp), %rax
movsbl 0x41(%rax), %eax
subl $0x0, %eax
movl %eax, -0xc(%rbp)
jmp 0x3466
movl -0xc(%rbp), %ecx
movl %ecx, %eax
addl $-0x1, %eax
movl %eax, -0xc(%rbp)
xorl %eax, %eax
cmpl %ecx, %eax
jge 0x3495
movq -0x20(%rbp), %rdi
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rsi
callq 0x3090
movq %rax, %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x10(%rax)
jmp 0x3466
jmp 0x3497
movq 0xbb32(%rip), %rax      # 0xefd0
movq (%rax), %rdi
movq -0x20(%rbp), %rax
movsbl 0x40(%rax), %esi
xorl %edx, %edx
callq 0x22a0
movq -0x20(%rbp), %rax
movsbl 0x40(%rax), %eax
movl %eax, -0xc(%rbp)
movl $0x0, -0x10(%rbp)
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x18(%rax)
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rax
movq -0x20(%rbp), %rcx
cmpq 0x18(%rcx), %rax
jne 0x34f8
movl -0xc(%rbp), %ecx
movq -0x20(%rbp), %rax
movl %ecx, 0x44(%rax)
movl -0x10(%rbp), %ecx
movq -0x20(%rbp), %rax
movl %ecx, 0x48(%rax)
movq -0x20(%rbp), %rdi
movq -0x20(%rbp), %rax
movq 0x18(%rax), %rsi
callq 0x2610
movq %rax, -0x8(%rbp)
movq -0x20(%rbp), %rax
movsbl 0x40(%rax), %eax
movq -0x20(%rbp), %rcx
movsbl 0x41(%rcx), %ecx
addl %ecx, %eax
cmpl -0xc(%rbp), %eax
jle 0x3532
movq -0x20(%rbp), %rax
movq 0x28(%rax), %rax
cmpq -0x8(%rbp), %rax
ja 0x3537
jmp 0x3657
movq -0x8(%rbp), %rax
movzbl (%rax), %eax
cmpl $0xd, %eax
je 0x3601
callq 0x2360
movq (%rax), %rax
movq -0x8(%rbp), %rcx
movzbl (%rcx), %ecx
movslq %ecx, %rcx
movzwl (%rax,%rcx,2), %eax
andl $0x4000, %eax           # imm = 0x4000
cmpl $0x0, %eax
jne 0x357f
movq -0x8(%rbp), %rax
movzbl (%rax), %eax
cmpl $0x9, %eax
je 0x357f
movq -0x8(%rbp), %rax
movzbl (%rax), %eax
cmpl $0xa, %eax
jne 0x35c8
movq -0x8(%rbp), %rax
movzbl (%rax), %eax
cmpl $0x9, %eax
jne 0x359d
movl -0x10(%rbp), %ecx
andl $0x7, %ecx
movl $0x8, %eax
subl %ecx, %eax
movl %eax, -0x34(%rbp)
jmp 0x35a7
movl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x35a7
movl -0x34(%rbp), %eax
addl -0x10(%rbp), %eax
movl %eax, -0x10(%rbp)
movq 0xba19(%rip), %rax      # 0xefd0
movq (%rax), %rdi
movq -0x8(%rbp), %rax
movzbl (%rax), %esi
callq 0x22c0
jmp 0x35ff
movq -0x8(%rbp), %rax
movzbl (%rax), %edi
callq 0x2270
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rdi
callq 0x20f0
addl -0x10(%rbp), %eax
movl %eax, -0x10(%rbp)
movq 0xb9e2(%rip), %rax      # 0xefd0
movq (%rax), %rdi
movq -0x28(%rbp), %rsi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x2330
jmp 0x3601
movq -0x8(%rbp), %rax
movzbl (%rax), %eax
cmpl $0xa, %eax
je 0x361b
movq 0xb9cc(%rip), %rax      # 0xefe0
movl (%rax), %eax
cmpl -0x10(%rbp), %eax
jg 0x3642
movq 0xb9be(%rip), %rax      # 0xefe0
movl (%rax), %ecx
movl -0x10(%rbp), %eax
subl %ecx, %eax
movl %eax, -0x10(%rbp)
cmpl $0x0, -0x10(%rbp)
jge 0x3639
movl $0x0, -0x10(%rbp)
movl -0xc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc(%rbp)
movq -0x20(%rbp), %rax
movq 0x18(%rax), %rcx
addq $0x1, %rcx
movq %rcx, 0x18(%rax)
jmp 0x34d2
movl -0xc(%rbp), %eax
movl %eax, -0x14(%rbp)
movl -0x14(%rbp), %eax
movq -0x20(%rbp), %rcx
movsbl 0x40(%rcx), %ecx
movq -0x20(%rbp), %rdx
movsbl 0x41(%rdx), %edx
addl %edx, %ecx
cmpl %ecx, %eax
jge 0x36ac
movq 0xb953(%rip), %rax      # 0xefd0
movq (%rax), %rdi
movl -0x14(%rbp), %esi
movl -0x10(%rbp), %edx
callq 0x22a0
movq 0xb93e(%rip), %rax      # 0xefd0
movq (%rax), %rdi
callq 0x22b0
movl $0x0, -0x10(%rbp)
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x365d
movq -0x20(%rbp), %rdi
callq 0x3220
callq 0x3320
movq 0xb90f(%rip), %rax      # 0xefd0
movq (%rax), %rdi
movq -0x20(%rbp), %rax
movl 0x44(%rax), %esi
movq -0x20(%rbp), %rax
movl 0x48(%rax), %edx
callq 0x22a0
movq 0xb8f2(%rip), %rax      # 0xefd0
movq (%rax), %rdi
callq 0x2160
addq $0x40, %rsp
popq %rbp
retq
nopl (%rax)