// File: codeniko[P]mossel_tov/mossel_tov.cpp
// Function: genPage(std::vector<Match, std::allocator<Match>>, std::vector<std::vector<Student, std::allocator<Student>>, std::allocator<std::vector<Student, std::allocator<Student>>>>)
void genPage(vector<Match> matches, vector< vector<Student> > groups) {
	ofstream page;
	page.open(PAGERESULTS);
	if (!page.is_open()) {
		cerr << "Unable to write to " << PAGERESULTS << endl;
		exit(2);
	}

	page << "<html><head><title>Mossel Tov! - an grouping extension to the moss plagiarism detector</title><link rel=\"stylesheet\" type=\"text/css\" href=\"mossel_tov.css\"></head><body><table><tr><th></th><th> Matches with other Students <i>(# lines identical)</i></th></tr>";

	int i = 1;
	for (vector< vector<Student> >::iterator group_it = groups.begin(); group_it != groups.end(); group_it++, i++) {
		page << "<tr> <td colspan=\"2\" id=\"group_header\">Group " << i << "</td></tr>";
		for (vector<Student>::iterator stud_it = group_it->begin(); stud_it != group_it->end(); stud_it++) {
			vector<Match> studentMatches = getStudentMatches(matches, *stud_it);
			page << "<tr><td>" << stud_it->student << "</td><td>";
			for (vector<Match>::iterator match_it = studentMatches.begin(); match_it != studentMatches.end(); match_it++) {
				page << "<a href=\"http://moss.stanford.edu/results/" << match_it->url << "\">(" << match_it->hasStudent(*stud_it) << "," << match_it->numIdentical << ")</a> ";
			}
			page << "</td></tr>";
		}
	}
	page << "</table></body></html>";

	page.close();
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x340, %rsp            # imm = 0x340
movq %rdi, -0x2d0(%rbp)
movq %rsi, -0x2c8(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
leaq -0x210(%rbp), %rdi
movq %rdi, -0x2c0(%rbp)
callq 0x2380
movq -0x2c0(%rbp), %rdi
leaq 0x88f2(%rip), %rsi      # 0xb014
movl $0x10, %edx
callq 0x2050
jmp 0x272e
leaq -0x210(%rbp), %rdi
callq 0x21a0
movb %al, -0x2d1(%rbp)
jmp 0x2742
movb -0x2d1(%rbp), %al
testb $0x1, %al
jne 0x27bc
jmp 0x274e
movq 0xe89b(%rip), %rdi      # 0x10ff0
leaq 0x88c8(%rip), %rsi      # 0xb024
callq 0x2210
movq %rax, -0x2e0(%rbp)
jmp 0x276a
movq -0x2e0(%rbp), %rdi
leaq 0x889c(%rip), %rsi      # 0xb014
callq 0x2210
movq %rax, -0x2e8(%rbp)
jmp 0x2786
movq -0x2e8(%rbp), %rdi
movq 0xe834(%rip), %rsi      # 0x10fc8
callq 0x2240
jmp 0x279b
movl $0x2, %edi
callq 0x22a0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x218(%rbp)
movl %eax, -0x21c(%rbp)
jmp 0x2bcf
leaq 0x8875(%rip), %rsi      # 0xb038
leaq -0x210(%rbp), %rdi
callq 0x2210
jmp 0x27d1
movq -0x2c8(%rbp), %rdi
movl $0x1, -0x220(%rbp)
callq 0x39d0
movq %rax, -0x228(%rbp)
movq -0x2c8(%rbp), %rdi
callq 0x3a40
movq %rax, -0x230(%rbp)
leaq -0x228(%rbp), %rdi
leaq -0x230(%rbp), %rsi
callq 0x3a00
testb $0x1, %al
jne 0x281d
jmp 0x2b97
leaq 0x8916(%rip), %rsi      # 0xb13a
leaq -0x210(%rbp), %rdi
callq 0x2210
movq %rax, -0x2f0(%rbp)
jmp 0x2839
movq -0x2f0(%rbp), %rdi
movl -0x220(%rbp), %esi
callq 0x2390
movq %rax, -0x2f8(%rbp)
jmp 0x2854
movq -0x2f8(%rbp), %rdi
leaq 0x8906(%rip), %rsi      # 0xb168
callq 0x2210
jmp 0x2869
leaq -0x228(%rbp), %rdi
callq 0x3a70
movq %rax, %rdi
callq 0x3a90
movq %rax, -0x238(%rbp)
leaq -0x228(%rbp), %rdi
callq 0x3a70
movq %rax, %rdi
callq 0x3b00
movq %rax, -0x240(%rbp)
leaq -0x238(%rbp), %rdi
leaq -0x240(%rbp), %rsi
callq 0x3ac0
testb $0x1, %al
jne 0x28bb
jmp 0x2b6c
movq -0x2d0(%rbp), %rsi
leaq -0x270(%rbp), %rdi
callq 0x3b30
jmp 0x28d0
leaq -0x238(%rbp), %rdi
callq 0x3c20
movq %rax, %rdx
leaq -0x258(%rbp), %rdi
leaq -0x270(%rbp), %rsi
callq 0x2560
jmp 0x28f4
leaq -0x270(%rbp), %rdi
callq 0x3970
leaq 0x886c(%rip), %rsi      # 0xb173
leaq -0x210(%rbp), %rdi
callq 0x2210
movq %rax, -0x300(%rbp)
jmp 0x291c
leaq -0x238(%rbp), %rdi
callq 0x3c40
movq -0x300(%rbp), %rdi
movq %rax, %rsi
callq 0x2200
movq %rax, -0x308(%rbp)
jmp 0x2940
movq -0x308(%rbp), %rdi
leaq 0x882e(%rip), %rsi      # 0xb17c
callq 0x2210
jmp 0x2955
leaq -0x258(%rbp), %rdi
callq 0x3690
movq %rax, -0x278(%rbp)
leaq -0x258(%rbp), %rdi
callq 0x3700
movq %rax, -0x280(%rbp)
leaq -0x278(%rbp), %rdi
leaq -0x280(%rbp), %rsi
callq 0x36c0
testb $0x1, %al
jne 0x2997
jmp 0x2b23
leaq 0x87e8(%rip), %rsi      # 0xb186
leaq -0x210(%rbp), %rdi
callq 0x2210
movq %rax, -0x310(%rbp)
jmp 0x29b3
leaq -0x278(%rbp), %rdi
callq 0x3760
movq -0x310(%rbp), %rdi
movq %rax, %rsi
addq $0x40, %rsi
callq 0x2200
movq %rax, -0x318(%rbp)
jmp 0x29db
movq -0x318(%rbp), %rdi
leaq 0x87c8(%rip), %rsi      # 0xb1b1
callq 0x2210
movq %rax, -0x320(%rbp)
jmp 0x29f7
leaq -0x278(%rbp), %rdi
callq 0x3760
movq %rax, -0x328(%rbp)
leaq -0x238(%rbp), %rdi
callq 0x3c20
movq -0x328(%rbp), %rsi
movq %rax, %rdx
leaq -0x2a0(%rbp), %rdi
callq 0x3780
jmp 0x2a2e
movq -0x320(%rbp), %rdi
leaq -0x2a0(%rbp), %rsi
callq 0x2200
movq %rax, -0x330(%rbp)
jmp 0x2a4a
movq -0x330(%rbp), %rdi
leaq 0x875d(%rip), %rsi      # 0xb1b5
callq 0x2210
movq %rax, -0x338(%rbp)
jmp 0x2a66
leaq -0x278(%rbp), %rdi
callq 0x3760
movq -0x338(%rbp), %rdi
movq %rax, %rsi
addq $0xa0, %rsi
callq 0x2200
movq %rax, -0x340(%rbp)
jmp 0x2a91
movq -0x340(%rbp), %rdi
leaq 0x8718(%rip), %rsi      # 0xb1b7
callq 0x2210
jmp 0x2aa6
leaq -0x2a0(%rbp), %rdi
callq 0x2150
leaq -0x278(%rbp), %rdi
xorl %esi, %esi
callq 0x38e0
movq %rax, -0x2a8(%rbp)
jmp 0x2968
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x218(%rbp)
movl %eax, -0x21c(%rbp)
leaq -0x270(%rbp), %rdi
callq 0x3970
jmp 0x2bcf
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x218(%rbp)
movl %eax, -0x21c(%rbp)
jmp 0x2b5e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x218(%rbp)
movl %eax, -0x21c(%rbp)
leaq -0x2a0(%rbp), %rdi
callq 0x2150
jmp 0x2b5e
leaq 0x863e(%rip), %rsi      # 0xb168
leaq -0x210(%rbp), %rdi
callq 0x2210
jmp 0x2b38
leaq -0x258(%rbp), %rdi
callq 0x3970
leaq -0x238(%rbp), %rdi
xorl %esi, %esi
callq 0x3c60
movq %rax, -0x2b0(%rbp)
jmp 0x2884
leaq -0x258(%rbp), %rdi
callq 0x3970
jmp 0x2bcf
jmp 0x2b6e
leaq -0x228(%rbp), %rdi
xorl %esi, %esi
callq 0x3ca0
movq %rax, -0x2b8(%rbp)
movl -0x220(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x220(%rbp)
jmp 0x27ee
leaq 0x8620(%rip), %rsi      # 0xb1be
leaq -0x210(%rbp), %rdi
callq 0x2210
jmp 0x2bac
leaq -0x210(%rbp), %rdi
callq 0x2300
jmp 0x2bba
leaq -0x210(%rbp), %rdi
callq 0x2320
addq $0x340, %rsp            # imm = 0x340
popq %rbp
retq
leaq -0x210(%rbp), %rdi
callq 0x2320
movq -0x218(%rbp), %rdi
callq 0x23a0
nopw (%rax,%rax)