// File: /workspace/github_c_makefile_star2_O1/odknt[P]st/st.c
// Function: eschandle
int
eschandle(uchar ascii)
{
	switch (ascii) {
	case '[':
		term.esc |= ESC_CSI;
		return 0;
	case '#':
		term.esc |= ESC_TEST;
		return 0;
	case '%':
		term.esc |= ESC_UTF8;
		return 0;
	case 'P': /* DCS -- Device Control String */
	case '_': /* APC -- Application Program Command */
	case '^': /* PM -- Privacy Message */
	case ']': /* OSC -- Operating System Command */
	case 'k': /* old title set compatibility */
		tstrsequence(ascii);
		return 0;
	case 'n': /* LS2 -- Locking shift 2 */
	case 'o': /* LS3 -- Locking shift 3 */
		term.charset = 2 + (ascii - 'n');
		break;
	case '(': /* GZD4 -- set primary charset G0 */
	case ')': /* G1D4 -- set secondary charset G1 */
	case '*': /* G2D4 -- set tertiary charset G2 */
	case '+': /* G3D4 -- set quaternary charset G3 */
		term.icharset = ascii - '(';
		term.esc |= ESC_ALTCHARSET;
		return 0;
	case 'D': /* IND -- Linefeed */
		if (term.c.y == term.bot) {
			tscrollup(term.top, 1, 1);
		} else {
			tmoveto(term.c.x, term.c.y+1);
		}
		break;
	case 'E': /* NEL -- Next line */
		tnewline(1); /* always go to first col */
		break;
	case 'H': /* HTS -- Horizontal tab stop */
		term.tabs[term.c.x] = 1;
		break;
	case 'M': /* RI -- Reverse index */
		if (term.c.y == term.top) {
			tscrolldown(term.top, 1, 1);
		} else {
			tmoveto(term.c.x, term.c.y-1);
		}
		break;
	case 'Z': /* DECID -- Identify Terminal */
		ttywrite(vtiden, strlen(vtiden), 0);
		break;
	case 'c': /* RIS -- Reset to initial state */
		treset();
		resettitle();
		xloadcols();
		break;
	case '=': /* DECPAM -- Application keypad */
		xsetmode(1, MODE_APPKEYPAD);
		break;
	case '>': /* DECPNM -- Normal keypad */
		xsetmode(0, MODE_APPKEYPAD);
		break;
	case '7': /* DECSC -- Save Cursor */
		tcursor(CURSOR_SAVE);
		break;
	case '8': /* DECRC -- Restore Cursor */
		tcursor(CURSOR_LOAD);
		break;
	case '\\': /* ST -- String Terminator */
		if (term.esc & ESC_STR_END)
			strhandle();
		break;
	default:
		fprintf(stderr, "erresc: unknown sequence ESC 0x%02X '%c'\n",
			(uchar) ascii, isprint(ascii)? ascii:'.');
		break;
	}
	return 1;
}

