// File: /workspace/github_c_makefile_star2_O3/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 0x19f9e
movsd %xmm1, 0x38(%rsp)
movl %ecx, %eax
cltd
idivl %ebx
movl %eax, %ebp
movl %eax, 0xc(%rsp)
imull %ebx, %ebp
cmpl %ecx, %ebp
jne 0x19fbd
movl %ecx, %ebp
movl %ebp, 0x10(%rsp)
movl %ebp, %edi
movq 0x18(%rsp), %rsi
callq 0x85e3
movq %rax, %r14
testl %ebx, %ebx
jle 0x19e9f
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 0xdcf9
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 0x19e79
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 0xdcf9
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 0x18ebf
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 0x19e00
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 0x19db0
movl 0x10(%rsp), %eax
testl %eax, %eax
jle 0x19f8c
movl %eax, %r13d
movl $0x1, %ebp
xorl %ebx, %ebx
movapd 0x6fb3(%rip), %xmm3     # 0x20e70
movq %rbx, %r15
incq %rbx
cmpq %r13, %rbx
jae 0x19f80
movq 0x10(%r14), %rax
movq %rbp, %r12
movq (%rax,%r15,8), %rcx
movq (%rax,%r12,8), %rdx
movss 0x28(%rdx), %xmm0
movss 0x28(%rcx), %xmm1
unpcklps %xmm0, %xmm1            # xmm1 = xmm1[0],xmm0[0],xmm1[1],xmm0[1]
cvtdq2pd %xmm1, %xmm0
divpd %xmm3, %xmm0
movss 0x20(%rdx), %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
sqrtsd %xmm0, %xmm0
movsd 0x40(%rsp), %xmm1
ucomisd %xmm0, %xmm1
jbe 0x19f74
movl $0x1, %edi
callq 0xdcf9
movl %r15d, %edi
movl %r12d, %esi
movq %rax, %rdx
movq %r14, %rcx
movq 0x18(%rsp), %r8
callq 0x84a3
movapd 0x6f0f(%rip), %xmm3     # 0x20e70
movq 0x10(%r14), %rax
movq (%rax,%r15,8), %rcx
movq 0x8(%rcx), %rcx
movl $0x1, 0x28(%rcx)
incq %r12
cmpq %r12, %r13
jne 0x19ed3
incq %rbp
cmpq %r13, %rbx
jne 0x19ebd
movq %r14, %rax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x13053(%rip), %rax     # 0x2cff8
movq (%rax), %rdi
leaq 0x6f12(%rip), %rsi      # 0x20ec1
xorl %r14d, %r14d
movl %ebx, %edx
xorl %eax, %eax
callq 0x1160
jmp 0x19f8c
movq 0x13034(%rip), %rax     # 0x2cff8
movq (%rax), %rdi
leaq 0x6f32(%rip), %rsi      # 0x20f00
movl %ebp, %edx
xorl %eax, %eax
callq 0x1160
jmp 0x19d65