// File: abaheti95[P]HMM-LDA/Models/cpp_hmm_lda/model.cpp
// Function: HMMLDA::save_assignments(int)
void HMMLDA::save_assignments(int iteration) {
	cout << "Saving assignments for iteration " << iteration << endl;
	int n_documents = documents.size();
	// Create a new directory and save 2 files for topic assignments and class assignments
	string save_dir_path = "Results/" + save_dir + "/" + to_string(iteration) + "_results";
	system(("mkdir -p " + save_dir_path).c_str());
	cout << "Directory :" << save_dir_path << " created" << endl;
	ofstream class_file((save_dir_path + "/class_assignments.txt").c_str());
	class_file << n_documents << " " << num_classes << endl;
	for(int document_idx = 0; document_idx < n_documents; document_idx++) {
		int doc_size = class_assignments[document_idx].size();
		for(int word_idx = 0; word_idx < doc_size; word_idx++)
			class_file << class_assignments[document_idx][word_idx] << " ";
		class_file << endl;
	}
	class_file.close();
	ofstream topic_file((save_dir_path + "/topic_assignments.txt").c_str());
	topic_file << n_documents << " " << num_topics << endl;
	for(int document_idx = 0; document_idx < n_documents; document_idx++) {
		int doc_size = topic_assignments[document_idx].size();
		for(int word_idx = 0; word_idx < doc_size; word_idx++)
			topic_file << topic_assignments[document_idx][word_idx] << " ";
		topic_file << endl;
	}
	topic_file.close();
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x5b0, %rsp            # imm = 0x5B0
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x550(%rbp)
movq 0x15104(%rip), %rdi     # 0x19fd8
leaq 0xd1e1(%rip), %rsi      # 0x120bc
callq 0x3240
movq %rax, %rdi
movl -0xc(%rbp), %esi
callq 0x33f0
movq %rax, %rdi
movq 0x150d3(%rip), %rsi     # 0x19fc8
callq 0x3270
movq -0x550(%rbp), %rdi
addq $0xa8, %rdi
callq 0x8be0
movq -0x550(%rbp), %rdx
movl %eax, -0x10(%rbp)
addq $0x38, %rdx
leaq 0xd1bc(%rip), %rsi      # 0x120de
leaq -0x90(%rbp), %rdi
movq %rdi, -0x548(%rbp)
callq 0x9510
movq -0x548(%rbp), %rsi
leaq 0xd1a2(%rip), %rdx      # 0x120e5
leaq -0x70(%rbp), %rdi
callq 0x93f0
jmp 0x4f4e
movl -0xc(%rbp), %esi
leaq -0xc0(%rbp), %rdi
callq 0x9620
jmp 0x4f5f
leaq -0x50(%rbp), %rdi
leaq -0x70(%rbp), %rsi
leaq -0xc0(%rbp), %rdx
callq 0x9440
jmp 0x4f75
leaq 0xd16b(%rip), %rdx      # 0x120e7
leaq -0x30(%rbp), %rdi
leaq -0x50(%rbp), %rsi
callq 0x93f0
jmp 0x4f8b
leaq -0x50(%rbp), %rdi
callq 0x3160
leaq -0xc0(%rbp), %rdi
callq 0x3160
leaq -0x70(%rbp), %rdi
callq 0x3160
leaq -0x90(%rbp), %rdi
callq 0x3160
leaq 0xd134(%rip), %rsi      # 0x120f0
leaq -0xe0(%rbp), %rdi
leaq -0x30(%rbp), %rdx
callq 0x9510
jmp 0x4fce
leaq -0xe0(%rbp), %rdi
callq 0x30e0
movq %rax, %rdi
callq 0x31f0
jmp 0x4fe4
leaq -0xe0(%rbp), %rdi
callq 0x3160
movq 0x14fe1(%rip), %rdi     # 0x19fd8
leaq 0xd0fc(%rip), %rsi      # 0x120fa
callq 0x3240
movq %rax, -0x558(%rbp)
jmp 0x500c
movq -0x558(%rbp), %rdi
leaq -0x30(%rbp), %rsi
callq 0x3210
movq %rax, -0x560(%rbp)
jmp 0x5025
movq -0x560(%rbp), %rdi
leaq 0xd0d3(%rip), %rsi      # 0x12106
callq 0x3240
movq %rax, -0x568(%rbp)
jmp 0x5041
movq -0x568(%rbp), %rdi
movq 0x14f79(%rip), %rsi     # 0x19fc8
callq 0x3270
jmp 0x5056
leaq 0xd0b2(%rip), %rdx      # 0x1210f
leaq -0x300(%rbp), %rdi
leaq -0x30(%rbp), %rsi
callq 0x9740
jmp 0x506f
leaq -0x300(%rbp), %rdi
callq 0x30e0
movq %rax, %rsi
leaq -0x2e0(%rbp), %rdi
movl $0x10, %edx
callq 0x3290
jmp 0x5091
leaq -0x300(%rbp), %rdi
callq 0x3160
movl -0x10(%rbp), %esi
leaq -0x2e0(%rbp), %rdi
callq 0x33f0
movq %rax, -0x570(%rbp)
jmp 0x50b5
movq -0x570(%rbp), %rdi
leaq 0xcfc0(%rip), %rsi      # 0x12083
callq 0x3240
movq %rax, -0x578(%rbp)
jmp 0x50d1
movq -0x578(%rbp), %rdi
movq -0x550(%rbp), %rax
movl 0x4(%rax), %esi
callq 0x33f0
movq %rax, -0x580(%rbp)
jmp 0x50f0
movq -0x580(%rbp), %rdi
movq 0x14eca(%rip), %rsi     # 0x19fc8
callq 0x3270
jmp 0x5105
movl $0x0, -0x304(%rbp)
movl -0x304(%rbp), %eax
cmpl -0x10(%rbp), %eax
jge 0x52e6
movq -0x550(%rbp), %rdi
addq $0xd8, %rdi
movslq -0x304(%rbp), %rsi
callq 0x8c10
movq %rax, %rdi
callq 0x8e50
movl %eax, -0x308(%rbp)
movl $0x0, -0x30c(%rbp)
movl -0x30c(%rbp), %eax
cmpl -0x308(%rbp), %eax
jge 0x52bb
movq -0x550(%rbp), %rdi
addq $0xd8, %rdi
movslq -0x304(%rbp), %rsi
callq 0x8c10
movq %rax, %rdi
movslq -0x30c(%rbp), %rsi
callq 0x8f60
movl (%rax), %esi
leaq -0x2e0(%rbp), %rdi
callq 0x33f0
movq %rax, -0x588(%rbp)
jmp 0x51a2
movq -0x588(%rbp), %rdi
leaq 0xced3(%rip), %rsi      # 0x12083
callq 0x3240
jmp 0x51b7
jmp 0x51b9
movl -0x30c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30c(%rbp)
jmp 0x5150
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x98(%rbp)
movl %eax, -0x9c(%rbp)
jmp 0x5236
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x98(%rbp)
movl %eax, -0x9c(%rbp)
jmp 0x522d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x98(%rbp)
movl %eax, -0x9c(%rbp)
jmp 0x5221
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x98(%rbp)
movl %eax, -0x9c(%rbp)
leaq -0x50(%rbp), %rdi
callq 0x3160
leaq -0xc0(%rbp), %rdi
callq 0x3160
leaq -0x70(%rbp), %rdi
callq 0x3160
leaq -0x90(%rbp), %rdi
callq 0x3160
jmp 0x5522
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x98(%rbp)
movl %eax, -0x9c(%rbp)
jmp 0x5519
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x98(%rbp)
movl %eax, -0x9c(%rbp)
leaq -0xe0(%rbp), %rdi
callq 0x3160
jmp 0x5519
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x98(%rbp)
movl %eax, -0x9c(%rbp)
leaq -0x300(%rbp), %rdi
callq 0x3160
jmp 0x5519
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x98(%rbp)
movl %eax, -0x9c(%rbp)
jmp 0x550d
movq 0x14d06(%rip), %rsi     # 0x19fc8
leaq -0x2e0(%rbp), %rdi
callq 0x3270
jmp 0x52d0
jmp 0x52d2
movl -0x304(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x304(%rbp)
jmp 0x510f
leaq -0x2e0(%rbp), %rdi
callq 0x3320
jmp 0x52f4
leaq 0xce2b(%rip), %rdx      # 0x12126
leaq -0x530(%rbp), %rdi
leaq -0x30(%rbp), %rsi
callq 0x9740
jmp 0x530d
leaq -0x530(%rbp), %rdi
callq 0x30e0
movq %rax, %rsi
leaq -0x510(%rbp), %rdi
movl $0x10, %edx
callq 0x3290
jmp 0x532f
leaq -0x530(%rbp), %rdi
callq 0x3160
movl -0x10(%rbp), %esi
leaq -0x510(%rbp), %rdi
callq 0x33f0
movq %rax, -0x590(%rbp)
jmp 0x5353
movq -0x590(%rbp), %rdi
leaq 0xcd22(%rip), %rsi      # 0x12083
callq 0x3240
movq %rax, -0x598(%rbp)
jmp 0x536f
movq -0x598(%rbp), %rdi
movq -0x550(%rbp), %rax
movl (%rax), %esi
callq 0x33f0
movq %rax, -0x5a0(%rbp)
jmp 0x538d
movq -0x5a0(%rbp), %rdi
movq 0x14c2d(%rip), %rsi     # 0x19fc8
callq 0x3270
jmp 0x53a2
movl $0x0, -0x534(%rbp)
movl -0x534(%rbp), %eax
cmpl -0x10(%rbp), %eax
jge 0x54d5
movq -0x550(%rbp), %rdi
addq $0xc0, %rdi
movslq -0x534(%rbp), %rsi
callq 0x8c10
movq %rax, %rdi
callq 0x8e50
movl %eax, -0x538(%rbp)
movl $0x0, -0x53c(%rbp)
movl -0x53c(%rbp), %eax
cmpl -0x538(%rbp), %eax
jge 0x54aa
movq -0x550(%rbp), %rdi
addq $0xc0, %rdi
movslq -0x534(%rbp), %rsi
callq 0x8c10
movq %rax, %rdi
movslq -0x53c(%rbp), %rsi
callq 0x8f60
movl (%rax), %esi
leaq -0x510(%rbp), %rdi
callq 0x33f0
movq %rax, -0x5a8(%rbp)
jmp 0x543f
movq -0x5a8(%rbp), %rdi
leaq 0xcc36(%rip), %rsi      # 0x12083
callq 0x3240
jmp 0x5454
jmp 0x5456
movl -0x53c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x53c(%rbp)
jmp 0x53ed
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x98(%rbp)
movl %eax, -0x9c(%rbp)
leaq -0x530(%rbp), %rdi
callq 0x3160
jmp 0x550d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x98(%rbp)
movl %eax, -0x9c(%rbp)
leaq -0x510(%rbp), %rdi
callq 0x3340
jmp 0x550d
movq 0x14b17(%rip), %rsi     # 0x19fc8
leaq -0x510(%rbp), %rdi
callq 0x3270
jmp 0x54bf
jmp 0x54c1
movl -0x534(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x534(%rbp)
jmp 0x53ac
leaq -0x510(%rbp), %rdi
callq 0x3320
jmp 0x54e3
leaq -0x510(%rbp), %rdi
callq 0x3340
leaq -0x2e0(%rbp), %rdi
callq 0x3340
leaq -0x30(%rbp), %rdi
callq 0x3160
addq $0x5b0, %rsp            # imm = 0x5B0
popq %rbp
retq
leaq -0x2e0(%rbp), %rdi
callq 0x3340
leaq -0x30(%rbp), %rdi
callq 0x3160
movq -0x98(%rbp), %rdi
callq 0x3400
nop