// File: /workspace/github_cpp_makefile_star2_O3/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 0x32b9
movq 0xbd57(%rip), %rbx      # 0xefd0
leaq 0x6e00(%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 0x35bc
movq %rsi, %rbx
movq 0x8(%rsi), %rdi
callq 0x75c4
movq 0x8(%rbx), %rbx
testq %rbx, %rbx
je 0x32ea
movq %rbx, %rdi
callq 0x20f0
movq 0xbcf3(%rip), %rdi      # 0xefd0
movq %rbx, %rsi
movq %rax, %rdx
callq 0x2250
jmp 0x3308
movq 0xbcdf(%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 0xbcb9(%rip), %rdi      # 0xefd0
movl $0x1, %edx
callq 0x2250
movq %rax, %rbx
leaq 0xbebd(%rip), %r15      # 0xf1e8
movq (%r15), %r14
testq %r14, %r14
je 0x334b
movq %r14, %rdi
callq 0x20f0
movq %rbx, %rdi
movq %r14, %rsi
movq %rax, %rdx
callq 0x2250
jmp 0x3364
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 0xb97e(%rip), %rcx      # 0xed10
addq $0x10, %rcx
leaq 0x28(%rsp), %rax
movq %rcx, (%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 0x83b8
leaq 0x20(%rsp), %rdi
callq 0x88a0
movq %rax, %r14
movl $0x60, %edi
callq 0x2220
movq %rax, 0x8(%rsp)
movq %rax, %rcx
addq $0x60, %rcx
movq %rcx, 0x18(%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, 0x10(%rsp)
movq (%r14), %rsi
cmpq %rsi, 0x8(%r14)
je 0x350c
leaq 0x98(%rsp), %rbp
xorl %ebx, %ebx
leaq 0x58(%rsp), %r15
movabsq $-0x5555555555555555, %r12 # imm = 0xAAAAAAAAAAAAAAAB
xorl %r13d, %r13d
addq %rbx, %rsi
movq %r15, %rdi
callq 0x6d56
movq %r15, %rdi
callq 0x7334
cltq
leaq (%rax,%rax,2), %rdi
shlq $0x3, %rdi
addq 0x8(%rsp), %rdi
movq %r15, %rsi
callq 0x405c
movq 0xc8(%rsp), %rdi
testq %rdi, %rdi
je 0x3477
movq 0xd8(%rsp), %rsi
subq %rdi, %rsi
callq 0x2230
movq 0xa8(%rsp), %rdi
leaq 0xb8(%rsp), %rax
cmpq %rax, %rdi
je 0x349c
movq 0xb8(%rsp), %rsi
incq %rsi
callq 0x2230
movq 0x88(%rsp), %rdi
cmpq %rbp, %rdi
je 0x34b9
movq 0x98(%rsp), %rsi
incq %rsi
callq 0x2230
movq 0x70(%rsp), %rdi
testq %rdi, %rdi
je 0x34d3
movq 0x80(%rsp), %rsi
subq %rdi, %rsi
callq 0x2230
movq 0x58(%rsp), %rdi
testq %rdi, %rdi
je 0x34ea
movq 0x68(%rsp), %rsi
subq %rdi, %rsi
callq 0x2230
incq %r13
movq (%r14), %rsi
movq 0x8(%r14), %rax
subq %rsi, %rax
sarq $0x3, %rax
imulq %r12, %rax
addq $0x18, %rbx
cmpq %r13, %rax
ja 0x3430
leaq 0x6b87(%rip), %rsi      # 0xa09a
leaq 0x58(%rsp), %rdi
movl $0x10, %edx
callq 0x2290
leaq 0x6b96(%rip), %rsi      # 0xa0bf
leaq 0x268(%rsp), %rdi
movl $0x10, %edx
callq 0x2290
movq 0x8(%rsp), %rsi
leaq 0x30(%rsi), %rdi
addq $0x48, %rsi
leaq 0x68(%rsp), %rdx
callq 0x363c
movq 0x8(%rsp), %rdi
leaq 0x18(%rdi), %rsi
leaq 0x278(%rsp), %rdx
callq 0x363c
leaq 0x268(%rsp), %rdi
callq 0x2060
leaq 0x58(%rsp), %rdi
callq 0x2060
leaq 0x268(%rsp), %rdi
callq 0x2080
leaq 0x58(%rsp), %rdi
callq 0x2080
leaq 0x8(%rsp), %rdi
callq 0x4104
leaq 0x40(%rsp), %rdi
movq (%rsp), %rax
movq %rax, -0x20(%rdi)
callq 0x4b42
leaq 0x28(%rsp), %rdi
callq 0x4b8a
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 0x35f0
jmp 0x35fc
jmp 0x35db
jmp 0x35db
movq %rax, %r14
jmp 0x3618
movq %rax, %r14
leaq 0x268(%rsp), %rdi
callq 0x2080
leaq 0x58(%rsp), %rdi
callq 0x2080
jmp 0x360e
movq %rax, %r14
jmp 0x360e
movq %rax, %r14
leaq 0x58(%rsp), %rdi
callq 0x408c
leaq 0x8(%rsp), %rdi
callq 0x4104
leaq 0x40(%rsp), %rdi
movq (%rsp), %rax
movq %rax, -0x20(%rdi)
callq 0x4b42
leaq 0x28(%rsp), %rdi
callq 0x4b8a
movq %r14, %rdi
callq 0x2370