// File: NKUSec[P]Rethinking-Honeywords/calc.cpp
// Function: read_training_set(char*)
void read_training_set(char* training_set)
{
	char line[LINE_LEN];
	FILE* fin = fopen(training_set, "r");
	while (fgets(line, LINE_LEN, fin))
	{
		dic_size++;
		int l = strlen(line);
		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;

		map<string, int>::iterator it;
		it = train_dic.find(line);
		if (it == train_dic.end())
			train_dic.insert(make_pair(line, 1));
		else
			it->second++;

		if (dic_size % 10000 == 0) printf("%d\n", dic_size);
	}
	fclose(fin);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x27d0, %rsp           # imm = 0x27D0
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rdi
leaq 0x1c56(%rip), %rsi      # 0x4010
callq 0x21b0
movq %rax, -0x2728(%rbp)
leaq -0x2720(%rbp), %rdi
movq -0x2728(%rbp), %rdx
movl $0x2710, %esi           # imm = 0x2710
callq 0x21f0
cmpq $0x0, %rax
je 0x262c
movl 0x4d66(%rip), %eax      # 0x7154
addl $0x1, %eax
movl %eax, 0x4d5d(%rip)      # 0x7154
leaq -0x2720(%rbp), %rdi
callq 0x20a0
movl %eax, -0x272c(%rbp)
movl -0x272c(%rbp), %eax
subl $0x1, %eax
cltq
movsbl -0x2720(%rbp,%rax), %eax
cmpl $0xa, %eax
jne 0x2443
movl -0x272c(%rbp), %eax
subl $0x1, %eax
cltq
movb $0x0, -0x2720(%rbp,%rax)
movl -0x272c(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x272c(%rbp)
movl -0x272c(%rbp), %eax
subl $0x1, %eax
cltq
movsbl -0x2720(%rbp,%rax), %eax
cmpl $0xd, %eax
jne 0x247d
movl -0x272c(%rbp), %eax
subl $0x1, %eax
cltq
movb $0x0, -0x2720(%rbp,%rax)
movl -0x272c(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x272c(%rbp)
cmpl $0x1e, -0x272c(%rbp)
jl 0x248b
jmp 0x23c6
leaq -0x2738(%rbp), %rdi
callq 0x2b90
leaq -0x2761(%rbp), %rdi
movq %rdi, -0x27c0(%rbp)
callq 0x2220
movq -0x27c0(%rbp), %rdx
leaq -0x2760(%rbp), %rdi
leaq -0x2720(%rbp), %rsi
callq 0x2be0
jmp 0x24c6
leaq 0x4c8b(%rip), %rdi      # 0x7158
leaq -0x2760(%rbp), %rsi
callq 0x2bb0
movq %rax, -0x27c8(%rbp)
jmp 0x24e2
movq -0x27c8(%rbp), %rax
movq %rax, -0x2740(%rbp)
movq -0x2740(%rbp), %rax
movq %rax, -0x2738(%rbp)
leaq -0x2760(%rbp), %rdi
callq 0x20b0
leaq -0x2761(%rbp), %rdi
callq 0x2180
leaq 0x4c3b(%rip), %rdi      # 0x7158
callq 0x2cc0
movq %rax, -0x2780(%rbp)
leaq -0x2738(%rbp), %rdi
leaq -0x2780(%rbp), %rsi
callq 0x2c90
testb $0x1, %al
jne 0x2545
jmp 0x25eb
movl $0x1, -0x2794(%rbp)
leaq -0x2720(%rbp), %rdi
leaq -0x2794(%rbp), %rsi
callq 0x2d30
movl %edx, -0x27a0(%rbp)
movq %rax, -0x27a8(%rbp)
movq -0x27a8(%rbp), %rax
movq %rax, -0x2790(%rbp)
movl -0x27a0(%rbp), %eax
movl %eax, -0x2788(%rbp)
leaq 0x4bc8(%rip), %rdi      # 0x7158
leaq -0x2790(%rbp), %rsi
callq 0x2cf0
movq %rax, -0x27b8(%rbp)
movb %dl, -0x27b0(%rbp)
jmp 0x2600
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x2770(%rbp)
movl %eax, -0x2774(%rbp)
jmp 0x25dd
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x2770(%rbp)
movl %eax, -0x2774(%rbp)
leaq -0x2760(%rbp), %rdi
callq 0x20b0
leaq -0x2761(%rbp), %rdi
callq 0x2180
jmp 0x2641
leaq -0x2738(%rbp), %rdi
callq 0x2d70
movl 0x20(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x20(%rax)
movl 0x4b4e(%rip), %eax      # 0x7154
movl $0x2710, %ecx           # imm = 0x2710
cltd
idivl %ecx
cmpl $0x0, %edx
jne 0x2627
movl 0x4b3b(%rip), %esi      # 0x7154
leaq 0x1a01(%rip), %rdi      # 0x4021
movb $0x0, %al
callq 0x2040
jmp 0x23c6
movq -0x2728(%rbp), %rdi
callq 0x2130
addq $0x27d0, %rsp           # imm = 0x27D0
popq %rbp
retq
movq -0x2770(%rbp), %rdi
callq 0x2210
nopl (%rax)