// File: /workspace/github_cpp_makefile_star2_O1/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 0x7b14
leaq 0x76f1(%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 0x83b0
leaq 0x70(%rsp), %rdi
callq 0x8896
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 0x787f
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 0x7dba
leaq 0x48(%rsp), %rcx
cmpq %rcx, %rax
jne 0x7857
movq (%r14), %rax
movq (%rax,%r13,8), %rsi
addq %rbx, %rsi
movq %r15, %rdi
callq 0x7e44
movq (%r14), %rax
movq (%rax,%r13,8), %rsi
addq %rbx, %rsi
movq %rbp, %rdi
callq 0x7fec
leaq 0x18(%rsp), %rcx
cmpq %rcx, %rax
je 0x79c6
movq (%r14), %rax
movq (%rax,%r13,8), %rdi
movl $0x120, %eax            # imm = 0x120
addq %rax, %rdi
callq 0x7aba
movq (%r14), %rax
movq (%rax,%r13,8), %rsi
addq %rbx, %rsi
movq %rbp, %rdi
callq 0x7bb0
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 0x780f
movl $0xe0, %ebp
xorl %r15d, %r15d
leaq 0x2e4c(%rip), %rax      # 0xa5b0
cmpb $0x0, (%r15,%rax)
je 0x77ad
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 0x325c
decl %eax
movq %rbx, %rdi
movl %eax, %esi
callq 0x2350
jmp 0x77e7
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 0x775d
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 0x76af
leaq 0xa8(%rsp), %rdi
callq 0x2060
leaq 0x795d(%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 0x7956
leaq 0x2c8(%rsp), %r15
leaq 0x40(%rsp), %r12
leaq 0x2cd2(%rip), %rbp      # 0xa5a1
leaq 0x20(%r14), %rsi
movq %r12, %rdi
callq 0x7dba
leaq 0x48(%rsp), %rcx
cmpq %rcx, %rax
jne 0x7942
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 0x78cf
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 0x7cb0
leaq 0xa8(%rsp), %rdi
callq 0x2080
leaq 0x90(%rsp), %rdi
movq %r15, -0x20(%rdi)
callq 0x4b4a
movq %rbx, %rdi
callq 0x4b8c
leaq 0x10(%rsp), %rdi
callq 0x7d28
addq $0x4c8, %rsp            # imm = 0x4C8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x7603(%rip), %rdi      # 0xefd0
leaq 0x2bb6(%rip), %rsi      # 0xa58a
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 0x75cc(%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 0x797a
jmp 0x7a57
jmp 0x7a6b
jmp 0x7a6b
jmp 0x7a6b
movq %rax, %r14
jmp 0x7a85
jmp 0x7a47
movq %rax, %r14
jmp 0x7a8f
movq %rax, %r14
jmp 0x7aa8
jmp 0x7a6b
jmp 0x7a6b
jmp 0x7a57
movq %rax, %r14
leaq 0x2b8(%rsp), %rdi
callq 0x2080
jmp 0x7a6e
jmp 0x7a6b
movq %rax, %r14
leaq 0x40(%rsp), %rdi
callq 0x7cb0
leaq 0xa8(%rsp), %rdi
callq 0x2080
leaq 0x78(%rsp), %rbx
movq 0x8(%rsp), %r12
leaq 0x90(%rsp), %rdi
movq %r12, -0x20(%rdi)
callq 0x4b4a
movq %rbx, %rdi
callq 0x4b8c
leaq 0x10(%rsp), %rdi
callq 0x7d28
movq %r14, %rdi
callq 0x2370