// File: /workspace/github_c_makefile_star2_O1/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 %r12
pushq %rbx
subq $0xa0, %rsp
movl $0x0, 0x18(%rsp)
xorps %xmm0, %xmm0
movups %xmm0, 0x20(%rsp)
movups %xmm0, 0x30(%rsp)
movups %xmm0, 0x40(%rsp)
movups %xmm0, 0x50(%rsp)
movups %xmm0, 0x60(%rsp)
movups %xmm0, 0x70(%rsp)
movups %xmm0, 0x80(%rsp)
movups %xmm0, 0x90(%rsp)
testq %rdi, %rdi
je 0x57ce
movq %rdi, %rbx
callq 0x20d0
testq %rax, %rax
je 0x57ce
movq %rax, %r14
movl 0x18(%rsp), %ebp
xorl %eax, %eax
testq %rax, %rax
jne 0x577b
movsbl (%rbx), %edi
callq 0x2110
testl %eax, %eax
je 0x5779
movq %rbx, %rax
jmp 0x577b
xorl %eax, %eax
cmpb $0x2f, (%rbx)
jne 0x5794
movb $0x0, (%rbx)
cmpl $0xf, %ebp
jg 0x5792
movslq %ebp, %rcx
movq %rax, 0x20(%rsp,%rcx,8)
incl %ebp
xorl %eax, %eax
cmpq $0x1, %r14
jne 0x57ae
testq %rax, %rax
je 0x57b8
cmpl $0xf, %ebp
jg 0x57ae
movslq %ebp, %rcx
movq %rax, 0x20(%rsp,%rcx,8)
incl %ebp
incq %rbx
decq %r14
jne 0x5763
jmp 0x57ca
cmpb $0x0, (%rbx)
setne %cl
cmpl $0x10, %ebp
setge %dl
orb %cl, %dl
je 0x57a4
jmp 0x57ae
movl %ebp, 0x18(%rsp)
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
cmpl $0x3, 0x18(%rsp)
jne 0x588b
movq 0x20(%rsp), %rdi
callq 0x20d0
movq %rax, %r14
xorl %r15d, %r15d
decl %r14d
leaq 0x2828(%rip), %r12      # 0x8020
movq 0x20(%rsp,%r15,8), %rdi
movl $0x0, %eax
testq %rdi, %rdi
je 0x5813
xorl %esi, %esi
movl $0x10, %edx
callq 0x2d03
cmpl $0x3, %r14d
ja 0x588b
movslq (%r12,%r14,4), %rcx
addq %r12, %rcx
jmpq *%rcx
movl %eax, %ecx
shll $0x4, %ecx
addl %eax, %ecx
movl %ecx, %eax
jmp 0x5866
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 0x5866
cltq
imulq $0x7f807f81, %rax, %rax # imm = 0x7F807F81
movq %rax, %rcx
shrq $0x3f, %rcx
sarq $0x27, %rax
addl %ecx, %eax
movzbl %al, %eax
movl %eax, 0xc(%rsp,%r15,4)
incq %r15
cmpq $0x3, %r15
jne 0x57f8
movl 0xc(%rsp), %eax
movl 0x10(%rsp), %ebx
shll $0x10, %eax
shll $0x8, %ebx
addl %eax, %ebx
addl 0x14(%rsp), %ebx
movl %ebx, %eax
addq $0xa0, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq