// File: /workspace/github_c_makefile_star2_O0/odknt[P]st/st.c
// Function: tresize
void
tresize(int col, int row)
{
	int i, j;
	int minrow = MIN(row, term.row);
	int mincol = MIN(col, term.col);
	int *bp;
	TCursor c;

	if (col < 1 || row < 1) {
		fprintf(stderr,
		        "tresize: error resizing to %dx%d\n", col, row);
		return;
	}

	/*
	 * slide screen to keep cursor where we expect it -
	 * tscrollup would work here, but we can optimize to
	 * memmove because we're freeing the earlier lines
	 */
	for (i = 0; i <= term.c.y - row; i++) {
		free(term.line[i]);
		free(term.alt[i]);
	}
	/* ensure that both src and dst are not NULL */
	if (i > 0) {
		memmove(term.line, term.line + i, row * sizeof(Line));
		memmove(term.alt, term.alt + i, row * sizeof(Line));
	}
	for (i += row; i < term.row; i++) {
		free(term.line[i]);
		free(term.alt[i]);
	}

	/* resize to new height */
	term.line = xrealloc(term.line, row * sizeof(Line));
	term.alt  = xrealloc(term.alt,  row * sizeof(Line));
	term.dirty = xrealloc(term.dirty, row * sizeof(*term.dirty));
	term.tabs = xrealloc(term.tabs, col * sizeof(*term.tabs));

	for (i = 0; i < HISTSIZE; i++) {
		term.hist[i] = xrealloc(term.hist[i], col * sizeof(Glyph));
		for (j = mincol; j < col; j++) {
			term.hist[i][j] = term.c.attr;
			term.hist[i][j].u = ' ';
		}
	}

	/* resize each r w to new width, zero-pad if needed */
	for (i = 0; i < minrow; i++) {
		term.line[i] = xrealloc(term.line[i], col * sizeof(Glyph));
		term.alt[i]  = xrealloc(term.alt[i],  col * sizeof(Glyph));
	}

	/* allocate any new rows */
	for (/* i = minrow */; i < row; i++) {
		term.line[i] = xmalloc(col * sizeof(Glyph));
		term.alt[i] = xmalloc(col * sizeof(Glyph));
	}
	if (col > term.col) {
		bp = term.tabs + term.col;

		memset(bp, 0, sizeof(*term.tabs) * (col - term.col));
		while (--bp > term.tabs && !*bp)
			/* nothing */ ;
		for (bp += tabspaces; bp < term.tabs + col; bp += tabspaces)
			*bp = 1;
	}
	/* update terminal size */
	term.col = col;
	term.row = row;
	/* reset scrolling region */
	tsetscroll(0, row-1);
	/* make use of the LIMIT in tmoveto */
	tmoveto(term.c.x, term.c.y);
	/* Clearing both screens (it makes dirty all lines) */
	c = term.c;
	for (i = 0; i < 2; i++) {
		if (mincol < col && 0 < minrow) {
			tclearregion(mincol, 0, col - 1, minrow - 1);
		}
		if (0 < col && minrow < row) {
			tclearregion(0, minrow, col - 1, row - 1);
		}
		tswapscreen();
		tcursor(CURSOR_LOAD);
	}
	term.c = c;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movl %edi, -0x4(%rbp)
movl %esi, -0x8(%rbp)
movl -0x8(%rbp), %eax
cmpl 0x13799(%rip), %eax     # 0x1c1e0
jge 0x8a51
movl -0x8(%rbp), %eax
movl %eax, -0x40(%rbp)
jmp 0x8a5a
movl 0x13789(%rip), %eax     # 0x1c1e0
movl %eax, -0x40(%rbp)
movl -0x40(%rbp), %eax
movl %eax, -0x14(%rbp)
movl -0x4(%rbp), %eax
cmpl 0x1377b(%rip), %eax     # 0x1c1e4
jge 0x8a73
movl -0x4(%rbp), %eax
movl %eax, -0x44(%rbp)
jmp 0x8a7c
movl 0x1376b(%rip), %eax     # 0x1c1e4
movl %eax, -0x44(%rbp)
movl -0x44(%rbp), %eax
movl %eax, -0x18(%rbp)
cmpl $0x1, -0x4(%rbp)
jl 0x8a8e
cmpl $0x1, -0x8(%rbp)
jge 0x8ab1
movq 0x1055b(%rip), %rax     # 0x18ff0
movq (%rax), %rdi
movl -0x4(%rbp), %edx
movl -0x8(%rbp), %ecx
leaq 0xbef0(%rip), %rsi      # 0x14995
movb $0x0, %al
callq 0x69d0
jmp 0x8f50
movl $0x0, -0xc(%rbp)
movl -0xc(%rbp), %eax
movl 0x175db(%rip), %ecx     # 0x2009c
subl -0x8(%rbp), %ecx
cmpl %ecx, %eax
jg 0x8afb
movq 0x13719(%rip), %rax     # 0x1c1e8
movslq -0xc(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0x63d0
movq 0x1370d(%rip), %rax     # 0x1c1f0
movslq -0xc(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0x63d0
movl -0xc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc(%rbp)
jmp 0x8ab8
cmpl $0x0, -0xc(%rbp)
jle 0x8b4d
movq 0x136e0(%rip), %rdi     # 0x1c1e8
movq 0x136d9(%rip), %rsi     # 0x1c1e8
movslq -0xc(%rbp), %rax
shlq $0x3, %rax
addq %rax, %rsi
movslq -0x8(%rbp), %rdx
shlq $0x3, %rdx
callq 0x6630
movq 0x136c2(%rip), %rdi     # 0x1c1f0
movq 0x136bb(%rip), %rsi     # 0x1c1f0
movslq -0xc(%rbp), %rax
shlq $0x3, %rax
addq %rax, %rsi
movslq -0x8(%rbp), %rdx
shlq $0x3, %rdx
callq 0x6630
movl -0x8(%rbp), %eax
addl -0xc(%rbp), %eax
movl %eax, -0xc(%rbp)
movl -0xc(%rbp), %eax
cmpl 0x13681(%rip), %eax     # 0x1c1e0
jge 0x8b94
movq 0x13680(%rip), %rax     # 0x1c1e8
movslq -0xc(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0x63d0
movq 0x13674(%rip), %rax     # 0x1c1f0
movslq -0xc(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0x63d0
movl -0xc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc(%rbp)
jmp 0x8b56
movq 0x1364d(%rip), %rdi     # 0x1c1e8
movslq -0x8(%rbp), %rsi
shlq $0x3, %rsi
callq 0x6cd0
movq %rax, 0x13639(%rip)     # 0x1c1e8
movq 0x1363a(%rip), %rdi     # 0x1c1f0
movslq -0x8(%rbp), %rsi
shlq $0x3, %rsi
callq 0x6cd0
movq %rax, 0x13626(%rip)     # 0x1c1f0
movq 0x174af(%rip), %rdi     # 0x20080
movslq -0x8(%rbp), %rsi
shlq $0x2, %rsi
callq 0x6cd0
movq %rax, 0x1749b(%rip)     # 0x20080
movq 0x174dc(%rip), %rdi     # 0x200c8
movslq -0x4(%rbp), %rsi
shlq $0x2, %rsi
callq 0x6cd0
movq %rax, 0x174c8(%rip)     # 0x200c8
movl $0x0, -0xc(%rbp)
cmpl $0x7d0, -0xc(%rbp)      # imm = 0x7D0
jge 0x8cbe
movslq -0xc(%rbp), %rcx
leaq 0x135c1(%rip), %rax     # 0x1c1e0
movq 0x18(%rax,%rcx,8), %rdi
movslq -0x4(%rbp), %rsi
shlq $0x4, %rsi
callq 0x6cd0
movq %rax, %rdx
movslq -0xc(%rbp), %rcx
leaq 0x135a1(%rip), %rax     # 0x1c1e0
movq %rdx, 0x18(%rax,%rcx,8)
movl -0x18(%rbp), %eax
movl %eax, -0x10(%rbp)
movl -0x10(%rbp), %eax
cmpl -0x4(%rbp), %eax
jge 0x8cae
movslq -0xc(%rbp), %rcx
leaq 0x13583(%rip), %rax     # 0x1c1e0
movq 0x18(%rax,%rcx,8), %rax
movslq -0x10(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq 0x17414(%rip), %rcx     # 0x20088
movq %rcx, (%rax)
movq 0x17412(%rip), %rcx     # 0x20090
movq %rcx, 0x8(%rax)
movslq -0xc(%rbp), %rcx
leaq 0x13553(%rip), %rax     # 0x1c1e0
movq 0x18(%rax,%rcx,8), %rax
movslq -0x10(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movl $0x20, (%rax)
movl -0x10(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x10(%rbp)
jmp 0x8c4a
jmp 0x8cb0
movl -0xc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc(%rbp)
jmp 0x8c07
movl $0x0, -0xc(%rbp)
movl -0xc(%rbp), %eax
cmpl -0x14(%rbp), %eax
jge 0x8d34
movq 0x13514(%rip), %rax     # 0x1c1e8
movslq -0xc(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
movslq -0x4(%rbp), %rsi
shlq $0x4, %rsi
callq 0x6cd0
movq %rax, %rdx
movq 0x134f5(%rip), %rax     # 0x1c1e8
movslq -0xc(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
movq 0x134ee(%rip), %rax     # 0x1c1f0
movslq -0xc(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
movslq -0x4(%rbp), %rsi
shlq $0x4, %rsi
callq 0x6cd0
movq %rax, %rdx
movq 0x134cf(%rip), %rax     # 0x1c1f0
movslq -0xc(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
movl -0xc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc(%rbp)
jmp 0x8cc5
jmp 0x8d36
movl -0xc(%rbp), %eax
cmpl -0x8(%rbp), %eax
jge 0x8d87
movslq -0x4(%rbp), %rdi
shlq $0x4, %rdi
callq 0x6bd0
movq %rax, %rdx
movq 0x13493(%rip), %rax     # 0x1c1e8
movslq -0xc(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
movslq -0x4(%rbp), %rdi
shlq $0x4, %rdi
callq 0x6bd0
movq %rax, %rdx
movq 0x1347c(%rip), %rax     # 0x1c1f0
movslq -0xc(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
movl -0xc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc(%rbp)
jmp 0x8d36
movl -0x4(%rbp), %eax
cmpl 0x13454(%rip), %eax     # 0x1c1e4
jle 0x8e5b
movq 0x1732b(%rip), %rax     # 0x200c8
movslq 0x13440(%rip), %rcx     # 0x1c1e4
shlq $0x2, %rcx
addq %rcx, %rax
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rdi
movl -0x4(%rbp), %eax
subl 0x13428(%rip), %eax     # 0x1c1e4
movslq %eax, %rdx
shlq $0x2, %rdx
xorl %esi, %esi
callq 0x60b0
movq -0x20(%rbp), %rcx
addq $-0x4, %rcx
movq %rcx, -0x20(%rbp)
xorl %eax, %eax
cmpq 0x172e9(%rip), %rcx     # 0x200c8
movb %al, -0x45(%rbp)
jbe 0x8df3
movq -0x20(%rbp), %rax
cmpl $0x0, (%rax)
setne %al
xorb $-0x1, %al
movb %al, -0x45(%rbp)
movb -0x45(%rbp), %al
testb $0x1, %al
jne 0x8dfc
jmp 0x8dfe
jmp 0x8dca
leaq 0x109a3(%rip), %rax     # 0x197a8
movl (%rax), %ecx
movq -0x20(%rbp), %rax
movl %ecx, %ecx
shlq $0x2, %rcx
addq %rcx, %rax
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rax
movq 0x172a5(%rip), %rcx     # 0x200c8
movslq -0x4(%rbp), %rdx
shlq $0x2, %rdx
addq %rdx, %rcx
cmpq %rcx, %rax
jae 0x8e59
movq -0x20(%rbp), %rax
movl $0x1, (%rax)
leaq 0x10964(%rip), %rax     # 0x197a8
movl (%rax), %ecx
movq -0x20(%rbp), %rax
movl %ecx, %ecx
shlq $0x2, %rcx
addq %rcx, %rax
movq %rax, -0x20(%rbp)
jmp 0x8e18
jmp 0x8e5b
movl -0x4(%rbp), %eax
movl %eax, 0x13380(%rip)     # 0x1c1e4
movl -0x8(%rbp), %eax
movl %eax, 0x13373(%rip)     # 0x1c1e0
movl -0x8(%rbp), %esi
subl $0x1, %esi
xorl %edi, %edi
callq 0x9720
movl 0x17218(%rip), %edi     # 0x20098
movl 0x17216(%rip), %esi     # 0x2009c
callq 0x97e0
movq 0x171f6(%rip), %rax     # 0x20088
movq %rax, -0x3c(%rbp)
movq 0x171f3(%rip), %rax     # 0x20090
movq %rax, -0x34(%rbp)
movq 0x171f0(%rip), %rax     # 0x20098
movq %rax, -0x2c(%rbp)
movl 0x171ee(%rip), %eax     # 0x200a0
movl %eax, -0x24(%rbp)
movl $0x0, -0xc(%rbp)
cmpl $0x2, -0xc(%rbp)
jge 0x8f26
movl -0x18(%rbp), %eax
cmpl -0x4(%rbp), %eax
jge 0x8ee7
xorl %eax, %eax
cmpl -0x14(%rbp), %eax
jge 0x8ee7
movl -0x18(%rbp), %edi
movl -0x4(%rbp), %edx
subl $0x1, %edx
movl -0x14(%rbp), %ecx
subl $0x1, %ecx
xorl %esi, %esi
callq 0x98b0
xorl %eax, %eax
cmpl -0x4(%rbp), %eax
jge 0x8f0c
movl -0x14(%rbp), %eax
cmpl -0x8(%rbp), %eax
jge 0x8f0c
movl -0x14(%rbp), %esi
movl -0x4(%rbp), %edx
subl $0x1, %edx
movl -0x8(%rbp), %ecx
subl $0x1, %ecx
xorl %edi, %edi
callq 0x98b0
callq 0x9aa0
movl $0x1, %edi
callq 0x9af0
movl -0xc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc(%rbp)
jmp 0x8ebc
movq -0x3c(%rbp), %rax
movq %rax, 0x17157(%rip)     # 0x20088
movq -0x34(%rbp), %rax
movq %rax, 0x17154(%rip)     # 0x20090
movq -0x2c(%rbp), %rax
movq %rax, 0x17151(%rip)     # 0x20098
movl -0x24(%rbp), %eax
movl %eax, 0x17150(%rip)     # 0x200a0
addq $0x50, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)