// File: /workspace/github_c_makefile_star2_O3/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, %r13d
movl %edi, %r12d
movq %rsi, 0x10(%rsp)
leal -0x1(%rsi), %r14d
imull %r14d, %r12d
leal 0x1(%r12), %ebx
movl %ebx, %edi
movq %r8, %rbp
movq %r8, %rsi
callq 0x85e3
movq %rax, %r15
testl %r13d, %r13d
jle 0x192a8
movq %r15, %rdi
movl %r13d, %esi
callq 0x18ff3
jmp 0x192dc
testl %r12d, %r12d
js 0x1940b
movl %ebx, %ebx
xorl %r13d, %r13d
movl %r13d, %edi
callq 0xdcf9
movq 0x10(%r15), %rcx
movq (%rcx,%r13,8), %rdx
movq %rax, (%rdx)
movq (%rcx,%r13,8), %rax
movl $0x1, 0x24(%rax)
incq %r13
cmpq %r13, %rbx
jne 0x192b6
testl %r12d, %r12d
jle 0x1940b
movslq %r14d, %rax
movq %rax, 0x30(%rsp)
movslq 0x10(%rsp), %rax
movq %rax, 0x28(%rsp)
movl %r12d, %eax
movq %rax, 0x20(%rsp)
xorl %ebx, %ebx
movq 0x28(%rsp), %rax
leaq (%rbx,%rax), %rcx
movq 0x10(%rsp), %rax
movl %eax, %r12d
movq %rbx, 0x38(%rsp)
movl %ebx, %r13d
testl %eax, %eax
movq %rcx, 0x40(%rsp)
jle 0x193b0
leal 0x1(%r13), %eax
movslq %eax, %rdx
cmpq %rdx, %rcx
jle 0x193b0
movq %rdx, 0x48(%rsp)
movl %eax, 0x1c(%rsp)
movl $0x1, %ebx
cmpl $0x1, %ebx
je 0x19366
callq 0x1250
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
divsd 0x7b06(%rip), %xmm0     # 0x20e60
movsd 0x50(%rsp), %xmm1
ucomisd %xmm0, %xmm1
jb 0x1938f
leal (%rbx,%r13), %r14d
callq 0x1250
cltd
idivl 0xc(%rsp)
movl %edx, %edi
callq 0xdcf9
movl %r13d, %edi
movl %r14d, %esi
movq %rax, %rdx
movq %r15, %rcx
movq %rbp, %r8
callq 0x84a3
incl %ebx
cmpl %ebx, %r12d
jne 0x19341
decl %r12d
movl 0x1c(%rsp), %eax
movl %eax, %r13d
movq 0x40(%rsp), %rcx
cmpq 0x48(%rsp), %rcx
jg 0x19327
movq 0x10(%r15), %rax
movq 0x38(%rsp), %rbx
movq (%rax,%rbx,8), %rdi
movq -0x8(%rax,%rcx,8), %rsi
callq 0x7ccd
testb %al, %al
jne 0x193fb
movq 0x10(%rsp), %rax
leal (%rbx,%rax), %r14d
decl %r14d
callq 0x1250
cltd
idivl 0xc(%rsp)
movl %edx, %edi
callq 0xdcf9
movl %ebx, %edi
movl %r14d, %esi
movq %rax, %rdx
movq %r15, %rcx
movq %rbp, %r8
callq 0x84a3
addq 0x30(%rsp), %rbx
cmpq 0x20(%rsp), %rbx
jl 0x19301
movq %r15, %rax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq