// File: /workspace/github_c_makefile_star2_O0/uobikiemukot[P]yaft/./fb/common.h
// Function: draw_line
static inline void draw_line(struct framebuffer_t *fb, struct terminal_t *term, int line)
{
	int pos, size, bdf_padding, glyph_width, margin_right;
	int col, w, h;
	uint32_t pixel;
	struct color_pair_t color_pair;
	struct cell_t *cellp;

	for (col = term->cols - 1; col >= 0; col--) {
		margin_right = (term->cols - 1 - col) * CELL_WIDTH;

		/* target cell */
		cellp = &term->cells[line][col];

		/* draw sixel pixmap */
		if (cellp->has_pixmap) {
			draw_sixel(fb, line, col, cellp->pixmap);
			continue;
		}

		/* copy current color_pair (maybe changed) */
		color_pair = cellp->color_pair;

		/* check wide character or not */
		glyph_width = (cellp->width == HALF) ? CELL_WIDTH: CELL_WIDTH * 2;
		bdf_padding = my_ceil(glyph_width, BITS_PER_BYTE) * BITS_PER_BYTE - glyph_width;
		if (cellp->width == WIDE)
			bdf_padding += CELL_WIDTH;

		/* check cursor position */
		if ((term->mode & MODE_CURSOR && line == term->cursor.y)
			&& (col == term->cursor.x
			|| (cellp->width == WIDE && (col + 1) == term->cursor.x)
			|| (cellp->width == NEXT_TO_WIDE && (col - 1) == term->cursor.x))) {
			color_pair.fg = DEFAULT_BG;
			color_pair.bg = (!vt_active && BACKGROUND_DRAW) ? PASSIVE_CURSOR_COLOR: ACTIVE_CURSOR_COLOR;
		}

		for (h = 0; h < CELL_HEIGHT; h++) {
			/* if UNDERLINE attribute on, swap bg/fg */
			if ((h == (CELL_HEIGHT - 1)) && (cellp->attribute & attr_mask[ATTR_UNDERLINE]))
				color_pair.bg = color_pair.fg;

			for (w = 0; w < CELL_WIDTH; w++) {
				pos = (term->width - 1 - margin_right - w) * fb->info.bytes_per_pixel
					+ (line * CELL_HEIGHT + h) * fb->info.line_length;

				/* set color palette */
				if (cellp->glyphp->bitmap[h] & (0x01 << (bdf_padding + w)))
					pixel = fb->real_palette[color_pair.fg];
				else if (fb->wall && color_pair.bg == DEFAULT_BG) /* wallpaper */
					memcpy(&pixel, fb->wall + pos, fb->info.bytes_per_pixel);
				else
					pixel = fb->real_palette[color_pair.bg];

				/* update copy buffer only */
				memcpy(fb->buf + pos, &pixel, fb->info.bytes_per_pixel);
			}
		}
	}

	/* actual display update (bit blit) */
	pos = (line * CELL_HEIGHT) * fb->info.line_length;
	size = CELL_HEIGHT * fb->info.line_length;
	memcpy(fb->fp + pos, fb->buf + pos, size);

	/* TODO: page flip
		if fb_fix_screeninfo.ypanstep > 0, we can use hardware panning.
		set fb_fix_screeninfo.{yres_virtual,yoffset} and call ioctl(FBIOPAN_DISPLAY)
		but drivers  of recent hardware (inteldrmfb, nouveaufb, radeonfb) don't support...
		(maybe we can use this by using libdrm) */
	/* TODO: vertical synchronizing */

	term->line_dirty[line] = ((term->mode & MODE_CURSOR) && term->cursor.y == line) ? true: false;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movq -0x10(%rbp), %rax
movl 0xc(%rax), %eax
subl $0x1, %eax
movl %eax, -0x2c(%rbp)
cmpl $0x0, -0x2c(%rbp)
jl 0x4647
movq -0x10(%rbp), %rax
movl 0xc(%rax), %eax
subl $0x1, %eax
subl -0x2c(%rbp), %eax
shll $0x3, %eax
movl %eax, -0x28(%rbp)
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rax
movslq -0x14(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x2c(%rbp), %rcx
imulq $0x218, %rcx, %rcx      # imm = 0x218
addq %rcx, %rax
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rax
testb $0x1, 0x14(%rax)
je 0x4415
movq -0x8(%rbp), %rdi
movl -0x14(%rbp), %esi
movl -0x2c(%rbp), %edx
movq -0x48(%rbp), %rcx
addq $0x15, %rcx
callq 0x9e70
jmp 0x4639
movq -0x48(%rbp), %rax
movw 0x8(%rax), %ax
movw %ax, -0x3a(%rbp)
movq -0x48(%rbp), %rax
movl 0x10(%rax), %edx
movl $0x10, %eax
movl $0x8, %ecx
cmpl $0x1, %edx
cmovel %ecx, %eax
movl %eax, -0x24(%rbp)
movl -0x24(%rbp), %edi
movl $0x8, %esi
callq 0x3180
shll $0x3, %eax
subl -0x24(%rbp), %eax
movl %eax, -0x20(%rbp)
movq -0x48(%rbp), %rax
cmpl $0x2, 0x10(%rax)
jne 0x4464
movl -0x20(%rbp), %eax
addl $0x8, %eax
movl %eax, -0x20(%rbp)
movq -0x10(%rbp), %rax
movl 0x38(%rax), %eax
andl $0x2, %eax
cmpl $0x0, %eax
je 0x44fe
movl -0x14(%rbp), %eax
movq -0x10(%rbp), %rcx
movzwl 0x26(%rcx), %ecx
cmpl %ecx, %eax
jne 0x44fe
movl -0x2c(%rbp), %eax
movq -0x10(%rbp), %rcx
movzwl 0x24(%rcx), %ecx
cmpl %ecx, %eax
je 0x44cd
movq -0x48(%rbp), %rax
cmpl $0x2, 0x10(%rax)
jne 0x44b1
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movq -0x10(%rbp), %rcx
movzwl 0x24(%rcx), %ecx
cmpl %ecx, %eax
je 0x44cd
movq -0x48(%rbp), %rax
cmpl $0x0, 0x10(%rax)
jne 0x44fe
movl -0x2c(%rbp), %eax
subl $0x1, %eax
movq -0x10(%rbp), %rcx
movzwl 0x24(%rcx), %ecx
cmpl %ecx, %eax
jne 0x44fe
movb $0x0, -0x3a(%rbp)
movl 0x54ce9(%rip), %ecx     # 0x591c0
xorl %eax, %eax
cmpl $0x0, %ecx
movb %al, -0x49(%rbp)
jne 0x44e8
xorl %eax, %eax
movb %al, -0x49(%rbp)
jmp 0x44e8
movb -0x49(%rbp), %dl
movl $0x2, %eax
movl $0x1, %ecx
testb $0x1, %dl
cmovnel %ecx, %eax
movb %al, -0x39(%rbp)
movl $0x0, -0x34(%rbp)
cmpl $0x10, -0x34(%rbp)
jge 0x4637
cmpl $0xf, -0x34(%rbp)
jne 0x4530
movq -0x48(%rbp), %rax
movl 0xc(%rax), %eax
movzbl 0x6ef1(%rip), %ecx      # 0xb414
andl %ecx, %eax
cmpl $0x0, %eax
je 0x4530
movb -0x3a(%rbp), %al
movb %al, -0x39(%rbp)
movl $0x0, -0x30(%rbp)
cmpl $0x8, -0x30(%rbp)
jge 0x4627
movq -0x10(%rbp), %rax
movl 0x4(%rax), %eax
subl $0x1, %eax
subl -0x28(%rbp), %eax
subl -0x30(%rbp), %eax
movq -0x8(%rbp), %rcx
imull 0x44c(%rcx), %eax
movl -0x14(%rbp), %ecx
shll $0x4, %ecx
addl -0x34(%rbp), %ecx
movq -0x8(%rbp), %rdx
imull 0x448(%rdx), %ecx
addl %ecx, %eax
movl %eax, -0x18(%rbp)
movq -0x48(%rbp), %rax
movq (%rax), %rax
movslq -0x34(%rbp), %rcx
movzwl 0x6(%rax,%rcx,2), %eax
movl -0x20(%rbp), %ecx
addl -0x30(%rbp), %ecx
movl $0x1, %edx
shll %cl, %edx
movl %edx, %ecx
andl %ecx, %eax
cmpl $0x0, %eax
je 0x45ac
movq -0x8(%rbp), %rax
movzbl -0x3a(%rbp), %ecx
movl 0x20(%rax,%rcx,4), %eax
movl %eax, -0x38(%rbp)
jmp 0x45f6
movq -0x8(%rbp), %rax
cmpq $0x0, 0x18(%rax)
je 0x45e5
movzbl -0x39(%rbp), %eax
cmpl $0x0, %eax
jne 0x45e5
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rsi
movslq -0x18(%rbp), %rax
addq %rax, %rsi
movq -0x8(%rbp), %rax
movslq 0x44c(%rax), %rdx
leaq -0x38(%rbp), %rdi
callq 0x21c0
jmp 0x45f4
movq -0x8(%rbp), %rax
movzbl -0x39(%rbp), %ecx
movl 0x20(%rax,%rcx,4), %eax
movl %eax, -0x38(%rbp)
jmp 0x45f6
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rdi
movslq -0x18(%rbp), %rax
addq %rax, %rdi
movq -0x8(%rbp), %rax
movslq 0x44c(%rax), %rdx
leaq -0x38(%rbp), %rsi
callq 0x21c0
movl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
jmp 0x4537
jmp 0x4629
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x4505
jmp 0x4639
movl -0x2c(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x43b0
movl -0x14(%rbp), %eax
shll $0x4, %eax
movq -0x8(%rbp), %rcx
imull 0x448(%rcx), %eax
movl %eax, -0x18(%rbp)
movq -0x8(%rbp), %rax
movl 0x448(%rax), %eax
shll $0x4, %eax
movl %eax, -0x1c(%rbp)
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rdi
movslq -0x18(%rbp), %rax
addq %rax, %rdi
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rsi
movslq -0x18(%rbp), %rax
addq %rax, %rsi
movslq -0x1c(%rbp), %rdx
callq 0x21c0
movq -0x10(%rbp), %rax
movl 0x38(%rax), %ecx
andl $0x2, %ecx
xorl %eax, %eax
cmpl $0x0, %ecx
movb %al, -0x4a(%rbp)
je 0x46b7
movq -0x10(%rbp), %rax
movzwl 0x26(%rax), %eax
cmpl -0x14(%rbp), %eax
sete %al
movb %al, -0x4a(%rbp)
movb -0x4a(%rbp), %dl
xorl %eax, %eax
movl $0x1, %ecx
testb $0x1, %dl
cmovnel %ecx, %eax
cmpl $0x0, %eax
setne %dl
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rax
movslq -0x14(%rbp), %rcx
andb $0x1, %dl
movb %dl, (%rax,%rcx)
addq $0x50, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)