// File: /workspace/github_c_makefile_star2_O0/uobikiemukot[P]yaft/./ctrlseq/osc.h
// Function: glyph_width_report
void glyph_width_report(struct terminal_t *term, void *arg)
{
	/*
	glyph width report
		* request *
		OSC 8900 ; Ps ; Pw ; ? : Pf : Pt ST
			Ps: reserved
			Pw: width (0 or 1 or 2)
			Pfrom: beginning of unicode code point
			Pto: end of unicode code point
			ST: BEL(0x07) or ESC(0x1B) BACKSLASH(0x5C)
		* answer *
		OSC 8900 ; Ps ; Pv ; Pw ; Pf : Pt ; Pf : Pt ; ... ST
			Ps: responce code
				0: ok (default)
				1: recognized but not supported
				2: not recognized
			Pv: reserved (maybe East Asian Width Version)
			Pw: width (0 or 1 or 2)
			Pfrom: beginning of unicode code point
			Pto: end of unicode code point
			ST: BEL(0x07) or ESC(0x1B) BACKSLASH(0x5C)
	ref
		http://uobikiemukot.github.io/yaft/glyph_width_report.html
		https://gist.github.com/saitoha/8767268
	*/
	struct parm_t *pt = (struct parm_t *) arg, sub_parm;
	int i, argc = pt->argc, width, from, to, left, right, w, wcw; //reserved
	char **argv = pt->argv, buf[BUFSIZE];

	if (argc < 4)
		return;

	reset_parm(&sub_parm);
	parse_arg(argv[3], &sub_parm, ':', isdigit_or_questionmark);

	if (sub_parm.argc != 3 || *sub_parm.argv[0] != '?')
		return;

	//reserved = dec2num(argv[1]);
	width = dec2num(argv[2]);
	from  = dec2num(sub_parm.argv[1]);
	to    = dec2num(sub_parm.argv[2]);

	if ((width < 0) || (width > 2))
		return;

	/* unicode private area: plane 16 (DRCSMMv1) is always half */
	if ((from < 0) || (to >= UCS2_CHARS))
		return;

	snprintf(buf, BUFSIZE, "\033]8900;0;0;%d;", width); /* OSC 8900 ; Ps; Pv ; Pw ; */
	ewrite(term->fd, buf, strlen(buf));

	left = right = -1;
	for (i = from; i <= to; i++) {
		wcw = wcwidth(i);
		if (wcw <= 0) /* zero width */
			w = 0;
		else if (term->glyph[i] == NULL) /* missing glyph */
			w = wcw;
		else
			w = term->glyph[i]->width;

		if (w != width) {
			if (right != -1) {
				snprintf(buf, BUFSIZE, "%d:%d;", left, right);
				ewrite(term->fd, buf, strlen(buf));
			} else if (left != -1) {
				snprintf(buf, BUFSIZE, "%d:%d;", left, left);
				ewrite(term->fd, buf, strlen(buf));
			}
			left = right = -1;
		} else {
			if (left == -1)
				left = i;
			else
				right = i;
		}
	}

	if (right != -1) {
		snprintf(buf, BUFSIZE, "%d:%d;", left, right);
		ewrite(term->fd, buf, strlen(buf));
	} else if (left != -1) {
		snprintf(buf, BUFSIZE, "%d:%d;", left, left);
		ewrite(term->fd, buf, strlen(buf));
	}

	ewrite(term->fd, "\033\\", 2); /* ST (ESC BACKSLASH) */
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x520, %rsp            # imm = 0x520
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rax
movl (%rax), %eax
movl %eax, -0xa8(%rbp)
movq -0x18(%rbp), %rax
addq $0x8, %rax
movq %rax, -0xd0(%rbp)
cmpl $0x4, -0xa8(%rbp)
jge 0x7704
jmp 0x7adf
leaq -0xa0(%rbp), %rdi
callq 0x2fa0
movq -0xd0(%rbp), %rax
movq 0x18(%rax), %rdi
leaq -0xa0(%rbp), %rsi
movl $0x3a, %edx
leaq -0xbe(%rip), %rcx       # 0x7670
callq 0x3060
cmpl $0x3, -0xa0(%rbp)
jne 0x774b
movq -0x98(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x3f, %eax
je 0x7750
jmp 0x7adf
movq -0xd0(%rbp), %rax
movq 0x10(%rax), %rdi
callq 0x31b0
movl %eax, -0xac(%rbp)
movq -0x90(%rbp), %rdi
callq 0x31b0
movl %eax, -0xb0(%rbp)
movq -0x88(%rbp), %rdi
callq 0x31b0
movl %eax, -0xb4(%rbp)
cmpl $0x0, -0xac(%rbp)
jl 0x779c
cmpl $0x2, -0xac(%rbp)
jle 0x77a1
jmp 0x7adf
cmpl $0x0, -0xb0(%rbp)
jl 0x77b6
cmpl $0x10000, -0xb4(%rbp)   # imm = 0x10000
jl 0x77bb
jmp 0x7adf
leaq -0x4d0(%rbp), %rdi
movl -0xac(%rbp), %ecx
movl $0x400, %esi            # imm = 0x400
leaq 0x4e632(%rip), %rdx     # 0x55e06
movb $0x0, %al
callq 0x2110
movq -0x8(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x4dc(%rbp)
leaq -0x4d0(%rbp), %rax
movq %rax, -0x4d8(%rbp)
leaq -0x4d0(%rbp), %rdi
callq 0x20d0
movl -0x4dc(%rbp), %edi
movq -0x4d8(%rbp), %rsi
movq %rax, %rdx
callq 0x2930
movl $0xffffffff, -0xbc(%rbp) # imm = 0xFFFFFFFF
movl $0xffffffff, -0xb8(%rbp) # imm = 0xFFFFFFFF
movl -0xb0(%rbp), %eax
movl %eax, -0xa4(%rbp)
movl -0xa4(%rbp), %eax
cmpl -0xb4(%rbp), %eax
jg 0x79ee
movl -0xa4(%rbp), %edi
callq 0x21e0
movl %eax, -0xc4(%rbp)
cmpl $0x0, -0xc4(%rbp)
jg 0x786e
movl $0x0, -0xc0(%rbp)
jmp 0x78b1
movq -0x8(%rbp), %rax
movslq -0xa4(%rbp), %rcx
cmpq $0x0, 0x488(%rax,%rcx,8)
jne 0x7892
movl -0xc4(%rbp), %eax
movl %eax, -0xc0(%rbp)
jmp 0x78af
movq -0x8(%rbp), %rax
movslq -0xa4(%rbp), %rcx
movq 0x488(%rax,%rcx,8), %rax
movzbl 0x4(%rax), %eax
movl %eax, -0xc0(%rbp)
jmp 0x78b1
movl -0xc0(%rbp), %eax
cmpl -0xac(%rbp), %eax
je 0x79b3
cmpl $-0x1, -0xbc(%rbp)
je 0x7930
leaq -0x4d0(%rbp), %rdi
movl -0xb8(%rbp), %ecx
movl -0xbc(%rbp), %r8d
movl $0x400, %esi            # imm = 0x400
leaq 0x4e529(%rip), %rdx     # 0x55e15
movb $0x0, %al
callq 0x2110
movq -0x8(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x4ec(%rbp)
leaq -0x4d0(%rbp), %rax
movq %rax, -0x4e8(%rbp)
leaq -0x4d0(%rbp), %rdi
callq 0x20d0
movl -0x4ec(%rbp), %edi
movq -0x4e8(%rbp), %rsi
movq %rax, %rdx
callq 0x2930
jmp 0x799d
cmpl $-0x1, -0xb8(%rbp)
je 0x799b
leaq -0x4d0(%rbp), %rdi
movl -0xb8(%rbp), %ecx
movl -0xb8(%rbp), %r8d
movl $0x400, %esi            # imm = 0x400
leaq 0x4e4bc(%rip), %rdx     # 0x55e15
movb $0x0, %al
callq 0x2110
movq -0x8(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x4fc(%rbp)
leaq -0x4d0(%rbp), %rax
movq %rax, -0x4f8(%rbp)
leaq -0x4d0(%rbp), %rdi
callq 0x20d0
movl -0x4fc(%rbp), %edi
movq -0x4f8(%rbp), %rsi
movq %rax, %rdx
callq 0x2930
jmp 0x799d
movl $0xffffffff, -0xbc(%rbp) # imm = 0xFFFFFFFF
movl $0xffffffff, -0xb8(%rbp) # imm = 0xFFFFFFFF
jmp 0x79d8
cmpl $-0x1, -0xb8(%rbp)
jne 0x79ca
movl -0xa4(%rbp), %eax
movl %eax, -0xb8(%rbp)
jmp 0x79d6
movl -0xa4(%rbp), %eax
movl %eax, -0xbc(%rbp)
jmp 0x79d8
jmp 0x79da
movl -0xa4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xa4(%rbp)
jmp 0x7836
cmpl $-0x1, -0xbc(%rbp)
je 0x7a5b
leaq -0x4d0(%rbp), %rdi
movl -0xb8(%rbp), %ecx
movl -0xbc(%rbp), %r8d
movl $0x400, %esi            # imm = 0x400
leaq 0x4e3fe(%rip), %rdx     # 0x55e15
movb $0x0, %al
callq 0x2110
movq -0x8(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x50c(%rbp)
leaq -0x4d0(%rbp), %rax
movq %rax, -0x508(%rbp)
leaq -0x4d0(%rbp), %rdi
callq 0x20d0
movl -0x50c(%rbp), %edi
movq -0x508(%rbp), %rsi
movq %rax, %rdx
callq 0x2930
jmp 0x7ac8
cmpl $-0x1, -0xb8(%rbp)
je 0x7ac6
leaq -0x4d0(%rbp), %rdi
movl -0xb8(%rbp), %ecx
movl -0xb8(%rbp), %r8d
movl $0x400, %esi            # imm = 0x400
leaq 0x4e391(%rip), %rdx     # 0x55e15
movb $0x0, %al
callq 0x2110
movq -0x8(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x51c(%rbp)
leaq -0x4d0(%rbp), %rax
movq %rax, -0x518(%rbp)
leaq -0x4d0(%rbp), %rdi
callq 0x20d0
movl -0x51c(%rbp), %edi
movq -0x518(%rbp), %rsi
movq %rax, %rdx
callq 0x2930
jmp 0x7ac8
movq -0x8(%rbp), %rax
movl (%rax), %edi
leaq 0x4e32e(%rip), %rsi     # 0x55e03
movl $0x2, %edx
callq 0x2930
addq $0x520, %rsp            # imm = 0x520
popq %rbp
retq
nopl (%rax,%rax)