// File: /workspace/github_c_makefile_star2_O1/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 0x1100
movq %rax, 0x3e08(%rip)      # 0x5108
testq %rax, %rax
je 0x15be
xorl %edi, %edi
callq 0x1160
movq %rax, 0x3df9(%rip)      # 0x5110
cmpq $-0x1, %rax
je 0x15f7
addq $-0x15180, %rax         # imm = 0xFFFEAE80
movq %rax, 0x3de2(%rip)      # 0x5110
movq 0x3ca3(%rip), %rbp      # 0x4fd8
movq (%rbp), %rsi
leaq 0x1ccb(%rip), %rdi      # 0x300b
callq 0x10c0
xorl %eax, %eax
cmpl $0x2, %ebx
setge %al
movl %eax, 0x3dc5(%rip)      # 0x5118
movq (%rbp), %rsi
leaq 0x1da3(%rip), %rax      # 0x3101
leaq 0x1db0(%rip), %rdi      # 0x3115
cmovgeq %rax, %rdi
callq 0x10c0
movq (%rbp), %rsi
leaq 0x1dc2(%rip), %rdi      # 0x313b
callq 0x10c0
cmpl $0x1, %ebx
movl %ebx, 0x4(%rsp)
jne 0x13e1
movl $0x1, %edi
movl $0x60, %esi
callq 0x1100
movq 0x3d6b(%rip), %rcx      # 0x5108
movq %rax, (%rcx)
testq %rax, %rax
je 0x15be
leaq 0x1d50(%rip), %rdx      # 0x3100
movq %rdx, (%rax)
movq 0x3c26(%rip), %rbx      # 0x4fe0
movq (%rbx), %rdi
movq (%rcx), %rsi
callq 0x1600
movq (%rbx), %rdi
callq 0x1060
testl %eax, %eax
je 0x148a
leaq 0x1d66(%rip), %rsi      # 0x3142
jmp 0x15c5
jle 0x148a
movl 0x4(%rsp), %ebx
decq %rbx
xorl %r15d, %r15d
movl $0x1, %edi
movl $0x60, %esi
callq 0x1100
movq %rax, %r12
movq 0x3cfe(%rip), %rax      # 0x5108
movq %r12, (%rax,%r15,8)
testq %r12, %r12
je 0x15be
movq 0x8(%r14,%r15,8), %r13
movq %r13, %rdi
movl $0x2f, %esi
callq 0x10b0
leaq 0x1(%rax), %rcx
testq %rax, %rax
cmoveq %r13, %rcx
movq %rcx, (%r12)
movq %r13, %rdi
leaq 0x1d11(%rip), %rsi      # 0x3153
callq 0x1190
testq %rax, %rax
je 0x15d1
movq %rax, %r12
movq 0x3cae(%rip), %rax      # 0x5108
movq (%rax,%r15,8), %rsi
movq %r12, %rdi
callq 0x1600
movq %r12, %rdi
callq 0x1060
testl %eax, %eax
jne 0x15df
movq %r12, %rdi
callq 0x1070
incq %r15
cmpq %r15, %rbx
jne 0x13f1
movq (%rbp), %rsi
leaq 0x1cd5(%rip), %rdi      # 0x316a
callq 0x10c0
cmpl $0x0, 0x3c77(%rip)      # 0x5118
je 0x1594
movq (%rbp), %rsi
leaq 0x1cc7(%rip), %rdi      # 0x3179
callq 0x10c0
movl 0x4(%rsp), %eax
cmpl $0x2, %eax
jl 0x1584
movl %eax, %r12d
decq %r12
leaq 0x1cf6(%rip), %r14      # 0x31c7
leaq 0x1cff(%rip), %r15      # 0x31d7
xorl %r13d, %r13d
movq 0x3c26(%rip), %rax      # 0x5108
movq (%rax,%r13,8), %rbx
cmpq $0x0, 0x8(%rbx)
leaq 0x1cbc(%rip), %rdi      # 0x31ae
je 0x14fb
leaq 0x1c9a(%rip), %rdi      # 0x3195
movq (%rbp), %rsi
callq 0x10c0
movq (%rbx), %rdi
movq (%rbp), %rsi
callq 0x1e83
movq (%rbp), %rsi
leaq 0x1ca2(%rip), %rdi      # 0x31bd
callq 0x10c0
cmpq $0x0, 0x8(%rbx)
je 0x1537
movq (%rbp), %rsi
leaq 0x1c8e(%rip), %rdi      # 0x31c0
callq 0x10c0
movq (%rbx), %rdi
movq (%rbp), %rsi
callq 0x1e83
movq (%rbp), %rdi
movq 0x8(%rbx), %rdx
movq %r14, %rsi
xorl %eax, %eax
callq 0x1130
cmpq $0x0, 0x8(%rbx)
je 0x156c
movq (%rbp), %rsi
leaq 0x1c67(%rip), %rdi      # 0x31ce
callq 0x10c0
movq (%rbp), %rsi
movq %r15, %rdi
callq 0x10c0
incq %r13
cmpq %r13, %r12
jne 0x14db
movq (%rbp), %rsi
leaq 0x1c53(%rip), %rdi      # 0x31e2
callq 0x10c0
movq (%rbp), %rdi
movq 0x3b81(%rip), %rdx      # 0x5120
leaq 0x1c4d(%rip), %rsi      # 0x31f3
xorl %eax, %eax
callq 0x1130
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x1a3f(%rip), %rsi      # 0x3004
movl $0x1, %edi
xorl %eax, %eax
callq 0x1180
movq 0x8(%r14,%r15,8), %rdx
leaq 0x1b78(%rip), %rsi      # 0x3155
jmp 0x15eb
movq 0x8(%r14,%r15,8), %rdx
leaq 0x1b74(%rip), %rsi      # 0x315f
movl $0x1, %edi
xorl %eax, %eax
callq 0x1180
leaq 0x1c3f(%rip), %rsi      # 0x323d
jmp 0x15c5