// Assembly:
pushq %rbx
movl %edi, %esi
cmpl $0x4c, %edi
jg 0xa7e2
cmpl $0x36, %esi
jle 0xa808
leal -0x37(%rsi), %eax
cmpl $0xe, %eax
ja 0xa861
leaq 0x5a51(%rip), %rcx      # 0x101f0
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movl 0x11b76(%rip), %eax     # 0x1c324
shrl $0x2, %eax
andl $0x1, %eax
leaq (%rax,%rax,8), %rcx
leaq (%rcx,%rcx,2), %rcx
addq %rax, %rcx
leaq 0x13eaa(%rip), %rax     # 0x1e670
movups 0x11b37(%rip), %xmm0    # 0x1c304
movups %xmm0, 0xc(%rax,%rcx)
movups 0x11b1f(%rip), %xmm0    # 0x1c2f8
movups %xmm0, (%rax,%rcx)
jmp 0xa9d6
leal -0x5a(%rsi), %eax
cmpl $0x15, %eax
ja 0xa822
leaq 0x5a3b(%rip), %rcx      # 0x1022c
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movzbl %sil, %edi
callq 0xaf56
jmp 0xa995
leal -0x28(%rsi), %eax
cmpl $0x4, %eax
jae 0xa835
movl %eax, 0x11b1e(%rip)     # 0x1c334
orb $0x8, 0x11b0b(%rip)     # 0x1c328
jmp 0xa995
cmpl $0x4d, %esi
je 0xa999
cmpl $0x50, %esi
je 0xa7fa
jmp 0xa9df
cmpl $0x23, %esi
je 0xa98e
cmpl $0x25, %esi
jne 0xa9df
orb $0x40, 0x11ada(%rip)    # 0x1c328
jmp 0xa995
addl $-0x6c, %esi
movl %esi, 0x11ad4(%rip)     # 0x1c330
jmp 0xa9d6
cmpl $0x48, %esi
jne 0xa9df
movq 0x11ac7(%rip), %rax     # 0x1c338
movslq 0x11a90(%rip), %rcx     # 0x1c308
movl $0x1, (%rax,%rcx,4)
jmp 0xa9d6
movl $0x1, %ebx
movl $0x1, %edi
movl $0x4, %esi
callq 0xd239
jmp 0xa9db
movl 0x11a81(%rip), %eax     # 0x1c324
shrl $0x2, %eax
andl $0x1, %eax
leaq (%rax,%rax,8), %rcx
leaq (%rcx,%rcx,2), %rcx
addq %rax, %rcx
leaq 0x13db5(%rip), %rax     # 0x1e670
movups (%rax,%rcx), %xmm0
movups 0xc(%rax,%rcx), %xmm1
movups %xmm0, 0x11a2d(%rip)    # 0x1c2f8
movups %xmm1, 0x11a32(%rip)    # 0x1c304
movl 0x10(%rax,%rcx), %edi
movl 0x14(%rax,%rcx), %esi
jmp 0xa9d1
xorl %edi, %edi
movl $0x4, %esi
callq 0xd239
jmp 0xa9d6
movl 0x11a16(%rip), %esi     # 0x1c30c
cmpl 0x11a24(%rip), %esi     # 0x1c320
jne 0xa9bf
movl 0x11a14(%rip), %edi     # 0x1c31c
movl $0x1, %ebx
movl $0x1, %esi
movl $0x1, %edx
callq 0xb2b7
jmp 0xa9db
movl $0x1, %ebx
movl $0x1, %edi
callq 0xa9ea
jmp 0xa9db
movl $0x1, %ebx
testb $0x10, 0x119e7(%rip)    # 0x1c328
je 0xa9db
callq 0xab92
jmp 0xa9db
leaq 0xcc40(%rip), %rax      # 0x17598
movq (%rax), %rbx
movq %rbx, %rdi
callq 0x6410
movq %rbx, %rdi
movq %rax, %rsi
xorl %edx, %edx
callq 0x8045
jmp 0xa9d6
callq 0x8908
xorl %edi, %edi
callq 0xc615
callq 0xbc62
jmp 0xa9d6
orb $0x2, 0x1199c(%rip)     # 0x1c328
jmp 0xa995
orb $0x20, 0x11993(%rip)    # 0x1c328
xorl %ebx, %ebx
jmp 0xa9db
movl 0x1196d(%rip), %esi     # 0x1c30c
movl 0x11977(%rip), %edi     # 0x1c31c
cmpl %edi, %esi
jne 0xa9c9
movl $0x1, %ebx
movl $0x1, %esi
movl $0x1, %edx
callq 0xb3c1
jmp 0xa9db
movl 0x11943(%rip), %edi     # 0x1c308
incl %esi
jmp 0xa9d1
movl 0x11939(%rip), %edi     # 0x1c308
decl %esi
callq 0x8eb5
movl $0x1, %ebx
movl %ebx, %eax
popq %rbx
retq
movzbl %sil, %edi
callq 0x6cda
jmp 0xa9d6