// File: 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
movq %rsp, %rbp
subq $0xd0, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq %rdx, -0x18(%rbp)
movq -0x18(%rbp), %rdi
movq -0x8(%rbp), %rax
movl (%rax), %edx
movq -0x8(%rbp), %rax
movl (%rax), %ecx
leaq 0x2c13(%rip), %rsi      # 0x5010
movb $0x0, %al
callq 0x2200
leaq -0x30(%rbp), %rdi
callq 0x2cd0
leaq -0x48(%rbp), %rdi
callq 0x2cd0
movl $0x0, -0x4c(%rbp)
movl -0x4c(%rbp), %eax
movq -0x8(%rbp), %rcx
cmpl (%rcx), %eax
jge 0x2508
movq -0x8(%rbp), %rdi
movl -0x4c(%rbp), %esi
callq 0x41e0
movq %rax, -0x98(%rbp)
jmp 0x2441
movq -0x98(%rbp), %rax
movq %rax, -0x58(%rbp)
movq -0x58(%rbp), %rax
movslq -0xc(%rbp), %rcx
movl 0x40(%rax,%rcx,4), %eax
movl %eax, -0x68(%rbp)
movl $0x0, -0x6c(%rbp)
movl -0x6c(%rbp), %eax
movq -0x58(%rbp), %rcx
cmpl 0x30(%rcx), %eax
jge 0x24f8
movq -0x58(%rbp), %rax
movq 0x38(%rax), %rax
movslq -0x6c(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq %rax, -0x78(%rbp)
movq -0x78(%rbp), %rdi
callq 0x2cf0
movl %eax, -0x9c(%rbp)
jmp 0x249a
movl -0x9c(%rbp), %eax
cmpl -0xc(%rbp), %eax
jne 0x24e8
leaq -0x30(%rbp), %rdi
leaq -0x68(%rbp), %rsi
callq 0x2d10
jmp 0x24b4
movq -0x78(%rbp), %rsi
leaq -0x48(%rbp), %rdi
callq 0x2d10
jmp 0x24c3
jmp 0x24e8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
leaq -0x48(%rbp), %rdi
callq 0x2dc0
leaq -0x30(%rbp), %rdi
callq 0x2dc0
jmp 0x2736
jmp 0x24ea
movl -0x6c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x6c(%rbp)
jmp 0x2462
jmp 0x24fa
movl -0x4c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4c(%rbp)
jmp 0x241d
movl $0x0, -0x7c(%rbp)
movslq -0x7c(%rbp), %rax
movq %rax, -0xa8(%rbp)
leaq -0x30(%rbp), %rdi
callq 0x2d80
movq %rax, %rcx
movq -0xa8(%rbp), %rax
cmpq %rcx, %rax
jae 0x2584
cmpl $0x0, -0x7c(%rbp)
je 0x254a
movq -0x18(%rbp), %rdi
leaq 0x2d64(%rip), %rsi      # 0x52a7
movb $0x0, %al
callq 0x2200
movq -0x18(%rbp), %rax
movq %rax, -0xb0(%rbp)
movslq -0x7c(%rbp), %rsi
leaq -0x30(%rbp), %rdi
callq 0x2da0
movq -0xb0(%rbp), %rdi
movl (%rax), %edx
leaq 0x2aa8(%rip), %rsi      # 0x501a
movb $0x0, %al
callq 0x2200
movl -0x7c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x7c(%rbp)
jmp 0x250f
movq -0x18(%rbp), %rdi
leaq 0x2bad(%rip), %rsi      # 0x513c
movb $0x0, %al
callq 0x2200
movl $0x0, -0x80(%rbp)
movslq -0x80(%rbp), %rax
movq %rax, -0xb8(%rbp)
leaq -0x48(%rbp), %rdi
callq 0x2d80
movq %rax, %rcx
movq -0xb8(%rbp), %rax
cmpq %rcx, %rax
jae 0x2612
cmpl $0x0, -0x80(%rbp)
je 0x25d8
movq -0x18(%rbp), %rdi
leaq 0x2cd6(%rip), %rsi      # 0x52a7
movb $0x0, %al
callq 0x2200
movq -0x18(%rbp), %rax
movq %rax, -0xc0(%rbp)
movslq -0x80(%rbp), %rsi
leaq -0x48(%rbp), %rdi
callq 0x2da0
movq -0xc0(%rbp), %rdi
movl (%rax), %edx
leaq 0x2a1a(%rip), %rsi      # 0x501a
movb $0x0, %al
callq 0x2200
movl -0x80(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x80(%rbp)
jmp 0x259d
movq -0x18(%rbp), %rdi
leaq 0x2b1f(%rip), %rsi      # 0x513c
movb $0x0, %al
callq 0x2200
movq -0x18(%rbp), %rdi
leaq 0x29e8(%rip), %rsi      # 0x5017
movb $0x0, %al
callq 0x2200
movl $0x0, -0x84(%rbp)
movl $0x0, -0x88(%rbp)
movl -0x88(%rbp), %eax
movq -0x8(%rbp), %rcx
cmpl (%rcx), %eax
jge 0x26c2
movq -0x8(%rbp), %rdi
movl -0x88(%rbp), %esi
callq 0x41e0
movq %rax, -0xc8(%rbp)
jmp 0x2670
movq -0xc8(%rbp), %rax
movq %rax, -0x90(%rbp)
movq -0x90(%rbp), %rax
movslq -0xc(%rbp), %rcx
movl 0x40(%rax,%rcx,4), %eax
addl -0x84(%rbp), %eax
movl %eax, -0x84(%rbp)
movq -0x18(%rbp), %rdi
movl -0x84(%rbp), %edx
leaq 0x296f(%rip), %rsi      # 0x5019
movb $0x0, %al
callq 0x2200
movl -0x88(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x88(%rbp)
jmp 0x264a
movq -0x18(%rbp), %rdi
leaq 0x2a6f(%rip), %rsi      # 0x513c
movb $0x0, %al
callq 0x2200
movslq -0x84(%rbp), %rax
movq %rax, -0xd0(%rbp)
leaq -0x30(%rbp), %rdi
callq 0x2d80
movq %rax, %rcx
movq -0xd0(%rbp), %rax
cmpq %rcx, %rax
jne 0x26fc
jmp 0x271b
leaq 0x291a(%rip), %rdi      # 0x501d
leaq 0x2929(%rip), %rsi      # 0x5033
movl $0x3b, %edx
leaq 0x2932(%rip), %rcx      # 0x5048
callq 0x20c0
leaq -0x48(%rbp), %rdi
callq 0x2dc0
leaq -0x30(%rbp), %rdi
callq 0x2dc0
addq $0xd0, %rsp
popq %rbp
retq
movq -0x60(%rbp), %rdi
callq 0x2260
nop