// File: /workspace/github_cpp_makefile_star2_O1/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 0x3621
cmpl $0x3, %r14d
jge 0x2f70
callq 0x278e
xorl %ebx, %ebx
jmp 0x3545
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 0x3d5a
leaq 0xc22d(%rip), %rcx      # 0xf240
cmpq %rcx, %rax
movl $0x1, %r15d
je 0x3581
cmpl $0x5, %r14d
jl 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 0x3de4
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 0x3990
leaq 0x78(%rsp), %rsi
movq %r14, %rdi
callq 0x3e3c
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 0x744c
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 0x3990
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 0x59f4
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 0x74b2
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 0x3492
movq 0x10(%r14), %rax
movq 0x18(%r14), %rcx
subq %rax, %rcx
sarq $0x3, %rcx
decq %rcx
je 0x344f
movl $0x1, %ebp
xorl %edx, %edx
movq (%rax,%rdx,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, %edx
movq 0x10(%r14), %rax
movq 0x18(%r14), %rcx
subq %rax, %rcx
sarq $0x3, %rcx
decq %rcx
incl %ebp
cmpq %rdx, %rcx
ja 0x3410
movq (%rax,%rcx,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 0xbb57(%rip), %r12      # 0xeff0
leaq 0x73dd(%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 0xbb24(%rip), %rdi      # 0xeff0
callq 0x2040
movq %rax, %rdi
callq 0x2170
movq %r15, %rdi
callq 0x5466
movq %r15, %rdi
callq 0x2220
movq 0x8(%rsp), %r15
testq %r15, %r15
je 0x3503
movq %r15, %rdi
callq 0x3dec
movq %r15, %rdi
callq 0x2220
movq %rbx, %rdi
callq 0x7498
movq %rbx, %rdi
callq 0x2220
callq 0x2070
movq %rax, %r14
movq 0xbace(%rip), %rdi      # 0xeff0
leaq 0x7363(%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 0x3559
callq 0x2220
movq 0x38(%rsp), %rdi
leaq 0x48(%rsp), %rax
cmpq %rax, %rdi
je 0x356d
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 0xba63(%rip), %rdi      # 0xeff0
movq (%rdi), %rax
addq -0x18(%rax), %rdi
movl $0xa, %esi
callq 0x2240
movsbl %al, %esi
movq 0xba48(%rip), %rdi      # 0xeff0
callq 0x2040
movq %rax, %rdi
callq 0x2170
movq %rax, %rbx
leaq 0x721f(%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 0x71f8(%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 0xbc40(%rip), %rdi      # 0xf268
callq 0x2400
testl %eax, %eax
je 0x2f5e
leaq 0xa8(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x7182(%rip), %rsi      # 0xa7ca
leaq 0x717d(%rip), %rdx      # 0xa7cc
leaq 0x98(%rsp), %r12
movq %r12, %rdi
callq 0x3a20
leaq 0xb8(%rsp), %r15
leaq 0xc8(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x7153(%rip), %rsi      # 0xa7cd
leaq 0x714e(%rip), %rdx      # 0xa7cf
movq %r15, %rdi
callq 0x3a20
leaq 0xd8(%rsp), %r15
leaq 0xe8(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x712c(%rip), %rsi      # 0xa7d0
leaq 0x7127(%rip), %rdx      # 0xa7d2
movq %r15, %rdi
callq 0x3a20
leaq 0xf8(%rsp), %r15
leaq 0x108(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x7105(%rip), %rsi      # 0xa7d3
leaq 0x7100(%rip), %rdx      # 0xa7d5
movq %r15, %rdi
callq 0x3a20
leaq 0x118(%rsp), %r15
leaq 0x128(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x70de(%rip), %rsi      # 0xa7d6
leaq 0x70da(%rip), %rdx      # 0xa7d9
movq %r15, %rdi
callq 0x3a20
leaq 0x138(%rsp), %r15
leaq 0x148(%rsp), %rbp
movq %rbp, -0x10(%rbp)
leaq 0x70b8(%rip), %rsi      # 0xa7da
leaq 0x70b4(%rip), %rdx      # 0xa7dd
movq %r15, %rdi
callq 0x3a20
leaq 0xbb00(%rip), %rdi      # 0xf238
leaq 0x98(%rsp), %rsi
leaq 0x8(%rsp), %rcx
leaq 0x7(%rsp), %r8
movl $0x6, %edx
callq 0x38a0
leaq 0x148(%rsp), %r15
xorl %r12d, %r12d
movq 0x138(%rsp,%r12), %rdi
leaq (%r15,%r12), %rax
cmpq %rdi, %rax
je 0x3775
callq 0x2220
addq $-0x20, %r12
cmpq $-0xc0, %r12
jne 0x375f
leaq 0x199(%rip), %rdi       # 0x3922
leaq 0xbaa8(%rip), %rsi      # 0xf238
leaq 0xba81(%rip), %rdx      # 0xf218
callq 0x21f0
leaq 0xbac5(%rip), %rdi      # 0xf268
callq 0x2150
jmp 0x2f5e
movq %rax, %r13
movq $-0xc0, %rbx
movq -0x10(%rbp), %rdi
cmpq %rdi, %rbp
je 0x37c5
callq 0x2220
addq $-0x20, %rbp
addq $0x20, %rbx
jne 0x37b7
movb $0x1, %al
jmp 0x37e0
jmp 0x37db
jmp 0x37db
jmp 0x37db
jmp 0x37db
movq %rax, %r13
xorl %eax, %eax
cmpq %r15, %r12
sete %cl
orb %al, %cl
jne 0x3814
addq $-0x10, %r15
leaq 0x98(%rsp), %rbx
movq -0x10(%r15), %rdi
cmpq %rdi, %r15
je 0x3804
callq 0x2220
leaq -0x20(%r15), %rax
addq $-0x10, %r15
cmpq %rbx, %r15
movq %rax, %r15
jne 0x37f6
leaq 0xba4d(%rip), %rdi      # 0xf268
callq 0x2140
jmp 0x3870
movq %rax, %r13
xorl %eax, %eax
movq %r12, %r15
jmp 0x37e0
jmp 0x386d
movq %rax, %r13
movq 0x58(%rsp), %rdi
cmpq %r14, %rdi
jne 0x385c
jmp 0x3870
movq %rax, %r13
movq %rbx, %rdi
jmp 0x385c
jmp 0x386d
movq %rax, %r13
movq 0x78(%rsp), %rdi
cmpq %rbx, %rdi
jne 0x385c
jmp 0x3870
movq %rax, %r13
movq %r14, %rdi
callq 0x2220
jmp 0x3870
jmp 0x386d
jmp 0x386d
jmp 0x386d
jmp 0x386d
jmp 0x386d
movq %rax, %r13
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
je 0x3884
callq 0x2220
movq 0x38(%rsp), %rdi
leaq 0x48(%rsp), %rax
cmpq %rax, %rdi
je 0x3898
callq 0x2220
movq %r13, %rdi
callq 0x23d0