// File: KokiKishimoto[P]cp_decomposition/./model_file_writer.hpp
// Function: ModelFileWriter::save(std::vector<std::vector<double, std::allocator<double>>, std::allocator<std::vector<double, std::allocator<double>>>>&, std::vector<std::vector<double, std::allocator<double>>, std::allocator<std::vector<double, std::allocator<double>>>>&, std::vector<std::vector<double, std::allocator<double>>, std::allocator<std::vector<double, std::allocator<double>>>>&, SignalOperation&, Data&, int)
void save(std::vector< std::vector<double> >& subjVec, std::vector< std::vector<double> >& objVec, std::vector< std::vector<double> >& relationVec, SignalOperation& op, Data& data, int iter) {
		std::ofstream fout;
		fout.open("./model/" + std::to_string(iter) + "_subject.txt");

		fout << data.entity_counter << " " << subjVec[0].size() << "\n";
		for (int i = 0; i < data.entity_counter; i++) {
			const std::vector<double>& vec = subjVec[i];
			const double norm = op.norm(vec);
			fout << data.entity_dict_rev[i] << " ";

			for (int j = 0; j < vec.size(); j++) {
				if (j > 0) fout << " ";
				fout << vec[j] / norm;
			}
			fout << "\n";
		}

		fout.close();


		fout.open("./model/" + std::to_string(iter) + "_object.txt");

		fout << data.entity_counter << " " << objVec[0].size() << "\n";
		for (int i = 0; i < data.entity_counter; i++) {
			const std::vector<double>& vec = objVec[i];
			const double norm = op.norm(vec);
			fout << data.entity_dict_rev[i] << " ";

			for (int j = 0; j < vec.size(); j++) {
				if (j > 0) fout << " ";
				fout << vec[j] / norm;
			}
			fout << "\n";
		}

		fout.close();


		fout.open("./model/" + std::to_string(iter) + "_relation.txt");

		fout << data.relation_counter << " " << relationVec[0].size() << "\n";
		for (int i = 0; i < data.relation_counter; i++) {
			const std::vector<double>& vec = relationVec[i];
			const double norm = op.norm(vec);
			fout << data.relation_dict_rev[i] << " ";

			for (int j = 0; j < vec.size(); j++) {
				if (j > 0) fout << " ";
				fout << vec[j] / norm;
			}
			fout << "\n";
		}

		fout.close();
	}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x450, %rsp            # imm = 0x450
