// File: /workspace/github_c_makefile_star2_O0/odknt[P]st/st.c
// Function: tsetmode
void
tsetmode(int priv, int set, const int *args, int narg)
{
	int alt; const int *lim;

	for (lim = args + narg; args < lim; ++args) {
		if (priv) {
			switch (*args) {
			case 1: /* DECCKM -- Cursor key */
				xsetmode(set, MODE_APPCURSOR);
				break;
			case 5: /* DECSCNM -- Reverse video */
				xsetmode(set, MODE_REVERSE);
				break;
			case 6: /* DECOM -- Origin */
				MODBIT(term.c.state, set, CURSOR_ORIGIN);
				tmoveato(0, 0);
				break;
			case 7: /* DECAWM -- Auto wrap */
				MODBIT(term.mode, set, MODE_WRAP);
				break;
			case 0:  /* Error (IGNORED) */
			case 2:  /* DECANM -- ANSI/VT52 (IGNORED) */
			case 3:  /* DECCOLM -- Column  (IGNORED) */
			case 4:  /* DECSCLM -- Scroll (IGNORED) */
			case 8:  /* DECARM -- Auto repeat (IGNORED) */
			case 18: /* DECPFF -- Printer feed (IGNORED) */
			case 19: /* DECPEX -- Printer extent (IGNORED) */
			case 42: /* DECNRCM -- National characters (IGNORED) */
			case 12: /* att610 -- Start blinking cursor (IGNORED) */
				break;
			case 25: /* DECTCEM -- Text Cursor Enable Mode */
				xsetmode(!set, MODE_HIDE);
				break;
			case 9:    /* X10 mouse compatibility mode */
				xsetpointermotion(0);
				xsetmode(0, MODE_MOUSE);
				xsetmode(set, MODE_MOUSEX10);
				break;
			case 1000: /* 1000: report button press */
				xsetpointermotion(0);
				xsetmode(0, MODE_MOUSE);
				xsetmode(set, MODE_MOUSEBTN);
				break;
			case 1002: /* 1002: report motion on button press */
				xsetpointermotion(0);
				xsetmode(0, MODE_MOUSE);
				xsetmode(set, MODE_MOUSEMOTION);
				break;
			case 1003: /* 1003: enable all mouse motions */
				xsetpointermotion(set);
				xsetmode(0, MODE_MOUSE);
				xsetmode(set, MODE_MOUSEMANY);
				break;
			case 1004: /* 1004: send focus events to tty */
				xsetmode(set, MODE_FOCUS);
				break;
			case 1006: /* 1006: extended reporting mode */
				xsetmode(set, MODE_MOUSESGR);
				break;
			case 1034:
				xsetmode(set, MODE_8BIT);
				break;
			case 1049: /* swap screen & set/restore cursor as xterm */
				if (!allowaltscreen)
					break;
				tcursor((set) ? CURSOR_SAVE : CURSOR_LOAD);
				/* FALLTHROUGH */
			case 47: /* swap screen */
			case 1047:
				if (!allowaltscreen)
					break;
				alt = IS_SET(MODE_ALTSCREEN);
				if (alt) {
					tclearregion(0, 0, term.col-1,
							term.row-1);
				}
				if (set ^ alt) /* set is always 1 or 0 */
					tswapscreen();
				if (*args != 1049)
					break;
				/* FALLTHROUGH */
			case 1048:
				tcursor((set) ? CURSOR_SAVE : CURSOR_LOAD);
				break;
			case 2004: /* 2004: bracketed paste mode */
				xsetmode(set, MODE_BRCKTPASTE);
				break;
			/* Not implemented mouse modes. See comments there. */
			case 1001: /* mouse highlight mode; can hang the
				      terminal by design when implemented. */
			case 1005: /* UTF-8 mouse mode; will confuse
				      applications not supporting UTF-8
				      and luit. */
			case 1015: /* urxvt mangled mouse mode; incompatible
				      and can be mistaken for other control
				      codes. */
				break;
			default:
				fprintf(stderr,
					"erresc: unknown private set/reset mode %d\n",
					*args);
				break;
			}
		} else {
			switch (*args) {
			case 0:  /* Error (IGNORED) */
				break;
			case 2:
				xsetmode(set, MODE_KBDLOCK);
				break;
			case 4:  /* IRM -- Insertion-replacement */
				MODBIT(term.mode, set, MODE_INSERT);
				break;
			case 12: /* SRM -- Send/Receive */
				MODBIT(term.mode, !set, MODE_ECHO);
				break;
			case 20: /* LNM -- Linefeed/new line */
				MODBIT(term.mode, set, MODE_CRLF);
				break;
			default:
				fprintf(stderr,
					"erresc: unknown set/reset mode %d\n",
					*args);
				break;
			}
		}
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movl %edi, -0x4(%rbp)
movl %esi, -0x8(%rbp)
movq %rdx, -0x10(%rbp)
movl %ecx, -0x14(%rbp)
movq -0x10(%rbp), %rax
movslq -0x14(%rbp), %rcx
shlq $0x2, %rcx
addq %rcx, %rax
movq %rax, -0x20(%rbp)
movq -0x10(%rbp), %rax
cmpq -0x20(%rbp), %rax
jae 0xd590
cmpl $0x0, -0x4(%rbp)
je 0xd4a6
movq -0x10(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x24(%rbp)
testl %eax, %eax
je 0xd2df
jmp 0xd0d3
movl -0x24(%rbp), %eax
subl $0x1, %eax
je 0xd254
jmp 0xd0e1
movl -0x24(%rbp), %eax
addl $-0x2, %eax
subl $0x3, %eax
jb 0xd2df
jmp 0xd0f2
movl -0x24(%rbp), %eax
subl $0x5, %eax
je 0xd266
jmp 0xd100
movl -0x24(%rbp), %eax
subl $0x6, %eax
je 0xd278
jmp 0xd10e
movl -0x24(%rbp), %eax
subl $0x7, %eax
je 0xd2b4
jmp 0xd11c
movl -0x24(%rbp), %eax
subl $0x8, %eax
je 0xd2df
jmp 0xd12a
movl -0x24(%rbp), %eax
subl $0x9, %eax
je 0xd301
jmp 0xd138
movl -0x24(%rbp), %eax
subl $0xc, %eax
je 0xd2df
jmp 0xd146
movl -0x24(%rbp), %eax
addl $-0x12, %eax
subl $0x2, %eax
jb 0xd2df
jmp 0xd157
movl -0x24(%rbp), %eax
subl $0x19, %eax
je 0xd2e4
jmp 0xd165
movl -0x24(%rbp), %eax
subl $0x2a, %eax
je 0xd2df
jmp 0xd173
movl -0x24(%rbp), %eax
subl $0x2f, %eax
je 0xd3f2
jmp 0xd181
movl -0x24(%rbp), %eax
subl $0x3e8, %eax            # imm = 0x3E8
je 0xd326
jmp 0xd191
movl -0x24(%rbp), %eax
subl $0x3e9, %eax            # imm = 0x3E9
je 0xd481
jmp 0xd1a1
movl -0x24(%rbp), %eax
subl $0x3ea, %eax            # imm = 0x3EA
je 0xd34b
jmp 0xd1b1
movl -0x24(%rbp), %eax
subl $0x3eb, %eax            # imm = 0x3EB
je 0xd370
jmp 0xd1c1
movl -0x24(%rbp), %eax
subl $0x3ec, %eax            # imm = 0x3EC
je 0xd396
jmp 0xd1d1
movl -0x24(%rbp), %eax
subl $0x3ed, %eax            # imm = 0x3ED
je 0xd481
jmp 0xd1e1
movl -0x24(%rbp), %eax
subl $0x3ee, %eax            # imm = 0x3EE
je 0xd3a8
jmp 0xd1f1
movl -0x24(%rbp), %eax
subl $0x3f7, %eax            # imm = 0x3F7
je 0xd481
jmp 0xd201
movl -0x24(%rbp), %eax
subl $0x40a, %eax            # imm = 0x40A
je 0xd3ba
jmp 0xd211
movl -0x24(%rbp), %eax
subl $0x417, %eax            # imm = 0x417
je 0xd3f2
jmp 0xd221
movl -0x24(%rbp), %eax
subl $0x418, %eax            # imm = 0x418
je 0xd45b
jmp 0xd231
movl -0x24(%rbp), %eax
subl $0x419, %eax            # imm = 0x419
je 0xd3cc
jmp 0xd241
movl -0x24(%rbp), %eax
subl $0x7d4, %eax            # imm = 0x7D4
je 0xd472
jmp 0xd483
movl -0x8(%rbp), %edi
movl $0x100, %esi            # imm = 0x100
callq 0xf7f0
jmp 0xd4a1
movl -0x8(%rbp), %edi
movl $0x20, %esi
callq 0xf7f0
jmp 0xd4a1
cmpl $0x0, -0x8(%rbp)
je 0xd293
movsbl 0x12e1b(%rip), %eax     # 0x200a0
orl $0x2, %eax
movb %al, 0x12e12(%rip)      # 0x200a0
movsbl %al, %eax
jmp 0xd2a6
movsbl 0x12e06(%rip), %eax     # 0x200a0
andl $-0x3, %eax
movb %al, 0x12dfd(%rip)      # 0x200a0
movsbl %al, %eax
xorl %esi, %esi
movl %esi, %edi
callq 0xccf0
jmp 0xd4a1
cmpl $0x0, -0x8(%rbp)
je 0xd2cb
movl 0x12df4(%rip), %eax     # 0x200b4
orl $0x1, %eax
movl %eax, 0x12deb(%rip)     # 0x200b4
jmp 0xd2da
movl 0x12de3(%rip), %eax     # 0x200b4
andl $-0x2, %eax
movl %eax, 0x12dda(%rip)     # 0x200b4
jmp 0xd4a1
jmp 0xd4a1
cmpl $0x0, -0x8(%rbp)
setne %al
xorb $-0x1, %al
andb $0x1, %al
movzbl %al, %edi
movl $0x80, %esi
callq 0xf7f0
jmp 0xd4a1
xorl %edi, %edi
callq 0xf780
xorl %edi, %edi
movl $0xc018, %esi           # imm = 0xC018
callq 0xf7f0
movl -0x8(%rbp), %edi
movl $0x4000, %esi           # imm = 0x4000
callq 0xf7f0
jmp 0xd4a1
xorl %edi, %edi
callq 0xf780
xorl %edi, %edi
movl $0xc018, %esi           # imm = 0xC018
callq 0xf7f0
movl -0x8(%rbp), %edi
movl $0x8, %esi
callq 0xf7f0
jmp 0xd4a1
xorl %edi, %edi
callq 0xf780
xorl %edi, %edi
movl $0xc018, %esi           # imm = 0xC018
callq 0xf7f0
movl -0x8(%rbp), %edi
movl $0x10, %esi
callq 0xf7f0
jmp 0xd4a1
movl -0x8(%rbp), %edi
callq 0xf780
xorl %edi, %edi
movl $0xc018, %esi           # imm = 0xC018
callq 0xf7f0
movl -0x8(%rbp), %edi
movl $0x8000, %esi           # imm = 0x8000
callq 0xf7f0
jmp 0xd4a1
movl -0x8(%rbp), %edi
movl $0x2000, %esi           # imm = 0x2000
callq 0xf7f0
jmp 0xd4a1
movl -0x8(%rbp), %edi
movl $0x200, %esi            # imm = 0x200
callq 0xf7f0
jmp 0xd4a1
movl -0x8(%rbp), %edi
movl $0x400, %esi            # imm = 0x400
callq 0xf7f0
jmp 0xd4a1
leaq 0xc3c5(%rip), %rax      # 0x19798
cmpl $0x0, (%rax)
jne 0xd3dd
jmp 0xd4a1
movl -0x8(%rbp), %ecx
movl $0x1, %edi
xorl %eax, %eax
cmpl $0x0, %ecx
cmovnel %eax, %edi
callq 0x9af0
leaq 0xc39f(%rip), %rax      # 0x19798
cmpl $0x0, (%rax)
jne 0xd403
jmp 0xd4a1
movl 0x12cab(%rip), %eax     # 0x200b4
andl $0x4, %eax
cmpl $0x0, %eax
setne %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x18(%rbp)
cmpl $0x0, -0x18(%rbp)
je 0xd43b
movl 0xedbe(%rip), %edx      # 0x1c1e4
subl $0x1, %edx
movl 0xedb1(%rip), %ecx      # 0x1c1e0
subl $0x1, %ecx
xorl %esi, %esi
movl %esi, %edi
callq 0x98b0
movl -0x8(%rbp), %eax
xorl -0x18(%rbp), %eax
cmpl $0x0, %eax
je 0xd44b
callq 0x9aa0
movq -0x10(%rbp), %rax
cmpl $0x419, (%rax)          # imm = 0x419
je 0xd459
jmp 0xd4a1
jmp 0xd45b
movl -0x8(%rbp), %ecx
movl $0x1, %edi
xorl %eax, %eax
cmpl $0x0, %ecx
cmovnel %eax, %edi
callq 0x9af0
jmp 0xd4a1
movl -0x8(%rbp), %edi
movl $0x10000, %esi          # imm = 0x10000
callq 0xf7f0
jmp 0xd4a1
jmp 0xd4a1
movq 0xbb66(%rip), %rax      # 0x18ff0
movq (%rax), %rdi
movq -0x10(%rbp), %rax
movl (%rax), %edx
leaq 0x77e1(%rip), %rsi      # 0x14c7b
movb $0x0, %al
callq 0x69d0
jmp 0xd57d
movq -0x10(%rbp), %rax
movl (%rax), %eax
movq %rax, -0x30(%rbp)
subq $0x14, %rax
ja 0xd55d
movq -0x30(%rbp), %rax
leaq 0x711f(%rip), %rcx      # 0x145e4
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
jmp 0xd57b
movl -0x8(%rbp), %edi
movl $0x40, %esi
callq 0xf7f0
jmp 0xd57b
cmpl $0x0, -0x8(%rbp)
je 0xd4fc
movl 0x12bc3(%rip), %eax     # 0x200b4
orl $0x2, %eax
movl %eax, 0x12bba(%rip)     # 0x200b4
jmp 0xd50b
movl 0x12bb2(%rip), %eax     # 0x200b4
andl $-0x3, %eax
movl %eax, 0x12ba9(%rip)     # 0x200b4
jmp 0xd57b
cmpl $0x0, -0x8(%rbp)
jne 0xd524
movl 0x12b9b(%rip), %eax     # 0x200b4
orl $0x10, %eax
movl %eax, 0x12b92(%rip)     # 0x200b4
jmp 0xd533
movl 0x12b8a(%rip), %eax     # 0x200b4
andl $-0x11, %eax
movl %eax, 0x12b81(%rip)     # 0x200b4
jmp 0xd57b
cmpl $0x0, -0x8(%rbp)
je 0xd54c
movl 0x12b73(%rip), %eax     # 0x200b4
orl $0x8, %eax
movl %eax, 0x12b6a(%rip)     # 0x200b4
jmp 0xd55b
movl 0x12b62(%rip), %eax     # 0x200b4
andl $-0x9, %eax
movl %eax, 0x12b59(%rip)     # 0x200b4
jmp 0xd57b
movq 0xba8c(%rip), %rax      # 0x18ff0
movq (%rax), %rdi
movq -0x10(%rbp), %rax
movl (%rax), %edx
leaq 0x7732(%rip), %rsi      # 0x14ca6
movb $0x0, %al
callq 0x69d0
jmp 0xd57d
jmp 0xd57f
movq -0x10(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x10(%rbp)
jmp 0xd0a8
addq $0x30, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)