// File: /workspace/github_cpp_makefile_star2_O3/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x478, %rsp            # imm = 0x478
movl %esi, %r14d
movq %rdi, %rbx
movq 0x7891(%rip), %r15      # 0xafd8
leaq 0x497e(%rip), %rsi      # 0x80cc
movl $0x21, %edx
movq %r15, %rdi
callq 0x2270
movq %r15, %rdi
movl %r14d, %esi
callq 0x2380
movq %rax, %r15
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x2220
movsbl %al, %esi
movq %r15, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2150
movq 0xb0(%rbx), %r13
subq 0xa8(%rbx), %r13
movq %rbx, -0x38(%rbp)
leaq 0x38(%rbx), %rdx
leaq 0x4941(%rip), %rsi      # 0x80ee
leaq -0x98(%rbp), %r15
movq %r15, %rdi
callq 0x5ed2
leaq 0x4932(%rip), %rsi      # 0x80f5
movq %r15, %rdi
callq 0x23c0
leaq -0x290(%rbp), %rsi
movq %rsi, -0x10(%rsi)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x37fb
movq %rsi, %rbx
movq %rdx, -0x2a0(%rbp)
movq (%rcx), %rdx
movq %rdx, -0x290(%rbp)
jmp 0x3804
movups (%rcx), %xmm0
movq %rsi, %rbx
movups %xmm0, (%rsi)
movq 0x8(%rax), %rdx
movq %rdx, -0x298(%rbp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
movl %r14d, %r15d
negl %r15d
cmovsl %r14d, %r15d
movl $0x1, %r12d
cmpl $0xa, %r15d
jb 0x387e
movl $0x4, %r12d
movl $0xd1b71759, %eax       # imm = 0xD1B71759
movl %r15d, %ecx
cmpl $0x63, %ecx
jbe 0x3875
cmpl $0x3e7, %ecx            # imm = 0x3E7
jbe 0x387b
cmpl $0x2710, %ecx           # imm = 0x2710
jb 0x387e
movl %ecx, %edx
imulq %rax, %rdx
shrq $0x2d, %rdx
addl $0x4, %r12d
cmpl $0x1869f, %ecx          # imm = 0x1869F
movl %edx, %ecx
ja 0x3842
addl $-0x3, %r12d
jmp 0x387e
addl $-0x2, %r12d
jmp 0x387e
decl %r12d
shrl $0x1f, %r14d
leal (%r12,%r14), %esi
leaq -0x68(%rbp), %rax
movq %rax, -0x10(%rax)
leaq -0x78(%rbp), %rdi
movl $0x2d, %edx
callq 0x2280
movl %r14d, %edi
addq -0x78(%rbp), %rdi
movl %r12d, %esi
movl %r15d, %edx
callq 0x6101
movq -0x2a0(%rbp), %rcx
movq -0x298(%rbp), %r8
movq -0x70(%rbp), %rdx
leaq (%rdx,%r8), %rax
movl $0xf, %edi
cmpq %rbx, %rcx
je 0x38d5
movq -0x290(%rbp), %rdi
movq -0x78(%rbp), %rsi
cmpq %rdi, %rax
jbe 0x38f5
movl $0xf, %edi
leaq -0x68(%rbp), %r9
cmpq %r9, %rsi
je 0x38f0
movq -0x68(%rbp), %rdi
cmpq %rdi, %rax
jbe 0x3903
leaq -0x2a0(%rbp), %rdi
callq 0x20a0
jmp 0x3910
leaq -0x78(%rbp), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x2260
leaq -0x490(%rbp), %rdx
movq %rdx, -0x10(%rdx)
movq (%rax), %rsi
leaq 0x10(%rax), %rcx
cmpq %rcx, %rsi
je 0x393a
movq %rsi, -0x4a0(%rbp)
movq (%rcx), %rdx
movq %rdx, -0x490(%rbp)
jmp 0x3940
movups (%rcx), %xmm0
movups %xmm0, (%rdx)
movq %rax, %rdx
addq $0x8, %rdx
movq 0x8(%rax), %rsi
movq %rsi, -0x498(%rbp)
movq %rcx, (%rax)
movq $0x0, (%rdx)
movb $0x0, (%rcx)
leaq 0x4791(%rip), %rsi      # 0x80f7
leaq -0x4a0(%rbp), %rdi
callq 0x23c0
leaq -0x48(%rbp), %rsi
movq %rsi, -0x10(%rsi)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x3996
movq %rdx, -0x58(%rbp)
movq (%rcx), %rdx
movq %rdx, -0x48(%rbp)
jmp 0x399c
movups (%rcx), %xmm0
movups %xmm0, (%rsi)
movq 0x8(%rax), %rdx
movq %rdx, -0x50(%rbp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
leaq -0x490(%rbp), %r14
movq -0x10(%r14), %rdi
cmpq %r14, %rdi
je 0x39c8
callq 0x2210
movq -0x78(%rbp), %rdi
leaq -0x68(%rbp), %rax
cmpq %rax, %rdi
je 0x39da
callq 0x2210
movq -0x2a0(%rbp), %rdi
cmpq %rbx, %rdi
je 0x39eb
callq 0x2210
leaq -0x88(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x3a00
callq 0x2210
leaq 0x46f9(%rip), %rsi      # 0x8100
leaq -0x4a0(%rbp), %rdi
leaq -0x58(%rbp), %rdx
callq 0x5ed2
movq -0x4a0(%rbp), %rdi
callq 0x21e0
movq -0x4a0(%rbp), %rdi
cmpq %r14, %rdi
je 0x3a34
callq 0x2210
movq 0x759d(%rip), %rdi      # 0xafd8
leaq 0x46c8(%rip), %rsi      # 0x810a
movl $0xb, %edx
callq 0x2270
movq -0x58(%rbp), %rsi
movq -0x50(%rbp), %rdx
movq 0x757d(%rip), %rdi      # 0xafd8
callq 0x2270
movq %rax, %r14
leaq 0x46ac(%rip), %rsi      # 0x8116
movl $0x8, %edx
movq %rax, %rdi
callq 0x2270
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x2220
movsbl %al, %esi
movq %r14, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2150
leaq -0x2a0(%rbp), %rdi
movq %rbx, (%rdi)
movq -0x58(%rbp), %rsi
movq -0x50(%rbp), %rdx
addq %rsi, %rdx
callq 0x6174
leaq 0x4660(%rip), %rsi      # 0x811f
leaq -0x2a0(%rbp), %rdi
callq 0x23c0
movq -0x2a0(%rbp), %rsi
leaq -0x4a0(%rbp), %rdi
movl $0x10, %edx
callq 0x2250
sarq $0x3, %r13
movabsq $-0x5555555555555555, %rax # imm = 0xAAAAAAAAAAAAAAAB
imulq %r13, %rax
movq %rax, -0x30(%rbp)
movq -0x2a0(%rbp), %rdi
cmpq %rbx, %rdi
je 0x3b0a
callq 0x2210
leaq -0x4a0(%rbp), %rdi
movq -0x30(%rbp), %rsi
callq 0x2380
movq %rax, %r12
leaq 0x456f(%rip), %rsi      # 0x8093
movl $0x1, %edx
movq %rax, %rdi
callq 0x2270
movq -0x38(%rbp), %rax
movl 0x4(%rax), %esi
movq %r12, %rdi
callq 0x2380
movq %rax, %r12
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r12, %rdi
movl $0xa, %esi
callq 0x2220
movsbl %al, %esi
movq %r12, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2150
cmpl $0x0, -0x30(%rbp)
jle 0x3c34
movq -0x30(%rbp), %rax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
movq %rax, -0xa0(%rbp)
xorl %r14d, %r14d
leaq 0x4505(%rip), %r12      # 0x8093
movq -0x38(%rbp), %rax
movq 0xd8(%rax), %rax
leaq (%r14,%r14,2), %r13
movq 0x8(%rax,%r13,8), %rbx
subq (%rax,%r13,8), %rbx
shrq $0x2, %rbx
testl %ebx, %ebx
jle 0x3bee
andl $0x7fffffff, %ebx       # imm = 0x7FFFFFFF
xorl %r15d, %r15d
movq -0x38(%rbp), %rax
movq 0xd8(%rax), %rax
movq (%rax,%r13,8), %rax
movl (%rax,%r15,4), %esi
leaq -0x4a0(%rbp), %rdi
callq 0x2380
movl $0x1, %edx
movq %rax, %rdi
movq %r12, %rsi
callq 0x2270
incq %r15
cmpq %r15, %rbx
jne 0x3bb7
movq -0x4a0(%rbp), %rax
movq -0x18(%rax), %rdi
leaq -0x4a0(%rbp), %rax
addq %rax, %rdi
movl $0xa, %esi
callq 0x2220
movsbl %al, %esi
leaq -0x4a0(%rbp), %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2150
incq %r14
cmpq -0xa0(%rbp), %r14
jne 0x3b8e
leaq -0x4a0(%rbp), %rdi
callq 0x22c0
leaq -0x98(%rbp), %rdi
leaq -0x88(%rbp), %rbx
movq %rbx, (%rdi)
movq -0x58(%rbp), %rsi
movq -0x50(%rbp), %rdx
addq %rsi, %rdx
callq 0x6174
leaq 0x44ce(%rip), %rsi      # 0x8136
leaq -0x98(%rbp), %rdi
callq 0x23c0
movq -0x98(%rbp), %rsi
leaq -0x2a0(%rbp), %rdi
movl $0x10, %edx
callq 0x2250
movq -0x98(%rbp), %rdi
cmpq %rbx, %rdi
je 0x3c9d
callq 0x2210
leaq -0x2a0(%rbp), %rdi
movq -0x30(%rbp), %rsi
callq 0x2380
movq %rax, %r13
leaq 0x43dc(%rip), %rsi      # 0x8093
movl $0x1, %edx
movq %rax, %rdi
callq 0x2270
movq -0x38(%rbp), %rax
movl (%rax), %esi
movq %r13, %rdi
callq 0x2380
movq %rax, %r13
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r13, %rdi
movl $0xa, %esi
callq 0x2220
movsbl %al, %esi
movq %r13, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2150
cmpl $0x0, -0x30(%rbp)
jle 0x3dc0
movq -0x30(%rbp), %rax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
movq %rax, -0x30(%rbp)
xorl %r14d, %r14d
leaq 0x4376(%rip), %r13      # 0x8093
movq -0x38(%rbp), %rax
movq 0xc0(%rax), %rax
leaq (%r14,%r14,2), %r15
movq 0x8(%rax,%r15,8), %rbx
subq (%rax,%r15,8), %rbx
shrq $0x2, %rbx
testl %ebx, %ebx
jle 0x3d7d
andl $0x7fffffff, %ebx       # imm = 0x7FFFFFFF
xorl %r12d, %r12d
movq -0x38(%rbp), %rax
movq 0xc0(%rax), %rax
movq (%rax,%r15,8), %rax
movl (%rax,%r12,4), %esi
leaq -0x2a0(%rbp), %rdi
callq 0x2380
movl $0x1, %edx
movq %rax, %rdi
movq %r13, %rsi
callq 0x2270
incq %r12
cmpq %r12, %rbx
jne 0x3d46
movq -0x2a0(%rbp), %rax
movq -0x18(%rax), %rdi
leaq -0x2a0(%rbp), %rax
addq %rax, %rdi
movl $0xa, %esi
callq 0x2220
movsbl %al, %esi
leaq -0x2a0(%rbp), %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2150
incq %r14
cmpq -0x30(%rbp), %r14
jne 0x3d1d
leaq -0x2a0(%rbp), %rbx
movq %rbx, %rdi
callq 0x22c0
movq 0x71fa(%rip), %rax      # 0xafd0
movq (%rax), %r14
movq 0x18(%rax), %r15
leaq -0x298(%rbp), %rdi
movq %r14, -0x8(%rdi)
movq -0x18(%r14), %rax
movq %r15, -0x2a0(%rbp,%rax)
callq 0x21d0
movl $0xf8, %r12d
addq %r12, %rbx
movq %rbx, %rdi
callq 0x20b0
leaq -0x498(%rbp), %rdi
movq %r14, -0x8(%rdi)
movq -0x18(%r14), %rax
movq %r15, -0x4a0(%rbp,%rax)
callq 0x21d0
leaq -0x4a0(%rbp), %rdi
addq %r12, %rdi
callq 0x20b0
movq -0x58(%rbp), %rdi
leaq -0x48(%rbp), %rax
cmpq %rax, %rdi
je 0x3e47
callq 0x2210
addq $0x478, %rsp            # imm = 0x478
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x3e5b
movq %rax, %r12
movq -0x98(%rbp), %rdi
cmpq %rbx, %rdi
je 0x3f2c
callq 0x2210
jmp 0x3f2c
jmp 0x3f29
jmp 0x3e7f
movq %rax, %r12
movq -0x2a0(%rbp), %rdi
cmpq %rbx, %rdi
jne 0x3ea8
jmp 0x3f38
jmp 0x3f0b
movq %rax, %r12
movq -0x4a0(%rbp), %rdi
cmpq %r14, %rdi
je 0x3f38
callq 0x2210
jmp 0x3f38
jmp 0x3f0b
movq %rax, %r12
leaq -0x490(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x3ed1
callq 0x2210
jmp 0x3ed1
movq %rax, %r12
movq -0x78(%rbp), %rdi
leaq -0x68(%rbp), %rax
cmpq %rax, %rdi
je 0x3ee8
callq 0x2210
jmp 0x3ee8
movq %rax, %r12
movq -0x2a0(%rbp), %rdi
cmpq %rbx, %rdi
je 0x3efe
callq 0x2210
jmp 0x3efe
movq %rax, %r12
leaq -0x88(%rbp), %rax
movq -0x10(%rax), %rdi
jmp 0x3f40
movq %rax, %r12
jmp 0x3f38
jmp 0x3f18
jmp 0x3f29
jmp 0x3f18
jmp 0x3f29
movq %rax, %r12
leaq -0x2a0(%rbp), %rdi
callq 0x22e0
jmp 0x3f2c
movq %rax, %r12
leaq -0x4a0(%rbp), %rdi
callq 0x22e0
movq -0x58(%rbp), %rdi
leaq -0x48(%rbp), %rax
cmpq %rax, %rdi
je 0x3f4a
callq 0x2210
movq %r12, %rdi
callq 0x2390