// File: /workspace/github_c_makefile_star2_O2/dxwc[P]sfeed/sfeed_html.c
// Function: main
int
main(int argc, char *argv[])
{
	struct feed *f;
	char *name;
	FILE *fp;
	int i;

	if (pledge(argc == 1 ? "stdio" : "stdio rpath", NULL) == -1)
		err(1, "pledge");

	if (!(feeds = calloc(argc, sizeof(struct feed *))))
		err(1, "calloc");
	if ((comparetime = time(NULL)) == -1)
		err(1, "time");
	/* 1 day old is old news */
	comparetime -= 86400;

	fputs("<!DOCTYPE HTML>\n"
	      "<html>\n"
	      "\t<head>\n"
	      "\t<meta name=\"referrer\" content=\"no-referrer\" />\n"
	      "\t\t<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\" />\n"
	      "\t\t<link rel=\"stylesheet\" type=\"text/css\" href=\"style.css\" />\n"
	      "\t</head>\n"
	      "\t<body class=\"noframe\">\n", stdout);

	showsidebar = (argc > 1);
	if (showsidebar)
		fputs("\t\t<div id=\"items\">\n", stdout);
	else
		fputs("\t\t<div id=\"items\" class=\"nosidebar\">\n", stdout);
	fputs("<pre>\n", stdout);

	if (argc == 1) {
		if (!(feeds[0] = calloc(1, sizeof(struct feed))))
			err(1, "calloc");
		feeds[0]->name = "";
		printfeed(stdin, feeds[0]);
		if (ferror(stdin))
			err(1, "ferror: <stdin>:");
	} else {
		for (i = 1; i < argc; i++) {
			if (!(feeds[i - 1] = calloc(1, sizeof(struct feed))))
				err(1, "calloc");
			name = ((name = strrchr(argv[i], '/'))) ? name + 1 : argv[i];
			feeds[i - 1]->name = name;
			if (!(fp = fopen(argv[i], "r")))
				err(1, "fopen: %s", argv[i]);
			printfeed(fp, feeds[i - 1]);
			if (ferror(fp))
				err(1, "ferror: %s", argv[i]);
			fclose(fp);
		}
	}
	fputs("</pre>\n</div>\n", stdout); /* div items */

	if (showsidebar) {
		fputs("\t<div id=\"sidebar\">\n\t\t<ul>\n", stdout);

		for (i = 1; i < argc; i++) {
			f = feeds[i - 1];
			if (f->totalnew > 0)
				fputs("<li class=\"n\"><a href=\"#", stdout);
			else
				fputs("<li><a href=\"#", stdout);
			xmlencode(f->name, stdout);
			fputs("\">", stdout);
			if (f->totalnew > 0)
				fputs("<b><u>", stdout);
			xmlencode(f->name, stdout);
			fprintf(stdout, " (%lu)", f->totalnew);
			if (f->totalnew > 0)
				fputs("</u></b>", stdout);
			fputs("</a></li>\n", stdout);
		}
		fputs("\t\t</ul>\n\t</div>\n", stdout);
	}

	fprintf(stdout, "\t</body>\n\t<title>Newsfeed (%lu)</title>\n</html>\n",
	        totalnew);

	return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %r14
movl %edi, %ebp
movslq %edi, %rbx
pushq $0x8
popq %rsi
movq %rbx, %rdi
callq 0x10f0
movq %rax, 0x2e0f(%rip)      # 0x4100
testq %rax, %rax
je 0x157a
xorl %edi, %edi
callq 0x1150
movq %rax, 0x2e00(%rip)      # 0x4108
cmpq $-0x1, %rax
je 0x15ad
addq $-0x15180, %rax         # imm = 0xFFFEAE80
movq %rax, 0x2de9(%rip)      # 0x4108
movq 0x2cb2(%rip), %r13      # 0x3fd8
movq (%r13), %rsi
leaq 0xcf6(%rip), %rdi       # 0x2027
callq 0x10b0
xorl %eax, %eax
cmpl $0x2, %ebp
setge %al
movl %eax, 0x2dcc(%rip)      # 0x4110
movq (%r13), %rsi
leaq 0xdce(%rip), %rax       # 0x211d
leaq 0xddb(%rip), %rdi       # 0x2131
cmovgeq %rax, %rdi
callq 0x10b0
movq (%r13), %rsi
leaq 0xded(%rip), %rdi       # 0x2157
callq 0x10b0
cmpl $0x1, %ebp
jne 0x14e9
pushq $0x1
popq %rdi
pushq $0x60
popq %rsi
callq 0x10f0
movq 0x2d76(%rip), %rcx      # 0x4100
movq %rax, (%rcx)
testq %rax, %rax
je 0x157a
leaq 0xd7f(%rip), %rcx       # 0x211c
movq %rcx, (%rax)
movq 0x2c39(%rip), %r14      # 0x3fe0
movq (%r14), %rdi
movq %rax, %rsi
callq 0x15bf
movq (%r14), %rdi
callq 0x1050
testl %eax, %eax
jne 0x15b6
movq (%r13), %rsi
leaq 0xdb9(%rip), %rdi       # 0x2186
callq 0x10b0
cmpl $0x0, 0x2d37(%rip)      # 0x4110
je 0x14bf
movq (%r13), %rsi
leaq 0xdab(%rip), %rdi       # 0x2195
callq 0x10b0
pushq $0x1
popq %rbp
leaq 0xdea(%rip), %r15       # 0x21e3
leaq 0xdf3(%rip), %r12       # 0x21f3
cmpq %rbx, %rbp
jge 0x14af
movq 0x2cf0(%rip), %rax      # 0x4100
movq -0x8(%rax,%rbp,8), %r14
cmpq $0x0, 0x8(%r14)
leaq 0xda9(%rip), %rdi       # 0x21ca
je 0x142a
leaq 0xd87(%rip), %rdi       # 0x21b1
movq (%r13), %rsi
callq 0x10b0
movq (%r14), %rdi
movq (%r13), %rsi
callq 0x1d8d
movq (%r13), %rsi
leaq 0xd8f(%rip), %rdi       # 0x21d9
callq 0x10b0
cmpq $0x0, 0x8(%r14)
je 0x1466
movq (%r13), %rsi
leaq 0xd7b(%rip), %rdi       # 0x21dc
callq 0x10b0
movq (%r14), %rdi
movq (%r13), %rsi
callq 0x1d8d
movq (%r13), %rdi
movq 0x8(%r14), %rdx
movq %r15, %rsi
xorl %eax, %eax
callq 0x1120
cmpq $0x0, 0x8(%r14)
je 0x149b
movq (%r13), %rsi
leaq 0xd54(%rip), %rdi       # 0x21ea
callq 0x10b0
movq (%r13), %rsi
movq %r12, %rdi
callq 0x10b0
incq %rbp
jmp 0x1400
movq (%r13), %rsi
leaq 0xd44(%rip), %rdi       # 0x21fe
callq 0x10b0
movq (%r13), %rdi
movq 0x2c4e(%rip), %rdx      # 0x4118
leaq 0xd3e(%rip), %rsi       # 0x220f
xorl %eax, %eax
callq 0x1120
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
pushq $0x1
popq %r15
cmpq %rbx, %r15
jge 0x13c2
pushq $0x1
popq %rdi
pushq $0x60
popq %rsi
callq 0x10f0
movq %rax, %r12
movq 0x2bf5(%rip), %rax      # 0x4100
movq %r12, -0x8(%rax,%r15,8)
testq %r12, %r12
je 0x157a
movq (%r14,%r15,8), %rbp
movq %rbp, %rdi
pushq $0x2f
popq %rsi
callq 0x10a0
leaq 0x1(%rax), %rcx
testq %rax, %rax
cmoveq %rbp, %rcx
movq %rcx, (%r12)
movq %rbp, %rdi
leaq 0xc32(%rip), %rsi       # 0x216f
callq 0x1180
testq %rax, %rax
je 0x158b
movq %rax, %r12
movq 0x2baf(%rip), %rax      # 0x4100
movq -0x8(%rax,%r15,8), %rsi
movq %r12, %rdi
callq 0x15bf
movq %r12, %rdi
callq 0x1050
testl %eax, %eax
jne 0x1598
movq %r12, %rdi
callq 0x1060
incq %r15
jmp 0x14ed
leaq 0xa9f(%rip), %rsi       # 0x2020
pushq $0x1
popq %rdi
xorl %eax, %eax
callq 0x1170
movq (%r14,%r15,8), %rdx
leaq 0xbdb(%rip), %rsi       # 0x2171
jmp 0x15a3
movq (%r14,%r15,8), %rdx
leaq 0xbd8(%rip), %rsi       # 0x217b
pushq $0x1
popq %rdi
xorl %eax, %eax
callq 0x1170
leaq 0xca5(%rip), %rsi       # 0x2259
jmp 0x1581
leaq 0xba1(%rip), %rsi       # 0x215e
jmp 0x1581