// File: /workspace/github_c_makefile_star2_O3/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 0xacb2
cmpl $0x36, %esi
jle 0xacd8
leal -0x37(%rsi), %eax
cmpl $0xe, %eax
ja 0xad31
leaq 0x65b1(%rip), %rcx      # 0x11220
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movl 0x12696(%rip), %eax     # 0x1d314
shrl $0x2, %eax
andl $0x1, %eax
leaq (%rax,%rax,8), %rcx
leaq (%rcx,%rcx,2), %rcx
addq %rax, %rcx
leaq 0x149ca(%rip), %rax     # 0x1f660
movups 0x12657(%rip), %xmm0    # 0x1d2f4
movups %xmm0, 0xc(%rax,%rcx)
movups 0x1263f(%rip), %xmm0    # 0x1d2e8
movups %xmm0, (%rax,%rcx)
jmp 0xaea6
leal -0x5a(%rsi), %eax
cmpl $0x15, %eax
ja 0xacf2
leaq 0x659b(%rip), %rcx      # 0x1125c
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movzbl %sil, %edi
callq 0xb5e9
jmp 0xae65
leal -0x28(%rsi), %eax
cmpl $0x4, %eax
jae 0xad05
movl %eax, 0x1263e(%rip)     # 0x1d324
orb $0x8, 0x1262b(%rip)     # 0x1d318
jmp 0xae65
cmpl $0x4d, %esi
je 0xae69
cmpl $0x50, %esi
je 0xacca
jmp 0xaeaf
cmpl $0x23, %esi
je 0xae5e
cmpl $0x25, %esi
jne 0xaeaf
orb $0x40, 0x125fa(%rip)    # 0x1d318
jmp 0xae65
addl $-0x6c, %esi
movl %esi, 0x125f4(%rip)     # 0x1d320
jmp 0xaea6
cmpl $0x48, %esi
jne 0xaeaf
movq 0x125e7(%rip), %rax     # 0x1d328
movslq 0x125b0(%rip), %rcx     # 0x1d2f8
movl $0x1, (%rax,%rcx,4)
jmp 0xaea6
movl $0x1, %ebx
movl $0x1, %edi
movl $0x4, %esi
callq 0xd86d
jmp 0xaeab
movl 0x125a1(%rip), %eax     # 0x1d314
shrl $0x2, %eax
andl $0x1, %eax
leaq (%rax,%rax,8), %rcx
leaq (%rcx,%rcx,2), %rcx
addq %rax, %rcx
leaq 0x148d5(%rip), %rax     # 0x1f660
movups (%rax,%rcx), %xmm0
movups 0xc(%rax,%rcx), %xmm1
movups %xmm0, 0x1254d(%rip)    # 0x1d2e8
movups %xmm1, 0x12552(%rip)    # 0x1d2f4
movl 0x10(%rax,%rcx), %edi
movl 0x14(%rax,%rcx), %esi
jmp 0xaea1
xorl %edi, %edi
movl $0x4, %esi
callq 0xd86d
jmp 0xaea6
movl 0x12536(%rip), %esi     # 0x1d2fc
cmpl 0x12544(%rip), %esi     # 0x1d310
jne 0xae8f
movl 0x12534(%rip), %edi     # 0x1d30c
movl $0x1, %ebx
movl $0x1, %esi
movl $0x1, %edx
callq 0xb925
jmp 0xaeab
movl $0x1, %ebx
movl $0x1, %edi
callq 0xaeba
jmp 0xaeab
movl $0x1, %ebx
testb $0x10, 0x12507(%rip)    # 0x1d318
je 0xaeab
callq 0xb06a
jmp 0xaeab
leaq 0xd760(%rip), %rax      # 0x18588
movq (%rax), %rbx
movq %rbx, %rdi
callq 0x6410
movq %rbx, %rdi
movq %rax, %rsi
xorl %edx, %edx
callq 0x8127
jmp 0xaea6
callq 0x8afa
xorl %edi, %edi
callq 0xcc5b
callq 0xc2be
jmp 0xaea6
orb $0x2, 0x124bc(%rip)     # 0x1d318
jmp 0xae65
orb $0x20, 0x124b3(%rip)    # 0x1d318
xorl %ebx, %ebx
jmp 0xaeab
movl 0x1248d(%rip), %esi     # 0x1d2fc
cmpl 0x12497(%rip), %esi     # 0x1d30c
jne 0xae99
movl $0x1, %ebx
movl %esi, %edi
movl $0x1, %esi
movl $0x1, %edx
callq 0xba2f
jmp 0xaeab
movl 0x12463(%rip), %edi     # 0x1d2f8
incl %esi
jmp 0xaea1
movl 0x12459(%rip), %edi     # 0x1d2f8
decl %esi
callq 0x9155
movl $0x1, %ebx
movl %ebx, %eax
popq %rbx
retq
movzbl %sil, %edi
callq 0x6cba
jmp 0xaea6