// File: /workspace/github_c_makefile_star2_O0/anachronic[P]st/st.c
// Function: tscrollup
void
tscrollup(int top, int bot, int n, int mode)
{
	int i, j, s;
	int alt = IS_SET(MODE_ALTSCREEN);
	int savehist = !alt && top == 0 && mode != SCROLL_NOSAVEHIST;
	Line temp;

	if (n <= 0)
		return;
	n = MIN(n, bot-top+1);

	if (savehist) {
		for (i = 0; i < n; i++) {
			term.histi = (term.histi + 1) % HISTSIZE;
			temp = term.hist[term.histi];
			for (j = 0; j < term.col; j++)
				tclearglyph(&temp[j], 1);
			term.hist[term.histi] = term.line[i];
			term.line[i] = temp;
		}
		term.histf = MIN(term.histf + n, HISTSIZE);
		s = n;
		if (term.scr) {
			j = term.scr;
			term.scr = MIN(j + n, HISTSIZE);
			s = j + n - term.scr;
		}
		if (mode != SCROLL_RESIZE)
			tfulldirt();
	} else {
		tclearregion(0, top, term.col-1, top+n-1, 1);
		tsetdirt(top+n, bot);
	}

	for (i = top; i <= bot-n; i++) {
		temp = term.line[i];
		term.line[i] = term.line[i+n];
		term.line[i+n] = temp;
	}

	if (sel.ob.x != -1 && sel.alt == alt) {
		if (!savehist) {
			selscroll(top, bot, -n);
		} else if (s > 0) {
			selmove(-s);
			if (-term.scr + sel.nb.y < -term.histf)
				selremove();
		}
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movl %edi, -0x4(%rbp)
movl %esi, -0x8(%rbp)
movl %edx, -0xc(%rbp)
movl %ecx, -0x10(%rbp)
movl 0x14ed2(%rip), %eax     # 0x20dbc
andl $0x4, %eax
cmpl $0x0, %eax
setne %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x20(%rbp)
xorl %eax, %eax
cmpl $0x0, -0x20(%rbp)
movb %al, -0x31(%rbp)
jne 0xbf1b
xorl %eax, %eax
cmpl $0x0, -0x4(%rbp)
movb %al, -0x31(%rbp)
jne 0xbf1b
cmpl $0x0, -0x10(%rbp)
setne %al
movb %al, -0x31(%rbp)
movb -0x31(%rbp), %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x24(%rbp)
cmpl $0x0, -0xc(%rbp)
jg 0xbf31
jmp 0xc1ac
movl -0xc(%rbp), %eax
movl -0x8(%rbp), %ecx
subl -0x4(%rbp), %ecx
addl $0x1, %ecx
cmpl %ecx, %eax
jge 0xbf49
movl -0xc(%rbp), %eax
movl %eax, -0x38(%rbp)
jmp 0xbf55
movl -0x8(%rbp), %eax
subl -0x4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x38(%rbp)
movl -0x38(%rbp), %eax
movl %eax, -0xc(%rbp)
cmpl $0x0, -0x24(%rbp)
je 0xc0af
movl $0x0, -0x14(%rbp)
movl -0x14(%rbp), %eax
cmpl -0xc(%rbp), %eax
jge 0xc01f
movl 0x14df2(%rip), %eax     # 0x20d70
addl $0x1, %eax
movl $0x7d0, %ecx            # imm = 0x7D0
cltd
idivl %ecx
movl %edx, 0x14de1(%rip)     # 0x20d70
movslq 0x14dda(%rip), %rcx     # 0x20d70
leaq 0x10f43(%rip), %rax     # 0x1cee0
movq 0x10(%rax,%rcx,8), %rax
movq %rax, -0x30(%rbp)
movl $0x0, -0x18(%rbp)
movl -0x18(%rbp), %eax
cmpl 0x10f2e(%rip), %eax     # 0x1cee4
jge 0xbfdc
movq -0x30(%rbp), %rdi
movslq -0x18(%rbp), %rax
shlq $0x4, %rax
addq %rax, %rdi
movl $0x1, %esi
callq 0x9170
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
jmp 0xbfad
movq 0x10f05(%rip), %rax     # 0x1cee8
movslq -0x14(%rbp), %rcx
movq (%rax,%rcx,8), %rdx
movslq 0x14d7e(%rip), %rcx     # 0x20d70
leaq 0x10ee7(%rip), %rax     # 0x1cee0
movq %rdx, 0x10(%rax,%rcx,8)
movq -0x30(%rbp), %rdx
movq 0x10edf(%rip), %rax     # 0x1cee8
movslq -0x14(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0xbf6c
movl 0x14d4f(%rip), %eax     # 0x20d74
addl -0xc(%rbp), %eax
cmpl $0x7d0, %eax            # imm = 0x7D0
jge 0xc03d
movl 0x14d3f(%rip), %eax     # 0x20d74
addl -0xc(%rbp), %eax
movl %eax, -0x3c(%rbp)
jmp 0xc047
movl $0x7d0, %eax            # imm = 0x7D0
movl %eax, -0x3c(%rbp)
jmp 0xc047
movl -0x3c(%rbp), %eax
movl %eax, 0x14d24(%rip)     # 0x20d74
movl -0xc(%rbp), %eax
movl %eax, -0x1c(%rbp)
cmpl $0x0, 0x14d1b(%rip)     # 0x20d78
je 0xc0a2
movl 0x14d13(%rip), %eax     # 0x20d78
movl %eax, -0x18(%rbp)
movl -0x18(%rbp), %eax
addl -0xc(%rbp), %eax
cmpl $0x7d0, %eax            # imm = 0x7D0
jge 0xc080
movl -0x18(%rbp), %eax
addl -0xc(%rbp), %eax
movl %eax, -0x40(%rbp)
jmp 0xc08a
movl $0x7d0, %eax            # imm = 0x7D0
movl %eax, -0x40(%rbp)
jmp 0xc08a
movl -0x40(%rbp), %eax
movl %eax, 0x14ce5(%rip)     # 0x20d78
movl -0x18(%rbp), %eax
addl -0xc(%rbp), %eax
subl 0x14cd9(%rip), %eax     # 0x20d78
movl %eax, -0x1c(%rbp)
cmpl $-0x1, -0x10(%rbp)
je 0xc0ad
callq 0x7c20
jmp 0xc0df
movl -0x4(%rbp), %esi
movl 0x10e2c(%rip), %edx     # 0x1cee4
subl $0x1, %edx
movl -0x4(%rbp), %ecx
addl -0xc(%rbp), %ecx
subl $0x1, %ecx
xorl %edi, %edi
movl $0x1, %r8d
callq 0xbe10
movl -0x4(%rbp), %edi
addl -0xc(%rbp), %edi
movl -0x8(%rbp), %esi
callq 0x61f0
movl -0x4(%rbp), %eax
movl %eax, -0x14(%rbp)
movl -0x14(%rbp), %eax
movl -0x8(%rbp), %ecx
subl -0xc(%rbp), %ecx
cmpl %ecx, %eax
jg 0xc14b
movq 0x10def(%rip), %rax     # 0x1cee8
movslq -0x14(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x30(%rbp)
movq 0x10ddc(%rip), %rax     # 0x1cee8
movl -0x14(%rbp), %ecx
addl -0xc(%rbp), %ecx
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rdx
movq 0x10dc8(%rip), %rax     # 0x1cee8
movslq -0x14(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
movq -0x30(%rbp), %rdx
movq 0x10db5(%rip), %rax     # 0x1cee8
movl -0x14(%rbp), %ecx
addl -0xc(%rbp), %ecx
movslq %ecx, %rcx
movq %rdx, (%rax,%rcx,8)
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0xc0e5
cmpl $-0x1, 0x10d7a(%rip)    # 0x1cecc
je 0xc1ac
movl 0x10d82(%rip), %eax     # 0x1cedc
cmpl -0x20(%rbp), %eax
jne 0xc1ac
cmpl $0x0, -0x24(%rbp)
jne 0xc177
movl -0x4(%rbp), %edi
movl -0x8(%rbp), %esi
xorl %edx, %edx
subl -0xc(%rbp), %edx
callq 0xcda0
jmp 0xc1aa
cmpl $0x0, -0x1c(%rbp)
jle 0xc1a8
xorl %edi, %edi
subl -0x1c(%rbp), %edi
callq 0x7bd0
xorl %eax, %eax
subl 0x14be9(%rip), %eax     # 0x20d78
addl 0x10d2b(%rip), %eax     # 0x1cec0
xorl %ecx, %ecx
subl 0x14bd7(%rip), %ecx     # 0x20d74
cmpl %ecx, %eax
jge 0xc1a6
callq 0x6820
jmp 0xc1a8
jmp 0xc1aa
jmp 0xc1ac
addq $0x40, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)