// File: /workspace/github_c_makefile_star2_O1/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 0xbaa6
movl %edi, %ebx
xorl %eax, %eax
leaq 0x12ade(%rip), %r15     # 0x1e410
leaq 0x4a53(%rip), %r12      # 0x1038c
leaq 0xbc7c(%rip), %r13      # 0x175bc
leaq 0xbc79(%rip), %rbp      # 0x175c0
leaq 0x4(%rsp), %r14
cltq
movl 0x20c(%r15,%rax,4), %edi
cmpq $0x31, %rdi
ja 0xb971
movslq (%r12,%rdi,4), %rax
addq %r12, %rax
jmpq *%rax
orb $0x10, 0x10990(%rip)    # 0x1c2fc
jmp 0xba65
leal -0x1e(%rdi), %eax
cmpl $0x7, %eax
jbe 0xb9be
movl %edi, %eax
andl $-0x8, %eax
cmpl $0x28, %eax
jne 0xba79
addl $-0x28, %edi
jmp 0xba97
movq %r14, %rdi
movl %ebx, %esi
callq 0xbab5
testl %eax, %eax
jns 0xb9be
jmp 0xba65
andb $-0x5, 0x10953(%rip)    # 0x1c2fc
jmp 0xba65
andb $-0x4, 0x10947(%rip)    # 0x1c2fc
jmp 0xba65
movl (%r13), %eax
movl %eax, 0x1093c(%rip)     # 0x1c300
jmp 0xba65
orb $0x1, 0x1092c(%rip)     # 0x1c2fc
jmp 0xba65
orb $0x8, 0x10920(%rip)     # 0x1c2fc
jmp 0xba65
orb $0x40, 0x10914(%rip)    # 0x1c2fc
jmp 0xba65
movb $0x0, 0x1090b(%rip)     # 0x1c2fc
movl (%r13), %eax
movl %eax, 0x10905(%rip)     # 0x1c300
movl (%rbp), %eax
jmp 0xba5f
orb $0x20, 0x108f5(%rip)    # 0x1c2fc
jmp 0xba65
andb $-0x11, 0x108ec(%rip)   # 0x1c2fc
jmp 0xba65
andb $-0x21, 0x108e3(%rip)   # 0x1c2fc
jmp 0xba65
orb $0x2, 0x108da(%rip)     # 0x1c2fc
jmp 0xba65
orb $0x4, 0x108d1(%rip)     # 0x1c2fc
jmp 0xba65
andb $0x7f, 0x108c8(%rip)    # 0x1c2fc
jmp 0xba65
orb $-0x80, 0x108bf(%rip)   # 0x1c2fc
jmp 0xba65
andb $-0x41, 0x108b6(%rip)   # 0x1c2fc
jmp 0xba65
andb $-0x9, 0x108ad(%rip)    # 0x1c2fc
jmp 0xba65
movq %r14, %rdi
movl %ebx, %esi
callq 0xbab5
testl %eax, %eax
js 0xba65
movl %eax, 0x1089f(%rip)     # 0x1c304
movl 0x4(%rsp), %eax
incl %eax
movl %eax, 0x4(%rsp)
cmpl %ebx, %eax
jl 0xb94c
jmp 0xbaa6
leal -0x5a(%rdi), %eax
cmpl $0x7, %eax
ja 0xba8c
addl $-0x52, %edi
movl %edi, 0x10876(%rip)     # 0x1c300
jmp 0xba65
leal -0x64(%rdi), %eax
cmpl $0x7, %eax
ja 0xba9f
addl $-0x5c, %edi
movl %edi, 0x10867(%rip)     # 0x1c304
jmp 0xba65
callq 0x6ea1
jmp 0xba65
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq