LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_c_makefile_star2_O2/uobikiemukot[P]yaft/./util.h
// Function: eexecl
int eexecl(const char *path)
{
	int ret;
	errno = 0;

	/* XXX: assume only one argument is given */
	if ((ret = execl(path, path, NULL)) < 0)
		logging(ERROR, "execl: %s\n", strerror(errno));

	return ret;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
callq 0x2060
movq %rax, %r14
andl $0x0, (%rax)
movq %rbx, %rdi
movq %rbx, %rsi
xorl %edx, %edx
xorl %eax, %eax
callq 0x22e0
movl %eax, %ebx
testl %eax, %eax
jns 0x2c84
movl (%r14), %edi
callq 0x22d0
leaq 0x4ed36(%rip), %rsi     # 0x519ad
pushq $0x2
popq %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x244c
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O2/uobikiemukot[P]yaft/./util.h
// Function: estrtol
long estrtol(const char *nptr, char **endptr, int base)
{
	long int ret;
	errno = 0;

	ret = strtol(nptr, endptr, base);
	if (ret == LONG_MIN || ret == LONG_MAX) {
		logging(ERROR, "strtol: %s\n", strerror(errno));
		return 0;
	}

	return ret;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movl %edx, %ebx
movq %rsi, %r15
movq %rdi, %r12
callq 0x2060
movq %rax, %r14
andl $0x0, (%rax)
movq %r12, %rdi
movq %r15, %rsi
movl %ebx, %edx
callq 0x21a0
movq %rax, %rbx
movabsq $-0x7fffffffffffffff, %rax # imm = 0x8000000000000001
addq %rbx, %rax
cmpq $0x1, %rax
ja 0x2cea
movl (%r14), %edi
callq 0x22d0
leaq 0x4ecdd(%rip), %rsi     # 0x519b8
xorl %ebx, %ebx
pushq $0x2
popq %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x244c
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O2/uobikiemukot[P]yaft/./util.h
// Function: parse_arg
void parse_arg(char *buf, struct parm_t *pt, int delim, int (is_valid)(int c))
{
	/*
		v..........v d           v.....v d v.....v ... d
		(valid char) (delimiter)
		argv[0]                  argv[1]   argv[2] ...   argv[argc - 1]
	*/
	size_t length;
	char *cp, *vp;

	if (buf == NULL)
		return;

	length = strlen(buf);
	logging(DEBUG, "parse_arg() length:%u\n", (unsigned) length);

	vp = NULL;
	for (size_t i = 0; i < length; i++) {
		cp = buf + i;

		if (vp == NULL && is_valid(*cp))
			vp = cp;

		if (*cp == delim) {
			*cp = '\0';
			add_parm(pt, vp);
			vp = NULL;
		}

		if (i == (length - 1) && (vp != NULL || *cp == '\0'))
			add_parm(pt, vp);
	}

	logging(DEBUG, "argc:%d\n", pt->argc);
}

// Assembly:
testq %rdi, %rdi
je 0x2dc6
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rcx, %rbx
movl %edx, %ebp
movq %rsi, %r14
movq %rdi, %r15
callq 0x20d0
movq %rax, %r12
xorl %eax, %eax
movq %r12, %r13
subq $0x1, %r12
jb 0x2db8
testq %rax, %rax
jne 0x2d6b
movsbl (%r15), %edi
callq *%rbx
testl %eax, %eax
je 0x2d69
movq %r15, %rax
jmp 0x2d6b
xorl %eax, %eax
movsbl (%r15), %ecx
cmpl %ebp, %ecx
jne 0x2d8d
movb $0x0, (%r15)
movslq (%r14), %rcx
cmpq $0xf, %rcx
jg 0x2d8b
movq %rax, 0x8(%r14,%rcx,8)
leal 0x1(%rcx), %eax
movl %eax, (%r14)
xorl %eax, %eax
cmpq $0x1, %r13
jne 0x2db3
testq %rax, %rax
je 0x2dad
movslq (%r14), %rcx
cmpq $0xf, %rcx
jg 0x2db3
movq %rax, 0x8(%r14,%rcx,8)
incl %ecx
movl %ecx, (%r14)
jmp 0x2db3
cmpb $0x0, (%r15)
je 0x2d98
incq %r15
jmp 0x2d4c
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/uobikiemukot[P]yaft/./util.h
// Function: sum
int sum(struct parm_t *parm)
{
	int sum = 0;

	for (int i = 0; i < parm->argc; i++)
		sum += dec2num(parm->argv[i]);

	return sum;
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
movq %rdi, %rbx
xorl %r14d, %r14d
xorl %ebp, %ebp
movslq (%rbx), %rax
cmpq %rax, %r14
jge 0x2e2c
movq 0x8(%rbx,%r14,8), %rdi
callq 0x2dd7
addl %eax, %ebp
incq %r14
jmp 0x2e13
movl %ebp, %eax
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/uobikiemukot[P]yaft/./fb/linux.h
// Function: alloc_cmap
void alloc_cmap(cmap_t *cmap, int colors)
{
	cmap->start  = 0;
	cmap->len    = colors;
	cmap->red    = (__u16 *) ecalloc(colors, sizeof(__u16));
	cmap->green  = (__u16 *) ecalloc(colors, sizeof(__u16));
	cmap->blue   = (__u16 *) ecalloc(colors, sizeof(__u16));
	cmap->transp = NULL;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rdi, %rbx
andl $0x0, (%rdi)
movl %esi, 0x4(%rdi)
movslq %esi, %r14
pushq $0x2
popq %r15
movq %r14, %rdi
movq %r15, %rsi
callq 0x2732
movq %rax, 0x8(%rbx)
movq %r14, %rdi
movq %r15, %rsi
callq 0x2732
movq %rax, 0x10(%rbx)
movq %r14, %rdi
movq %r15, %rsi
callq 0x2732
movq %rax, 0x18(%rbx)
andq $0x0, 0x20(%rbx)
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O2/uobikiemukot[P]yaft/./fb/linux.h
// Function: set_bitfield
void set_bitfield(struct fb_var_screeninfo *vinfo,
	struct bitfield_t *red, struct bitfield_t *green, struct bitfield_t *blue)
{
	red->length   = vinfo->red.length;
	green->length = vinfo->green.length;
	blue->length  = vinfo->blue.length;

	red->offset   = vinfo->red.offset;
	green->offset = vinfo->green.offset;
	blue->offset  = vinfo->blue.offset;
}

// Assembly:
movl 0x30(%rdi), %eax
movl 0x3c(%rdi), %r8d
movq 0x20(%rdi), %xmm0
pshufd $0xe1, %xmm0, %xmm0     # xmm0 = xmm0[1,0,2,3]
movq %xmm0, (%rsi)
movl %eax, (%rdx)
movl %r8d, (%rcx)
movl 0x2c(%rdi), %eax
movl %eax, 0x4(%rdx)
movl 0x38(%rdi), %eax
movl %eax, 0x4(%rcx)
retq
// File: /workspace/github_c_makefile_star2_O2/uobikiemukot[P]yaft/./fb/linux.h
// Function: set_fbinfo
bool set_fbinfo(int fd, struct fb_info_t *info)
{
	struct fb_fix_screeninfo finfo;
	struct fb_var_screeninfo vinfo;

	if (ioctl(fd, FBIOGET_FSCREENINFO, &finfo)) {
		logging(ERROR, "ioctl: FBIOGET_FSCREENINFO failed\n");
		return false;
	}

	if (ioctl(fd, FBIOGET_VSCREENINFO, &vinfo)) {
		logging(ERROR, "ioctl: FBIOGET_VSCREENINFO failed\n");
		return false;
	}

	set_bitfield(&vinfo, &info->red, &info->green, &info->blue);

	info->width  = vinfo.xres;
	info->height = vinfo.yres;
	info->screen_size = finfo.smem_len;
	info->line_length = finfo.line_length;

	info->bits_per_pixel  = vinfo.bits_per_pixel;
	info->bytes_per_pixel = my_ceil(info->bits_per_pixel, BITS_PER_BYTE);

	info->type   = set_type(finfo.type);
	info->visual = set_visual(finfo.visual);

	/* check screen [xy]offset and initialize because linux console changes these values */
	if (vinfo.xoffset != 0 || vinfo.yoffset != 0) {
		vinfo.xoffset = vinfo.yoffset = 0;
		if (ioctl(fd, FBIOPUT_VSCREENINFO, &vinfo))
			logging(WARN, "couldn't reset offset (x:%d y:%d)\n", vinfo.xoffset, vinfo.yoffset);
	}

	return true;
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
subq $0xf0, %rsp
movq %rsi, %r14
movl %edi, %ebx
leaq 0xa0(%rsp), %rdx
movl $0x4602, %esi           # imm = 0x4602
xorl %eax, %eax
callq 0x2130
testl %eax, %eax
je 0x2f1f
leaq 0x4eaa7(%rip), %rsi     # 0x519c4
jmp 0x2f3b
movq %rsp, %rdx
movl $0x4600, %esi           # imm = 0x4600
movl %ebx, %edi
xorl %eax, %eax
callq 0x2130
testl %eax, %eax
je 0x2f55
leaq 0x4eaac(%rip), %rsi     # 0x519e7
xorl %ebp, %ebp
pushq $0x2
popq %rdi
xorl %eax, %eax
callq 0x244c
movl %ebp, %eax
addq $0xf0, %rsp
popq %rbx
popq %r14
popq %rbp
retq
movq 0x20(%rsp), %xmm0
pshufd $0xe1, %xmm0, %xmm0     # xmm0 = xmm0[1,0,2,3]
movq %xmm0, (%r14)
movq 0x2c(%rsp), %xmm0
pshufd $0xe1, %xmm0, %xmm0     # xmm0 = xmm0[1,0,2,3]
movq %xmm0, 0x8(%r14)
movq 0x38(%rsp), %xmm0
pshufd $0xe1, %xmm0, %xmm0     # xmm0 = xmm0[1,0,2,3]
movq %xmm0, 0x10(%r14)
movq (%rsp), %rax
movq %rax, 0x18(%r14)
movl 0xb8(%rsp), %eax
movq %rax, 0x20(%r14)
movl 0xd0(%rsp), %eax
movl %eax, 0x28(%r14)
movl 0x18(%rsp), %eax
movl %eax, 0x30(%r14)
addl $0x7, %eax
pushq $0x8
popq %rcx
cltd
idivl %ecx
movl %eax, 0x2c(%r14)
movl 0xbc(%rsp), %eax
xorl %ecx, %ecx
cmpl $0x1, %eax
setne %cl
incl %ecx
testl %eax, %eax
cmovel %eax, %ecx
movl %ecx, 0x34(%r14)
movl 0xc4(%rsp), %eax
addl $-0x2, %eax
cmpl $0x2, %eax
ja 0x2ff1
movl %eax, %eax
leaq 0x4e834(%rip), %rcx     # 0x51820
movl (%rcx,%rax,4), %eax
jmp 0x2ff4
pushq $0x3
popq %rax
movl %eax, 0x38(%r14)
movl 0x14(%rsp), %eax
movb $0x1, %bpl
orl 0x10(%rsp), %eax
je 0x2f47
movq %rsp, %rdx
andq $0x0, 0x10(%rdx)
movl $0x4601, %esi           # imm = 0x4601
movl %ebx, %edi
xorl %eax, %eax
callq 0x2130
testl %eax, %eax
je 0x2f47
movl 0x10(%rsp), %edx
movl 0x14(%rsp), %ecx
leaq 0x4e9d4(%rip), %rsi     # 0x51a0a
pushq $0x1
popq %rdi
xorl %eax, %eax
callq 0x244c
jmp 0x2f47
// File: /workspace/github_c_makefile_star2_O2/uobikiemukot[P]yaft/./fb/common.h
// Function: cmap_die
void cmap_die(cmap_t *cmap)
{
	if (cmap) {
		free(cmap->red);
		free(cmap->green);
		free(cmap->blue);
		//free(cmap->transp);
		free(cmap);
	}
}

// Assembly:
testq %rdi, %rdi
je 0x30ba
pushq %rbx
movq %rdi, %rbx
movq 0x8(%rdi), %rdi
callq 0x2050
movq 0x10(%rbx), %rdi
callq 0x2050
movq 0x18(%rbx), %rdi
callq 0x2050
movq %rbx, %rdi
popq %rbx
jmp 0x2050
retq
// File: /workspace/github_c_makefile_star2_O2/uobikiemukot[P]yaft/./fb/common.h
// Function: cmap_create
cmap_t *cmap_create(int colors)
{
	cmap_t *cmap;

	if ((cmap = (cmap_t *) ecalloc(1, sizeof(cmap_t))) == NULL) {
		logging(ERROR, "couldn't allocate cmap buffer\n");
		return NULL;
	}

	/* init os specific */
	alloc_cmap(cmap, colors);

	if (!cmap->red || !cmap->green || !cmap->blue) {
		logging(ERROR, "couldn't allocate red/green/blue buffer of cmap\n");
		cmap_die(cmap);
		return NULL;
	}
	return cmap;
}

// Assembly:
pushq %rbp
pushq %rbx
pushq %rax
movl %edi, %ebp
pushq $0x1
popq %rdi
pushq $0x28
popq %rsi
callq 0x2732
testq %rax, %rax
je 0x310f
movq %rax, %rbx
movq %rax, %rdi
movl %ebp, %esi
callq 0x2e33
cmpq $0x0, 0x8(%rbx)
je 0x30f2
cmpq $0x0, 0x10(%rbx)
je 0x30f2
cmpq $0x0, 0x18(%rbx)
jne 0x3122
leaq 0x4e977(%rip), %rsi     # 0x51a70
pushq $0x2
popq %rdi
xorl %eax, %eax
callq 0x244c
movq %rbx, %rdi
callq 0x308d
xorl %ebx, %ebx
jmp 0x3122
leaq 0x4e93b(%rip), %rsi     # 0x51a51
xorl %ebx, %ebx
pushq $0x2
popq %rdi
xorl %eax, %eax
callq 0x244c
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/uobikiemukot[P]yaft/./fb/common.h
// Function: init_truecolor
bool init_truecolor(struct fb_info_t *info, cmap_t **cmap, cmap_t **cmap_orig)
{
	switch(info->bits_per_pixel) {
	case 15: /* XXX: 15 bpp is not tested */
	case 16:
	case 24:
	case 32:
		break;
	default:
		logging(ERROR, "truecolor %d bpp not supported\n", info->bits_per_pixel);
		return false;
	}
	/* we don't use cmap in truecolor */
	*cmap = *cmap_orig = NULL;

	return true;
}

// Assembly:
pushq %rbx
movq %rdx, %rax
movl 0x30(%rdi), %edx
cmpq $0x20, %rdx
ja 0x32d9
movabsq $0x101018000, %rcx      # imm = 0x101018000
btq %rdx, %rcx
jae 0x32d9
andq $0x0, (%rax)
andq $0x0, (%rsi)
movb $0x1, %bl
movl %ebx, %eax
popq %rbx
retq
leaq 0x4e7e3(%rip), %rsi     # 0x51ac3
xorl %ebx, %ebx
pushq $0x2
popq %rdi
xorl %eax, %eax
callq 0x244c
jmp 0x32d5
// File: /workspace/github_c_makefile_star2_O2/uobikiemukot[P]yaft/./fb/common.h
// Function: color2pixel
static inline uint32_t color2pixel(struct fb_info_t *info, uint32_t color)
{
	uint32_t r, g, b;

	r = bit_mask[BITS_PER_RGB] & (color >> (BITS_PER_RGB * 2));
	g = bit_mask[BITS_PER_RGB] & (color >>  BITS_PER_RGB);
	b = bit_mask[BITS_PER_RGB] & (color >>  0);

	r = r >> (BITS_PER_RGB - info->red.length);
	g = g >> (BITS_PER_RGB - info->green.length);
	b = b >> (BITS_PER_RGB - info->blue.length);

	return (r << info->red.offset)
			+ (g << info->green.offset)
			+ (b << info->blue.offset);
}

// Assembly:
movl %esi, %r8d
shrl $0x10, %r8d
movl $0xff, %eax
andl %eax, %r8d
movl %esi, %r9d
shrl $0x8, %r9d
movb $0x8, %cl
subb (%rdi), %cl
shrl %cl, %r8d
andl %eax, %r9d
movb $0x8, %cl
subb 0x8(%rdi), %cl
shrl %cl, %r9d
andl %esi, %eax
movb $0x8, %cl
subb 0x10(%rdi), %cl
shrl %cl, %eax
movb 0x4(%rdi), %cl
movb 0xc(%rdi), %dl
shll %cl, %r8d
movl %edx, %ecx
shll %cl, %r9d
movb 0x14(%rdi), %cl
shll %cl, %eax
addl %r8d, %r9d
addl %r9d, %eax
retq
// File: /workspace/github_c_makefile_star2_O2/uobikiemukot[P]yaft/./fb/common.h
// Function: fb_die
void fb_die(struct framebuffer_t *fb)
{
	cmap_die(fb->cmap);
	if (fb->cmap_orig) {
		put_cmap(fb->fd, fb->cmap_orig);
		cmap_die(fb->cmap_orig);
	}
	free(fb->wall);
	free(fb->buf);
	emunmap(fb->fp, fb->info.screen_size);
	eclose(fb->fd);
	//fb_release(fb->fd, &fb->info); /* os specific */
}

// Assembly:
pushq %rbx
movq %rdi, %rbx
movq 0x460(%rdi), %rdi
callq 0x308d
movq 0x468(%rbx), %rsi
testq %rsi, %rsi
je 0x364d
movl (%rbx), %edi
callq 0x2e80
movq 0x468(%rbx), %rdi
callq 0x308d
movq 0x18(%rbx), %rdi
callq 0x2050
movq 0x10(%rbx), %rdi
callq 0x2050
movq 0x8(%rbx), %rdi
movq 0x440(%rbx), %rsi
callq 0x26e7
movl (%rbx), %edi
popq %rbx
jmp 0x257b
// File: /workspace/github_c_makefile_star2_O2/uobikiemukot[P]yaft/./terminal.h
// Function: copy_cell
void copy_cell(struct terminal_t *term, int dst_y, int dst_x, int src_y, int src_x)
{
	struct cell_t *dst, *src;

	dst = &term->cells[dst_y][dst_x];
	src = &term->cells[src_y][src_x];

	if (src->width == NEXT_TO_WIDE) {
		return;
	} else if (src->width == WIDE && dst_x == (term->cols - 1)) {
		erase_cell(term, dst_y, dst_x);
	} else {
		*dst = *src;
		if (src->width == WIDE) {
			*(dst + 1) = *src;
			(dst + 1)->width = NEXT_TO_WIDE;
		}
		term->line_dirty[dst_y] = true;
	}
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %rbx
movq 0x18(%rdi), %rdi
movslq %ecx, %rax
movq (%rdi,%rax,8), %r14
movslq %r8d, %rax
imulq $0x218, %rax, %rax      # imm = 0x218
movl 0x10(%r14,%rax), %ecx
testl %ecx, %ecx
je 0x3aee
movslq %esi, %r12
movslq %edx, %r8
imulq $0x218, %r8, %r15       # imm = 0x218
addq (%rdi,%r12,8), %r15
cmpl $0x2, %ecx
jne 0x3aaf
movl 0xc(%rbx), %ecx
decl %ecx
cmpl %edx, %ecx
jne 0x3aaf
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
jmp 0x3a0e
addq %rax, %r14
movl $0x218, %edx            # imm = 0x218
movq %r15, %rdi
movq %r14, %rsi
callq 0x21c0
cmpl $0x2, 0x10(%r14)
jne 0x3ae5
leaq 0x218(%r15), %rdi
movl $0x218, %edx            # imm = 0x218
movq %r14, %rsi
callq 0x21c0
andl $0x0, 0x228(%r15)
movq 0x28(%rbx), %rax
movb $0x1, (%rax,%r12)
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O2/uobikiemukot[P]yaft/./terminal.h
// Function: set_cell
int set_cell(struct terminal_t *term, int y, int x, const struct glyph_t *glyphp)
{
	struct cell_t cell, *cellp;
	uint8_t color_tmp;

	cell.glyphp = glyphp;

	cell.color_pair.fg = (term->attribute & attr_mask[ATTR_BOLD] && term->color_pair.fg <= 7) ?
		term->color_pair.fg + BRIGHT_INC: term->color_pair.fg;
	cell.color_pair.bg = (term->attribute & attr_mask[ATTR_BLINK] && term->color_pair.bg <= 7) ?
		term->color_pair.bg + BRIGHT_INC: term->color_pair.bg;

	if (term->attribute & attr_mask[ATTR_REVERSE]) {
		color_tmp          = cell.color_pair.fg;
		cell.color_pair.fg = cell.color_pair.bg;
		cell.color_pair.bg = color_tmp;
	}

	cell.attribute  = term->attribute;
	cell.width      = glyphp->width;
	cell.has_pixmap = false;

	cellp    = &term->cells[y][x];
	*cellp   = cell;
	term->line_dirty[y] = true;

	if (cell.width == WIDE && x + 1 < term->cols) {
		cellp        = &term->cells[y][x + 1];
		*cellp       = cell;
		cellp->width = NEXT_TO_WIDE;
		return WIDE;
	}

	if (cell.width == HALF /* isolated NEXT_TO_WIDE cell */
		&& x + 1 < term->cols
		&& term->cells[y][x + 1].width == NEXT_TO_WIDE) {
		erase_cell(term, y, x + 1);
	}
	return HALF;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movb 0x4c(%rdi), %al
movl %eax, %r8d
orb $0x8, %r8b
cmpb $0x8, %al
movzbl %al, %r9d
movzbl %r8b, %r10d
cmovael %r9d, %r10d
movl 0x50(%rdi), %eax
testb $0x1, %al
cmovel %r9d, %r10d
movzbl 0x4d(%rdi), %r9d
movl %r9d, %r8d
orb $0x8, %r8b
cmpb $0x8, %r9b
movzbl %r8b, %r8d
cmovael %r9d, %r8d
testb $0x4, %al
cmovel %r9d, %r8d
testb $0x8, %al
movl %r10d, %r9d
cmovel %r8d, %r9d
cmovel %r10d, %r8d
movzbl 0x4(%rcx), %r11d
movslq %edx, %r10
imulq $0x218, %r10, %rbx      # imm = 0x218
movq 0x18(%rdi), %r14
movslq %esi, %r10
movq (%r14,%r10,8), %r14
movq %rcx, (%r14,%rbx)
movb %r8b, 0x8(%r14,%rbx)
movb %r9b, 0x9(%r14,%rbx)
movl %eax, 0xc(%r14,%rbx)
movl %r11d, 0x10(%r14,%rbx)
movb $0x0, 0x14(%r14,%rbx)
movq 0x28(%rdi), %rbx
movb $0x1, (%rbx,%r10)
pushq $0x1
popq %rbx
cmpl $0x1, %r11d
je 0x3bd4
cmpl $0x2, %r11d
jne 0x3bf9
incl %edx
cmpl 0xc(%rdi), %edx
jge 0x3bf9
movq 0x18(%rdi), %rsi
movq (%rsi,%r10,8), %rsi
movslq %edx, %rdx
imulq $0x218, %rdx, %rdx      # imm = 0x218
movq %rcx, (%rsi,%rdx)
movb %r8b, 0x8(%rsi,%rdx)
movb %r9b, 0x9(%rsi,%rdx)
movl %eax, 0xc(%rsi,%rdx)
movb $0x0, 0x14(%rsi,%rdx)
andl $0x0, 0x10(%rsi,%rdx)
pushq $0x2
popq %rbx
jmp 0x3bf9
incl %edx
cmpl 0xc(%rdi), %edx
jge 0x3bf9
movq 0x18(%rdi), %rax
movq (%rax,%r10,8), %rax
movslq %edx, %rcx
imulq $0x218, %rcx, %rcx      # imm = 0x218
cmpl $0x0, 0x10(%rax,%rcx)
jne 0x3bf9
callq 0x3a0e
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O2/uobikiemukot[P]yaft/./terminal.h
// Function: scroll
void scroll(struct terminal_t *term, int from, int to, int offset)
{
	int abs_offset, scroll_lines;

	if (offset == 0 || from >= to)
		return;

	logging(DEBUG, "scroll from:%d to:%d offset:%d\n", from, to, offset);

	for (int y = from; y <= to; y++)
		term->line_dirty[y] = true;

	abs_offset = abs(offset);
	scroll_lines = (to - from + 1) - abs_offset;

	if (offset > 0) { /* scroll down */
		for (int y = from; y < from + scroll_lines; y++)
			swap_lines(term, y, y + offset);
		for (int y = (to - offset + 1); y <= to; y++)
			for (int x = 0; x < term->cols; x++)
				erase_cell(term, y, x);
	}
	else {            /* scroll up */
		for (int y = to; y >= from + abs_offset; y--)
			swap_lines(term, y, y - abs_offset);
		for (int y = from; y < from + abs_offset; y++)
			for (int x = 0; x < term->cols; x++)
				erase_cell(term, y, x);
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movl %edx, %r14d
testl %ecx, %ecx
sete %al
cmpl %edx, %esi
setge %dl
orb %al, %dl
jne 0x3d0c
movl %esi, %ebp
movq %rdi, %rbx
movslq %esi, %rax
movslq %r14d, %rdx
movq %rax, %rsi
cmpq %rdx, %rsi
jg 0x3c3f
movq 0x28(%rbx), %rdi
movb $0x1, (%rdi,%rsi)
incq %rsi
jmp 0x3c2d
movl %ecx, %esi
negl %esi
movl %ecx, %r15d
cmovnsl %esi, %r15d
addl %ebp, %r15d
testl %ecx, %ecx
jle 0x3cb2
addl %r14d, %ebp
subl %r15d, %ebp
incl %ebp
movslq %ebp, %rdx
movl %ecx, %esi
shlq $0x3, %rsi
cmpq %rdx, %rax
jge 0x3c8b
movq 0x18(%rbx), %rdi
leaq (%rdi,%rax,8), %r8
movq (%rdi,%rax,8), %r9
movq (%rsi,%r8), %r8
movq %r8, (%rdi,%rax,8)
movq 0x18(%rbx), %rdi
addq %rsi, %rdi
movq %r9, (%rdi,%rax,8)
incq %rax
jmp 0x3c62
movl %r14d, %ebp
subl %ecx, %ebp
cmpl %r14d, %ebp
jge 0x3d0c
incl %ebp
xorl %r15d, %r15d
cmpl 0xc(%rbx), %r15d
jge 0x3c90
movq %rbx, %rdi
movl %ebp, %esi
movl %r15d, %edx
callq 0x3a0e
incl %r15d
jmp 0x3c9a
movslq %r15d, %rax
cmpl %esi, %ecx
cmovgl %ecx, %esi
shlq $0x3, %rsi
negq %rsi
cmpq %rax, %rdx
jl 0x3d07
movq 0x18(%rbx), %rcx
leaq (%rcx,%rdx,8), %rdi
movq (%rcx,%rdx,8), %r8
movq (%rsi,%rdi), %rdi
movq %rdi, (%rcx,%rdx,8)
movq 0x18(%rbx), %rcx
addq %rsi, %rcx
movq %r8, (%rcx,%rdx,8)
decq %rdx
jmp 0x3cc1
xorl %r14d, %r14d
cmpl 0xc(%rbx), %r14d
jge 0x3d05
movq %rbx, %rdi
movl %ebp, %esi
movl %r14d, %edx
callq 0x3a0e
incl %r14d
jmp 0x3ced
incl %ebp
cmpl %r15d, %ebp
jl 0x3cea
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/uobikiemukot[P]yaft/./terminal.h
// Function: move_cursor
void move_cursor(struct terminal_t *term, int y_offset, int x_offset)
{
	int x, y, top, bottom;

	x = term->cursor.x + x_offset;
	y = term->cursor.y + y_offset;

	top    = term->scroll.top;
	bottom = term->scroll.bottom;

	if (x < 0) {
		x = 0;
	} else if (x >= term->cols) {
		if (term->mode & MODE_AMRIGHT)
			term->wrap_occurred = true;
		x = term->cols - 1;
	}
	term->cursor.x = x;

	y = (y < 0) ? 0:
		(y >= term->lines) ? term->lines - 1: y;

	if (term->cursor.y == top && y_offset < 0) {
		y = top;
		scroll(term, top, bottom, y_offset);
	} else if (term->cursor.y == bottom && y_offset > 0) {
		y = bottom;
		scroll(term, top, bottom, y_offset);
	}
	term->cursor.y = y;
}

// Assembly:
pushq %rbp
pushq %rbx
pushq %rax
movl %esi, %ecx
movq %rdi, %rbx
movzwl 0x24(%rdi), %esi
movzwl 0x26(%rdi), %edi
leal (%rdi,%rcx), %r8d
xorl %eax, %eax
addl %edx, %esi
movl $0x0, %r9d
js 0x3d50
movl 0xc(%rbx), %edx
movl %esi, %r9d
cmpl %edx, %esi
jl 0x3d50
testb $0x4, 0x38(%rbx)
je 0x3d4b
movb $0x1, 0x3c(%rbx)
decl %edx
movl %edx, %r9d
movzwl 0x20(%rbx), %esi
movzwl 0x22(%rbx), %edx
movw %r9w, 0x24(%rbx)
testl %r8d, %r8d
js 0x3d71
movl 0x10(%rbx), %r9d
leal -0x1(%r9), %eax
cmpl %r9d, %r8d
cmovll %r8d, %eax
cmpw %si, %di
sete %r8b
testl %ecx, %ecx
sets %r9b
movl %esi, %ebp
testb %r8b, %r9b
jne 0x3d99
cmpw %dx, %di
setne %dil
testl %ecx, %ecx
setle %r8b
orb %dil, %r8b
movl %edx, %ebp
jne 0x3da3
movq %rbx, %rdi
callq 0x3c03
movl %ebp, %eax
movw %ax, 0x26(%rbx)
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/uobikiemukot[P]yaft/./terminal.h
// Function: set_cursor
void set_cursor(struct terminal_t *term, int y, int x)
{
	int top, bottom;

	if (term->mode & MODE_ORIGIN) {
		top    = term->scroll.top;
		bottom = term->scroll.bottom;
		y += term->scroll.top;
	} else {
		top = 0;
		bottom = term->lines - 1;
	}

	x = (x < 0) ? 0: (x >= term->cols) ? term->cols - 1: x;
	y = (y < top) ? top: (y > bottom) ? bottom: y;

	term->cursor.x = x;
	term->cursor.y = y;
	term->wrap_occurred = false;
}

// Assembly:
testb $0x1, 0x38(%rdi)
jne 0x3dbd
movl 0x10(%rdi), %eax
decl %eax
xorl %ecx, %ecx
jmp 0x3dc7
movzwl 0x20(%rdi), %ecx
movzwl 0x22(%rdi), %eax
addl %ecx, %esi
testl %edx, %edx
js 0x3ddc
movl 0xc(%rdi), %r9d
leal -0x1(%r9), %r8d
cmpl %edx, %r9d
cmovgl %edx, %r8d
jmp 0x3ddf
xorl %r8d, %r8d
cmpl %eax, %esi
cmovll %esi, %eax
cmpl %ecx, %esi
movw %r8w, 0x24(%rdi)
cmovll %ecx, %eax
movw %ax, 0x26(%rdi)
movb $0x0, 0x3c(%rdi)
retq
// File: /workspace/github_c_makefile_star2_O2/uobikiemukot[P]yaft/./terminal.h
// Function: drcs_glyph
const struct glyph_t *drcs_glyph(struct terminal_t *term, uint32_t code)
{
	/* DRCSMMv1
		ESC ( SP <\xXX> <\xYY> ESC ( B
		<===> U+10XXYY ( 0x40 <= 0xXX <=0x7E, 0x20 <= 0xYY <= 0x7F )
	*/
	int row, cell; /* = ku, ten */

	row  = (0xFF00 & code) >> 8;
	cell = 0xFF & code;

	logging(DEBUG, "drcs row:0x%.2X cell:0x%.2X\n", row, cell);

	if ((0x40 <= row && row <= 0x7E) && (0x20 <= cell && cell <= 0x7F))
		return &term->drcs[(row - 0x40) * GLYPHS_PER_CHARSET + (cell - 0x20)];
	else
		return term->glyph[SUBSTITUTE_HALF];
}

// Assembly:
movl %esi, %eax
shrl $0x8, %eax
movl $0xff, %ecx
andl %ecx, %eax
andl %ecx, %esi
leal -0x40(%rax), %ecx
cmpl $0x3f, %ecx
setae %cl
leal -0x20(%rsi), %edx
cmpl $0x60, %edx
setae %dl
orb %cl, %dl
jne 0x3e33
imull $0x60, %eax, %eax
addl %esi, %eax
addl $0xffffe7e0, %eax       # imm = 0xFFFFE7E0
imulq $0x28, %rax, %rax
addq %rdi, %rax
addq $0x80488, %rax          # imm = 0x80488
retq
movq 0x588(%rdi), %rax
retq
// File: /workspace/github_c_makefile_star2_O2/uobikiemukot[P]yaft/./terminal.h
// Function: addch
void addch(struct terminal_t *term, uint32_t code)
{
	int width;
	const struct glyph_t *glyphp;

	logging(DEBUG, "addch: U+%.4X\n", code);

	width = wcwidth(code);

	if (width <= 0)                                /* zero width: not support combining characters */
		return;
	else if (0x100000 <= code && code <= 0x10FFFD) /* unicode private area: plane 16 (DRCSMMv1) */
		glyphp = drcs_glyph(term, code);
	else if (code >= UCS2_CHARS                    /* yaft support only UCS2 */
		|| term->glyph[code] == NULL           /* missing glyph */
		|| term->glyph[code]->width != width)  /* width unmatched */
		glyphp = (width == 1) ? term->glyph[SUBSTITUTE_HALF]: term->glyph[SUBSTITUTE_WIDE];
	else
		glyphp = term->glyph[code];

	if ((term->wrap_occurred && term->cursor.x == term->cols - 1) /* folding */
		|| (glyphp->width == WIDE && term->cursor.x == term->cols - 1)) {
		set_cursor(term, term->cursor.y, 0);
		move_cursor(term, 1, 0);
	}
	term->wrap_occurred = false;

	move_cursor(term, 0, set_cell(term, term->cursor.y, term->cursor.x, glyphp));
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movl %esi, %r14d
movq %rdi, %rbx
movl %esi, %edi
callq 0x21e0
testl %eax, %eax
jle 0x3e6f
leal -0x100000(%r14), %ecx
cmpl $0xfffd, %ecx           # imm = 0xFFFD
ja 0x3e77
movq %rbx, %rdi
movl %r14d, %esi
callq 0x3df7
movq %rax, %r14
jmp 0x3eb1
addq $0x8, %rsp
popq %rbx
popq %r14
retq
cmpl $0xffff, %r14d          # imm = 0xFFFF
ja 0x3e99
movl %r14d, %ecx
movq 0x488(%rbx,%rcx,8), %r14
testq %r14, %r14
je 0x3e99
movzbl 0x4(%r14), %ecx
cmpl %ecx, %eax
je 0x3eb1
leaq 0x18488(%rbx), %rcx
leaq 0x588(%rbx), %rdx
cmpl $0x1, %eax
cmoveq %rdx, %rcx
movq (%rcx), %r14
cmpb $0x1, 0x3c(%rbx)
jne 0x3ec4
movzwl 0x24(%rbx), %eax
movl 0xc(%rbx), %ecx
decl %ecx
cmpl %eax, %ecx
je 0x3ed8
cmpb $0x2, 0x4(%r14)
jne 0x3ef3
movzwl 0x24(%rbx), %eax
movl 0xc(%rbx), %ecx
decl %ecx
cmpl %eax, %ecx
jne 0x3ef3
movzwl 0x26(%rbx), %esi
movq %rbx, %rdi
xorl %edx, %edx
callq 0x3dae
pushq $0x1
popq %rsi
movq %rbx, %rdi
xorl %edx, %edx
callq 0x3d17
movb $0x0, 0x3c(%rbx)
movzwl 0x26(%rbx), %esi
movzwl 0x24(%rbx), %edx
movq %rbx, %rdi
movq %r14, %rcx
callq 0x3afa
movq %rbx, %rdi
xorl %esi, %esi
movl %eax, %edx
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x3d17
// File: /workspace/github_c_makefile_star2_O2/uobikiemukot[P]yaft/./terminal.h
// Function: push_esc
bool push_esc(struct terminal_t *term, uint8_t ch)
{
	long offset;

	if ((term->esc.bp - term->esc.buf) >= term->esc.size) { /* buffer limit */
		logging(DEBUG, "escape sequence length >= %d, term.esc.buf reallocated\n", term->esc.size);
		offset = term->esc.bp - term->esc.buf;
		term->esc.buf = erealloc(term->esc.buf, term->esc.size * 2);
		term->esc.bp  = term->esc.buf + offset;
		term->esc.size *= 2;
	}

	/* ref: http://www.vt100.net/docs/vt102-ug/appendixd.html */
	*term->esc.bp++ = ch;
	if (term->esc.state == STATE_ESC) {
		/* format:
			ESC  I.......I F
				 ' '  '/'  '0'  '~'
			0x1B 0x20-0x2F 0x30-0x7E
		*/
		if ('0' <= ch && ch <= '~')        /* final char */
			return true;
		else if (SPACE <= ch && ch <= '/') /* intermediate char */
			return false;
	} else if (term->esc.state == STATE_CSI) {
		/* format:
			CSI       P.......P I.......I F
			ESC  '['  '0'  '?'  ' '  '/'  '@'  '~'
			0x1B 0x5B 0x30-0x3F 0x20-0x2F 0x40-0x7E
		*/
		if ('@' <= ch && ch <= '~')
			return true;
		else if (SPACE <= ch && ch <= '?')
			return false;
	} else {
		/* format:
			OSC       I.....I F
			ESC  ']'          BEL  or ESC  '\'
			0x1B 0x5D unknown 0x07 or 0x1B 0x5C
			DCS       I....I  F
			ESC  'P'          BEL  or ESC  '\'
			0x1B 0x50 unknown 0x07 or 0x1B 0x5C
		*/
		if (ch == BEL || (ch == BACKSLASH
			&& (term->esc.bp - term->esc.buf) >= 2 && *(term->esc.bp - 2) == ESC))
			return true;
		else if ((ch == ESC || ch == CR || ch == LF || ch == BS || ch == HT)
			|| (SPACE <= ch && ch <= '~'))
			return false;
	}

	/* invalid sequence */
	reset_esc(term);
	return false;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movl %esi, %r14d
movq %rdi, %rbx
movq 0x68(%rdi), %rdi
movq 0x70(%rbx), %rax
movq %rax, %r15
subq %rdi, %r15
movslq 0x78(%rbx), %rsi
cmpq %rsi, %r15
jl 0x3f61
addq %rsi, %rsi
callq 0x277d
movq %rax, 0x68(%rbx)
shll 0x78(%rbx)
addq %rax, %r15
movq %r15, %rax
leaq 0x1(%rax), %rcx
movq %rcx, 0x70(%rbx)
movb %r14b, (%rax)
movl 0x7c(%rbx), %eax
cmpl $0x2, %eax
je 0x3f8a
cmpl $0x1, %eax
jne 0x3fad
leal -0x30(%r14), %ecx
movb $0x1, %al
cmpb $0x4f, %cl
jb 0x3fc5
andb $-0x10, %r14b
jmp 0x3f99
leal -0x40(%r14), %ecx
movb $0x1, %al
cmpb $0x3f, %cl
jb 0x3fc5
andb $-0x20, %r14b
cmpb $0x20, %r14b
je 0x3fc3
movq 0x68(%rbx), %rax
movq %rax, 0x70(%rbx)
andl $0x0, 0x7c(%rbx)
jmp 0x3fc3
movzbl %r14b, %ecx
movb $0x1, %al
cmpb $0x1b, %r14b
ja 0x3fd0
movl $0x8002700, %edx        # imm = 0x8002700
btl %ecx, %edx
jae 0x3fcb
xorl %eax, %eax
popq %rbx
popq %r14
popq %r15
retq
cmpl $0x7, %ecx
je 0x3fc5
cmpl $0x5c, %ecx
jne 0x3fee
movq 0x70(%rbx), %rcx
movq %rcx, %rdx
subq 0x68(%rbx), %rdx
cmpq $0x2, %rdx
jl 0x3fc3
cmpb $0x1b, -0x2(%rcx)
jne 0x3fc3
jmp 0x3fc5
addb $-0x20, %r14b
cmpb $0x5f, %r14b
jae 0x3f9f
jmp 0x3fc3
// File: /workspace/github_c_makefile_star2_O2/uobikiemukot[P]yaft/./terminal.h
// Function: reset
void reset(struct terminal_t *term)
{
	term->mode  = MODE_RESET;
	term->mode |= (MODE_CURSOR | MODE_AMRIGHT);
	term->wrap_occurred = false;

	term->scroll.top    = 0;
	term->scroll.bottom = term->lines - 1;

	term->cursor.x = term->cursor.y = 0;

	term->state.mode      = term->mode;
	term->state.cursor    = term->cursor;
	term->state.attribute = ATTR_RESET;

	term->color_pair.fg = DEFAULT_FG;
	term->color_pair.bg = DEFAULT_BG;

	term->attribute = ATTR_RESET;

	for (int line = 0; line < term->lines; line++) {
		for (int col = 0; col < term->cols; col++) {
			erase_cell(term, line, col);
			if ((col % TABSTOP) == 0)
				term->tabstop[col] = true;
			else
				term->tabstop[col] = false;
		}
		term->line_dirty[line] = true;
	}

	reset_esc(term);
	reset_charset(term);
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rdi, %rbx
movl $0x6, 0x38(%rdi)
movb $0x0, 0x3c(%rdi)
andw $0x0, 0x20(%rdi)
movl 0x10(%rdi), %eax
leal -0x1(%rax), %ecx
movw %cx, 0x22(%rdi)
andl $0x0, 0x24(%rdi)
movq $0x6, 0x44(%rdi)
andl $0x0, 0x40(%rdi)
movw $0x7, 0x4c(%rdi)
andl $0x0, 0x50(%rdi)
xorl %r14d, %r14d
cltq
cmpq %rax, %r14
jge 0x408b
xorl %r15d, %r15d
movslq 0xc(%rbx), %rax
cmpq %rax, %r15
jge 0x407a
movq %rbx, %rdi
movl %r14d, %esi
movl %r15d, %edx
callq 0x3a0e
testb $0x7, %r15b
movq 0x30(%rbx), %rax
sete (%rax,%r15)
incq %r15
jmp 0x4051
movq 0x28(%rbx), %rax
movb $0x1, (%rax,%r14)
incq %r14
movl 0x10(%rbx), %eax
jmp 0x4047
movq 0x68(%rbx), %rax
movq %rax, 0x70(%rbx)
andl $0x0, 0x7c(%rbx)
andl $0x0, 0x5c(%rbx)
andq $0x0, 0x54(%rbx)
movb $0x1, 0x60(%rbx)
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O2/uobikiemukot[P]yaft/./terminal.h
// Function: term_die
void term_die(struct terminal_t *term)
{
	free(term->line_dirty);
	free(term->tabstop);
	free(term->esc.buf);
	free(term->sixel.pixmap);

	for (int i = 0; i < term->lines; i++)
		free(term->cells[i]);
	free(term->cells);
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
movq 0x28(%rdi), %rdi
callq 0x2050
movq 0x30(%rbx), %rdi
callq 0x2050
movq 0x68(%rbx), %rdi
callq 0x2050
movq 0xbb588(%rbx), %rdi
callq 0x2050
xorl %r14d, %r14d
movslq 0x10(%rbx), %rax
movq 0x18(%rbx), %rdi
cmpq %rax, %r14
jge 0x410f
movq (%rdi,%r14,8), %rdi
callq 0x2050
incq %r14
jmp 0x40f4
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x2050
// File: /workspace/github_c_makefile_star2_O2/uobikiemukot[P]yaft/./ctrlseq/esc.h
// Function: bs
void bs(struct terminal_t *term)
{
	if (term->mode & MODE_VWBS
		&& term->cursor.x - 1 >= 0
		&& term->cells[term->cursor.y][term->cursor.x - 1].width == NEXT_TO_WIDE)
		move_cursor(term, 0, -2);
	else
		move_cursor(term, 0, -1);
}

// Assembly:
testb $0x8, 0x38(%rdi)
je 0x42eb
movzwl 0x24(%rdi), %eax
testq %rax, %rax
je 0x42eb
decl %eax
movq 0x18(%rdi), %rcx
movzwl 0x26(%rdi), %edx
movq (%rcx,%rdx,8), %rcx
imulq $0x218, %rax, %rax      # imm = 0x218
cmpl $0x0, 0x10(%rcx,%rax)
je 0x42f5
pushq $-0x1
popq %rdx
xorl %esi, %esi
jmp 0x3d17
pushq $-0x2
jmp 0x42ed
// File: /workspace/github_c_makefile_star2_O2/uobikiemukot[P]yaft/./ctrlseq/esc.h
// Function: tab
void tab(struct terminal_t *term)
{
	int i;

	for (i = term->cursor.x + 1; i < term->cols; i++) {
		if (term->tabstop[i]) {
			set_cursor(term, term->cursor.y, i);
			return;
		}
	}
	set_cursor(term, term->cursor.y, term->cols - 1);
}

// Assembly:
movzwl 0x24(%rdi), %ecx
movslq 0xc(%rdi), %rdx
incq %rcx
cmpq %rdx, %rcx
jge 0x4327
movq 0x30(%rdi), %rsi
leaq 0x1(%rcx), %rax
cmpb $0x1, (%rsi,%rcx)
movq %rax, %rcx
jne 0x4304
decl %eax
movzwl 0x26(%rdi), %esi
movl %eax, %edx
jmp 0x3dae
movzwl 0x26(%rdi), %esi
decl %edx
jmp 0x3dae
// File: /workspace/github_c_makefile_star2_O2/uobikiemukot[P]yaft/./ctrlseq/csi.h
// Function: insert_blank
void insert_blank(struct terminal_t *term, struct parm_t *parm)
{
	int i, num = sum(parm);

	if (num <= 0)
		num = 1;

	for (i = term->cols - 1; term->cursor.x <= i; i--) {
		if (term->cursor.x <= (i - num))
			copy_cell(term, term->cursor.y, i, term->cursor.y, i - num);
		else
			erase_cell(term, term->cursor.y, i);
	}
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rdi, %rbx
movq %rsi, %rdi
callq 0x2e07
cmpl $0x2, %eax
pushq $0x1
popq %r15
cmovgel %eax, %r15d
movl 0xc(%rbx), %r14d
notl %r15d
movzwl 0x24(%rbx), %eax
cmpl %eax, %r14d
jle 0x442b
leal (%r15,%r14), %r8d
decl %r14d
movzwl 0x26(%rbx), %esi
movq %rbx, %rdi
movl %r14d, %edx
cmpl %eax, %r8d
jge 0x4422
callq 0x3a0e
jmp 0x43fc
movl %esi, %ecx
callq 0x3a54
jmp 0x43fc
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O2/uobikiemukot[P]yaft/./ctrlseq/csi.h
// Function: curs_nl
void curs_nl(struct terminal_t *term, struct parm_t *parm)
{
	int num = sum(parm);

	if (num <= 0)
		num = 1;

	move_cursor(term, num, 0);
	cr(term);
}

// Assembly:
pushq %rbx
movq %rdi, %rbx
movq %rsi, %rdi
callq 0x2e07
cmpl $0x2, %eax
pushq $0x1
popq %rsi
cmovgel %eax, %esi
movq %rbx, %rdi
xorl %edx, %edx
callq 0x3d17
movq %rbx, %rdi
popq %rbx
jmp 0x433c
// File: /workspace/github_c_makefile_star2_O2/uobikiemukot[P]yaft/./ctrlseq/csi.h
// Function: curs_pos
void curs_pos(struct terminal_t *term, struct parm_t *parm)
{
	int line, col;

	if (parm->argc <= 0) {
		line = col = 0;
	} else if (parm->argc == 2) {
		line = dec2num(parm->argv[0]) - 1;
		col  = dec2num(parm->argv[1]) - 1;
	} else {
		return;
	}

	if (line < 0)
		line = 0;
	if (col < 0)
		col = 0;

	set_cursor(term, line, col);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
movl (%rsi), %ecx
xorl %ebp, %ebp
movl $0x0, %r14d
movl $0x0, %eax
testl %ecx, %ecx
jle 0x4571
cmpl $0x2, %ecx
jne 0x4594
movq %rsi, %r15
movq 0x8(%rsi), %rdi
callq 0x2dd7
movl %eax, %r14d
decl %r14d
movq 0x10(%r15), %rdi
callq 0x2dd7
decl %eax
testl %r14d, %r14d
cmovlel %ebp, %r14d
testl %eax, %eax
cmovgl %eax, %ebp
movq %rbx, %rdi
movl %r14d, %esi
movl %ebp, %edx
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x3dae
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/uobikiemukot[P]yaft/./ctrlseq/csi.h
// Function: erase_display
void erase_display(struct terminal_t *term, struct parm_t *parm)
{
	int i, j, mode;

	mode = (parm->argc <= 0) ? 0: dec2num(parm->argv[parm->argc - 1]);

	if (mode < 0 || 2 < mode)
		return;

	if (mode == 0) {
		for (i = term->cursor.y; i < term->lines; i++)
			for (j = 0; j < term->cols; j++)
				if (i > term->cursor.y || (i == term->cursor.y && j >= term->cursor.x))
					erase_cell(term, i, j);
	} else if (mode == 1) {
		for (i = 0; i <= term->cursor.y; i++)
			for (j = 0; j < term->cols; j++)
				if (i < term->cursor.y || (i == term->cursor.y && j <= term->cursor.x))
					erase_cell(term, i, j);
	} else if (mode == 2) {
		for (i = 0; i < term->lines; i++)
			for (j = 0; j < term->cols; j++)
				erase_cell(term, i, j);
	}
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
movq %rdi, %rbx
movl (%rsi), %eax
testl %eax, %eax
jle 0x4656
decl %eax
movq 0x8(%rsi,%rax,8), %rdi
callq 0x2dd7
cmpl $0x2, %eax
ja 0x4651
testl %eax, %eax
je 0x4656
xorl %ebp, %ebp
cmpl $0x1, %eax
jne 0x464c
movzwl 0x26(%rbx), %eax
cmpl %eax, %ebp
ja 0x4651
xorl %r14d, %r14d
cmpl 0xc(%rbx), %r14d
jge 0x462b
movzwl 0x26(%rbx), %eax
cmpl %eax, %ebp
jae 0x461b
movq %rbx, %rdi
movl %ebp, %esi
movl %r14d, %edx
callq 0x3a0e
jmp 0x4626
jne 0x4626
movzwl 0x24(%rbx), %eax
cmpl %eax, %r14d
jbe 0x460c
incl %r14d
jmp 0x45fe
incl %ebp
jmp 0x45f3
xorl %r14d, %r14d
cmpl 0xc(%rbx), %r14d
jge 0x464a
movq %rbx, %rdi
movl %ebp, %esi
movl %r14d, %edx
callq 0x3a0e
incl %r14d
jmp 0x4632
incl %ebp
cmpl 0x10(%rbx), %ebp
jl 0x462f
popq %rbx
popq %r14
popq %rbp
retq
movzwl 0x26(%rbx), %ebp
cmpl 0x10(%rbx), %ebp
jge 0x4651
xorl %r14d, %r14d
cmpl 0xc(%rbx), %r14d
jge 0x468f
movzwl 0x26(%rbx), %eax
cmpl %eax, %ebp
jbe 0x467f
movq %rbx, %rdi
movl %ebp, %esi
movl %r14d, %edx
callq 0x3a0e
jmp 0x468a
jne 0x468a
movzwl 0x24(%rbx), %eax
cmpl %eax, %r14d
jae 0x4670
incl %r14d
jmp 0x4662
incl %ebp
jmp 0x465a
// File: /workspace/github_c_makefile_star2_O2/uobikiemukot[P]yaft/./ctrlseq/csi.h
// Function: erase_line
void erase_line(struct terminal_t *term, struct parm_t *parm)
{
	int i, mode;

	mode = (parm->argc <= 0) ? 0: dec2num(parm->argv[parm->argc - 1]);

	if (mode < 0 || 2 < mode)
		return;

	if (mode == 0) {
		for (i = term->cursor.x; i < term->cols; i++)
			erase_cell(term, term->cursor.y, i);
	} else if (mode == 1) {
		for (i = 0; i <= term->cursor.x; i++)
			erase_cell(term, term->cursor.y, i);
	} else if (mode == 2) {
		for (i = 0; i < term->cols; i++)
			erase_cell(term, term->cursor.y, i);
	}
}

// Assembly:
pushq %rbp
pushq %rbx
pushq %rax
movq %rdi, %rbx
movl (%rsi), %eax
testl %eax, %eax
jle 0x46f1
decl %eax
movq 0x8(%rsi,%rax,8), %rdi
callq 0x2dd7
cmpl $0x2, %eax
ja 0x46ea
testl %eax, %eax
je 0x46f1
xorl %ebp, %ebp
cmpl $0x1, %eax
je 0x46e2
cmpl 0xc(%rbx), %ebp
jge 0x46ea
movzwl 0x26(%rbx), %esi
movq %rbx, %rdi
movl %ebp, %edx
callq 0x3a0e
incl %ebp
jmp 0x46bb
movzwl 0x26(%rbx), %esi
movq %rbx, %rdi
movl %ebp, %edx
callq 0x3a0e
incl %ebp
movzwl 0x24(%rbx), %eax
cmpl %eax, %ebp
jbe 0x46d2
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
movzwl 0x24(%rbx), %ebp
cmpl 0xc(%rbx), %ebp
jge 0x46ea
movzwl 0x26(%rbx), %esi
movq %rbx, %rdi
movl %ebp, %edx
callq 0x3a0e
incl %ebp
jmp 0x46f5
// File: /workspace/github_c_makefile_star2_O2/uobikiemukot[P]yaft/./ctrlseq/csi.h
// Function: insert_line
void insert_line(struct terminal_t *term, struct parm_t *parm)
{
	int num = sum(parm);

	if (term->mode & MODE_ORIGIN) {
		if (term->cursor.y < term->scroll.top
			|| term->cursor.y > term->scroll.bottom)
			return;
	}

	if (num <= 0)
		num = 1;

	scroll(term, term->cursor.y, term->scroll.bottom, -num);
}

// Assembly:
pushq %rbx
movq %rdi, %rbx
movq %rsi, %rdi
callq 0x2e07
movzwl 0x26(%rbx), %esi
testb $0x1, 0x38(%rbx)
jne 0x473d
movzwl 0x22(%rbx), %edx
cmpl $0x2, %eax
pushq $0x1
popq %rcx
cmovgel %eax, %ecx
movzwl %dx, %edx
negl %ecx
movq %rbx, %rdi
popq %rbx
jmp 0x3c03
cmpw 0x20(%rbx), %si
jb 0x474c
movzwl 0x22(%rbx), %edx
cmpw %dx, %si
jbe 0x4726
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O2/uobikiemukot[P]yaft/./ctrlseq/csi.h
// Function: delete_line
void delete_line(struct terminal_t *term, struct parm_t *parm)
{
	int num = sum(parm);

	if (term->mode & MODE_ORIGIN) {
		if (term->cursor.y < term->scroll.top
			|| term->cursor.y > term->scroll.bottom)
			return;
	}

	if (num <= 0)
		num = 1;

	scroll(term, term->cursor.y, term->scroll.bottom, num);
}

// Assembly:
pushq %rbx
movq %rdi, %rbx
movq %rsi, %rdi
callq 0x2e07
movzwl 0x26(%rbx), %esi
testb $0x1, 0x38(%rbx)
jne 0x477d
movzwl 0x22(%rbx), %edx
cmpl $0x2, %eax
pushq $0x1
popq %rcx
cmovgel %eax, %ecx
movzwl %dx, %edx
movq %rbx, %rdi
popq %rbx
jmp 0x3c03
cmpw 0x20(%rbx), %si
jb 0x478c
movzwl 0x22(%rbx), %edx
cmpw %dx, %si
jbe 0x4768
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O2/uobikiemukot[P]yaft/./ctrlseq/csi.h
// Function: delete_char
void delete_char(struct terminal_t *term, struct parm_t *parm)
{
	int i, num = sum(parm);

	if (num <= 0)
		num = 1;

	for (i = term->cursor.x; i < term->cols; i++) {
		if ((i + num) < term->cols)
			copy_cell(term, term->cursor.y, i, term->cursor.y, i + num);
		else
			erase_cell(term, term->cursor.y, i);
	}
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rdi, %rbx
movq %rsi, %rdi
callq 0x2e07
cmpl $0x2, %eax
pushq $0x1
popq %r15
cmovgel %eax, %r15d
movzwl 0x24(%rbx), %r14d
movl 0xc(%rbx), %eax
cmpl %eax, %r14d
jge 0x47dc
leal (%r15,%r14), %r8d
movzwl 0x26(%rbx), %esi
movq %rbx, %rdi
movl %r14d, %edx
cmpl %eax, %r8d
jge 0x47d2
movl %esi, %ecx
callq 0x3a54
jmp 0x47d7
callq 0x3a0e
incl %r14d
jmp 0x47ae
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O2/uobikiemukot[P]yaft/./ctrlseq/csi.h
// Function: erase_char
void erase_char(struct terminal_t *term, struct parm_t *parm)
{
	int i, num = sum(parm);

	if (num <= 0)
		num = 1;
	else if (num + term->cursor.x > term->cols)
		num = term->cols - term->cursor.x;

	for (i = term->cursor.x; i < term->cursor.x + num; i++)
		erase_cell(term, term->cursor.y, i);
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
movq %rdi, %rbx
movq %rsi, %rdi
callq 0x2e07
movzwl 0x24(%rbx), %ecx
movzwl %cx, %r14d
testl %eax, %eax
jle 0x4810
leal (%rax,%r14), %edx
movl 0xc(%rbx), %esi
movl %esi, %ebp
subl %r14d, %ebp
cmpl %esi, %edx
cmovlel %eax, %ebp
jmp 0x482b
pushq $0x1
popq %rbp
jmp 0x482b
movzwl 0x26(%rbx), %esi
movq %rbx, %rdi
movl %r14d, %edx
callq 0x3a0e
incl %r14d
movzwl 0x24(%rbx), %ecx
movzwl %cx, %eax
addl %ebp, %eax
cmpl %eax, %r14d
jl 0x4815
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/uobikiemukot[P]yaft/./ctrlseq/csi.h
// Function: status_report
void status_report(struct terminal_t *term, struct parm_t *parm)
{
	int i, num;
	char buf[BUFSIZE];

	for (i = 0; i < parm->argc; i++) {
		num = dec2num(parm->argv[i]);
		if (num == 5) {         /* terminal response: ready */
			ewrite(term->fd, "\033[0n", 4);
		} else if (num == 6) {  /* cursor position report */
			snprintf(buf, BUFSIZE, "\033[%d;%dR", term->cursor.y + 1, term->cursor.x + 1);
			ewrite(term->fd, buf, strlen(buf));
		} else if (num == 15) { /* terminal response: printer not connected */
			ewrite(term->fd, "\033[?13n", 6);
		}
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x408, %rsp            # imm = 0x408
movq %rsi, %rbx
movq %rdi, %r14
movq %rsp, %rbp
pushq $0x4
popq %r12
xorl %r15d, %r15d
movslq (%rbx), %rax
cmpq %rax, %r15
jge 0x4c1f
movq 0x8(%rbx,%r15,8), %rdi
callq 0x2dd7
cmpl $0xf, %eax
je 0x4c05
cmpl $0x6, %eax
je 0x4bca
cmpl $0x5, %eax
jne 0x4c17
movl (%r14), %edi
leaq 0x4d045(%rip), %rsi     # 0x51c0a
movq %r12, %rdx
jmp 0x4c12
movzwl 0x26(%r14), %ecx
incl %ecx
movzwl 0x24(%r14), %r8d
incl %r8d
movl $0x400, %esi            # imm = 0x400
movq %rbp, %rdi
leaq 0x4d027(%rip), %rdx     # 0x51c0f
xorl %eax, %eax
callq 0x2110
movl (%r14), %r13d
movq %rbp, %rdi
callq 0x20d0
movl %r13d, %edi
movq %rbp, %rsi
movq %rax, %rdx
jmp 0x4c12
movl (%r14), %edi
leaq 0x4d009(%rip), %rsi     # 0x51c18
pushq $0x6
popq %rdx
callq 0x283d
incq %r15
jmp 0x4b9a
addq $0x408, %rsp            # imm = 0x408
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/uobikiemukot[P]yaft/./ctrlseq/csi.h
// Function: set_mode
void set_mode(struct terminal_t *term, struct parm_t *parm)
{
	int i, mode;

	for (i = 0; i < parm->argc; i++) {
		mode = dec2num(parm->argv[i]);
		if (*(term->esc.buf + 1) != '?')
			continue; /* not supported */

		if (mode == 6) { /* private mode */
			term->mode |= MODE_ORIGIN;
			set_cursor(term, 0, 0);
		} else if (mode == 7) {
			term->mode |= MODE_AMRIGHT;
		} else if (mode == 25) {
			term->mode |= MODE_CURSOR;
		} else if (mode == 8901) {
			term->mode |= MODE_VWBS;
		}
	}

}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rsi, %rbx
movq %rdi, %r14
xorl %r15d, %r15d
movslq (%rbx), %rax
cmpq %rax, %r15
jge 0x4cad
movq 0x8(%rbx,%r15,8), %rdi
callq 0x2dd7
movq 0x68(%r14), %rcx
cmpb $0x3f, 0x1(%rcx)
jne 0x4ca8
cmpl $0x22c5, %eax           # imm = 0x22C5
je 0x4ca3
cmpl $0x7, %eax
je 0x4c95
cmpl $0x19, %eax
je 0x4c9c
cmpl $0x6, %eax
jne 0x4ca8
orb $0x1, 0x38(%r14)
movq %r14, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x3dae
jmp 0x4ca8
orb $0x4, 0x38(%r14)
jmp 0x4ca8
orb $0x2, 0x38(%r14)
jmp 0x4ca8
orb $0x8, 0x38(%r14)
incq %r15
jmp 0x4c50
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O2/uobikiemukot[P]yaft/./ctrlseq/csi.h
// Function: reset_mode
void reset_mode(struct terminal_t *term, struct parm_t *parm)
{
	int i, mode;

	for (i = 0; i < parm->argc; i++) {
		mode = dec2num(parm->argv[i]);
		if (*(term->esc.buf + 1) != '?')
			continue; /* not supported */

		if (mode == 6) { /* private mode */
			term->mode &= ~MODE_ORIGIN;
			set_cursor(term, 0, 0);
		} else if (mode == 7) {
			term->mode &= ~MODE_AMRIGHT;
			term->wrap_occurred = false;
		} else if (mode == 25) {
			term->mode &= ~MODE_CURSOR;
		} else if (mode == 8901) {
			term->mode &= ~MODE_VWBS;
		}
	}

}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rsi, %rbx
movq %rdi, %r14
xorl %r15d, %r15d
movslq (%rbx), %rax
cmpq %rax, %r15
jge 0x4d23
movq 0x8(%rbx,%r15,8), %rdi
callq 0x2dd7
movq 0x68(%r14), %rcx
cmpb $0x3f, 0x1(%rcx)
jne 0x4d1e
cmpl $0x22c5, %eax           # imm = 0x22C5
je 0x4d19
cmpl $0x7, %eax
je 0x4d06
cmpl $0x19, %eax
je 0x4d12
cmpl $0x6, %eax
jne 0x4d1e
andb $-0x2, 0x38(%r14)
movq %r14, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x3dae
jmp 0x4d1e
andb $-0x5, 0x38(%r14)
movb $0x0, 0x3c(%r14)
jmp 0x4d1e
andb $-0x3, 0x38(%r14)
jmp 0x4d1e
andb $-0x9, 0x38(%r14)
incq %r15
jmp 0x4cc1
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O2/uobikiemukot[P]yaft/./ctrlseq/csi.h
// Function: set_margin
void set_margin(struct terminal_t *term, struct parm_t *parm)
{
	int top, bottom;

	if (parm->argc <= 0) {        /* CSI r */
		top    = 0;
		bottom = term->lines - 1;
	} else if (parm->argc == 2) { /* CSI ; r -> use default value */
		top    = (parm->argv[0] == NULL) ? 0: dec2num(parm->argv[0]) - 1;
		bottom = (parm->argv[1] == NULL) ? term->lines - 1: dec2num(parm->argv[1]) - 1;
	} else {
		return;
	}

	if (top < 0 || top >= term->lines)
		top = 0;
	if (bottom < 0 || bottom >= term->lines)
		bottom = term->lines - 1;

	if (top >= bottom)
		return;

	term->scroll.top = top;
	term->scroll.bottom = bottom;

	set_cursor(term, 0, 0); /* move cursor to home */
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
movq %rdi, %rbx
movl (%rsi), %eax
testl %eax, %eax
jle 0x4d52
cmpl $0x2, %eax
jne 0x4dab
movq %rsi, %r14
movq 0x8(%rsi), %rdi
testq %rdi, %rdi
je 0x4d5b
callq 0x2dd7
movl %eax, %ebp
decl %ebp
jmp 0x4d5d
movl 0x10(%rbx), %edx
xorl %ebp, %ebp
movl %edx, %eax
jmp 0x4d77
xorl %ebp, %ebp
movq 0x10(%r14), %rdi
testq %rdi, %rdi
je 0x4d6d
callq 0x2dd7
jmp 0x4d70
movl 0x10(%rbx), %eax
testl %ebp, %ebp
js 0x4db0
movl 0x10(%rbx), %edx
xorl %ecx, %ecx
cmpl %edx, %ebp
cmovll %ebp, %ecx
movl 0x10(%rbx), %esi
cmpl %esi, %eax
movl %esi, %edx
cmovll %eax, %edx
testl %eax, %eax
cmovlel %esi, %edx
decl %edx
cmpl %edx, %ecx
jge 0x4dab
movw %cx, 0x20(%rbx)
movw %dx, 0x22(%rbx)
movq %rbx, %rdi
xorl %esi, %esi
xorl %edx, %edx
popq %rbx
popq %r14
popq %rbp
jmp 0x3dae
popq %rbx
popq %r14
popq %rbp
retq
xorl %ecx, %ecx
jmp 0x4d7e
// File: /workspace/github_c_makefile_star2_O2/uobikiemukot[P]yaft/./ctrlseq/csi.h
// Function: clear_tabstop
void clear_tabstop(struct terminal_t *term, struct parm_t *parm)
{
	int i, j, num;

	if (parm->argc <= 0) {
		term->tabstop[term->cursor.x] = false;
	} else {
		for (i = 0; i < parm->argc; i++) {
			num = dec2num(parm->argv[i]);
			if (num == 0) {
				term->tabstop[term->cursor.x] = false;
			} else if (num == 3) {
				for (j = 0; j < term->cols; j++)
					term->tabstop[j] = false;
				return;
			}
		}
	}
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rdi, %rbx
movl (%rsi), %eax
testl %eax, %eax
jle 0x4df8
movq %rsi, %r14
xorl %r15d, %r15d
cltq
cmpq %rax, %r15
jge 0x4e04
movq 0x8(%r14,%r15,8), %rdi
callq 0x2dd7
testl %eax, %eax
je 0x4de4
cmpl $0x3, %eax
jne 0x4df0
jmp 0x4e0a
movq 0x30(%rbx), %rax
movzwl 0x24(%rbx), %ecx
movb $0x0, (%rax,%rcx)
incq %r15
movl (%r14), %eax
jmp 0x4dc8
movq 0x30(%rbx), %rax
movzwl 0x24(%rbx), %ecx
movb $0x0, (%rax,%rcx)
popq %rbx
popq %r14
popq %r15
retq
movl 0xc(%rbx), %eax
xorl %ecx, %ecx
testl %eax, %eax
cmovlel %ecx, %eax
cmpq %rcx, %rax
je 0x4e04
movq 0x30(%rbx), %rdx
movb $0x0, (%rdx,%rcx)
incq %rcx
jmp 0x4e14