// File: /workspace/github_c_makefile_star2_O3/uobikiemukot[P]yaft/./ctrlseq/osc.h
// Function: parse_color1
int32_t parse_color1(char *seq)
{
	/*
	format
		rgb:r/g/b
		rgb:rr/gg/bb
		rgb:rrr/ggg/bbb
		rgb:rrrr/gggg/bbbb
	*/
	int i, length, value;
	int32_t color;
	uint32_t rgb[3];
	struct parm_t parm;

	reset_parm(&parm);
	parse_arg(seq, &parm, '/', isalnum);

	for (i = 0; i < parm.argc; i++)
		logging(DEBUG, "parm.argv[%d]: %s\n", i, parm.argv[i]);

	if (parm.argc != 3)
		return -1;

	length = strlen(parm.argv[0]);

	for (i = 0; i < 3; i++) {
		value = hex2num(parm.argv[i]);
		logging(DEBUG, "value:%d\n", value);

		if (length == 1)      /* r/g/b/ */
			rgb[i] = bit_mask[8] & (value * 0xFF / 0x0F);
		else if (length == 2) /* rr/gg/bb */
			rgb[i] = bit_mask[8] & value;
		else if (length == 3) /* rrr/ggg/bbb */
			rgb[i] = bit_mask[8] & (value * 0xFF / 0xFFF);
		else if (length == 4) /* rrrr/gggg/bbbb */
			rgb[i] = bit_mask[8] & (value * 0xFF / 0xFFFF);
		else
			return -1;
	}

	color = (rgb[0] << 16) + (rgb[1] << 8) + rgb[2];
	logging(DEBUG, "color:0x%.6X\n", color);

	return color;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x98, %rsp
xorps %xmm0, %xmm0
movups %xmm0, 0x88(%rsp)
movups %xmm0, 0x78(%rsp)
movups %xmm0, 0x68(%rsp)
movups %xmm0, 0x58(%rsp)
movups %xmm0, 0x48(%rsp)
movups %xmm0, 0x38(%rsp)
movups %xmm0, 0x28(%rsp)
movups %xmm0, 0x18(%rsp)
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
testq %rdi, %rdi
je 0x58be
movq %rdi, %r14
callq 0x20d0
testq %rax, %rax
je 0x58be
movq %rax, %r15
xorl %r12d, %r12d
xorl %ebp, %ebp
xorl %r13d, %r13d
xorl %eax, %eax
movb (%r14), %bl
testq %rax, %rax
jne 0x5796
movsbl %bl, %edi
callq 0x2110
testl %eax, %eax
je 0x5794
movq %r14, %rax
jmp 0x5796
xorl %eax, %eax
cmpb $0x2f, %bl
jne 0x57be
movb $0x0, (%r14)
cmpl $0xf, %r13d
jle 0x57a9
xorl %ebx, %ebx
jmp 0x57bc
movslq %r13d, %rcx
movq %rax, 0x18(%rsp,%rcx,8)
incl %r13d
xorl %ebx, %ebx
movl %r13d, %r12d
movl %r13d, %ebp
xorl %eax, %eax
cmpq $0x1, %r15
jne 0x57f4
testq %rax, %rax
je 0x57d3
movl %ebp, %r13d
cmpl $0xf, %ebp
jle 0x57e3
jmp 0x57f4
testb %bl, %bl
jne 0x57ee
movl %r12d, %ebp
movl %r12d, %r13d
cmpl $0xf, %r12d
jg 0x57f4
movslq %ebp, %r12
movq %rax, 0x18(%rsp,%r12,8)
incl %r12d
movl %r12d, %ebp
movl %r12d, %r13d
incq %r14
decq %r15
jne 0x577b
cmpl $0x3, %r12d
jne 0x58b9
movq 0x18(%rsp), %rdi
callq 0x20d0
movq %rax, %r14
xorl %r15d, %r15d
decl %r14d
leaq 0x282c(%rip), %r12      # 0x8050
movq 0x18(%rsp,%r15,8), %rdi
movl $0x0, %eax
testq %rdi, %rdi
je 0x583f
xorl %esi, %esi
movl $0x10, %edx
callq 0x2d12
cmpl $0x3, %r14d
ja 0x58b9
movslq (%r12,%r14,4), %rcx
addq %r12, %rcx
jmpq *%rcx
movl %eax, %ecx
shll $0x4, %ecx
addl %eax, %ecx
movl %ecx, %eax
jmp 0x5892
movl %eax, %ecx
shll $0x8, %ecx
subl %eax, %ecx
movslq %ecx, %rax
imulq $-0x7ff7ff7f, %rax, %rcx # imm = 0x80080081
shrq $0x20, %rcx
addl %ecx, %eax
movl %eax, %ecx
shrl $0x1f, %ecx
sarl $0xb, %eax
addl %ecx, %eax
jmp 0x5892
cltq
imulq $0x7f807f81, %rax, %rax # imm = 0x7F807F81
movq %rax, %rcx
shrq $0x3f, %rcx
sarq $0x27, %rax
addl %ecx, %eax
movzbl %al, %eax
movl %eax, 0x4(%rsp,%r15,4)
incq %r15
cmpq $0x3, %r15
jne 0x5824
movl 0x4(%rsp), %eax
movl 0x8(%rsp), %ebx
shll $0x10, %eax
shll $0x8, %ebx
addl %eax, %ebx
addl 0xc(%rsp), %ebx
jmp 0x58be
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
movl %ebx, %eax
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq