// File: /workspace/github_c_makefile_star2_O2/pwelke[P]GraphMiningTools/randomGraphGenerators.c
// Function: randomClusteredOverlapGraphWithLabels
struct Graph* randomClusteredOverlapGraphWithLabels(int n, double d, int nClusters, double mu, struct GraphPool* gp) {

	if (nClusters > n) {
		fprintf(stderr, "Number of clusters is larger than number of vertices: %i > %i\n", nClusters, n);
		return NULL;
	}

	// ensure that nClusters divides number of vertices.
	int nodesPerCluster = n / nClusters;
	if (n != nodesPerCluster * nClusters) {
		fprintf(stderr, "Randomly generated graph will have %i vertices instead of %i vertices\n", nodesPerCluster * nClusters, n);
		n = nodesPerCluster * nClusters;
	}

	struct Graph* g = createGraph(n, gp);

	// every vertex is a two-dimensional point
	int i=0;
	for (int v=0; v<nClusters; ++v) {
		g->vertices[i]->d = rand();
		g->vertices[i]->lowPoint = rand();
		g->vertices[i]->label = intLabel(v);
		g->vertices[i]->isStringMaster = 1;
		for (int w=1; w<nodesPerCluster; ++w) {
			g->vertices[i+w]->d = g->vertices[i]->d;
			g->vertices[i+w]->lowPoint = g->vertices[i]->lowPoint;
			g->vertices[i+w]->label = intLabel(v);
			g->vertices[i+w]->isStringMaster = 1;
			moveVertexGaussian(g->vertices[i+w], mu);
		}
		i += nodesPerCluster;
	}

	// add edge iff distance is smaller than d
	for (int v=0; v<n; ++v) {
		for (int w=v+1; w<n; ++w) {
			if (euclideanDistanceWrap(v, w, g) < d) {
				addEdgeBetweenVertices(v, w, intLabel(1), g, gp);
				g->vertices[v]->neighborhood->isStringMaster = 1;
			}
		}
	}
	return g;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movsd %xmm1, 0x10(%rsp)
movl %esi, %r8d
movsd %xmm0, 0x30(%rsp)
movl %edi, %ecx
cmpl %edi, %esi
jg 0x17a0c
movq %rdx, %rbx
movl %ecx, %eax
cltd
idivl %r8d
movl %eax, %r12d
movl %eax, %ebp
movl %r8d, 0x4(%rsp)
imull %r8d, %ebp
cmpl %ecx, %ebp
jne 0x17a3c
movl %ecx, %ebp
movl %ebp, %edi
movq %rbx, %rsi
callq 0x630e
movq %rax, %r14
movslq %r12d, %r13
xorl %r15d, %r15d
movl 0x4(%rsp), %eax
testl %eax, %eax
cmovlel %r15d, %eax
leaq (,%r13,8), %rcx
movq %rcx, 0x20(%rsp)
pushq $0x8
popq %rcx
movq %rcx, 0x8(%rsp)
xorl %r12d, %r12d
movq %rbx, 0x28(%rsp)
movl %ebp, 0x1c(%rsp)
movl %eax, 0x4(%rsp)
cmpl %eax, %r12d
je 0x17985
callq 0x1240
movq 0x10(%r14), %rcx
movq (%rcx,%r15,8), %rcx
movl %eax, 0x28(%rcx)
callq 0x1240
movq 0x10(%r14), %rcx
movq (%rcx,%r15,8), %rcx
movl %eax, 0x20(%rcx)
movl %r12d, %edi
callq 0xb405
movq 0x10(%r14), %rcx
movq (%rcx,%r15,8), %rdx
movq %rax, (%rdx)
movq (%rcx,%r15,8), %rax
movl $0x1, 0x24(%rax)
movq 0x8(%rsp), %rbx
pushq $0x1
popq %rbp
cmpq %r13, %rbp
jge 0x1795e
movq 0x10(%r14), %rax
movq (%rax,%r15,8), %rcx
movl 0x28(%rcx), %edx
movq (%rax,%rbx), %rax
movl %edx, 0x28(%rax)
movl 0x20(%rcx), %ecx
movl %ecx, 0x20(%rax)
movl %r12d, %edi
callq 0xb405
movq 0x10(%r14), %rcx
movq (%rcx,%rbx), %rdx
movq %rax, (%rdx)
movq (%rcx,%rbx), %rdi
movl $0x1, 0x24(%rdi)
movsd 0x10(%rsp), %xmm0
callq 0x177fe
incq %rbp
addq $0x8, %rbx
jmp 0x1790f
addq %r13, %r15
incl %r12d
movq 0x8(%rsp), %rax
addq 0x20(%rsp), %rax
movq %rax, 0x8(%rsp)
movq 0x28(%rsp), %rbx
movl 0x1c(%rsp), %ebp
movl 0x4(%rsp), %eax
jmp 0x178c0
xorl %r15d, %r15d
testl %ebp, %ebp
movl $0x0, %eax
cmovgl %ebp, %eax
movq %rax, 0x8(%rsp)
pushq $0x1
popq %r12
cmpq 0x8(%rsp), %r15
je 0x17a2a
leaq 0x1(%r15), %rax
movq %rax, 0x10(%rsp)
movl %eax, %r13d
cmpl %ebp, %r13d
jge 0x17a05
movl %r15d, %edi
movl %r13d, %esi
movq %r14, %rdx
callq 0x17521
movsd 0x30(%rsp), %xmm1
ucomisd %xmm0, %xmm1
jbe 0x17a00
movl %r12d, %edi
callq 0xb405
movl %r15d, %edi
movl %r13d, %esi
movq %rax, %rdx
movq %r14, %rcx
movq %rbx, %r8
callq 0x6200
movq 0x10(%r14), %rax
movq (%rax,%r15,8), %rax
movq 0x8(%rax), %rax
movl $0x1, 0x28(%rax)
incl %r13d
jmp 0x179b2
movq 0x10(%rsp), %r15
jmp 0x1799b
movq 0x125e5(%rip), %rax     # 0x29ff8
movq (%rax), %rdi
leaq 0x6474(%rip), %rsi      # 0x1de91
xorl %r14d, %r14d
movl %r8d, %edx
xorl %eax, %eax
callq 0x1150
movq %r14, %rax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x125b5(%rip), %rax     # 0x29ff8
movq (%rax), %rdi
leaq 0x6483(%rip), %rsi      # 0x1ded0
movl %ebp, %edx
xorl %eax, %eax
callq 0x1150
jmp 0x1787e