// File: /workspace/github_c_makefile_star2_O0/vampirefrog[P]x68ksjis/sjisstat.c
// Function: main
int main(int argc, char **argv) {
	FILE *in = stdin;

	uint8_t buf[1024];
	int last_byte = 0;
	int l;
	while((l = fread(buf, 1, 1024, in)) > 0) {
		for(int i = 0; i < l; i++) {
			uint8_t b = buf[i];
			if(last_byte == 0 && SJIS_FIRST_CHAR(b)) {
				last_byte = b;
			} else {
				push_charstat((last_byte << 8) | b);
				last_byte = 0;
			}
		}
	}

	qsort(stats, sizeof(stats) / sizeof(stats[0]), sizeof(stats[0]), cmpstatfn);

	for(int i = 0; i < 65536; i++) {
		if(stats[i].cnt == 0) break;
		int chr = stats[i].chr;
		char utfbuf[5];
		if(chr < 0x20) {
			snprintf(utfbuf, 5, "0x%02x", chr);
		} else {
			int l = utf8_encode(sjis_char_to_unicode(chr), utfbuf);
			utfbuf[l] = 0;
		}
		if(chr > 0xff)
			printf("0x%02x 0x%02x %d %s\n", chr >> 8, chr & 0xff, stats[i].cnt, utfbuf);
		else
			printf("     0x%02x %d %s\n", chr & 0xff, stats[i].cnt, utfbuf);
	}

	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x450, %rsp            # imm = 0x450
movl $0x0, -0x4(%rbp)
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq 0x5da0(%rip), %rax      # 0x6fe0
movq (%rax), %rax
movq %rax, -0x18(%rbp)
movl $0x0, -0x424(%rbp)
leaq -0x420(%rbp), %rdi
movq -0x18(%rbp), %rcx
movl $0x1, %esi
movl $0x400, %edx            # imm = 0x400
callq 0x1050
movl %eax, -0x428(%rbp)
cmpl $0x0, %eax
jle 0x136e
movl $0x0, -0x42c(%rbp)
movl -0x42c(%rbp), %eax
cmpl -0x428(%rbp), %eax
jge 0x1369
movslq -0x42c(%rbp), %rax
movb -0x420(%rbp,%rax), %al
movb %al, -0x42d(%rbp)
cmpl $0x0, -0x424(%rbp)
jne 0x1332
movzbl -0x42d(%rbp), %eax
cmpl $0x80, %eax
jl 0x12cf
movzbl -0x42d(%rbp), %eax
cmpl $0x84, %eax
jle 0x1323
movzbl -0x42d(%rbp), %eax
cmpl $0x88, %eax
jl 0x12eb
movzbl -0x42d(%rbp), %eax
cmpl $0x9f, %eax
jle 0x1323
movzbl -0x42d(%rbp), %eax
cmpl $0xe0, %eax
jl 0x1307
movzbl -0x42d(%rbp), %eax
cmpl $0xeb, %eax
jle 0x1323
movzbl -0x42d(%rbp), %eax
cmpl $0xf0, %eax
jl 0x1332
movzbl -0x42d(%rbp), %eax
cmpl $0xf3, %eax
jg 0x1332
movzbl -0x42d(%rbp), %eax
movl %eax, -0x424(%rbp)
jmp 0x1353
movl -0x424(%rbp), %edi
shll $0x8, %edi
movzbl -0x42d(%rbp), %eax
orl %eax, %edi
callq 0x11b0
movl $0x0, -0x424(%rbp)
jmp 0x1355
movl -0x42c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x42c(%rbp)
jmp 0x1284
jmp 0x1251
leaq 0x1845b(%rip), %rdi     # 0x197d0
movl $0x10000, %esi          # imm = 0x10000
movl $0x8, %edx
leaq -0x186(%rip), %rcx      # 0x1200
callq 0x1040
movl $0x0, -0x434(%rbp)
cmpl $0x10000, -0x434(%rbp)  # imm = 0x10000
jge 0x14c5
movslq -0x434(%rbp), %rcx
leaq 0x1841d(%rip), %rax     # 0x197d0
cmpl $0x0, 0x4(%rax,%rcx,8)
jne 0x13bf
jmp 0x14c5
movslq -0x434(%rbp), %rcx
leaq 0x18403(%rip), %rax     # 0x197d0
movl (%rax,%rcx,8), %eax
movl %eax, -0x438(%rbp)
cmpl $0x20, -0x438(%rbp)
jge 0x1401
leaq -0x43d(%rbp), %rdi
movl -0x438(%rbp), %ecx
movl $0x5, %esi
leaq 0x3c0c(%rip), %rdx      # 0x5004
movb $0x0, %al
callq 0x1070
jmp 0x1432
movl -0x438(%rbp), %eax
movzwl %ax, %edi
callq 0x1ba0
movl %eax, %edi
leaq -0x43d(%rbp), %rsi
callq 0x4320
movl %eax, -0x444(%rbp)
movslq -0x444(%rbp), %rax
movb $0x0, -0x43d(%rbp,%rax)
cmpl $0xff, -0x438(%rbp)
jle 0x147c
movl -0x438(%rbp), %esi
sarl $0x8, %esi
movl -0x438(%rbp), %edx
andl $0xff, %edx
movslq -0x434(%rbp), %rcx
leaq 0x1836f(%rip), %rax     # 0x197d0
movl 0x4(%rax,%rcx,8), %ecx
leaq -0x43d(%rbp), %r8
leaq 0x3b98(%rip), %rdi      # 0x500b
movb $0x0, %al
callq 0x1060
jmp 0x14af
movl -0x438(%rbp), %esi
andl $0xff, %esi
movslq -0x434(%rbp), %rcx
leaq 0x1833a(%rip), %rax     # 0x197d0
movl 0x4(%rax,%rcx,8), %edx
leaq -0x43d(%rbp), %rcx
leaq 0x3b78(%rip), %rdi      # 0x5020
movb $0x0, %al
callq 0x1060
jmp 0x14b1
movl -0x434(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x434(%rbp)
jmp 0x1395
xorl %eax, %eax
addq $0x450, %rsp            # imm = 0x450
popq %rbp
retq