// File: SNUCSE-CTA[P]GI/src/compare.cpp
// Function: compare
int compare(const char *fname1, const char *fname2, bool *isomorphic, double *processedTime, const char *outfname)
{
	double totalTime = 0;

	Timer t;
	Context cont;

	string file1(fname1);
	string file2(fname2);

	//1. read input graph files
	Graph* g1 = new Graph(file1, cont);
	Graph* g2 = new Graph(file2, cont);

	std::shared_ptr<Graph> upg1(g1);
	std::shared_ptr<Graph> upg2(g2);

	//check if input files exist, and they have no errors.
	if (g1->fail() || g2->fail()) {
		return 0;
	}

	//2. GI algorithm
	if(g1->numNode != g2->numNode || g1->numEdge != g2->numEdge) {
		//trivially false
		*isomorphic = false;
	}
	else {
	t.start();
		Algorithm alg(cont);
		*isomorphic = alg.run(g1, g2);
	totalTime = t.end();

		if(*isomorphic && outfname != nullptr) {
			//cout << "Output isomorphism file: " << outfname << endl;
			alg.printIso(fname1, fname2, outfname);
		}
	}

	if (processedTime != nullptr) {
		*processedTime = totalTime;
	}


	return 1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x1e0, %rsp            # imm = 0x1E0
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movq %r8, -0x30(%rbp)
movq $0x0, -0x38(%rbp)
leaq -0x48(%rbp), %rdi
callq 0x9790
leaq -0x90(%rbp), %rdi
callq 0x4980
movq -0x10(%rbp), %rax
movq %rax, -0x1b0(%rbp)
leaq -0xb1(%rbp), %rdi
movq %rdi, -0x1a8(%rbp)
callq 0x3380
movq -0x1b0(%rbp), %rsi
movq -0x1a8(%rbp), %rdx
leaq -0xb0(%rbp), %rdi
callq 0x4140
jmp 0x3ca6
leaq -0xb1(%rbp), %rdi
callq 0x3200
movq -0x18(%rbp), %rax
movq %rax, -0x1c0(%rbp)
leaq -0xe9(%rbp), %rdi
movq %rdi, -0x1b8(%rbp)
callq 0x3380
movq -0x1c0(%rbp), %rsi
movq -0x1b8(%rbp), %rdx
leaq -0xe8(%rbp), %rdi
callq 0x4140
jmp 0x3cec
leaq -0xe9(%rbp), %rdi
callq 0x3200
movl $0x48, %edi
callq 0x31c0
movq %rax, -0x1c8(%rbp)
jmp 0x3d0b
movb $0x1, -0x119(%rbp)
leaq -0x118(%rbp), %rdi
leaq -0xb0(%rbp), %rsi
callq 0x30d0
jmp 0x3d27
movq -0x1c8(%rbp), %rdi
leaq -0x118(%rbp), %rsi
leaq -0x90(%rbp), %rdx
callq 0x4b00
jmp 0x3d43
movb $0x0, -0x119(%rbp)
leaq -0x118(%rbp), %rdi
callq 0x3140
movq -0x1c8(%rbp), %rax
movq %rax, -0xf8(%rbp)
movl $0x48, %edi
callq 0x31c0
movq %rax, -0x1d0(%rbp)
jmp 0x3d77
movb $0x1, -0x149(%rbp)
leaq -0x148(%rbp), %rdi
leaq -0xe8(%rbp), %rsi
callq 0x30d0
jmp 0x3d93
movq -0x1d0(%rbp), %rdi
leaq -0x148(%rbp), %rsi
leaq -0x90(%rbp), %rdx
callq 0x4b00
jmp 0x3daf
movb $0x0, -0x149(%rbp)
leaq -0x148(%rbp), %rdi
callq 0x3140
movq -0x1d0(%rbp), %rax
movq %rax, -0x128(%rbp)
movq -0xf8(%rbp), %rsi
leaq -0x160(%rbp), %rdi
callq 0x41f0
jmp 0x3de5
movq -0x128(%rbp), %rsi
leaq -0x170(%rbp), %rdi
callq 0x41f0
jmp 0x3dfa
movq -0xf8(%rbp), %rdi
callq 0x6740
movb %al, -0x1d1(%rbp)
jmp 0x3e0e
movb -0x1d1(%rbp), %al
testb $0x1, %al
jne 0x3e3d
jmp 0x3e1a
movq -0x128(%rbp), %rdi
callq 0x6740
movb %al, -0x1d2(%rbp)
jmp 0x3e2e
movb -0x1d2(%rbp), %al
testb $0x1, %al
jne 0x3e3d
jmp 0x3f84
movl $0x0, -0x4(%rbp)
movl $0x1, -0x174(%rbp)
jmp 0x40aa
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xc0(%rbp)
movl %eax, -0xc4(%rbp)
leaq -0xb1(%rbp), %rdi
callq 0x3200
jmp 0x4122
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xc0(%rbp)
movl %eax, -0xc4(%rbp)
leaq -0xe9(%rbp), %rdi
callq 0x3200
jmp 0x4116
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xc0(%rbp)
movl %eax, -0xc4(%rbp)
jmp 0x410a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xc0(%rbp)
movl %eax, -0xc4(%rbp)
jmp 0x3ee2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xc0(%rbp)
movl %eax, -0xc4(%rbp)
leaq -0x118(%rbp), %rdi
callq 0x3140
testb $0x1, -0x119(%rbp)
jne 0x3eed
jmp 0x3efe
movq -0x1c8(%rbp), %rdi
movl $0x48, %esi
callq 0x31d0
jmp 0x410a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xc0(%rbp)
movl %eax, -0xc4(%rbp)
jmp 0x3f35
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xc0(%rbp)
movl %eax, -0xc4(%rbp)
leaq -0x148(%rbp), %rdi
callq 0x3140
testb $0x1, -0x149(%rbp)
jne 0x3f40
jmp 0x3f51
movq -0x1d0(%rbp), %rdi
movl $0x48, %esi
callq 0x31d0
jmp 0x410a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xc0(%rbp)
movl %eax, -0xc4(%rbp)
jmp 0x40fe
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xc0(%rbp)
movl %eax, -0xc4(%rbp)
jmp 0x40f2
movq -0xf8(%rbp), %rax
movl 0xc(%rax), %eax
movq -0x128(%rbp), %rcx
cmpl 0xc(%rcx), %eax
jne 0x3fb0
movq -0xf8(%rbp), %rax
movl 0x10(%rax), %eax
movq -0x128(%rbp), %rcx
cmpl 0x10(%rcx), %eax
je 0x3fbc
movq -0x20(%rbp), %rax
movb $0x0, (%rax)
jmp 0x4085
leaq -0x48(%rbp), %rdi
callq 0x97c0
jmp 0x3fc7
leaq -0x1a0(%rbp), %rdi
leaq -0x90(%rbp), %rsi
callq 0x9a70
jmp 0x3fdc
movq -0xf8(%rbp), %rsi
movq -0x128(%rbp), %rdx
leaq -0x1a0(%rbp), %rdi
callq 0x9b70
movb %al, -0x1d3(%rbp)
jmp 0x3ffe
movb -0x1d3(%rbp), %cl
movq -0x20(%rbp), %rax
andb $0x1, %cl
movb %cl, (%rax)
leaq -0x48(%rbp), %rdi
callq 0x9800
movsd %xmm0, -0x1e0(%rbp)
jmp 0x4020
movsd -0x1e0(%rbp), %xmm0
movsd %xmm0, -0x38(%rbp)
movq -0x20(%rbp), %rax
testb $0x1, (%rax)
je 0x4079
cmpq $0x0, -0x30(%rbp)
je 0x4079
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %rdx
movq -0x30(%rbp), %rcx
leaq -0x1a0(%rbp), %rdi
callq 0xa290
jmp 0x4057
jmp 0x4079
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xc0(%rbp)
movl %eax, -0xc4(%rbp)
leaq -0x1a0(%rbp), %rdi
callq 0x9ab0
jmp 0x40f2
leaq -0x1a0(%rbp), %rdi
callq 0x9ab0
cmpq $0x0, -0x28(%rbp)
je 0x4099
movsd -0x38(%rbp), %xmm0
movq -0x28(%rbp), %rax
movsd %xmm0, (%rax)
movl $0x1, -0x4(%rbp)
movl $0x1, -0x174(%rbp)
leaq -0x170(%rbp), %rdi
callq 0x4220
leaq -0x160(%rbp), %rdi
callq 0x4220
leaq -0xe8(%rbp), %rdi
callq 0x3140
leaq -0xb0(%rbp), %rdi
callq 0x3140
leaq -0x90(%rbp), %rdi
callq 0x4240
movl -0x4(%rbp), %eax
addq $0x1e0, %rsp            # imm = 0x1E0
popq %rbp
retq
leaq -0x170(%rbp), %rdi
callq 0x4220
leaq -0x160(%rbp), %rdi
callq 0x4220
leaq -0xe8(%rbp), %rdi
callq 0x3140
leaq -0xb0(%rbp), %rdi
callq 0x3140
leaq -0x90(%rbp), %rdi
callq 0x4240
movq -0xc0(%rbp), %rdi
callq 0x3370
nopw (%rax,%rax)