// File: NKUSec[P]Rethinking-Honeywords/gen.cpp
// Function: read_dic(char*)
void read_dic(char* dic_file)
{
	int line_cnt = 0;
	char line[LINE_LEN];
	FILE* fpwd = fopen(dic_file, "r");
	while (fgets(line, LINE_LEN, fpwd))
	{
		int l = strlen(line);
		line_cnt++;
		if (line_cnt % 10000==0) printf("%d\n", line_cnt);
		if (line[l-1] == '\n') {line[l-1] = '\0'; l--;}
		if (line[l-1] == '\r') {line[l-1] = '\0'; l--;}
		if (l>=WORD_LEN) continue;

		anpair anp;
		BaseStructure bs;
		char w[WORD_LEN];
		if (isDigit(line[0])) anp.a = 'D';
		else if (isAlpha(line[0])) anp.a = 'L';
		else anp.a = 'S';
		w[0] = line[0];
		anp.n = 1;

		int ptr = 1; int wptr = 1;
		while (line[ptr] != '\0')
		{
			if (isDigit(line[ptr]))
			{
				if (anp.a == 'D')
				{
					anp.n++;
					w[wptr] = line[ptr];
				}
				else
				{
					bs.add(anp);
					anp.a = 'D'; anp.n = 1;
					w[wptr] = '\0';
					if (isAlpha(w[0])) {if (!LTree.insert(w)) LT[wptr].n++;}
					else {if (!STree.insert(w)) ST[wptr].n++;}
					w[0] = line[ptr]; wptr = 0;
				}
			}
			else if (isAlpha(line[ptr]))
			{
				if (anp.a == 'L')
				{
					anp.n++;
					w[wptr] = line[ptr];
				}
				else
				{
					bs.add(anp);
					anp.a = 'L'; anp.n = 1;
					w[wptr] = '\0';
					if (isDigit(w[0])) {if (!DTree.insert(w)) DT[wptr].n++;}
					else {if (!STree.insert(w)) ST[wptr].n++;}
					w[0] = line[ptr]; wptr = 0;
				}
			}
			else
			{
				if (anp.a == 'S')
				{
					anp.n++;
					w[wptr] = line[ptr];
				}
				else
				{
					bs.add(anp);
					anp.a = 'S'; anp.n = 1;
					w[wptr] = '\0';
					if (isDigit(w[0])) {if (!DTree.insert(w)) DT[wptr].n++;}
					else {if (!LTree.insert(w)) LT[wptr].n++;}
					w[0] = line[ptr]; wptr = 0;
				}
			}
			ptr++; wptr++;
		}
		w[wptr] = '\0';
		if (isDigit(w[0])) {if (!DTree.insert(w)) DT[wptr].n++;}
		else if (isAlpha(w[0])) {if (!LTree.insert(w)) LT[wptr].n++;}
		else {if (!STree.insert(w)) ST[wptr].n++;}
		bs.add(anp);
	}
	fclose(fpwd);

	printf("read in.\n");

	for (int i = 0; i < WORD_LEN; i++)
	{
		DT[i].makeSpace(); LT[i].makeSpace(); ST[i].makeSpace(); 
	}

	printIntoSegTable(LT, &LTree);
	printIntoSegTable(DT, &DTree);
	printIntoSegTable(ST, &STree);
	printf("write in table.\n");
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x18810, %rsp          # imm = 0x18810
movq %rdi, -0x8(%rbp)
movl $0x0, -0xc(%rbp)
movq -0x8(%rbp), %rdi
leaq 0x28ef(%rip), %rsi      # 0x4010
callq 0x10f0
movq %rax, -0x186b8(%rbp)
leaq -0x186b0(%rbp), %rdi
movq -0x186b8(%rbp), %rdx
movl $0x186a0, %esi          # imm = 0x186A0
callq 0x1110
cmpq $0x0, %rax
je 0x1d44
leaq -0x186b0(%rbp), %rdi
callq 0x1060
movl %eax, -0x186bc(%rbp)
movl -0xc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc(%rbp)
movl -0xc(%rbp), %eax
movl $0x2710, %ecx           # imm = 0x2710
cltd
idivl %ecx
cmpl $0x0, %edx
jne 0x178b
movl -0xc(%rbp), %esi
leaq 0x288e(%rip), %rdi      # 0x4012
movb $0x0, %al
callq 0x1040
movl -0x186bc(%rbp), %eax
subl $0x1, %eax
cltq
movsbl -0x186b0(%rbp,%rax), %eax
cmpl $0xa, %eax
jne 0x17c5
movl -0x186bc(%rbp), %eax
subl $0x1, %eax
cltq
movb $0x0, -0x186b0(%rbp,%rax)
movl -0x186bc(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x186bc(%rbp)
movl -0x186bc(%rbp), %eax
subl $0x1, %eax
cltq
movsbl -0x186b0(%rbp,%rax), %eax
cmpl $0xd, %eax
jne 0x17ff
movl -0x186bc(%rbp), %eax
subl $0x1, %eax
cltq
movb $0x0, -0x186b0(%rbp,%rax)
movl -0x186bc(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x186bc(%rbp)
cmpl $0x1e, -0x186bc(%rbp)
jl 0x180d
jmp 0x172d
leaq -0x187b8(%rbp), %rdi
callq 0x2800
movsbl -0x186b0(%rbp), %edi
callq 0x1420
testb $0x1, %al
jne 0x182b
jmp 0x1834
movb $0x44, -0x186c4(%rbp)
jmp 0x1858
movsbl -0x186b0(%rbp), %edi
callq 0x1450
testb $0x1, %al
jne 0x1846
jmp 0x184f
movb $0x4c, -0x186c4(%rbp)
jmp 0x1856
movb $0x53, -0x186c4(%rbp)
jmp 0x1858
movb -0x186b0(%rbp), %al
movb %al, -0x187e0(%rbp)
movl $0x1, -0x186c0(%rbp)
movl $0x1, -0x187e4(%rbp)
movl $0x1, -0x187e8(%rbp)
movslq -0x187e4(%rbp), %rax
movsbl -0x186b0(%rbp,%rax), %eax
cmpl $0x0, %eax
je 0x1c4a
movslq -0x187e4(%rbp), %rax
movsbl -0x186b0(%rbp,%rax), %edi
callq 0x1420
testb $0x1, %al
jne 0x18b7
jmp 0x19d3
movsbl -0x186c4(%rbp), %eax
cmpl $0x44, %eax
jne 0x18f3
movl -0x186c0(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x186c0(%rbp)
movslq -0x187e4(%rbp), %rax
movb -0x186b0(%rbp,%rax), %cl
movslq -0x187e8(%rbp), %rax
movb %cl, -0x187e0(%rbp,%rax)
jmp 0x19ce
movq -0x186c4(%rbp), %rax
movq %rax, -0x187f0(%rbp)
movq -0x187f0(%rbp), %rsi
leaq -0x187b8(%rbp), %rdi
callq 0x2820
movb $0x44, -0x186c4(%rbp)
movl $0x1, -0x186c0(%rbp)
movslq -0x187e8(%rbp), %rax
movb $0x0, -0x187e0(%rbp,%rax)
movsbl -0x187e0(%rbp), %edi
callq 0x1450
testb $0x1, %al
jne 0x1946
jmp 0x197b
leaq -0x187e0(%rbp), %rsi
leaq 0x478c(%rip), %rdi      # 0x60e0
callq 0x2850
testb $0x1, %al
jne 0x1979
movslq -0x187e8(%rbp), %rcx
leaq 0x4a55(%rip), %rax      # 0x63c0
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl (%rax), %ecx
addl $0x1, %ecx
movl %ecx, (%rax)
jmp 0x19b0
leaq -0x187e0(%rbp), %rsi
leaq 0x475f(%rip), %rdi      # 0x60e8
callq 0x2850
testb $0x1, %al
jne 0x19ae
movslq -0x187e8(%rbp), %rcx
leaq 0x4cf0(%rip), %rax      # 0x6690
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl (%rax), %ecx
addl $0x1, %ecx
movl %ecx, (%rax)
jmp 0x19b0
movslq -0x187e4(%rbp), %rax
movb -0x186b0(%rbp,%rax), %al
movb %al, -0x187e0(%rbp)
movl $0x0, -0x187e8(%rbp)
jmp 0x1c27
movslq -0x187e4(%rbp), %rax
movsbl -0x186b0(%rbp,%rax), %edi
callq 0x1450
testb $0x1, %al
jne 0x19f0
jmp 0x1b0c
movsbl -0x186c4(%rbp), %eax
cmpl $0x4c, %eax
jne 0x1a2c
movl -0x186c0(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x186c0(%rbp)
movslq -0x187e4(%rbp), %rax
movb -0x186b0(%rbp,%rax), %cl
movslq -0x187e8(%rbp), %rax
movb %cl, -0x187e0(%rbp,%rax)
jmp 0x1b07
movq -0x186c4(%rbp), %rax
movq %rax, -0x187f8(%rbp)
movq -0x187f8(%rbp), %rsi
leaq -0x187b8(%rbp), %rdi
callq 0x2820
movb $0x4c, -0x186c4(%rbp)
movl $0x1, -0x186c0(%rbp)
movslq -0x187e8(%rbp), %rax
movb $0x0, -0x187e0(%rbp,%rax)
movsbl -0x187e0(%rbp), %edi
callq 0x1420
testb $0x1, %al
jne 0x1a7f
jmp 0x1ab4
leaq -0x187e0(%rbp), %rsi
leaq 0x464b(%rip), %rdi      # 0x60d8
callq 0x2850
testb $0x1, %al
jne 0x1ab2
movslq -0x187e8(%rbp), %rcx
leaq 0x464c(%rip), %rax      # 0x60f0
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl (%rax), %ecx
addl $0x1, %ecx
movl %ecx, (%rax)
jmp 0x1ae9
leaq -0x187e0(%rbp), %rsi
leaq 0x4626(%rip), %rdi      # 0x60e8
callq 0x2850
testb $0x1, %al
jne 0x1ae7
movslq -0x187e8(%rbp), %rcx
leaq 0x4bb7(%rip), %rax      # 0x6690
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl (%rax), %ecx
addl $0x1, %ecx
movl %ecx, (%rax)
jmp 0x1ae9
movslq -0x187e4(%rbp), %rax
movb -0x186b0(%rbp,%rax), %al
movb %al, -0x187e0(%rbp)
movl $0x0, -0x187e8(%rbp)
jmp 0x1c25
movsbl -0x186c4(%rbp), %eax
cmpl $0x53, %eax
jne 0x1b48
movl -0x186c0(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x186c0(%rbp)
movslq -0x187e4(%rbp), %rax
movb -0x186b0(%rbp,%rax), %cl
movslq -0x187e8(%rbp), %rax
movb %cl, -0x187e0(%rbp,%rax)
jmp 0x1c23
movq -0x186c4(%rbp), %rax
movq %rax, -0x18800(%rbp)
movq -0x18800(%rbp), %rsi
leaq -0x187b8(%rbp), %rdi
callq 0x2820
movb $0x53, -0x186c4(%rbp)
movl $0x1, -0x186c0(%rbp)
movslq -0x187e8(%rbp), %rax
movb $0x0, -0x187e0(%rbp,%rax)
movsbl -0x187e0(%rbp), %edi
callq 0x1420
testb $0x1, %al
jne 0x1b9b
jmp 0x1bd0
leaq -0x187e0(%rbp), %rsi
leaq 0x452f(%rip), %rdi      # 0x60d8
callq 0x2850
testb $0x1, %al
jne 0x1bce
movslq -0x187e8(%rbp), %rcx
leaq 0x4530(%rip), %rax      # 0x60f0
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl (%rax), %ecx
addl $0x1, %ecx
movl %ecx, (%rax)
jmp 0x1c05
leaq -0x187e0(%rbp), %rsi
leaq 0x4502(%rip), %rdi      # 0x60e0
callq 0x2850
testb $0x1, %al
jne 0x1c03
movslq -0x187e8(%rbp), %rcx
leaq 0x47cb(%rip), %rax      # 0x63c0
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl (%rax), %ecx
addl $0x1, %ecx
movl %ecx, (%rax)
jmp 0x1c05
movslq -0x187e4(%rbp), %rax
movb -0x186b0(%rbp,%rax), %al
movb %al, -0x187e0(%rbp)
movl $0x0, -0x187e8(%rbp)
jmp 0x1c25
jmp 0x1c27
movl -0x187e4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x187e4(%rbp)
movl -0x187e8(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x187e8(%rbp)
jmp 0x1882
movslq -0x187e8(%rbp), %rax
movb $0x0, -0x187e0(%rbp,%rax)
movsbl -0x187e0(%rbp), %edi
callq 0x1420
testb $0x1, %al
jne 0x1c6b
jmp 0x1ca0
leaq -0x187e0(%rbp), %rsi
leaq 0x445f(%rip), %rdi      # 0x60d8
callq 0x2850
testb $0x1, %al
jne 0x1c9e
movslq -0x187e8(%rbp), %rcx
leaq 0x4460(%rip), %rax      # 0x60f0
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl (%rax), %ecx
addl $0x1, %ecx
movl %ecx, (%rax)
jmp 0x1d1e
movsbl -0x187e0(%rbp), %edi
callq 0x1450
testb $0x1, %al
jne 0x1cb2
jmp 0x1ce7
leaq -0x187e0(%rbp), %rsi
leaq 0x4420(%rip), %rdi      # 0x60e0
callq 0x2850
testb $0x1, %al
jne 0x1ce5
movslq -0x187e8(%rbp), %rcx
leaq 0x46e9(%rip), %rax      # 0x63c0
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl (%rax), %ecx
addl $0x1, %ecx
movl %ecx, (%rax)
jmp 0x1d1c
leaq -0x187e0(%rbp), %rsi
leaq 0x43f3(%rip), %rdi      # 0x60e8
callq 0x2850
testb $0x1, %al
jne 0x1d1a
movslq -0x187e8(%rbp), %rcx
leaq 0x4984(%rip), %rax      # 0x6690
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl (%rax), %ecx
addl $0x1, %ecx
movl %ecx, (%rax)
jmp 0x1d1c
jmp 0x1d1e
movq -0x186c4(%rbp), %rax
movq %rax, -0x18808(%rbp)
movq -0x18808(%rbp), %rsi
leaq -0x187b8(%rbp), %rdi
callq 0x2820
jmp 0x172d
movq -0x186b8(%rbp), %rdi
callq 0x10c0
leaq 0x22bf(%rip), %rdi      # 0x4016
movb $0x0, %al
callq 0x1040
movl $0x0, -0x1880c(%rbp)
cmpl $0x1e, -0x1880c(%rbp)
jge 0x1dd0
movslq -0x1880c(%rbp), %rax
leaq 0x4371(%rip), %rdi      # 0x60f0
imulq $0x18, %rax, %rax
addq %rax, %rdi
callq 0x29a0
movslq -0x1880c(%rbp), %rax
leaq 0x4627(%rip), %rdi      # 0x63c0
imulq $0x18, %rax, %rax
addq %rax, %rdi
callq 0x29a0
movslq -0x1880c(%rbp), %rax
leaq 0x48dd(%rip), %rdi      # 0x6690
imulq $0x18, %rax, %rax
addq %rax, %rdi
callq 0x29a0
movl -0x1880c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1880c(%rbp)
jmp 0x1d68
leaq 0x45e9(%rip), %rdi      # 0x63c0
leaq 0x4302(%rip), %rsi      # 0x60e0
callq 0x1670
leaq 0x4306(%rip), %rdi      # 0x60f0
leaq 0x42e7(%rip), %rsi      # 0x60d8
callq 0x1670
leaq 0x4893(%rip), %rdi      # 0x6690
leaq 0x42e4(%rip), %rsi      # 0x60e8
callq 0x1670
leaq 0x2210(%rip), %rdi      # 0x4020
movb $0x0, %al
callq 0x1040
addq $0x18810, %rsp          # imm = 0x18810
popq %rbp
retq