// File: sjtuwrk[P]SunwayMR/tools/SunwayMRHelper.hpp
// Function: SunwayMRHelper::setLocalResouce(int, int)
void SunwayMRHelper::setLocalResouce(int threads, int memory) {

	// send repeatedly
	stringstream ss;
	ss << threads << " " << memory << " " << listenPort;
	stringstream info;
	info << "SunwayMRHelper: set local resource: thread: "
			<< threads << " memory: " << memory
			<< " listenPort: " << listenPort;
	Logging::logInfo(info.str());

	int v = 0;
	struct thread_data *data = new thread_data (*this, ss.str().c_str(), v);

	//pthread_cancel(sendResourceInfoThread);
	if (!xyz_send_host_resource_info_thread_canceled_flag) {
		xyz_send_host_resource_info_thread_cancel_flag = true;
		while (!xyz_send_host_resource_info_thread_canceled_flag);
	}
	int rc = pthread_create(&sendResourceInfoThread, NULL, sendHostResourceInfoToMasterRepeatedly, (void *)data);
	if (rc){
		Logging::logError("SunwayMRHelper: SunwayMRHelper: failed to create thread to send host resource info.");
		exit(1);
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x410, %rsp            # imm = 0x410
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movl %edx, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x3c0(%rbp)
leaq -0x198(%rbp), %rdi
callq 0x4280
leaq -0x188(%rbp), %rdi
movl -0xc(%rbp), %esi
callq 0x4750
movq %rax, -0x3b8(%rbp)
jmp 0xacd4
movq -0x3b8(%rbp), %rdi
leaq 0xf890(%rip), %rsi      # 0x1a572
callq 0x43f0
movq %rax, -0x3c8(%rbp)
jmp 0xacf0
movq -0x3c8(%rbp), %rdi
movl -0x10(%rbp), %esi
callq 0x4750
movq %rax, -0x3d0(%rbp)
jmp 0xad08
movq -0x3d0(%rbp), %rdi
leaq 0xf85c(%rip), %rsi      # 0x1a572
callq 0x43f0
movq %rax, -0x3d8(%rbp)
jmp 0xad24
movq -0x3d8(%rbp), %rdi
movq -0x3c0(%rbp), %rax
movl 0x13c(%rax), %esi
callq 0x4750
jmp 0xad3f
leaq -0x330(%rbp), %rdi
callq 0x4280
jmp 0xad4d
leaq -0x320(%rbp), %rdi
leaq 0xf6d8(%rip), %rsi      # 0x1a433
callq 0x43f0
movq %rax, -0x3e0(%rbp)
jmp 0xad69
movq -0x3e0(%rbp), %rdi
movl -0xc(%rbp), %esi
callq 0x4750
movq %rax, -0x3e8(%rbp)
jmp 0xad81
movq -0x3e8(%rbp), %rdi
leaq 0xf6d1(%rip), %rsi      # 0x1a460
callq 0x43f0
movq %rax, -0x3f0(%rbp)
jmp 0xad9d
movq -0x3f0(%rbp), %rdi
movl -0x10(%rbp), %esi
callq 0x4750
movq %rax, -0x3f8(%rbp)
jmp 0xadb5
movq -0x3f8(%rbp), %rdi
leaq 0xf6a7(%rip), %rsi      # 0x1a46a
callq 0x43f0
movq %rax, -0x400(%rbp)
jmp 0xadd1
movq -0x400(%rbp), %rdi
movq -0x3c0(%rbp), %rax
movl 0x13c(%rax), %esi
callq 0x4750
jmp 0xadec
leaq -0x350(%rbp), %rdi
leaq -0x330(%rbp), %rsi
callq 0x43e0
jmp 0xae01
leaq -0x350(%rbp), %rdi
callq 0x7140
jmp 0xae0f
leaq -0x350(%rbp), %rdi
callq 0x4878
movl $0x0, -0x354(%rbp)
movl $0x18, %edi
callq 0x4400
movq %rax, -0x408(%rbp)
jmp 0xae38
movb $0x1, -0x381(%rbp)
leaq -0x380(%rbp), %rdi
leaq -0x198(%rbp), %rsi
callq 0x43e0
jmp 0xae54
leaq -0x380(%rbp), %rdi
callq 0x4190
movq -0x408(%rbp), %rdi
movq -0x3c0(%rbp), %rsi
movq %rax, %rdx
movl -0x354(%rbp), %ecx
callq 0xf840
jmp 0xae7e
movb $0x0, -0x381(%rbp)
leaq -0x380(%rbp), %rdi
callq 0x4878
movq -0x408(%rbp), %rax
movq %rax, -0x360(%rbp)
testb $0x1, 0x1a5c2(%rip)     # 0x25468
jne 0xaf6c
movb $0x1, 0x1a685(%rip)     # 0x25538
movb 0x1a5af(%rip), %al      # 0x25468
xorb $-0x1, %al
testb $0x1, %al
jne 0xaec4
jmp 0xaf6a
jmp 0xaeb3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x1a0(%rbp)
movl %eax, -0x1a4(%rbp)
jmp 0xb070
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x1a0(%rbp)
movl %eax, -0x1a4(%rbp)
jmp 0xb064
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x1a0(%rbp)
movl %eax, -0x1a4(%rbp)
leaq -0x350(%rbp), %rdi
callq 0x4878
jmp 0xb064
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x1a0(%rbp)
movl %eax, -0x1a4(%rbp)
jmp 0xaf49
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x1a0(%rbp)
movl %eax, -0x1a4(%rbp)
leaq -0x380(%rbp), %rdi
callq 0x4878
testb $0x1, -0x381(%rbp)
jne 0xaf54
jmp 0xaf65
movq -0x408(%rbp), %rdi
movl $0x18, %esi
callq 0x4410
jmp 0xb064
jmp 0xaf6c
movq -0x3c0(%rbp), %rdi
addq $0x190, %rdi            # imm = 0x190
movq -0x360(%rbp), %rcx
xorl %eax, %eax
movl %eax, %esi
leaq -0x11dc(%rip), %rdx     # 0x9db0
callq 0x47c0
movl %eax, -0x388(%rbp)
cmpl $0x0, -0x388(%rbp)
je 0xb043
leaq -0x3a9(%rbp), %rdi
movq %rdi, -0x410(%rbp)
callq 0x47a0
movq -0x410(%rbp), %rdx
leaq 0xf4b3(%rip), %rsi      # 0x1a478
leaq -0x3a8(%rbp), %rdi
callq 0xe8d0
jmp 0xafd3
leaq -0x3a8(%rbp), %rdi
callq 0x7300
jmp 0xafe1
leaq -0x3a8(%rbp), %rdi
callq 0x4878
leaq -0x3a9(%rbp), %rdi
callq 0x4470
movl $0x1, %edi
callq 0x44e0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x1a0(%rbp)
movl %eax, -0x1a4(%rbp)
jmp 0xb035
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x1a0(%rbp)
movl %eax, -0x1a4(%rbp)
leaq -0x3a8(%rbp), %rdi
callq 0x4878
leaq -0x3a9(%rbp), %rdi
callq 0x4470
jmp 0xb064
leaq -0x330(%rbp), %rdi
callq 0x42b0
leaq -0x198(%rbp), %rdi
callq 0x42b0
addq $0x410, %rsp            # imm = 0x410
popq %rbp
retq
leaq -0x330(%rbp), %rdi
callq 0x42b0
leaq -0x198(%rbp), %rdi
callq 0x42b0
movq -0x1a0(%rbp), %rdi
callq 0x4780
nopl (%rax,%rax)