// File: /workspace/github_c_makefile_star2_O0/uobikiemukot[P]yaft/./ctrlseq/dcs.h
// Function: decdld_parse_header
void decdld_parse_header(struct terminal_t *term, char *start_buf)
{
	/*
	DECDLD format
		DCS Pfn; Pcn; Pe; Pcmw; Pss; Pt; Pcmh; Pcss; f Dscs Sxbp1 ; Sxbp2 ; .. .; Sxbpn ST
	parameters
		DCS : ESC (0x1B) 'P' (0x50) (DCS(8bit C1 code) is not supported)
		Pfn : fontset (ignored)
		Pcn : start char (0 means SPACE 0x20)
		Pe  : erase mode
				0: clear selectet charset
				1: clear only redefined glyph
				2: clear all drcs charset
		Pcmw: max cellwidth (force CELL_WEDTH defined in glyph.h)
		Pss : screen size (ignored)
		Pt  : defines the glyph as text or full cell or sixel (force full cell mode)
		      (TODO: implement sixel/text mode)
		Pcmh: max cellheight (force CELL_HEIGHT defined in glyph.h)
		Pcss: character set size (force: 96)
				0: 94 glyphs charset
				1: 96 glyphs charset
		f   : '{' (0x7B)
		Dscs: define character set
				Intermediate char: SPACE (0x20) to '/' (0x2F)
				final char       : '0' (0x30) to '~' (0x7E)
									but allow chars between '@' (0x40) and '~' (0x7E) for DRCSMMv1
									(ref: https://github.com/saitoha/drcsterm/blob/master/README.rst)
		Sxbp: see parse_decdld_sixel()
		ST  : ESC (0x1B) '\' (0x5C) or BEL (0x07)
	*/
	char *cp;
	int start_char, erase_mode, charset;
	struct parm_t parm;

	/* replace final char of DECDLD header by NUL '\0' */
	cp = strchr(start_buf, '{');
	*cp = '\0';

	logging(DEBUG, "decdld_parse_header()\nbuf:%s\n", start_buf);

	/* split header by semicolon ';' */
	reset_parm(&parm);
	parse_arg(start_buf, &parm, ';', isdigit);

	if (parm.argc != 8) /* DECDLD header must have 8 params */
		return;

	/* set params */
	start_char = dec2num(parm.argv[1]);
	erase_mode = dec2num(parm.argv[2]);

	/* parse Dscs */
	cp++; /* skip final char (NUL) of DECDLD header */
	while (SPACE <= *cp && *cp <= '/') /* skip intermediate char */
		cp++;

	if (0x40 <= *cp && *cp <= 0x7E) /* final char of Dscs must be between 0x40 to 0x7E (DRCSMMv1) */
		charset = *cp - 0x40;
	else
		charset = 0;

	logging(DEBUG, "charset(ku):0x%.2X start_char:%d erase_mode:%d\n",
		charset, start_char, erase_mode);

	/* reset previous glyph data */
	if (erase_mode < 0 || erase_mode > 2)
		erase_mode = 0;

	if (erase_mode == 2)      /* reset all drcs charset */
		memset(term->drcs, 0, sizeof(struct glyph_t) * DRCS_CHARS);
	else if (erase_mode == 0) /* reset selected drcs charset */
		memset(term->drcs + GLYPHS_PER_CHARSET * charset, 0, sizeof(struct glyph_t) * DRCS_CHARS);

	//if (term->drcs[charset] == NULL) /* always allocate 96 chars buffer */
		//term->drcs[charset] = ecalloc(GLYPH_PER_CHARSET, sizeof(struct glyph_t));

	decdld_parse_data(cp + 1, start_char, term->drcs + GLYPHS_PER_CHARSET * charset); /* skip final char */
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xc0, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x10(%rbp), %rdi
movl $0x7b, %esi
callq 0x2100
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rax
movb $0x0, (%rax)
movq -0x10(%rbp), %rdx
xorl %edi, %edi
leaq 0x4d35d(%rip), %rsi     # 0x55e76
movb $0x0, %al
callq 0x2450
leaq -0xb0(%rbp), %rdi
callq 0x2fa0
movq -0x10(%rbp), %rdi
leaq -0xb0(%rbp), %rsi
movl $0x3b, %edx
movq 0x50475(%rip), %rcx     # 0x58fb8
callq 0x3060
cmpl $0x8, -0xb0(%rbp)
je 0x8b56
jmp 0x8c97
movq -0xa0(%rbp), %rdi
callq 0x31b0
movl %eax, -0x1c(%rbp)
movq -0x98(%rbp), %rdi
callq 0x31b0
movl %eax, -0x20(%rbp)
movq -0x18(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rax
movsbl (%rax), %edx
xorl %eax, %eax
movl $0x20, %ecx
cmpl %edx, %ecx
movb %al, -0xb1(%rbp)
jg 0x8bab
movq -0x18(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x2f, %eax
setle %al
movb %al, -0xb1(%rbp)
movb -0xb1(%rbp), %al
testb $0x1, %al
jne 0x8bb7
jmp 0x8bc5
movq -0x18(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x18(%rbp)
jmp 0x8b80
movq -0x18(%rbp), %rax
movsbl (%rax), %ecx
movl $0x40, %eax
cmpl %ecx, %eax
jg 0x8bf0
movq -0x18(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x7e, %eax
jg 0x8bf0
movq -0x18(%rbp), %rax
movsbl (%rax), %eax
subl $0x40, %eax
movl %eax, -0x24(%rbp)
jmp 0x8bf7
movl $0x0, -0x24(%rbp)
movl -0x24(%rbp), %edx
movl -0x1c(%rbp), %ecx
movl -0x20(%rbp), %r8d
xorl %edi, %edi
leaq 0x4d28a(%rip), %rsi     # 0x55e94
movb $0x0, %al
callq 0x2450
cmpl $0x0, -0x20(%rbp)
jl 0x8c1d
cmpl $0x2, -0x20(%rbp)
jle 0x8c24
movl $0x0, -0x20(%rbp)
cmpl $0x2, -0x20(%rbp)
jne 0x8c43
movq -0x8(%rbp), %rdi
addq $0x80488, %rdi          # imm = 0x80488
xorl %esi, %esi
movl $0x3b100, %edx          # imm = 0x3B100
callq 0x2120
jmp 0x8c6f
cmpl $0x0, -0x20(%rbp)
jne 0x8c6d
movq -0x8(%rbp), %rdi
addq $0x80488, %rdi          # imm = 0x80488
imull $0x60, -0x24(%rbp), %eax
cltq
imulq $0x28, %rax, %rax
addq %rax, %rdi
xorl %esi, %esi
movl $0x3b100, %edx          # imm = 0x3B100
callq 0x2120
jmp 0x8c6f
movq -0x18(%rbp), %rdi
addq $0x1, %rdi
movl -0x1c(%rbp), %esi
movq -0x8(%rbp), %rdx
addq $0x80488, %rdx          # imm = 0x80488
imull $0x60, -0x24(%rbp), %eax
cltq
imulq $0x28, %rax, %rax
addq %rax, %rdx
callq 0x8860
addq $0xc0, %rsp
popq %rbp
retq