// File: /workspace/github_cpp_makefile_star2_O2/cooljacket[P]Dormitory-distribution/main.cpp
// Function: main
int main(int argc, char* argv[]) {
	if (argc < 2) {
		cout << "usage: main original_data" << endl;
		return 0;
	}


	// 先把从问卷星得到的原始数据进行预处理及变换
	transform_original_data(argv[1]);

	cout << argv[1] << ' ' << file_after_process << endl;

	//首先读取处理过后的数据
	CSVVectorContainer vec;
	CSVReader::read(file_after_process, &vec, false);
	vector<vector<string> >& data = vec.getData();

	// 将处理过后的数据分成4个组：男省内，男省外，女省内，女省外
	vector<vector<Student> > all_stus(4);
	for (int i = 0; i < data.size(); ++i) {
		Student stu(data[i]);
		all_stus[stu.getKind()].push_back(stu);
	}


	// 接下来是分配算法的主体
	fstream girls_output("results/女生宿舍分配情况.csv", ios::out);
	fstream boys_output("results/男生宿舍分配情况.csv", ios::out);
	divide(all_stus[Student::GIRLS_IN], all_stus[Student::GIRLS_OUT], girls_output);
	divide(all_stus[Student::BOYS_IN], all_stus[Student::BOYS_OUT], boys_output);
	boys_output.close();
	girls_output.close();

	return 0;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x470, %rsp            # imm = 0x470
cmpl $0x1, %edi
jg 0x2e49
movq 0xc1a0(%rip), %rdi      # 0xefd0
leaq 0x6249(%rip), %rsi      # 0x9080
callq 0x2200
movq %rax, %rdi
callq 0x20f0
jmp 0x2fc2
movq %rsi, %rbx
movq 0x8(%rsi), %rdi
callq 0x6984
movq 0x8(%rbx), %rsi
movq 0xc170(%rip), %rdi      # 0xefd0
callq 0x2200
pushq $0x20
popq %rsi
movq %rax, %rdi
callq 0x2250
leaq 0xc371(%rip), %rbx      # 0xf1e8
movq (%rbx), %rsi
movq %rax, %rdi
callq 0x2200
movq %rax, %rdi
callq 0x20f0
leaq 0xbe87(%rip), %rax      # 0xed18
addq $0x10, %rax
leaq 0x18(%rsp), %rsi
movq %rax, (%rsi)
xorps %xmm0, %xmm0
movups %xmm0, 0x8(%rsi)
movups %xmm0, 0x18(%rsi)
movups %xmm0, 0x28(%rsi)
movq (%rbx), %rdi
xorl %edx, %edx
callq 0x7604
leaq 0x18(%rsp), %rdi
callq 0x7a32
movq %rax, %rbx
movq %rsp, %rdi
pushq $0x4
popq %rsi
leaq 0x50(%rsp), %rdx
callq 0x374c
xorl %r15d, %r15d
pushq $0x18
popq %r12
leaq 0x50(%rsp), %r14
xorl %r13d, %r13d
movq (%rbx), %rsi
movq 0x8(%rbx), %rax
subq %rsi, %rax
cqto
idivq %r12
cmpq %r13, %rax
jbe 0x2f2c
addq %r15, %rsi
movq %r14, %rdi
callq 0x6242
movq %r14, %rdi
callq 0x6606
cltq
imulq $0x18, %rax, %rdi
addq (%rsp), %rdi
movq %r14, %rsi
callq 0x379e
movq %r14, %rdi
callq 0x37ce
incq %r13
addq $0x18, %r15
jmp 0x2ee2
leaq 0x6167(%rip), %rsi      # 0x909a
leaq 0x50(%rsp), %rdi
pushq $0x10
popq %rdx
callq 0x2290
leaq 0x6178(%rip), %rsi      # 0x90bf
leaq 0x260(%rsp), %rdi
pushq $0x10
popq %rdx
callq 0x2290
movq (%rsp), %rsi
leaq 0x30(%rsi), %rdi
addq $0x48, %rsi
leaq 0x60(%rsp), %rdx
callq 0x302d
movq (%rsp), %rdi
leaq 0x18(%rdi), %rsi
leaq 0x270(%rsp), %rdx
callq 0x302d
leaq 0x260(%rsp), %rdi
callq 0x2050
leaq 0x50(%rsp), %rdi
callq 0x2050
leaq 0x260(%rsp), %rdi
callq 0x2070
leaq 0x50(%rsp), %rdi
callq 0x2070
movq %rsp, %rdi
callq 0x37f6
leaq 0x18(%rsp), %rdi
callq 0x3818
xorl %eax, %eax
addq $0x470, %rsp            # imm = 0x470
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
movq %rax, %rbx
jmp 0x2ff5
jmp 0x3001
jmp 0x2fe0
jmp 0x2fe0
movq %rax, %rbx
jmp 0x301b
movq %rax, %rbx
leaq 0x260(%rsp), %rdi
callq 0x2070
leaq 0x50(%rsp), %rdi
callq 0x2070
jmp 0x3013
movq %rax, %rbx
jmp 0x3013
movq %rax, %rbx
leaq 0x50(%rsp), %rdi
callq 0x37ce
movq %rsp, %rdi
callq 0x37f6
leaq 0x18(%rsp), %rdi
callq 0x3818
movq %rbx, %rdi
callq 0x2350