// File: abaheti95[P]HMM-LDA/Models/cpp_hmm_lda/model.cpp
// Function: HMMLDA::add_document(std::vector<int, std::allocator<int>>)
void HMMLDA::add_document(vector<int> document) {
	documents.push_back(document);
	// Sample random topics and classes for the words
	vector<int> topic_assignment(document.size(), 0);
	vector<int> class_assignment(document.size(), 0);
	int doc_size = document.size();
	for(int i = 0; i < doc_size; i++) {
		topic_assignment[i] = topic_dist(rng);
		if(document[i] == start_word_id)
			class_assignment[i] = START_WORD_CLASS;
		else if(document[i] ==  end_word_id)
			class_assignment[i] = END_WORD_CLASS;
		else
			class_assignment[i] = class_dist(rng);
	}
	// cout << "Printing topic assignments of a document" << endl;
	// print_vector<int>(topic_assignment);
	topic_assignments.push_back(topic_assignment);
	class_assignments.push_back(class_assignment);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xb0, %rsp
movq %rsi, -0x80(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rdi
movq %rdi, -0x88(%rbp)
addq $0xa8, %rdi
callq 0x8de0
movq -0x80(%rbp), %rdi
callq 0x8e50
movq %rax, -0x78(%rbp)
movl $0x0, -0x2c(%rbp)
leaq -0x2d(%rbp), %rdi
movq %rdi, -0x70(%rbp)
callq 0x8e70
movq -0x78(%rbp), %rsi
movq -0x70(%rbp), %rcx
leaq -0x28(%rbp), %rdi
leaq -0x2c(%rbp), %rdx
callq 0x8e90
jmp 0x3ea6
leaq -0x2d(%rbp), %rdi
callq 0x8f10
movq -0x80(%rbp), %rdi
callq 0x8e50
movq %rax, -0x98(%rbp)
movl $0x0, -0x5c(%rbp)
leaq -0x5d(%rbp), %rdi
movq %rdi, -0x90(%rbp)
callq 0x8e70
movq -0x98(%rbp), %rsi
movq -0x90(%rbp), %rcx
leaq -0x58(%rbp), %rdi
leaq -0x5c(%rbp), %rdx
callq 0x8e90
jmp 0x3ef3
leaq -0x5d(%rbp), %rdi
callq 0x8f10
movq -0x80(%rbp), %rdi
callq 0x8e50
movl %eax, -0x64(%rbp)
movl $0x0, -0x68(%rbp)
movl -0x68(%rbp), %eax
cmpl -0x64(%rbp), %eax
jge 0x4076
movq -0x88(%rbp), %rsi
movq %rsi, %rdi
addq $0x1508, %rdi           # imm = 0x1508
addq $0x180, %rsi            # imm = 0x180
callq 0x8f30
movl %eax, -0x9c(%rbp)
jmp 0x3f40
movslq -0x68(%rbp), %rsi
leaq -0x28(%rbp), %rdi
callq 0x8f60
movl -0x9c(%rbp), %ecx
movq -0x80(%rbp), %rdi
movl %ecx, (%rax)
movslq -0x68(%rbp), %rsi
callq 0x8f60
movq -0x88(%rbp), %rcx
movl (%rax), %eax
cmpl 0x8(%rcx), %eax
jne 0x3fe8
movq -0x88(%rbp), %rax
movl 0x10(%rax), %eax
movl %eax, -0xa0(%rbp)
movslq -0x68(%rbp), %rsi
leaq -0x58(%rbp), %rdi
callq 0x8f60
movl -0xa0(%rbp), %ecx
movl %ecx, (%rax)
jmp 0x4066
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x2d(%rbp), %rdi
callq 0x8f10
jmp 0x40cc
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x5d(%rbp), %rdi
callq 0x8f10
jmp 0x40c3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x58(%rbp), %rdi
callq 0x8aa0
jmp 0x40c3
movq -0x80(%rbp), %rdi
movslq -0x68(%rbp), %rsi
callq 0x8f60
movq -0x88(%rbp), %rcx
movl (%rax), %eax
cmpl 0xc(%rcx), %eax
jne 0x402a
movq -0x88(%rbp), %rax
movl 0x14(%rax), %eax
movl %eax, -0xa4(%rbp)
movslq -0x68(%rbp), %rsi
leaq -0x58(%rbp), %rdi
callq 0x8f60
movl -0xa4(%rbp), %ecx
movl %ecx, (%rax)
jmp 0x4064
movq -0x88(%rbp), %rsi
movq %rsi, %rdi
addq $0x1510, %rdi           # imm = 0x1510
addq $0x180, %rsi            # imm = 0x180
callq 0x8f30
movl %eax, -0xa8(%rbp)
jmp 0x404f
movslq -0x68(%rbp), %rsi
leaq -0x58(%rbp), %rdi
callq 0x8f60
movl -0xa8(%rbp), %ecx
movl %ecx, (%rax)
jmp 0x4066
jmp 0x4068
movl -0x68(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x68(%rbp)
jmp 0x3f0f
movq -0x88(%rbp), %rdi
addq $0xc0, %rdi
leaq -0x28(%rbp), %rsi
callq 0x8de0
jmp 0x408f
movq -0x88(%rbp), %rdi
addq $0xd8, %rdi
leaq -0x58(%rbp), %rsi
callq 0x8de0
jmp 0x40a8
leaq -0x58(%rbp), %rdi
callq 0x8aa0
leaq -0x28(%rbp), %rdi
callq 0x8aa0
addq $0xb0, %rsp
popq %rbp
retq
leaq -0x28(%rbp), %rdi
callq 0x8aa0
movq -0x38(%rbp), %rdi
callq 0x3400
nopw %cs:(%rax,%rax)