// File: /workspace/github_c_makefile_star2_O1/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 $0x58, %rsp
movsd %xmm0, 0x50(%rsp)
movl %ecx, 0xc(%rsp)
movl %edx, %r12d
movl %edi, %ebx
movq %rsi, 0x10(%rsp)
leal -0x1(%rsi), %r14d
imull %r14d, %ebx
leal 0x1(%rbx), %r13d
movl %r13d, %edi
movq %r8, %rbp
movq %r8, %rsi
callq 0x8565
movq %rax, %r15
testl %r12d, %r12d
jle 0x1936e
movq %r15, %rdi
movl %r12d, %esi
callq 0x190c3
jmp 0x1939b
testl %ebx, %ebx
js 0x1939b
xorl %r12d, %r12d
movl %r12d, %edi
callq 0xdde3
movq 0x10(%r15), %rcx
movq (%rcx,%r12,8), %rdx
movq %rax, (%rdx)
movq (%rcx,%r12,8), %rax
movl $0x1, 0x24(%rax)
incq %r12
cmpq %r12, %r13
jne 0x19375
testl %ebx, %ebx
jle 0x194cc
movslq %r14d, %rax
movq %rax, 0x38(%rsp)
movslq 0x10(%rsp), %rax
movq %rax, 0x30(%rsp)
movl %ebx, %eax
movq %rax, 0x28(%rsp)
xorl %ebx, %ebx
movq 0x30(%rsp), %rax
movq %rbx, 0x20(%rsp)
leaq (%rbx,%rax), %rcx
cmpl $0x0, 0x10(%rsp)
jle 0x19471
movq 0x10(%rsp), %rax
movl %eax, %r12d
movq 0x20(%rsp), %rax
movq %rcx, 0x40(%rsp)
movl %eax, %r13d
leal 0x1(%r13), %eax
movl %eax, 0x1c(%rsp)
cltq
movq %rax, 0x48(%rsp)
cmpq %rax, %rcx
jle 0x1945a
movl $0x1, %ebx
cmpl $0x1, %ebx
je 0x1942a
callq 0x1250
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
divsd 0x7a42(%rip), %xmm0     # 0x20e60
movsd 0x50(%rsp), %xmm1
ucomisd %xmm0, %xmm1
jb 0x19453
leal (%rbx,%r13), %r14d
callq 0x1250
cltd
idivl 0xc(%rsp)
movl %edx, %edi
callq 0xdde3
movl %r13d, %edi
movl %r14d, %esi
movq %rax, %rdx
movq %r15, %rcx
movq %rbp, %r8
callq 0x8425
incl %ebx
cmpl %ebx, %r12d
jne 0x19405
decl %r12d
movq 0x40(%rsp), %rcx
cmpq 0x48(%rsp), %rcx
movl 0x1c(%rsp), %eax
jg 0x193e9
movq 0x10(%r15), %rax
movq 0x20(%rsp), %rbx
movq (%rax,%rbx,8), %rdi
movq -0x8(%rax,%rcx,8), %rsi
callq 0x7c9f
testb %al, %al
jne 0x194bc
movq 0x10(%rsp), %rax
leal (%rbx,%rax), %r14d
decl %r14d
callq 0x1250
cltd
idivl 0xc(%rsp)
movl %edx, %edi
callq 0xdde3
movl %ebx, %edi
movl %r14d, %esi
movq %rax, %rdx
movq %r15, %rcx
movq %rbp, %r8
callq 0x8425
addq 0x38(%rsp), %rbx
cmpq 0x28(%rsp), %rbx
jl 0x193be
movq %r15, %rax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq