// File: /workspace/github_c_makefile_star2_O2/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, %ecx
movl 0x10536(%rip), %eax     # 0x18450
cmpl %esi, %eax
movl %esi, %edx
movl %eax, 0x2c(%rsp)
cmovll %eax, %edx
movq %rdx, 0x20(%rsp)
movslq 0x10523(%rip), %rbp     # 0x18454
cmpl %edi, %ebp
movl %edi, %eax
cmovll %ebp, %eax
movl %eax, 0x14(%rsp)
movl %edi, 0xc(%rsp)
testl %edi, %edi
jle 0x82d3
testl %ecx, %ecx
jle 0x82d3
movl %ecx, %eax
movq %rax, 0x18(%rsp)
xorl %ebx, %ebx
movl %ecx, 0x10(%rsp)
movslq %ecx, %r15
movslq 0x143a5(%rip), %rax     # 0x1c30c
subq %r15, %rax
cmpq %rax, %rbx
jg 0x7f94
movq 0x104e2(%rip), %rax     # 0x18458
movq (%rax,%rbx,8), %rdi
callq 0x63d0
movq 0x104da(%rip), %rax     # 0x18460
movq (%rax,%rbx,8), %rdi
callq 0x63d0
incq %rbx
jmp 0x7f60
movq 0x18(%rsp), %rax
leaq (%rax,%rbx), %r15
testq %rbx, %rbx
je 0x7fd9
movq 0x104af(%rip), %rdi     # 0x18458
movl %ebx, %r12d
shlq $0x3, %r12
leaq (%rdi,%r12), %rsi
leaq (,%rax,8), %r13
movq %r13, %rdx
callq 0x6630
movq 0x10495(%rip), %rdi     # 0x18460
addq %rdi, %r12
movq %r12, %rsi
movq %r13, %rdx
callq 0x6630
movl %r15d, %ebx
movq 0x10475(%rip), %rdi     # 0x18458
cmpl %ebx, 0x10467(%rip)     # 0x18450
jle 0x8009
movq (%rdi,%rbx,8), %rdi
callq 0x63d0
movq 0x10465(%rip), %rax     # 0x18460
movq (%rax,%rbx,8), %rdi
callq 0x63d0
incq %rbx
jmp 0x7fdc
movq 0x18(%rsp), %rbx
leaq (,%rbx,8), %r12
movq %r12, %rsi
callq 0x6c8e
movq %rax, 0x10433(%rip)     # 0x18458
movq 0x10434(%rip), %rdi     # 0x18460
movq %r12, %rsi
callq 0x6c8e
movq %rax, 0x10425(%rip)     # 0x18460
movq 0x142ae(%rip), %rdi     # 0x1c2f0
leaq (,%rbx,4), %rsi
callq 0x6c8e
movq %rax, 0x1429a(%rip)     # 0x1c2f0
movq 0x142db(%rip), %rdi     # 0x1c338
movl 0xc(%rsp), %ebx
movl %ebx, %r13d
leaq (,%r13,4), %rsi
callq 0x6c8e
movq %rax, 0x142c0(%rip)     # 0x1c338
movq %r13, %r12
shlq $0x4, %r12
cmpq %r13, %rbp
movq %r13, 0x30(%rsp)
movq %rbp, 0x38(%rsp)
cmovlq %rbp, %r13
subl 0x14(%rsp), %ebx
shlq $0x4, %r13
xorl %r15d, %r15d
leaq 0x103ae(%rip), %rbp     # 0x18450
cmpq $0x7d0, %r15            # imm = 0x7D0
je 0x80e9
movq 0x18(%rbp,%r15,8), %rdi
movq %r12, %rsi
callq 0x6c8e
movq %rax, 0x18(%rbp,%r15,8)
movq %r13, %rcx
movl %ebx, %edx
subl $0x1, %edx
jb 0x80e4
movups 0x1422a(%rip), %xmm0    # 0x1c2f8
movups %xmm0, (%rax,%rcx)
movq 0x18(%rbp,%r15,8), %rax
movl $0x20, (%rax,%rcx)
addq $0x10, %rcx
jmp 0x80c2
incq %r15
jmp 0x80a2
xorl %ebx, %ebx
movq 0x20(%rsp), %rax
testl %eax, %eax
movl $0x0, %r13d
cmovgl %eax, %r13d
movl 0x10(%rsp), %r14d
movq 0x38(%rsp), %rbp
cmpq %rbx, %r13
je 0x814c
movq 0x10346(%rip), %rax     # 0x18458
movq (%rax,%rbx,8), %rdi
movq %r12, %rsi
callq 0x6c8e
movq 0x10333(%rip), %rcx     # 0x18458
movq %rax, (%rcx,%rbx,8)
movq 0x10330(%rip), %rax     # 0x18460
movq (%rax,%rbx,8), %rdi
movq %r12, %rsi
callq 0x6c8e
movq 0x1031d(%rip), %rcx     # 0x18460
movq %rax, (%rcx,%rbx,8)
incq %rbx
jmp 0x8106
movq 0x18(%rsp), %rbx
cmpq %rbx, %r13
jae 0x8181
movq %r12, %rdi
callq 0x6bcc
movq 0x102f3(%rip), %rcx     # 0x18458
movq %rax, (%rcx,%r13,8)
movq %r12, %rdi
callq 0x6bcc
movq 0x102e8(%rip), %rcx     # 0x18460
movq %rax, (%rcx,%r13,8)
incq %r13
jmp 0x8151
movslq 0x102cc(%rip), %rbx     # 0x18454
cmpl %ebx, 0xc(%rsp)
jle 0x81fb
movq 0x141a3(%rip), %r15     # 0x1c338
movl 0xc(%rsp), %eax
subl %ebx, %eax
movslq %eax, %rdx
shlq $0x2, %rdx
leaq (%r15,%rbx,4), %rdi
xorl %esi, %esi
callq 0x60b0
movq 0x14184(%rip), %rax     # 0x1c338
leaq (%r15,%rbx,4), %rcx
addq $-0x4, %rcx
movq %rcx, %rdx
cmpq %rax, %rcx
jbe 0x81cd
leaq -0x4(%rdx), %rcx
cmpl $0x0, (%rdx)
je 0x81bc
leaq 0xf3e4(%rip), %rcx      # 0x175b8
movl (%rcx), %esi
leaq (%rdx,%rsi,4), %rdx
movq 0x30(%rsp), %rsi
leaq (%rax,%rsi,4), %rax
movl 0x10(%rsp), %r14d
cmpq %rax, %rdx
jae 0x81fb
movl $0x1, (%rdx)
movl (%rcx), %esi
leaq (%rdx,%rsi,4), %rdx
jmp 0x81e8
movl 0xc(%rsp), %r15d
movl %r15d, 0x1024d(%rip)    # 0x18454
movl %r14d, %esi
movl %r14d, 0x1023f(%rip)    # 0x18450
decl %esi
xorl %edi, %edi
movl %esi, %r14d
callq 0x87d8
movl 0x140e5(%rip), %edi     # 0x1c308
movl 0x140e3(%rip), %esi     # 0x1c30c
callq 0x8818
movups 0x140cf(%rip), %xmm0    # 0x1c304
movups %xmm0, 0x4c(%rsp)
movups 0x140b7(%rip), %xmm0    # 0x1c2f8
movaps %xmm0, 0x40(%rsp)
cmpl %r15d, %ebp
setl %al
movq 0x20(%rsp), %rcx
testl %ecx, %ecx
setg %bl
andb %al, %bl
decl %r15d
leal -0x1(%rcx), %r12d
pushq $0x2
popq %rbp
pushq $0x1
popq %r13
subl $0x1, %ebp
jb 0x82ac
testb %bl, %bl
je 0x8280
movl 0x14(%rsp), %edi
xorl %esi, %esi
movl %r15d, %edx
movl %r12d, %ecx
callq 0x8883
movq 0x18(%rsp), %rax
cmpl %eax, 0x2c(%rsp)
jge 0x829d
xorl %edi, %edi
movq 0x20(%rsp), %rsi
movl %r15d, %edx
movl %r14d, %ecx
callq 0x8883
callq 0x89a8
movl %r13d, %edi
callq 0x89c9
jmp 0x8266
movups 0x4c(%rsp), %xmm0
movups %xmm0, 0x1404c(%rip)    # 0x1c304
movaps 0x40(%rsp), %xmm0
movups %xmm0, 0x14034(%rip)    # 0x1c2f8
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0xed16(%rip), %rax      # 0x16ff0
movq (%rax), %rdi
leaq 0x83ff(%rip), %rsi      # 0x106e3
movl 0xc(%rsp), %edx
xorl %eax, %eax
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x69d0