// File: /workspace/github_c_makefile_star2_O0/dxwc[P]sfeed/sfeed_frames.c
// Function: main
int
main(int argc, char *argv[])
{
	FILE *fpindex, *fpitems, *fpmenu = NULL, *fp;
	char *name;
	int i, showsidebar = (argc > 1);
	struct feed *f;

	if (pledge("stdio rpath wpath cpath", 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 is old news */
	comparetime -= 86400;

	/* write main index page */
	if (!(fpindex = fopen("index.html", "wb")))
		err(1, "fopen: index.html");
	if (!(fpitems = fopen("items.html", "wb")))
		err(1, "fopen: items.html");
	if (showsidebar && !(fpmenu = fopen("menu.html", "wb")))
		err(1, "fopen: menu.html");

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

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

	if (argc == 1) {
		if (!(feeds[0] = calloc(1, sizeof(struct feed))))
			err(1, "calloc");
		feeds[0]->name = "";
		printfeed(fpitems, stdin, feeds[0]);
	} 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(fpitems, fp, feeds[i - 1]);
			if (ferror(fp))
				err(1, "ferror: %s", argv[i]);
			fclose(fp);
		}
	}
	fputs("</pre>\n</div></body>\n</html>\n", fpitems); /* div items */

	if (showsidebar) {
		fputs("<!DOCTYPE HTML>\n"
		      "<html>\n"
		      "<head>\n"
		      "\t<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\" />\n"
		      "\t<link rel=\"stylesheet\" type=\"text/css\" href=\"style.css\" />\n"
		      "</head>\n"
		      "<body class=\"frame\">\n<div id=\"sidebar\">\n", fpmenu);

		for (i = 1; i < argc; i++) {
			f = feeds[i - 1];
			if (f->totalnew)
				fputs("<a class=\"n\" href=\"items.html#", fpmenu);
			else
				fputs("<a href=\"items.html#", fpmenu);
			xmlencode(f->name, fpmenu);
			fputs("\" target=\"items\">", fpmenu);
			if (f->totalnew > 0)
				fputs("<b><u>", fpmenu);
			xmlencode(f->name, fpmenu);
			fprintf(fpmenu, " (%lu)", f->totalnew);
			if (f->totalnew > 0)
				fputs("</u></b>", fpmenu);
			fputs("</a><br/>\n", fpmenu);
		}
		fputs("</div></body></html>\n", fpmenu);
	}
	fputs("<!DOCTYPE html>\n<html>\n<head>\n"
	      "\t<meta name=\"referrer\" content=\"no-referrer\" />\n"
	      "\t<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\" />\n"
	      "\t<title>Newsfeed (", fpindex);
	fprintf(fpindex, "%lu", totalnew);
	fputs(")</title>\n\t<link rel=\"stylesheet\" type=\"text/css\" href=\"style.css\" />\n"
	      "</head>\n", fpindex);
	if (showsidebar) {
		fputs("<frameset framespacing=\"0\" cols=\"250,*\" frameborder=\"1\">\n"
		      "\t<frame name=\"menu\" src=\"menu.html\" target=\"menu\">\n", fpindex);
	} else {
		fputs("<frameset framespacing=\"0\" cols=\"*\" frameborder=\"1\">\n", fpindex);
	}
	fputs(
	      "\t<frame name=\"items\" src=\"items.html\" target=\"items\">\n"
	      "</frameset>\n"
	      "</html>\n", fpindex);

	fclose(fpindex);
	fclose(fpitems);
	if (fpmenu)
		fclose(fpmenu);

	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movl $0x0, -0x4(%rbp)
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq $0x0, -0x28(%rbp)
cmpl $0x1, -0x8(%rbp)
setg %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x40(%rbp)
movslq -0x8(%rbp), %rdi
movl $0x8, %esi
callq 0x1100
movq %rax, 0x3dee(%rip)      # 0x5110
cmpq $0x0, %rax
jne 0x133b
movl $0x1, %edi
leaq 0x1cd0(%rip), %rsi      # 0x3004
movb $0x0, %al
callq 0x1180
xorl %eax, %eax
movl %eax, %edi
callq 0x1160
movq %rax, 0x3dcd(%rip)      # 0x5118
cmpq $-0x1, %rax
jne 0x1364
movl $0x1, %edi
leaq 0x217f(%rip), %rsi      # 0x34dc
movb $0x0, %al
callq 0x1180
movq 0x3dad(%rip), %rax      # 0x5118
subq $0x15180, %rax          # imm = 0x15180
movq %rax, 0x3da0(%rip)      # 0x5118
leaq 0x1c96(%rip), %rdi      # 0x3015
leaq 0x1c85(%rip), %rsi      # 0x300b
callq 0x1190
movq %rax, -0x18(%rbp)
cmpq $0x0, %rax
jne 0x13a8
movl $0x1, %edi
leaq 0x1c6d(%rip), %rsi      # 0x300e
movb $0x0, %al
callq 0x1180
leaq 0x1c78(%rip), %rdi      # 0x3027
leaq 0x1c55(%rip), %rsi      # 0x300b
callq 0x1190
movq %rax, -0x20(%rbp)
cmpq $0x0, %rax
jne 0x13d8
movl $0x1, %edi
leaq 0x1c4f(%rip), %rsi      # 0x3020
movb $0x0, %al
callq 0x1180
cmpl $0x0, -0x40(%rbp)
je 0x140e
leaq 0x1c54(%rip), %rdi      # 0x3039
leaq 0x1c1f(%rip), %rsi      # 0x300b
callq 0x1190
movq %rax, -0x28(%rbp)
cmpq $0x0, %rax
jne 0x140e
movl $0x1, %edi
leaq 0x1c2b(%rip), %rsi      # 0x3032
movb $0x0, %al
callq 0x1180
movq -0x20(%rbp), %rsi
leaq 0x1c2a(%rip), %rdi      # 0x3043
callq 0x10c0
cmpl $0x1, -0x8(%rbp)
jne 0x148c
movl $0x1, %edi
movl $0x60, %esi
callq 0x1100
movq 0x3cd6(%rip), %rcx      # 0x5110
movq %rax, (%rcx)
cmpq $0x0, %rax
jne 0x1456
movl $0x1, %edi
leaq 0x1bb5(%rip), %rsi      # 0x3004
movb $0x0, %al
callq 0x1180
movq 0x3cb3(%rip), %rax      # 0x5110
movq (%rax), %rax
leaq 0x2003(%rip), %rcx      # 0x346a
movq %rcx, (%rax)
movq -0x20(%rbp), %rdi
movq 0x3b6b(%rip), %rax      # 0x4fe0
movq (%rax), %rsi
movq 0x3c91(%rip), %rax      # 0x5110
movq (%rax), %rdx
callq 0x17b0
jmp 0x15e4
movl $0x1, -0x3c(%rbp)
movl -0x3c(%rbp), %eax
cmpl -0x8(%rbp), %eax
jge 0x15e2
movl $0x1, %edi
movl $0x60, %esi
callq 0x1100
movq 0x3c5b(%rip), %rcx      # 0x5110
movl -0x3c(%rbp), %edx
subl $0x1, %edx
movslq %edx, %rdx
movq %rax, (%rcx,%rdx,8)
cmpq $0x0, %rax
jne 0x14db
movl $0x1, %edi
leaq 0x1b30(%rip), %rsi      # 0x3004
movb $0x0, %al
callq 0x1180
movq -0x10(%rbp), %rax
movslq -0x3c(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
movl $0x2f, %esi
callq 0x10b0
movq %rax, -0x38(%rbp)
cmpq $0x0, %rax
je 0x1509
movq -0x38(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x50(%rbp)
jmp 0x1519
movq -0x10(%rbp), %rax
movslq -0x3c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rcx
movq 0x3be4(%rip), %rax      # 0x5110
movl -0x3c(%rbp), %edx
subl $0x1, %edx
movslq %edx, %rdx
movq (%rax,%rdx,8), %rax
movq %rcx, (%rax)
movq -0x10(%rbp), %rax
movslq -0x3c(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
leaq 0x1bf9(%rip), %rsi      # 0x3148
callq 0x1190
movq %rax, -0x30(%rbp)
cmpq $0x0, %rax
jne 0x157d
movq -0x10(%rbp), %rax
movslq -0x3c(%rbp), %rcx
movq (%rax,%rcx,8), %rdx
movl $0x1, %edi
leaq 0x1bd4(%rip), %rsi      # 0x314a
movb $0x0, %al
callq 0x1180
movq -0x20(%rbp), %rdi
movq -0x30(%rbp), %rsi
movq 0x3b84(%rip), %rax      # 0x5110
movl -0x3c(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rdx
callq 0x17b0
movq -0x30(%rbp), %rdi
callq 0x1060
cmpl $0x0, %eax
je 0x15cb
movq -0x10(%rbp), %rax
movslq -0x3c(%rbp), %rcx
movq (%rax,%rcx,8), %rdx
movl $0x1, %edi
leaq 0x1b90(%rip), %rsi      # 0x3154
movb $0x0, %al
callq 0x1180
movq -0x30(%rbp), %rdi
callq 0x1070
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x1493
jmp 0x15e4
movq -0x20(%rbp), %rsi
leaq 0x1b70(%rip), %rdi      # 0x315f
callq 0x10c0
cmpl $0x0, -0x40(%rbp)
je 0x1714
movq -0x28(%rbp), %rsi
leaq 0x1b74(%rip), %rdi      # 0x317d
callq 0x10c0
movl $0x1, -0x3c(%rbp)
movl -0x3c(%rbp), %eax
cmpl -0x8(%rbp), %eax
jge 0x1704
movq 0x3ae8(%rip), %rax      # 0x5110
movl -0x3c(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rax
cmpq $0x0, 0x8(%rax)
je 0x1656
movq -0x28(%rbp), %rsi
leaq 0x1c00(%rip), %rdi      # 0x324f
callq 0x10c0
jmp 0x1666
movq -0x28(%rbp), %rsi
leaq 0x1c0d(%rip), %rdi      # 0x326e
callq 0x10c0
movq -0x48(%rbp), %rax
movq (%rax), %rdi
movq -0x28(%rbp), %rsi
callq 0x24f0
movq -0x28(%rbp), %rsi
leaq 0x1c02(%rip), %rdi      # 0x3283
callq 0x10c0
movq -0x48(%rbp), %rax
cmpq $0x0, 0x8(%rax)
jbe 0x16a1
movq -0x28(%rbp), %rsi
leaq 0x1bf9(%rip), %rdi      # 0x3295
callq 0x10c0
movq -0x48(%rbp), %rax
movq (%rax), %rdi
movq -0x28(%rbp), %rsi
callq 0x24f0
movq -0x28(%rbp), %rdi
movq -0x48(%rbp), %rax
movq 0x8(%rax), %rdx
leaq 0x1bd8(%rip), %rsi      # 0x329c
movb $0x0, %al
callq 0x1130
movq -0x48(%rbp), %rax
cmpq $0x0, 0x8(%rax)
jbe 0x16e6
movq -0x28(%rbp), %rsi
leaq 0x1bc2(%rip), %rdi      # 0x32a3
callq 0x10c0
movq -0x28(%rbp), %rsi
leaq 0x1bbb(%rip), %rdi      # 0x32ac
callq 0x10c0
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x1615
movq -0x28(%rbp), %rsi
leaq 0x1ba8(%rip), %rdi      # 0x32b7
callq 0x10c0
movq -0x18(%rbp), %rsi
leaq 0x1bae(%rip), %rdi      # 0x32cd
callq 0x10c0
movq -0x18(%rbp), %rdi
movq 0x39f1(%rip), %rdx      # 0x5120
leaq 0x1c3f(%rip), %rsi      # 0x3375
movb $0x0, %al
callq 0x1130
movq -0x18(%rbp), %rsi
leaq 0x1c31(%rip), %rdi      # 0x3379
callq 0x10c0
cmpl $0x0, -0x40(%rbp)
je 0x1765
movq -0x18(%rbp), %rsi
leaq 0x1c6a(%rip), %rdi      # 0x33c8
callq 0x10c0
jmp 0x1775
movq -0x18(%rbp), %rsi
leaq 0x1cc5(%rip), %rdi      # 0x3435
callq 0x10c0
movq -0x18(%rbp), %rsi
leaq 0x1ceb(%rip), %rdi      # 0x346b
callq 0x10c0
movq -0x18(%rbp), %rdi
callq 0x1070
movq -0x20(%rbp), %rdi
callq 0x1070
cmpq $0x0, -0x28(%rbp)
je 0x17a7
movq -0x28(%rbp), %rdi
callq 0x1070
xorl %eax, %eax
addq $0x50, %rsp
popq %rbp
retq
nop