// File: 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
movq %rsp, %rbp
subq $0x610, %rsp            # imm = 0x610
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
leaq -0x48(%rbp), %rdi
movq %rdi, -0x568(%rbp)
callq 0x14b60
movq -0x568(%rbp), %rsi
movq -0x18(%rbp), %rdi
callq 0x14aa0
jmp 0x143a9
leaq -0x90(%rbp), %rdi
movq %rdi, -0x570(%rbp)
callq 0x64e0
movq -0x570(%rbp), %rsi
movq -0x8(%rbp), %rdi
movl $0x1, %edx
callq 0x17370
jmp 0x143d3
leaq -0x90(%rbp), %rdi
callq 0x17930
movq %rax, -0x578(%rbp)
jmp 0x143e8
movq -0x578(%rbp), %rax
movq %rax, -0x98(%rbp)
movq -0x10(%rbp), %rsi
leaq -0x2a8(%rbp), %rdi
movl $0x10, %edx
callq 0x3380
jmp 0x1440d
leaq -0x2d8(%rbp), %rdi
callq 0x14b80
movq 0x81a0(%rip), %rax      # 0x1c5c0
movq %rax, -0x2f0(%rbp)
movq 0x819a(%rip), %rax      # 0x1c5c8
movq %rax, -0x2e8(%rbp)
movl $0x0, -0x2f4(%rbp)
movslq -0x2f4(%rbp), %rax
movq %rax, -0x580(%rbp)
movq -0x98(%rbp), %rdi
callq 0x65e0
movq %rax, %rcx
movq -0x580(%rbp), %rax
cmpq %rcx, %rax
jae 0x14823
movq -0x98(%rbp), %rdi
movslq -0x2f4(%rbp), %rsi
callq 0x6610
movq %rax, %rdi
movl $0x7, %esi
callq 0x13710
movq %rax, %rsi
leaq -0x2d8(%rbp), %rdi
callq 0x14bd0
movq %rax, -0x588(%rbp)
jmp 0x144a4
movq -0x588(%rbp), %rax
movq %rax, -0x300(%rbp)
leaq -0x2d8(%rbp), %rdi
callq 0x14c10
movq %rax, -0x308(%rbp)
leaq -0x300(%rbp), %rdi
leaq -0x308(%rbp), %rsi
callq 0x14ba0
testb $0x1, %al
jne 0x144de
jmp 0x14516
jmp 0x1480f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x14a21
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x14a15
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x149fd
movq -0x98(%rbp), %rdi
movslq -0x2f4(%rbp), %rsi
callq 0x6610
movq %rax, %rdi
movl $0x7, %esi
callq 0x13710
movq %rax, %rsi
leaq -0x2d8(%rbp), %rdi
callq 0x14c40
movb %dl, -0x591(%rbp)
movq %rax, -0x590(%rbp)
jmp 0x14554
movb -0x591(%rbp), %al
movq -0x590(%rbp), %rcx
movq %rcx, -0x318(%rbp)
movb %al, -0x310(%rbp)
movq -0x98(%rbp), %rdi
movslq -0x2f4(%rbp), %rsi
callq 0x6610
movq %rax, %rdi
movl $0x7, %esi
callq 0x13710
movq %rax, %rsi
leaq -0x48(%rbp), %rdi
callq 0x14cc0
movq %rax, -0x5a0(%rbp)
jmp 0x145a3
movq -0x5a0(%rbp), %rax
movq %rax, -0x320(%rbp)
leaq -0x48(%rbp), %rdi
callq 0x14cf0
movq %rax, -0x328(%rbp)
leaq -0x320(%rbp), %rdi
leaq -0x328(%rbp), %rsi
callq 0x14c90
testb $0x1, %al
jne 0x145da
jmp 0x14652
movq 0x159ef(%rip), %rdi     # 0x29fd0
leaq 0x7fb5(%rip), %rsi      # 0x1c59d
callq 0x3270
movq %rax, -0x5a8(%rbp)
jmp 0x145f6
movq -0x98(%rbp), %rdi
movslq -0x2f4(%rbp), %rsi
callq 0x6610
movq %rax, %rdi
movl $0x7, %esi
callq 0x13710
movq -0x5a8(%rbp), %rdi
movq %rax, %rsi
callq 0x3240
movq %rax, -0x5b0(%rbp)
jmp 0x1462e
movq -0x5b0(%rbp), %rdi
movq 0x1597c(%rip), %rsi     # 0x29fb8
callq 0x32b0
jmp 0x14643
movl $0x1, -0x32c(%rbp)
jmp 0x149c7
movq -0x98(%rbp), %rdi
movslq -0x2f4(%rbp), %rsi
callq 0x6610
movq %rax, %rdi
movl $0x9, %esi
callq 0x13710
movq %rax, %rdi
callq 0x14a40
jmp 0x1467c
leaq -0x298(%rbp), %rax
movq %rax, -0x5c0(%rbp)
movq -0x98(%rbp), %rdi
movslq -0x2f4(%rbp), %rsi
callq 0x6610
movq %rax, %rdi
movl $0x7, %esi
callq 0x13710
movq %rax, %rsi
leaq -0x48(%rbp), %rdi
callq 0x14d20
movq %rax, -0x5b8(%rbp)
jmp 0x146bf
movq -0x5b8(%rbp), %rsi
movq -0x5c0(%rbp), %rdi
callq 0x3240
jmp 0x146d4
movl $0x7, -0x330(%rbp)
movslq -0x330(%rbp), %rax
movq %rax, -0x5c8(%rbp)
movq -0x98(%rbp), %rdi
movslq -0x2f4(%rbp), %rsi
callq 0x6610
movq %rax, %rdi
callq 0x13680
movq %rax, %rcx
movq -0x5c8(%rbp), %rax
cmpq %rcx, %rax
jae 0x147f8
movl -0x330(%rbp), %eax
subl $0x7, %eax
cltq
testb $0x1, -0x2f0(%rbp,%rax)
jne 0x1477e
leaq -0x298(%rbp), %rdi
movl $0x2c, %esi
callq 0x3320
movq %rax, -0x5d0(%rbp)
jmp 0x14749
movq -0x98(%rbp), %rdi
movslq -0x2f4(%rbp), %rsi
callq 0x6610
movq %rax, %rdi
movslq -0x330(%rbp), %rsi
callq 0x13710
movq -0x5d0(%rbp), %rdi
movq %rax, %rsi
callq 0x3240
jmp 0x1477c
jmp 0x147e2
leaq -0x298(%rbp), %rdi
movl $0x2c, %esi
callq 0x3320
movq %rax, -0x5d8(%rbp)
jmp 0x14798
movq -0x98(%rbp), %rdi
movslq -0x2f4(%rbp), %rsi
callq 0x6610
movq %rax, %rdi
movslq -0x330(%rbp), %rsi
callq 0x13710
movq %rax, %rdi
callq 0x5530
movl %eax, -0x5dc(%rbp)
jmp 0x147ca
movq -0x5d8(%rbp), %rdi
movl -0x5dc(%rbp), %esi
decl %esi
callq 0x3430
jmp 0x147e0
jmp 0x147e2
jmp 0x147e4
movl -0x330(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x330(%rbp)
jmp 0x146de
leaq -0x298(%rbp), %rdi
movq 0x157b2(%rip), %rsi     # 0x29fb8
callq 0x32b0
jmp 0x1480d
jmp 0x1480f
movl -0x2f4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2f4(%rbp)
jmp 0x1443f
leaq -0x2a8(%rbp), %rdi
callq 0x3060
jmp 0x14831
leaq 0x15a40(%rip), %rax     # 0x2a278
movq (%rax), %rsi
leaq -0x540(%rbp), %rdi
movl $0x10, %edx
callq 0x3380
jmp 0x1484e
leaq -0x48(%rbp), %rdi
callq 0x14e00
movq %rax, -0x548(%rbp)
leaq -0x48(%rbp), %rdi
callq 0x14cf0
movq %rax, -0x550(%rbp)
leaq -0x548(%rbp), %rdi
leaq -0x550(%rbp), %rsi
callq 0x14e30
testb $0x1, %al
jne 0x1488a
jmp 0x149a3
leaq -0x548(%rbp), %rdi
callq 0x14e90
movq %rax, %rsi
leaq -0x2d8(%rbp), %rdi
callq 0x14bd0
movq %rax, -0x5e8(%rbp)
jmp 0x148ae
movq -0x5e8(%rbp), %rax
movq %rax, -0x558(%rbp)
leaq -0x2d8(%rbp), %rdi
callq 0x14c10
movq %rax, -0x560(%rbp)
leaq -0x558(%rbp), %rdi
leaq -0x560(%rbp), %rsi
callq 0x14e60
testb $0x1, %al
jne 0x148eb
jmp 0x14992
leaq -0x530(%rbp), %rax
movq %rax, -0x5f8(%rbp)
leaq -0x548(%rbp), %rdi
callq 0x14e90
movq -0x5f8(%rbp), %rdi
movq %rax, %rsi
addq $0x20, %rsi
callq 0x3240
movq %rax, -0x5f0(%rbp)
jmp 0x14921
movq -0x5f0(%rbp), %rdi
leaq 0x7c85(%rip), %rsi      # 0x1c5b4
callq 0x3270
movq %rax, -0x600(%rbp)
jmp 0x1493d
leaq -0x548(%rbp), %rdi
callq 0x14e90
movq -0x600(%rbp), %rdi
movq %rax, %rsi
callq 0x3240
movq %rax, -0x608(%rbp)
jmp 0x14961
movq -0x608(%rbp), %rdi
movq 0x15649(%rip), %rsi     # 0x29fb8
callq 0x32b0
jmp 0x14976
jmp 0x14992
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x540(%rbp), %rdi
callq 0x3090
jmp 0x149fd
leaq -0x548(%rbp), %rdi
callq 0x14eb0
jmp 0x1485e
leaq -0x540(%rbp), %rdi
callq 0x3060
jmp 0x149b1
leaq -0x540(%rbp), %rdi
callq 0x3090
movl $0x0, -0x32c(%rbp)
leaq -0x2d8(%rbp), %rdi
callq 0x14ee0
leaq -0x2a8(%rbp), %rdi
callq 0x3090
leaq -0x90(%rbp), %rdi
callq 0x6770
leaq -0x48(%rbp), %rdi
callq 0x14f00
addq $0x610, %rsp            # imm = 0x610
popq %rbp
retq
leaq -0x2d8(%rbp), %rdi
callq 0x14ee0
leaq -0x2a8(%rbp), %rdi
callq 0x3090
leaq -0x90(%rbp), %rdi
callq 0x6770
leaq -0x48(%rbp), %rdi
callq 0x14f00
movq -0x50(%rbp), %rdi
callq 0x3440
nopw %cs:(%rax,%rax)