// File: /workspace/github_cpp_makefile_star2_O1/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
movl %esi, %ebp
movq %rdi, %r12
movl (%rdi), %ecx
leaq 0x1c58(%rip), %rsi      # 0x3010
xorl %r15d, %r15d
movq %rdx, 0x50(%rsp)
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, (%r12)
movslq %ebp, %r13
jle 0x14a9
movq %r12, 0x60(%rsp)
movq %r13, 0x58(%rsp)
movq %r12, %rdi
movl %r15d, %esi
callq 0x1d10
movq %rax, %rbx
movl 0x40(%rax,%r13,4), %eax
movl %eax, 0xc(%rsp)
cmpl $0x0, 0x30(%rbx)
jle 0x1492
xorl %r13d, %r13d
xorl %r14d, %r14d
movq 0x38(%rbx), %r12
cmpl %ebp, 0x4(%r12,%r13)
jne 0x1482
movq 0x18(%rsp), %rsi
cmpq 0x20(%rsp), %rsi
je 0x1446
movl 0xc(%rsp), %eax
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x18(%rsp)
jmp 0x1455
leaq 0x10(%rsp), %rdi
leaq 0xc(%rsp), %rdx
callq 0x1a94
addq %r13, %r12
movq 0x38(%rsp), %rsi
cmpq 0x40(%rsp), %rsi
je 0x1475
movl (%r12), %eax
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x38(%rsp)
jmp 0x1482
leaq 0x30(%rsp), %rdi
movq %r12, %rdx
callq 0x1a94
incq %r14
movslq 0x30(%rbx), %rax
addq $0x10, %r13
cmpq %rax, %r14
jl 0x141e
incl %r15d
movq 0x60(%rsp), %r12
cmpl (%r12), %r15d
movq 0x58(%rsp), %r13
jl 0x13fb
movq 0x18(%rsp), %rax
cmpq 0x10(%rsp), %rax
movq 0x50(%rsp), %r15
je 0x1502
leaq 0x1b57(%rip), %rbx      # 0x3018
xorl %r14d, %r14d
testq %r14, %r14
je 0x14d6
movl $0x20, %edi
movq %r15, %rsi
callq 0x1120
movq 0x10(%rsp), %rax
movl (%rax,%r14,4), %edx
movq %r15, %rdi
movq %rbx, %rsi
xorl %eax, %eax
callq 0x1150
incq %r14
movq 0x18(%rsp), %rax
subq 0x10(%rsp), %rax
sarq $0x2, %rax
cmpq %r14, %rax
ja 0x14c4
movl $0xa, %edi
movq %r15, %rsi
callq 0x1120
movq 0x38(%rsp), %rax
cmpq 0x30(%rsp), %rax
je 0x1563
leaq 0x1af6(%rip), %rbx      # 0x3018
xorl %r14d, %r14d
testq %r14, %r14
je 0x1537
movl $0x20, %edi
movq %r15, %rsi
callq 0x1120
movq 0x30(%rsp), %rax
movl (%rax,%r14,4), %edx
movq %r15, %rdi
movq %rbx, %rsi
xorl %eax, %eax
callq 0x1150
incq %r14
movq 0x38(%rsp), %rax
subq 0x30(%rsp), %rax
sarq $0x2, %rax
cmpq %r14, %rax
ja 0x1525
movl $0xa, %edi
movq %r15, %rsi
callq 0x1120
movl $0x30, %edi
movq %r15, %rsi
callq 0x1120
cmpl $0x0, (%r12)
jle 0x15bd
leaq 0x1a8c(%rip), %r14      # 0x3017
xorl %ebp, %ebp
xorl %ebx, %ebx
movq %r12, %rdi
movl %ebp, %esi
callq 0x1d10
movslq 0x40(%rax,%r13,4), %rax
movslq %ebx, %rbx
addq %rax, %rbx
movq %r15, %rdi
movq %r14, %rsi
movl %ebx, %edx
xorl %eax, %eax
callq 0x1150
incl %ebp
cmpl (%r12), %ebp
jl 0x158f
jmp 0x15bf
xorl %ebx, %ebx
movl $0xa, %edi
movq %r15, %rsi
callq 0x1120
movq 0x18(%rsp), %rax
subq 0x10(%rsp), %rax
sarq $0x2, %rax
cmpq %rbx, %rax
jne 0x161c
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x15f6
movq 0x40(%rsp), %rsi
subq %rdi, %rsi
callq 0x10e0
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x160d
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 0x19f8(%rip), %rdi      # 0x301b
leaq 0x1a07(%rip), %rsi      # 0x3031
leaq 0x1a15(%rip), %rcx      # 0x3046
movl $0x3b, %edx
callq 0x1080
jmp 0x163f
jmp 0x163f
movq %rax, %rbx
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x1659
movq 0x40(%rsp), %rsi
subq %rdi, %rsi
callq 0x10e0
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x1670
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x10e0
movq %rbx, %rdi
callq 0x1190