movl 0x10(%rbp), %eax
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
movq %r9, -0x30(%rbp)
leaq -0x230(%rbp), %rdi
callq 0x3420
movl 0x10(%rbp), %esi
leaq -0x290(%rbp), %rdi
callq 0xf2a0
jmp 0xcb63
leaq 0x35a5(%rip), %rsi      # 0x1010f
leaq -0x270(%rbp), %rdi
leaq -0x290(%rbp), %rdx
callq 0xf250
jmp 0xcb7f
leaq 0x3592(%rip), %rdx      # 0x10118
leaq -0x250(%rbp), %rdi
leaq -0x270(%rbp), %rsi
callq 0xf200
jmp 0xcb9b
leaq -0x230(%rbp), %rdi
leaq -0x250(%rbp), %rsi
movl $0x10, %edx
callq 0x3140
jmp 0xcbb5
leaq -0x250(%rbp), %rdi
callq 0x31a0
leaq -0x270(%rbp), %rdi
callq 0x31a0
leaq -0x290(%rbp), %rdi
callq 0x31a0
movq -0x30(%rbp), %rax
movl (%rax), %esi
leaq -0x230(%rbp), %rdi
callq 0x3430
movq %rax, -0x3c0(%rbp)
jmp 0xcbf4
movq -0x3c0(%rbp), %rdi
leaq 0x350b(%rip), %rsi      # 0x1010d
callq 0x3280
movq %rax, -0x3c8(%rbp)
jmp 0xcc10
movq -0x10(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0xaa60
movq %rax, %rdi
callq 0xb090
movq -0x3c8(%rbp), %rdi
movq %rax, %rsi
callq 0x3090
movq %rax, -0x3d0(%rbp)
jmp 0xcc3d
movq -0x3d0(%rbp), %rdi
leaq 0x34da(%rip), %rsi      # 0x10125
callq 0x3280
jmp 0xcc52
movl $0x0, -0x2a0(%rbp)
movl -0x2a0(%rbp), %eax
movq -0x30(%rbp), %rcx
cmpl (%rcx), %eax
jge 0xce32
movq -0x10(%rbp), %rdi
movslq -0x2a0(%rbp), %rsi
callq 0xaa60
movq %rax, -0x2a8(%rbp)
movq -0x28(%rbp), %rdi
movq -0x2a8(%rbp), %rsi
callq 0xe6f0
movsd %xmm0, -0x2b0(%rbp)
movq -0x30(%rbp), %rdi
addq $0x68, %rdi
leaq -0x2a0(%rbp), %rsi
callq 0x66d0
movq %rax, -0x3d8(%rbp)
jmp 0xccba
movq -0x3d8(%rbp), %rsi
leaq -0x230(%rbp), %rdi
callq 0x3270
movq %rax, -0x3e0(%rbp)
jmp 0xccd6
movq -0x3e0(%rbp), %rdi
leaq 0x3429(%rip), %rsi      # 0x1010d
callq 0x3280
jmp 0xcceb
movl $0x0, -0x2b4(%rbp)
movslq -0x2b4(%rbp), %rax
movq %rax, -0x3e8(%rbp)
movq -0x2a8(%rbp), %rdi
callq 0xb090
movq %rax, %rcx
movq -0x3e8(%rbp), %rax
cmpq %rcx, %rax
jae 0xce07
cmpl $0x0, -0x2b4(%rbp)
jle 0xcdc0
leaq 0x33d7(%rip), %rsi      # 0x1010d
leaq -0x230(%rbp), %rdi
callq 0x3280
jmp 0xcd44
jmp 0xcdc0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x298(%rbp)
movl %eax, -0x29c(%rbp)
jmp 0xd400
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x298(%rbp)
movl %eax, -0x29c(%rbp)
jmp 0xcdaf
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x298(%rbp)
movl %eax, -0x29c(%rbp)
jmp 0xcda3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x298(%rbp)
movl %eax, -0x29c(%rbp)
leaq -0x250(%rbp), %rdi
callq 0x31a0
leaq -0x270(%rbp), %rdi
callq 0x31a0
leaq -0x290(%rbp), %rdi
callq 0x31a0
jmp 0xd400
movq -0x2a8(%rbp), %rdi
movslq -0x2b4(%rbp), %rsi
callq 0xe720
movsd (%rax), %xmm0
movsd -0x2b0(%rbp), %xmm1
divsd %xmm1, %xmm0
leaq -0x230(%rbp), %rdi
callq 0x3480
jmp 0xcdf1
jmp 0xcdf3
movl -0x2b4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2b4(%rbp)
jmp 0xccf5
leaq 0x3317(%rip), %rsi      # 0x10125
leaq -0x230(%rbp), %rdi
callq 0x3280
jmp 0xce1c
jmp 0xce1e
movl -0x2a0(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2a0(%rbp)
jmp 0xcc5c
leaq -0x230(%rbp), %rdi
callq 0x3390
jmp 0xce40
movl 0x10(%rbp), %esi
leaq -0x318(%rbp), %rdi
callq 0xf2a0
jmp 0xce51
leaq 0x32b7(%rip), %rsi      # 0x1010f
leaq -0x2f8(%rbp), %rdi
leaq -0x318(%rbp), %rdx
callq 0xf250
jmp 0xce6d
leaq 0x32b3(%rip), %rdx      # 0x10127
leaq -0x2d8(%rbp), %rdi
leaq -0x2f8(%rbp), %rsi
callq 0xf200
jmp 0xce89
leaq -0x230(%rbp), %rdi
leaq -0x2d8(%rbp), %rsi
movl $0x10, %edx
callq 0x3140
jmp 0xcea3
leaq -0x2d8(%rbp), %rdi
callq 0x31a0
leaq -0x2f8(%rbp), %rdi
callq 0x31a0
leaq -0x318(%rbp), %rdi
callq 0x31a0
movq -0x30(%rbp), %rax
movl (%rax), %esi
leaq -0x230(%rbp), %rdi
callq 0x3430
movq %rax, -0x3f0(%rbp)
jmp 0xcee2
movq -0x3f0(%rbp), %rdi
leaq 0x321d(%rip), %rsi      # 0x1010d
callq 0x3280
movq %rax, -0x3f8(%rbp)
jmp 0xcefe
movq -0x18(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0xaa60
movq %rax, %rdi
callq 0xb090
movq -0x3f8(%rbp), %rdi
movq %rax, %rsi
callq 0x3090
movq %rax, -0x400(%rbp)
jmp 0xcf2b
movq -0x400(%rbp), %rdi
leaq 0x31ec(%rip), %rsi      # 0x10125
callq 0x3280
jmp 0xcf40
movl $0x0, -0x31c(%rbp)
movl -0x31c(%rbp), %eax
movq -0x30(%rbp), %rcx
cmpl (%rcx), %eax
jge 0xd105
movq -0x18(%rbp), %rdi
movslq -0x31c(%rbp), %rsi
callq 0xaa60
movq %rax, -0x328(%rbp)
movq -0x28(%rbp), %rdi
movq -0x328(%rbp), %rsi
callq 0xe6f0
movsd %xmm0, -0x330(%rbp)
movq -0x30(%rbp), %rdi
addq $0x68, %rdi
leaq -0x31c(%rbp), %rsi
callq 0x66d0
movq %rax, -0x408(%rbp)
jmp 0xcfa8
movq -0x408(%rbp), %rsi
leaq -0x230(%rbp), %rdi
callq 0x3270
movq %rax, -0x410(%rbp)
jmp 0xcfc4
movq -0x410(%rbp), %rdi
leaq 0x313b(%rip), %rsi      # 0x1010d
callq 0x3280
jmp 0xcfd9
movl $0x0, -0x334(%rbp)
movslq -0x334(%rbp), %rax
movq %rax, -0x418(%rbp)
movq -0x328(%rbp), %rdi
callq 0xb090
movq %rax, %rcx
movq -0x418(%rbp), %rax
cmpq %rcx, %rax
jae 0xd0da
cmpl $0x0, -0x334(%rbp)
jle 0xd093
leaq 0x30ed(%rip), %rsi      # 0x1010d
leaq -0x230(%rbp), %rdi
callq 0x3280
jmp 0xd02e
jmp 0xd093
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x298(%rbp)
movl %eax, -0x29c(%rbp)
jmp 0xd082
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x298(%rbp)
movl %eax, -0x29c(%rbp)
jmp 0xd076
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x298(%rbp)
movl %eax, -0x29c(%rbp)
leaq -0x2d8(%rbp), %rdi
callq 0x31a0
leaq -0x2f8(%rbp), %rdi
callq 0x31a0
leaq -0x318(%rbp), %rdi
callq 0x31a0
jmp 0xd400
movq -0x328(%rbp), %rdi
movslq -0x334(%rbp), %rsi
callq 0xe720
movsd (%rax), %xmm0
movsd -0x330(%rbp), %xmm1
divsd %xmm1, %xmm0
leaq -0x230(%rbp), %rdi
callq 0x3480
jmp 0xd0c4
jmp 0xd0c6
movl -0x334(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x334(%rbp)
jmp 0xcfe3
leaq 0x3044(%rip), %rsi      # 0x10125
leaq -0x230(%rbp), %rdi
callq 0x3280
jmp 0xd0ef
jmp 0xd0f1
movl -0x31c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x31c(%rbp)
jmp 0xcf4a
leaq -0x230(%rbp), %rdi
callq 0x3390
jmp 0xd113
movl 0x10(%rbp), %esi
leaq -0x398(%rbp), %rdi
callq 0xf2a0
jmp 0xd124
leaq 0x2fe4(%rip), %rsi      # 0x1010f
leaq -0x378(%rbp), %rdi
leaq -0x398(%rbp), %rdx
callq 0xf250
jmp 0xd140
leaq 0x2fec(%rip), %rdx      # 0x10133
leaq -0x358(%rbp), %rdi
leaq -0x378(%rbp), %rsi
callq 0xf200
jmp 0xd15c
leaq -0x230(%rbp), %rdi
leaq -0x358(%rbp), %rsi
movl $0x10, %edx
callq 0x3140
jmp 0xd176
leaq -0x358(%rbp), %rdi
callq 0x31a0
leaq -0x378(%rbp), %rdi
callq 0x31a0
leaq -0x398(%rbp), %rdi
callq 0x31a0
movq -0x30(%rbp), %rax
movl 0x4(%rax), %esi
leaq -0x230(%rbp), %rdi
callq 0x3430
movq %rax, -0x420(%rbp)
jmp 0xd1b6
movq -0x420(%rbp), %rdi
leaq 0x2f49(%rip), %rsi      # 0x1010d
callq 0x3280
movq %rax, -0x428(%rbp)
jmp 0xd1d2
movq -0x20(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0xaa60
movq %rax, %rdi
callq 0xb090
movq -0x428(%rbp), %rdi
movq %rax, %rsi
callq 0x3090
movq %rax, -0x430(%rbp)
jmp 0xd1ff
movq -0x430(%rbp), %rdi
leaq 0x2f18(%rip), %rsi      # 0x10125
callq 0x3280
jmp 0xd214
movl $0x0, -0x39c(%rbp)
movl -0x39c(%rbp), %eax
movq -0x30(%rbp), %rcx
cmpl 0x4(%rcx), %eax
jge 0xd3dd
movq -0x20(%rbp), %rdi
movslq -0x39c(%rbp), %rsi
callq 0xaa60
movq %rax, -0x3a8(%rbp)
movq -0x28(%rbp), %rdi
movq -0x3a8(%rbp), %rsi
callq 0xe6f0
movsd %xmm0, -0x3b0(%rbp)
movq -0x30(%rbp), %rdi
addq $0x98, %rdi
leaq -0x39c(%rbp), %rsi
callq 0x66d0
movq %rax, -0x438(%rbp)
jmp 0xd280
movq -0x438(%rbp), %rsi
leaq -0x230(%rbp), %rdi
callq 0x3270
movq %rax, -0x440(%rbp)
jmp 0xd29c
movq -0x440(%rbp), %rdi
leaq 0x2e63(%rip), %rsi      # 0x1010d
callq 0x3280
jmp 0xd2b1
movl $0x0, -0x3b4(%rbp)
movslq -0x3b4(%rbp), %rax
movq %rax, -0x448(%rbp)
movq -0x3a8(%rbp), %rdi
callq 0xb090
movq %rax, %rcx
movq -0x448(%rbp), %rax
cmpq %rcx, %rax
jae 0xd3b2
cmpl $0x0, -0x3b4(%rbp)
jle 0xd36b
leaq 0x2e15(%rip), %rsi      # 0x1010d
leaq -0x230(%rbp), %rdi
callq 0x3280
jmp 0xd306
jmp 0xd36b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x298(%rbp)
movl %eax, -0x29c(%rbp)
jmp 0xd35a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x298(%rbp)
movl %eax, -0x29c(%rbp)
jmp 0xd34e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x298(%rbp)
movl %eax, -0x29c(%rbp)
leaq -0x358(%rbp), %rdi
callq 0x31a0
leaq -0x378(%rbp), %rdi
callq 0x31a0
leaq -0x398(%rbp), %rdi
callq 0x31a0
jmp 0xd400
movq -0x3a8(%rbp), %rdi
movslq -0x3b4(%rbp), %rsi
callq 0xe720
movsd (%rax), %xmm0
movsd -0x3b0(%rbp), %xmm1
divsd %xmm1, %xmm0
leaq -0x230(%rbp), %rdi
callq 0x3480
jmp 0xd39c
jmp 0xd39e
movl -0x3b4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3b4(%rbp)
jmp 0xd2bb
leaq 0x2d6c(%rip), %rsi      # 0x10125
leaq -0x230(%rbp), %rdi
callq 0x3280
jmp 0xd3c7
jmp 0xd3c9
movl -0x39c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x39c(%rbp)
jmp 0xd21e
leaq -0x230(%rbp), %rdi
callq 0x3390
jmp 0xd3eb
leaq -0x230(%rbp), %rdi
callq 0x33c0
addq $0x450, %rsp            # imm = 0x450
popq %rbp
retq
leaq -0x230(%rbp), %rdi
callq 0x33c0
movq -0x298(%rbp), %rdi
callq 0x3440
nopl (%rax,%rax)