// File: /workspace/github_c_makefile_star2_O3/odknt[P]st/st.c
// Function: tsetattr
void
tsetattr(const int *attr, int l)
{
	int i;
	int32_t idx;

	for (i = 0; i < l; i++) {
		switch (attr[i]) {
		case 0:
			term.c.attr.mode &= ~(
				ATTR_BOLD       |
				ATTR_FAINT      |
				ATTR_ITALIC     |
				ATTR_UNDERLINE  |
				ATTR_BLINK      |
				ATTR_REVERSE    |
				ATTR_INVISIBLE  |
				ATTR_STRUCK     );
			term.c.attr.fg = defaultfg;
			term.c.attr.bg = defaultbg;
			break;
		case 1:
			term.c.attr.mode |= ATTR_BOLD;
			break;
		case 2:
			term.c.attr.mode |= ATTR_FAINT;
			break;
		case 3:
			term.c.attr.mode |= ATTR_ITALIC;
			break;
		case 4:
			term.c.attr.mode |= ATTR_UNDERLINE;
			break;
		case 5: /* slow blink */
			/* FALLTHROUGH */
		case 6: /* rapid blink */
			term.c.attr.mode |= ATTR_BLINK;
			break;
		case 7:
			term.c.attr.mode |= ATTR_REVERSE;
			break;
		case 8:
			term.c.attr.mode |= ATTR_INVISIBLE;
			break;
		case 9:
			term.c.attr.mode |= ATTR_STRUCK;
			break;
		case 22:
			term.c.attr.mode &= ~(ATTR_BOLD | ATTR_FAINT);
			break;
		case 23:
			term.c.attr.mode &= ~ATTR_ITALIC;
			break;
		case 24:
			term.c.attr.mode &= ~ATTR_UNDERLINE;
			break;
		case 25:
			term.c.attr.mode &= ~ATTR_BLINK;
			break;
		case 27:
			term.c.attr.mode &= ~ATTR_REVERSE;
			break;
		case 28:
			term.c.attr.mode &= ~ATTR_INVISIBLE;
			break;
		case 29:
			term.c.attr.mode &= ~ATTR_STRUCK;
			break;
		case 38:
			if ((idx = tdefcolor(attr, &i, l)) >= 0)
				term.c.attr.fg = idx;
			break;
		case 39:
			term.c.attr.fg = defaultfg;
			break;
		case 48:
			if ((idx = tdefcolor(attr, &i, l)) >= 0)
				term.c.attr.bg = idx;
			break;
		case 49:
			term.c.attr.bg = defaultbg;
			break;
		default:
			if (BETWEEN(attr[i], 30, 37)) {
				term.c.attr.fg = attr[i] - 30;
			} else if (BETWEEN(attr[i], 40, 47)) {
				term.c.attr.bg = attr[i] - 40;
			} else if (BETWEEN(attr[i], 90, 97)) {
				term.c.attr.fg = attr[i] - 90 + 8;
			} else if (BETWEEN(attr[i], 100, 107)) {
				term.c.attr.bg = attr[i] - 100 + 8;
			} else {
				fprintf(stderr,
					"erresc(default): gfx attr %d unknown\n",
					attr[i]);
				csidump();
			}
			break;
		}
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl $0x0, 0x4(%rsp)
testl %edi, %edi
jle 0xc100
movl %edi, %ebx
xorl %eax, %eax
leaq 0x13474(%rip), %r15     # 0x1f400
leaq 0x5429(%rip), %r12      # 0x113bc
leaq 0xc612(%rip), %r13      # 0x185ac
leaq 0xc60f(%rip), %rbp      # 0x185b0
leaq 0x4(%rsp), %r14
cltq
movl 0x20c(%r15,%rax,4), %edi
cmpq $0x31, %rdi
ja 0xbfcb
movslq (%r12,%rdi,4), %rax
addq %r12, %rax
jmpq *%rax
orb $0x10, 0x11326(%rip)    # 0x1d2ec
jmp 0xc0bf
leal -0x1e(%rdi), %eax
cmpl $0x7, %eax
jbe 0xc018
movl %edi, %eax
andl $-0x8, %eax
cmpl $0x28, %eax
jne 0xc0d3
addl $-0x28, %edi
jmp 0xc0f1
movq %r14, %rdi
movl %ebx, %esi
callq 0xc10f
testl %eax, %eax
jns 0xc018
jmp 0xc0bf
andb $-0x5, 0x112e9(%rip)    # 0x1d2ec
jmp 0xc0bf
andb $-0x4, 0x112dd(%rip)    # 0x1d2ec
jmp 0xc0bf
movl (%r13), %eax
movl %eax, 0x112d2(%rip)     # 0x1d2f0
jmp 0xc0bf
orb $0x1, 0x112c2(%rip)     # 0x1d2ec
jmp 0xc0bf
orb $0x8, 0x112b6(%rip)     # 0x1d2ec
jmp 0xc0bf
orb $0x40, 0x112aa(%rip)    # 0x1d2ec
jmp 0xc0bf
movb $0x0, 0x112a1(%rip)     # 0x1d2ec
movl (%r13), %eax
movl %eax, 0x1129b(%rip)     # 0x1d2f0
movl (%rbp), %eax
jmp 0xc0b9
orb $0x20, 0x1128b(%rip)    # 0x1d2ec
jmp 0xc0bf
andb $-0x11, 0x11282(%rip)   # 0x1d2ec
jmp 0xc0bf
andb $-0x21, 0x11279(%rip)   # 0x1d2ec
jmp 0xc0bf
orb $0x2, 0x11270(%rip)     # 0x1d2ec
jmp 0xc0bf
orb $0x4, 0x11267(%rip)     # 0x1d2ec
jmp 0xc0bf
andb $0x7f, 0x1125e(%rip)    # 0x1d2ec
jmp 0xc0bf
orb $-0x80, 0x11255(%rip)   # 0x1d2ec
jmp 0xc0bf
andb $-0x41, 0x1124c(%rip)   # 0x1d2ec
jmp 0xc0bf
andb $-0x9, 0x11243(%rip)    # 0x1d2ec
jmp 0xc0bf
movq %r14, %rdi
movl %ebx, %esi
callq 0xc10f
testl %eax, %eax
js 0xc0bf
movl %eax, 0x11235(%rip)     # 0x1d2f4
movl 0x4(%rsp), %eax
incl %eax
movl %eax, 0x4(%rsp)
cmpl %ebx, %eax
jl 0xbfa6
jmp 0xc100
leal -0x5a(%rdi), %eax
cmpl $0x7, %eax
ja 0xc0e6
addl $-0x52, %edi
movl %edi, 0x1120c(%rip)     # 0x1d2f0
jmp 0xc0bf
leal -0x64(%rdi), %eax
cmpl $0x7, %eax
ja 0xc0f9
addl $-0x5c, %edi
movl %edi, 0x111fd(%rip)     # 0x1d2f4
jmp 0xc0bf
callq 0x6e81
jmp 0xc0bf
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq