// File: /workspace/github_cpp_makefile_star2_O3/szmer[P]brill/./src/corpus.cpp
// Function: Corpus::load_file(char const*)
Corpus Corpus::load_file(const char* fname) {
	Corpus corp;
	ifstream corp_file(fname);

	char buff [256];
	while(corp_file.good()) {

		corp_file.getline(buff, 256);
		if(corp_file.gcount() == 256 && buff[255] != '\0')
			throw "load_file: corpus file has a line longer than 256 characters!";

		string corp_file_line(buff);

		// Empty line = a new sentence in the corpus (initialize new sentence vector).
		if(corp_file_line.size() == 0) {
			corp.sentences.push_back( vector<TaggedWord>() );
			continue;
		}
		if(corp.sentences.size() == 0) // (occurs when there is no leading empty line in the file)
			throw "load_file: corpus file has no sentence start marker! (should be an empty line)";

		// ELSE: add new tagged word to the latest sentence vector.
		int tab_ind = corp_file_line.find("\t");
		if(tab_ind == -1 || tab_ind != (int)corp_file_line.rfind("\t"))
			throw "load_file: line in corpus \""+corp_file_line+"\" is improperly formatted!";

		string tag = corp_file_line.substr(tab_ind+1);
		corp.sentences.rbegin()->push_back( TaggedWord(
						corp_file_line.substr(0, tab_ind),
						tag
					) );
	}

	return corp;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x3d8, %rsp            # imm = 0x3D8
xorl %eax, %eax
movq %rax, 0x10(%rdi)
xorps %xmm0, %xmm0
movups %xmm0, (%rdi)
leaq 0x20(%rdi), %rcx
movl $0x0, 0x20(%rdi)
movq %rax, 0x28(%rdi)
movq %rcx, 0x30(%rdi)
movq %rcx, 0x38(%rdi)
movq %rdi, -0x30(%rbp)
movq %rax, 0x40(%rdi)
leaq -0x2f8(%rbp), %rdi
movl $0x8, %edx
callq 0x2340
movq -0x2f8(%rbp), %rax
movq -0x18(%rax), %rax
cmpl $0x0, -0x2d8(%rbp,%rax)
jne 0x2980
leaq (%rax,%rbp), %rdi
addq $-0x2f8, %rdi           # imm = 0xFD08
leaq -0x40(%rbp), %r14
leaq -0x50(%rbp), %r12
leaq -0xd0(%rbp), %r13
leaq -0x70(%rbp), %r15
movl $0xa, %esi
callq 0x2190
movsbl %al, %ecx
movl $0x100, %edx            # imm = 0x100
leaq -0x2f8(%rbp), %rdi
leaq -0x400(%rbp), %rsi
callq 0x2360
cmpq $0x100, -0x2f0(%rbp) # imm = 0x100
jne 0x2762
cmpb $0x0, -0x301(%rbp)
jne 0x29fa
movq %r14, -0x50(%rbp)
leaq -0x400(%rbp), %rbx
movq %rbx, %rdi
callq 0x20d0
leaq (%rax,%rbp), %rdx
addq $-0x400, %rdx           # imm = 0xFC00
movq %r12, %rdi
movq %rbx, %rsi
callq 0x6eb4
cmpq $0x0, -0x48(%rbp)
je 0x2922
movq -0x30(%rbp), %rcx
movq 0x8(%rcx), %rax
cmpq (%rcx), %rax
je 0x2a21
movl $0x1, %ecx
movq %r12, %rdi
leaq 0x69b7(%rip), %rbx      # 0x916d
movq %rbx, %rsi
xorl %edx, %edx
callq 0x2300
movq %rax, %r14
cmpl $-0x1, %r14d
je 0x29a2
movl $0x1, %ecx
movq %r12, %rdi
movq %rbx, %rsi
movq $-0x1, %rdx
callq 0x2240
cmpl %eax, %r14d
jne 0x29a2
movq %r13, %rbx
shlq $0x20, %r14
movabsq $0x100000000, %rax      # imm = 0x100000000
leaq (%r14,%rax), %rdx
sarq $0x20, %rdx
leaq -0x90(%rbp), %rdi
movq %r12, %rsi
movq $-0x1, %rcx
callq 0x21e0
movq -0x30(%rbp), %rax
movq 0x8(%rax), %r13
sarq $0x20, %r14
leaq -0xf0(%rbp), %rdi
movq %r12, %rsi
xorl %edx, %edx
movq %r14, %rcx
callq 0x21e0
leaq -0x60(%rbp), %rax
movq %rax, -0x70(%rbp)
movq -0x90(%rbp), %rsi
movq -0x88(%rbp), %rdx
addq %rsi, %rdx
movq %r15, %rdi
callq 0x6e16
movq %rbx, %rdi
leaq -0xf0(%rbp), %rsi
movq %r15, %rdx
callq 0x6168
addq $-0x18, %r13
movq %r13, %rdi
movq %rbx, %rsi
callq 0x71d6
movq %rbx, %r13
movq -0xb0(%rbp), %rdi
leaq -0xa0(%rbp), %rax
cmpq %rax, %rdi
leaq -0x40(%rbp), %r14
je 0x28a7
movq -0xa0(%rbp), %rsi
incq %rsi
callq 0x21c0
movq -0xd0(%rbp), %rdi
leaq -0xc0(%rbp), %rax
cmpq %rax, %rdi
je 0x28c9
movq -0xc0(%rbp), %rsi
incq %rsi
callq 0x21c0
movq -0x70(%rbp), %rdi
leaq -0x60(%rbp), %rax
cmpq %rax, %rdi
je 0x28e2
movq -0x60(%rbp), %rsi
incq %rsi
callq 0x21c0
movq -0xf0(%rbp), %rdi
leaq -0xe0(%rbp), %rax
cmpq %rax, %rdi
je 0x2904
movq -0xe0(%rbp), %rsi
incq %rsi
callq 0x21c0
movq -0x90(%rbp), %rdi
leaq -0x80(%rbp), %rax
cmpq %rax, %rdi
je 0x294b
movq -0x80(%rbp), %rsi
incq %rsi
callq 0x21c0
jmp 0x294b
xorps %xmm0, %xmm0
movaps %xmm0, -0xd0(%rbp)
movq $0x0, -0xc0(%rbp)
movq -0x30(%rbp), %rdi
movq %r13, %rsi
callq 0x6faa
movq %r13, %rdi
callq 0x603a
movq -0x50(%rbp), %rdi
cmpq %r14, %rdi
je 0x2960
movq -0x40(%rbp), %rsi
incq %rsi
callq 0x21c0
movq -0x2f8(%rbp), %rax
movq -0x18(%rax), %rax
leaq (%rax,%rbp), %rdi
addq $-0x2f8, %rdi           # imm = 0xFD08
cmpl $0x0, 0x20(%rdi)
je 0x2723
leaq -0x2f8(%rbp), %rdi
callq 0x2070
movq -0x30(%rbp), %rax
addq $0x3d8, %rsp            # imm = 0x3D8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0x20, %edi
callq 0x20f0
movq %rax, %r15
leaq 0x67b9(%rip), %rsi      # 0x916f
leaq -0xd0(%rbp), %rdi
leaq -0x50(%rbp), %rdx
callq 0x60d5
movb $0x1, %r12b
leaq 0x67bb(%rip), %rdx      # 0x918b
leaq -0xd0(%rbp), %rsi
movq %r15, %rdi
callq 0x6078
xorl %r12d, %r12d
leaq 0xa3af(%rip), %rsi      # 0xcd98
movq 0xa5d0(%rip), %rdx      # 0xcfc0
movq %r15, %rdi
callq 0x22e0
jmp 0x2a46
movl $0x8, %edi
callq 0x20f0
leaq 0x66d5(%rip), %rcx      # 0x90e0
movq %rcx, (%rax)
movq 0xa5b3(%rip), %rsi      # 0xcfc8
movq %rax, %rdi
xorl %edx, %edx
callq 0x22e0
jmp 0x2a46
movl $0x8, %edi
callq 0x20f0
leaq 0x66ec(%rip), %rcx      # 0x911e
movq %rcx, (%rax)
movq 0xa58c(%rip), %rsi      # 0xcfc8
movq %rax, %rdi
xorl %edx, %edx
callq 0x22e0
movq %rax, %r14
jmp 0x2b4b
movq %rax, %r14
leaq -0xd0(%rbp), %rdi
callq 0x603a
jmp 0x2b1d
jmp 0x2a71
movq %rax, %r14
jmp 0x2b01
movq %rax, %r14
jmp 0x2adf
movq %rax, %r14
jmp 0x2b1d
movq %rax, %r14
movq -0xd0(%rbp), %rdi
leaq -0xc0(%rbp), %rax
cmpq %rax, %rdi
je 0x2a9e
movq -0xc0(%rbp), %rsi
incq %rsi
callq 0x21c0
testb %r12b, %r12b
jne 0x2aa8
jmp 0x2b1d
movq %rax, %r14
movq %r15, %rdi
callq 0x2150
jmp 0x2b1d
movq %rax, %r14
jmp 0x2ac6
movq %rax, %r14
leaq -0xd0(%rbp), %rdi
callq 0x61ea
movq -0x70(%rbp), %rdi
leaq -0x60(%rbp), %rax
cmpq %rax, %rdi
je 0x2adf
movq -0x60(%rbp), %rsi
incq %rsi
callq 0x21c0
movq -0xf0(%rbp), %rdi
leaq -0xe0(%rbp), %rax
cmpq %rax, %rdi
je 0x2b01
movq -0xe0(%rbp), %rsi
incq %rsi
callq 0x21c0
movq -0x90(%rbp), %rdi
leaq -0x80(%rbp), %rax
cmpq %rax, %rdi
je 0x2b1d
movq -0x80(%rbp), %rsi
incq %rsi
callq 0x21c0
movq -0x50(%rbp), %rdi
leaq -0x40(%rbp), %rax
cmpq %rax, %rdi
je 0x2b3f
movq -0x40(%rbp), %rsi
incq %rsi
callq 0x21c0
jmp 0x2b3f
jmp 0x2b3c
jmp 0x2b3c
movq %rax, %r14
leaq -0x2f8(%rbp), %rdi
callq 0x2070
movq -0x30(%rbp), %rbx
leaq 0x18(%rbx), %rdi
callq 0x6960
movq %rbx, %rdi
callq 0x67cc
movq %r14, %rdi
callq 0x2320