// File: /workspace/github_cpp_makefile_star2_O3/wenleix[P]EdgePPR/src/GenCSRMatrix.cpp
// Function: GenCscFile(ParamGraph*, int, _IO_FILE*)
void GenCscFile(ParamGraph* g, int etype, FILE *cscFile) {
	//	Print the matrix size
	fprintf(cscFile, "%d %d\n", g->numVertex, g->numVertex);

	vector<int> invdata;
	vector<int> indices;


	for (int i = 0; i < g->numVertex; i++) {
		ParamVertex *vtx = g->GetVertex(i);
		int invw = vtx->outEdgeTypeCount[etype];
		for (int j = 0; j < vtx->outDeg; j++) {
			ParamEdge *e = &vtx->outEdge[j];
			if (e->GetIntEType() == etype) {
				invdata.push_back(invw);
				indices.push_back(e->dstId);
			}
		}
	}

	//	inv-data
	for (int i = 0; i < invdata.size(); i++) {
		if (i != 0) fprintf(cscFile, " ");
		fprintf(cscFile, "%d", invdata[i]);
	}
	fprintf(cscFile, "\n");

	//	indices
	for (int i = 0; i < indices.size(); i++) {
		if (i != 0) fprintf(cscFile, " ");
		fprintf(cscFile, "%d", indices[i]);
	}
	fprintf(cscFile, "\n");
	//	indptr
	fprintf(cscFile, "0");
	int acc = 0;
	for (int i = 0; i < g->numVertex; i++) {
		ParamVertex *vtx = g->GetVertex(i);
		acc += vtx->outEdgeTypeCount[etype];
		fprintf(cscFile, " %d", acc);
	}
	fprintf(cscFile, "\n");

	assert(acc == invdata.size());
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movq %rdx, %r12
movl %esi, %ebp
movq %rdi, %r13
movl (%rdi), %ecx
leaq 0x1c55(%rip), %rsi      # 0x3010
xorl %r15d, %r15d
movq %rdx, %rdi
movl %ecx, %edx
xorl %eax, %eax
callq 0x1150
movq %r15, 0x20(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0x10(%rsp)
movq %r15, 0x40(%rsp)
movaps %xmm0, 0x30(%rsp)
cmpl $0x0, (%r13)
movslq %ebp, %rax
movq %rax, 0x50(%rsp)
jle 0x1508
movq %r12, 0x58(%rsp)
movq %r13, 0x60(%rsp)
movq %r13, %rdi
movl %r15d, %esi
callq 0x1d3c
movq %rax, %r14
movq 0x50(%rsp), %rax
movl 0x40(%r14,%rax,4), %eax
movl %eax, 0xc(%rsp)
cmpl $0x0, 0x30(%r14)
jle 0x149a
xorl %r13d, %r13d
xorl %ebx, %ebx
movq 0x38(%r14), %r12
cmpl %ebp, 0x4(%r12,%r13)
jne 0x148a
movq 0x18(%rsp), %rsi
cmpq 0x20(%rsp), %rsi
je 0x144e
movl 0xc(%rsp), %eax
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x18(%rsp)
jmp 0x145d
leaq 0x10(%rsp), %rdi
leaq 0xc(%rsp), %rdx
callq 0x1abe
addq %r13, %r12
movq 0x38(%rsp), %rsi
cmpq 0x40(%rsp), %rsi
je 0x147d
movl (%r12), %eax
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x38(%rsp)
jmp 0x148a
leaq 0x30(%rsp), %rdi
movq %r12, %rdx
callq 0x1abe
incq %rbx
movslq 0x30(%r14), %rax
addq $0x10, %r13
cmpq %rax, %rbx
jl 0x1426
incl %r15d
movq 0x60(%rsp), %r13
cmpl (%r13), %r15d
jl 0x13fe
movq 0x10(%rsp), %rax
cmpq %rax, 0x18(%rsp)
movq 0x58(%rsp), %r12
je 0x1508
leaq 0x1b54(%rip), %rbx      # 0x3018
xorl %r14d, %r14d
testq %r14, %r14
je 0x14de
movl $0x20, %edi
movq %r12, %rsi
callq 0x1120
movq 0x10(%rsp), %rax
movl (%rax,%r14,4), %edx
movq %r12, %rdi
movq %rbx, %rsi
xorl %eax, %eax
callq 0x1150
incq %r14
movq 0x10(%rsp), %rax
movq 0x18(%rsp), %rcx
subq %rax, %rcx
sarq $0x2, %rcx
cmpq %r14, %rcx
ja 0x14c7
movl $0xa, %edi
movq %r12, %rsi
callq 0x1120
movq 0x30(%rsp), %rax
cmpq %rax, 0x38(%rsp)
je 0x156c
leaq 0x1af0(%rip), %rbx      # 0x3018
xorl %r14d, %r14d
testq %r14, %r14
je 0x1542
movl $0x20, %edi
movq %r12, %rsi
callq 0x1120
movq 0x30(%rsp), %rax
movl (%rax,%r14,4), %edx
movq %r12, %rdi
movq %rbx, %rsi
xorl %eax, %eax
callq 0x1150
incq %r14
movq 0x30(%rsp), %rax
movq 0x38(%rsp), %rcx
subq %rax, %rcx
sarq $0x2, %rcx
cmpq %r14, %rcx
ja 0x152b
movl $0xa, %edi
movq %r12, %rsi
callq 0x1120
movl $0x30, %edi
movq %r12, %rsi
callq 0x1120
cmpl $0x0, (%r13)
jle 0x15cb
leaq 0x1a83(%rip), %r14      # 0x3017
xorl %ebp, %ebp
xorl %ebx, %ebx
movq %r13, %rdi
movl %ebp, %esi
callq 0x1d3c
movq 0x50(%rsp), %rcx
movslq 0x40(%rax,%rcx,4), %rax
movslq %ebx, %rbx
addq %rax, %rbx
movq %r12, %rdi
movq %r14, %rsi
movl %ebx, %edx
xorl %eax, %eax
callq 0x1150
incl %ebp
cmpl (%r13), %ebp
jl 0x1598
jmp 0x15cd
xorl %ebx, %ebx
movl $0xa, %edi
movq %r12, %rsi
callq 0x1120
movq 0x10(%rsp), %rdi
movq 0x18(%rsp), %rax
subq %rdi, %rax
sarq $0x2, %rax
cmpq %rbx, %rax
jne 0x1630
movq 0x30(%rsp), %rax
testq %rax, %rax
je 0x160f
movq 0x40(%rsp), %rsi
subq %rax, %rsi
movq %rax, %rdi
callq 0x10e0
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x1621
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x10e0
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x19e4(%rip), %rdi      # 0x301b
leaq 0x19f3(%rip), %rsi      # 0x3031
leaq 0x1a01(%rip), %rcx      # 0x3046
movl $0x3b, %edx
callq 0x1080
jmp 0x1653
jmp 0x1653
movq %rax, %rbx
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x166d
movq 0x40(%rsp), %rsi
subq %rdi, %rsi
callq 0x10e0
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x1684
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x10e0
movq %rbx, %rdi
callq 0x1190