// File: /workspace/github_cpp_makefile_star2_O3/szmer[P]brill/./src/corpus.cpp
// Function: Corpus::tag_with_table(std::map<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::less<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>, std::allocator<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>>>*)
Corpus Corpus::tag_with_table(map<string,string> * tbl) {

	// Find the most frequent tag in the table and make it default.
	map<string, int> freqs;
	for(map<string,string>::iterator i = tbl->begin(); i != tbl->end(); i++) {

		if(freqs.find(i->second) == freqs.end())
			freqs[i->second] = 1;

		else	freqs[i->second]++;

	}
	string default_tag;
	int default_freq = 0;
	for(map<string,int>::iterator i = freqs.begin(); i != freqs.end(); i++)
		if(i->second > default_freq) {
			default_freq = i->second;
			default_tag = i->first;
		}
	default_tag = "NN";

	// Create and tag the child corpus. 
	Corpus child;
	child.sentences.reserve(sentences.size());

	for( unsigned int si = 0; si < sentences.size(); si++ ) {

		vector<TaggedWord> * stc = & sentences[si];

		child.sentences.push_back( vector<TaggedWord>() );
		child.sentences.rbegin()->reserve( stc->size() );	// reserve space in the last sentence
									// vector of the child

		for( unsigned int wi = 0; wi < stc->size(); wi++ ) {
			if(tbl->find(stc->at(wi).word) != tbl->end()) // we know exact tag for this word
				child.sentences.rbegin()->push_back( TaggedWord(stc->at(wi).word,
									(*tbl)[stc->at(wi).word]) );
			else 					// use the default tag instead
				child.sentences.rbegin()->push_back( TaggedWord(stc->at(wi).word,
									default_tag) );
		}
	}

	return child;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x148, %rsp            # imm = 0x148
movq %rsi, %r14
movq %rdi, -0x30(%rbp)
leaq -0x160(%rbp), %r13
movl $0x0, (%r13)
xorl %eax, %eax
movq %rax, 0x8(%r13)
movq %r13, 0x10(%r13)
movq %r13, 0x18(%r13)
movq %rax, 0x20(%r13)
movq 0x18(%rdx), %rbx
movq %rdx, -0x50(%rbp)
leaq 0x8(%rdx), %rax
movq %rax, -0x48(%rbp)
cmpq %rax, %rbx
movq %rsi, -0x40(%rbp)
je 0x3316
leaq -0x168(%rbp), %r15
leaq 0x40(%rbx), %r12
movq %r15, %rdi
movq %r12, %rsi
callq 0x826e
cmpq %r13, %rax
je 0x3299
movq %r15, %rdi
movq %r12, %rsi
callq 0x64d0
incl (%rax)
jmp 0x32aa
movq %r15, %rdi
movq %r12, %rsi
callq 0x64d0
movl $0x1, (%rax)
movq %rbx, %rdi
callq 0x2130
movq %rax, %rbx
cmpq -0x48(%rbp), %rax
jne 0x3276
movq -0x150(%rbp), %r15
leaq -0x60(%rbp), %rax
movq %rax, -0x10(%rax)
movq $0x0, -0x8(%rax)
movq %rax, -0x38(%rbp)
movb $0x0, (%rax)
xorl %ebx, %ebx
cmpq %r13, %r15
je 0x332f
leaq -0x70(%rbp), %r12
movl 0x40(%r15), %r14d
cmpl %ebx, %r14d
jle 0x32fc
leaq 0x20(%r15), %rsi
movq %r12, %rdi
callq 0x2110
movl %r14d, %ebx
movq %r15, %rdi
callq 0x2130
movq %rax, %r15
cmpq %r13, %rax
jne 0x32e4
movq -0x68(%rbp), %rbx
movq -0x40(%rbp), %r14
jmp 0x332f
leaq -0x60(%rbp), %rax
movq %rax, -0x10(%rax)
movq $0x0, -0x8(%rax)
movq %rax, -0x38(%rbp)
movb $0x0, (%rax)
xorl %ebx, %ebx
leaq 0x5eb0(%rip), %rcx      # 0x91e6
leaq -0x70(%rbp), %rdi
movl $0x2, %r8d
xorl %esi, %esi
movq %rbx, %rdx
callq 0x2280
movq -0x30(%rbp), %r13
xorps %xmm0, %xmm0
movups %xmm0, (%r13)
xorl %eax, %eax
movq %rax, 0x10(%r13)
leaq 0x20(%r13), %rcx
movl $0x0, 0x20(%r13)
movq %rax, 0x28(%r13)
movq %rcx, 0x30(%r13)
movq %rcx, 0x38(%r13)
movq %rax, 0x40(%r13)
movq 0x8(%r14), %rsi
subq (%r14), %rsi
sarq $0x3, %rsi
movabsq $-0x5555555555555555, %rax # imm = 0xAAAAAAAAAAAAAAAB
imulq %rax, %rsi
movq %r13, %rdi
callq 0x629e
movq (%r14), %rbx
cmpq %rbx, 0x8(%r14)
je 0x36cf
xorl %r15d, %r15d
xorps %xmm0, %xmm0
movaps %xmm0, -0xb0(%rbp)
movq $0x0, -0xa0(%rbp)
movq %r13, %rdi
leaq -0xb0(%rbp), %r12
movq %r12, %rsi
callq 0x6faa
movq %r15, -0x138(%rbp)
leaq (%r15,%r15,2), %rax
leaq (%rbx,%rax,8), %r15
movq %r12, %rdi
callq 0x603a
movq 0x8(%r13), %rdi
addq $-0x18, %rdi
movq 0x8(%r15), %rsi
subq (%r15), %rsi
sarq $0x6, %rsi
callq 0x63bc
movq (%r15), %rsi
cmpq %rsi, 0x8(%r15)
je 0x369c
movl $0x1, %r12d
xorl %r14d, %r14d
movq %r14, %r13
shlq $0x6, %r13
addq %r13, %rsi
movq -0x50(%rbp), %rdi
callq 0x82be
movq -0x30(%rbp), %rcx
movq 0x8(%rcx), %rbx
addq $-0x18, %rbx
cmpq -0x48(%rbp), %rax
je 0x3570
movq (%r15), %rax
movq 0x8(%r15), %rdx
subq %rax, %rdx
sarq $0x6, %rdx
cmpq %r14, %rdx
jbe 0x3717
leaq -0xe0(%rbp), %rcx
movq %rcx, -0xf0(%rbp)
movq (%rax,%r13), %rsi
movq 0x8(%rax,%r13), %rdx
addq %rsi, %rdx
leaq -0xf0(%rbp), %rdi
callq 0x6e16
movq (%r15), %rsi
movq 0x8(%r15), %rdx
subq %rsi, %rdx
sarq $0x6, %rdx
cmpq %r14, %rdx
jbe 0x3706
addq %r13, %rsi
movq -0x50(%rbp), %rdi
callq 0x6550
leaq -0x130(%rbp), %r13
leaq -0x120(%rbp), %rcx
movq %rcx, -0x130(%rbp)
movq (%rax), %rsi
movq 0x8(%rax), %rdx
addq %rsi, %rdx
movq %r13, %rdi
callq 0x6e16
leaq -0xb0(%rbp), %r14
movq %r14, %rdi
leaq -0xf0(%rbp), %rsi
movq %r13, %rdx
movq -0x30(%rbp), %r13
callq 0x6168
movq %rbx, %rdi
movq %r14, %rsi
callq 0x71d6
movq -0x90(%rbp), %rdi
leaq -0x80(%rbp), %rax
cmpq %rax, %rdi
je 0x3509
movq -0x80(%rbp), %rsi
incq %rsi
callq 0x21c0
movq -0xb0(%rbp), %rdi
leaq -0xa0(%rbp), %rax
cmpq %rax, %rdi
je 0x352b
movq -0xa0(%rbp), %rsi
incq %rsi
callq 0x21c0
movq -0x130(%rbp), %rdi
leaq -0x120(%rbp), %rax
cmpq %rax, %rdi
je 0x354d
movq -0x120(%rbp), %rsi
incq %rsi
callq 0x21c0
movq -0xf0(%rbp), %rdi
leaq -0xe0(%rbp), %rax
cmpq %rax, %rdi
je 0x367f
movq -0xe0(%rbp), %rsi
jmp 0x3677
movq (%r15), %rax
movq 0x8(%r15), %rdx
subq %rax, %rdx
sarq $0x6, %rdx
cmpq %r14, %rdx
jbe 0x372c
leaq -0xc0(%rbp), %rcx
movq %rcx, -0xd0(%rbp)
movq (%rax,%r13), %rsi
movq 0x8(%rax,%r13), %rdx
addq %rsi, %rdx
leaq -0xd0(%rbp), %rdi
callq 0x6e16
leaq -0x100(%rbp), %rax
movq %rax, -0x110(%rbp)
movq -0x70(%rbp), %rsi
movq -0x68(%rbp), %rdx
addq %rsi, %rdx
leaq -0x110(%rbp), %r14
movq %r14, %rdi
movq -0x30(%rbp), %r13
callq 0x6e16
movq %r14, %rdx
leaq -0xb0(%rbp), %r14
movq %r14, %rdi
leaq -0xd0(%rbp), %rsi
callq 0x6168
movq %rbx, %rdi
movq %r14, %rsi
callq 0x71d6
movq -0x90(%rbp), %rdi
leaq -0x80(%rbp), %rax
cmpq %rax, %rdi
je 0x3619
movq -0x80(%rbp), %rsi
incq %rsi
callq 0x21c0
movq -0xb0(%rbp), %rdi
leaq -0xa0(%rbp), %rax
cmpq %rax, %rdi
je 0x363b
movq -0xa0(%rbp), %rsi
incq %rsi
callq 0x21c0
movq -0x110(%rbp), %rdi
leaq -0x100(%rbp), %rax
cmpq %rax, %rdi
je 0x365d
movq -0x100(%rbp), %rsi
incq %rsi
callq 0x21c0
movq -0xd0(%rbp), %rdi
leaq -0xc0(%rbp), %rax
cmpq %rax, %rdi
je 0x367f
movq -0xc0(%rbp), %rsi
incq %rsi
callq 0x21c0
movl %r12d, %r14d
movq (%r15), %rsi
movq 0x8(%r15), %rax
subq %rsi, %rax
sarq $0x6, %rax
incl %r12d
cmpq %r14, %rax
ja 0x3415
movq -0x138(%rbp), %r15
incl %r15d
movq -0x40(%rbp), %r14
movq (%r14), %rbx
movq 0x8(%r14), %rax
subq %rbx, %rax
sarq $0x3, %rax
movabsq $-0x5555555555555555, %rcx # imm = 0xAAAAAAAAAAAAAAAB
imulq %rcx, %rax
cmpq %r15, %rax
ja 0x33a9
movq -0x70(%rbp), %rdi
cmpq -0x38(%rbp), %rdi
je 0x36e5
movq -0x60(%rbp), %rsi
incq %rsi
callq 0x21c0
leaq -0x168(%rbp), %rdi
callq 0x68d0
movq %r13, %rax
addq $0x148, %rsp            # imm = 0x148
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x5d3b(%rip), %rdi      # 0x9448
movq %r14, %rsi
xorl %eax, %eax
callq 0x2260
leaq 0x5d2a(%rip), %rdi      # 0x9448
movq %r14, %rsi
xorl %eax, %eax
movq -0x30(%rbp), %r13
callq 0x2260
leaq 0x5d15(%rip), %rdi      # 0x9448
movq %r14, %rsi
xorl %eax, %eax
movq -0x30(%rbp), %r13
callq 0x2260
jmp 0x37ce
jmp 0x3748
movq %rax, %r14
jmp 0x3852
movq %rax, %r14
leaq -0xb0(%rbp), %rdi
callq 0x603a
jmp 0x3841
jmp 0x37ce
jmp 0x3768
movq %rax, %r14
jmp 0x3868
movq %rax, %r14
jmp 0x37b2
jmp 0x380f
movq %rax, %r14
leaq -0xb0(%rbp), %rdi
callq 0x61ea
jmp 0x3790
jmp 0x37ce
movq %rax, %r14
movq -0x110(%rbp), %rdi
leaq -0x100(%rbp), %rax
cmpq %rax, %rdi
je 0x37b2
movq -0x100(%rbp), %rsi
incq %rsi
callq 0x21c0
movq -0xd0(%rbp), %rdi
leaq -0xc0(%rbp), %rax
cmpq %rax, %rdi
je 0x3841
movq -0xc0(%rbp), %rsi
jmp 0x3839
movq %rax, %r14
jmp 0x3841
movq %rax, %r14
jmp 0x37e9
jmp 0x380f
movq %rax, %r14
leaq -0xb0(%rbp), %rdi
callq 0x61ea
movq -0x130(%rbp), %rdi
leaq -0x120(%rbp), %rax
cmpq %rax, %rdi
je 0x381f
movq -0x120(%rbp), %rsi
incq %rsi
callq 0x21c0
jmp 0x381f
jmp 0x3818
movq %rax, %r14
movq -0x30(%rbp), %r13
jmp 0x3841
movq %rax, %r14
movq -0x30(%rbp), %r13
movq -0xf0(%rbp), %rdi
leaq -0xe0(%rbp), %rax
cmpq %rax, %rdi
je 0x3841
movq -0xe0(%rbp), %rsi
incq %rsi
callq 0x21c0
leaq 0x18(%r13), %rdi
callq 0x6960
movq %r13, %rdi
callq 0x67cc
movq -0x70(%rbp), %rdi
cmpq -0x38(%rbp), %rdi
je 0x3868
movq -0x60(%rbp), %rsi
incq %rsi
callq 0x21c0
leaq -0x168(%rbp), %rdi
callq 0x68d0
movq %r14, %rdi
callq 0x2320