// File: /workspace/github_c_makefile_star2_O0/odknt[P]st/st.c
// Function: tdefcolor
int32_t
tdefcolor(const int *attr, int *npar, int l)
{
	int32_t idx = -1;
	uint r, g, b;

	switch (attr[*npar + 1]) {
	case 2: /* direct color in RGB space */
		if (*npar + 4 >= l) {
			fprintf(stderr,
				"erresc(38): Incorrect number of parameters (%d)\n",
				*npar);
			break;
		}
		r = attr[*npar + 2];
		g = attr[*npar + 3];
		b = attr[*npar + 4];
		*npar += 4;
		if (!BETWEEN(r, 0, 255) || !BETWEEN(g, 0, 255) || !BETWEEN(b, 0, 255))
			fprintf(stderr, "erresc: bad rgb color (%u,%u,%u)\n",
				r, g, b);
		else
			idx = TRUECOLOR(r, g, b);
		break;
	case 5: /* indexed color */
		if (*npar + 2 >= l) {
			fprintf(stderr,
				"erresc(38): Incorrect number of parameters (%d)\n",
				*npar);
			break;
		}
		*npar += 2;
		if (!BETWEEN(attr[*npar], 0, 255))
			fprintf(stderr, "erresc: bad fgcolor %d\n", attr[*npar]);
		else
			idx = attr[*npar];
		break;
	case 0: /* implemented defined (only foreground) */
	case 1: /* transparent */
	case 3: /* direct color in CMY space */
	case 4: /* direct color in CMYK space */
	default:
		fprintf(stderr,
		        "erresc(38): gfx attr %d unknown\n", attr[*npar]);
		break;
	}

	return idx;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movl $0xffffffff, -0x18(%rbp) # imm = 0xFFFFFFFF
movq -0x8(%rbp), %rax
movq -0x10(%rbp), %rcx
movslq (%rcx), %rcx
movl 0x4(%rax,%rcx,4), %eax
movl %eax, -0x28(%rbp)
subl $0x2, %eax
jb 0xdc30
jmp 0xda77
movl -0x28(%rbp), %eax
subl $0x2, %eax
je 0xdaa3
jmp 0xda81
movl -0x28(%rbp), %eax
addl $-0x3, %eax
subl $0x2, %eax
jb 0xdc30
jmp 0xda92
movl -0x28(%rbp), %eax
subl $0x5, %eax
je 0xdb93
jmp 0xdc32
movq -0x10(%rbp), %rax
movl (%rax), %eax
addl $0x4, %eax
cmpl -0x14(%rbp), %eax
jl 0xdad4
movq 0xb538(%rip), %rax      # 0x18ff0
movq (%rax), %rdi
movq -0x10(%rbp), %rax
movl (%rax), %edx
leaq 0x7227(%rip), %rsi      # 0x14cef
movb $0x0, %al
callq 0x69d0
jmp 0xdc58
movq -0x8(%rbp), %rax
movq -0x10(%rbp), %rcx
movl (%rcx), %ecx
addl $0x2, %ecx
movslq %ecx, %rcx
movl (%rax,%rcx,4), %eax
movl %eax, -0x1c(%rbp)
movq -0x8(%rbp), %rax
movq -0x10(%rbp), %rcx
movl (%rcx), %ecx
addl $0x3, %ecx
movslq %ecx, %rcx
movl (%rax,%rcx,4), %eax
movl %eax, -0x20(%rbp)
movq -0x8(%rbp), %rax
movq -0x10(%rbp), %rcx
movl (%rcx), %ecx
addl $0x4, %ecx
movslq %ecx, %rcx
movl (%rax,%rcx,4), %eax
movl %eax, -0x24(%rbp)
movq -0x10(%rbp), %rax
movl (%rax), %ecx
addl $0x4, %ecx
movl %ecx, (%rax)
xorl %eax, %eax
cmpl -0x1c(%rbp), %eax
ja 0xdb51
cmpl $0xff, -0x1c(%rbp)
ja 0xdb51
xorl %eax, %eax
cmpl -0x20(%rbp), %eax
ja 0xdb51
cmpl $0xff, -0x20(%rbp)
ja 0xdb51
xorl %eax, %eax
cmpl -0x24(%rbp), %eax
ja 0xdb51
cmpl $0xff, -0x24(%rbp)
jbe 0xdb75
movq 0xb498(%rip), %rax      # 0x18ff0
movq (%rax), %rdi
movl -0x1c(%rbp), %edx
movl -0x20(%rbp), %ecx
movl -0x24(%rbp), %r8d
leaq 0x71b4(%rip), %rsi      # 0x14d20
movb $0x0, %al
callq 0x69d0
jmp 0xdb8e
movl -0x1c(%rbp), %eax
shll $0x10, %eax
orl $0x1000000, %eax        # imm = 0x1000000
movl -0x20(%rbp), %ecx
shll $0x8, %ecx
orl %ecx, %eax
orl -0x24(%rbp), %eax
movl %eax, -0x18(%rbp)
jmp 0xdc58
movq -0x10(%rbp), %rax
movl (%rax), %eax
addl $0x2, %eax
cmpl -0x14(%rbp), %eax
jl 0xdbc4
movq 0xb448(%rip), %rax      # 0x18ff0
movq (%rax), %rdi
movq -0x10(%rbp), %rax
movl (%rax), %edx
leaq 0x7137(%rip), %rsi      # 0x14cef
movb $0x0, %al
callq 0x69d0
jmp 0xdc58
movq -0x10(%rbp), %rax
movl (%rax), %ecx
addl $0x2, %ecx
movl %ecx, (%rax)
movq -0x8(%rbp), %rcx
movq -0x10(%rbp), %rax
movslq (%rax), %rdx
xorl %eax, %eax
cmpl (%rcx,%rdx,4), %eax
jg 0xdbf5
movq -0x8(%rbp), %rax
movq -0x10(%rbp), %rcx
movslq (%rcx), %rcx
cmpl $0xff, (%rax,%rcx,4)
jle 0xdc1d
movq 0xb3f4(%rip), %rax      # 0x18ff0
movq (%rax), %rdi
movq -0x8(%rbp), %rax
movq -0x10(%rbp), %rcx
movslq (%rcx), %rcx
movl (%rax,%rcx,4), %edx
leaq 0x712e(%rip), %rsi      # 0x14d42
movb $0x0, %al
callq 0x69d0
jmp 0xdc2e
movq -0x8(%rbp), %rax
movq -0x10(%rbp), %rcx
movslq (%rcx), %rcx
movl (%rax,%rcx,4), %eax
movl %eax, -0x18(%rbp)
jmp 0xdc58
jmp 0xdc32
movq 0xb3b7(%rip), %rax      # 0x18ff0
movq (%rax), %rdi
movq -0x8(%rbp), %rax
movq -0x10(%rbp), %rcx
movslq (%rcx), %rcx
movl (%rax,%rcx,4), %edx
leaq 0x7109(%rip), %rsi      # 0x14d5a
movb $0x0, %al
callq 0x69d0
movl -0x18(%rbp), %eax
addq $0x30, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
nopl (%rax,%rax)