// File: /workspace/github_c_makefile_star2_O2/pwelke[P]GraphMiningTools/randomGraphGenerators.c
// Function: blockChainGenerator
struct Graph* blockChainGenerator(int nBlocks, int blockSize, int nVertexLabels, int nEdgeLabels, double diagonalProbability, struct GraphPool* gp) {

	// create empty graph of correct size
	int nVertices = nBlocks * blockSize - nBlocks + 1;
	struct Graph* g = createGraph(nVertices, gp);

	// add vertex labels
	if (nVertexLabels < 1) {
		for (int v=0; v<nVertices; ++v) {
			g->vertices[v]->label = intLabel(v);
			g->vertices[v]->isStringMaster = 1;
		}
	} else {
		randomVertexLabels(g, nVertexLabels);
	}

	// add cycle edges
	for (int blockStart=0; blockStart<nVertices-1; blockStart+=blockSize-1) {
		for (int v=blockStart; v<blockStart+blockSize; ++v) {
			for (int w=v+1; w<blockStart+blockSize; ++w) {
				if ((w - v == 1) || (rand() / ((double)RAND_MAX) <= diagonalProbability)) {
					addEdgeBetweenVertices(v, w, intLabel(rand() % nEdgeLabels), g, gp);
				}
			}
		}
		if (!isIncident(g->vertices[blockStart], g->vertices[blockStart+blockSize-1])) {
			addEdgeBetweenVertices(blockStart, blockStart+blockSize-1, intLabel(rand() % nEdgeLabels), g, gp);
		}
	}
	return g;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movsd %xmm0, 0x40(%rsp)
movl %ecx, 0x4(%rsp)
movl %edx, %r14d
movl %edi, %r12d
movq %rsi, 0x10(%rsp)
leal -0x1(%rsi), %ebx
imull %ebx, %r12d
leal 0x1(%r12), %edi
movq %r8, %rbp
movq %r8, %rsi
callq 0x630e
movq %rax, %r15
movslq %r12d, %rax
movq %rax, 0x18(%rsp)
testl %r14d, %r14d
jle 0x17061
movq %r15, %rdi
movl %r14d, %esi
callq 0x16c99
movslq %ebx, %rax
movq %rax, 0x30(%rsp)
movslq 0x10(%rsp), %rax
movq %rax, 0x28(%rsp)
xorl %ebx, %ebx
cmpq 0x18(%rsp), %rbx
jge 0x1704f
movq 0x28(%rsp), %rax
addq %rbx, %rax
movq %rax, 0x20(%rsp)
movq 0x10(%rsp), %rax
leal (%rbx,%rax), %ecx
movl %ecx, 0x8(%rsp)
movl %eax, %r14d
movq %rbx, 0x38(%rsp)
movl %ebx, %r12d
movslq %r12d, %rax
cmpq %rax, 0x20(%rsp)
jle 0x16ff9
leal 0x1(%r12), %eax
movl %eax, 0xc(%rsp)
pushq $0x1
popq %rax
movl %eax, %ebx
cmpl %ebx, %r14d
je 0x16fed
cmpl $0x1, %ebx
je 0x16fc0
callq 0x1240
cvtsi2sd %eax, %xmm0
divsd 0x6e7c(%rip), %xmm0     # 0x1de30
movsd 0x40(%rsp), %xmm1
ucomisd %xmm0, %xmm1
jb 0x16fe9
leal (%r12,%rbx), %r13d
callq 0x1240
cltd
idivl 0x4(%rsp)
movl %edx, %edi
callq 0xb405
movl %r12d, %edi
movl %r13d, %esi
movq %rax, %rdx
movq %r15, %rcx
movq %rbp, %r8
callq 0x6200
incl %ebx
jmp 0x16f99
decl %r14d
movl 0xc(%rsp), %eax
movl %eax, %r12d
jmp 0x16f81
movq 0x10(%r15), %rax
movq 0x38(%rsp), %rbx
movq (%rax,%rbx,8), %rdi
movq 0x20(%rsp), %rcx
movq -0x8(%rax,%rcx,8), %rsi
callq 0x5afb
testb %al, %al
jne 0x17045
movl 0x8(%rsp), %r14d
decl %r14d
callq 0x1240
cltd
idivl 0x4(%rsp)
movl %edx, %edi
callq 0xb405
movl %ebx, %edi
movl %r14d, %esi
movq %rax, %rdx
movq %r15, %rcx
movq %rbp, %r8
callq 0x6200
addq 0x30(%rsp), %rbx
jmp 0x16f52
movq %r15, %rax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
xorl %r14d, %r14d
cmpq 0x18(%rsp), %r14
jg 0x16f3e
movl %r14d, %edi
callq 0xb405
movq 0x10(%r15), %rcx
movq (%rcx,%r14,8), %rdx
movq %rax, (%rdx)
movq (%rcx,%r14,8), %rax
movl $0x1, 0x24(%rax)
incq %r14
jmp 0x17064