// File: /workspace/github_c_makefile_star2_O1/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 0xff7a(%rip), %eax      # 0x18450
cmpl %esi, %eax
movl %esi, %ecx
movl %eax, 0x24(%rsp)
cmovll %eax, %ecx
movq %rcx, 0x30(%rsp)
movslq 0xff67(%rip), %rcx      # 0x18454
cmpl %edi, %ecx
movl %edi, %eax
movq %rcx, 0x18(%rsp)
cmovll %ecx, %eax
movl %eax, 0xc(%rsp)
testl %edi, %edi
jle 0x88dd
testl %r13d, %r13d
jle 0x88dd
xorl %ebx, %ebx
cmpl %r13d, 0x13df5(%rip)    # 0x1c30c
jl 0x8553
xorl %ebx, %ebx
movslq %r13d, %r14
movq %rbx, %r15
movq 0xff30(%rip), %rax      # 0x18458
movq (%rax,%rbx,8), %rdi
callq 0x63d0
movq 0xff28(%rip), %rax      # 0x18460
movq (%rax,%rbx,8), %rdi
callq 0x63d0
incq %rbx
movslq 0x13dc1(%rip), %rax     # 0x1c30c
subq %r14, %rax
cmpq %rax, %r15
jl 0x851e
movl %r13d, %r15d
testl %ebx, %ebx
je 0x858b
movq 0xfef7(%rip), %rdi      # 0x18458
movl %ebx, %r14d
leaq (%rdi,%r14,8), %rsi
leaq (,%r15,8), %r12
movq %r12, %rdx
callq 0x6630
movq 0xfee1(%rip), %rdi      # 0x18460
leaq (%rdi,%r14,8), %rsi
movq %r12, %rdx
callq 0x6630
movq %r15, 0x28(%rsp)
movq %r13, 0x10(%rsp)
addl %r13d, %ebx
cmpl 0xfeb2(%rip), %ebx      # 0x18450
jge 0x85cd
movl %ebx, %ebx
movq 0xfeaf(%rip), %rax      # 0x18458
movq (%rax,%rbx,8), %rdi
callq 0x63d0
movq 0xfea7(%rip), %rax      # 0x18460
movq (%rax,%rbx,8), %rdi
callq 0x63d0
incq %rbx
cmpl %ebx, 0xfe85(%rip)      # 0x18450
jg 0x85a2
movq 0xfe84(%rip), %rdi      # 0x18458
movq 0x28(%rsp), %rbx
leaq (,%rbx,8), %r12
movq %r12, %rsi
callq 0x7160
movq %rax, 0xfe68(%rip)      # 0x18458
movq 0xfe69(%rip), %rdi      # 0x18460
movq %r12, %rsi
callq 0x7160
movq %rax, 0xfe5a(%rip)      # 0x18460
movq 0x13ce3(%rip), %rdi     # 0x1c2f0
leaq (,%rbx,4), %rsi
callq 0x7160
movq %rax, 0x13ccf(%rip)     # 0x1c2f0
movq 0x13d10(%rip), %rdi     # 0x1c338
movl %ebp, %ebx
leaq (,%rbx,4), %rsi
callq 0x7160
movq %rax, 0x13cfa(%rip)     # 0x1c338
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 0xfde4(%rip), %r13      # 0x18450
movq 0x18(%r13,%r14,8), %rdi
movq %r12, %rsi
callq 0x7160
movq %rax, 0x18(%r13,%r14,8)
cmpl %ebp, 0x18(%rsp)
jge 0x86ae
movl %r15d, %eax
movq %rbx, %rcx
movq 0x18(%r13,%r14,8), %rdx
movups 0x13c62(%rip), %xmm0    # 0x1c2f8
movups %xmm0, (%rdx,%rcx)
movq 0x18(%r13,%r14,8), %rdx
movl $0x20, (%rdx,%rcx)
addq $0x10, %rcx
decl %eax
jne 0x868a
incq %r14
cmpq $0x7d0, %r14            # imm = 0x7D0
jne 0x866c
movq 0x30(%rsp), %r13
testl %r13d, %r13d
jle 0x8714
movl %r13d, %r14d
xorl %ebx, %ebx
movq 0x10(%rsp), %r15
movq 0xfd83(%rip), %rax      # 0x18458
movq (%rax,%rbx,8), %rdi
movq %r12, %rsi
callq 0x7160
movq 0xfd70(%rip), %rcx      # 0x18458
movq %rax, (%rcx,%rbx,8)
movq 0xfd6d(%rip), %rax      # 0x18460
movq (%rax,%rbx,8), %rdi
movq %r12, %rsi
callq 0x7160
movq 0xfd5a(%rip), %rcx      # 0x18460
movq %rax, (%rcx,%rbx,8)
incq %rbx
cmpq %rbx, %r14
jne 0x86ce
jmp 0x871b
xorl %ebx, %ebx
movq 0x10(%rsp), %r15
cmpl %r15d, %ebx
movq 0x28(%rsp), %r14
jge 0x8755
movl %ebx, %ebx
movq %r12, %rdi
callq 0x709c
movq 0xfd22(%rip), %rcx      # 0x18458
movq %rax, (%rcx,%rbx,8)
movq %r12, %rdi
callq 0x709c
movq 0xfd17(%rip), %rcx      # 0x18460
movq %rax, (%rcx,%rbx,8)
incq %rbx
cmpq %rbx, %r14
jne 0x8727
movslq 0xfcf8(%rip), %rbx      # 0x18454
cmpl %ebx, %ebp
jle 0x87c6
movq 0x13bd1(%rip), %r14     # 0x1c338
movl %ebp, %eax
subl %ebx, %eax
movslq %eax, %rdx
shlq $0x2, %rdx
leaq (%r14,%rbx,4), %rdi
xorl %esi, %esi
callq 0x60b0
movq 0x13bb4(%rip), %rcx     # 0x1c338
leaq (%r14,%rbx,4), %rax
addq $-0x4, %rax
movq %rax, %rdx
cmpq %rcx, %rax
jbe 0x879d
leaq -0x4(%rdx), %rax
cmpl $0x0, (%rdx)
je 0x878c
leaq 0xee14(%rip), %rax      # 0x175b8
movl (%rax), %esi
leaq (%rdx,%rsi,4), %rdx
movq 0x38(%rsp), %rsi
leaq (%rcx,%rsi,4), %rcx
cmpq %rcx, %rdx
jae 0x87c6
movl $0x1, (%rdx)
movl (%rax), %esi
leaq (%rdx,%rsi,4), %rdx
jmp 0x87b3
movl %ebp, 0xfc88(%rip)      # 0x18454
movl %r15d, 0xfc7d(%rip)     # 0x18450
leal -0x1(%r15), %r12d
movl %r12d, %eax
sarl $0x1f, %eax
andl %r12d, %eax
xorl %ecx, %ecx
testl %r12d, %r12d
cmovgl %r12d, %ecx
movl %eax, 0x13b2d(%rip)     # 0x1c31c
movl %ecx, 0x13b2b(%rip)     # 0x1c320
movl 0x13b0d(%rip), %edi     # 0x1c308
movl 0x13b0b(%rip), %esi     # 0x1c30c
callq 0x8eb5
movups 0x13af7(%rip), %xmm0    # 0x1c304
movups %xmm0, 0x4c(%rsp)
movups 0x13adf(%rip), %xmm0    # 0x1c2f8
movaps %xmm0, 0x40(%rsp)
cmpl %ebp, 0x18(%rsp)
setl %al
testl %r13d, %r13d
setg %r14b
andb %al, %r14b
decl %ebp
decl %r13d
movl $0x1, %r15d
leaq 0x15e2f(%rip), %rbx     # 0x1e670
testb %r14b, %r14b
je 0x8856
movl 0xc(%rsp), %edi
xorl %esi, %esi
movl %ebp, %edx
movl %r13d, %ecx
callq 0x8f20
movl 0x24(%rsp), %eax
cmpl 0x10(%rsp), %eax
jge 0x8871
xorl %edi, %edi
movq 0x30(%rsp), %rsi
movl %ebp, %edx
movl %r12d, %ecx
callq 0x8f20
callq 0x908e
movl 0x13aa8(%rip), %eax     # 0x1c324
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, 0x13a5b(%rip)    # 0x1c2f8
movups %xmm1, 0x13a60(%rip)    # 0x1c304
movl 0x10(%rbx,%rcx), %edi
movl 0x14(%rbx,%rcx), %esi
callq 0x8eb5
decl %r15d
je 0x8841
movups 0x4c(%rsp), %xmm0
movups %xmm0, 0x13a42(%rip)    # 0x1c304
movaps 0x40(%rsp), %xmm0
movups %xmm0, 0x13a2a(%rip)    # 0x1c2f8
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0xe70c(%rip), %rax      # 0x16ff0
movq (%rax), %rdi
leaq 0x7df7(%rip), %rsi      # 0x106e5
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 0x69e0