// File: /workspace/github_cpp_makefile_star2_O1/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), %r15
movl $0x0, (%r15)
xorl %eax, %eax
movq %rax, 0x8(%r15)
movq %r15, 0x10(%r15)
movq %r15, 0x18(%r15)
movq %rax, 0x20(%r15)
movq 0x18(%rdx), %rbx
movq %rdx, -0x48(%rbp)
leaq 0x8(%rdx), %rax
movq %rax, -0x40(%rbp)
cmpq %rax, %rbx
je 0x32be
leaq -0x168(%rbp), %r13
leaq 0x40(%rbx), %r12
movq %r13, %rdi
movq %r12, %rsi
callq 0x81ce
cmpq %r15, %rax
je 0x329c
movq %r13, %rdi
movq %r12, %rsi
callq 0x6432
incl (%rax)
jmp 0x32ad
movq %r13, %rdi
movq %r12, %rsi
callq 0x6432
movl $0x1, (%rax)
movq %rbx, %rdi
callq 0x2130
movq %rax, %rbx
cmpq -0x40(%rbp), %rax
jne 0x3279
movq %r14, -0x38(%rbp)
leaq -0x58(%rbp), %rax
movq %rax, -0x10(%rax)
movq $0x0, -0x8(%rax)
movb $0x0, (%rax)
movq -0x150(%rbp), %rbx
cmpq %r15, %rbx
je 0x3310
xorl %r14d, %r14d
leaq -0x68(%rbp), %r12
movl 0x40(%rbx), %r13d
cmpl %r14d, %r13d
jle 0x3300
leaq 0x20(%rbx), %rsi
movq %r12, %rdi
callq 0x2110
movl %r13d, %r14d
movq %rbx, %rdi
callq 0x2130
movq %rax, %rbx
cmpq %r15, %rax
jne 0x32e8
leaq -0x68(%rbp), %rdi
movq 0x8(%rdi), %rdx
leaq 0x5ec7(%rip), %rcx      # 0x91e6
movl $0x2, %r8d
xorl %esi, %esi
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 -0x38(%rbp), %r14
movq 0x8(%r14), %rsi
subq (%r14), %rsi
sarq $0x3, %rsi
movabsq $-0x5555555555555555, %rax # imm = 0xAAAAAAAAAAAAAAAB
imulq %rax, %rsi
movq %r13, %rdi
callq 0x620a
movq (%r14), %rbx
cmpq %rbx, 0x8(%r14)
je 0x36b5
xorl %r14d, %r14d
xorps %xmm0, %xmm0
movaps %xmm0, -0xb0(%rbp)
movq $0x0, -0xa0(%rbp)
movq %r13, %rdi
leaq -0xb0(%rbp), %r12
movq %r12, %rsi
callq 0x6efe
movq %r14, -0x138(%rbp)
leaq (%r14,%r14,2), %rax
leaq (%rbx,%rax,8), %r15
movq %r12, %rdi
callq 0x5faa
movq 0x8(%r13), %rdi
addq $-0x18, %rdi
movq 0x8(%r15), %rsi
subq (%r15), %rsi
sarq $0x6, %rsi
callq 0x631e
movq (%r15), %rsi
cmpq %rsi, 0x8(%r15)
je 0x3682
movl $0x1, %r12d
xorl %r14d, %r14d
movq %r14, %r13
shlq $0x6, %r13
addq %r13, %rsi
movq -0x48(%rbp), %rdi
callq 0x821e
movq -0x30(%rbp), %rcx
movq 0x8(%rcx), %rbx
addq $-0x18, %rbx
cmpq -0x40(%rbp), %rax
je 0x3556
movq (%r15), %rax
movq 0x8(%r15), %rdx
subq %rax, %rdx
sarq $0x6, %rdx
cmpq %r14, %rdx
jbe 0x3700
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 0x6d72
movq (%r15), %rsi
movq 0x8(%r15), %rdx
subq %rsi, %rdx
sarq $0x6, %rdx
cmpq %r14, %rdx
jbe 0x36ef
addq %r13, %rsi
movq -0x48(%rbp), %rdi
callq 0x64b2
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 0x6d72
leaq -0xb0(%rbp), %r14
movq %r14, %rdi
leaq -0xf0(%rbp), %rsi
movq %r13, %rdx
movq -0x30(%rbp), %r13
callq 0x60d8
movq %rbx, %rdi
movq %r14, %rsi
callq 0x7122
movq -0x90(%rbp), %rdi
leaq -0x80(%rbp), %rax
cmpq %rax, %rdi
je 0x34ef
movq -0x80(%rbp), %rsi
incq %rsi
callq 0x21c0
movq -0xb0(%rbp), %rdi
leaq -0xa0(%rbp), %rax
cmpq %rax, %rdi
je 0x3511
movq -0xa0(%rbp), %rsi
incq %rsi
callq 0x21c0
movq -0x130(%rbp), %rdi
leaq -0x120(%rbp), %rax
cmpq %rax, %rdi
je 0x3533
movq -0x120(%rbp), %rsi
incq %rsi
callq 0x21c0
movq -0xf0(%rbp), %rdi
leaq -0xe0(%rbp), %rax
cmpq %rax, %rdi
je 0x3665
movq -0xe0(%rbp), %rsi
jmp 0x365d
movq (%r15), %rax
movq 0x8(%r15), %rdx
subq %rax, %rdx
sarq $0x6, %rdx
cmpq %r14, %rdx
jbe 0x3715
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 0x6d72
leaq -0x100(%rbp), %rax
movq %rax, -0x110(%rbp)
movq -0x68(%rbp), %rsi
movq -0x60(%rbp), %rdx
addq %rsi, %rdx
leaq -0x110(%rbp), %r14
movq %r14, %rdi
movq -0x30(%rbp), %r13
callq 0x6d72
movq %r14, %rdx
leaq -0xb0(%rbp), %r14
movq %r14, %rdi
leaq -0xd0(%rbp), %rsi
callq 0x60d8
movq %rbx, %rdi
movq %r14, %rsi
callq 0x7122
movq -0x90(%rbp), %rdi
leaq -0x80(%rbp), %rax
cmpq %rax, %rdi
je 0x35ff
movq -0x80(%rbp), %rsi
incq %rsi
callq 0x21c0
movq -0xb0(%rbp), %rdi
leaq -0xa0(%rbp), %rax
cmpq %rax, %rdi
je 0x3621
movq -0xa0(%rbp), %rsi
incq %rsi
callq 0x21c0
movq -0x110(%rbp), %rdi
leaq -0x100(%rbp), %rax
cmpq %rax, %rdi
je 0x3643
movq -0x100(%rbp), %rsi
incq %rsi
callq 0x21c0
movq -0xd0(%rbp), %rdi
leaq -0xc0(%rbp), %rax
cmpq %rax, %rdi
je 0x3665
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 0x33fb
movq -0x138(%rbp), %r14
incl %r14d
movq -0x38(%rbp), %rax
movq (%rax), %rbx
movq 0x8(%rax), %rax
subq %rbx, %rax
sarq $0x3, %rax
movabsq $-0x5555555555555555, %rcx # imm = 0xAAAAAAAAAAAAAAAB
imulq %rcx, %rax
cmpq %r14, %rax
ja 0x338f
movq -0x68(%rbp), %rdi
leaq -0x58(%rbp), %rax
cmpq %rax, %rdi
je 0x36ce
movq -0x58(%rbp), %rsi
incq %rsi
callq 0x21c0
leaq -0x168(%rbp), %rdi
callq 0x682c
movq %r13, %rax
addq $0x148, %rsp            # imm = 0x148
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x5d52(%rip), %rdi      # 0x9448
movq %r14, %rsi
xorl %eax, %eax
callq 0x2260
leaq 0x5d41(%rip), %rdi      # 0x9448
movq %r14, %rsi
xorl %eax, %eax
movq -0x30(%rbp), %r13
callq 0x2260
leaq 0x5d2c(%rip), %rdi      # 0x9448
movq %r14, %rsi
xorl %eax, %eax
movq -0x30(%rbp), %r13
callq 0x2260
jmp 0x37b7
jmp 0x3731
movq %rax, %r14
jmp 0x383b
movq %rax, %r14
leaq -0xb0(%rbp), %rdi
callq 0x5faa
jmp 0x382a
jmp 0x37b7
jmp 0x3751
movq %rax, %r14
jmp 0x3854
movq %rax, %r14
jmp 0x379b
jmp 0x37f8
movq %rax, %r14
leaq -0xb0(%rbp), %rdi
callq 0x615a
jmp 0x3779
jmp 0x37b7
movq %rax, %r14
movq -0x110(%rbp), %rdi
leaq -0x100(%rbp), %rax
cmpq %rax, %rdi
je 0x379b
movq -0x100(%rbp), %rsi
incq %rsi
callq 0x21c0
movq -0xd0(%rbp), %rdi
leaq -0xc0(%rbp), %rax
cmpq %rax, %rdi
je 0x382a
movq -0xc0(%rbp), %rsi
jmp 0x3822
movq %rax, %r14
jmp 0x382a
movq %rax, %r14
jmp 0x37d2
jmp 0x37f8
movq %rax, %r14
leaq -0xb0(%rbp), %rdi
callq 0x615a
movq -0x130(%rbp), %rdi
leaq -0x120(%rbp), %rax
cmpq %rax, %rdi
je 0x3808
movq -0x120(%rbp), %rsi
incq %rsi
callq 0x21c0
jmp 0x3808
jmp 0x3801
movq %rax, %r14
movq -0x30(%rbp), %r13
jmp 0x382a
movq %rax, %r14
movq -0x30(%rbp), %r13
movq -0xf0(%rbp), %rdi
leaq -0xe0(%rbp), %rax
cmpq %rax, %rdi
je 0x382a
movq -0xe0(%rbp), %rsi
incq %rsi
callq 0x21c0
leaq 0x18(%r13), %rdi
callq 0x68bc
movq %r13, %rdi
callq 0x672e
movq -0x68(%rbp), %rdi
leaq -0x58(%rbp), %rax
cmpq %rax, %rdi
je 0x3854
movq -0x58(%rbp), %rsi
incq %rsi
callq 0x21c0
leaq -0x168(%rbp), %rdi
callq 0x682c
movq %r14, %rdi
callq 0x2320