// File: 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
subq $0x1c0, %rsp            # imm = 0x1C0
movq %rdi, -0x1a0(%rbp)
movq %rdi, %rax
movq %rax, -0x198(%rbp)
movl 0x18(%rbp), %eax
movq 0x10(%rbp), %rax
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
movq %r9, -0x30(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x190(%rbp)
movq -0x18(%rbp), %rsi
leaq -0x48(%rbp), %rdi
movq %rdi, -0x188(%rbp)
movl $0x20, %edx
callq 0x3d90
movq -0x190(%rbp), %rdi
movq -0x188(%rbp), %rsi
movq -0x20(%rbp), %rdx
movq -0x28(%rbp), %rcx
movq -0x30(%rbp), %r8
callq 0x6d40
movl %eax, -0x17c(%rbp)
jmp 0x6f36
movq -0x190(%rbp), %rdi
movl -0x17c(%rbp), %eax
movl %eax, -0x4c(%rbp)
movq -0x20(%rbp), %rsi
movq -0x28(%rbp), %rdx
movq -0x30(%rbp), %rcx
movq 0x10(%rbp), %r8
movl -0x4c(%rbp), %r9d
callq 0x69c0
movl $0x1, -0x60(%rbp)
movl -0x60(%rbp), %eax
cmpl 0x18(%rbp), %eax
jg 0x7007
movl $0x0, -0x64(%rbp)
movl -0x64(%rbp), %eax
cmpl -0x4c(%rbp), %eax
jge 0x6ff7
movq -0x190(%rbp), %rdi
movq -0x20(%rbp), %rsi
movq -0x30(%rbp), %rdx
movq -0x28(%rbp), %rcx
movq 0x10(%rbp), %r8
movl -0x64(%rbp), %r9d
movl -0x4c(%rbp), %r10d
movq %rsp, %rax
movl %r10d, (%rax)
callq 0x7370
jmp 0x6fad
movq -0x190(%rbp), %rdi
movq -0x20(%rbp), %rsi
movq -0x30(%rbp), %rdx
movq -0x28(%rbp), %rcx
movq 0x10(%rbp), %r8
movl -0x64(%rbp), %r9d
movl -0x4c(%rbp), %r10d
movq %rsp, %rax
movl %r10d, (%rax)
callq 0x81a0
jmp 0x6fd9
jmp 0x6fdb
movl -0x64(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x64(%rbp)
jmp 0x6f79
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x735a
jmp 0x6ff9
movl -0x60(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x60(%rbp)
jmp 0x6f66
movb $0x0, -0x65(%rbp)
leaq -0x66(%rbp), %rdi
movq %rdi, -0x1a8(%rbp)
callq 0x3410
movq -0x1a0(%rbp), %rdi
movq -0x1a8(%rbp), %rdx
leaq 0xb054(%rip), %rsi      # 0x12084
callq 0x32f0
jmp 0x7037
leaq -0x66(%rbp), %rdi
callq 0x3280
movl $0x0, -0x6c(%rbp)
movl -0x6c(%rbp), %eax
cmpl -0x4c(%rbp), %eax
jge 0x72ff
leaq -0x91(%rbp), %rdi
movq %rdi, -0x1b0(%rbp)
callq 0x3410
movq -0x1b0(%rbp), %rdx
leaq 0xb010(%rip), %rsi      # 0x12084
leaq -0x90(%rbp), %rdi
callq 0x32f0
jmp 0x7082
leaq -0x91(%rbp), %rdi
callq 0x3280
movq -0x30(%rbp), %rdi
movslq -0x6c(%rbp), %rsi
callq 0x8f60
cmpl $0x0, (%rax)
jne 0x7172
movq -0x28(%rbp), %rdi
movslq -0x6c(%rbp), %rsi
callq 0x8f60
movl (%rax), %esi
leaq -0xd8(%rbp), %rdi
callq 0x9620
jmp 0x70c1
leaq 0xb075(%rip), %rsi      # 0x1213d
leaq -0xb8(%rbp), %rdi
leaq -0xd8(%rbp), %rdx
callq 0x97c0
jmp 0x70dd
leaq -0x90(%rbp), %rdi
leaq -0xb8(%rbp), %rsi
callq 0x32c0
leaq -0xb8(%rbp), %rdi
callq 0x3160
leaq -0xd8(%rbp), %rdi
callq 0x3160
jmp 0x71f5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0x66(%rbp), %rdi
callq 0x3280
jmp 0x735a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0x91(%rbp), %rdi
callq 0x3280
jmp 0x734e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x72f1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0xd8(%rbp), %rdi
callq 0x3160
jmp 0x72f1
movq -0x30(%rbp), %rdi
movslq -0x6c(%rbp), %rsi
callq 0x8f60
movl (%rax), %esi
leaq -0x118(%rbp), %rdi
callq 0x9620
jmp 0x718f
leaq 0xafa9(%rip), %rsi      # 0x1213f
leaq -0xf8(%rbp), %rdi
leaq -0x118(%rbp), %rdx
callq 0x97c0
jmp 0x71ab
leaq -0x90(%rbp), %rdi
leaq -0xf8(%rbp), %rsi
callq 0x32c0
leaq -0xf8(%rbp), %rdi
callq 0x3160
leaq -0x118(%rbp), %rdi
callq 0x3160
jmp 0x71f5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0x118(%rbp), %rdi
callq 0x3160
jmp 0x72f1
movslq -0x6c(%rbp), %rsi
leaq -0x48(%rbp), %rdi
callq 0x8cc0
movq %rax, %rsi
leaq 0xaed9(%rip), %rdx      # 0x120e5
leaq -0x178(%rbp), %rdi
callq 0x9740
jmp 0x721a
leaq -0x158(%rbp), %rdi
leaq -0x178(%rbp), %rsi
leaq -0x90(%rbp), %rdx
callq 0x9810
jmp 0x7236
leaq 0xae46(%rip), %rdx      # 0x12083
leaq -0x138(%rbp), %rdi
leaq -0x158(%rbp), %rsi
callq 0x93f0
jmp 0x7252
movq -0x1a0(%rbp), %rdi
leaq -0x138(%rbp), %rsi
callq 0x32e0
jmp 0x7267
leaq -0x138(%rbp), %rdi
callq 0x3160
leaq -0x158(%rbp), %rdi
callq 0x3160
leaq -0x178(%rbp), %rdi
callq 0x3160
leaq -0x90(%rbp), %rdi
callq 0x3160
movl -0x6c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x6c(%rbp)
jmp 0x7047
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x72e5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x72d9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0x138(%rbp), %rdi
callq 0x3160
leaq -0x158(%rbp), %rdi
callq 0x3160
leaq -0x178(%rbp), %rdi
callq 0x3160
leaq -0x90(%rbp), %rdi
callq 0x3160
jmp 0x734e
movq -0x190(%rbp), %rdi
movq -0x20(%rbp), %rsi
movq -0x28(%rbp), %rdx
movq -0x30(%rbp), %rcx
movq 0x10(%rbp), %r8
movl -0x4c(%rbp), %r9d
callq 0x6b80
movb $0x1, -0x65(%rbp)
testb $0x1, -0x65(%rbp)
jne 0x7335
movq -0x1a0(%rbp), %rdi
callq 0x3160
leaq -0x48(%rbp), %rdi
callq 0x8b80
movq -0x198(%rbp), %rax
addq $0x1c0, %rsp            # imm = 0x1C0
popq %rbp
retq
movq -0x1a0(%rbp), %rdi
callq 0x3160
leaq -0x48(%rbp), %rdi
callq 0x8b80
movq -0x58(%rbp), %rdi
callq 0x3400
nopl (%rax)