// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0xc0, %rsp
movq %rdi, -0x10(%rbp)
leaq -0xb8(%rbp), %rdi
callq 0x2fa0
movq -0x10(%rbp), %rdi
leaq -0xb8(%rbp), %rsi
movl $0x2f, %edx
movq 0x5200e(%rip), %rcx     # 0x58fd0
callq 0x3060
movl $0x0, -0x14(%rbp)
movl -0x14(%rbp), %eax
cmpl -0xb8(%rbp), %eax
jge 0x7003
movl -0x14(%rbp), %edx
movslq -0x14(%rbp), %rax
movq -0xb0(%rbp,%rax,8), %rcx
xorl %edi, %edi
leaq 0x4edc5(%rip), %rsi     # 0x55db6
movb $0x0, %al
callq 0x2450
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x6fce
cmpl $0x3, -0xb8(%rbp)
je 0x7018
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x7139
movq -0xb0(%rbp), %rdi
callq 0x20d0
movl %eax, -0x18(%rbp)
movl $0x0, -0x14(%rbp)
cmpl $0x3, -0x14(%rbp)
jge 0x710c
movslq -0x14(%rbp), %rax
movq -0xb0(%rbp,%rax,8), %rdi
callq 0x31f0
movl %eax, -0x1c(%rbp)
movl -0x1c(%rbp), %edx
xorl %edi, %edi
leaq 0x4ed71(%rip), %rsi     # 0x55dc9
movb $0x0, %al
callq 0x2450
cmpl $0x1, -0x18(%rbp)
jne 0x7086
movl 0x43d5(%rip), %ecx      # 0xb440
imull $0xff, -0x1c(%rbp), %eax
movl $0xf, %esi
cltd
idivl %esi
andl %eax, %ecx
movslq -0x14(%rbp), %rax
movl %ecx, -0x2c(%rbp,%rax,4)
jmp 0x70fc
cmpl $0x2, -0x18(%rbp)
jne 0x709f
movl 0x43ae(%rip), %ecx      # 0xb440
andl -0x1c(%rbp), %ecx
movslq -0x14(%rbp), %rax
movl %ecx, -0x2c(%rbp,%rax,4)
jmp 0x70fa
cmpl $0x3, -0x18(%rbp)
jne 0x70c6
movl 0x4395(%rip), %ecx      # 0xb440
imull $0xff, -0x1c(%rbp), %eax
movl $0xfff, %esi            # imm = 0xFFF
cltd
idivl %esi
andl %eax, %ecx
movslq -0x14(%rbp), %rax
movl %ecx, -0x2c(%rbp,%rax,4)
jmp 0x70f8
cmpl $0x4, -0x18(%rbp)
jne 0x70ed
movl 0x436e(%rip), %ecx      # 0xb440
imull $0xff, -0x1c(%rbp), %eax
movl $0xffff, %esi           # imm = 0xFFFF
cltd
idivl %esi
andl %eax, %ecx
movslq -0x14(%rbp), %rax
movl %ecx, -0x2c(%rbp,%rax,4)
jmp 0x70f6
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x7139
jmp 0x70f8
jmp 0x70fa
jmp 0x70fc
jmp 0x70fe
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x702e
movl -0x2c(%rbp), %eax
shll $0x10, %eax
movl -0x28(%rbp), %ecx
shll $0x8, %ecx
addl %ecx, %eax
addl -0x24(%rbp), %eax
movl %eax, -0x20(%rbp)
movl -0x20(%rbp), %edx
xorl %edi, %edi
leaq 0x4eca7(%rip), %rsi     # 0x55dd3
movb $0x0, %al
callq 0x2450
movl -0x20(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0xc0, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)