// File: /workspace/github_cpp_makefile_star2_O3/cooljacket[P]Dormitory-distribution/transform.cpp
// Function: transform(char const*, char const*, char const*)
void transform(const char* inputFile, const char* outputFile, const char* studentsListFile) {
	map<string, string> list;
	readStudentsList(studentsListFile, list);

	CSVVectorContainer vec;
	CSVReader::read(inputFile, &vec);
	vector<vector<string> >& data = vec.getData();

	fstream out(outputFile, ios::out);
	set<string> names;

	bool mask[] = {0, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1};

	for (int i = 0; i < data.size(); ++i) {
		if (names.find(data[i][7]) != names.end())
			continue;
		names.insert(data[i][7]);

		if (list.find(data[i][7]) == list.end()) {
			cout << "ERROR!!!!!No such man " << data[i][7] << endl;
			return ;
		}

		province2int(data[i][9]);
		out << list[data[i][7]];
		for (int j = 7; j < data[i].size(); ++j) {
			if (!mask[j-7])
				out << ',' << data[i][j];
			else
				out << ',' << str2int(data[i][j]) - 1;
		}
		out << endl;
	}

	out.close();


	// 最后还要输出没有填问卷的那部分学生的名字
	fstream others(not_in_the_list, ios::out);
	map<string, string>::iterator it = list.begin();
	while (it != list.end()) {
		if (names.find(it->first) == names.end())
			others << it->second << ", " << it->first << endl;
		++it;
	}
	others.close();
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x4c8, %rsp            # imm = 0x4C8
movq %rsi, %r15
movq %rdi, %r14
leaq 0x18(%rsp), %rcx
movl $0x0, (%rcx)
xorl %eax, %eax
movq %rax, 0x8(%rcx)
movq %rcx, 0x10(%rcx)
movq %rcx, 0x18(%rcx)
movq %rax, 0x20(%rcx)
leaq 0x10(%rsp), %rsi
movq %rdx, %rdi
callq 0x7b1c
leaq 0x76e9(%rip), %r12      # 0xed10
addq $0x10, %r12
leaq 0x78(%rsp), %rbx
movq %r12, -0x8(%rbx)
xorps %xmm0, %xmm0
movups %xmm0, (%rbx)
movups %xmm0, 0x10(%rbx)
movups %xmm0, 0x20(%rbx)
leaq 0x70(%rsp), %rsi
movq %r14, %rdi
movl $0x1, %edx
callq 0x83b8
leaq 0x70(%rsp), %rdi
callq 0x88a0
movq %rax, %r14
movq %r12, 0x8(%rsp)
leaq 0xa8(%rsp), %rdi
movq %r15, %rsi
movl $0x10, %edx
callq 0x2290
leaq 0x48(%rsp), %rcx
movl $0x0, (%rcx)
xorl %eax, %eax
movq %rax, 0x8(%rcx)
movq %rcx, 0x10(%rcx)
movq %rcx, 0x18(%rcx)
movq %rax, 0x20(%rcx)
movq (%r14), %rax
cmpq %rax, 0x8(%r14)
je 0x7887
xorl %r12d, %r12d
movl $0xe0, %ebx
leaq 0x40(%rsp), %r15
leaq 0x10(%rsp), %rbp
leaq (%r12,%r12,2), %r13
movq (%rax,%r13,8), %rsi
addq %rbx, %rsi
movq %r15, %rdi
callq 0x7dc2
leaq 0x48(%rsp), %rcx
cmpq %rcx, %rax
jne 0x785f
movq (%r14), %rax
movq (%rax,%r13,8), %rsi
addq %rbx, %rsi
movq %r15, %rdi
callq 0x7e4c
movq (%r14), %rax
movq (%rax,%r13,8), %rsi
addq %rbx, %rsi
movq %rbp, %rdi
callq 0x7ff4
leaq 0x18(%rsp), %rcx
cmpq %rcx, %rax
je 0x79ce
movq (%r14), %rax
movq (%rax,%r13,8), %rdi
movl $0x120, %eax            # imm = 0x120
addq %rax, %rdi
callq 0x7ac2
movq (%r14), %rax
movq (%rax,%r13,8), %rsi
addq %rbx, %rsi
movq %rbp, %rdi
callq 0x7bb8
movq (%rax), %rsi
movq 0x8(%rax), %rdx
leaq 0xb8(%rsp), %rdi
callq 0x2250
movq (%r14), %rax
movq 0x8(%rax,%r13,8), %rcx
subq (%rax,%r13,8), %rcx
cmpq $0xe1, %rcx
jb 0x7817
movl $0xe0, %ebp
xorl %r15d, %r15d
leaq 0x2e54(%rip), %rax      # 0xa5c0
cmpb $0x0, (%r15,%rax)
je 0x77b5
movb $0x2c, 0x2b8(%rsp)
movl $0x1, %edx
leaq 0xb8(%rsp), %rdi
leaq 0x2b8(%rsp), %rsi
callq 0x2250
movq %rax, %rbx
movq (%r14), %rax
movq (%rax,%r13,8), %rdi
addq %rbp, %rdi
callq 0x31dc
decl %eax
movq %rbx, %rdi
movl %eax, %esi
callq 0x2350
jmp 0x77ef
movb $0x2c, 0x2b8(%rsp)
movl $0x1, %edx
leaq 0xb8(%rsp), %rdi
leaq 0x2b8(%rsp), %rsi
callq 0x2250
movq (%r14), %rcx
movq (%rcx,%r13,8), %rcx
movq (%rcx,%rbp), %rsi
movq 0x8(%rcx,%rbp), %rdx
movq %rax, %rdi
callq 0x2250
movq (%r14), %rax
movq 0x8(%rax,%r13,8), %rcx
subq (%rax,%r13,8), %rcx
sarq $0x5, %rcx
addq $0x20, %rbp
leaq 0x1(%r15), %rax
addq $0x8, %r15
cmpq %r15, %rcx
movq %rax, %r15
ja 0x7765
movq 0xb8(%rsp), %rax
movq -0x18(%rax), %rdi
leaq 0xb8(%rsp), %rax
addq %rax, %rdi
movl $0xa, %esi
callq 0x2210
movl $0xe0, %ebx
leaq 0x40(%rsp), %r15
leaq 0x10(%rsp), %rbp
movsbl %al, %esi
leaq 0xb8(%rsp), %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2160
incq %r12
movq (%r14), %rax
movq 0x8(%r14), %rcx
subq %rax, %rcx
sarq $0x3, %rcx
movabsq $-0x5555555555555555, %rdx # imm = 0xAAAAAAAAAAAAAAAB
imulq %rdx, %rcx
cmpq %r12, %rcx
ja 0x76b7
leaq 0xa8(%rsp), %rdi
callq 0x2060
leaq 0x7955(%rip), %rax      # 0xf1f0
movq (%rax), %rsi
leaq 0x2b8(%rsp), %rdi
movl $0x10, %edx
callq 0x2290
leaq 0x18(%rsp), %r13
movq 0x28(%rsp), %r14
cmpq %r13, %r14
je 0x795e
leaq 0x2c8(%rsp), %r15
leaq 0x40(%rsp), %r12
leaq 0x2cda(%rip), %rbp      # 0xa5b1
leaq 0x20(%r14), %rsi
movq %r12, %rdi
callq 0x7dc2
leaq 0x48(%rsp), %rcx
cmpq %rcx, %rax
jne 0x794a
movq 0x40(%r14), %rsi
movq 0x48(%r14), %rdx
movq %r15, %rdi
callq 0x2250
movq %rax, %rbx
movl $0x2, %edx
movq %rax, %rdi
movq %rbp, %rsi
callq 0x2250
movq 0x20(%r14), %rsi
movq 0x28(%r14), %rdx
movq %rbx, %rdi
callq 0x2250
movq %rax, %rbx
movq (%rax), %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
movq %r14, %rdi
callq 0x2170
movq %rax, %r14
cmpq %r13, %rax
jne 0x78d7
leaq 0x2b8(%rsp), %rdi
callq 0x2060
leaq 0x2b8(%rsp), %rdi
callq 0x2080
leaq 0x78(%rsp), %rbx
movq 0x8(%rsp), %r15
leaq 0x40(%rsp), %rdi
callq 0x7cb8
leaq 0xa8(%rsp), %rdi
callq 0x2080
leaq 0x90(%rsp), %rdi
movq %r15, -0x20(%rdi)
callq 0x4b42
movq %rbx, %rdi
callq 0x4b8a
leaq 0x10(%rsp), %rdi
callq 0x7d30
addq $0x4c8, %rsp            # imm = 0x4C8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x75fb(%rip), %rdi      # 0xefd0
leaq 0x2bbe(%rip), %rsi      # 0xa59a
movl $0x16, %edx
leaq 0x78(%rsp), %rbx
movq 0x8(%rsp), %r15
callq 0x2250
movq (%r14), %rax
movq (%rax,%r13,8), %rax
movq 0xe0(%rax), %rsi
movq 0xe8(%rax), %rdx
movq 0x75c4(%rip), %rdi      # 0xefd0
callq 0x2250
movq %rax, %r14
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x2210
movsbl %al, %esi
movq %r14, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2160
jmp 0x7982
jmp 0x7a5f
jmp 0x7a73
jmp 0x7a73
jmp 0x7a73
movq %rax, %r14
jmp 0x7a8d
jmp 0x7a4f
movq %rax, %r14
jmp 0x7a97
movq %rax, %r14
jmp 0x7ab0
jmp 0x7a73
jmp 0x7a73
jmp 0x7a5f
movq %rax, %r14
leaq 0x2b8(%rsp), %rdi
callq 0x2080
jmp 0x7a76
jmp 0x7a73
movq %rax, %r14
leaq 0x40(%rsp), %rdi
callq 0x7cb8
leaq 0xa8(%rsp), %rdi
callq 0x2080
leaq 0x78(%rsp), %rbx
movq 0x8(%rsp), %r12
leaq 0x90(%rsp), %rdi
movq %r12, -0x20(%rdi)
callq 0x4b42
movq %rbx, %rdi
callq 0x4b8a
leaq 0x10(%rsp), %rdi
callq 0x7d30
movq %r14, %rdi
callq 0x2370