// File: /workspace/github_c_makefile_star2_O2/uobikiemukot[P]yaft/./ctrlseq/dcs.h
// Function: sixel_parse_data
void sixel_parse_data(struct terminal_t *term, struct sixel_canvas_t *sc, char *start_buf)
{
	/*
	DECDLD sixel data
		'$': carriage return
		'-': new line
		'#': color
			# Pc: select color
			# Pc; Pu; Px; Py; Pz
				Pc : color index (0 to 255)
				Pu : color coordinate system
					1: HLS (0 to 360 for Hue, 0 to 100 for others)
					2: RGB (0 to 100 percent) (default)
				Px : Hue        / Red
				Py : Lightness  / Green
				Pz : Saturation / Blue
		'"': attr
			" Pan; Pad; Ph; Pv
				Pan, Pad: defines aspect ratio (Pan / Pad) (ignored)
				Ph, Pv  : defines vertical/horizontal size of the image
		'!': repeat
			! Pn ch
				Pn : repeat count ([0-9]+)
				ch : character to repeat ('?' to '~')
		sixel bitmap:
			range of ? (hex 3F) to ~ (hex 7E)
			? (hex 3F) represents the binary value 00 0000.
			t (hex 74) represents the binary value 11 0101.
			~ (hex 7E) represents the binary value 11 1111.
	*/
	int size = 0;
	char *cp, *end_buf;
	uint8_t bitmap;

	cp = start_buf;
	end_buf = cp + strlen(start_buf);

	while (cp < end_buf) {
		if (*cp == '!') {
			size = sixel_repeat(term, sc, cp);
		} else if (*cp == '"') {
			size = sixel_attr(sc, cp);
		} else if (*cp == '#') {
			size = sixel_color(sc, cp);
		} else if (*cp == '$') {
			size = sixel_cr(sc);
		} else if (*cp == '-') {
			size = sixel_nl(sc);
		} else if ('?' <= *cp && *cp <= '~')  {
			bitmap =  bit_mask[BITS_PER_SIXEL] & (*cp - '?');
			size = sixel_bitmap(term, sc, bitmap);
		} else if (*cp == '\0') { /* end of sixel data */
			break;
		} else {
			size = 1;
		}
		cp += size;
	}

	logging(DEBUG, "sixel_parse_data()\nwidth:%d height:%d\n", sc->width, sc->height);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x4c8, %rsp            # imm = 0x4C8
movq %rdx, %rbx
movq %rsi, %r14
movq %rdi, %r15
movq %rdx, %rdi
callq 0x20d0
movq %rax, %r13
addq %rbx, %r13
movq %r13, 0x30(%rsp)
movq %r15, 0x28(%rsp)
cmpq %r13, %rbx
jae 0x584b
movb (%rbx), %al
movzbl %al, %ecx
leal -0x21(%rcx), %edx
cmpl $0x3, %edx
ja 0x54b7
leaq 0x1c3c(%rip), %rcx      # 0x7088
movslq (%rcx,%rdx,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq 0x1(%rbx), %r13
callq 0x2330
movq (%rax), %rax
pushq $-0x1
popq %rbp
movsbq 0x1(%r13,%rbp), %rcx
incq %rbp
testb $0x8, 0x1(%rax,%rcx,2)
jne 0x5464
leaq 0xc0(%rsp), %r12
movq %r12, %rdi
movq %r13, %rsi
movq %rbp, %rdx
callq 0x2070
movb $0x0, 0xc0(%rsp,%rbp)
movq %r12, %rdi
callq 0x2dd7
movl %eax, %r12d
movb (%r13,%rbp), %al
leal -0x7f(%rax), %ecx
cmpb $-0x40, %cl
jae 0x567d
addq $0x2, %rbp
jmp 0x583b
cmpl $0x2d, %ecx
jne 0x54e8
movzwl 0xa(%r14), %eax
addl $0x6, %eax
movw %ax, 0xa(%r14)
andw $0x0, 0x8(%r14)
movzwl %ax, %eax
pushq $0x1
popq %rbp
cmpl %eax, 0x10(%r14)
jge 0x5840
movl %eax, 0x10(%r14)
jmp 0x5840
leal -0x7f(%rax), %ecx
cmpb $-0x40, %cl
jae 0x5663
pushq $0x1
popq %rbp
testb %al, %al
jne 0x5840
jmp 0x584b
leaq 0x1(%rbx), %r12
callq 0x2330
movq (%rax), %rax
xorl %ebp, %ebp
movsbq (%r12,%rbp), %rcx
incq %rbp
cmpq $0x3b, %rcx
je 0x5512
movzwl (%rax,%rcx,2), %ecx
andl $0x800, %ecx            # imm = 0x800
jne 0x5512
leaq -0x1(%rbp), %rdx
leaq 0xc0(%rsp), %r15
movq %r15, %rdi
movq %r12, %rsi
callq 0x2070
movb $0x0, 0xbf(%rsp,%rbp)
leaq 0x38(%rsp), %r12
movq %r12, %rdi
callq 0x2cf9
movq %r15, %rdi
movq %r12, %rsi
pushq $0x3b
popq %rdx
movq 0x4fa58(%rip), %rcx     # 0x54fc0
callq 0x2d23
movl 0x38(%rsp), %r12d
testl %r12d, %r12d
movq 0x28(%rsp), %r15
jle 0x583b
movq 0x40(%rsp), %rdi
callq 0x2dd7
movl %eax, %r13d
movl $0xff, %eax
cmpl %eax, %r13d
cmovgel %eax, %r13d
testl %r13d, %r13d
movl $0x0, %eax
cmovlel %eax, %r13d
cmpl $0x5, %r12d
je 0x56ab
cmpl $0x1, %r12d
jne 0x583b
movb %r13b, 0x18(%r14)
jmp 0x583b
andw $0x0, 0x8(%r14)
jmp 0x5675
leaq 0x1(%rbx), %r12
callq 0x2330
movq (%rax), %rax
xorl %ebp, %ebp
movsbq (%r12,%rbp), %rcx
incq %rbp
cmpq $0x3b, %rcx
je 0x55db
movzwl (%rax,%rcx,2), %ecx
andl $0x800, %ecx            # imm = 0x800
jne 0x55db
leaq -0x1(%rbp), %rdx
leaq 0xc0(%rsp), %r15
movq %r15, %rdi
movq %r12, %rsi
callq 0x2070
movb $0x0, 0xbf(%rsp,%rbp)
leaq 0x38(%rsp), %r12
movq %r12, %rdi
callq 0x2cf9
movq %r15, %rdi
movq %r12, %rsi
pushq $0x3b
popq %rdx
movq 0x4f98f(%rip), %rcx     # 0x54fc0
callq 0x2d23
cmpl $0x4, 0x38(%rsp)
jl 0x5659
movq 0x50(%rsp), %rdi
callq 0x2dd7
movl %eax, 0xc(%r14)
movq 0x58(%rsp), %rdi
callq 0x2dd7
movl %eax, 0x10(%r14)
movq 0x28(%rsp), %r15
jmp 0x5840
incb %al
andb $0x3f, %al
movzbl %al, %edx
movq %r15, %rdi
movq %r14, %rsi
callq 0x585d
pushq $0x1
popq %rbp
jmp 0x5840
incb %al
andb $0x3f, %al
testl %r12d, %r12d
movl $0x0, %ecx
cmovlel %ecx, %r12d
movzbl %al, %r13d
subl $0x1, %r12d
jb 0x54ae
movq %r15, %rdi
movq %r14, %rsi
movl %r13d, %edx
callq 0x585d
jmp 0x5691
movq 0x48(%rsp), %rdi
callq 0x2dd7
movl %eax, 0xc(%rsp)
movq 0x50(%rsp), %rdi
callq 0x2dd7
movl %eax, %r12d
movq 0x58(%rsp), %rdi
callq 0x2dd7
movq %rax, 0x10(%rsp)
movq 0x60(%rsp), %rdi
callq 0x2dd7
movl %eax, %ecx
movzwl %r12w, %edi
cmpl $0x1, 0xc(%rsp)
jne 0x5723
movl $0xffff, %eax           # imm = 0xFFFF
movq 0x10(%rsp), %r8
andl %eax, %r8d
andl %eax, %ecx
pushq $0x64
popq %r12
je 0x5779
cmpl $0x32, %r8d
ja 0x578f
addl $0x64, %ecx
imull %r8d, %ecx
addl $0x32, %ecx
movl %ecx, %eax
xorl %edx, %edx
divl %r12d
movl %eax, %esi
jmp 0x57a3
imull $0xff, %edi, %eax
xorl %edx, %edx
pushq $0x64
popq %r8
divl %r8d
movl %eax, %esi
movl $0xffff, %edi           # imm = 0xFFFF
movq 0x10(%rsp), %rax
andl %edi, %eax
imull $0xff, %eax, %eax
xorl %edx, %edx
divl %r8d
movl %eax, %r12d
andl %edi, %ecx
imull $0xff, %ecx, %eax
xorl %edx, %edx
divl %r8d
movl $0xff, %ecx
andl %ecx, %eax
andl %ecx, %esi
shll $0x10, %esi
shll $0x8, %r12d
andl %edi, %r12d
orl %esi, %r12d
orl %eax, %r12d
jmp 0x5833
imull $0xff, %r8d, %eax
xorl %edx, %edx
divl %r12d
movl %eax, %r12d
movl %eax, %ecx
jmp 0x5826
leal (%rcx,%r8), %esi
imull %r8d, %ecx
addl $0x32, %ecx
movl %ecx, %eax
xorl %edx, %edx
divl %r12d
subl %eax, %esi
movl %esi, 0xc(%rsp)
addl %r8d, %r8d
subl %esi, %r8d
leal 0x78(%rdi), %edx
movq %r8, 0x10(%rsp)
movq %rdi, 0x20(%rsp)
movl %r8d, %edi
callq 0x6800
imull $0xff, %eax, %eax
addl $0x32, %eax
xorl %edx, %edx
pushq $0x64
popq %r12
divl %r12d
movl %eax, 0x1c(%rsp)
movq 0x10(%rsp), %rdi
movl 0xc(%rsp), %esi
movq 0x20(%rsp), %rdx
callq 0x6800
imull $0xff, %eax, %eax
addl $0x32, %eax
xorl %edx, %edx
divl %r12d
movl %eax, %r12d
movq 0x20(%rsp), %rdx
addl $-0x78, %edx
movq 0x10(%rsp), %rdi
movl 0xc(%rsp), %esi
callq 0x6800
movl 0x1c(%rsp), %ecx
imull $0xff, %eax, %eax
addl $0x32, %eax
xorl %edx, %edx
pushq $0x64
popq %rsi
divl %esi
shll $0x10, %ecx
shll $0x8, %r12d
addl %eax, %r12d
addl %ecx, %r12d
movl %r13d, %eax
movl %r12d, 0x1c(%r14,%rax,4)
movq 0x30(%rsp), %r13
movslq %ebp, %rax
addq %rax, %rbx
jmp 0x542f
addq $0x4c8, %rsp            # imm = 0x4C8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq