// File: /workspace/github_cpp_makefile_star2_O2/abaheti95[P]HMM-LDA/Models/cpp_hmm_lda/model.cpp
// Function: HMMLDA::relabel_document(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>&, std::vector<int, std::allocator<int>>&, std::vector<int, std::allocator<int>>&, std::vector<int, std::allocator<int>>&, std::vector<int, std::allocator<int>>&, int)
string HMMLDA::relabel_document(string &input, vector<int> &document, vector<int> &topic_assignment, vector<int> &class_assignment, vector<int> &num_words_in_document_assigned_to_topic, int iterations) {
	vector<string> words = split(input, ' ');
	int doc_size = input_to_document(words, document, topic_assignment, class_assignment);
	add_counts_for_new_document(document, topic_assignment, class_assignment, num_words_in_document_assigned_to_topic, doc_size);
	// Resample the current document for some iterations
	for(int i = 1; i <= iterations; i++) {
		for(int word_idx = 0; word_idx < doc_size; word_idx++) {
			spl_draw_class(document, class_assignment, topic_assignment, num_words_in_document_assigned_to_topic, word_idx, doc_size);
			spl_draw_topic(document, class_assignment, topic_assignment, num_words_in_document_assigned_to_topic, word_idx, doc_size);
		}
	}
	// Create the output string
	string output = "";
	for(int i = 0; i < doc_size; i++) {
		string assignment = "";
		if(class_assignment[i] == 0)
			assignment = "T" + std::to_string(topic_assignment[i]);
		else
			assignment = "C" + std::to_string(class_assignment[i]);
		output += words[i] + "/" + assignment + " ";
	}
	remove_counts_for_new_document(document, topic_assignment, class_assignment, num_words_in_document_assigned_to_topic, doc_size);
	return output;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xd8, %rsp
movq %r9, %r14
movq %r8, %r15
movq %rcx, %r12
movq %rsi, %r13
movq %rdi, -0x40(%rbp)
leaq -0x98(%rbp), %rbx
pushq $0x20
popq %rax
movq %rbx, %rdi
movq %rdx, %rsi
movl %eax, %edx
callq 0x29ee
movq %r13, %rdi
movq %rbx, %rsi
movq %r12, %rdx
movq %r15, %rcx
movq %r14, %r8
callq 0x4196
movl %eax, %ebx
movq 0x10(%rbp), %rax
movq %r13, %rdi
movq %r12, %rsi
movq %r15, -0x58(%rbp)
movq %r15, %rdx
movq %rax, %r15
movq %r14, %rcx
movq %rax, %r8
movl %ebx, %r9d
callq 0x3ff6
xorl %ecx, %ecx
testl %ebx, %ebx
movl %ebx, %eax
cmovlel %ecx, %eax
movl %eax, -0x30(%rbp)
movl 0x18(%rbp), %eax
testl %eax, %eax
cmovgl %eax, %ecx
incl %ecx
movl %ecx, -0x50(%rbp)
pushq $0x1
popq %rcx
movl %ebx, -0x34(%rbp)
movq %r13, -0x60(%rbp)
movl %ecx, -0x48(%rbp)
cmpl -0x50(%rbp), %ecx
je 0x4379
xorl %r9d, %r9d
cmpl %r9d, -0x30(%rbp)
je 0x4372
movl %ebx, (%rsp)
movq %r13, %rdi
movq %r12, %rsi
movq %r14, %rdx
movq %r14, %r13
movq %r12, %r14
movq -0x58(%rbp), %r12
movq %r12, %rcx
movq %r15, %r8
movl %r9d, %ebx
callq 0x4586
movq -0x60(%rbp), %rdi
movq %r14, %rsi
movq %r13, %rdx
movq %r12, %rcx
movq %r15, %r8
movl %ebx, %r9d
callq 0x4b94
movl %ebx, %r9d
incl %r9d
movq %r14, %r12
movq %r13, %r14
movq -0x60(%rbp), %r13
movl -0x34(%rbp), %ebx
jmp 0x431b
movl -0x48(%rbp), %ecx
incl %ecx
jmp 0x4310
leaq 0x2d04(%rip), %rsi      # 0x7084
leaq -0x80(%rbp), %rdx
movq -0x40(%rbp), %rdi
callq 0x20c0
movl -0x30(%rbp), %eax
movq %rax, -0x50(%rbp)
movq $0x0, -0x48(%rbp)
leaq -0xd8(%rbp), %rbx
xorl %eax, %eax
movq %rax, -0x30(%rbp)
cmpq %rax, -0x50(%rbp)
je 0x44cd
leaq -0x80(%rbp), %rdi
leaq 0x2cc6(%rip), %rsi      # 0x7084
leaq -0xb8(%rbp), %rdx
callq 0x20c0
movq (%r14), %rax
movq -0x30(%rbp), %rcx
movl (%rax,%rcx,4), %esi
testl %esi, %esi
je 0x43fb
movq %rbx, %rdi
callq 0x522d
leaq -0xb8(%rbp), %r15
movq %r15, %rdi
leaq 0x2d4e(%rip), %rsi      # 0x713f
movq %rbx, %rdx
callq 0x52c5
jmp 0x4426
movq -0x58(%rbp), %rax
movq (%rax), %rax
movl (%rax,%rcx,4), %esi
movq %rbx, %rdi
callq 0x522d
leaq -0xb8(%rbp), %r15
movq %r15, %rdi
leaq 0x2d1f(%rip), %rsi      # 0x713d
movq %rbx, %rdx
callq 0x52c5
leaq -0x80(%rbp), %rdi
movq %r15, %rsi
callq 0x2260
movq %r15, %rdi
callq 0x20f0
movq %rbx, %rdi
callq 0x20f0
movq -0x98(%rbp), %rsi
addq -0x48(%rbp), %rsi
leaq -0xf8(%rbp), %r15
movq %r15, %rdi
leaq 0x2c87(%rip), %rdx      # 0x70e5
callq 0x528d
movq %rbx, %rdi
movq %r15, %rsi
leaq -0x80(%rbp), %rdx
callq 0x52f3
movq %rbx, %rsi
leaq -0xb8(%rbp), %r15
movq %r15, %rdi
leaq 0x2bfd(%rip), %rdx      # 0x7083
callq 0x511d
movq -0x40(%rbp), %rdi
movq %r15, %rsi
callq 0x23b0
movq %r15, %rdi
callq 0x20f0
movq %rbx, %rdi
callq 0x20f0
leaq -0xf8(%rbp), %rdi
callq 0x20f0
leaq -0x80(%rbp), %rdi
callq 0x20f0
movq -0x30(%rbp), %rax
incq %rax
addq $0x20, -0x48(%rbp)
jmp 0x43a5
movq %r13, %rdi
movq %r12, %rsi
movq -0x58(%rbp), %rdx
movq %r14, %rcx
movq 0x10(%rbp), %r8
movl -0x34(%rbp), %r9d
callq 0x40c6
leaq -0x98(%rbp), %rdi
callq 0x4e36
movq -0x40(%rbp), %rax
addq $0xd8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x456e
jmp 0x456e
jmp 0x4513
jmp 0x451f
jmp 0x451f
movq %rax, %rbx
leaq -0xd8(%rbp), %rdi
jmp 0x4550
movq %rax, %rbx
jmp 0x4555
movq %rax, %rbx
jmp 0x4549
movq %rax, %rbx
jmp 0x453d
movq %rax, %rbx
leaq -0xb8(%rbp), %rdi
callq 0x20f0
leaq -0xd8(%rbp), %rdi
callq 0x20f0
leaq -0xf8(%rbp), %rdi
callq 0x20f0
leaq -0x80(%rbp), %rdi
callq 0x20f0
movq -0x40(%rbp), %rdi
callq 0x20f0
jmp 0x4571
movq %rax, %rbx
jmp 0x455e
movq %rax, %rbx
leaq -0x98(%rbp), %rdi
callq 0x4e36
movq %rbx, %rdi
callq 0x2380
nop