// File: /workspace/github_c_makefile_star2_O0/jsummers[P]deark/modules/storyboard.c
// Function: do_oldfmt_text_main
static void do_oldfmt_text_main(deark *c, struct storyboard_ctx *d, dbuf *unc_data,
	struct de_char_context *charctx)
{
	i64 i, j;
	u8 ccode, acode;
	u8 fgcol, bgcol;
	struct de_char_screen *screen;
	struct de_encconv_state es;

	charctx->nscreens = 1;
	charctx->screens = de_mallocarray(c, charctx->nscreens, sizeof(struct de_char_screen*));
	charctx->screens[0] = de_malloc(c, sizeof(struct de_char_screen));
	screen = charctx->screens[0];
	screen->width = d->width_in_chars;
	screen->height = d->height_in_chars;
	screen->cell_rows = de_mallocarray(c, d->height_in_chars, sizeof(struct de_char_cell*));
	de_encconv_init(&es, d->input_encoding);

	for(j=0; j<d->height_in_chars; j++) {
		screen->cell_rows[j] = de_mallocarray(c, d->width_in_chars, sizeof(struct de_char_cell));

		for(i=0; i<d->width_in_chars; i++) {
			ccode = dbuf_getbyte(unc_data, j*d->width_in_chars + i);
			acode = dbuf_getbyte(unc_data, d->attribs_pos + j*d->width_in_chars + i);

			fgcol = (acode & 0x0f);
			bgcol = acode >> 4;

			screen->cell_rows[j][i].fgcol = (u32)fgcol;
			screen->cell_rows[j][i].bgcol = (u32)bgcol;
			screen->cell_rows[j][i].codepoint = (i32)ccode;
			screen->cell_rows[j][i].codepoint_unicode = de_char_to_unicode_ex((i32)ccode, &es);
		}
	}

	de_char_output_to_file(c, charctx);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq -0x20(%rbp), %rax
movq $0x1, 0x10(%rax)
movq -0x8(%rbp), %rdi
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rsi
movl $0x8, %edx
callq 0x15c450
movq %rax, %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x18(%rax)
movq -0x8(%rbp), %rdi
movl $0x18, %esi
callq 0x15b780
movq %rax, %rcx
movq -0x20(%rbp), %rax
movq 0x18(%rax), %rax
movq %rcx, (%rax)
movq -0x20(%rbp), %rax
movq 0x18(%rax), %rax
movq (%rax), %rax
movq %rax, -0x40(%rbp)
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rcx
movq -0x40(%rbp), %rax
movq %rcx, (%rax)
movq -0x10(%rbp), %rax
movq 0x30(%rax), %rcx
movq -0x40(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x30(%rax), %rsi
movl $0x8, %edx
callq 0x15c450
movq %rax, %rcx
movq -0x40(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x10(%rbp), %rax
movl (%rax), %esi
leaq -0x60(%rbp), %rdi
callq 0x160150
movq $0x0, -0x30(%rbp)
movq -0x30(%rbp), %rax
movq -0x10(%rbp), %rcx
cmpq 0x30(%rcx), %rax
jge 0x15870f
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rsi
movl $0x14, %edx
callq 0x15c450
movq %rax, %rdx
movq -0x40(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x30(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
movq $0x0, -0x28(%rbp)
movq -0x28(%rbp), %rax
movq -0x10(%rbp), %rcx
cmpq 0x28(%rcx), %rax
jge 0x1586fc
movq -0x18(%rbp), %rdi
movq -0x30(%rbp), %rsi
movq -0x10(%rbp), %rax
imulq 0x28(%rax), %rsi
addq -0x28(%rbp), %rsi
callq 0x165060
movb %al, -0x31(%rbp)
movq -0x18(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x40(%rax), %rsi
movq -0x30(%rbp), %rax
movq -0x10(%rbp), %rcx
imulq 0x28(%rcx), %rax
addq %rax, %rsi
addq -0x28(%rbp), %rsi
callq 0x165060
movb %al, -0x32(%rbp)
movzbl -0x32(%rbp), %eax
andl $0xf, %eax
movb %al, -0x33(%rbp)
movzbl -0x32(%rbp), %eax
sarl $0x4, %eax
movb %al, -0x34(%rbp)
movzbl -0x33(%rbp), %ecx
movq -0x40(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x30(%rbp), %rdx
movq (%rax,%rdx,8), %rax
imulq $0x14, -0x28(%rbp), %rdx
addq %rdx, %rax
movl %ecx, 0x8(%rax)
movzbl -0x34(%rbp), %ecx
movq -0x40(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x30(%rbp), %rdx
movq (%rax,%rdx,8), %rax
imulq $0x14, -0x28(%rbp), %rdx
addq %rdx, %rax
movl %ecx, 0xc(%rax)
movzbl -0x31(%rbp), %ecx
movq -0x40(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x30(%rbp), %rdx
movq (%rax,%rdx,8), %rax
imulq $0x14, -0x28(%rbp), %rdx
addq %rdx, %rax
movl %ecx, (%rax)
movzbl -0x31(%rbp), %edi
leaq -0x60(%rbp), %rsi
callq 0x160a30
movl %eax, %ecx
movq -0x40(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x30(%rbp), %rdx
movq (%rax,%rdx,8), %rax
imulq $0x14, -0x28(%rbp), %rdx
addq %rdx, %rax
movl %ecx, 0x4(%rax)
movq -0x28(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x28(%rbp)
jmp 0x1585fa
jmp 0x1586fe
movq -0x30(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x30(%rbp)
jmp 0x1585b7
movq -0x8(%rbp), %rdi
movq -0x20(%rbp), %rsi
callq 0x16da40
addq $0x60, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)