// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x40, %rsp
movl $0x0, -0x4(%rbp)
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movslq -0x8(%rbp), %rdi
movl $0x8, %esi
callq 0x1100
movq %rax, 0x3e05(%rip)      # 0x5110
cmpq $0x0, %rax
jne 0x1324
movl $0x1, %edi
leaq 0x1ce7(%rip), %rsi      # 0x3004
movb $0x0, %al
callq 0x1180
xorl %eax, %eax
movl %eax, %edi
callq 0x1160
movq %rax, 0x3de4(%rip)      # 0x5118
cmpq $-0x1, %rax
jne 0x134d
movl $0x1, %edi
leaq 0x1ef7(%rip), %rsi      # 0x323d
movb $0x0, %al
callq 0x1180
movq 0x3dc4(%rip), %rax      # 0x5118
subq $0x15180, %rax          # imm = 0x15180
movq %rax, 0x3db7(%rip)      # 0x5118
movq 0x3c70(%rip), %rax      # 0x4fd8
movq (%rax), %rsi
leaq 0x1c99(%rip), %rdi      # 0x300b
callq 0x10c0
cmpl $0x1, -0x8(%rbp)
setg %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, 0x3d97(%rip)      # 0x5120
cmpl $0x0, 0x3d90(%rip)      # 0x5120
je 0x13aa
movq 0x3c3f(%rip), %rax      # 0x4fd8
movq (%rax), %rsi
leaq 0x1d5e(%rip), %rdi      # 0x3101
callq 0x10c0
jmp 0x13c0
movq 0x3c27(%rip), %rax      # 0x4fd8
movq (%rax), %rsi
leaq 0x1d5a(%rip), %rdi      # 0x3115
callq 0x10c0
movq 0x3c11(%rip), %rax      # 0x4fd8
movq (%rax), %rsi
leaq 0x1d6a(%rip), %rdi      # 0x313b
callq 0x10c0
cmpl $0x1, -0x8(%rbp)
jne 0x146b
movl $0x1, %edi
movl $0x60, %esi
callq 0x1100
movq 0x3d1a(%rip), %rcx      # 0x5110
movq %rax, (%rcx)
cmpq $0x0, %rax
jne 0x1412
movl $0x1, %edi
leaq 0x1bf9(%rip), %rsi      # 0x3004
movb $0x0, %al
callq 0x1180
movq 0x3cf7(%rip), %rax      # 0x5110
movq (%rax), %rax
leaq 0x1cdd(%rip), %rcx      # 0x3100
movq %rcx, (%rax)
movq 0x3bb3(%rip), %rax      # 0x4fe0
movq (%rax), %rdi
movq 0x3cd9(%rip), %rax      # 0x5110
movq (%rax), %rsi
callq 0x1770
movq 0x3b9a(%rip), %rax      # 0x4fe0
movq (%rax), %rdi
callq 0x1060
cmpl $0x0, %eax
je 0x1466
movl $0x1, %edi
leaq 0x1ce3(%rip), %rsi      # 0x3142
movb $0x0, %al
callq 0x1180
jmp 0x15bf
movl $0x1, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
cmpl -0x8(%rbp), %eax
jge 0x15bd
movl $0x1, %edi
movl $0x60, %esi
callq 0x1100
movq 0x3c7c(%rip), %rcx      # 0x5110
movl -0x2c(%rbp), %edx
subl $0x1, %edx
movslq %edx, %rdx
movq %rax, (%rcx,%rdx,8)
cmpq $0x0, %rax
jne 0x14ba
movl $0x1, %edi
leaq 0x1b51(%rip), %rsi      # 0x3004
movb $0x0, %al
callq 0x1180
movq -0x10(%rbp), %rax
movslq -0x2c(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
movl $0x2f, %esi
callq 0x10b0
movq %rax, -0x20(%rbp)
cmpq $0x0, %rax
je 0x14e8
movq -0x20(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x38(%rbp)
jmp 0x14f8
movq -0x10(%rbp), %rax
movslq -0x2c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rax
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rcx
movq 0x3c05(%rip), %rax      # 0x5110
movl -0x2c(%rbp), %edx
subl $0x1, %edx
movslq %edx, %rdx
movq (%rax,%rdx,8), %rax
movq %rcx, (%rax)
movq -0x10(%rbp), %rax
movslq -0x2c(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
leaq 0x1c25(%rip), %rsi      # 0x3153
callq 0x1190
movq %rax, -0x28(%rbp)
cmpq $0x0, %rax
jne 0x155c
movq -0x10(%rbp), %rax
movslq -0x2c(%rbp), %rcx
movq (%rax,%rcx,8), %rdx
movl $0x1, %edi
leaq 0x1c00(%rip), %rsi      # 0x3155
movb $0x0, %al
callq 0x1180
movq -0x28(%rbp), %rdi
movq 0x3ba9(%rip), %rax      # 0x5110
movl -0x2c(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rsi
callq 0x1770
movq -0x28(%rbp), %rdi
callq 0x1060
cmpl $0x0, %eax
je 0x15a6
movq -0x10(%rbp), %rax
movslq -0x2c(%rbp), %rcx
movq (%rax,%rcx,8), %rdx
movl $0x1, %edi
leaq 0x1bc0(%rip), %rsi      # 0x315f
movb $0x0, %al
callq 0x1180
movq -0x28(%rbp), %rdi
callq 0x1070
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x1472
jmp 0x15bf
movq 0x3a12(%rip), %rax      # 0x4fd8
movq (%rax), %rsi
leaq 0x1b9a(%rip), %rdi      # 0x316a
callq 0x10c0
cmpl $0x0, 0x3b44(%rip)      # 0x5120
je 0x173a
movq 0x39ef(%rip), %rax      # 0x4fd8
movq (%rax), %rsi
leaq 0x1b86(%rip), %rdi      # 0x3179
callq 0x10c0
movl $0x1, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
cmpl -0x8(%rbp), %eax
jge 0x1724
movq 0x3afe(%rip), %rax      # 0x5110
movl -0x2c(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rax
cmpq $0x0, 0x8(%rax)
jbe 0x1646
movq 0x39a3(%rip), %rax      # 0x4fd8
movq (%rax), %rsi
leaq 0x1b56(%rip), %rdi      # 0x3195
callq 0x10c0
jmp 0x165c
movq 0x398b(%rip), %rax      # 0x4fd8
movq (%rax), %rsi
leaq 0x1b57(%rip), %rdi      # 0x31ae
callq 0x10c0
movq -0x18(%rbp), %rax
movq (%rax), %rdi
movq 0x396e(%rip), %rax      # 0x4fd8
movq (%rax), %rsi
callq 0x2510
movq 0x395f(%rip), %rax      # 0x4fd8
movq (%rax), %rsi
leaq 0x1b3a(%rip), %rdi      # 0x31bd
callq 0x10c0
movq -0x18(%rbp), %rax
cmpq $0x0, 0x8(%rax)
jbe 0x16a9
movq 0x393e(%rip), %rax      # 0x4fd8
movq (%rax), %rsi
leaq 0x1b1c(%rip), %rdi      # 0x31c0
callq 0x10c0
movq -0x18(%rbp), %rax
movq (%rax), %rdi
movq 0x3921(%rip), %rax      # 0x4fd8
movq (%rax), %rsi
callq 0x2510
movq 0x3912(%rip), %rax      # 0x4fd8
movq (%rax), %rdi
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rdx
leaq 0x1aef(%rip), %rsi      # 0x31c7
movb $0x0, %al
callq 0x1130
movq -0x18(%rbp), %rax
cmpq $0x0, 0x8(%rax)
jbe 0x1700
movq 0x38e7(%rip), %rax      # 0x4fd8
movq (%rax), %rsi
leaq 0x1ad3(%rip), %rdi      # 0x31ce
callq 0x10c0
movq 0x38d1(%rip), %rax      # 0x4fd8
movq (%rax), %rsi
leaq 0x1ac6(%rip), %rdi      # 0x31d7
callq 0x10c0
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x15ff
movq 0x38ad(%rip), %rax      # 0x4fd8
movq (%rax), %rsi
leaq 0x1aad(%rip), %rdi      # 0x31e2
callq 0x10c0
movq 0x3897(%rip), %rax      # 0x4fd8
movq (%rax), %rdi
movq 0x39dd(%rip), %rdx      # 0x5128
leaq 0x1aa1(%rip), %rsi      # 0x31f3
movb $0x0, %al
callq 0x1130
xorl %eax, %eax
addq $0x40, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)