// File: /workspace/github_cpp_makefile_star2_O3/rtackx[P]ComSim/main.cpp
// Function: main
int main(int argc, const char* argv[])
{
	string path_dataset, similarity_index;
	int distance, depth_best;
	static set<string> list_valid_similarities = {"cn", "ji", "aa", "ra", "lhn", "pan"};

	if(argc < 3)
	{
		usage();
		return 0;
	}
	else
	{
		path_dataset = argv[1];
		distance = atoi(argv[2]);
		similarity_index = "cn";
		depth_best = 1;

		if(argc > 3)
		{
			similarity_index = argv[3];

			if(list_valid_similarities.find(similarity_index) == list_valid_similarities.end())
			{
				usage();
				cerr << endl << "\"" << similarity_index << "\" is not a valid similarity index" << endl;
				return 0;
			}

			if(argc > 4)
			{
				if(argc == 5)
					depth_best = atoi(argv[4]);
				else
				{
					usage();
					return 0;
				}
			}
		}
	}

	high_resolution_clock::time_point t1, t2;
	t1 = high_resolution_clock::now();

	Graph* main_graph = new Graph();
	cerr << "Loading graph..." << endl;
	main_graph->load_graph(path_dataset);
	cerr << "   n = " << main_graph->n << endl << "   m = " << main_graph->m/2 << endl;

	srand(unsigned(time(NULL)));

	Community* c = new Community(main_graph, depth_best);
	Projection* p;
	Graph* g;
	unsigned int nb_remaining_nodes = 0;

	g = main_graph;

	p = select_similarity(similarity_index, g);
	cerr << endl << "Projecting graph (distance : " << distance << ") ..." << endl;
	p->project(distance);

	if(p->graph_projection->n > 0)
	{
		cerr << "Detecting communities..." << endl;
		nb_remaining_nodes = c->detect(p->graph_projection);

		//g = main_graph->get_subgraph(list_ending_nodes);
	}
	cerr << "Number of remaining nodes : " << nb_remaining_nodes << endl;

	cerr << endl << "--------------" << endl;
	unsigned int i;
	for(auto& e : c->community)
	{
		for(i=0; i<e.second.size()-1; i++)
			cout << e.second[i]->id << " ";
		cout << e.second[e.second.size()-1]->id << endl;
	}
	cerr << "--------------" << endl;

	delete p;
	delete g;
	//delete main_graph;
	delete c;

	t2 = high_resolution_clock::now();
	cerr << "Time : ";
	display_ms(t1, t2);

	return 1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x158, %rsp            # imm = 0x158
movq %rsi, %rbx
movl %edi, %r14d
leaq 0x48(%rsp), %rcx
movq %rcx, -0x10(%rcx)
xorl %eax, %eax
movq %rax, -0x8(%rcx)
movb %al, (%rcx)
leaq 0x20(%rsp), %rcx
movq %rcx, -0x10(%rcx)
movq %rax, -0x8(%rcx)
movb %al, (%rcx)
movb 0xc312(%rip), %al       # 0xf268
testb %al, %al
je 0x3622
cmpl $0x3, %r14d
jge 0x2f70
callq 0x278e
xorl %ebx, %ebx
jmp 0x3546
movq 0x8(%rbx), %r15
leaq 0x38(%rsp), %r12
movq 0x8(%r12), %r13
movq %r15, %rdi
callq 0x20f0
movq %r12, %rdi
xorl %esi, %esi
movq %r13, %rdx
movq %r15, %rcx
movq %rax, %r8
callq 0x2360
movq 0x10(%rbx), %rdi
callq 0x2370
movl %eax, %ebp
leaq 0x10(%rsp), %rdi
movq 0x8(%rdi), %rdx
leaq 0x7816(%rip), %rcx      # 0xa7ca
movl $0x2, %r8d
xorl %esi, %esi
callq 0x2360
movl $0x1, %r15d
cmpl $0x3, %r14d
je 0x303a
movq 0x18(%rbx), %r12
leaq 0x10(%rsp), %r13
movl %ebp, %r15d
movq 0x8(%r13), %rbp
movq %r12, %rdi
callq 0x20f0
movq %r13, %rdi
xorl %esi, %esi
movq %rbp, %rdx
movl %r15d, %ebp
movq %r12, %rcx
movq %rax, %r8
callq 0x2360
leaq 0xc236(%rip), %rdi      # 0xf238
leaq 0x10(%rsp), %rsi
callq 0x3d4e
leaq 0xc22d(%rip), %rcx      # 0xf240
cmpq %rcx, %rax
movl $0x1, %r15d
je 0x3582
cmpl $0x5, %r14d
jb 0x303a
jne 0x2f64
movq 0x20(%rbx), %rdi
callq 0x2370
movl %eax, %r15d
callq 0x2070
movq %rax, 0x30(%rsp)
movl $0x10, %edi
callq 0x2250
movq %rax, %r14
movq %rax, %rdi
callq 0x3dd8
movq %r14, 0x98(%rsp)
movq 0xbf88(%rip), %r14      # 0xeff0
leaq 0x7793(%rip), %rsi      # 0xa802
movl $0x10, %edx
movq %r14, %rdi
callq 0x2280
movq (%r14), %rax
addq -0x18(%rax), %r14
movq %r14, %rdi
movl $0xa, %esi
callq 0x2240
movsbl %al, %esi
movq 0xbf56(%rip), %rdi      # 0xeff0
callq 0x2040
movq %rax, %rdi
callq 0x2170
movq 0x98(%rsp), %r14
leaq 0x88(%rsp), %rbx
movq %rbx, -0x10(%rbx)
movq 0x38(%rsp), %rsi
movq 0x40(%rsp), %rdx
addq %rsi, %rdx
leaq 0x78(%rsp), %rdi
callq 0x3978
leaq 0x78(%rsp), %rsi
movq %r14, %rdi
callq 0x3e30
movq 0x78(%rsp), %rdi
cmpq %rbx, %rdi
je 0x30ee
callq 0x2220
movq 0xbefb(%rip), %rdi      # 0xeff0
leaq 0x7717(%rip), %rsi      # 0xa813
movl $0x7, %edx
callq 0x2280
movq 0x98(%rsp), %rax
movl (%rax), %esi
movq 0xbed9(%rip), %r12      # 0xeff0
movq %r12, %rdi
callq 0x2160
movq %rax, %r14
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x2240
movsbl %al, %esi
movq %r14, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2170
movq %rax, %r14
leaq 0x76c8(%rip), %rsi      # 0xa81b
movl $0x7, %edx
movq %rax, %rdi
callq 0x2280
movq 0x98(%rsp), %rax
movl 0x4(%rax), %esi
shrl %esi
movq %r14, %rdi
callq 0x2160
movq %rax, %r14
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x2240
movsbl %al, %esi
movq %r14, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2170
xorl %edi, %edi
callq 0x2210
movl %eax, %edi
callq 0x2230
movl $0x80, %edi
callq 0x2250
movq %rax, %rbx
leaq 0x98(%rsp), %rsi
movq %rax, %rdi
movl %r15d, %edx
callq 0x7340
movq 0x98(%rsp), %rax
movq %rax, 0x8(%rsp)
leaq 0x68(%rsp), %r14
movq %r14, -0x10(%r14)
movq 0x10(%rsp), %rsi
movq 0x18(%rsp), %rdx
addq %rsi, %rdx
leaq 0x58(%rsp), %rdi
callq 0x3978
leaq 0x58(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0x2dbf
movq %rax, %r15
movq 0x58(%rsp), %rdi
cmpq %r14, %rdi
je 0x321b
callq 0x2220
movq (%r12), %rax
addq -0x18(%rax), %r12
movq %r12, %rdi
movl $0xa, %esi
callq 0x2240
movsbl %al, %esi
movq 0xbdb6(%rip), %rdi      # 0xeff0
callq 0x2040
movq %rax, %rdi
callq 0x2170
movq %rax, %r12
leaq 0x75d2(%rip), %rsi      # 0xa823
movl $0x1d, %edx
movq %rax, %rdi
callq 0x2280
movq %r12, %rdi
movl %ebp, %esi
callq 0x23c0
movq %rax, %r12
leaq 0x75cf(%rip), %rsi      # 0xa841
movl $0x5, %edx
movq %rax, %rdi
callq 0x2280
movq (%r12), %rax
movq -0x18(%rax), %rdi
addq %r12, %rdi
movl $0xa, %esi
callq 0x2240
movsbl %al, %esi
movq %r12, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2170
movq %r15, %rdi
movl %ebp, %esi
callq 0x5970
movq 0x18(%r15), %rax
cmpl $0x0, (%rax)
je 0x3314
movq 0xbd2f(%rip), %r12      # 0xeff0
leaq 0x757f(%rip), %rsi      # 0xa847
movl $0x18, %edx
movq %r12, %rdi
callq 0x2280
movq (%r12), %rax
addq -0x18(%rax), %r12
movq %r12, %rdi
movl $0xa, %esi
callq 0x2240
movsbl %al, %esi
movq 0xbcfc(%rip), %rdi      # 0xeff0
callq 0x2040
movq %rax, %rdi
callq 0x2170
movq %r15, %rsi
addq $0x18, %rsi
movq %rbx, %rdi
callq 0x73a6
movl %eax, %ebp
jmp 0x3316
xorl %ebp, %ebp
movq 0xbcd3(%rip), %rdi      # 0xeff0
leaq 0x753c(%rip), %rsi      # 0xa860
movl $0x1c, %edx
callq 0x2280
movl %ebp, %esi
movq 0xbcb9(%rip), %r12      # 0xeff0
movq %r12, %rdi
callq 0x2160
movq %rax, %r13
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r13, %rdi
movl $0xa, %esi
callq 0x2240
movsbl %al, %esi
movq %r13, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2170
movq (%r12), %rax
addq -0x18(%rax), %r12
movq %r12, %rdi
movl $0xa, %esi
callq 0x2240
movsbl %al, %esi
movq 0xbc68(%rip), %rdi      # 0xeff0
callq 0x2040
movq %rax, %rdi
callq 0x2170
movq %rax, %r12
leaq 0x74de(%rip), %rsi      # 0xa87d
movl $0xe, %edx
movq %rax, %rdi
callq 0x2280
movq (%r12), %rax
movq -0x18(%rax), %rdi
addq %r12, %rdi
movl $0xa, %esi
callq 0x2240
movsbl %al, %esi
movq %r12, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2170
movq %rbx, %r14
addq $0x58, %r14
movq 0xbbee(%rip), %r12      # 0xefd0
leaq 0x7456(%rip), %r13      # 0xa83f
movq (%r14), %r14
testq %r14, %r14
je 0x3493
movq 0x10(%r14), %rax
movq 0x18(%r14), %rcx
subq %rax, %rcx
cmpq $0x8, %rcx
jne 0x340a
xorl %edx, %edx
jmp 0x3450
movl $0x1, %ebp
xorl %ecx, %ecx
movq (%rax,%rcx,8), %rax
movq 0x8(%rax), %rsi
movq 0x10(%rax), %rdx
movq %r12, %rdi
callq 0x2280
movl $0x1, %edx
movq %rax, %rdi
movq %r13, %rsi
callq 0x2280
movl %ebp, %ecx
movq 0x10(%r14), %rax
movq 0x18(%r14), %rdx
subq %rax, %rdx
sarq $0x3, %rdx
decq %rdx
incl %ebp
cmpq %rcx, %rdx
ja 0x3411
movq (%rax,%rdx,8), %rax
movq 0x8(%rax), %rsi
movq 0x10(%rax), %rdx
movq %r12, %rdi
callq 0x2280
movq %rax, %rbp
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbp, %rdi
movl $0xa, %esi
callq 0x2240
movsbl %al, %esi
movq %rbp, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2170
jmp 0x33e9
movq 0xbb56(%rip), %r12      # 0xeff0
leaq 0x73dc(%rip), %rsi      # 0xa87d
movl $0xe, %edx
movq %r12, %rdi
callq 0x2280
movq (%r12), %rax
addq -0x18(%rax), %r12
movq %r12, %rdi
movl $0xa, %esi
callq 0x2240
movsbl %al, %esi
movq 0xbb23(%rip), %rdi      # 0xeff0
callq 0x2040
movq %rax, %rdi
callq 0x2170
movq %r15, %rdi
callq 0x53ae
movq %r15, %rdi
callq 0x2220
movq 0x8(%rsp), %r15
testq %r15, %r15
je 0x34fc
movq %r15, %rdi
callq 0x3de0
movq %r15, %rdi
callq 0x2220
movq %rbx, %rdi
callq 0x738c
movq %rbx, %rdi
callq 0x2220
callq 0x2070
movq %rax, %r14
movq 0xbacd(%rip), %rdi      # 0xeff0
leaq 0x7362(%rip), %rsi      # 0xa88c
movl $0x7, %edx
callq 0x2280
movq 0x30(%rsp), %rdi
movq %r14, %rsi
callq 0x2728
movl $0x1, %ebx
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
je 0x355a
callq 0x2220
movq 0x38(%rsp), %rdi
leaq 0x48(%rsp), %rax
cmpq %rax, %rdi
je 0x356e
callq 0x2220
movl %ebx, %eax
addq $0x158, %rsp            # imm = 0x158
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x278e
movq 0xba62(%rip), %rdi      # 0xeff0
movq (%rdi), %rax
addq -0x18(%rax), %rdi
movl $0xa, %esi
callq 0x2240
movsbl %al, %esi
movq 0xba47(%rip), %rdi      # 0xeff0
callq 0x2040
movq %rax, %rdi
callq 0x2170
movq %rax, %rbx
leaq 0x721e(%rip), %rsi      # 0xa7de
movl $0x1, %edx
movq %rax, %rdi
callq 0x2280
movq 0x10(%rsp), %rsi
movq 0x18(%rsp), %rdx
movq %rbx, %rdi
callq 0x2280
movq %rax, %rbx
leaq 0x71f7(%rip), %rsi      # 0xa7e0
movl $0x21, %edx
movq %rax, %rdi
callq 0x2280
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x2240
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2170
jmp 0x2f69
leaq 0xbc3f(%rip), %rdi      # 0xf268
callq 0x2400
testl %eax, %eax
je 0x2f5e
leaq 0xa8(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x7181(%rip), %rsi      # 0xa7ca
leaq 0x717c(%rip), %rdx      # 0xa7cc
leaq 0x98(%rsp), %r15
movq %r15, %rdi
callq 0x3a0e
leaq 0xb8(%rsp), %r12
leaq 0xc8(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x7152(%rip), %rsi      # 0xa7cd
leaq 0x714d(%rip), %rdx      # 0xa7cf
movq %r12, %rdi
callq 0x3a0e
leaq 0xd8(%rsp), %r12
leaq 0xe8(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x712b(%rip), %rsi      # 0xa7d0
leaq 0x7126(%rip), %rdx      # 0xa7d2
movq %r12, %rdi
callq 0x3a0e
leaq 0xf8(%rsp), %r12
leaq 0x108(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x7104(%rip), %rsi      # 0xa7d3
leaq 0x70ff(%rip), %rdx      # 0xa7d5
movq %r12, %rdi
callq 0x3a0e
leaq 0x118(%rsp), %r12
leaq 0x128(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x70dd(%rip), %rsi      # 0xa7d6
leaq 0x70d9(%rip), %rdx      # 0xa7d9
movq %r12, %rdi
callq 0x3a0e
leaq 0x138(%rsp), %r12
leaq 0x148(%rsp), %rbp
movq %rbp, -0x10(%rbp)
leaq 0x70b7(%rip), %rsi      # 0xa7da
leaq 0x70b3(%rip), %rdx      # 0xa7dd
movq %r12, %rdi
callq 0x3a0e
leaq 0xbaff(%rip), %rdi      # 0xf238
leaq 0x98(%rsp), %rsi
leaq 0x8(%rsp), %rcx
leaq 0x7(%rsp), %r8
movl $0x6, %edx
callq 0x3888
leaq 0x148(%rsp), %r15
xorl %r12d, %r12d
movq 0x138(%rsp,%r12), %rdi
leaq (%r15,%r12), %rax
cmpq %rdi, %rax
je 0x3776
callq 0x2220
addq $-0x20, %r12
cmpq $-0xc0, %r12
jne 0x3760
leaq 0x180(%rip), %rdi       # 0x390a
leaq 0xbaa7(%rip), %rsi      # 0xf238
leaq 0xba80(%rip), %rdx      # 0xf218
callq 0x21f0
leaq 0xbac4(%rip), %rdi      # 0xf268
callq 0x2150
jmp 0x2f5e
movq %rax, %r13
movq $-0xc0, %rbx
movq -0x10(%rbp), %rdi
cmpq %rdi, %rbp
je 0x37c6
callq 0x2220
addq $-0x20, %rbp
addq $0x20, %rbx
jne 0x37b8
jmp 0x3801
jmp 0x37da
jmp 0x37da
jmp 0x37da
jmp 0x37da
movq %rax, %r13
addq $-0x10, %r12
movq -0x10(%r12), %rdi
cmpq %rdi, %r12
je 0x37f0
callq 0x2220
leaq -0x20(%r12), %rax
addq $-0x10, %r12
cmpq %r15, %r12
movq %rax, %r12
jne 0x37e1
leaq 0xba60(%rip), %rdi      # 0xf268
callq 0x2140
jmp 0x3858
movq %rax, %r13
jmp 0x3801
jmp 0x3855
movq %rax, %r13
movq 0x58(%rsp), %rdi
cmpq %r14, %rdi
jne 0x3844
jmp 0x3858
movq %rax, %r13
movq %rbx, %rdi
jmp 0x3844
jmp 0x3855
movq %rax, %r13
movq 0x78(%rsp), %rdi
cmpq %rbx, %rdi
jne 0x3844
jmp 0x3858
movq %rax, %r13
movq %r14, %rdi
callq 0x2220
jmp 0x3858
jmp 0x3855
jmp 0x3855
jmp 0x3855
jmp 0x3855
jmp 0x3855
movq %rax, %r13
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
je 0x386c
callq 0x2220
movq 0x38(%rsp), %rdi
leaq 0x48(%rsp), %rax
cmpq %rax, %rdi
je 0x3880
callq 0x2220
movq %r13, %rdi
callq 0x23d0