// File: /workspace/github_c_makefile_star2_O0/jsummers[P]deark/src/deark-char.c
// Function: do_output_html_header
static void do_output_html_header(deark *c, struct de_char_context *charctx,
	struct charextractx *ectx, dbuf *ofile)
{
	int has_metadata; // metadata other than comments

	has_metadata = charctx->title || charctx->artist || charctx->organization ||
		(charctx->creation_date.is_valid);
	if(c->write_bom && !c->ascii_html) dbuf_write_uchar_as_utf8(ofile, 0xfeff);
	dbuf_puts(ofile, "<!DOCTYPE html>\n");
	dbuf_puts(ofile, "<html>\n");
	dbuf_puts(ofile, "<head>\n");
	dbuf_printf(ofile, "<meta charset=\"%s\">\n", c->ascii_html?"US-ASCII":"UTF-8");
	dbuf_puts(ofile, "<title>");
	write_ucstring_to_html(c, charctx->title, ofile);
	dbuf_puts(ofile, "</title>\n");

	dbuf_puts(ofile, "<style type=\"text/css\">\n");

	dbuf_puts(ofile, " body { background-color: #222; background-image: url(\"data:image/png;base64,"
		"iVBORw0KGgoAAAANSUhEUgAAABAAAAAQAQMAAAAlPW0iAAAABlBMVEUgICAoKCidji3LAAAAMUlE"
		"QVQI12NgaGBgPMDA/ICB/QMD/w8G+T8M9v8Y6v8z/P8PIoFsoAhQHCgLVMN4AACOoBFvDLHV4QAA"
		"AABJRU5ErkJggg==\") }\n");

	// The table for the main graphics
	dbuf_puts(ofile, " .mt { margin-left: auto; margin-right: auto }\n");

	if(has_metadata || charctx->comment) {
		// Styles for header name and value
		// Header table <table> styles
		dbuf_puts(ofile, " .htt { width: 100%; border-collapse: collapse; background-color: #034 }\n");
		// Header table cell <td> styles
		dbuf_puts(ofile, " .htc { border: 2px solid #056; text-align: center }\n");
		if(charctx->comment) {
			// Comment table cell <td> styles
			dbuf_puts(ofile, " .hcth { border: 2px solid #056; padding-left: 0.5em; "
				"padding-right: 0.5em; width: 1px }\n");
			dbuf_puts(ofile, " .hctc { border: 2px solid #056; padding-left: 0.5em }\n");
		}
		// Header name styles
		dbuf_puts(ofile, " .hn { color: #aaa; font-style: italic }\n");
		// Header value styles
		dbuf_puts(ofile, " .hv { color: #fff }\n");
	}

	output_css_color_block(c, ofile, charctx->pal, ".f", "color", &ectx->used_fgcol[0]);
	output_css_color_block(c, ofile, charctx->pal, ".b", "background-color", &ectx->used_bgcol[0]);

	if(ectx->used_underline) {
		dbuf_puts(ofile, " .u { text-decoration: underline }\n");
	}
	if(ectx->used_strikethru) {
		dbuf_puts(ofile, " .s { text-decoration: line-through }\n");
	}

	if(ectx->used_blink) {
		dbuf_puts(ofile, " .blink {\n"
			"  animation: blink 1s steps(1) infinite;\n"
			"  -webkit-animation: blink 1s steps(1) infinite }\n"
			" @keyframes blink { 50% { color: transparent } }\n"
			" @-webkit-keyframes blink { 50% { color: transparent } }\n");
	}
	dbuf_puts(ofile, "</style>\n");

	dbuf_puts(ofile, "</head>\n");
	dbuf_puts(ofile, "<body>\n");

	if(has_metadata) {
		de_ucstring *tmps = NULL;
		dbuf_puts(ofile, "<table class=htt><tr>\n");
		print_header_item(c, ofile, "Title", charctx->title);
		print_header_item(c, ofile, "Organization", charctx->organization);
		print_header_item(c, ofile, "Artist", charctx->artist);
		tmps = ucstring_create(c);
		if(charctx->creation_date.is_valid) {
			timestamp_to_ucstring(&charctx->creation_date, tmps);
		}
		print_header_item(c, ofile, "Date", tmps);
		ucstring_destroy(tmps);
		dbuf_puts(ofile, "</tr></table>\n");
	}

