// File: /workspace/github_c_makefile_star2_O3/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movl %esi, %r13d
movl %edi, %ebp
movl 0x10d70(%rip), %eax     # 0x19440
cmpl %esi, %eax
movl %esi, %ecx
movl %eax, 0x24(%rsp)
cmovll %eax, %ecx
movq %rcx, 0x30(%rsp)
movslq 0x10d5d(%rip), %rcx     # 0x19444
cmpl %edi, %ecx
movl %edi, %eax
movq %rcx, 0x18(%rsp)
cmovll %ecx, %eax
movl %eax, 0xc(%rsp)
testl %edi, %edi
jle 0x8acf
testl %r13d, %r13d
jle 0x8acf
xorl %ebx, %ebx
movl %r13d, %r14d
cmpl %r13d, 0x14be8(%rip)    # 0x1d2fc
movq %r14, 0x28(%rsp)
jl 0x8791
xorl %ebx, %ebx
movslq %r13d, %r14
movq %rbx, %r15
movq 0x10d1e(%rip), %rax     # 0x19448
movq (%rax,%rbx,8), %rdi
callq 0x63d0
movq 0x10d16(%rip), %rax     # 0x19450
movq (%rax,%rbx,8), %rdi
callq 0x63d0
incq %rbx
movslq 0x14baf(%rip), %rax     # 0x1d2fc
subq %r14, %rax
cmpq %rax, %r15
jl 0x8720
movq 0x10cec(%rip), %rdi     # 0x19448
movl %ebx, %r12d
shlq $0x3, %r12
leaq (%rdi,%r12), %rsi
movq 0x28(%rsp), %r14
leaq (,%r14,8), %r15
movq %r15, %rdx
callq 0x6630
movq 0x10ccd(%rip), %rdi     # 0x19450
addq %rdi, %r12
movq %r12, %rsi
movq %r15, %rdx
callq 0x6630
movq %r13, 0x10(%rsp)
addl %r13d, %ebx
cmpl 0x10ca1(%rip), %ebx     # 0x19440
jge 0x87ce
movl %ebx, %ebx
movq 0x10c9e(%rip), %rax     # 0x19448
movq (%rax,%rbx,8), %rdi
callq 0x63d0
movq 0x10c96(%rip), %rax     # 0x19450
movq (%rax,%rbx,8), %rdi
callq 0x63d0
incq %rbx
cmpl %ebx, 0x10c74(%rip)     # 0x19440
jg 0x87a3
movq 0x10c73(%rip), %rdi     # 0x19448
leaq (,%r14,8), %r12
movq %r12, %rsi
callq 0x7140
movq %rax, 0x10c5c(%rip)     # 0x19448
movq 0x10c5d(%rip), %rdi     # 0x19450
movq %r12, %rsi
callq 0x7140
movq %rax, 0x10c4e(%rip)     # 0x19450
movq 0x14ad7(%rip), %rdi     # 0x1d2e0
leaq (,%r14,4), %rsi
callq 0x7140
movq %rax, 0x14ac3(%rip)     # 0x1d2e0
movq 0x14b04(%rip), %rdi     # 0x1d328
movl %ebp, %ebx
leaq (,%rbx,4), %rsi
callq 0x7140
movq %rax, 0x14aee(%rip)     # 0x1d328
movq %rbx, %r12
shlq $0x4, %r12
movq 0x18(%rsp), %rax
cmpq %rbx, %rax
movq %rbx, 0x38(%rsp)
cmovlq %rax, %rbx
shlq $0x4, %rbx
movl %ebp, %r15d
subl 0xc(%rsp), %r15d
xorl %r14d, %r14d
leaq 0x10bd8(%rip), %r13     # 0x19440
movq 0x18(%r13,%r14,8), %rdi
movq %r12, %rsi
callq 0x7140
movq %rax, 0x18(%r13,%r14,8)
cmpl %ebp, 0x18(%rsp)
jge 0x88a5
movl %r15d, %ecx
movq %rbx, %rdx
movups 0x14a5b(%rip), %xmm0    # 0x1d2e8
movups %xmm0, (%rax,%rdx)
movq 0x18(%r13,%r14,8), %rax
movl $0x20, (%rax,%rdx)
addq $0x10, %rdx
decl %ecx
jne 0x8886
incq %r14
cmpq $0x7d0, %r14            # imm = 0x7D0
jne 0x8868
movq 0x30(%rsp), %r13
testl %r13d, %r13d
jle 0x890f
movl %r13d, %ebx
xorl %r14d, %r14d
movq 0x10(%rsp), %r15
movq 0x10b7b(%rip), %rax     # 0x19448
movq (%rax,%r14,8), %rdi
movq %r12, %rsi
callq 0x7140
movq 0x10b68(%rip), %rcx     # 0x19448
movq %rax, (%rcx,%r14,8)
movq 0x10b65(%rip), %rax     # 0x19450
movq (%rax,%r14,8), %rdi
movq %r12, %rsi
callq 0x7140
movq 0x10b52(%rip), %rcx     # 0x19450
movq %rax, (%rcx,%r14,8)
incq %r14
cmpq %r14, %rbx
jne 0x88c6
movl %r13d, %eax
jmp 0x8916
xorl %eax, %eax
movq 0x10(%rsp), %r15
cmpl %r15d, %eax
movq 0x28(%rsp), %r14
jge 0x8950
movl %eax, %ebx
movq %r12, %rdi
callq 0x707c
movq 0x10b17(%rip), %rcx     # 0x19448
movq %rax, (%rcx,%rbx,8)
movq %r12, %rdi
callq 0x707c
movq 0x10b0c(%rip), %rcx     # 0x19450
movq %rax, (%rcx,%rbx,8)
incq %rbx
cmpq %rbx, %r14
jne 0x8922
movslq 0x10aed(%rip), %rbx     # 0x19444
cmpl %ebx, %ebp
jle 0x89c1
movq 0x149c6(%rip), %r14     # 0x1d328
movl %ebp, %eax
subl %ebx, %eax
movslq %eax, %rdx
shlq $0x2, %rdx
leaq (%r14,%rbx,4), %rdi
xorl %esi, %esi
callq 0x60b0
movq 0x149a9(%rip), %rcx     # 0x1d328
leaq (%r14,%rbx,4), %rax
addq $-0x4, %rax
movq %rax, %rdx
cmpq %rcx, %rax
jbe 0x8998
leaq -0x4(%rdx), %rax
cmpl $0x0, (%rdx)
je 0x8987
leaq 0xfc09(%rip), %rax      # 0x185a8
movl (%rax), %esi
leaq (%rdx,%rsi,4), %rdx
movq 0x38(%rsp), %rsi
leaq (%rcx,%rsi,4), %rcx
cmpq %rcx, %rdx
jae 0x89c1
movl $0x1, (%rdx)
movl (%rax), %esi
leaq (%rdx,%rsi,4), %rdx
jmp 0x89ae
testl %r13d, %r13d
setg %bl
cmpl %ebp, 0x18(%rsp)
setl %r14b
movl %ebp, 0x10a6f(%rip)     # 0x19444
movl %r15d, 0x10a64(%rip)    # 0x19440
leal -0x1(%r15), %r12d
movl $0x0, 0x14922(%rip)     # 0x1d30c
movl %r12d, 0x1491f(%rip)    # 0x1d310
movl 0x14901(%rip), %edi     # 0x1d2f8
movl 0x148ff(%rip), %esi     # 0x1d2fc
callq 0x9155
movups 0x148eb(%rip), %xmm0    # 0x1d2f4
movups %xmm0, 0x4c(%rsp)
movups 0x148d3(%rip), %xmm0    # 0x1d2e8
movaps %xmm0, 0x40(%rsp)
andb %bl, %r14b
decl %ebp
decl %r13d
movb $0x1, %r15b
leaq 0x16c34(%rip), %rbx     # 0x1f660
testb %r14b, %r14b
je 0x8a41
movl 0xc(%rsp), %edi
xorl %esi, %esi
movl %ebp, %edx
movl %r13d, %ecx
callq 0x91c0
movl 0x24(%rsp), %eax
cmpl 0x10(%rsp), %eax
jge 0x8a5c
xorl %edi, %edi
movq 0x30(%rsp), %rsi
movl %ebp, %edx
movl %r12d, %ecx
callq 0x91c0
callq 0x932e
movl 0x148ad(%rip), %eax     # 0x1d314
shrl $0x2, %eax
andl $0x1, %eax
leaq (%rax,%rax,8), %rcx
leaq (%rcx,%rcx,2), %rcx
addq %rax, %rcx
movups (%rbx,%rcx), %xmm0
movups 0xc(%rbx,%rcx), %xmm1
movups %xmm0, 0x14860(%rip)    # 0x1d2e8
movups %xmm1, 0x14865(%rip)    # 0x1d2f4
movl 0x10(%rbx,%rcx), %edi
movl 0x14(%rbx,%rcx), %esi
callq 0x9155
testb $0x1, %r15b
movl $0x0, %r15d
jne 0x8a2c
movups 0x4c(%rsp), %xmm0
movups %xmm0, 0x14840(%rip)    # 0x1d2f4
movaps 0x40(%rsp), %xmm0
movups %xmm0, 0x14828(%rip)    # 0x1d2e8
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0xf51a(%rip), %rax      # 0x17ff0
movq (%rax), %rdi
leaq 0x8c33(%rip), %rsi      # 0x11713
movl %ebp, %edx
movl %r13d, %ecx
xorl %eax, %eax
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x69c0