// File: /workspace/github_cpp_makefile_star2_O1/ATOMIC-LICHESS[P]ATOMKRAFT/create_book.cpp
// Function: findChildren(MoveTreeNode*, Position&, int*)
void findChildren(MoveTreeNode* node, Position& pos, int* index) {
	searchMoves[0] = MOVE_NONE;

	SearchLimits limits;
	limits.maxTime = MAX_SEARCH_TIME;
    limits.increment = 0;

    Move bestmove, pondermove;

	think(pos, limits, searchMoves, bestmove, pondermove);
	insertion_sort<MoveStack, base::iterator>(book_moves.begin(), book_moves.end());

	for (base::iterator it = book_moves.begin(); it != book_moves.end(); ++it) {

		node->child[node->child_count] = new MoveTreeNode();
		node->child[node->child_count]->parent = node;
		node->child[node->child_count]->child_count = 0;
		node->child[node->child_count]->ms.move = it->move;
		node->child[node->child_count]->ms.score = it->score;
		node->child[node->child_count]->index = *index;

		cout << "  " << move_to_string(node->child[node->child_count]->ms.move) << " "
			 << node->child[node->child_count]->ms.score << endl;

		++(*index);
		++node->child_count;
		if (node->child_count >= MAX_BOOK_BRANCHING) {
			break;
		}
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movq %rdx, %rbx
movq %rsi, %rax
movq %rdi, %r14
xorl %ecx, %ecx
movl %ecx, 0x11aad9(%rip)    # 0x123aa0
leaq 0x11aad2(%rip), %rdx    # 0x123aa0
xorps %xmm0, %xmm0
leaq 0x30(%rsp), %rsi
movups %xmm0, 0xc(%rsi)
movaps %xmm0, (%rsi)
movl $0xbb8, 0xc(%rsi)       # imm = 0xBB8
movl %ecx, 0x4(%rsi)
leaq 0x2c(%rsp), %rcx
leaq 0x28(%rsp), %r8
movq %rax, %rdi
callq 0x219de
movq 0x11aa80(%rip), %rax    # 0x123a80
movq 0x11aa81(%rip), %rcx    # 0x123a88
cmpq %rcx, %rax
sete %dl
leaq 0x8(%rax), %r8
cmpq %rcx, %r8
sete %sil
orb %dl, %sil
jne 0x9074
movl $0x8, %edx
movq %rax, %rsi
movq %rsi, %r9
movq 0x8(%rsi), %rdi
movq %r8, %rsi
movq %rdi, %r8
shrq $0x20, %r8
cmpl %r8d, 0x4(%r9)
jge 0x9067
movq %rdx, %r10
movq -0x8(%rax,%r10), %r9
movq %r9, (%rax,%r10)
cmpq $0x8, %r10
je 0x9061
leaq -0x8(%r10), %r9
cmpl %r8d, -0xc(%rax,%r10)
movq %r9, %r10
jl 0x903f
addq %rax, %r9
jmp 0x9064
movq %rax, %r9
movq %rdi, (%r9)
leaq 0x8(%rsi), %r8
addq $0x8, %rdx
cmpq %rcx, %r8
jne 0x9025
movq 0x11aa05(%rip), %r13    # 0x123a80
cmpq 0x11aa06(%rip), %r13    # 0x123a88
je 0x91c9
addq $0x8, %r13
movq 0x32f0d(%rip), %r15     # 0x3bfa0
leaq 0x275a6(%rip), %rbp     # 0x30640
movl $0xc0, %edi
callq 0x53f0
movq %rax, %r12
movl $0xc0, %edx
movq %rax, %rdi
xorl %esi, %esi
callq 0x5210
movslq 0xa8(%r14), %rax
movq %r12, 0x8(%r14,%rax,8)
movq %r14, (%r12)
movl $0x0, 0xa8(%r12)
movq -0x8(%r13), %rax
movq %rax, 0xac(%r12)
movl (%rbx), %eax
movl %eax, 0xb4(%r12)
movl $0x2, %edx
movq %r15, %rdi
leaq 0x27548(%rip), %rsi     # 0x3063f
callq 0x5460
movslq 0xa8(%r14), %rax
movq 0x8(%r14,%rax,8), %rax
movl 0xac(%rax), %esi
leaq 0x8(%rsp), %rdi
callq 0x16fdc
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rdx
movq %r15, %rdi
callq 0x5460
movq %rax, %r12
movl $0x1, %edx
movq %rax, %rdi
movq %rbp, %rsi
callq 0x5460
movslq 0xa8(%r14), %rax
movq 0x8(%r14,%rax,8), %rax
movl 0xb0(%rax), %esi
movq %r12, %rdi
callq 0x5760
movq %rax, %r12
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r12, %rdi
movl $0xa, %esi
callq 0x53c0
movsbl %al, %esi
movq %r12, %rdi
callq 0x5050
movq %rax, %rdi
callq 0x5270
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x919d
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x5400
incl (%rbx)
movl 0xa8(%r14), %eax
leal 0x1(%rax), %ecx
movl %ecx, 0xa8(%r14)
cmpl $0x12, %eax
jg 0x91c9
leaq 0x8(%r13), %rax
cmpq 0x11a8c8(%rip), %r13    # 0x123a88
movq %rax, %r13
jne 0x909a
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x91f7
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x5400
movq %rbx, %rdi
callq 0x5790