LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_cpp_makefile_star2_O2/ATOMIC-LICHESS[P]ATOMKRAFT/book.cpp
// Function: Book::read_entry(int)
BookEntry Book::read_entry(int idx) {

  assert(idx >= 0 && idx < bookSize);
  assert(bookFile.is_open());

  BookEntry e;

  bookFile.seekg(idx * sizeof(BookEntry), ios_base::beg);

  get_number(e.key);
  get_number(e.move);
  get_number(e.count);
  get_number(e.learn);

  if (!bookFile.good())
  {
      cerr << "Failed to read book entry at index " << idx << endl;
      exit(EXIT_FAILURE);
  }
  return e;
}

// Assembly:
pushq %r14
pushq %rbx
subq $0x18, %rsp
movl %esi, %ebx
movq %rdi, %r14
movslq %esi, %rsi
shlq $0x4, %rsi
xorl %edx, %edx
callq 0x5540
leaq 0x8(%rsp), %rsi
movq %r14, %rdi
callq 0x89ca
leaq 0x10(%rsp), %rsi
movq %r14, %rdi
callq 0x8a0c
leaq 0x12(%rsp), %rsi
movq %r14, %rdi
callq 0x8a0c
leaq 0x14(%rsp), %rsi
movq %r14, %rdi
callq 0x8a4a
movq (%r14), %rax
movq -0x18(%rax), %rax
cmpl $0x0, 0x20(%r14,%rax)
jne 0x878d
movq 0x8(%rsp), %rax
movq 0x10(%rsp), %rdx
addq $0x18, %rsp
popq %rbx
popq %r14
retq
movq 0x2c85c(%rip), %rdi     # 0x34ff0
leaq 0x1fd17(%rip), %rsi     # 0x284b2
callq 0x53b0
movq %rax, %rdi
movl %ebx, %esi
callq 0x5760
movq %rax, %rdi
callq 0x51d0
pushq $0x1
popq %rdi
callq 0x54b0
// File: /workspace/github_cpp_makefile_star2_O2/ATOMIC-LICHESS[P]ATOMKRAFT/book.cpp
// Function: Book::write_entry(unsigned long, Move, unsigned short)
void Book::write_entry(uint64_t key, Move move, uint16_t count) {
	// convert Move to polyglot move
	uint16_t m = make_move(move_from(move), move_to(move)) | (move_promotion_piece(move) << 12);
	uint32_t learn = 0;
	
	write_number(key);
	write_number(m);
	write_number(count);
	write_number(learn);
	
	++bookSize;
	
	if (!bookFile.good()) {
		cerr << "Failed to write book." << endl;
		exit(EXIT_FAILURE);
	}
	
//	bookFile.flush();
//	
//	if (!bookFile.good()) {
//		cerr << "Failed to flush book." << endl;
//		exit(EXIT_FAILURE);
//	}
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdi, %rbx
leaq 0x10(%rsp), %rax
movq %rsi, (%rax)
movl %edx, %esi
andl $0xfff, %esi            # imm = 0xFFF
movl %edx, %edi
andl $0xc000, %edi           # imm = 0xC000
andl $0x3000, %edx           # imm = 0x3000
addl $0x2000, %edx           # imm = 0x2000
xorl %r8d, %r8d
cmpl $0x4000, %edi           # imm = 0x4000
leaq 0xa(%rsp), %r14
cmovel %edx, %r8d
movw %cx, (%r14)
orl %esi, %r8d
leaq 0x8(%rsp), %r15
movw %r8w, (%r15)
leaq 0xc(%rsp), %r12
andl $0x0, (%r12)
movq %rbx, %rdi
movq %rax, %rsi
callq 0x8a82
movq %rbx, %rdi
movq %r15, %rsi
callq 0x8ae0
movq %rbx, %rdi
movq %r14, %rsi
callq 0x8ae0
movq %rbx, %rdi
movq %r12, %rsi
callq 0x8b36
incl 0x230(%rbx)
movq (%rbx), %rax
movq -0x18(%rax), %rax
cmpl $0x0, 0x20(%rbx,%rax)
jne 0x8864
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
movq 0x2c785(%rip), %rdi     # 0x34ff0
leaq 0x1fc64(%rip), %rsi     # 0x284d6
callq 0x53b0
movq %rax, %rdi
callq 0x51d0
pushq $0x1
popq %rdi
callq 0x54b0
nop
// File: /workspace/github_cpp_makefile_star2_O2/ATOMIC-LICHESS[P]ATOMKRAFT/book.cpp
// Function: Book::print_all_moves(Position const&)
void Book::print_all_moves(const Position& pos) {
	  if (!bookFile.is_open() || bookSize == 0) {
		  cout << "book is empty" << endl;
		  return;
	  }
	  

	  BookEntry entry;
	  uint64_t key = book_key(pos);
	  
	  
	  // Choose a book move among the possible moves for the given position
	  for (int idx = find_entry(key); idx < bookSize; idx++)
	  {
	      entry = read_entry(idx);
	      
	      if (entry.key != key)
	          break;
	      
	      cout << "(" << move_to_string(Move(entry.move)) << " " << entry.count << ") ";
	  }
	  cout << endl;

}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rsi, %r14
movq %rdi, %rbx
addq $0x80, %rdi
callq 0x50e0
testb %al, %al
je 0x8965
cmpl $0x0, 0x230(%rbx)
je 0x8965
movq %r14, %rdi
callq 0x82c8
movq %rax, %r14
movq %rbx, %rdi
movq %rax, %rsi
callq 0x86ba
movl %eax, %ebp
leaq 0x8(%rsp), %r13
cmpl 0x230(%rbx), %ebp
jge 0x898e
movq %rbx, %rdi
movl %ebp, %esi
callq 0x871e
cmpq %r14, %rax
jne 0x898e
movq %rdx, %r15
movq 0x2c69d(%rip), %rdi     # 0x34fa0
leaq 0x1fbf0(%rip), %rsi     # 0x284fa
callq 0x53b0
movq %rax, %r12
movzwl %r15w, %esi
movq %r13, %rdi
callq 0x13248
movq %r12, %rdi
movq %r13, %rsi
callq 0x5340
movq %rax, %rdi
leaq 0x1fc2d(%rip), %rsi     # 0x28560
callq 0x53b0
shrl $0x10, %r15d
movq %rax, %rdi
movl %r15d, %esi
callq 0x5720
movq %rax, %rdi
leaq 0x20c28(%rip), %rsi     # 0x29579
callq 0x53b0
movq %r13, %rdi
callq 0x5858
incl %ebp
jmp 0x88da
movq 0x2c634(%rip), %rdi     # 0x34fa0
leaq 0x1fb79(%rip), %rsi     # 0x284ec
callq 0x53b0
movq %rax, %rdi
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x51d0
movq 0x2c60b(%rip), %rdi     # 0x34fa0
callq 0x51d0
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x5858
movq %rbx, %rdi
callq 0x5780
// File: /workspace/github_cpp_makefile_star2_O2/ATOMIC-LICHESS[P]ATOMKRAFT/book.cpp
// Function: void Book::get_number<unsigned long>(unsigned long&)
void Book::get_number(T& n) {

  n = 0;

  for (size_t i = 0; i < sizeof(T); i++) {
      n = (n << 8) + (T)bookFile.get();
      
//      int get = bookFile.get();
//      n = (n << 8) + (T)get;
//      if (sizeof(T) == 8) {
//    	  cout << get << " ";
//      } 
  }
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %rbx
andq $0x0, (%rsi)
movq %rdi, %r14
pushq $0x8
popq %r15
xorl %r12d, %r12d
subq $0x1, %r15
jb 0x89ff
shlq $0x8, %r12
movq %r14, %rdi
callq 0x5490
cltq
addq %rax, %r12
movq %r12, (%rbx)
jmp 0x89e3
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
nop
// File: /workspace/github_cpp_makefile_star2_O2/ATOMIC-LICHESS[P]ATOMKRAFT/./rkiss.h
// Function: RKISS::raninit()
void raninit() {

    s.a = 0xf1ea5eed;
    s.b = s.c = s.d = 0xd4e12c77;
    for (int i = 0; i < 73; i++)
        rand64();
  }

// Assembly:
pushq %rbp
pushq %rbx
pushq %rax
movq %rdi, %rbx
movl $0xd4e12c77, %eax       # imm = 0xD4E12C77
leaq 0x1d093276(%rax), %rcx
movq %rcx, (%rdi)
movq %rax, 0x18(%rdi)
movq %rax, 0x10(%rdi)
movq %rax, 0x8(%rdi)
pushq $0x49
popq %rbp
subl $0x1, %ebp
jb 0x8bc1
movq %rbx, %rdi
callq 0x8bc8
jmp 0x8bb2
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O2/ATOMIC-LICHESS[P]ATOMKRAFT/./rkiss.h
// Function: RKISS::rand64()
uint64_t rand64() {

    const uint64_t
      e = s.a - rotate(s.b,  7);
    s.a = s.b ^ rotate(s.c, 13);
    s.b = s.c + rotate(s.d, 37);
    s.c = s.d + e;
    return s.d = e + s.a;
  }

// Assembly:
movq (%rdi), %rcx
movq 0x8(%rdi), %rdx
movq 0x10(%rdi), %rsi
movq %rsi, %rax
rolq $0xd, %rax
xorq %rdx, %rax
rolq $0x7, %rdx
movq %rax, (%rdi)
movq 0x18(%rdi), %r8
movq %r8, %r9
rolq $0x25, %r9
subq %rdx, %rcx
addq %rsi, %r9
movq %r9, 0x8(%rdi)
addq %rcx, %r8
movq %r8, 0x10(%rdi)
addq %rcx, %rax
movq %rax, 0x18(%rdi)
retq
// File: /workspace/github_cpp_makefile_star2_O2/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
andl $0x0, 0x113e80(%rip)    # 0x11caa0
movq %rsi, %rax
movq %rdi, %r14
leaq 0x113e73(%rip), %rdx    # 0x11caa0
xorps %xmm0, %xmm0
leaq 0x30(%rsp), %rsi
movups %xmm0, 0xc(%rsi)
movaps %xmm0, (%rsi)
movl $0xbb8, 0xc(%rsi)       # imm = 0xBB8
leaq 0xc(%rsp), %rcx
leaq 0x8(%rsp), %r8
movq %rax, %rdi
callq 0x1b60e
movq 0x113e24(%rip), %rdi    # 0x11ca80
movq 0x113e25(%rip), %rsi    # 0x11ca88
callq 0x9b4d
movq 0x113e11(%rip), %r12    # 0x11ca80
leaq 0x10(%rsp), %r13
leaq 0x1f8e5(%rip), %rbp     # 0x28560
cmpq 0x113e06(%rip), %r12    # 0x11ca88
je 0x8d57
movl $0xc0, %edi
callq 0x53d0
movq %rax, %r15
movl $0xc0, %edx
movq %rax, %rdi
xorl %esi, %esi
callq 0x5210
movslq 0xa8(%r14), %rax
movq %r15, 0x8(%r14,%rax,8)
movq %r14, (%r15)
movq (%r12), %rax
movq %rax, 0xac(%r15)
movl (%rbx), %eax
movl %eax, 0xb4(%r15)
movq 0x2c2d2(%rip), %rdi     # 0x34fa0
leaq 0x1f88a(%rip), %rsi     # 0x2855f
callq 0x53b0
movq %rax, %r15
movslq 0xa8(%r14), %rax
movq 0x8(%r14,%rax,8), %rax
movl 0xac(%rax), %esi
movq %r13, %rdi
callq 0x13248
movq %r15, %rdi
movq %r13, %rsi
callq 0x5340
movq %rax, %rdi
movq %rbp, %rsi
callq 0x53b0
movslq 0xa8(%r14), %rcx
movq 0x8(%r14,%rcx,8), %rcx
movl 0xb0(%rcx), %esi
movq %rax, %rdi
callq 0x5760
movq %rax, %rdi
callq 0x51d0
movq %r13, %rdi
callq 0x5858
incl (%rbx)
movl 0xa8(%r14), %eax
leal 0x1(%rax), %ecx
movl %ecx, 0xa8(%r14)
addq $0x8, %r12
cmpl $0x12, %eax
jle 0x8c7b
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0x5858
movq %rbx, %rdi
callq 0x5780
// File: /workspace/github_cpp_makefile_star2_O2/ATOMIC-LICHESS[P]ATOMKRAFT/create_book.cpp
// Function: printTree(MoveTreeNode*)
void printTree(MoveTreeNode* node) {

	if (node->child_count == 0) {
		cout << endl;
		return;
	}

	// print first move
	cout << move_to_string(node->child[0]->ms.move) << " ";
	printTree(node->child[0]);

	// print following moves
	for (int k = 1; k < node->child_count; ++k) {
		// indentation
		for (int s = 0; s < node->depth; ++s) {
			cout << "     ";
		}

		// print moves
		cout << move_to_string(node->child[k]->ms.move) << " ";
		printTree(node->child[k]);
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
cmpl $0x0, 0xa8(%rdi)
je 0x9134
movq %rdi, %rbx
movq 0x8(%rdi), %rax
movl 0xac(%rax), %esi
leaq 0x8(%rsp), %r14
movq %r14, %rdi
callq 0x13248
movq 0x2bf25(%rip), %rdi     # 0x34fa0
movq %r14, %rsi
callq 0x5340
leaq 0x1f4d6(%rip), %rsi     # 0x28560
movq %rax, %rdi
callq 0x53b0
leaq 0x8(%rsp), %r14
movq %r14, %rdi
callq 0x5858
movq 0x8(%rbx), %rdi
callq 0x903f
pushq $0x1
popq %rbp
movq 0x2beee(%rip), %r15     # 0x34fa0
leaq 0x1f4a3(%rip), %r12     # 0x2855c
movslq 0xa8(%rbx), %rax
cmpq %rax, %rbp
jge 0x9125
xorl %r13d, %r13d
cmpl 0xb8(%rbx), %r13d
jge 0x90e1
movq %r15, %rdi
movq %r12, %rsi
callq 0x53b0
incl %r13d
jmp 0x90c8
movq 0x8(%rbx,%rbp,8), %rax
movl 0xac(%rax), %esi
movq %r14, %rdi
callq 0x13248
movq %r15, %rdi
movq %r14, %rsi
callq 0x5340
movq %rax, %rdi
leaq 0x1f457(%rip), %rsi     # 0x28560
callq 0x53b0
movq %r14, %rdi
callq 0x5858
movq 0x8(%rbx,%rbp,8), %rdi
callq 0x903f
incq %rbp
jmp 0x90b9
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x2be65(%rip), %rdi     # 0x34fa0
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x51d0
jmp 0x9150
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x5858
movq %rbx, %rdi
callq 0x5780
// File: /workspace/github_cpp_makefile_star2_O2/ATOMIC-LICHESS[P]ATOMKRAFT/create_book.cpp
// Function: numberOfNodes(MoveTreeNode*)
int numberOfNodes(MoveTreeNode* node) {

	int sum = 0;

	for (int k = 0; k < node->child_count; ++k) {
		sum += numberOfNodes(node->child[k]);
	}

	// node->ms.score was set true or false, false means not playable
	if (node->ms.score) {
		node->ms.score = 1;//sum + 1;	// a move with score 0 will never be played
	}
	return sum + 1;
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
movq %rdi, %rbx
xorl %r14d, %r14d
xorl %ebp, %ebp
movslq 0xa8(%rbx), %rax
cmpq %rax, %r14
jge 0x918e
movq 0x8(%rbx,%r14,8), %rdi
callq 0x9165
addl %eax, %ebp
incq %r14
jmp 0x9171
cmpl $0x0, 0xb0(%rbx)
je 0x91a1
movl $0x1, 0xb0(%rbx)
incl %ebp
movl %ebp, %eax
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O2/ATOMIC-LICHESS[P]ATOMKRAFT/create_book.cpp
// Function: write_entry(_IO_FILE*, unsigned long, Move, unsigned short)
void write_entry(FILE* file, uint64_t key, Move move, uint16_t count) {
	// convert Move to polyglot move
	uint16_t m = make_move(move_from(move), move_to(move)) | (move_promotion_piece(move) << 12);
	uint32_t learn = 0;

	write_number(file, key);
	write_number(file, m);
	write_number(file, count);
	write_number(file, learn);


	if (ferror(file)) {
		cerr << "Failed to write book." << endl;
		exit(EXIT_FAILURE);
	}

//	bookFile.flush();
//
//	if (!bookFile.good()) {
//		cerr << "Failed to flush book." << endl;
//		exit(EXIT_FAILURE);
//	}
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdi, %rbx
leaq 0x10(%rsp), %rax
movq %rsi, (%rax)
movl %edx, %esi
andl $0xfff, %esi            # imm = 0xFFF
movl %edx, %edi
andl $0xc000, %edi           # imm = 0xC000
andl $0x3000, %edx           # imm = 0x3000
addl $0x2000, %edx           # imm = 0x2000
xorl %r8d, %r8d
cmpl $0x4000, %edi           # imm = 0x4000
leaq 0xa(%rsp), %r14
cmovel %edx, %r8d
movw %cx, (%r14)
orl %esi, %r8d
leaq 0x8(%rsp), %r15
movw %r8w, (%r15)
leaq 0xc(%rsp), %r12
andl $0x0, (%r12)
movq %rbx, %rdi
movq %rax, %rsi
callq 0x9ba7
movq %rbx, %rdi
movq %r15, %rsi
callq 0x9bdd
movq %rbx, %rdi
movq %r14, %rsi
callq 0x9bdd
movq %rbx, %rdi
movq %r12, %rsi
callq 0x9c10
movq %rbx, %rdi
callq 0x57e0
testl %eax, %eax
jne 0x924c
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
movq 0x2bd9d(%rip), %rdi     # 0x34ff0
leaq 0x1f27c(%rip), %rsi     # 0x284d6
callq 0x53b0
movq %rax, %rdi
callq 0x51d0
pushq $0x1
popq %rdi
callq 0x54b0
// File: /workspace/github_cpp_makefile_star2_O2/ATOMIC-LICHESS[P]ATOMKRAFT/create_book.cpp
// Function: void write_number<unsigned long>(_IO_FILE*, unsigned long&)
void write_number(FILE* file, T& n) {

	for (size_t i = 0; i < sizeof(T); i++) {
		uint8_t c = uint8_t((n >> ((sizeof(T) - 1) * 8)));
		n <<= 8;
		fputc(c, file);
	}

}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rsi, %rbx
movq %rdi, %r14
pushq $0x8
popq %r15
subq $0x1, %r15
jb 0x9bd7
movq (%rbx), %rax
movq %rax, %rdi
shrq $0x38, %rdi
shlq $0x8, %rax
movq %rax, (%rbx)
movq %r14, %rsi
callq 0x54d0
jmp 0x9bb6
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_cpp_makefile_star2_O2/ATOMIC-LICHESS[P]ATOMKRAFT/debug.cpp
// Function: print_pos(Position const&)
void print_pos(const Position& pos) {
	Piece piece;
	
	cout << "    0   1   2   3   4   5   6   7" << endl;
	cout << "  +---+---+---+---+---+---+---+---+" << endl;
	
	for (int rank = 7; rank >= 0; --rank) {
		cout << rank + 1 << " |";
		for (int file = 0; file < 8; ++file) {
			piece = pos.piece_on(BOARDVTOI[rank][file]);
			if (piece < 0 || piece > 16) {
				cout << "ERROR" << endl;
				return;
			}
			cout << " " << PIECE_NAME[piece] << " |";
		}
		cout << " " << rank << endl;
		cout << "  +---+---+---+---+---+---+---+---+" << endl;
	}
	
	cout << "    a   b   c   d   e   f   g   h" << endl;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %rbx
movq 0x2a74f(%rip), %r14     # 0x34fa0
leaq 0x1ddfe(%rip), %rsi     # 0x28656
movq %r14, %rdi
callq 0x53b0
movq %rax, %rdi
callq 0x51d0
leaq 0x1de09(%rip), %rsi     # 0x28678
movq %r14, %rdi
callq 0x53b0
movq %rax, %rdi
callq 0x51d0
pushq $0x7
popq %r12
leaq 0x1de12(%rip), %rbp     # 0x2869c
leaq 0x1dccf(%rip), %r15     # 0x28560
testl %r12d, %r12d
js 0xa987
movl %r12d, %r14d
shlq $0x5, %r14
movq %r12, (%rsp)
leal 0x1(%r12), %esi
movq 0x2a6ef(%rip), %rdi     # 0x34fa0
callq 0x5760
movq %rax, %rdi
movq %rbp, %rsi
callq 0x53b0
xorl %r13d, %r13d
cmpq $0x8, %r13
je 0xa916
leaq (%r14,%r13,4), %rax
leaq 0x1de6b(%rip), %rcx     # 0x28740
movslq (%rcx,%rax), %rax
movl (%rbx,%rax,4), %r12d
cmpq $0x10, %r12
ja 0xa95e
movq 0x2a6b6(%rip), %rdi     # 0x34fa0
movq %r15, %rsi
callq 0x53b0
leaq 0x1df47(%rip), %rcx     # 0x28840
movsbl (%r12,%rcx), %esi
movq %rax, %rdi
callq 0x5450
movq %rax, %rdi
movq %rbp, %rsi
callq 0x53b0
incq %r13
jmp 0xa8c4
movq 0x2a683(%rip), %r14     # 0x34fa0
movq %r14, %rdi
movq %r15, %rsi
callq 0x53b0
movq %rax, %rdi
movq (%rsp), %r12
movl %r12d, %esi
callq 0x5760
movq %rax, %rdi
callq 0x51d0
movq %r14, %rdi
leaq 0x1dd2f(%rip), %rsi     # 0x28678
callq 0x53b0
movq %rax, %rdi
callq 0x51d0
decl %r12d
jmp 0xa891
leaq 0x1dd3a(%rip), %rsi     # 0x2869f
movq 0x2a634(%rip), %rdi     # 0x34fa0
callq 0x53b0
movq %rax, %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x51d0
leaq 0x1dd17(%rip), %rsi     # 0x286a5
jmp 0xa965
// File: /workspace/github_cpp_makefile_star2_O2/ATOMIC-LICHESS[P]ATOMKRAFT/debug.cpp
// Function: print_bb(unsigned long)
void print_bb(Bitboard bb) {
	Piece piece;
	Piece pieces[64];
	
	for (int k = 0; k < 64; ++k) {
		pieces[k] = PIECE_NONE;
	}
	
	while (bb) {
		pieces[pop_1st_bit(&bb)] = PIECE_NONE_DARK_SQ;
	}
	
	cout << "    0   1   2   3   4   5   6   7" << endl;
	cout << "  +---+---+---+---+---+---+---+---+" << endl;
	
	for (int rank = 7; rank >= 0; --rank) {
		cout << rank + 1 << " |";
		for (int file = 0; file < 8; ++file) {
			piece = pieces[BOARDVTOI[rank][file]];
			if (piece < 0 || piece > 16) {
				cout << "ERROR" << endl;
				return;
			}
			cout << " " << PIECE_NAME[piece] << " |";
		}
		cout << " " << rank << endl;
		cout << "  +---+---+---+---+---+---+---+---+" << endl;
	}
	
	cout << "    a   b   c   d   e   f   g   h" << endl;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x118, %rsp            # imm = 0x118
movq %rdi, (%rsp)
xorl %eax, %eax
cmpq $0x40, %rax
je 0xa9ba
movl $0x10, 0x10(%rsp,%rax,4)
incq %rax
jmp 0xa9a7
movq %rsp, %rbx
testq %rdi, %rdi
je 0xa9d7
movq %rbx, %rdi
callq 0x7b62
cltq
andl $0x0, 0x10(%rsp,%rax,4)
movq (%rsp), %rdi
jmp 0xa9bd
movq 0x2a5c2(%rip), %rbx     # 0x34fa0
leaq 0x1dc71(%rip), %rsi     # 0x28656
movq %rbx, %rdi
callq 0x53b0
movq %rax, %rdi
callq 0x51d0
leaq 0x1dc7c(%rip), %rsi     # 0x28678
movq %rbx, %rdi
callq 0x53b0
movq %rax, %rdi
callq 0x51d0
pushq $0x7
popq %r15
leaq 0x1dc85(%rip), %r13     # 0x2869c
leaq 0x1db42(%rip), %rbp     # 0x28560
leaq 0x1dd1b(%rip), %r14     # 0x28740
testl %r15d, %r15d
js 0xab19
movl %r15d, %r12d
shlq $0x5, %r12
movq %r15, 0x8(%rsp)
leal 0x1(%r15), %esi
movq 0x2a55b(%rip), %rdi     # 0x34fa0
callq 0x5760
movq %rax, %rdi
movq %r13, %rsi
callq 0x53b0
xorl %ebx, %ebx
cmpq $0x8, %rbx
je 0xaaa3
leaq (%r12,%rbx,4), %rax
movslq (%r14,%rax), %rax
movl 0x10(%rsp,%rax,4), %r15d
cmpq $0x10, %r15
ja 0xaaec
movq 0x2a529(%rip), %rdi     # 0x34fa0
movq %rbp, %rsi
callq 0x53b0
leaq 0x1ddba(%rip), %rcx     # 0x28840
movsbl (%r15,%rcx), %esi
movq %rax, %rdi
callq 0x5450
movq %rax, %rdi
movq %r13, %rsi
callq 0x53b0
incq %rbx
jmp 0xaa57
movq 0x2a4f6(%rip), %rbx     # 0x34fa0
movq %rbx, %rdi
movq %rbp, %rsi
callq 0x53b0
movq %rax, %rdi
movq 0x8(%rsp), %r15
movl %r15d, %esi
callq 0x5760
movq %rax, %rdi
callq 0x51d0
movq %rbx, %rdi
leaq 0x1dba1(%rip), %rsi     # 0x28678
callq 0x53b0
movq %rax, %rdi
callq 0x51d0
decl %r15d
jmp 0xaa25
leaq 0x1dbac(%rip), %rsi     # 0x2869f
movq 0x2a4a6(%rip), %rdi     # 0x34fa0
callq 0x53b0
movq %rax, %rdi
callq 0x51d0
addq $0x118, %rsp            # imm = 0x118
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x1db85(%rip), %rsi     # 0x286a5
jmp 0xaaf3
// File: /workspace/github_cpp_makefile_star2_O2/ATOMIC-LICHESS[P]ATOMKRAFT/debug.cpp
// Function: print_castleRights(Position const&)
void print_castleRights(const Position& pos) {
	cout << (pos.can_castle_queenside(BLACK) ? 1 : 0);
	cout << (pos.can_castle_queenside(WHITE) ? 1 : 0);
	cout << (pos.can_castle_kingside(BLACK) ? 1 : 0);
	cout << (pos.can_castle_kingside(WHITE) ? 1 : 0);
	cout << endl;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %r14
movq 0x1938(%rdi), %rax
movl 0x10(%rax), %esi
shrl $0x3, %esi
andl $0x1, %esi
movq 0x2a460(%rip), %rbx     # 0x34fa0
movq %rbx, %rdi
callq 0x5760
movq 0x1938(%r14), %rax
movl 0x10(%rax), %esi
shrl $0x2, %esi
andl $0x1, %esi
movq %rbx, %rdi
callq 0x5760
movq 0x1938(%r14), %rax
movl 0x10(%rax), %esi
shrl %esi
andl $0x1, %esi
movq %rbx, %rdi
callq 0x5760
movq 0x1938(%r14), %rax
movl 0x10(%rax), %esi
andl $0x1, %esi
movq %rbx, %rdi
callq 0x5760
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x51d0
// File: /workspace/github_cpp_makefile_star2_O2/ATOMIC-LICHESS[P]ATOMKRAFT/endgame.cpp
// Function: Endgame<Value, (EndgameType)28>::apply(Position const&) const
Value Endgame<Value, KRPKP_ATOMIC>::apply(const Position& pos) const {
	// there are 6 draw pawn configurations all the others are a win for white
	
#define S(x) (1ULL << (x))
	static const Bitboard draw_pattern_white = 
		S(SQ_A3) | S(SQ_E3) | S(SQ_D3) | S(SQ_H3) | S(SQ_E4) | S(SQ_D4);
	static const Bitboard draw_pattern_black = 
		S(SQ_A6) | S(SQ_E6) | S(SQ_D6) | S(SQ_H6) | S(SQ_E5) | S(SQ_D5);
#undef S
	
	if (strongerSide == WHITE) {
		Bitboard blocked_pawn = pos.pieces(PAWN, WHITE) & draw_pattern_white;
		if ((blocked_pawn << 8) & pos.pieces(PAWN, BLACK)) {
			return VALUE_DRAW;
		}
	} else {
		Bitboard blocked_pawn = pos.pieces(PAWN, BLACK) & draw_pattern_black;
		if ((blocked_pawn >> 8) & pos.pieces(PAWN, WHITE)) {
			return VALUE_DRAW;
		}
	}
	
	// TODO: this is not always true
	return strongerSide == pos.side_to_move() ? VALUE_KNOWN_WIN : -VALUE_KNOWN_WIN;
}

// Assembly:
movl 0x8(%rdi), %eax
movq 0x108(%rsi), %rcx
testl %eax, %eax
je 0xb2e4
movq 0x148(%rsi), %rdx
andq %rcx, %rdx
andq 0x140(%rsi), %rcx
shrq $0x8, %rdx
andq %rdx, %rcx
movabsq $0x9918000000, %rdx     # imm = 0x9918000000
jmp 0xb304
movl 0x140(%rsi), %edx
andl %ecx, %edx
andq 0x148(%rsi), %rcx
shlq $0x8, %rdx
andq %rdx, %rcx
movabsq $0x1899000000, %rdx     # imm = 0x1899000000
testq %rdx, %rcx
je 0xb30c
xorl %eax, %eax
retq
cmpl 0x1090(%rsi), %eax
movl $0x3a98, %ecx           # imm = 0x3A98
movl $0xffffc568, %eax       # imm = 0xFFFFC568
cmovel %ecx, %eax
retq
// File: /workspace/github_cpp_makefile_star2_O2/ATOMIC-LICHESS[P]ATOMKRAFT/endgame.cpp
// Function: Endgame<Value, (EndgameType)6>::apply(Position const&) const
Value Endgame<Value, KQKR>::apply(const Position& pos) const {

  assert(pos.non_pawn_material(strongerSide) == QueenValueMidgame);
  assert(pos.piece_count(strongerSide, PAWN) == 0);
  assert(pos.non_pawn_material(weakerSide) == RookValueMidgame);
  assert(pos.piece_count(weakerSide, PAWN) == 0);

  Square winnerKSq = pos.king_square(strongerSide);
  Square loserKSq = pos.king_square(weakerSide);

  Value result =  QueenValueEndgame
                - RookValueEndgame
                + MateTable[loserKSq]
                + DistanceBonus[square_distance(winnerKSq, loserKSq)];

  return strongerSide == pos.side_to_move() ? result : -result;
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
movq %rsi, %rbx
movq %rdi, %r14
movl 0x8(%rdi), %eax
movl 0xc(%rdi), %ecx
shlq $0x9, %rax
movl 0x310(%rsi,%rax), %edi
shlq $0x9, %rcx
leaq 0x29eda(%rip), %rax     # 0x3546c
movl (%rax), %ebp
leaq 0x29ec9(%rip), %rax     # 0x35464
subl (%rax), %ebp
movslq 0x310(%rsi,%rcx), %rsi
leaq 0x1d474(%rip), %rax     # 0x28a20
addl (%rax,%rsi,4), %ebp
callq 0x75ec
cltq
leaq 0x1d583(%rip), %rcx     # 0x28b40
addl (%rcx,%rax,4), %ebp
movl 0x8(%r14), %ecx
movl %ebp, %eax
negl %eax
cmpl 0x1090(%rbx), %ecx
cmovel %ebp, %eax
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O2/ATOMIC-LICHESS[P]ATOMKRAFT/endgame.cpp
// Function: Endgame<ScaleFactor, (EndgameType)11>::apply(Position const&) const
ScaleFactor Endgame<ScaleFactor, KQKRPs>::apply(const Position& pos) const {

  assert(pos.non_pawn_material(strongerSide) == QueenValueMidgame);
  assert(pos.piece_count(strongerSide, QUEEN) == 1);
  assert(pos.piece_count(strongerSide, PAWN) == 0);
  assert(pos.piece_count(weakerSide, ROOK) == 1);
  assert(pos.piece_count(weakerSide, PAWN) >= 1);

  Square kingSq = pos.king_square(weakerSide);
  if (   relative_rank(weakerSide, kingSq) <= RANK_2
      && relative_rank(weakerSide, pos.king_square(strongerSide)) >= RANK_4
      && (pos.pieces(ROOK, weakerSide) & rank_bb(relative_rank(weakerSide, RANK_3)))
      && (pos.pieces(PAWN, weakerSide) & rank_bb(relative_rank(weakerSide, RANK_2)))
      && (pos.attacks_from<KING>(kingSq) & pos.pieces(PAWN, weakerSide)))
  {
      Square rsq = pos.piece_list(weakerSide, ROOK, 0);
      if (pos.attacks_from<PAWN>(rsq, strongerSide) & pos.pieces(PAWN, weakerSide))
          return SCALE_FACTOR_ZERO;
  }
  return SCALE_FACTOR_NONE;
}

// Assembly:
pushq %rbx
movl 0xc(%rdi), %r9d
movslq %r9d, %rcx
movq %r9, %rax
shlq $0x9, %rax
movslq 0x310(%rsi,%rax), %rdx
movl %edx, %r10d
sarl $0x3, %r10d
imulq $0x7, %rcx, %r8
xorl %r8d, %r10d
cmpl $0x1, %r10d
jg 0xb7b4
leaq 0x190(%rsi), %rcx
movl 0x8(%rdi), %edi
movq %rdi, %r10
shlq $0x9, %r10
movl 0x180(%rcx,%r10), %r10d
sarl $0x3, %r10d
xorl %r8d, %r10d
cmpl $0x3, %r10d
jl 0xb7b4
movq 0x120(%rsi), %r11
movq 0x140(%rsi,%r9,8), %r9
movq %r8, %rbx
xorq $0x2, %rbx
leaq 0x105eac(%rip), %r10    # 0x111610
andq (%r10,%rbx,8), %r11
testq %r9, %r11
je 0xb7b4
andq 0x108(%rsi), %r9
xorl $0x1, %r8d
movslq %r8d, %rsi
testq %r9, (%r10,%rsi,8)
je 0xb7b4
leaq 0x105fc8(%rip), %rsi    # 0x111750
testq %r9, 0xc00(%rsi,%rdx,8)
je 0xb7b4
leal 0x1(,%rdi,8), %edx
shlq $0x9, %rdx
addq 0x29834(%rip), %rdx     # 0x34fd8
movslq 0x100(%rcx,%rax), %rcx
xorl %eax, %eax
testq %r9, (%rdx,%rcx,8)
jne 0xb7b9
movl $0xff, %eax
popq %rbx
retq
nop
// File: /workspace/github_cpp_makefile_star2_O2/ATOMIC-LICHESS[P]ATOMKRAFT/endgame.cpp
// Function: Endgame<ScaleFactor, (EndgameType)13>::apply(Position const&) const
ScaleFactor Endgame<ScaleFactor, KRPPKRP>::apply(const Position& pos) const {

  assert(pos.non_pawn_material(strongerSide) == RookValueMidgame);
  assert(pos.piece_count(strongerSide, PAWN) == 2);
  assert(pos.non_pawn_material(weakerSide) == RookValueMidgame);
  assert(pos.piece_count(weakerSide, PAWN) == 1);

  Square wpsq1 = pos.piece_list(strongerSide, PAWN, 0);
  Square wpsq2 = pos.piece_list(strongerSide, PAWN, 1);
  Square bksq = pos.king_square(weakerSide);

  // Does the stronger side have a passed pawn?
  if (   pos.pawn_is_passed(strongerSide, wpsq1)
      || pos.pawn_is_passed(strongerSide, wpsq2))
      return SCALE_FACTOR_NONE;

  Rank r = Max(relative_rank(strongerSide, wpsq1), relative_rank(strongerSide, wpsq2));

  if (   file_distance(bksq, wpsq1) <= 1
      && file_distance(bksq, wpsq2) <= 1
      && relative_rank(strongerSide, bksq) > r)
  {
      switch (r) {
      case RANK_2: return ScaleFactor(10);
      case RANK_3: return ScaleFactor(10);
      case RANK_4: return ScaleFactor(15);
      case RANK_5: return ScaleFactor(20);
      case RANK_6: return ScaleFactor(40);
      default: assert(false);
      }
  }
  return SCALE_FACTOR_NONE;
}

// Assembly:
movl 0x8(%rdi), %ecx
movq %rcx, %rdx
shlq $0x9, %rdx
movslq 0x1d0(%rsi,%rdx), %r8
movq %rcx, %rax
xorq $0x1, %rax
movq 0x140(%rsi,%rax,8), %r10
andq 0x108(%rsi), %r10
leaq 0x10fe73(%rip), %r11    # 0x11bb50
addq %rdx, %r11
movl $0xff, %eax
testq %r10, (%r11,%r8,8)
je 0xbd75
movslq 0x1d4(%rsi,%rdx), %r9
testq %r10, (%r11,%r9,8)
je 0xbd75
movl 0xc(%rdi), %edx
shlq $0x9, %rdx
movl 0x310(%rsi,%rdx), %edx
movl %r8d, %edi
sarl $0x3, %edi
imull $0x7, %ecx, %esi
xorl %esi, %edi
movl %r9d, %ecx
sarl $0x3, %ecx
xorl %esi, %ecx
cmpl %ecx, %edi
cmovgl %edi, %ecx
movl %edx, %edi
andl $0x7, %edi
andl $0x7, %r8d
movl %edi, %r10d
subl %r8d, %r10d
movl %r10d, %r8d
negl %r8d
cmovsl %r10d, %r8d
cmpl $0x1, %r8d
ja 0xbd75
andl $0x7, %r9d
subl %r9d, %edi
movl %edi, %r8d
negl %r8d
cmovsl %edi, %r8d
cmpl $0x1, %r8d
ja 0xbd75
sarl $0x3, %edx
xorl %esi, %edx
cmpl %ecx, %edx
jle 0xbd75
decl %ecx
cmpl $0x4, %ecx
ja 0xbd75
movl %ecx, %eax
leaq 0x1cdae(%rip), %rcx     # 0x28b20
movl (%rcx,%rax,4), %eax
retq
// File: /workspace/github_cpp_makefile_star2_O2/ATOMIC-LICHESS[P]ATOMKRAFT/endgame.cpp
// Function: Endgame<ScaleFactor, (EndgameType)14>::apply(Position const&) const
ScaleFactor Endgame<ScaleFactor, KPsK>::apply(const Position& pos) const {

  assert(pos.non_pawn_material(strongerSide) == VALUE_ZERO);
  assert(pos.piece_count(strongerSide, PAWN) >= 2);
  assert(pos.non_pawn_material(weakerSide) == VALUE_ZERO);
  assert(pos.piece_count(weakerSide, PAWN) == 0);

  Square ksq = pos.king_square(weakerSide);
  Bitboard pawns = pos.pieces(PAWN, strongerSide);

  // Are all pawns on the 'a' file?
  if ((pawns & ~FileABB) == EmptyBoardBB)
  {
      // Does the defending king block the pawns?
      if (   square_distance(ksq, relative_square(strongerSide, SQ_A8)) <= 1
          || (   square_file(ksq) == FILE_A
              && (in_front_bb(strongerSide, ksq) & pawns) == EmptyBoardBB))
          return SCALE_FACTOR_ZERO;
  }
  // Are all pawns on the 'h' file?
  else if ((pawns & ~FileHBB) == EmptyBoardBB)
  {
    // Does the defending king block the pawns?
    if (   square_distance(ksq, relative_square(strongerSide, SQ_H8)) <= 1
        || (   square_file(ksq) == FILE_H
            && (in_front_bb(strongerSide, ksq) & pawns) == EmptyBoardBB))
        return SCALE_FACTOR_ZERO;
  }
  return SCALE_FACTOR_NONE;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rdi, %r14
movl 0x8(%rdi), %eax
movl 0xc(%rdi), %ecx
shlq $0x9, %rcx
movl 0x310(%rsi,%rcx), %ebx
movq 0x140(%rsi,%rax,8), %r15
andq 0x108(%rsi), %r15
movabsq $-0x101010101010102, %rcx # imm = 0xFEFEFEFEFEFEFEFE
testq %rcx, %r15
je 0xbddd
movabsq $0x7f7f7f7f7f7f7f7f, %rcx # imm = 0x7F7F7F7F7F7F7F7F
testq %rcx, %r15
jne 0xbe13
imull $0x38, %eax, %esi
xorl $0x3f, %esi
movl %ebx, %edi
callq 0x75ec
movl %eax, %ecx
xorl %eax, %eax
cmpl $0x2, %ecx
jl 0xbe18
movl %ebx, %ecx
notl %ecx
testb $0x7, %cl
je 0xbdf8
jmp 0xbe13
imull $0x38, %eax, %esi
xorl $0x38, %esi
movl %ebx, %edi
callq 0x75ec
movl %eax, %ecx
xorl %eax, %eax
cmpl $0x2, %ecx
jl 0xbe18
testb $0x7, %bl
jne 0xbe13
movl 0x8(%r14), %ecx
sarl $0x3, %ebx
movslq %ebx, %rdx
shlq $0x6, %rcx
addq 0x2913b(%rip), %rcx     # 0x34f48
testq %r15, (%rcx,%rdx,8)
je 0xbe18
movl $0xff, %eax
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_cpp_makefile_star2_O2/ATOMIC-LICHESS[P]ATOMKRAFT/endgame.cpp
// Function: Endgame<ScaleFactor, (EndgameType)17>::apply(Position const&) const
ScaleFactor Endgame<ScaleFactor, KBPKN>::apply(const Position& pos) const {

  assert(pos.non_pawn_material(strongerSide) == BishopValueMidgame);
  assert(pos.piece_count(strongerSide, BISHOP) == 1);
  assert(pos.piece_count(strongerSide, PAWN) == 1);
  assert(pos.non_pawn_material(weakerSide) == KnightValueMidgame);
  assert(pos.piece_count(weakerSide, KNIGHT) == 1);
  assert(pos.piece_count(weakerSide, PAWN) == 0);

  Square pawnSq = pos.piece_list(strongerSide, PAWN, 0);
  Square strongerBishopSq = pos.piece_list(strongerSide, BISHOP, 0);
  Square weakerKingSq = pos.king_square(weakerSide);

  if (   square_file(weakerKingSq) == square_file(pawnSq)
      && relative_rank(strongerSide, pawnSq) < relative_rank(strongerSide, weakerKingSq)
      && (   opposite_color_squares(weakerKingSq, strongerBishopSq)
          || relative_rank(strongerSide, weakerKingSq) <= RANK_6))
      return SCALE_FACTOR_ZERO;

  return SCALE_FACTOR_NONE;
}

// Assembly:
movl 0x8(%rdi), %r8d
movl 0xc(%rdi), %edx
movq %r8, %rcx
shlq $0x9, %rcx
movl 0x1d0(%rsi,%rcx), %eax
shlq $0x9, %rdx
movl 0x310(%rsi,%rdx), %edx
movl %edx, %edi
xorl %eax, %edi
testb $0x7, %dil
jne 0xc150
sarl $0x3, %eax
imull $0x7, %r8d, %r8d
xorl %r8d, %eax
movl %edx, %edi
sarl $0x3, %edi
xorl %r8d, %edi
cmpl %edi, %eax
jge 0xc150
xorl %eax, %eax
cmpl $0x6, %edi
jl 0xc155
xorl 0x250(%rsi,%rcx), %edx
movl %edx, %ecx
shrl $0x3, %ecx
xorl %edx, %ecx
andl $0x1, %ecx
jne 0xc155
movl $0xff, %eax
retq
// File: /workspace/github_cpp_makefile_star2_O2/ATOMIC-LICHESS[P]ATOMKRAFT/endgame.cpp
// Function: Endgame<ScaleFactor, (EndgameType)18>::apply(Position const&) const
ScaleFactor Endgame<ScaleFactor, KNPK>::apply(const Position& pos) const {

  assert(pos.non_pawn_material(strongerSide) == KnightValueMidgame);
  assert(pos.piece_count(strongerSide, KNIGHT) == 1);
  assert(pos.piece_count(strongerSide, PAWN) == 1);
  assert(pos.non_pawn_material(weakerSide) == VALUE_ZERO);
  assert(pos.piece_count(weakerSide, PAWN) == 0);

  Square pawnSq = pos.piece_list(strongerSide, PAWN, 0);
  Square weakerKingSq = pos.king_square(weakerSide);

  if (   pawnSq == relative_square(strongerSide, SQ_A7)
      && square_distance(weakerKingSq, relative_square(strongerSide, SQ_A8)) <= 1)
      return SCALE_FACTOR_ZERO;

  if (   pawnSq == relative_square(strongerSide, SQ_H7)
      && square_distance(weakerKingSq, relative_square(strongerSide, SQ_H8)) <= 1)
      return SCALE_FACTOR_ZERO;

  return SCALE_FACTOR_NONE;
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
movq %rsi, %rax
movl 0x8(%rdi), %ecx
movl 0xc(%rdi), %edx
imull $0x38, %ecx, %esi
shlq $0x9, %rcx
movl 0x1d0(%rax,%rcx), %r14d
shlq $0x9, %rdx
movl 0x310(%rax,%rdx), %ebp
movl %esi, %eax
xorl %r14d, %eax
cmpl $0x30, %eax
jne 0xc19d
movq %rdi, %rbx
xorl $0x38, %esi
movl %ebp, %edi
callq 0x75ec
cmpl $0x2, %eax
jl 0xc1b5
imull $0x38, 0x8(%rbx), %esi
xorl %esi, %r14d
cmpl $0x37, %r14d
jne 0xc1b9
xorl $0x3f, %esi
movl %ebp, %edi
callq 0x75ec
cmpl $0x2, %eax
jge 0xc1b9
xorl %eax, %eax
jmp 0xc1be
movl $0xff, %eax
popq %rbx
popq %r14
popq %rbp
retq
nop
// File: /workspace/github_cpp_makefile_star2_O2/ATOMIC-LICHESS[P]ATOMKRAFT/endgame.cpp
// Function: Endgame<ScaleFactor, (EndgameType)19>::apply(Position const&) const
ScaleFactor Endgame<ScaleFactor, KPKP>::apply(const Position& pos) const {

  assert(pos.non_pawn_material(strongerSide) == VALUE_ZERO);
  assert(pos.non_pawn_material(weakerSide) == VALUE_ZERO);
  assert(pos.piece_count(WHITE, PAWN) == 1);
  assert(pos.piece_count(BLACK, PAWN) == 1);

  Square wksq, bksq, wpsq;
  Color stm;

  if (strongerSide == WHITE)
  {
      wksq = pos.king_square(WHITE);
      bksq = pos.king_square(BLACK);
      wpsq = pos.piece_list(WHITE, PAWN, 0);
      stm = pos.side_to_move();
  }
  else
  {
      wksq = flip_square(pos.king_square(BLACK));
      bksq = flip_square(pos.king_square(WHITE));
      wpsq = flip_square(pos.piece_list(BLACK, PAWN, 0));
      stm = opposite_color(pos.side_to_move());
  }

  if (square_file(wpsq) >= FILE_E)
  {
      wksq = flop_square(wksq);
      bksq = flop_square(bksq);
      wpsq = flop_square(wpsq);
  }

  // If the pawn has advanced to the fifth rank or further, and is not a
  // rook pawn, it's too dangerous to assume that it's at least a draw.
  if (   square_rank(wpsq) >= RANK_5
      && square_file(wpsq) != FILE_A)
      return SCALE_FACTOR_NONE;

  // Probe the KPK bitbase with the weakest side's pawn removed. If it's a
  // draw, it's probably at least a draw even with the pawn.
  return probe_kpk_bitbase(wksq, wpsq, bksq, stm) ? SCALE_FACTOR_NONE : SCALE_FACTOR_ZERO;
}

// Assembly:
cmpl $0x0, 0x8(%rdi)
je 0xc1f6
movl 0x510(%rsi), %r8d
xorl $0x38, %r8d
movl 0x310(%rsi), %r9d
movl 0x3d0(%rsi), %r10d
xorl $0x38, %r9d
xorl $0x38, %r10d
movl 0x1090(%rsi), %ecx
xorl $0x1, %ecx
jmp 0xc211
movl 0x1d0(%rsi), %r10d
movl 0x310(%rsi), %r8d
movl 0x510(%rsi), %r9d
movl 0x1090(%rsi), %ecx
movl %r10d, %esi
xorl $0x7, %esi
testb $0x4, %r10b
cmovel %r10d, %esi
cmpl $0x20, %esi
setge %dl
testb $0x7, %sil
setne %dil
movl $0xff, %eax
testb %dil, %dl
jne 0xc265
pushq %rax
movl %r9d, %edx
xorl $0x7, %edx
movl %r8d, %edi
xorl $0x7, %edi
testb $0x4, %r10b
cmovel %r9d, %edx
cmovel %r8d, %edi
callq 0x7614
movl %eax, %ecx
testl %eax, %eax
movl $0xff, %eax
cmovel %ecx, %eax
addq $0x8, %rsp
retq
// File: /workspace/github_cpp_makefile_star2_O2/ATOMIC-LICHESS[P]ATOMKRAFT/endgame.cpp
// Function: (anonymous namespace)::mat_key(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&)
Key mat_key(const string& keyCode) {

    assert(keyCode.length() > 0 && keyCode.length() < 8);
    assert(keyCode[0] == 'K');

    string fen;
    size_t i = 0;

    // First add white and then black pieces
    do fen += keyCode[i];                while (keyCode[++i] != 'K');
    do fen += char(tolower(keyCode[i])); while (++i < keyCode.length());

    // Add file padding and remaining empty ranks
    fen += string(1, '0' + int(8 - keyCode.length())) + "/8/8/8/8/8/8/8 w - -";

    // Build a Position out of the fen string and get its material key
    return Position(fen, false, 0).get_material_key();
  }

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x1980, %rsp           # imm = 0x1980
movq %rdi, %rbx
leaq 0x10(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb $0x0, (%rax)
movq (%rdi), %rax
movb (%rax), %al
xorl %r15d, %r15d
movq %rsp, %r14
movsbl %al, %esi
movq %r14, %rdi
callq 0x5320
movq (%rbx), %rax
movb 0x1(%rax,%r15), %al
incq %r15
cmpb $0x4b, %al
jne 0xc291
movq %rsp, %r14
movq (%rbx), %rax
movsbl (%rax,%r15), %edi
callq 0x55b0
movsbl %al, %esi
movq %r14, %rdi
callq 0x5320
incq %r15
movq 0x8(%rbx), %rax
cmpq %rax, %r15
jb 0xc2ae
movb $0x38, %cl
subb %al, %cl
leaq 0x30(%rsp), %rax
movq %rax, -0x10(%rax)
movsbl %cl, %edx
leaq 0x20(%rsp), %rdi
pushq $0x1
popq %rsi
callq 0x5440
leaq 0x1c70e(%rip), %rdx     # 0x28a04
leaq 0x40(%rsp), %rdi
leaq 0x20(%rsp), %rsi
callq 0xd16d
movq %rsp, %rdi
leaq 0x40(%rsp), %rsi
callq 0x5830
leaq 0x40(%rsp), %rdi
callq 0x5858
leaq 0x20(%rsp), %rdi
callq 0x5858
leaq 0x40(%rsp), %rdi
movq %rsp, %rsi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0x173dc
movq 0x1978(%rsp), %rax
movq 0x8(%rax), %rbx
movq %rsp, %rdi
callq 0x5858
movq %rbx, %rax
addq $0x1980, %rsp           # imm = 0x1980
popq %rbx
popq %r14
popq %r15
retq
jmp 0xc37f
movq %rax, %rbx
leaq 0x40(%rsp), %rdi
callq 0x5858
jmp 0xc36f
movq %rax, %rbx
leaq 0x20(%rsp), %rdi
callq 0x5858
jmp 0xc382
jmp 0xc37f
jmp 0xc37f
movq %rax, %rbx
movq %rsp, %rdi
callq 0x5858
movq %rbx, %rdi
callq 0x5780
// File: /workspace/github_cpp_makefile_star2_O2/ATOMIC-LICHESS[P]ATOMKRAFT/endgame.cpp
// Function: void Endgames::add<Endgame<Value, (EndgameType)8>>(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&)
void Endgames::add(const string& keyCode) {

  typedef typename T::Base F;
  typedef std::map<Key, F*> M;

  const_cast<M&>(get<F>()).insert(std::pair<Key, F*>(mat_key(keyCode), new T(WHITE)));
  const_cast<M&>(get<F>()).insert(std::pair<Key, F*>(mat_key(swap_colors(keyCode)), new T(BLACK)));
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rsi, %r14
movq %rdi, %rbx
movq %rsi, %rdi
callq 0xc266
movq %rax, %r15
pushq $0x10
popq %rdi
callq 0x53d0
leaq 0x283cf(%rip), %r12     # 0x34820
movq %r12, (%rax)
movabsq $0x100000000, %rcx      # imm = 0x100000000
movq %rcx, 0x8(%rax)
leaq 0x8(%rsp), %rsi
movq %r15, (%rsi)
movq %rax, 0x8(%rsi)
movq %rbx, %rdi
callq 0xcfe0
leaq 0x8(%rsp), %r15
movq %r15, %rdi
movq %r14, %rsi
callq 0xc392
movq %r15, %rdi
callq 0xc266
movq %rax, %r14
pushq $0x10
popq %rdi
callq 0x53d0
movq %r12, (%rax)
movq $0x1, 0x8(%rax)
leaq 0x28(%rsp), %rsi
movq %r14, (%rsi)
movq %rax, 0x8(%rsi)
movq %rbx, %rdi
callq 0xcfe0
leaq 0x8(%rsp), %rdi
callq 0x5858
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
jmp 0xc4d0
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x5858
movq %rbx, %rdi
callq 0x5780
nop
// File: /workspace/github_cpp_makefile_star2_O2/ATOMIC-LICHESS[P]ATOMKRAFT/evaluate.cpp
// Function: (anonymous namespace)::weight_option(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, Score)
Score weight_option(const std::string& mgOpt, const std::string& egOpt, Score internalWeight) {

    // Scale option value from 100 to 256
    int mg = Options[mgOpt].value<int>() * 256 / 100;
    int eg = Options[egOpt].value<int>() * 256 / 100;

    return apply_weight(make_score(mg, eg), internalWeight);
  }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movl %edx, %ebx
movq %rsi, %r14
movq %rdi, %rsi
leaq 0x3b70bf(%rip), %r15    # 0x3c6078
movq %r15, %rdi
callq 0x11dbc
movq %rax, %rdi
callq 0x11e28
shll $0x8, %eax
pushq $0x64
popq %r12
cltd
idivl %r12d
movl %eax, %ebp
movq %r15, %rdi
movq %r14, %rsi
callq 0x11dbc
movq %rax, %rdi
callq 0x11e28
shll $0x8, %eax
cltd
idivl %r12d
shll $0x10, %ebp
addl %eax, %ebp
movl %ebp, %edi
movl %ebx, %esi
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x1116c
// File: /workspace/github_cpp_makefile_star2_O2/ATOMIC-LICHESS[P]ATOMKRAFT/evaluate.cpp
// Function: void (anonymous namespace)::init_eval_info<(Color)0, false>(Position const&, (anonymous namespace)::EvalInfo&)
void init_eval_info(const Position& pos, EvalInfo& ei) {

    const BitCountType Max15 = HasPopCnt ? CNT_POPCNT : CpuIs64Bit ? CNT64_MAX15 : CNT32_MAX15;
    const Color Them = (Us == WHITE ? BLACK : WHITE);

    Bitboard b = ei.attackedBy[Them][KING] = pos.attacks_from<KING>(pos.king_square(Them));
    ei.attackedBy[Us][PAWN] = ei.pi->pawn_attacks(Us);
    
    STARTNEW
    // init halfOpenFiles for minor pieces
	// this is done analog to pi->halfOpenFiles
    ei.halfOpenFiles_mp[WHITE] = ei.halfOpenFiles_mp[BLACK] = 0xFF;
    
    Square s;
    
    const Square* ptr = pos.piece_list_begin(Us, KNIGHT);
    while ((s = *ptr++) != SQ_NONE) {
		ei.halfOpenFiles_mp[Us] &= ~(1 << square_file(s));
    }
    
    ptr = pos.piece_list_begin(Us, BISHOP);
    while ((s = *ptr++) != SQ_NONE) {
		ei.halfOpenFiles_mp[Us] &= ~(1 << square_file(s));
    }
    ENDNEW

    // Init king safety tables only if we are going to use them
    if (   pos.piece_count(Us, QUEEN)
        && pos.non_pawn_material(Us) >= QueenValueMidgame + RookValueMidgame)
    {
        ei.kingZone[Us] = (b | (Us == WHITE ? b >> 8 : b << 8));
        b &= ei.attackedBy[Us][PAWN];
        ei.kingAttackersCount[Us] = b ? count_1s<Max15>(b) / 2 : 0;
        ei.kingAdjacentZoneAttacksCount[Us] = ei.kingAttackersWeight[Us] = 0;
    } else
        ei.kingZone[Us] = ei.kingAttackersCount[Us] = 0;
  }

// Assembly:
pushq %rbx
movq %rsi, %rbx
movq %rdi, %rax
movslq 0x510(%rdi), %rcx
leaq 0x10058a(%rip), %rdx    # 0x111750
movq 0xc00(%rdx,%rcx,8), %rcx
movq %rcx, 0x80(%rsi)
movq 0x8(%rsi), %rdx
movq 0x18(%rdx), %rdi
movq %rdi, 0x18(%rsi)
movabsq $0xff000000ff, %rdx     # imm = 0xFF000000FF
movq %rdx, 0xb8(%rsi)
leaq 0x210(%rax), %rsi
movl $0xff, %edx
movl (%rsi), %r8d
cmpl $0x40, %r8d
je 0x1121b
addq $0x4, %rsi
andb $0x7, %r8b
btrl %r8d, %edx
movl %edx, 0xb8(%rbx)
jmp 0x111fe
leaq 0x250(%rax), %rsi
movl (%rsi), %r8d
cmpl $0x40, %r8d
je 0x1123f
addq $0x4, %rsi
andb $0x7, %r8b
btrl %r8d, %edx
movl %edx, 0xb8(%rbx)
jmp 0x11222
cmpl $0x0, 0x164(%rax)
je 0x11266
movq 0x1938(%rax), %rax
leaq 0x24212(%rip), %rdx     # 0x35468
leaq 0x24203(%rip), %rsi     # 0x35460
movl (%rsi), %esi
addl (%rdx), %esi
cmpl %esi, 0x28(%rax)
jge 0x11277
andl $0x0, 0xa0(%rbx)
andq $0x0, 0x90(%rbx)
jmp 0x112b0
movq %rcx, %rax
shrq $0x8, %rax
orq %rcx, %rax
movq %rax, 0x90(%rbx)
andq %rcx, %rdi
je 0x1129a
callq 0x122c5
pushq $0x2
popq %rcx
cltd
idivl %ecx
jmp 0x1129c
xorl %eax, %eax
movl %eax, 0xa0(%rbx)
andl $0x0, 0xa8(%rbx)
andl $0x0, 0xb0(%rbx)
popq %rbx
retq
// File: /workspace/github_cpp_makefile_star2_O2/ATOMIC-LICHESS[P]ATOMKRAFT/evaluate.cpp
// Function: (anonymous namespace)::scale_by_game_phase(Score const&, Phase, ScaleFactor)
Value scale_by_game_phase(const Score& v, Phase ph, ScaleFactor sf) {

    assert(mg_value(v) > -VALUE_INFINITE && mg_value(v) < VALUE_INFINITE);
    assert(eg_value(v) > -VALUE_INFINITE && eg_value(v) < VALUE_INFINITE);
    assert(ph >= PHASE_ENDGAME && ph <= PHASE_MIDGAME);

    int ev = (eg_value(v) * int(sf)) / SCALE_FACTOR_NORMAL;
    int result = (mg_value(v) * int(ph) + ev * int(128 - ph)) / 128;
    return Value((result + GrainSize / 2) & ~(GrainSize - 1));
  }

// Assembly:
movl (%rdi), %ecx
movl %ecx, %eax
andl $0x7fff, %eax           # imm = 0x7FFF
movl $0x8000, %edi           # imm = 0x8000
movl %ecx, %r8d
andl %edi, %r8d
subl %r8d, %eax
imull %edx, %eax
pushq $0x40
popq %r8
cltd
idivl %r8d
addl %edi, %ecx
sarl $0x10, %ecx
imull %esi, %ecx
movl $0x80, %edi
movl $0x80, %edx
subl %esi, %edx
imull %edx, %eax
addl %ecx, %eax
cltd
idivl %edi
addl $0x4, %eax
andl $-0x8, %eax
retq
nop
// File: /workspace/github_cpp_makefile_star2_O2/ATOMIC-LICHESS[P]ATOMKRAFT/./material.h
// Function: MaterialInfo::scale_factor(Position const&, Color) const
inline ScaleFactor MaterialInfo::scale_factor(const Position& pos, Color c) const {

  if (!scalingFunction[c])
      return ScaleFactor(factor[c]);

  ScaleFactor sf = scalingFunction[c]->apply(pos);
  return sf == SCALE_FACTOR_NONE ? ScaleFactor(factor[c]) : sf;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
movl %edx, %r14d
movq 0x18(%rdi,%r14,8), %rdi
testq %rdi, %rdi
je 0x122b7
movq (%rdi), %rax
callq *0x18(%rax)
cmpl $0xff, %eax
jne 0x122bd
movzbl 0xa(%rbx,%r14), %eax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_cpp_makefile_star2_O2/ATOMIC-LICHESS[P]ATOMKRAFT/./bitcount.h
// Function: int count_1s<(BitCountType)3>(unsigned long)
inline int count_1s<CNT32_MAX15>(Bitboard b) {
  unsigned w = unsigned(b >> 32), v = unsigned(b);
  v -= (v >> 1) & 0x55555555; // 0-2 in 2 bits
  w -= (w >> 1) & 0x55555555;
  v = ((v >> 2) & 0x33333333) + (v & 0x33333333); // 0-4 in 4 bits
  w = ((w >> 2) & 0x33333333) + (w & 0x33333333);
  v += w; // 0-8 in 4 bits
  v *= 0x11111111;
  return int(v >> 28);
}

// Assembly:
movq %rdi, %rax
shrq $0x20, %rax
movl %edi, %ecx
shrl %ecx
movl $0x55555555, %edx       # imm = 0x55555555
andl %edx, %ecx
movl %edi, %esi
subl %ecx, %esi
shrq $0x21, %rdi
andl %edx, %edi
subl %edi, %eax
movl %esi, %ecx
shrl $0x2, %ecx
movl $0x33333333, %edx       # imm = 0x33333333
andl %edx, %ecx
andl %edx, %esi
movl %eax, %edi
shrl $0x2, %edi
andl %edx, %edi
andl %edx, %eax
addl %esi, %eax
addl %ecx, %eax
addl %edi, %eax
imull $0x11111111, %eax, %eax # imm = 0x11111111
shrl $0x1c, %eax
retq
// File: /workspace/github_cpp_makefile_star2_O2/ATOMIC-LICHESS[P]ATOMKRAFT/main_uci.cpp
// Function: main_uci(int)
void main_uci(int argc) {

	if (argc < 2)
	{
		// Print copyright notice
		//cout << engine_name() << " by " << engine_authors() << endl;

		//if (CpuHasPOPCNT)
		//	cout << "Good! CPU has hardware POPCNT." << endl;

		// Wait for a command from the user, and passes this command to
		// execute_uci_command() and also intercepts EOF from stdin to
		// ensure that we exit gracefully if the GUI dies unexpectedly.
		string cmd;
		while (getline(cin, cmd) && execute_uci_command(cmd)) {}
	}

	Threads.exit();
}

// Assembly:
pushq %r14
pushq %rbx
subq $0x28, %rsp
cmpl $0x1, %edi
jg 0x126a8
leaq 0x18(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb $0x0, (%rax)
movq 0x2295c(%rip), %rbx     # 0x34fd0
leaq 0x8(%rsp), %r14
movq %rbx, %rdi
movq %r14, %rsi
callq 0x50c0
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x1269e
movq %r14, %rdi
callq 0x23178
testb %al, %al
jne 0x12679
leaq 0x8(%rsp), %rdi
callq 0x5858
leaq 0x3a73e1(%rip), %rdi    # 0x3b9a90
callq 0x21f02
addq $0x28, %rsp
popq %rbx
popq %r14
retq
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x5858
movq %rbx, %rdi
callq 0x5780
nopl (%rax)
// File: /workspace/github_cpp_makefile_star2_O2/ATOMIC-LICHESS[P]ATOMKRAFT/./tt.h
// Function: SimpleHash<MaterialInfo, 8192>::init()
void init() {

    if (entries)
        return;

    entries = new (std::nothrow) Entry[HashSize];
    if (!entries)
    {
        std::cerr << "Failed to allocate " << HashSize * sizeof(Entry)
                  << " bytes for hash table." << std::endl;
        exit(EXIT_FAILURE);
    }
    memset(entries, 0, HashSize * sizeof(Entry));
  }

// Assembly:
pushq %rbx
cmpq $0x0, 0x8(%rdi)
je 0x1298e
popq %rbx
retq
movq %rdi, %rbx
movq 0x225a8(%rip), %rsi     # 0x34f40
movl $0x60000, %edi          # imm = 0x60000
callq 0x56f0
movq %rax, 0x8(%rbx)
testq %rax, %rax
je 0x129bb
movl $0x60000, %edx          # imm = 0x60000
movq %rax, %rdi
xorl %esi, %esi
popq %rbx
jmp 0x5210
movq 0x2262e(%rip), %rdi     # 0x34ff0
leaq 0x16aec(%rip), %rsi     # 0x294b5
callq 0x53b0
movl $0x60000, %esi          # imm = 0x60000
movq %rax, %rdi
callq 0x50f0
leaq 0x16ae7(%rip), %rsi     # 0x294c9
movq %rax, %rdi
callq 0x53b0
movq %rax, %rdi
callq 0x51d0
pushq $0x1
popq %rdi
callq 0x54b0