// File: /workspace/github_cpp_makefile_star2_O1/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 0x7897(%rip), %r15      # 0xafd8
leaq 0x4974(%rip), %rsi      # 0x80bc
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 0x4937(%rip), %rsi      # 0x80de
leaq -0x98(%rbp), %r15
movq %r15, %rdi
callq 0x5ece
leaq 0x4928(%rip), %rsi      # 0x80e5
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 0x37f5
movq %rsi, %rbx
movq %rdx, -0x2a0(%rbp)
movq (%rcx), %rdx
movq %rdx, -0x290(%rbp)
jmp 0x37fe
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 0x3878
movl $0x4, %r12d
movl $0xd1b71759, %eax       # imm = 0xD1B71759
movl %r15d, %ecx
cmpl $0x63, %ecx
jbe 0x386f
cmpl $0x3e7, %ecx            # imm = 0x3E7
jbe 0x3875
cmpl $0x2710, %ecx           # imm = 0x2710
jb 0x3878
movl %ecx, %edx
imulq %rax, %rdx
shrq $0x2d, %rdx
addl $0x4, %r12d
cmpl $0x1869f, %ecx          # imm = 0x1869F
movl %edx, %ecx
ja 0x383c
addl $-0x3, %r12d
jmp 0x3878
addl $-0x2, %r12d
jmp 0x3878
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 0x60fd
movq -0x2a0(%rbp), %rcx
movq -0x298(%rbp), %r8
movq -0x70(%rbp), %rdx
leaq (%rdx,%r8), %rax
movl $0xf, %esi
cmpq %rbx, %rcx
je 0x38cf
movq -0x290(%rbp), %rsi
cmpq %rsi, %rax
jbe 0x38ec
movl $0xf, %esi
leaq -0x68(%rbp), %rdi
cmpq %rdi, -0x78(%rbp)
je 0x38e7
movq -0x68(%rbp), %rsi
cmpq %rsi, %rax
jbe 0x38fe
movq -0x78(%rbp), %rsi
leaq -0x2a0(%rbp), %rdi
callq 0x20a0
jmp 0x390b
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 0x3935
movq %rsi, -0x4a0(%rbp)
movq (%rcx), %rdx
movq %rdx, -0x490(%rbp)
jmp 0x393b
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 0x4786(%rip), %rsi      # 0x80e7
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 0x3991
movq %rdx, -0x58(%rbp)
movq (%rcx), %rdx
movq %rdx, -0x48(%rbp)
jmp 0x3997
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 0x39c3
callq 0x2210
movq -0x78(%rbp), %rdi
leaq -0x68(%rbp), %rax
cmpq %rax, %rdi
je 0x39d5
callq 0x2210
movq -0x2a0(%rbp), %rdi
cmpq %rbx, %rdi
je 0x39e6
callq 0x2210
leaq -0x88(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x39fb
callq 0x2210
leaq 0x46ee(%rip), %rsi      # 0x80f0
leaq -0x4a0(%rbp), %rdi
leaq -0x58(%rbp), %rdx
callq 0x5ece
movq -0x4a0(%rbp), %rdi
callq 0x21e0
movq -0x4a0(%rbp), %rdi
cmpq %r14, %rdi
je 0x3a2f
callq 0x2210
movq 0x75a2(%rip), %rdi      # 0xafd8
leaq 0x46bd(%rip), %rsi      # 0x80fa
movl $0xb, %edx
callq 0x2270
movq -0x58(%rbp), %rsi
movq -0x50(%rbp), %rdx
movq 0x7582(%rip), %rdi      # 0xafd8
callq 0x2270
movq %rax, %r14
leaq 0x46a1(%rip), %rsi      # 0x8106
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 0x6170
leaq 0x4655(%rip), %rsi      # 0x810f
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 0x3b05
callq 0x2210
leaq -0x4a0(%rbp), %rdi
movq -0x30(%rbp), %rsi
callq 0x2380
movq %rax, %r12
leaq 0x4564(%rip), %rsi      # 0x8083
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 0x3c2f
movq -0x30(%rbp), %rax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
movq %rax, -0xa0(%rbp)
xorl %r14d, %r14d
leaq 0x44fa(%rip), %r12      # 0x8083
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 0x3be9
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 0x3bb2
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 0x3b89
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 0x6170
leaq 0x44c3(%rip), %rsi      # 0x8126
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 0x3c98
callq 0x2210
leaq -0x2a0(%rbp), %rdi
movq -0x30(%rbp), %rsi
callq 0x2380
movq %rax, %r13
leaq 0x43d1(%rip), %rsi      # 0x8083
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 0x3dbb
movq -0x30(%rbp), %rax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
movq %rax, -0x30(%rbp)
xorl %r14d, %r14d
leaq 0x436b(%rip), %r13      # 0x8083
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 0x3d78
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 0x3d41
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 0x3d18
leaq -0x2a0(%rbp), %rbx
movq %rbx, %rdi
callq 0x22c0
movq 0x71ff(%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 0x3e42
callq 0x2210
addq $0x478, %rsp            # imm = 0x478
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x3e56
movq %rax, %r12
movq -0x98(%rbp), %rdi
cmpq %rbx, %rdi
je 0x3f27
callq 0x2210
jmp 0x3f27
jmp 0x3f24
jmp 0x3e7a
movq %rax, %r12
movq -0x2a0(%rbp), %rdi
cmpq %rbx, %rdi
jne 0x3ea3
jmp 0x3f33
jmp 0x3f06
movq %rax, %r12
movq -0x4a0(%rbp), %rdi
cmpq %r14, %rdi
je 0x3f33
callq 0x2210
jmp 0x3f33
jmp 0x3f06
movq %rax, %r12
leaq -0x490(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x3ecc
callq 0x2210
jmp 0x3ecc
movq %rax, %r12
movq -0x78(%rbp), %rdi
leaq -0x68(%rbp), %rax
cmpq %rax, %rdi
je 0x3ee3
callq 0x2210
jmp 0x3ee3
movq %rax, %r12
movq -0x2a0(%rbp), %rdi
cmpq %rbx, %rdi
je 0x3ef9
callq 0x2210
jmp 0x3ef9
movq %rax, %r12
leaq -0x88(%rbp), %rax
movq -0x10(%rax), %rdi
jmp 0x3f3b
movq %rax, %r12
jmp 0x3f33
jmp 0x3f13
jmp 0x3f24
jmp 0x3f13
jmp 0x3f24
movq %rax, %r12
leaq -0x2a0(%rbp), %rdi
callq 0x22e0
jmp 0x3f27
movq %rax, %r12
leaq -0x4a0(%rbp), %rdi
callq 0x22e0
movq -0x58(%rbp), %rdi
leaq -0x48(%rbp), %rax
cmpq %rax, %rdi
je 0x3f45
callq 0x2210
movq %r12, %rdi
callq 0x2390
nop