// File: /workspace/github_cpp_makefile_star2_O1/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 0x298e
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 0x2770
cmpb $0x0, -0x301(%rbp)
jne 0x2a08
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 0x6e0c
cmpq $0x0, -0x48(%rbp)
je 0x2930
movq -0x30(%rbp), %rcx
movq 0x8(%rcx), %rax
cmpq (%rcx), %rax
je 0x2a2f
movl $0x1, %ecx
movq %r12, %rdi
leaq 0x69a9(%rip), %rbx      # 0x916d
movq %rbx, %rsi
xorl %edx, %edx
callq 0x2300
movq %rax, %r14
cmpl $-0x1, %r14d
je 0x29b0
movl $0x1, %ecx
movq %r12, %rdi
movq %rbx, %rsi
movq $-0x1, %rdx
callq 0x2240
cmpl %eax, %r14d
jne 0x29b0
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 0x6d72
movq %rbx, %rdi
leaq -0xf0(%rbp), %rsi
movq %r15, %rdx
callq 0x60d8
addq $-0x18, %r13
movq %r13, %rdi
movq %rbx, %rsi
callq 0x7122
movq %rbx, %r13
movq -0xb0(%rbp), %rdi
leaq -0xa0(%rbp), %rax
cmpq %rax, %rdi
leaq -0x40(%rbp), %r14
je 0x28b5
movq -0xa0(%rbp), %rsi
incq %rsi
callq 0x21c0
movq -0xd0(%rbp), %rdi
leaq -0xc0(%rbp), %rax
cmpq %rax, %rdi
je 0x28d7
movq -0xc0(%rbp), %rsi
incq %rsi
callq 0x21c0
movq -0x70(%rbp), %rdi
leaq -0x60(%rbp), %rax
cmpq %rax, %rdi
je 0x28f0
movq -0x60(%rbp), %rsi
incq %rsi
callq 0x21c0
movq -0xf0(%rbp), %rdi
leaq -0xe0(%rbp), %rax
cmpq %rax, %rdi
je 0x2912
movq -0xe0(%rbp), %rsi
incq %rsi
callq 0x21c0
movq -0x90(%rbp), %rdi
leaq -0x80(%rbp), %rax
cmpq %rax, %rdi
je 0x2959
movq -0x80(%rbp), %rsi
incq %rsi
callq 0x21c0
jmp 0x2959
xorps %xmm0, %xmm0
movaps %xmm0, -0xd0(%rbp)
movq $0x0, -0xc0(%rbp)
movq -0x30(%rbp), %rdi
movq %r13, %rsi
callq 0x6efe
movq %r13, %rdi
callq 0x5faa
movq -0x50(%rbp), %rdi
cmpq %r14, %rdi
je 0x296e
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 0x2731
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 0x67ab(%rip), %rsi      # 0x916f
leaq -0xd0(%rbp), %rdi
leaq -0x50(%rbp), %rdx
callq 0x6045
movb $0x1, %r12b
leaq 0x67ad(%rip), %rdx      # 0x918b
leaq -0xd0(%rbp), %rsi
movq %r15, %rdi
callq 0x5fe8
xorl %r12d, %r12d
leaq 0xa3a1(%rip), %rsi      # 0xcd98
movq 0xa5c2(%rip), %rdx      # 0xcfc0
movq %r15, %rdi
callq 0x22e0
jmp 0x2a54
movl $0x8, %edi
callq 0x20f0
leaq 0x66c7(%rip), %rcx      # 0x90e0
movq %rcx, (%rax)
movq 0xa5a5(%rip), %rsi      # 0xcfc8
movq %rax, %rdi
xorl %edx, %edx
callq 0x22e0
jmp 0x2a54
movl $0x8, %edi
callq 0x20f0
leaq 0x66de(%rip), %rcx      # 0x911e
movq %rcx, (%rax)
movq 0xa57e(%rip), %rsi      # 0xcfc8
movq %rax, %rdi
xorl %edx, %edx
callq 0x22e0
movq %rax, %r14
jmp 0x2b5c
movq %rax, %r14
leaq -0xd0(%rbp), %rdi
callq 0x5faa
jmp 0x2b2e
jmp 0x2a7f
movq %rax, %r14
jmp 0x2b12
movq %rax, %r14
jmp 0x2af0
movq %rax, %r14
jmp 0x2b2e
movq %rax, %r14
movq -0xd0(%rbp), %rdi
leaq -0xc0(%rbp), %rax
cmpq %rax, %rdi
je 0x2ab4
movq -0xc0(%rbp), %rsi
incq %rsi
callq 0x21c0
jmp 0x2ab4
movq %rax, %r14
movb $0x1, %r12b
testb %r12b, %r12b
je 0x2b2e
movq %r15, %rdi
callq 0x2150
jmp 0x2b2e
movq %rax, %r14
jmp 0x2ad7
movq %rax, %r14
leaq -0xd0(%rbp), %rdi
callq 0x615a
movq -0x70(%rbp), %rdi
leaq -0x60(%rbp), %rax
cmpq %rax, %rdi
je 0x2af0
movq -0x60(%rbp), %rsi
incq %rsi
callq 0x21c0
movq -0xf0(%rbp), %rdi
leaq -0xe0(%rbp), %rax
cmpq %rax, %rdi
je 0x2b12
movq -0xe0(%rbp), %rsi
incq %rsi
callq 0x21c0
movq -0x90(%rbp), %rdi
leaq -0x80(%rbp), %rax
cmpq %rax, %rdi
je 0x2b2e
movq -0x80(%rbp), %rsi
incq %rsi
callq 0x21c0
movq -0x50(%rbp), %rdi
leaq -0x40(%rbp), %rax
cmpq %rax, %rdi
je 0x2b50
movq -0x40(%rbp), %rsi
incq %rsi
callq 0x21c0
jmp 0x2b50
jmp 0x2b4d
jmp 0x2b4d
movq %rax, %r14
leaq -0x2f8(%rbp), %rdi
callq 0x2070
movq -0x30(%rbp), %rbx
leaq 0x18(%rbx), %rdi
callq 0x68bc
movq %rbx, %rdi
callq 0x672e
movq %r14, %rdi
callq 0x2320
nop