// File: wenleix[P]EdgePPR/src/PPRCommon.cpp
// Function: ReadVector(double*, int, char const*, char const*)
void ReadVector(double *pprValue, int allocSize, const char* filename, const char* suffix) {
	char fullname[1000];
	sprintf(fullname, "%s.%s", filename, suffix);

	if (strcmp(suffix, "txt") == 0) {
		FILE *f = fopen(fullname, "r");
		int numRead = -1;
		int size = 0;
		numRead = fscanf(f, "%d", &size);
		assert(numRead == 1 && size == allocSize);
		for (int i = 0; i < size; i++) {
			numRead = fscanf(f, "%lf", &pprValue[i]);
			assert(numRead == 1);
		}
	} else if (strcmp(suffix, "bin") == 0) {
		FILE *f = fopen(fullname, "rb");
		int numRead;
		int size;
		numRead = fread(&size, sizeof(int), 1, f);
		assert(numRead == 1);
		assert(allocSize == size);
		numRead = fread(pprValue, sizeof(double), size, f);
		assert(numRead == size);
	} else {
		assert(false);
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x440, %rsp            # imm = 0x440
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
leaq -0x410(%rbp), %rdi
movq -0x18(%rbp), %rdx
movq -0x20(%rbp), %rcx
leaq 0x34fc(%rip), %rsi      # 0x84cc
movb $0x0, %al
callq 0x2060
movq -0x20(%rbp), %rdi
leaq 0x3113(%rip), %rsi      # 0x80f5
callq 0x2270
cmpl $0x0, %eax
jne 0x5117
leaq -0x410(%rbp), %rdi
leaq 0x30f1(%rip), %rsi      # 0x80ef
callq 0x2220
movq %rax, -0x418(%rbp)
movl $0xffffffff, -0x41c(%rbp) # imm = 0xFFFFFFFF
movl $0x0, -0x420(%rbp)
movq -0x418(%rbp), %rdi
leaq 0x301c(%rip), %rsi      # 0x8048
leaq -0x420(%rbp), %rdx
movb $0x0, %al
callq 0x2350
movl %eax, -0x41c(%rbp)
xorl %eax, %eax
cmpl $0x1, -0x41c(%rbp)
movb %al, -0x439(%rbp)
jne 0x5063
movl -0x420(%rbp), %eax
cmpl -0xc(%rbp), %eax
sete %al
movb %al, -0x439(%rbp)
movb -0x439(%rbp), %al
testb $0x1, %al
jne 0x506f
jmp 0x5071
jmp 0x5090
leaq 0x345a(%rip), %rdi      # 0x84d2
leaq 0x3475(%rip), %rsi      # 0x84f4
movl $0xa2, %edx
leaq 0x347b(%rip), %rcx      # 0x8506
callq 0x20f0
movl $0x0, -0x424(%rbp)
movl -0x424(%rbp), %eax
cmpl -0x420(%rbp), %eax
jge 0x5112
movq -0x418(%rbp), %rdi
movq -0x8(%rbp), %rdx
movslq -0x424(%rbp), %rax
shlq $0x3, %rax
addq %rax, %rdx
leaq 0x3098(%rip), %rsi      # 0x8160
movb $0x0, %al
callq 0x2350
movl %eax, -0x41c(%rbp)
cmpl $0x1, -0x41c(%rbp)
jne 0x50e0
jmp 0x50ff
leaq 0x345a(%rip), %rdi      # 0x8541
leaq 0x3406(%rip), %rsi      # 0x84f4
movl $0xa5, %edx
leaq 0x340c(%rip), %rcx      # 0x8506
callq 0x20f0
jmp 0x5101
movl -0x424(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x424(%rbp)
jmp 0x509a
jmp 0x5237
movq -0x20(%rbp), %rdi
leaq 0x2fcf(%rip), %rsi      # 0x80f1
callq 0x2270
cmpl $0x0, %eax
jne 0x5216
leaq -0x410(%rbp), %rdi
leaq 0x3410(%rip), %rsi      # 0x854e
callq 0x2220
movq %rax, -0x430(%rbp)
movq -0x430(%rbp), %rcx
leaq -0x438(%rbp), %rdi
movl $0x4, %esi
movl $0x1, %edx
callq 0x22a0
movl %eax, -0x434(%rbp)
cmpl $0x1, -0x434(%rbp)
jne 0x5178
jmp 0x5197
leaq 0x33c2(%rip), %rdi      # 0x8541
leaq 0x336e(%rip), %rsi      # 0x84f4
movl $0xac, %edx
leaq 0x3374(%rip), %rcx      # 0x8506
callq 0x20f0
movl -0xc(%rbp), %eax
cmpl -0x438(%rbp), %eax
jne 0x51a4
jmp 0x51c3
leaq 0x33a6(%rip), %rdi      # 0x8551
leaq 0x3342(%rip), %rsi      # 0x84f4
movl $0xad, %edx
leaq 0x3348(%rip), %rcx      # 0x8506
callq 0x20f0
movq -0x8(%rbp), %rdi
movslq -0x438(%rbp), %rdx
movq -0x430(%rbp), %rcx
movl $0x8, %esi
callq 0x22a0
movl %eax, -0x434(%rbp)
movl -0x434(%rbp), %eax
cmpl -0x438(%rbp), %eax
jne 0x51f5
jmp 0x5214
leaq 0x3367(%rip), %rdi      # 0x8563
leaq 0x32f1(%rip), %rsi      # 0x84f4
movl $0xaf, %edx
leaq 0x32f7(%rip), %rcx      # 0x8506
callq 0x20f0
jmp 0x5235
leaq 0x3356(%rip), %rdi      # 0x8573
leaq 0x32d0(%rip), %rsi      # 0x84f4
movl $0xb1, %edx
leaq 0x32d6(%rip), %rcx      # 0x8506
callq 0x20f0
jmp 0x5237
addq $0x440, %rsp            # imm = 0x440
popq %rbp
retq