// File: /workspace/github_cpp_makefile_star2_O3/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
movl $0x0, 0x11b59f(%rip)    # 0x124aa0
leaq 0x11b598(%rip), %rdx    # 0x124aa0
xorps %xmm0, %xmm0
leaq 0x30(%rsp), %rsi
movups %xmm0, 0xc(%rsi)
movaps %xmm0, (%rsi)
movl $0xbb8, 0xc(%rsi)       # imm = 0xBB8
leaq 0x2c(%rsp), %rcx
leaq 0x28(%rsp), %r8
movq %rax, %rdi
callq 0x21ea6
movq 0x11b549(%rip), %r13    # 0x124a80
movq 0x11b54a(%rip), %rax    # 0x124a88
cmpq %rax, %r13
sete %cl
leaq 0x8(%r13), %rdi
cmpq %rax, %rdi
sete %dl
orb %cl, %dl
jne 0x95b8
movl $0x8, %ecx
movq %r13, %rdx
movq %rdx, %r8
movq 0x8(%rdx), %rsi
movq %rdi, %rdx
movq %rsi, %rdi
shrq $0x20, %rdi
cmpl %edi, 0x4(%r8)
jge 0x959d
movq %rcx, %r9
movq -0x8(%r13,%r9), %r8
movq %r8, (%r13,%r9)
cmpq $0x8, %r9
je 0x9597
leaq -0x8(%r9), %r8
cmpl %edi, -0xc(%r13,%r9)
movq %r8, %r9
jl 0x9574
addq %r13, %r8
jmp 0x959a
movq %r13, %r8
movq %rsi, (%r8)
leaq 0x8(%rdx), %rdi
addq $0x8, %rcx
cmpq %rax, %rdi
jne 0x955a
movq 0x11b4cf(%rip), %r13    # 0x124a80
movq 0x11b4d0(%rip), %rax    # 0x124a88
cmpq %rax, %r13
je 0x96f6
addq $0x8, %r13
movq 0x339d4(%rip), %r15     # 0x3cfa0
leaq 0x280ed(%rip), %rbp     # 0x316c0
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)
movq -0x8(%r13), %rax
movq %rax, 0xac(%r12)
movl (%rbx), %eax
movl %eax, 0xb4(%r12)
movl $0x2, %edx
movq %r15, %rdi
leaq 0x2809b(%rip), %rsi     # 0x316bf
callq 0x5460
movslq 0xa8(%r14), %rax
movq 0x8(%r14,%rax,8), %rax
movl 0xac(%rax), %esi
leaq 0x8(%rsp), %rdi
callq 0x1754c
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 0x96ca
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 0x96f6
leaq 0x8(%r13), %rax
cmpq 0x11b39b(%rip), %r13    # 0x124a88
movq %rax, %r13
jne 0x95d3
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 0x9724
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x5400
movq %rbx, %rdi
callq 0x5790