// File: /workspace/github_cpp_makefile_star2_O2/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, %r15
movl %esi, %ebp
movq %rdi, %r12
movl (%rdi), %ecx
leaq 0x1ce5(%rip), %rsi      # 0x3010
xorl %ebx, %ebx
movq %rdx, %rdi
movl %ecx, %edx
xorl %eax, %eax
callq 0x1180
xorps %xmm0, %xmm0
leaq 0x10(%rsp), %rax
andq $0x0, 0x10(%rax)
leaq 0x30(%rsp), %rcx
andq $0x0, 0x10(%rcx)
movaps %xmm0, (%rax)
movaps %xmm0, (%rcx)
movslq %ebp, %r13
leaq 0xc(%rsp), %r14
movq %r15, 0x58(%rsp)
movq %r12, 0x50(%rsp)
movq %r13, 0x48(%rsp)
cmpl (%r12), %ebx
jge 0x13e6
movq %r12, %rdi
movq %rbx, 0x60(%rsp)
movl %ebx, %esi
callq 0x1c74
movq %rax, %rbx
movl 0x40(%rax,%r13,4), %eax
movl %eax, 0xc(%rsp)
xorl %r12d, %r12d
xorl %r13d, %r13d
movslq 0x30(%rbx), %rax
cmpq %rax, %r13
jge 0x13ce
movq 0x38(%rbx), %r15
cmpl %ebp, 0x4(%r15,%r12)
jne 0x13c5
leaq 0x10(%rsp), %rdi
movq %r14, %rsi
callq 0x1936
addq %r12, %r15
leaq 0x30(%rsp), %rdi
movq %r15, %rsi
callq 0x1936
incq %r13
addq $0x10, %r12
jmp 0x1394
movq 0x60(%rsp), %rbx
incl %ebx
movq 0x58(%rsp), %r15
movq 0x50(%rsp), %r12
movq 0x48(%rsp), %r13
jmp 0x136d
leaq 0x1c2b(%rip), %rbx      # 0x3018
pushq $0x20
popq %rbp
xorl %r14d, %r14d
movq 0x10(%rsp), %rax
movq 0x18(%rsp), %rcx
subq %rax, %rcx
sarq $0x2, %rcx
cmpq %r14, %rcx
jbe 0x1433
testq %r14, %r14
je 0x141d
movl %ebp, %edi
movq %r15, %rsi
callq 0x1150
movq 0x10(%rsp), %rax
movl (%rax,%r14,4), %edx
movq %r15, %rdi
movq %rbx, %rsi
xorl %eax, %eax
callq 0x1180
incq %r14
jmp 0x13f3
pushq $0xa
popq %rdi
movq %r15, %rsi
callq 0x1150
leaq 0x1bd3(%rip), %rbx      # 0x3018
pushq $0x20
popq %rbp
xorl %r14d, %r14d
movq 0x30(%rsp), %rax
movq 0x38(%rsp), %rcx
subq %rax, %rcx
sarq $0x2, %rcx
cmpq %r14, %rcx
jbe 0x148b
testq %r14, %r14
je 0x1475
movl %ebp, %edi
movq %r15, %rsi
callq 0x1150
movq 0x30(%rsp), %rax
movl (%rax,%r14,4), %edx
movq %r15, %rdi
movq %rbx, %rsi
xorl %eax, %eax
callq 0x1180
incq %r14
jmp 0x144b
pushq $0xa
popq %rdi
movq %r15, %rsi
callq 0x1150
pushq $0x30
popq %rdi
movq %r15, %rsi
callq 0x1150
leaq 0x1b6f(%rip), %r14      # 0x3017
xorl %ebx, %ebx
xorl %ebp, %ebp
cmpl (%r12), %ebp
jge 0x14d4
movq %r12, %rdi
movl %ebp, %esi
callq 0x1c74
addl 0x40(%rax,%r13,4), %ebx
movq %r15, %rdi
movq %r14, %rsi
movl %ebx, %edx
xorl %eax, %eax
callq 0x1180
incl %ebp
jmp 0x14ac
pushq $0xa
popq %rdi
movq %r15, %rsi
callq 0x1150
movslq %ebx, %rax
movq 0x18(%rsp), %rcx
subq 0x10(%rsp), %rcx
sarq $0x2, %rcx
cmpq %rax, %rcx
jne 0x1518
leaq 0x30(%rsp), %rdi
callq 0x1982
leaq 0x10(%rsp), %rdi
callq 0x1982
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x1afc(%rip), %rdi      # 0x301b
leaq 0x1b0b(%rip), %rsi      # 0x3031
leaq 0x1b19(%rip), %rcx      # 0x3046
pushq $0x3b
popq %rdx
callq 0x10b0
jmp 0x1539
jmp 0x1539
movq %rax, %rbx
leaq 0x30(%rsp), %rdi
callq 0x1982
leaq 0x10(%rsp), %rdi
callq 0x1982
movq %rbx, %rdi
callq 0x11c0