// File: /workspace/github_c_makefile_star2_O0/jsummers[P]deark/modules/gif.c
// Function: do_plaintext_ext_header
static void do_plaintext_ext_header(deark *c, lctx *d, struct plaintext_ext_ctx *ctx,
	dbuf *inf, i64 pos1, i64 len)
{
	u8 fgclr_idx, bgclr_idx;
	i64 pos = pos1;

	if(len<12) goto done;

	if(d->gce) {
		ctx->disposal_method = d->gce->disposal_method;
	}

	ctx->textarea_xpos_in_pixels = dbuf_getu16le(inf, pos);
	ctx->textarea_ypos_in_pixels = dbuf_getu16le(inf, pos+2);
	ctx->textarea_xsize_in_pixels = dbuf_getu16le(inf, pos+4);
	ctx->textarea_ysize_in_pixels = dbuf_getu16le(inf, pos+6);
	ctx->char_width = (i64)dbuf_getbyte(inf, pos+8);
	ctx->char_height = (i64)dbuf_getbyte(inf, pos+9);
	de_dbg(c, "text-area pos: %d,%d pixels", (int)ctx->textarea_xpos_in_pixels,
		(int)ctx->textarea_ypos_in_pixels);
	de_dbg(c, "text-area size: %d"DE_CHAR_TIMES"%d pixels", (int)ctx->textarea_xsize_in_pixels,
		(int)ctx->textarea_ysize_in_pixels);
	de_dbg(c, "character size: %d"DE_CHAR_TIMES"%d pixels", (int)ctx->char_width, (int)ctx->char_height);

	if(ctx->char_width<3 || ctx->char_height<3) {
		ctx->ok_to_render = 0;
	}

	if(ctx->char_width>0) {
		ctx->text_width_in_chars = ctx->textarea_xsize_in_pixels / ctx->char_width;
		if(ctx->text_width_in_chars<1) {
			ctx->ok_to_render = 0;
			ctx->text_width_in_chars = 1;
		}
	}
	else {
		ctx->text_width_in_chars = 80;
	}
	de_dbg(c, "calculated chars/line: %d", (int)ctx->text_width_in_chars);

	fgclr_idx = dbuf_getbyte(inf, pos+10);
	decode_text_color(c, d, "fg", fgclr_idx, &ctx->fgclr);
	bgclr_idx = dbuf_getbyte(inf, pos+11);
	decode_text_color(c, d, "bg", bgclr_idx, &ctx->bgclr);

	if(d->dump_plaintext_ext) {
		ctx->outf_txt = dbuf_create_output_file(c, "plaintext.txt", NULL, 0);
	}

	if(ctx->ok_to_render && (ctx->disposal_method==DISPOSE_PREVIOUS)) {
		i64 tmpw, tmph;
		// We need to save a copy of the pixels that may be overwritten.
		tmpw = ctx->textarea_xsize_in_pixels;
		if(tmpw>d->screen_w) tmpw = d->screen_w;
		tmph = ctx->textarea_ysize_in_pixels;
		if(tmph>d->screen_h) tmph = d->screen_h;
		ctx->prev_img = de_bitmap_create(c, tmpw, tmph, 4);
		de_bitmap_copy_rect(d->screen_img, ctx->prev_img,
			ctx->textarea_xpos_in_pixels, ctx->textarea_ypos_in_pixels,
			tmpw, tmph, 0, 0, 0);
	}

	ctx->cur_xpos_in_chars = 0;
	ctx->cur_ypos_in_chars = 0;

	ctx->header_ok = 1;
done:
	;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
movq %r9, -0x30(%rbp)
movq -0x28(%rbp), %rax
movq %rax, -0x40(%rbp)
cmpq $0xc, -0x30(%rbp)
jge 0x73f04
jmp 0x74267
movq -0x10(%rbp), %rax
cmpq $0x0, 0x440(%rax)
je 0x73f26
movq -0x10(%rbp), %rax
movq 0x440(%rax), %rax
movb (%rax), %cl
movq -0x18(%rbp), %rax
movb %cl, 0x58(%rax)
movq -0x20(%rbp), %rdi
movq -0x40(%rbp), %rsi
callq 0x165280
movq %rax, %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x20(%rbp), %rdi
movq -0x40(%rbp), %rsi
addq $0x2, %rsi
callq 0x165280
movq %rax, %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x20(%rbp), %rdi
movq -0x40(%rbp), %rsi
addq $0x4, %rsi
callq 0x165280
movq %rax, %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x18(%rax)
movq -0x20(%rbp), %rdi
movq -0x40(%rbp), %rsi
addq $0x6, %rsi
callq 0x165280
movq %rax, %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x20(%rax)
movq -0x20(%rbp), %rdi
movq -0x40(%rbp), %rsi
addq $0x8, %rsi
callq 0x165060
movzbl %al, %eax
movl %eax, %ecx
movq -0x18(%rbp), %rax
movq %rcx, 0x30(%rax)
movq -0x20(%rbp), %rdi
movq -0x40(%rbp), %rsi
addq $0x9, %rsi
callq 0x165060
movzbl %al, %eax
movl %eax, %ecx
movq -0x18(%rbp), %rax
movq %rcx, 0x38(%rax)
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rax
movl %eax, %edx
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rax
movl %eax, %ecx
leaq 0x137824(%rip), %rsi    # 0x1ab811
movb $0x0, %al
callq 0x15b0d0
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rax
movq 0x18(%rax), %rax
movl %eax, %edx
movq -0x18(%rbp), %rax
movq 0x20(%rax), %rax
movl %eax, %ecx
leaq 0x13781a(%rip), %rsi    # 0x1ab82d
movb $0x0, %al
callq 0x15b0d0
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rax
movq 0x30(%rax), %rax
movl %eax, %edx
movq -0x18(%rbp), %rax
movq 0x38(%rax), %rax
movl %eax, %ecx
leaq 0x137812(%rip), %rsi    # 0x1ab84b
movb $0x0, %al
callq 0x15b0d0
movq -0x18(%rbp), %rax
cmpq $0x3, 0x30(%rax)
jl 0x74056
movq -0x18(%rbp), %rax
cmpq $0x3, 0x38(%rax)
jge 0x74061
movq -0x18(%rbp), %rax
movl $0x0, 0x4(%rax)
movq -0x18(%rbp), %rax
cmpq $0x0, 0x30(%rax)
jle 0x740ad
movq -0x18(%rbp), %rax
movq 0x18(%rax), %rax
movq -0x18(%rbp), %rcx
cqto
idivq 0x30(%rcx)
movq %rax, %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x28(%rax)
movq -0x18(%rbp), %rax
cmpq $0x1, 0x28(%rax)
jge 0x740ab
movq -0x18(%rbp), %rax
movl $0x0, 0x4(%rax)
movq -0x18(%rbp), %rax
movq $0x1, 0x28(%rax)
jmp 0x740b9
movq -0x18(%rbp), %rax
movq $0x50, 0x28(%rax)
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rax
movq 0x28(%rax), %rax
movl %eax, %edx
leaq 0x13779b(%rip), %rsi    # 0x1ab869
movb $0x0, %al
callq 0x15b0d0
movq -0x20(%rbp), %rdi
movq -0x40(%rbp), %rsi
addq $0xa, %rsi
callq 0x165060
movb %al, -0x31(%rbp)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movb -0x31(%rbp), %al
movq -0x18(%rbp), %r8
addq $0x50, %r8
leaq 0x129d5d(%rip), %rdx    # 0x19de60
movzbl %al, %ecx
callq 0x743f0
movq -0x20(%rbp), %rdi
movq -0x40(%rbp), %rsi
addq $0xb, %rsi
callq 0x165060
movb %al, -0x32(%rbp)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movb -0x32(%rbp), %al
movq -0x18(%rbp), %r8
addq $0x54, %r8
leaq 0x13e13d(%rip), %rdx    # 0x1b2276
movzbl %al, %ecx
callq 0x743f0
movq -0x10(%rbp), %rax
cmpl $0x0, 0xc(%rax)
je 0x7416c
movq -0x8(%rbp), %rdi
leaq 0x13772d(%rip), %rsi    # 0x1ab883
xorl %eax, %eax
movl %eax, %edx
xorl %ecx, %ecx
callq 0x166c60
movq %rax, %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x68(%rax)
movq -0x18(%rbp), %rax
cmpl $0x0, 0x4(%rax)
je 0x74245
movq -0x18(%rbp), %rax
movzbl 0x58(%rax), %eax
cmpl $0x3, %eax
jne 0x74245
movq -0x18(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rax
movq -0x10(%rbp), %rcx
cmpq 0x18(%rcx), %rax
jle 0x741b1
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0x48(%rbp)
movq -0x18(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rax
movq -0x10(%rbp), %rcx
cmpq 0x20(%rcx), %rax
jle 0x741d7
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0x50(%rbp)
movq -0x8(%rbp), %rdi
movq -0x48(%rbp), %rsi
movq -0x50(%rbp), %rdx
movl $0x4, %ecx
callq 0x16b750
movq %rax, %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x60(%rax)
movq -0x10(%rbp), %rax
movq 0x438(%rax), %rdi
movq -0x18(%rbp), %rax
movq 0x60(%rax), %rsi
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rdx
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rcx
movq -0x48(%rbp), %r8
movq -0x50(%rbp), %r9
xorl %eax, %eax
xorl %eax, %eax
movq $0x0, (%rsp)
movq $0x0, 0x8(%rsp)
movl $0x0, 0x10(%rsp)
callq 0x16ce50
movq -0x18(%rbp), %rax
movq $0x0, 0x40(%rax)
movq -0x18(%rbp), %rax
movq $0x0, 0x48(%rax)
movq -0x18(%rbp), %rax
movl $0x1, (%rax)
addq $0x70, %rsp
popq %rbp
retq
nopl (%rax)