// File: /workspace/github_c_makefile_star2_O1/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 $0x48, %rsp
movq %rdx, 0x18(%rsp)
movl %esi, %ebx
movsd %xmm0, 0x40(%rsp)
movl %edi, %ecx
cmpl %edi, %esi
jg 0x1a080
movsd %xmm1, 0x38(%rsp)
movl %ecx, %eax
cltd
idivl %ebx
movl %eax, %ebp
movl %eax, 0xc(%rsp)
imull %ebx, %ebp
cmpl %ecx, %ebp
jne 0x1a09f
movl %ecx, %ebp
movl %ebp, 0x10(%rsp)
movl %ebp, %edi
movq 0x18(%rsp), %rsi
callq 0x8565
movq %rax, %r14
testl %ebx, %ebx
jle 0x19f78
movl 0xc(%rsp), %eax
movslq %eax, %rcx
movq %rcx, 0x28(%rsp)
movl %eax, %eax
decq %rax
movq %rax, 0x20(%rsp)
xorl %r12d, %r12d
movl $0x1, %ebp
movl $0x0, 0x8(%rsp)
movl %ebx, 0x14(%rsp)
movl $0x7fffffff, %r13d      # imm = 0x7FFFFFFF
callq 0x1250
movq 0x10(%r14), %rcx
movq (%rcx,%r12,8), %rcx
movl %eax, 0x28(%rcx)
callq 0x1250
movq 0x10(%r14), %rcx
movq (%rcx,%r12,8), %rcx
movl %eax, 0x20(%rcx)
movl 0x8(%rsp), %edi
callq 0xdde3
movq 0x10(%r14), %rcx
movq (%rcx,%r12,8), %rdx
movq %rax, (%rdx)
movq (%rcx,%r12,8), %rax
movl $0x1, 0x24(%rax)
movq 0x20(%rsp), %rbx
movq %rbp, 0x30(%rsp)
cmpl $0x2, 0xc(%rsp)
jl 0x19f52
movq 0x10(%r14), %rax
movq (%rax,%r12,8), %rcx
movl 0x28(%rcx), %edx
movq (%rax,%rbp,8), %rax
movl %edx, 0x28(%rax)
movl 0x20(%rcx), %ecx
movl %ecx, 0x20(%rax)
movl 0x8(%rsp), %edi
callq 0xdde3
movq 0x10(%r14), %rcx
movq (%rcx,%rbp,8), %rdx
movq %rax, (%rdx)
movq (%rcx,%rbp,8), %r15
movl $0x1, 0x24(%r15)
leaq 0x28(%r15), %rdi
leaq 0x20(%r15), %rsi
movsd 0x38(%rsp), %xmm0
callq 0x18f8f
movl 0x20(%r15), %eax
movl 0x28(%r15), %ecx
movl %ecx, %edx
negl %edx
cmovsl %ecx, %edx
cmovol %r13d, %edx
movl %eax, %ecx
negl %ecx
cmovsl %eax, %ecx
cmovol %r13d, %ecx
movl %edx, 0x28(%r15)
movl %ecx, 0x20(%r15)
incq %rbp
decq %rbx
jne 0x19ed9
movq 0x28(%rsp), %rax
addq %rax, %r12
movl 0x8(%rsp), %ecx
incl %ecx
movq 0x30(%rsp), %rbp
addq %rax, %rbp
movl 0x14(%rsp), %ebx
movl %ecx, 0x8(%rsp)
cmpl %ebx, %ecx
jne 0x19e89
movl 0x10(%rsp), %eax
testl %eax, %eax
jle 0x1a06e
movl %eax, %r13d
movl $0x1, %ebp
xorl %ebx, %ebx
movq %rbx, %r15
incq %rbx
cmpq %r13, %rbx
jae 0x1a062
movq %rbp, %r12
movq 0x10(%r14), %rax
movq (%rax,%r15,8), %rcx
movq (%rax,%r12,8), %rax
movss 0x28(%rax), %xmm0
movss 0x28(%rcx), %xmm1
unpcklps %xmm0, %xmm1            # xmm1 = xmm1[0],xmm0[0],xmm1[1],xmm0[1]
cvtdq2pd %xmm1, %xmm0
movapd 0x6eab(%rip), %xmm3     # 0x20e70
divpd %xmm3, %xmm0
movss 0x20(%rax), %xmm1
movss 0x20(%rcx), %xmm2
unpcklps %xmm1, %xmm2            # xmm2 = xmm2[0],xmm1[0],xmm2[1],xmm1[1]
cvtdq2pd %xmm2, %xmm1
divpd %xmm3, %xmm1
movapd %xmm0, %xmm2
unpckhpd %xmm0, %xmm2            # xmm2 = xmm2[1],xmm0[1]
subsd %xmm2, %xmm0
movapd %xmm1, %xmm2
unpckhpd %xmm1, %xmm2            # xmm2 = xmm2[1],xmm1[1]
subsd %xmm2, %xmm1
mulsd %xmm1, %xmm1
mulsd %xmm0, %xmm0
addsd %xmm1, %xmm0
ucomisd 0x6e4e(%rip), %xmm0     # 0x20e58
jb 0x1a012
sqrtsd %xmm0, %xmm0
jmp 0x1a017
callq 0x1230
movsd 0x40(%rsp), %xmm1
ucomisd %xmm0, %xmm1
jbe 0x1a056
movl $0x1, %edi
callq 0xdde3
movl %r15d, %edi
movl %r12d, %esi
movq %rax, %rdx
movq %r14, %rcx
movq 0x18(%rsp), %r8
callq 0x8425
movq 0x10(%r14), %rax
movq (%rax,%r15,8), %rax
movq 0x8(%rax), %rax
movl $0x1, 0x28(%rax)
incq %r12
cmpq %r12, %r13
jne 0x19fa0
incq %rbp
cmpq %r13, %rbx
jne 0x19f8e
movq %r14, %rax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x12f71(%rip), %rax     # 0x2cff8
movq (%rax), %rdi
leaq 0x6e30(%rip), %rsi      # 0x20ec1
xorl %r14d, %r14d
movl %ebx, %edx
xorl %eax, %eax
callq 0x1160
jmp 0x1a06e
movq 0x12f52(%rip), %rax     # 0x2cff8
movq (%rax), %rdi
leaq 0x6e50(%rip), %rsi      # 0x20f00
movl %ebp, %edx
xorl %eax, %eax
callq 0x1160
jmp 0x19e3e