// File: /workspace/github_cpp_makefile_star2_O1/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x478, %rsp            # imm = 0x478
cmpl $0x1, %edi
jg 0x3339
movq 0xbcd7(%rip), %rbx      # 0xefd0
leaq 0x6d80(%rip), %rsi      # 0xa080
movl $0x19, %edx
movq %rbx, %rdi
callq 0x2250
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x2210
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2160
jmp 0x364d
movq %rsi, %rbx
movq 0x8(%rsi), %rdi
callq 0x75bc
movq 0x8(%rbx), %rbx
testq %rbx, %rbx
je 0x336a
movq %rbx, %rdi
callq 0x20f0
movq 0xbc73(%rip), %rdi      # 0xefd0
movq %rbx, %rsi
movq %rax, %rdx
callq 0x2250
jmp 0x3388
movq 0xbc5f(%rip), %rax      # 0xefd0
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
leaq (%rax,%rcx), %rdi
movl 0x20(%rax,%rcx), %esi
orl $0x1, %esi
callq 0x2330
leaq 0x58(%rsp), %rsi
movb $0x20, (%rsi)
movq 0xbc39(%rip), %rdi      # 0xefd0
movl $0x1, %edx
callq 0x2250
movq %rax, %rbx
leaq 0xbe3d(%rip), %r15      # 0xf1e8
movq (%r15), %r14
testq %r14, %r14
je 0x33cb
movq %r14, %rdi
callq 0x20f0
movq %rbx, %rdi
movq %r14, %rsi
movq %rax, %rdx
callq 0x2250
jmp 0x33e4
movq (%rbx), %rax
movq -0x18(%rax), %rax
movq %rbx, %rdi
addq %rax, %rdi
movl 0x20(%rbx,%rax), %esi
orl $0x1, %esi
callq 0x2330
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x2210
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2160
leaq 0xb8fe(%rip), %rcx      # 0xed10
addq $0x10, %rcx
leaq 0x28(%rsp), %rax
movq %rcx, 0x18(%rsp)
movq %rcx, -0x8(%rax)
xorps %xmm0, %xmm0
movups %xmm0, (%rax)
movups %xmm0, 0x10(%rax)
movups %xmm0, 0x20(%rax)
movq (%r15), %rdi
leaq 0x20(%rsp), %rsi
xorl %edx, %edx
callq 0x83b0
leaq 0x20(%rsp), %rdi
callq 0x8896
movq %rax, %r14
xorps %xmm0, %xmm0
movaps %xmm0, (%rsp)
movq $0x0, 0x10(%rsp)
movl $0x60, %edi
callq 0x2220
movq %rax, (%rsp)
movq %rax, 0x8(%rsp)
movq %rax, %rcx
addq $0x60, %rcx
movq %rcx, 0x10(%rsp)
xorps %xmm0, %xmm0
movups %xmm0, 0x50(%rax)
movups %xmm0, 0x40(%rax)
movups %xmm0, 0x30(%rax)
movups %xmm0, 0x20(%rax)
movups %xmm0, 0x10(%rax)
movups %xmm0, (%rax)
movq %rcx, 0x8(%rsp)
movq 0x8(%r14), %rax
cmpq (%r14), %rax
je 0x35a0
leaq 0x98(%rsp), %rbp
xorl %ebx, %ebx
leaq 0x58(%rsp), %r15
movabsq $-0x5555555555555555, %r12 # imm = 0xAAAAAAAAAAAAAAAB
xorl %r13d, %r13d
movq (%r14), %rsi
addq %rbx, %rsi
movq %r15, %rdi
callq 0x6dce
movq %r15, %rdi
callq 0x7330
cltq
leaq (%rax,%rax,2), %rdi
shlq $0x3, %rdi
addq (%rsp), %rdi
movq %r15, %rsi
callq 0x40ea
movq 0xc8(%rsp), %rdi
testq %rdi, %rdi
je 0x350e
movq 0xd8(%rsp), %rsi
subq %rdi, %rsi
callq 0x2230
movq 0xa8(%rsp), %rdi
leaq 0xb8(%rsp), %rax
cmpq %rax, %rdi
je 0x3533
movq 0xb8(%rsp), %rsi
incq %rsi
callq 0x2230
movq 0x88(%rsp), %rdi
cmpq %rbp, %rdi
je 0x3550
movq 0x98(%rsp), %rsi
incq %rsi
callq 0x2230
movq 0x70(%rsp), %rdi
testq %rdi, %rdi
je 0x356a
movq 0x80(%rsp), %rsi
subq %rdi, %rsi
callq 0x2230
movq 0x58(%rsp), %rdi
testq %rdi, %rdi
je 0x3581
movq 0x68(%rsp), %rsi
subq %rdi, %rsi
callq 0x2230
incq %r13
movq 0x8(%r14), %rax
subq (%r14), %rax
sarq $0x3, %rax
imulq %r12, %rax
addq $0x18, %rbx
cmpq %r13, %rax
ja 0x34c5
leaq 0x6af3(%rip), %rsi      # 0xa09a
leaq 0x58(%rsp), %rdi
movl $0x10, %edx
callq 0x2290
leaq 0x6b02(%rip), %rsi      # 0xa0bf
leaq 0x268(%rsp), %rdi
movl $0x10, %edx
callq 0x2290
movq (%rsp), %rsi
leaq 0x30(%rsi), %rdi
addq $0x48, %rsi
leaq 0x68(%rsp), %rdx
callq 0x36cc
movq (%rsp), %rdi
leaq 0x18(%rdi), %rsi
leaq 0x278(%rsp), %rdx
callq 0x36cc
leaq 0x268(%rsp), %rdi
callq 0x2060
leaq 0x58(%rsp), %rdi
callq 0x2060
leaq 0x268(%rsp), %rdi
callq 0x2080
leaq 0x58(%rsp), %rdi
callq 0x2080
movq %rsp, %rdi
callq 0x4192
leaq 0x40(%rsp), %rdi
movq 0x18(%rsp), %rax
movq %rax, -0x20(%rdi)
callq 0x4b4a
leaq 0x28(%rsp), %rdi
callq 0x4b8c
xorl %eax, %eax
addq $0x478, %rsp            # imm = 0x478
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %r14
jmp 0x3681
jmp 0x368d
jmp 0x366c
jmp 0x366c
movq %rax, %r14
jmp 0x36a7
movq %rax, %r14
leaq 0x268(%rsp), %rdi
callq 0x2080
leaq 0x58(%rsp), %rdi
callq 0x2080
jmp 0x369f
movq %rax, %r14
jmp 0x369f
movq %rax, %r14
leaq 0x58(%rsp), %rdi
callq 0x411a
movq %rsp, %rdi
callq 0x4192
leaq 0x40(%rsp), %rdi
movq 0x18(%rsp), %rax
movq %rax, -0x20(%rdi)
callq 0x4b4a
leaq 0x28(%rsp), %rdi
callq 0x4b8c
movq %r14, %rdi
callq 0x2370