// File: /workspace/github_c_makefile_star2_O3/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, %ebx
movslq %edi, %rdi
movl $0x8, %esi
callq 0x10f0
movq %rax, 0x3e10(%rip)      # 0x5100
testq %rax, %rax
je 0x15b3
xorl %edi, %edi
callq 0x1150
movq %rax, 0x3e01(%rip)      # 0x5108
cmpq $-0x1, %rax
je 0x15ec
addq $-0x15180, %rax         # imm = 0xFFFEAE80
movq %rax, 0x3dea(%rip)      # 0x5108
movq 0x3cb3(%rip), %rbp      # 0x4fd8
movq (%rbp), %rsi
leaq 0x1cf7(%rip), %rdi      # 0x3027
callq 0x10b0
xorl %eax, %eax
movq (%rbp), %rsi
cmpl $0x2, %ebx
setge %al
movl %eax, 0x3dc9(%rip)      # 0x5110
movl %ebx, 0x4(%rsp)
jl 0x1410
leaq 0x1dc5(%rip), %rdi      # 0x311d
callq 0x10b0
movq (%rbp), %rsi
leaq 0x1def(%rip), %rdi      # 0x3157
callq 0x10b0
movl %ebx, %ebx
decq %rbx
xorl %r15d, %r15d
movl $0x1, %edi
movl $0x60, %esi
callq 0x10f0
movq %rax, %r12
movq 0x3d72(%rip), %rax      # 0x5100
movq %r12, (%rax,%r15,8)
testq %r12, %r12
je 0x15b3
movq 0x8(%r14,%r15,8), %r13
movq %r13, %rdi
movl $0x2f, %esi
callq 0x10a0
leaq 0x1(%rax), %rcx
testq %rax, %rax
cmoveq %r13, %rcx
movq %rcx, (%r12)
movq %r13, %rdi
leaq 0x1da9(%rip), %rsi      # 0x316f
callq 0x1180
testq %rax, %rax
je 0x15c6
movq %rax, %r12
movq 0x3d22(%rip), %rax      # 0x5100
movq (%rax,%r15,8), %rsi
movq %r12, %rdi
callq 0x15fe
movq %r12, %rdi
callq 0x1050
testl %eax, %eax
jne 0x15d4
movq %r12, %rdi
callq 0x1060
incq %r15
cmpq %r15, %rbx
jne 0x1375
jmp 0x147f
leaq 0x1d1a(%rip), %rdi      # 0x3131
callq 0x10b0
movq (%rbp), %rsi
leaq 0x1d30(%rip), %rdi      # 0x3157
callq 0x10b0
cmpl $0x1, %ebx
jne 0x147f
movl $0x1, %edi
movl $0x60, %esi
callq 0x10f0
movq 0x3cb9(%rip), %rcx      # 0x5100
movq %rax, (%rcx)
testq %rax, %rax
je 0x15b3
leaq 0x1cc2(%rip), %rcx      # 0x311c
movq %rcx, (%rax)
movq 0x3b7c(%rip), %rbx      # 0x4fe0
movq (%rbx), %rdi
movq %rax, %rsi
callq 0x15fe
movq (%rbx), %rdi
callq 0x1050
testl %eax, %eax
jne 0x15f5
movq (%rbp), %rsi
leaq 0x1cfc(%rip), %rdi      # 0x3186
callq 0x10b0
cmpl $0x0, 0x3c7a(%rip)      # 0x5110
je 0x1589
movq (%rbp), %rsi
leaq 0x1cee(%rip), %rdi      # 0x3195
callq 0x10b0
movl 0x4(%rsp), %eax
cmpl $0x2, %eax
jl 0x1579
movl %eax, %r12d
decq %r12
leaq 0x1d1d(%rip), %r14      # 0x31e3
leaq 0x1d26(%rip), %r15      # 0x31f3
xorl %r13d, %r13d
movq 0x3c29(%rip), %rax      # 0x5100
movq (%rax,%r13,8), %rbx
cmpq $0x0, 0x8(%rbx)
leaq 0x1ce3(%rip), %rdi      # 0x31ca
je 0x14f0
leaq 0x1cc1(%rip), %rdi      # 0x31b1
movq (%rbp), %rsi
callq 0x10b0
movq (%rbx), %rdi
movq (%rbp), %rsi
callq 0x1ede
movq (%rbp), %rsi
leaq 0x1cc9(%rip), %rdi      # 0x31d9
callq 0x10b0
cmpq $0x0, 0x8(%rbx)
je 0x152c
movq (%rbp), %rsi
leaq 0x1cb5(%rip), %rdi      # 0x31dc
callq 0x10b0
movq (%rbx), %rdi
movq (%rbp), %rsi
callq 0x1ede
movq (%rbp), %rdi
movq 0x8(%rbx), %rdx
movq %r14, %rsi
xorl %eax, %eax
callq 0x1120
cmpq $0x0, 0x8(%rbx)
je 0x1561
movq (%rbp), %rsi
leaq 0x1c8e(%rip), %rdi      # 0x31ea
callq 0x10b0
movq (%rbp), %rsi
movq %r15, %rdi
callq 0x10b0
incq %r13
cmpq %r13, %r12
jne 0x14d0
movq (%rbp), %rsi
leaq 0x1c7a(%rip), %rdi      # 0x31fe
callq 0x10b0
movq (%rbp), %rdi
movq 0x3b84(%rip), %rdx      # 0x5118
leaq 0x1c74(%rip), %rsi      # 0x320f
xorl %eax, %eax
callq 0x1120
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x1a66(%rip), %rsi      # 0x3020
movl $0x1, %edi
xorl %eax, %eax
callq 0x1170
movq 0x8(%r14,%r15,8), %rdx
leaq 0x1b9f(%rip), %rsi      # 0x3171
jmp 0x15e0
movq 0x8(%r14,%r15,8), %rdx
leaq 0x1b9b(%rip), %rsi      # 0x317b
movl $0x1, %edi
xorl %eax, %eax
callq 0x1170
leaq 0x1c66(%rip), %rsi      # 0x3259
jmp 0x15ba
leaq 0x1b62(%rip), %rsi      # 0x315e
jmp 0x15ba