// File: /workspace/github_c_makefile_star2_O0/uobikiemukot[P]yaft/./ctrlseq/osc.h
// Function: parse_color2
int32_t parse_color2(char *seq)
{
	/*
	format
		#rgb
		#rrggbb
		#rrrgggbbb
		#rrrrggggbbbb
	*/
	int i, length;
	uint32_t rgb[3];
	int32_t color;
	char buf[BUFSIZE];

	length = strlen(seq);
	memset(buf, '\0', BUFSIZE);

	if (length == 3) {       /* rgb */
		for (i = 0; i < 3; i++) {
			strncpy(buf, seq + i, 1);
			rgb[i] = bit_mask[8] & hex2num(buf) * 0xFF / 0x0F;
		}
	} else if (length == 6) {  /* rrggbb */
		for (i = 0; i < 3; i++) { /* rrggbb */
			strncpy(buf, seq + i * 2, 2);
			rgb[i] = bit_mask[8] & hex2num(buf);
		}
	} else if (length == 9) {  /* rrrgggbbb */
		for (i = 0; i < 3; i++) {
			strncpy(buf, seq + i * 3, 3);
			rgb[i] = bit_mask[8] & hex2num(buf) * 0xFF / 0xFFF;
		}
	} else if (length == 12) { /* rrrrggggbbbb */
		for (i = 0; i < 3; i++) {
			strncpy(buf, seq + i * 4, 4);
			rgb[i] = bit_mask[8] & hex2num(buf) * 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 $0x440, %rsp            # imm = 0x440
movq %rdi, -0x10(%rbp)
movq -0x10(%rbp), %rdi
callq 0x20d0
movl %eax, -0x18(%rbp)
leaq -0x430(%rbp), %rdi
xorl %esi, %esi
movl $0x400, %edx            # imm = 0x400
callq 0x2120
cmpl $0x3, -0x18(%rbp)
jne 0x71f3
movl $0x0, -0x14(%rbp)
cmpl $0x3, -0x14(%rbp)
jge 0x71ee
leaq -0x430(%rbp), %rdi
movq -0x10(%rbp), %rsi
movslq -0x14(%rbp), %rax
addq %rax, %rsi
movl $0x1, %edx
callq 0x2070
movl 0x428d(%rip), %eax      # 0xb440
movl %eax, -0x434(%rbp)
leaq -0x430(%rbp), %rdi
callq 0x31f0
movl -0x434(%rbp), %ecx
imull $0xff, %eax, %eax
movl $0xf, %esi
cltd
idivl %esi
andl %eax, %ecx
movslq -0x14(%rbp), %rax
movl %ecx, -0x24(%rbp,%rax,4)
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x718b
jmp 0x7359
cmpl $0x6, -0x18(%rbp)
jne 0x725d
movl $0x0, -0x14(%rbp)
cmpl $0x3, -0x14(%rbp)
jge 0x7258
leaq -0x430(%rbp), %rdi
movq -0x10(%rbp), %rsi
movl -0x14(%rbp), %eax
shll %eax
cltq
addq %rax, %rsi
movl $0x2, %edx
callq 0x2070
movl 0x4215(%rip), %eax      # 0xb440
movl %eax, -0x438(%rbp)
leaq -0x430(%rbp), %rdi
callq 0x31f0
movl -0x438(%rbp), %ecx
andl %eax, %ecx
movslq -0x14(%rbp), %rax
movl %ecx, -0x24(%rbp,%rax,4)
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x7200
jmp 0x7357
cmpl $0x9, -0x18(%rbp)
jne 0x72d4
movl $0x0, -0x14(%rbp)
cmpl $0x3, -0x14(%rbp)
jge 0x72cf
leaq -0x430(%rbp), %rdi
movq -0x10(%rbp), %rsi
imull $0x3, -0x14(%rbp), %eax
cltq
addq %rax, %rsi
movl $0x3, %edx
callq 0x2070
movl 0x41ac(%rip), %eax      # 0xb440
movl %eax, -0x43c(%rbp)
leaq -0x430(%rbp), %rdi
callq 0x31f0
movl -0x43c(%rbp), %ecx
imull $0xff, %eax, %eax
movl $0xfff, %esi            # imm = 0xFFF
cltd
idivl %esi
andl %eax, %ecx
movslq -0x14(%rbp), %rax
movl %ecx, -0x24(%rbp,%rax,4)
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x726a
jmp 0x7355
cmpl $0xc, -0x18(%rbp)
jne 0x734a
movl $0x0, -0x14(%rbp)
cmpl $0x3, -0x14(%rbp)
jge 0x7348
leaq -0x430(%rbp), %rdi
movq -0x10(%rbp), %rsi
movl -0x14(%rbp), %eax
shll $0x2, %eax
cltq
addq %rax, %rsi
movl $0x4, %edx
callq 0x2070
movl 0x4133(%rip), %eax      # 0xb440
movl %eax, -0x440(%rbp)
leaq -0x430(%rbp), %rdi
callq 0x31f0
movl -0x440(%rbp), %ecx
imull $0xff, %eax, %eax
movl $0xffff, %esi           # imm = 0xFFFF
cltd
idivl %esi
andl %eax, %ecx
movslq -0x14(%rbp), %rax
movl %ecx, -0x24(%rbp,%rax,4)
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x72e1
jmp 0x7353
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x7386
jmp 0x7355
jmp 0x7357
jmp 0x7359
movl -0x24(%rbp), %eax
shll $0x10, %eax
movl -0x20(%rbp), %ecx
shll $0x8, %ecx
addl %ecx, %eax
addl -0x1c(%rbp), %eax
movl %eax, -0x28(%rbp)
movl -0x28(%rbp), %edx
xorl %edi, %edi
leaq 0x4ea5a(%rip), %rsi     # 0x55dd3
movb $0x0, %al
callq 0x2450
movl -0x28(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x440, %rsp            # imm = 0x440
popq %rbp
retq
nopw %cs:(%rax,%rax)