// File: tyhsu[P]Ewn/tree_node.cpp
// Function: Tree_node::new_child_nodes()
void Tree_node::new_child_nodes() {
	int legal_child_num = 0;
	// new the legal nodes for children_ptr
	for (int i = 0; i < 18; i++) {
		// check if the movement is legal
		int chs_index = i / 3, direction = i % 3;
		if (!this->game.get_cur_chs_list(chs_index).exist) continue;
		Movement movement(chs_index, direction);
		if (!this->game.check_in_board(movement)) continue;

		// new legal child nodes
		this->children_ptr_list[legal_child_num] = new Tree_node();
		Tree_node* node_ptr = this->children_ptr_list[legal_child_num];
		legal_child_num++;

		// reset the values of the members
		node_ptr->game = this->game;
		node_ptr->game_status = node_ptr->game.update_game_status(movement);
		node_ptr->game.switch_player();
		node_ptr->parent_ptr = this;
	}
	// reset the rest of the children_ptr to NULL
	for (int i = legal_child_num; i < 18; i++)
		this->children_ptr_list[i] = NULL;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x68(%rbp)
movl $0x0, -0xc(%rbp)
movl $0x0, -0x10(%rbp)
cmpl $0x12, -0x10(%rbp)
jge 0x77f5
movq -0x68(%rbp), %rdi
movslq -0x10(%rbp), %rax
imulq $0x55555556, %rax, %rax # imm = 0x55555556
movq %rax, %rcx
shrq $0x3f, %rcx
shrq $0x20, %rax
addl %ecx, %eax
movl %eax, -0x14(%rbp)
movslq -0x10(%rbp), %rcx
movl %ecx, %eax
imulq $0x55555556, %rcx, %rdx # imm = 0x55555556
movq %rdx, %rcx
shrq $0x3f, %rcx
shrq $0x20, %rdx
addl %ecx, %edx
movl %edx, %ecx
leal (%rcx,%rcx,2), %ecx
subl %ecx, %eax
movl %eax, -0x18(%rbp)
addq $0x10, %rdi
leaq -0x14(%rbp), %rsi
callq 0xb810
movl %edx, -0x30(%rbp)
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rax
movq %rax, -0x24(%rbp)
movl -0x30(%rbp), %eax
movl %eax, -0x1c(%rbp)
movb -0x23(%rbp), %al
xorb $-0x1, %al
testb $0x1, %al
jne 0x770c
jmp 0x7711
jmp 0x77cb
leaq -0x40(%rbp), %rdi
leaq -0x14(%rbp), %rsi
leaq -0x18(%rbp), %rdx
callq 0x5c40
movq -0x68(%rbp), %rdi
addq $0x10, %rdi
leaq -0x40(%rbp), %rsi
callq 0xafe0
testb $0x1, %al
jne 0x773c
jmp 0x77cb
movl $0x190, %edi            # imm = 0x190
callq 0x2160
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x70(%rbp)
callq 0x7590
jmp 0x7757
movq -0x68(%rbp), %rsi
movq -0x70(%rbp), %rcx
movslq -0xc(%rbp), %rax
movq %rcx, 0x100(%rsi,%rax,8)
movslq -0xc(%rbp), %rax
movq 0x100(%rsi,%rax,8), %rax
movq %rax, -0x58(%rbp)
movl -0xc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc(%rbp)
addq $0x10, %rsi
movq -0x58(%rbp), %rdi
addq $0x10, %rdi
callq 0xa720
movq -0x58(%rbp), %rdi
addq $0x10, %rdi
leaq -0x40(%rbp), %rsi
callq 0xb120
movl %eax, %ecx
movq -0x58(%rbp), %rax
movl %ecx, 0x8(%rax)
movq -0x58(%rbp), %rdi
addq $0x10, %rdi
callq 0xb440
movq -0x68(%rbp), %rcx
movq -0x58(%rbp), %rax
movq %rcx, 0xf8(%rax)
movl -0x10(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x10(%rbp)
jmp 0x7692
movq -0x70(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
movl $0x190, %esi            # imm = 0x190
callq 0x2170
jmp 0x7826
movl -0xc(%rbp), %eax
movl %eax, -0x5c(%rbp)
cmpl $0x12, -0x5c(%rbp)
jge 0x7820
movq -0x68(%rbp), %rax
movslq -0x5c(%rbp), %rcx
movq $0x0, 0x100(%rax,%rcx,8)
movl -0x5c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x5c(%rbp)
jmp 0x77fb
addq $0x70, %rsp
popq %rbp
retq
movq -0x48(%rbp), %rdi
callq 0x2210
nop