// File: 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 %rbp
movq %rsp, %rbp
subq $0x580, %rsp            # imm = 0x580
movl $0x0, -0x4(%rbp)
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
cmpl $0x2, -0x8(%rbp)
jge 0x564d
movq 0x249aa(%rip), %rdi     # 0x29fd0
leaq 0x16a43(%rip), %rsi     # 0x1c070
callq 0x3270
movq %rax, %rdi
movq 0x2497c(%rip), %rsi     # 0x29fb8
callq 0x32b0
movl $0x0, -0x4(%rbp)
jmp 0x5962
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x14330
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rsi
movq 0x24967(%rip), %rdi     # 0x29fd0
callq 0x3270
movq %rax, %rdi
movl $0x20, %esi
callq 0x3320
movq %rax, %rdi
leaq 0x24beb(%rip), %rax     # 0x2a270
movq %rax, -0x538(%rbp)
movq (%rax), %rsi
callq 0x3270
movq %rax, %rdi
movq 0x2491a(%rip), %rsi     # 0x29fb8
callq 0x32b0
leaq -0x48(%rbp), %rdi
movq %rdi, -0x530(%rbp)
callq 0x64e0
movq -0x538(%rbp), %rax
movq -0x530(%rbp), %rsi
movq (%rax), %rdi
xorl %edx, %edx
callq 0x17370
jmp 0x56cd
leaq -0x48(%rbp), %rdi
callq 0x17930
movq %rax, -0x540(%rbp)
jmp 0x56df
movq -0x540(%rbp), %rax
movq %rax, -0x60(%rbp)
leaq -0x79(%rbp), %rdi
movq %rdi, -0x548(%rbp)
callq 0x6530
movq -0x548(%rbp), %rdx
leaq -0x78(%rbp), %rdi
movl $0x4, %esi
callq 0x6550
jmp 0x5711
leaq -0x79(%rbp), %rdi
callq 0x65c0
movl $0x0, -0x80(%rbp)
movslq -0x80(%rbp), %rax
movq %rax, -0x550(%rbp)
movq -0x60(%rbp), %rdi
callq 0x65e0
movq %rax, %rcx
movq -0x550(%rbp), %rax
cmpq %rcx, %rax
jae 0x5810
movq -0x60(%rbp), %rdi
movslq -0x80(%rbp), %rsi
callq 0x6610
movq %rax, %rsi
leaq -0x108(%rbp), %rdi
callq 0x12de0
jmp 0x5766
leaq -0x108(%rbp), %rdi
callq 0x13540
movl %eax, -0x554(%rbp)
jmp 0x577a
movl -0x554(%rbp), %eax
movslq %eax, %rsi
leaq -0x78(%rbp), %rdi
callq 0x6630
movq %rax, %rdi
leaq -0x108(%rbp), %rsi
callq 0x6650
jmp 0x579d
leaq -0x108(%rbp), %rdi
callq 0x66c0
movl -0x80(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x80(%rbp)
jmp 0x5721
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x5957
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x79(%rbp), %rdi
callq 0x65c0
jmp 0x5957
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x594e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x108(%rbp), %rdi
callq 0x66c0
jmp 0x594e
leaq 0x16873(%rip), %rsi     # 0x1c08a
leaq -0x318(%rbp), %rdi
movl $0x10, %edx
callq 0x3380
jmp 0x582a
leaq 0x1687e(%rip), %rsi     # 0x1c0af
leaq -0x528(%rbp), %rdi
movl $0x10, %edx
callq 0x3380
jmp 0x5844
leaq -0x78(%rbp), %rdi
movq %rdi, -0x568(%rbp)
movl $0x2, %esi
callq 0x6630
movq -0x568(%rbp), %rdi
movq %rax, -0x560(%rbp)
movl $0x3, %esi
callq 0x6630
movq -0x560(%rbp), %rdi
movq %rax, %rsi
leaq -0x308(%rbp), %rdx
callq 0x5980
jmp 0x5889
xorl %eax, %eax
movl %eax, %esi
leaq -0x78(%rbp), %rdi
movq %rdi, -0x578(%rbp)
callq 0x6630
movq -0x578(%rbp), %rdi
movq %rax, -0x570(%rbp)
movl $0x1, %esi
callq 0x6630
movq -0x570(%rbp), %rdi
movq %rax, %rsi
leaq -0x518(%rbp), %rdx
callq 0x5980
jmp 0x58cd
leaq -0x528(%rbp), %rdi
callq 0x3060
jmp 0x58db
leaq -0x318(%rbp), %rdi
callq 0x3060
jmp 0x58e9
movl $0x0, -0x4(%rbp)
leaq -0x528(%rbp), %rdi
callq 0x3090
leaq -0x318(%rbp), %rdi
callq 0x3090
leaq -0x78(%rbp), %rdi
callq 0x6710
leaq -0x48(%rbp), %rdi
callq 0x6770
jmp 0x5962
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x5942
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x528(%rbp), %rdi
callq 0x3090
leaq -0x318(%rbp), %rdi
callq 0x3090
leaq -0x78(%rbp), %rdi
callq 0x6710
leaq -0x48(%rbp), %rdi
callq 0x6770
jmp 0x596e
movl -0x4(%rbp), %eax
addq $0x580, %rsp            # imm = 0x580
popq %rbp
retq
movq -0x50(%rbp), %rdi
callq 0x3440
nopw (%rax,%rax)