// File: /workspace/github_cpp_makefile_star2_O2/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 $0x488, %rsp            # imm = 0x488
movl %esi, %r15d
movq %rdi, %rbx
movq 0x7c73(%rip), %rdi      # 0xafd8
leaq 0x3d50(%rip), %rsi      # 0x70bc
callq 0x2200
movq %rax, %rdi
movl %r15d, %esi
callq 0x2370
movq %rax, %rdi
callq 0x2100
movq 0xb0(%rbx), %rax
subq 0xa8(%rbx), %rax
pushq $0x18
popq %rcx
cqto
idivq %rcx
movq %rax, -0x38(%rbp)
movq %rbx, -0x30(%rbp)
leaq 0x38(%rbx), %rdx
leaq 0x3d31(%rip), %rsi      # 0x70de
leaq -0x68(%rbp), %r12
movq %r12, %rdi
callq 0x51b7
leaq 0x3d25(%rip), %rdx      # 0x70e5
leaq -0x2a8(%rbp), %rdi
movq %r12, %rsi
callq 0x511d
leaq -0xa8(%rbp), %rdi
movl %r15d, %esi
callq 0x522d
leaq -0x4a8(%rbp), %rdi
leaq -0x2a8(%rbp), %rsi
leaq -0xa8(%rbp), %rdx
callq 0x5146
leaq 0x3ce8(%rip), %rdx      # 0x70e7
leaq -0x88(%rbp), %rdi
leaq -0x4a8(%rbp), %rsi
callq 0x511d
leaq -0x4a8(%rbp), %rdi
callq 0x20f0
leaq -0xa8(%rbp), %rdi
callq 0x20f0
leaq -0x2a8(%rbp), %rdi
callq 0x20f0
leaq -0x68(%rbp), %rdi
callq 0x20f0
leaq 0x3caa(%rip), %rsi      # 0x70f0
leaq -0x4a8(%rbp), %rdi
leaq -0x88(%rbp), %rdx
callq 0x51b7
movq -0x4a8(%rbp), %rdi
callq 0x21b0
leaq -0x4a8(%rbp), %rdi
callq 0x20f0
movq 0x7b60(%rip), %rdi      # 0xafd8
leaq 0x3c7b(%rip), %rsi      # 0x70fa
callq 0x2200
leaq -0x88(%rbp), %rsi
movq %rax, %rdi
callq 0x21d0
leaq 0x3c6c(%rip), %rsi      # 0x7106
movq %rax, %rdi
callq 0x2200
movq %rax, %rdi
callq 0x2100
leaq 0x3c5e(%rip), %rdx      # 0x710f
leaq -0x2a8(%rbp), %rdi
leaq -0x88(%rbp), %rsi
callq 0x528d
movq -0x2a8(%rbp), %rsi
leaq -0x4a8(%rbp), %rdi
pushq $0x10
popq %rdx
callq 0x2230
leaq -0x2a8(%rbp), %rdi
callq 0x20f0
leaq -0x4a8(%rbp), %rdi
movq -0x38(%rbp), %rsi
callq 0x2370
leaq 0x3b86(%rip), %rsi      # 0x7083
movq %rax, %rdi
callq 0x2200
movq -0x30(%rbp), %rcx
movl 0x4(%rcx), %esi
movq %rax, %rdi
callq 0x2370
movq %rax, %rdi
callq 0x2100
movq -0x38(%rbp), %rax
testl %eax, %eax
movl $0x0, %ecx
cmovgl %eax, %ecx
movq %rcx, -0x48(%rbp)
leaq -0x4a8(%rbp), %r15
leaq 0x3b47(%rip), %r12      # 0x7083
xorl %ecx, %ecx
cmpq -0x48(%rbp), %rcx
je 0x35b2
movq -0x30(%rbp), %rax
movq 0xd8(%rax), %rax
movq %rcx, -0x40(%rbp)
imulq $0x18, %rcx, %r13
movq 0x8(%rax,%r13), %r14
subq (%rax,%r13), %r14
shrq $0x2, %r14
testl %r14d, %r14d
movl $0x0, %eax
cmovlel %eax, %r14d
xorl %ebx, %ebx
cmpq %rbx, %r14
je 0x35a1
movq -0x30(%rbp), %rax
movq 0xd8(%rax), %rax
movq (%rax,%r13), %rax
movl (%rax,%rbx,4), %esi
movq %r15, %rdi
callq 0x2370
movq %rax, %rdi
movq %r12, %rsi
callq 0x2200
incq %rbx
jmp 0x3572
movq %r15, %rdi
callq 0x2100
movq -0x40(%rbp), %rcx
incq %rcx
jmp 0x353e
leaq -0x4a8(%rbp), %rdi
callq 0x22a0
leaq 0x3b61(%rip), %rdx      # 0x7126
leaq -0x68(%rbp), %rdi
leaq -0x88(%rbp), %rsi
callq 0x528d
movq -0x68(%rbp), %rsi
leaq -0x2a8(%rbp), %rdi
pushq $0x10
popq %rdx
callq 0x2230
leaq -0x68(%rbp), %rdi
callq 0x20f0
leaq -0x2a8(%rbp), %rdi
movq -0x38(%rbp), %rsi
callq 0x2370
leaq 0x3a7b(%rip), %rsi      # 0x7083
movq %rax, %rdi
callq 0x2200
movq -0x30(%rbp), %rcx
movl (%rcx), %esi
movq %rax, %rdi
callq 0x2370
movq %rax, %rdi
callq 0x2100
leaq -0x2a8(%rbp), %r14
leaq 0x3a4f(%rip), %r15      # 0x7083
xorl %ecx, %ecx
cmpq -0x48(%rbp), %rcx
je 0x36aa
movq -0x30(%rbp), %rax
movq 0xc0(%rax), %rax
movq %rcx, -0x40(%rbp)
imulq $0x18, %rcx, %r13
movq 0x8(%rax,%r13), %r12
subq (%rax,%r13), %r12
shrq $0x2, %r12
testl %r12d, %r12d
movl $0x0, %eax
cmovlel %eax, %r12d
xorl %ebx, %ebx
cmpq %rbx, %r12
je 0x3699
movq -0x30(%rbp), %rax
movq 0xc0(%rax), %rax
movq (%rax,%r13), %rax
movl (%rax,%rbx,4), %esi
movq %r14, %rdi
callq 0x2370
movq %rax, %rdi
movq %r15, %rsi
callq 0x2200
incq %rbx
jmp 0x366a
movq %r14, %rdi
callq 0x2100
movq -0x40(%rbp), %rcx
incq %rcx
jmp 0x3636
leaq -0x2a8(%rbp), %rdi
callq 0x22a0
leaq -0x2a8(%rbp), %rdi
callq 0x22c0
leaq -0x4a8(%rbp), %rdi
callq 0x22c0
leaq -0x88(%rbp), %rdi
callq 0x20f0
addq $0x488, %rsp            # imm = 0x488
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq -0x68(%rbp), %rdi
callq 0x20f0
jmp 0x377d
jmp 0x377a
movq %rax, %rbx
leaq -0x2a8(%rbp), %rdi
jmp 0x3717
jmp 0x375c
movq %rax, %rbx
leaq -0x4a8(%rbp), %rdi
callq 0x20f0
jmp 0x3789
jmp 0x375c
movq %rax, %rbx
leaq -0x4a8(%rbp), %rdi
callq 0x20f0
jmp 0x3734
movq %rax, %rbx
leaq -0xa8(%rbp), %rdi
callq 0x20f0
jmp 0x3745
movq %rax, %rbx
leaq -0x2a8(%rbp), %rdi
callq 0x20f0
jmp 0x3756
movq %rax, %rbx
leaq -0x68(%rbp), %rdi
jmp 0x3790
movq %rax, %rbx
jmp 0x3789
jmp 0x3769
jmp 0x377a
jmp 0x3769
jmp 0x377a
movq %rax, %rbx
leaq -0x2a8(%rbp), %rdi
callq 0x22c0
jmp 0x377d
movq %rax, %rbx
leaq -0x4a8(%rbp), %rdi
callq 0x22c0
leaq -0x88(%rbp), %rdi
callq 0x20f0
movq %rbx, %rdi
callq 0x2380
nop