// File: wenleix[P]EdgePPR/src/ParamPPR.cpp
// Function: WorkerThread(void*)
void *WorkerThread(void *__conf) {
	ThreadConfig* conf = (ThreadConfig*)__conf;

	fprintf(stdout, "INFO: Thread %d start!\n", conf->threadId);

	double *value = new double[conf->g->numVertex];
	for (int i = conf->start; i < conf->end; i++) {
		int paramId = conf->paramIdx[i];
		double *curParam = conf->params + ParamGraph_NumEdgeTypes * paramId;
		fprintf(stderr, "DEBUG: Param:");
		for (int j = 0; j < ParamGraph_NumEdgeTypes; j++)
			fprintf(stderr, " %.2lf", curParam[j]);
		fprintf(stderr, "\n");

		ParamJacobiSolver(conf->g, conf->pref, value, curParam);

		//	Print out the useful vertices
		char filenameBuf[1000];
		sprintf(filenameBuf, "%s-%d", conf->outputPrefix, paramId);
		WriteVector(value, conf->g->numVertex, filenameBuf, conf->outputFormat);
		fprintf(stderr, "DEBUG: Thread %d finished param %d!\n", conf->threadId, paramId);
	}

	fprintf(stdout, "INFO: Thread %d done!\n", conf->threadId);
	pthread_exit(NULL);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x420, %rsp            # imm = 0x420
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x10(%rbp)
movq 0x9b1a(%rip), %rax      # 0xbfc8
movq (%rax), %rdi
movq -0x10(%rbp), %rax
movl (%rax), %edx
leaq 0x5b5a(%rip), %rsi      # 0x8018
movb $0x0, %al
callq 0x2280
movq -0x10(%rbp), %rax
movq 0x40(%rax), %rax
movslq (%rax), %rax
movl $0x8, %ecx
mulq %rcx
movq %rax, %rdi
seto %cl
movq $-0x1, %rax
testb $0x1, %cl
cmovneq %rax, %rdi
callq 0x2030
movq %rax, -0x18(%rbp)
movq -0x10(%rbp), %rax
movl 0x10(%rax), %eax
movl %eax, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
movq -0x10(%rbp), %rcx
cmpl 0x14(%rcx), %eax
jge 0x263e
movq -0x10(%rbp), %rax
movq 0x30(%rax), %rax
movslq -0x1c(%rbp), %rcx
movl (%rax,%rcx,4), %eax
movl %eax, -0x20(%rbp)
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
imull $0x7, -0x20(%rbp), %ecx
movslq %ecx, %rcx
shlq $0x3, %rcx
addq %rcx, %rax
movq %rax, -0x28(%rbp)
movq 0x9a9e(%rip), %rax      # 0xbfe0
movq (%rax), %rdi
leaq 0x5ae4(%rip), %rsi      # 0x8030
movb $0x0, %al
callq 0x2280
movl $0x0, -0x2c(%rbp)
cmpl $0x7, -0x2c(%rbp)
jge 0x2590
movq 0x9a79(%rip), %rax      # 0xbfe0
movq (%rax), %rdi
movq -0x28(%rbp), %rax
movslq -0x2c(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
leaq 0x5ac0(%rip), %rsi      # 0x803e
movb $0x1, %al
callq 0x2280
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x255a
movq 0x9a49(%rip), %rax      # 0xbfe0
movq (%rax), %rdi
leaq 0x5c06(%rip), %rsi      # 0x81a7
movb $0x0, %al
callq 0x2280
movq -0x10(%rbp), %rax
movq 0x40(%rax), %rdi
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rsi
movq -0x18(%rbp), %rdx
movq -0x28(%rbp), %rcx
movsd 0x5a40(%rip), %xmm0     # 0x8008
callq 0x4ae0
leaq -0x420(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rdx
movl -0x20(%rbp), %ecx
leaq 0x5a5f(%rip), %rsi      # 0x8045
movb $0x0, %al
callq 0x2060
movq -0x18(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x40(%rax), %rax
movl (%rax), %esi
leaq -0x420(%rbp), %rdx
movq -0x10(%rbp), %rax
movq 0x38(%rax), %rcx
callq 0x5240
movq 0x99ca(%rip), %rax      # 0xbfe0
movq (%rax), %rdi
movq -0x10(%rbp), %rax
movl (%rax), %edx
movl -0x20(%rbp), %ecx
leaq 0x5a22(%rip), %rsi      # 0x804b
movb $0x0, %al
callq 0x2280
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x24ff
movq 0x9983(%rip), %rax      # 0xbfc8
movq (%rax), %rdi
movq -0x10(%rbp), %rax
movl (%rax), %edx
leaq 0x5a1b(%rip), %rsi      # 0x8070
movb $0x0, %al
callq 0x2280
xorl %eax, %eax
movl %eax, %edi
callq 0x2310
nopw %cs:(%rax,%rax)