// File: /workspace/github_cpp_makefile_star2_O2/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, %r14
movq %rdi, %rbx
leaq 0x48(%rsp), %r15
andl $0x0, (%r15)
andq $0x0, 0x8(%r15)
movq %r15, 0x10(%r15)
movq %r15, 0x18(%r15)
andq $0x0, 0x20(%r15)
leaq 0x40(%rsp), %rsi
movq %rdx, %rdi
callq 0x6d61
leaq 0x8333(%rip), %rax      # 0xed18
addq $0x10, %rax
leaq 0x70(%rsp), %rsi
movq %rax, (%rsi)
xorps %xmm0, %xmm0
movups %xmm0, 0x8(%rsi)
movups %xmm0, 0x18(%rsi)
movups %xmm0, 0x28(%rsi)
pushq $0x1
popq %rdx
movq %rbx, %rdi
callq 0x7604
leaq 0x70(%rsp), %rdi
callq 0x7a32
movq %rax, %rbx
leaq 0x2b8(%rsp), %rdi
pushq $0x10
popq %rdx
movq %r14, %rsi
callq 0x2290
leaq 0x18(%rsp), %rax
andl $0x0, (%rax)
andq $0x0, 0x8(%rax)
movq %rax, 0x10(%rax)
movq %rax, 0x18(%rax)
andq $0x0, 0x20(%rax)
leaq 0x2c8(%rsp), %r14
xorl %r13d, %r13d
pushq $0x18
popq %rbp
movq (%rbx), %rcx
movq 0x8(%rbx), %rax
subq %rcx, %rax
cqto
idivq %rbp
cmpq %r13, %rax
jbe 0x6ba8
imulq $0x18, %r13, %r12
movq (%rcx,%r12), %rsi
movl $0xe0, %eax
addq %rax, %rsi
leaq 0x10(%rsp), %rdi
callq 0x6fac
leaq 0x18(%rsp), %rcx
cmpq %rcx, %rax
jne 0x6ba0
movq (%rbx), %rax
movq (%rax,%r12), %rsi
movl $0xe0, %eax
addq %rax, %rsi
leaq 0x10(%rsp), %rdi
callq 0x7036
movq (%rbx), %rax
movq (%rax,%r12), %rsi
movl $0xe0, %eax
addq %rax, %rsi
leaq 0x40(%rsp), %rdi
callq 0x7214
cmpq %r15, %rax
je 0x6c5b
movq (%rbx), %rax
movq (%rax,%r12), %rdi
movl $0x120, %eax            # imm = 0x120
addq %rax, %rdi
callq 0x6d2d
movq (%rbx), %rax
movq (%rax,%r12), %rsi
movl $0xe0, %eax
addq %rax, %rsi
leaq 0x40(%rsp), %rdi
callq 0x6dee
movq %r14, %rdi
movq %rax, %rsi
callq 0x21d0
movq %r13, 0x8(%rsp)
movl $0xe0, %r15d
xorl %ebp, %ebp
leaq 0x7(%rbp), %rax
movq (%rbx), %rcx
movq 0x8(%rcx,%r12), %rdx
subq (%rcx,%r12), %rdx
sarq $0x5, %rdx
cmpq %rax, %rdx
jbe 0x6b8b
leaq 0x2a9d(%rip), %rax      # 0x95d0
cmpb $0x0, (%rbp,%rax)
je 0x6b65
movq %r14, %rdi
pushq $0x2c
popq %rsi
callq 0x2250
movq %rax, %r13
movq (%rbx), %rax
movq (%rax,%r12), %rdi
addq %r15, %rdi
callq 0x2dbc
decl %eax
movq %r13, %rdi
movl %eax, %esi
callq 0x2340
jmp 0x6b82
movq %r14, %rdi
pushq $0x2c
popq %rsi
callq 0x2250
movq (%rbx), %rcx
movq (%rcx,%r12), %rsi
addq %r15, %rsi
movq %rax, %rdi
callq 0x21d0
incq %rbp
addq $0x20, %r15
jmp 0x6b13
movq %r14, %rdi
callq 0x20f0
leaq 0x48(%rsp), %r15
movq 0x8(%rsp), %r13
pushq $0x18
popq %rbp
incq %r13
jmp 0x6a53
leaq 0x2b8(%rsp), %rdi
callq 0x2050
leaq 0x8634(%rip), %rax      # 0xf1f0
movq (%rax), %rsi
leaq 0xa8(%rsp), %rdi
pushq $0x10
popq %rdx
callq 0x2290
movq 0x58(%rsp), %r12
leaq 0xb8(%rsp), %rbx
leaq 0x10(%rsp), %r14
leaq 0x29dc(%rip), %rbp      # 0x95c4
cmpq %r15, %r12
je 0x6c3f
leaq 0x20(%r12), %r13
movq %r14, %rdi
movq %r13, %rsi
callq 0x6fac
leaq 0x18(%rsp), %rcx
cmpq %rcx, %rax
jne 0x6c32
leaq 0x40(%r12), %rsi
movq %rbx, %rdi
callq 0x21d0
movq %rax, %rdi
movq %rbp, %rsi
callq 0x2200
movq %rax, %rdi
movq %r13, %rsi
callq 0x21d0
movq %rax, %rdi
callq 0x20f0
movq %r12, %rdi
callq 0x2150
movq %rax, %r12
jmp 0x6be8
leaq 0xa8(%rsp), %rdi
callq 0x2050
leaq 0xa8(%rsp), %rdi
callq 0x2070
jmp 0x6c8a
movq 0x836e(%rip), %rdi      # 0xefd0
leaq 0x2944(%rip), %rsi      # 0x95ad
callq 0x2200
movq (%rbx), %rcx
movl $0xe0, %esi
addq (%rcx,%r12), %rsi
movq %rax, %rdi
callq 0x21d0
movq %rax, %rdi
callq 0x20f0
leaq 0x10(%rsp), %rdi
callq 0x6ece
leaq 0x2b8(%rsp), %rdi
callq 0x2070
leaq 0x70(%rsp), %rdi
callq 0x3818
leaq 0x40(%rsp), %rdi
callq 0x6f32
addq $0x4c8, %rsp            # imm = 0x4C8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x6ce3
jmp 0x6cf7
jmp 0x6cf7
jmp 0x6cf7
jmp 0x6cd3
jmp 0x6cd3
movq %rax, %rbx
jmp 0x6d11
movq %rax, %rbx
jmp 0x6d1b
jmp 0x6cf7
jmp 0x6ce3
jmp 0x6cf7
movq %rax, %rbx
leaq 0xa8(%rsp), %rdi
callq 0x2070
jmp 0x6cfa
jmp 0x6cf7
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0x6ece
leaq 0x2b8(%rsp), %rdi
callq 0x2070
leaq 0x70(%rsp), %rdi
callq 0x3818
leaq 0x40(%rsp), %rdi
callq 0x6f32
movq %rbx, %rdi
callq 0x2350