// File: tewalds[P]morat/hex/../lib/agentpool.h
// Function: Morat::AgentThreadPool<Morat::Hex::AgentMCTS>::set_num_threads(unsigned int)
void set_num_threads(unsigned int new_num_threads) { // destroys the existing threads and creates the specified number of new ones
		//start and end with thread_state = Thread_Wait_Start
		assert(thread_state == Thread_Wait_Start);

		//wait for them to all get to the barrier
		assert(CAS(thread_state, Thread_Wait_Start, Thread_Wait_Start_Cancelled));
		run_barrier.wait();

		//make sure they exited cleanly
		for(unsigned int i = 0; i < threads.size(); i++){
			threads[i]->join();
			delete threads[i];
		}

		threads.clear();

		thread_state = Thread_Wait_Start;

		num_threads = new_num_threads;

		run_barrier.reset(num_threads + 1);
		gc_barrier.reset(num_threads);

		//start new threads
		for(unsigned int i = 0; i < num_threads; i++)
			threads.push_back(new typename AgentType::AgentThread(this, agent));

		assert(thread_state == Thread_Wait_Start);
	}

// Assembly:
subq $0x68, %rsp
movq %rdi, 0x60(%rsp)
movl %esi, 0x5c(%rsp)
movq 0x60(%rsp), %rax
movq %rax, 0x28(%rsp)
movl (%rax), %eax
cmpl $0x1, %eax
jne 0x1b790
jmp 0x1b7af
leaq 0x32574(%rip), %rdi     # 0x4dd0b
leaq 0x3258f(%rip), %rsi     # 0x4dd2d
movl $0x7e, %edx
leaq 0x32726(%rip), %rcx     # 0x4ded0
callq 0x52a0
movq 0x28(%rsp), %rdi
movl $0x1, 0x58(%rsp)
movl $0x2, 0x54(%rsp)
leaq 0x58(%rsp), %rsi
leaq 0x54(%rsp), %rdx
callq 0x21c20
testb $0x1, %al
jne 0x1b7d9
jmp 0x1b7db
jmp 0x1b7fa
leaq 0x32764(%rip), %rdi     # 0x4df46
leaq 0x32544(%rip), %rsi     # 0x4dd2d
movl $0x81, %edx
leaq 0x326db(%rip), %rcx     # 0x4ded0
callq 0x52a0
movq 0x28(%rsp), %rdi
addq $0x20, %rdi
callq 0x21b40
movl $0x0, 0x50(%rsp)
movq 0x28(%rsp), %rdi
movl 0x50(%rsp), %eax
movq %rax, 0x20(%rsp)
addq $0x8, %rdi
callq 0x22ce0
movq %rax, %rcx
movq 0x20(%rsp), %rax
cmpq %rcx, %rax
jae 0x1b88c
movq 0x28(%rsp), %rdi
addq $0x8, %rdi
movl 0x50(%rsp), %eax
movl %eax, %esi
callq 0x22d00
movq (%rax), %rdi
callq 0x22d20
movq 0x28(%rsp), %rdi
addq $0x8, %rdi
movl 0x50(%rsp), %eax
movl %eax, %esi
callq 0x22d00
movq (%rax), %rax
movq %rax, 0x18(%rsp)
cmpq $0x0, %rax
je 0x1b87d
movq 0x18(%rsp), %rdi
movq (%rdi), %rax
callq *0x8(%rax)
jmp 0x1b87f
movl 0x50(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x50(%rsp)
jmp 0x1b810
movq 0x28(%rsp), %rdi
addq $0x8, %rdi
callq 0x22d40
movq 0x28(%rsp), %rax
movl $0x1, (%rax)
movl 0x5c(%rsp), %ecx
movl %ecx, 0x4(%rax)
movq %rax, %rdi
addq $0x20, %rdi
movl 0x4(%rax), %esi
addl $0x1, %esi
callq 0x22d60
movq 0x28(%rsp), %rax
movq %rax, %rdi
addq $0x80, %rdi
movl 0x4(%rax), %esi
callq 0x22d60
movl $0x0, 0x4c(%rsp)
movq 0x28(%rsp), %rcx
movl 0x4c(%rsp), %eax
cmpl 0x4(%rcx), %eax
jae 0x1b961
movq 0x28(%rsp), %rax
addq $0x8, %rax
movq %rax, 0x8(%rsp)
movl $0x121e8, %edi          # imm = 0x121E8
callq 0x5400
movq 0x28(%rsp), %rsi
movq %rax, %rdi
movq %rdi, %rax
movq %rax, 0x10(%rsp)
movq 0xe0(%rsi), %rdx
callq 0x22df0
jmp 0x1b921
movq 0x8(%rsp), %rdi
movq 0x10(%rsp), %rax
movq %rax, 0x40(%rsp)
leaq 0x40(%rsp), %rsi
callq 0x22dc0
movl 0x4c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x4c(%rsp)
jmp 0x1b8dd
movq 0x10(%rsp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x38(%rsp)
movl %eax, 0x34(%rsp)
callq 0x53a0
jmp 0x1b993
movq 0x28(%rsp), %rax
movl (%rax), %eax
cmpl $0x1, %eax
jne 0x1b96f
jmp 0x1b98e
leaq 0x32395(%rip), %rdi     # 0x4dd0b
leaq 0x323b0(%rip), %rsi     # 0x4dd2d
movl $0x97, %edx
leaq 0x32547(%rip), %rcx     # 0x4ded0
callq 0x52a0
addq $0x68, %rsp
retq
movq 0x38(%rsp), %rdi
callq 0x5760
nopl (%rax)