	print_comments(c, charctx, ofile);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq -0x10(%rbp), %rcx
movb $0x1, %al
cmpq $0x0, 0x68(%rcx)
movb %al, -0x31(%rbp)
jne 0x16e7dc
movq -0x10(%rbp), %rcx
movb $0x1, %al
cmpq $0x0, 0x70(%rcx)
movb %al, -0x31(%rbp)
jne 0x16e7dc
movq -0x10(%rbp), %rcx
movb $0x1, %al
cmpq $0x0, 0x78(%rcx)
movb %al, -0x31(%rbp)
jne 0x16e7dc
movq -0x10(%rbp), %rax
movzbl 0x80(%rax), %eax
cmpl $0x0, %eax
setne %al
movb %al, -0x31(%rbp)
movb -0x31(%rbp), %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x24(%rbp)
movq -0x8(%rbp), %rax
movzbl 0xcc(%rax), %eax
cmpl $0x0, %eax
je 0x16e812
movq -0x8(%rbp), %rax
cmpb $0x0, 0xce(%rax)
jne 0x16e812
movq -0x20(%rbp), %rdi
movl $0xfeff, %esi           # imm = 0xFEFF
callq 0x160cc0
movq -0x20(%rbp), %rdi
leaq 0x5eaa6(%rip), %rsi     # 0x1cd2c3
callq 0x168da0
movq -0x20(%rbp), %rdi
leaq 0x5eaa7(%rip), %rsi     # 0x1cd2d4
callq 0x168da0
movq -0x20(%rbp), %rdi
leaq 0x5ea9f(%rip), %rsi     # 0x1cd2dc
callq 0x168da0
movq -0x20(%rbp), %rdi
movq -0x8(%rbp), %rax
movzbl 0xce(%rax), %ecx
leaq 0x41391(%rip), %rdx     # 0x1afbe9
leaq 0x5ea9a(%rip), %rax     # 0x1cd2f9
cmpl $0x0, %ecx
cmovneq %rax, %rdx
leaq 0x5ea77(%rip), %rsi     # 0x1cd2e4
movb $0x0, %al
callq 0x167f00
movq -0x20(%rbp), %rdi
leaq 0x66a96(%rip), %rsi     # 0x1d5315
callq 0x168da0
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x68(%rax), %rsi
movq -0x20(%rbp), %rdx
callq 0x16ef60
movq -0x20(%rbp), %rdi
leaq 0x5ea65(%rip), %rsi     # 0x1cd309
callq 0x168da0
movq -0x20(%rbp), %rdi
leaq 0x5ea5f(%rip), %rsi     # 0x1cd313
callq 0x168da0
movq -0x20(%rbp), %rdi
leaq 0x66a59(%rip), %rsi     # 0x1d531d
callq 0x168da0
movq -0x20(%rbp), %rdi
leaq 0x66b44(%rip), %rsi     # 0x1d5418
callq 0x168da0
cmpl $0x0, -0x24(%rbp)
jne 0x16e8ed
movq -0x10(%rbp), %rax
cmpq $0x0, 0x90(%rax)
je 0x16e95b
movq -0x20(%rbp), %rdi
leaq 0x66b50(%rip), %rsi     # 0x1d5448
callq 0x168da0
movq -0x20(%rbp), %rdi
leaq 0x66b8a(%rip), %rsi     # 0x1d5492
callq 0x168da0
movq -0x10(%rbp), %rax
cmpq $0x0, 0x90(%rax)
je 0x16e93b
movq -0x20(%rbp), %rdi
leaq 0x66ba2(%rip), %rsi     # 0x1d54c8
callq 0x168da0
movq -0x20(%rbp), %rdi
leaq 0x66bec(%rip), %rsi     # 0x1d5522
callq 0x168da0
movq -0x20(%rbp), %rdi
leaq 0x66c14(%rip), %rsi     # 0x1d555a
callq 0x168da0
movq -0x20(%rbp), %rdi
leaq 0x66c2e(%rip), %rsi     # 0x1d5584
callq 0x168da0
movq -0x8(%rbp), %rdi
movq -0x20(%rbp), %rsi
movq -0x10(%rbp), %rdx
addq $0x20, %rdx
movq -0x18(%rbp), %r9
addq $0x6, %r9
leaq 0x66c20(%rip), %rcx     # 0x1d559a
leaq 0x3348d(%rip), %r8      # 0x1a1e0e
callq 0x16f090
movq -0x8(%rbp), %rdi
movq -0x20(%rbp), %rsi
movq -0x10(%rbp), %rdx
addq $0x20, %rdx
movq -0x18(%rbp), %r9
addq $0x16, %r9
leaq 0x66bf8(%rip), %rcx     # 0x1d559d
leaq 0x66bf4(%rip), %r8      # 0x1d55a0
callq 0x16f090
movq -0x18(%rbp), %rax
cmpb $0x0, 0x2(%rax)
je 0x16e9cb
movq -0x20(%rbp), %rdi
leaq 0x66beb(%rip), %rsi     # 0x1d55b1
callq 0x168da0
movq -0x18(%rbp), %rax
cmpb $0x0, 0x3(%rax)
je 0x16e9e5
movq -0x20(%rbp), %rdi
leaq 0x66bf5(%rip), %rsi     # 0x1d55d5
callq 0x168da0
movq -0x18(%rbp), %rax
cmpb $0x0, 0x4(%rax)
je 0x16e9ff
movq -0x20(%rbp), %rdi
leaq 0x66c02(%rip), %rsi     # 0x1d55fc
callq 0x168da0
movq -0x20(%rbp), %rdi
leaq 0x5ea55(%rip), %rsi     # 0x1cd45f
callq 0x168da0
movq -0x20(%rbp), %rdi
leaq 0x5ea4f(%rip), %rsi     # 0x1cd469
callq 0x168da0
movq -0x20(%rbp), %rdi
leaq 0x5ea48(%rip), %rsi     # 0x1cd472
callq 0x168da0
cmpl $0x0, -0x24(%rbp)
je 0x16eb04
movq $0x0, -0x30(%rbp)
movq -0x20(%rbp), %rdi
leaq 0x66c80(%rip), %rsi     # 0x1d56cc
callq 0x168da0
movq -0x8(%rbp), %rdi
movq -0x20(%rbp), %rsi
movq -0x10(%rbp), %rax
movq 0x68(%rax), %rcx
leaq 0x46f3a(%rip), %rdx     # 0x1b59a2
callq 0x16f130
movq -0x8(%rbp), %rdi
movq -0x20(%rbp), %rsi
movq -0x10(%rbp), %rax
movq 0x78(%rax), %rcx
leaq 0x66c5f(%rip), %rdx     # 0x1d56e3
callq 0x16f130
movq -0x8(%rbp), %rdi
movq -0x20(%rbp), %rsi
movq -0x10(%rbp), %rax
movq 0x70(%rax), %rcx
leaq 0x59ff0(%rip), %rdx     # 0x1c8a90
callq 0x16f130
movq -0x8(%rbp), %rdi
callq 0x1711d0
movq %rax, -0x30(%rbp)
movq -0x10(%rbp), %rax
cmpb $0x0, 0x80(%rax)
je 0x16ead3
movq -0x10(%rbp), %rdi
addq $0x80, %rdi
movq -0x30(%rbp), %rsi
callq 0x16f1f0
movq -0x8(%rbp), %rdi
movq -0x20(%rbp), %rsi
movq -0x30(%rbp), %rcx
leaq 0x46e1f(%rip), %rdx     # 0x1b5905
callq 0x16f130
movq -0x30(%rbp), %rdi
callq 0x171750
movq -0x20(%rbp), %rdi
leaq 0x66cb6(%rip), %rsi     # 0x1d57b5
callq 0x168da0
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x20(%rbp), %rdx
callq 0x16f230
addq $0x40, %rsp
popq %rbp
retq
nopl (%rax,%rax)