LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_cpp_makefile_star2_O1/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 %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movl %ecx, %ebp
movq %rsi, %r14
movq %rdi, %rbx
movl %edx, %eax
andl $0xfff, %eax            # imm = 0xFFF
movl %edx, %ecx
andl $0xc000, %ecx           # imm = 0xC000
andl $0x3000, %edx           # imm = 0x3000
addl $0x2000, %edx           # imm = 0x2000
xorl %r15d, %r15d
cmpl $0x4000, %ecx           # imm = 0x4000
cmovel %edx, %r15d
orl %eax, %r15d
movl $0x8, %r12d
movq %r14, %rdi
shrq $0x38, %rdi
shlq $0x8, %r14
movq %rbx, %rsi
callq 0x5500
decq %r12
jne 0x9795
movl $0x1, %r14d
movzwl %r15w, %edi
shrl $0x8, %edi
shll $0x8, %r15d
movq %rbx, %rsi
callq 0x5500
decq %r14
je 0x97b3
movl $0x1, %r14d
movzwl %bp, %edi
shrl $0x8, %edi
shll $0x8, %ebp
movq %rbx, %rsi
callq 0x5500
decq %r14
je 0x97d1
movl $0x4, %r14d
xorl %edi, %edi
movq %rbx, %rsi
callq 0x5500
decq %r14
jne 0x97ed
movq %rbx, %rdi
callq 0x5810
testl %eax, %eax
jne 0x9811
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movq 0x327d8(%rip), %rdi     # 0x3bff0
leaq 0x26d77(%rip), %rsi     # 0x30596
callq 0x53d0
movq %rax, %rdi
callq 0x51c0
movl $0x1, %edi
callq 0x54e0
// File: /workspace/github_cpp_makefile_star2_O1/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
subq $0x18, %rsp
movq %rdi, %r14
movq 0x311ac(%rip), %rbx     # 0x3bfa0
leaq 0x2593b(%rip), %rsi     # 0x30736
movl $0x21, %edx
movq %rbx, %rdi
callq 0x5460
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x53c0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x5050
movq %rax, %rdi
callq 0x5270
leaq 0x25922(%rip), %rsi     # 0x30758
movl $0x23, %edx
movq %rbx, %rdi
callq 0x5460
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x53c0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x5050
movq %rax, %rdi
callq 0x5270
movl $0x7, %r15d
leaq 0x25905(%rip), %r13     # 0x3077c
movl %r15d, %r12d
shlq $0x5, %r12
movq %r15, 0x10(%rsp)
leal 0x1(%r15), %esi
movq %rbx, %rdi
callq 0x5760
movl $0x2, %edx
movq %rax, %rdi
movq %r13, %rsi
callq 0x5460
xorl %r15d, %r15d
leaq (%r12,%r15,4), %rax
leaq 0x25973(%rip), %rcx     # 0x30820
movslq (%rcx,%rax), %rax
movl (%r14,%rax,4), %ebp
cmpq $0x11, %rbp
jae 0xafb5
movl $0x1, %edx
movq %rbx, %rdi
leaq 0x25772(%rip), %rsi     # 0x30640
callq 0x5460
leaq 0x25a46(%rip), %rax     # 0x30920
movb (%rbp,%rax), %al
movb %al, 0xf(%rsp)
movl $0x1, %edx
movq %rbx, %rdi
leaq 0xf(%rsp), %rsi
callq 0x5460
movl $0x2, %edx
movq %rax, %rdi
movq %r13, %rsi
callq 0x5460
incq %r15
cmpq $0x8, %r15
jne 0xaea2
movl $0x1, %edx
movq %rbx, %rdi
leaq 0x25724(%rip), %rsi     # 0x30640
callq 0x5460
movq %rbx, %rdi
movq 0x10(%rsp), %r15
movl %r15d, %esi
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
movl $0x23, %edx
movq %rbx, %rdi
leaq 0x257ee(%rip), %rsi     # 0x30758
callq 0x5460
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x53c0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x5050
movq %rax, %rdi
callq 0x5270
subl $0x1, %r15d
jae 0xae77
movq 0x30ff9(%rip), %rdi     # 0x3bfa0
leaq 0x257d7(%rip), %rsi     # 0x30785
movl $0x21, %edx
jmp 0xafc8
movq 0x30fe4(%rip), %rdi     # 0x3bfa0
leaq 0x257bc(%rip), %rsi     # 0x3077f
movl $0x5, %edx
callq 0x5460
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x53c0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x5050
movq %rax, %rdi
callq 0x5270
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O1/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 0x30d12(%rip), %rbx     # 0x3bfa0
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), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x53c0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x5050
movq %rax, %rdi
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x5270
// File: /workspace/github_cpp_makefile_star2_O1/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 0xbe14
movq 0x148(%rsi), %rdx
andq %rcx, %rdx
andq 0x140(%rsi), %rcx
shrq $0x8, %rdx
andq %rdx, %rcx
movabsq $0x9918000000, %rdx     # imm = 0x9918000000
jmp 0xbe34
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 0xbe3c
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_O1/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:
movl 0x8(%rdi), %ecx
movl 0xc(%rdi), %edx
movq %rcx, %rax
shlq $0x9, %rax
movl 0x310(%rsi,%rax), %eax
shlq $0x9, %rdx
movslq 0x310(%rsi,%rdx), %rdi
leaq 0x30305(%rip), %rdx     # 0x3c46c
movl (%rdx), %edx
leaq 0x302f4(%rip), %r8      # 0x3c464
subl (%r8), %edx
leaq 0x24986(%rip), %r8      # 0x30b00
addl (%r8,%rdi,4), %edx
movl %eax, %r8d
andl $0x7, %r8d
movl %edi, %r9d
andl $0x7, %r9d
subl %r9d, %r8d
movl %r8d, %r9d
negl %r9d
cmovsl %r8d, %r9d
sarl $0x3, %eax
sarl $0x3, %edi
subl %edi, %eax
movl %eax, %edi
negl %edi
cmovsl %eax, %edi
cmpl %edi, %r9d
cmoval %r9d, %edi
leaq 0x24a6a(%rip), %rax     # 0x30c20
addl (%rax,%rdi,4), %edx
movl %edx, %eax
negl %eax
cmpl 0x1090(%rsi), %ecx
cmovel %edx, %eax
retq
nop
// File: /workspace/github_cpp_makefile_star2_O1/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, %rdx
movq %r9, %rax
shlq $0x9, %rax
movslq 0x310(%rsi,%rax), %rcx
movl %ecx, %r10d
sarl $0x3, %r10d
leaq (,%rdx,8), %r8
subq %rdx, %r8
xorl %r8d, %r10d
cmpl $0x1, %r10d
jg 0xc3b7
leaq 0x190(%rsi), %rdx
movl 0x8(%rdi), %edi
movq %rdi, %r10
shlq $0x9, %r10
movl 0x180(%rdx,%r10), %r10d
sarl $0x3, %r10d
xorl %r8d, %r10d
cmpl $0x3, %r10d
jl 0xc3b7
movq 0x120(%rsi), %r11
movq 0x140(%rsi,%r9,8), %r9
movq %r8, %rbx
xorq $0x2, %rbx
leaq 0x10c2a9(%rip), %r10    # 0x118610
andq (%r10,%rbx,8), %r11
testq %r9, %r11
je 0xc3b7
andq 0x108(%rsi), %r9
xorl $0x1, %r8d
movslq %r8d, %rsi
testq %r9, (%r10,%rsi,8)
je 0xc3b7
leaq 0x10c3c5(%rip), %rsi    # 0x118750
testq %r9, 0xc00(%rsi,%rcx,8)
je 0xc3b7
leal 0x1(,%rdi,8), %ecx
shlq $0x9, %rcx
addq 0x2fc31(%rip), %rcx     # 0x3bfd8
movslq 0x100(%rdx,%rax), %rdx
xorl %eax, %eax
testq %r9, (%rcx,%rdx,8)
jne 0xc3bc
movl $0xff, %eax
popq %rbx
retq
// File: /workspace/github_cpp_makefile_star2_O1/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), %edx
movq %rdx, %rcx
shlq $0x9, %rcx
movslq 0x1d0(%rsi,%rcx), %r8
movq %rdx, %rax
xorq $0x1, %rax
movq 0x140(%rsi,%rax,8), %r10
andq 0x108(%rsi), %r10
leaq 0x11624b(%rip), %r11    # 0x122b50
addq %rcx, %r11
movl $0xff, %eax
testq %r10, (%r11,%r8,8)
je 0xc9a3
movslq 0x1d4(%rsi,%rcx), %r9
testq %r10, (%r11,%r9,8)
je 0xc9a3
movl 0xc(%rdi), %ecx
shlq $0x9, %rcx
movl 0x310(%rsi,%rcx), %ecx
movl %r8d, %edi
sarl $0x3, %edi
leal (,%rdx,8), %esi
subl %edx, %esi
xorl %esi, %edi
movl %r9d, %edx
sarl $0x3, %edx
xorl %esi, %edx
cmpl %edx, %edi
cmovgl %edi, %edx
movl %ecx, %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 0xc9a3
andl $0x7, %r9d
subl %r9d, %edi
movl %edi, %r8d
negl %r8d
cmovsl %edi, %r8d
cmpl $0x1, %r8d
ja 0xc9a3
sarl $0x3, %ecx
xorl %esi, %ecx
cmpl %edx, %ecx
jle 0xc9a3
decl %edx
cmpl $0x4, %edx
ja 0xc9a3
movl %edx, %eax
leaq 0x24260(%rip), %rcx     # 0x30c00
movl (%rcx,%rax,4), %eax
retq
// File: /workspace/github_cpp_makefile_star2_O1/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:
movl 0x8(%rdi), %ecx
movl 0xc(%rdi), %eax
shlq $0x9, %rax
movl 0x310(%rsi,%rax), %edi
movq 0x140(%rsi,%rcx,8), %rdx
andq 0x108(%rsi), %rdx
movabsq $-0x101010101010102, %rax # imm = 0xFEFEFEFEFEFEFEFE
testq %rax, %rdx
je 0xca2b
movabsq $0x7f7f7f7f7f7f7f7f, %rax # imm = 0x7F7F7F7F7F7F7F7F
testq %rax, %rdx
jne 0xca73
imull $0x38, %ecx, %eax
movl %edi, %esi
andl $0x7, %esi
leal -0x7(%rsi), %r8d
movl %r8d, %r9d
negl %r9d
cmovsl %r8d, %r9d
sarl $0x3, %edi
sarl $0x3, %eax
xorl $0x7, %eax
movl %edi, %r8d
subl %eax, %r8d
movl %r8d, %r10d
negl %r10d
cmovsl %r8d, %r10d
cmpl %r10d, %r9d
cmoval %r9d, %r10d
xorl %eax, %eax
cmpl $0x2, %r10d
jb 0xca78
cmpl $0x7, %esi
je 0xca5f
jmp 0xca73
imull $0x38, %ecx, %eax
movl %edi, %esi
andl $0x7, %esi
sarl $0x3, %edi
sarl $0x3, %eax
xorl $0x7, %eax
movl %edi, %r8d
subl %eax, %r8d
movl %r8d, %r9d
negl %r9d
cmovsl %r8d, %r9d
cmpl %r9d, %esi
cmoval %esi, %r9d
xorl %eax, %eax
cmpl $0x2, %r9d
jb 0xca78
testl %esi, %esi
jne 0xca73
movslq %edi, %rsi
shlq $0x6, %rcx
addq 0x2f4c3(%rip), %rcx     # 0x3bf30
testq %rdx, (%rcx,%rsi,8)
je 0xca78
movl $0xff, %eax
retq
nop
// File: /workspace/github_cpp_makefile_star2_O1/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 0xce67
sarl $0x3, %eax
leal (,%r8,8), %r9d
subl %r8d, %r9d
xorl %r9d, %eax
movl %edx, %edi
sarl $0x3, %edi
xorl %r9d, %edi
cmpl %edi, %eax
jge 0xce67
xorl %eax, %eax
cmpl $0x6, %edi
jl 0xce6c
xorl 0x250(%rsi,%rcx), %edx
movl %edx, %ecx
shrl $0x3, %ecx
xorl %edx, %ecx
andl $0x1, %ecx
jne 0xce6c
movl $0xff, %eax
retq
nop
// File: /workspace/github_cpp_makefile_star2_O1/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:
movl 0x8(%rdi), %eax
movl 0xc(%rdi), %edx
imull $0x38, %eax, %ecx
movq %rax, %rdi
shlq $0x9, %rdi
shlq $0x9, %rdx
movl 0x310(%rsi,%rdx), %eax
movl 0x1d0(%rsi,%rdi), %edx
xorl %ecx, %edx
cmpl $0x30, %edx
jne 0xcec6
movl %eax, %esi
andl $0x7, %esi
movl %eax, %edi
sarl $0x3, %edi
movl %ecx, %r8d
sarl $0x3, %r8d
xorl $0x7, %r8d
subl %r8d, %edi
movl %edi, %r8d
negl %r8d
cmovsl %edi, %r8d
cmpl %r8d, %esi
cmoval %esi, %r8d
cmpl $0x2, %r8d
jb 0xcef6
cmpl $0x37, %edx
jne 0xcef9
movl %eax, %edx
andl $0x7, %edx
addl $-0x7, %edx
movl %edx, %esi
negl %esi
cmovsl %edx, %esi
sarl $0x3, %eax
sarl $0x3, %ecx
xorl $0x7, %ecx
subl %ecx, %eax
movl %eax, %ecx
negl %ecx
cmovsl %eax, %ecx
cmpl %ecx, %esi
cmoval %esi, %ecx
cmpl $0x2, %ecx
jae 0xcef9
xorl %eax, %eax
retq
movl $0xff, %eax
retq
nop
// File: /workspace/github_cpp_makefile_star2_O1/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 0xcf32
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 0xcf4d
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 0xcfa1
pushq %rax
movl %r9d, %edx
xorl $0x7, %edx
movl %r8d, %edi
xorl $0x7, %edi
testb $0x4, %r10b
cmovel %r9d, %edx
cmovel %r8d, %edi
callq 0x7760
movl %eax, %ecx
testl %eax, %eax
movl $0xff, %eax
cmovel %ecx, %eax
addq $0x8, %rsp
retq
// File: /workspace/github_cpp_makefile_star2_O1/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 %r13
pushq %r12
pushq %rbx
subq $0x1980, %rsp           # imm = 0x1980
movq %rdi, %rbx
leaq 0x10(%rsp), %r15
movq %r15, -0x10(%r15)
movq $0x0, -0x8(%r15)
movb $0x0, (%r15)
xorl %r13d, %r13d
movq %rsp, %r14
movq (%rbx), %rax
movsbl (%rax,%r13), %esi
movq %r14, %rdi
callq 0x5330
leaq 0x1(%r13), %r12
movq (%rbx), %rax
cmpb $0x4b, 0x1(%rax,%r13)
movq %r12, %r13
jne 0xcfd0
movq %rsp, %r14
movq (%rbx), %rax
movsbl (%rax,%r12), %edi
callq 0x55d0
movsbl %al, %esi
movq %r14, %rdi
callq 0x5330
incq %r12
movq 0x8(%rbx), %rax
cmpq %rax, %r12
jb 0xcff5
movb $0x38, %cl
subb %al, %cl
leaq 0x30(%rsp), %r14
movq %r14, -0x10(%r14)
movsbl %cl, %edx
leaq 0x20(%rsp), %rdi
movl $0x1, %esi
callq 0x5480
leaq 0x23aa5(%rip), %rsi     # 0x30ae4
leaq 0x20(%rsp), %rdi
callq 0x5820
leaq 0x50(%rsp), %r12
movq %r12, -0x10(%r12)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0xd071
movq %rdx, 0x40(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x50(%rsp)
jmp 0xd079
movups (%rcx), %xmm0
movups %xmm0, (%r12)
movq 0x8(%rax), %rdx
movq %rdx, 0x48(%rsp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
movq 0x40(%rsp), %rsi
movq 0x48(%rsp), %rdx
movq %rsp, %rdi
callq 0x5130
movq 0x40(%rsp), %rdi
cmpq %r12, %rdi
je 0xd0ba
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x5400
movq 0x20(%rsp), %rdi
cmpq %r14, %rdi
je 0xd0d1
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x5400
leaq 0x40(%rsp), %rdi
movq %rsp, %rsi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0x1c7c2
movq 0x1978(%rsp), %rax
movq 0x8(%rax), %rbx
movq (%rsp), %rdi
cmpq %r15, %rdi
je 0xd104
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x5400
movq %rbx, %rax
addq $0x1980, %rsp           # imm = 0x1980
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
jmp 0xd156
movq %rax, %rbx
movq 0x40(%rsp), %rdi
cmpq %r12, %rdi
je 0xd139
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x5400
jmp 0xd139
movq %rax, %rbx
movq 0x20(%rsp), %rdi
cmpq %r14, %rdi
je 0xd159
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x5400
jmp 0xd159
jmp 0xd156
jmp 0xd156
movq %rax, %rbx
movq (%rsp), %rdi
cmpq %r15, %rdi
je 0xd16f
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x5400
movq %rbx, %rdi
callq 0x5790
// File: /workspace/github_cpp_makefile_star2_O1/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 0xcfa2
movq %rax, %r15
movl $0x10, %edi
callq 0x53f0
leaq 0x2e4f3(%rip), %r12     # 0x3b808
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 0xe104
leaq 0x8(%rsp), %r15
movq %r15, %rdi
movq %r14, %rsi
callq 0xd177
movq %r15, %rdi
callq 0xcfa2
movq %rax, %r14
movl $0x10, %edi
callq 0x53f0
movq %r12, (%rax)
movq $0x1, 0x8(%rax)
leaq 0x28(%rsp), %rsi
movq %r14, (%rsi)
movq %rax, 0x8(%rsi)
movq %rbx, %rdi
callq 0xe104
leaq 0x18(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0xd399
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x5400
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
jmp 0xd3a7
movq %rax, %rbx
leaq 0x18(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0xd3c5
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x5400
movq %rbx, %rdi
callq 0x5790
nop
// File: /workspace/github_cpp_makefile_star2_O1/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 %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movl %edx, %ebx
movq %rsi, %r14
movq %rdi, %rsi
leaq 0x3bbe79(%rip), %r15    # 0x3cd078
movq %r15, %rdi
callq 0x155b0
movq 0x20(%rax), %rdi
callq 0x5660
shll $0x8, %eax
cltq
imulq $0x51eb851f, %rax, %r12 # imm = 0x51EB851F
movq %r12, %rax
shrq $0x3f, %rax
shrq $0x25, %r12
addl %eax, %r12d
movq %r15, %rdi
movq %r14, %rsi
callq 0x155b0
movq 0x20(%rax), %rdi
callq 0x5660
shll $0x8, %eax
cltq
imulq $0x51eb851f, %rax, %rcx # imm = 0x51EB851F
movq %rcx, %rax
shrq $0x3f, %rax
sarq $0x25, %rcx
addl %eax, %ecx
shll $0x10, %r12d
movl $0x8000, %esi           # imm = 0x8000
addl %ecx, %r12d
addl %esi, %r12d
sarl $0x10, %r12d
leal (%rbx,%rsi), %edi
sarl $0x10, %edi
imull %r12d, %edi
movl $0xff, %edx
leal (%rdi,%rdx), %eax
testl %edi, %edi
cmovnsl %edi, %eax
movl $0x7fff, %edi           # imm = 0x7FFF
movl %ecx, %r8d
andl %edi, %r8d
andl %esi, %ecx
subl %ecx, %r8d
andl %ebx, %edi
andl %esi, %ebx
subl %ebx, %edi
imull %r8d, %edi
addl %edi, %edx
testl %edi, %edi
cmovnsl %edi, %edx
sarl $0x8, %edx
shll $0x8, %eax
andl $0xffff0000, %eax       # imm = 0xFFFF0000
addl %edx, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
// File: /workspace/github_cpp_makefile_star2_O1/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 %r15
pushq %r14
pushq %rbx
subq $0x20, %rsp
cmpl $0x1, %edi
jg 0x15f33
leaq 0x10(%rsp), %r15
movq %r15, -0x10(%r15)
movq $0x0, -0x8(%r15)
movb $0x0, (%r15)
movq 0x260f2(%rip), %rbx     # 0x3bfd0
movq %rsp, %r14
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x53c0
movsbl %al, %edx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x57e0
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x15f1d
movq %r14, %rdi
callq 0x2a8c0
testb %al, %al
jne 0x15ee1
movq (%rsp), %rdi
cmpq %r15, %rdi
je 0x15f33
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x5400
leaq 0x3aab56(%rip), %rdi    # 0x3c0a90
callq 0x2921c
addq $0x20, %rsp
popq %rbx
popq %r14
popq %r15
retq
movq %rax, %rbx
movq (%rsp), %rdi
cmpq %r15, %rdi
je 0x15f62
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x5400
movq %rbx, %rdi
callq 0x5790
nop
// File: /workspace/github_cpp_makefile_star2_O1/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 0x16292
popq %rbx
retq
movq %rdi, %rbx
movq 0x25c8c(%rip), %rsi     # 0x3bf28
movl $0x60000, %edi          # imm = 0x60000
callq 0x5700
movq %rax, 0x8(%rbx)
testq %rax, %rax
je 0x162bf
movl $0x60000, %edx          # imm = 0x60000
movq %rax, %rdi
xorl %esi, %esi
popq %rbx
jmp 0x5210
movq 0x25d2a(%rip), %rdi     # 0x3bff0
leaq 0x1b2d8(%rip), %rsi     # 0x315a5
callq 0x53d0
movl $0x60000, %esi          # imm = 0x60000
movq %rax, %rdi
callq 0x50f0
leaq 0x1b2d3(%rip), %rsi     # 0x315b9
movq %rax, %rdi
callq 0x53d0
movq %rax, %rdi
callq 0x51c0
movl $0x1, %edi
callq 0x54e0
// File: /workspace/github_cpp_makefile_star2_O1/ATOMIC-LICHESS[P]ATOMKRAFT/material.cpp
// Function: int MaterialInfoTable::imbalance<(Color)0>(int const (*) [8])
int MaterialInfoTable::imbalance(const int pieceCount[][8]) {

  const Color Them = (Us == WHITE ? BLACK : WHITE);

  int pt1, pt2, pc, v;
  int value = 0;

  // Redundancy of major pieces, formula based on Kaufman's paper
  // "The Evaluation of Material Imbalances in Chess"
  if (pieceCount[Us][ROOK] > 0)
      value -=  RedundantRookPenalty * (pieceCount[Us][ROOK] - 1)
              + RedundantQueenPenalty * pieceCount[Us][QUEEN];

  // Second-degree polynomial material imbalance by Tord Romstad
  for (pt1 = PIECE_TYPE_NONE; pt1 <= QUEEN; pt1++)
  {
      pc = pieceCount[Us][pt1];
      if (!pc)
          continue;

      v = LinearCoefficients[pt1];

      for (pt2 = PIECE_TYPE_NONE; pt2 <= pt1; pt2++)
          v +=  QuadraticCoefficientsSameColor[pt1][pt2] * pieceCount[Us][pt2]
              + QuadraticCoefficientsOppositeColor[pt1][pt2] * pieceCount[Them][pt2];

      value += pc * v;
  }
  return value;
}

// Assembly:
movl 0x10(%rdi), %eax
testl %eax, %eax
jle 0x1631f
imull $0xfffffdd6, %eax, %eax # imm = 0xFFFFFDD6
movl 0x14(%rdi), %ecx
shll $0x6, %ecx
leal (%rcx,%rcx,4), %ecx
subl %ecx, %eax
addl $0x22a, %eax            # imm = 0x22A
jmp 0x16321
xorl %eax, %eax
pushq %rbp
pushq %rbx
movl $0x1, %ecx
leaq 0x1b0b1(%rip), %rdx     # 0x313e0
leaq 0x1b16a(%rip), %rsi     # 0x314a0
xorl %r8d, %r8d
leaq 0x1b080(%rip), %r9      # 0x313c0
movl (%rdi,%r8,4), %r10d
testl %r10d, %r10d
je 0x16375
movl (%r9,%r8,4), %r11d
xorl %ebx, %ebx
movl (%rdi,%rbx,4), %ebp
imull (%rdx,%rbx,4), %ebp
addl %r11d, %ebp
movl 0x20(%rdi,%rbx,4), %r11d
imull (%rsi,%rbx,4), %r11d
addl %ebp, %r11d
incq %rbx
cmpq %rbx, %rcx
jne 0x1634f
imull %r10d, %r11d
addl %r11d, %eax
incq %r8
incq %rcx
addq $0x20, %rdx
addq $0x20, %rsi
cmpq $0x6, %r8
jne 0x16340
popq %rbx
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O1/ATOMIC-LICHESS[P]ATOMKRAFT/misc.cpp
// Function: get_system_time()
int64_t get_system_time() {
#if defined(_MSC_VER)
  struct _timeb t;
  _ftime(&t);
  return int64_t(t.time * 1000 + t.millitm);
#else
#include <sys/time.h>
  struct timeval t; int64_t x;
  // ERROR: gettimeofday(&t, NULL);
  //  return clock() * ((clock_t)1000 / CLOCKS_PER_SEC);// t.tv_sec * 1000 + t.tv_usec / 1000; // bad, when CLOCKS_PER_SEC exceeds 1000
  //  return clock() * (clock_t) 1000 / CLOCKS_PER_SEC;
  // want wall time, not user time
  gettimeofday (&t, NULL);
  x = t.tv_sec * 1000000 + t.tv_usec;
  return x/1000;
#endif
}

// Assembly:
pushq %rbx
subq $0x10, %rsp
movq %rsp, %rbx
movq %rbx, %rdi
xorl %esi, %esi
callq 0x56c0
imulq $0xf4240, (%rbx), %rax  # imm = 0xF4240
addq 0x8(%rbx), %rax
movabsq $0x20c49ba5e353f7cf, %rcx # imm = 0x20C49BA5E353F7CF
imulq %rcx
movq %rdx, %rax
shrq $0x3f, %rax
sarq $0x7, %rdx
addq %rdx, %rax
addq $0x10, %rsp
popq %rbx
retq
// File: /workspace/github_cpp_makefile_star2_O1/ATOMIC-LICHESS[P]ATOMKRAFT/misc.cpp
// Function: input_available()
int input_available() {

  fd_set readfds;
  struct timeval  timeout;

  FD_ZERO(&readfds);
  FD_SET(fileno(stdin), &readfds);
  timeout.tv_sec = 0; // Set to timeout immediately
  timeout.tv_usec = 0;
  select(16, &readfds, 0, 0, &timeout);

  return (FD_ISSET(fileno(stdin), &readfds));
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x90, %rsp
xorps %xmm0, %xmm0
leaq 0x10(%rsp), %rbx
movaps %xmm0, (%rbx)
movaps %xmm0, 0x10(%rbx)
movaps %xmm0, 0x20(%rbx)
movaps %xmm0, 0x30(%rbx)
movaps %xmm0, 0x40(%rbx)
movaps %xmm0, 0x50(%rbx)
movaps %xmm0, 0x60(%rbx)
movaps %xmm0, 0x70(%rbx)
movq 0x2502a(%rip), %r14     # 0x3bf68
movq (%r14), %rdi
callq 0x5440
leal 0x3f(%rax), %ecx
testl %eax, %eax
cmovnsl %eax, %ecx
andl $0xc0, %ecx
subl %ecx, %eax
movl $0x1, %r15d
movl %eax, %ecx
shlq %cl, %r15
movq (%r14), %rdi
callq 0x5440
leal 0x3f(%rax), %ecx
testl %eax, %eax
cmovnsl %eax, %ecx
sarl $0x6, %ecx
movslq %ecx, %rax
orq %r15, 0x10(%rsp,%rax,8)
movq %rsp, %r8
xorps %xmm0, %xmm0
movaps %xmm0, (%r8)
movl $0x10, %edi
movq %rbx, %rsi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0x53a0
movq (%r14), %rdi
callq 0x5440
leal 0x3f(%rax), %ecx
testl %eax, %eax
cmovnsl %eax, %ecx
sarl $0x6, %ecx
movslq %ecx, %rax
movq 0x10(%rsp,%rax,8), %rbx
movq (%r14), %rdi
callq 0x5440
xorl %ecx, %ecx
btq %rax, %rbx
setb %cl
movl %ecx, %eax
addq $0x90, %rsp
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_cpp_makefile_star2_O1/ATOMIC-LICHESS[P]ATOMKRAFT/move.cpp
// Function: move_from_uci(Position const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&)
Move move_from_uci(const Position& pos, const string& str) {
	
	
  MoveStack mlist[MAX_MOVES];
  MoveStack* last = generate<MV_LEGAL>(pos, mlist);
  
  for (MoveStack* cur = mlist; cur != last; cur++)
      if (str == move_to_uci(cur->move, pos.is_chess960()))
          return cur->move;

  return MOVE_NONE;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x828, %rsp            # imm = 0x828
movq %rsi, %rbx
movq %rdi, %r14
leaq 0x20(%rsp), %r15
movq %r15, %rsi
callq 0x1a0ce
cmpq %rax, %r15
je 0x1787c
movq %rax, %r12
movq %rsp, %r13
movl (%r15), %esi
movzbl 0x1924(%r14), %edx
movq %r13, %rdi
callq 0x17480
movq 0x8(%rbx), %rdx
cmpq 0x8(%rsp), %rdx
jne 0x1784c
testq %rdx, %rdx
je 0x17850
movq (%rsp), %rsi
movq (%rbx), %rdi
callq 0x5410
testl %eax, %eax
sete %bpl
jmp 0x17853
xorl %ebp, %ebp
jmp 0x17853
movb $0x1, %bpl
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0x1786e
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x5400
testb %bpl, %bpl
jne 0x17880
addq $0x8, %r15
cmpq %r12, %r15
jne 0x17815
xorl %eax, %eax
jmp 0x17883
movl (%r15), %eax
addq $0x828, %rsp            # imm = 0x828
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O1/ATOMIC-LICHESS[P]ATOMKRAFT/movegen.cpp
// Function: MoveStack* generate<(MoveType)6>(Position const&, MoveStack*)
MoveStack* generate<MV_LEGAL>(const Position& pos, MoveStack* mlist) {
  STARTNEW
  if (!(pos.piece_count(WHITE, KING) && pos.piece_count(BLACK, KING))) {
	  return mlist;
  }
  ENDNEW
  //NEW assert(pos.piece_count(WHITE, KING) && pos.piece_count(BLACK, KING));
		
  assert(pos.is_ok());
  

  MoveStack *last, *cur = mlist;
  Bitboard pinned = pos.pinned_pieces(pos.side_to_move());

  last = generate<MV_PSEUDO_LEGAL>(pos, mlist);
  
  
  
  // Remove illegal moves from the list
  while (cur != last) {
	  //NEW assert(pos.color_of_piece_on(move_from(cur->move)) == pos.side_to_move());
      if (!pos.pl_move_is_legal(cur->move, pinned))
          cur->move = (--last)->move;
      else
          cur++;
      
  }

  return last;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %rbx
cmpl $0x0, 0x168(%rdi)
je 0x1a13b
movq %rdi, %r14
cmpl $0x0, 0x188(%rdi)
je 0x1a13b
movl 0x1090(%r14), %esi
movq %r14, %rdi
callq 0x1de74
movq %rax, %r12
movq %r14, %rdi
movq %rbx, %rsi
callq 0x1a0a1
movq %rax, %r15
cmpq %rbx, %rax
je 0x1a13e
movl (%rbx), %esi
movq %r14, %rdi
movq %r12, %rdx
callq 0x1e44a
testb %al, %al
je 0x1a12a
addq $0x8, %rbx
jmp 0x1a134
movl -0x8(%r15), %eax
addq $-0x8, %r15
movl %eax, (%rbx)
cmpq %r15, %rbx
jne 0x1a113
jmp 0x1a13e
movq %rbx, %r15
movq %r15, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
// File: /workspace/github_cpp_makefile_star2_O1/ATOMIC-LICHESS[P]ATOMKRAFT/movepick.cpp
// Function: MovePicker::MovePicker(Position const&, Move, Depth, History const&, SearchStack*, Value)
MovePicker::MovePicker(const Position& p, Move ttm, Depth d, const History& h,
                       SearchStack* ss, Value beta) : pos(p), H(h) {
  int searchTT = ttm;
  ttMoves[0].move = ttm;
  
  //NEW badCaptureThreshold = PawnValueMidgame;
  badCaptureThreshold = 0;
  
  badCaptures = moves + MAX_MOVES;

  assert(d > DEPTH_ZERO);

  pinned = p.pinned_pieces(pos.side_to_move());

  if (p.in_check())
  {
      ttMoves[1].move = killers[0].move = killers[1].move = MOVE_NONE;
      phasePtr = EvasionTable;
  }
  else
  {
      ttMoves[1].move = (ss->mateKiller == ttm) ? MOVE_NONE : ss->mateKiller;
      searchTT |= ttMoves[1].move;
      killers[0].move = ss->killers[0];
      killers[1].move = ss->killers[1];

      // Consider sligtly negative captures as good if at low
      // depth and far from beta.
      if (ss && ss->eval < beta - PawnValueMidgame && d < 3 * ONE_PLY) { 
    	  //NEW badCaptureThreshold = 0;
    	  badCaptureThreshold = -PawnValueMidgame;
      }

      phasePtr = MainSearchTable;
  }

  phasePtr += int(!searchTT) - 1;
  go_next_phase();
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %r9, %r14
movl %ecx, %r15d
movl %edx, %ebp
movq %rsi, %r12
movq %rdi, %rbx
movl 0x40(%rsp), %r13d
movq %rsi, (%rdi)
movq %r8, 0x8(%rdi)
movl %edx, 0x18(%rdi)
movl $0x0, 0x38(%rdi)
leaq 0x868(%rdi), %rax
movq %rax, 0x60(%rdi)
movl 0x1090(%rsi), %esi
movq %r12, %rdi
callq 0x1de74
movq %rax, 0x10(%rbx)
movq 0x1938(%r12), %rax
cmpq $0x0, 0x40(%rax)
je 0x1b1ca
xorl %eax, %eax
movl %eax, 0x30(%rbx)
movl %eax, 0x28(%rbx)
movl %eax, 0x20(%rbx)
leaq 0x1679f(%rip), %rax     # 0x31948
cmpl $0x1, %ebp
adcq $-0x1, %rax
movq %rax, 0x40(%rbx)
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x1b214
movl 0x8(%r14), %eax
xorl %ecx, %ecx
cmpl %ebp, %eax
cmovnel %eax, %ecx
movl %ecx, 0x20(%rbx)
orl %ecx, %ebp
movl 0x14(%r14), %eax
movl %eax, 0x28(%rbx)
movl 0x18(%r14), %eax
movl %eax, 0x30(%rbx)
leaq 0x16791(%rip), %rax     # 0x31980
testq %r14, %r14
je 0x1b1a9
cmpl $0x5, %r15d
jg 0x1b1a9
leaq 0x21247(%rip), %rcx     # 0x3c448
movl (%rcx), %ecx
subl %ecx, %r13d
cmpl %r13d, 0x20(%r14)
jge 0x1b1a9
negl %ecx
movl %ecx, 0x38(%rbx)
jmp 0x1b1a9
nop
// File: /workspace/github_cpp_makefile_star2_O1/ATOMIC-LICHESS[P]ATOMKRAFT/movepick.cpp
// Function: MovePicker::MovePicker(Position const&, Move, Depth, History const&)
MovePicker::MovePicker(const Position& p, Move ttm, Depth d, const History& h)
                      : pos(p), H(h) {
  int searchTT = ttm;
  ttMoves[0].move = ttm;
  ttMoves[1].move = MOVE_NONE;

  assert(d <= DEPTH_ZERO);

  pinned = p.pinned_pieces(pos.side_to_move());

  if (p.in_check())
      phasePtr = EvasionTable;
  else if (d >= DEPTH_QS_CHECKS)
      phasePtr = QsearchWithChecksTable;
  else
  {
      phasePtr = QsearchWithoutChecksTable;

      // Skip TT move if is not a capture or a promotion, this avoids
      // qsearch tree explosion due to a possible perpetual check or
      // similar rare cases when TT table is full.
      if (ttm != MOVE_NONE && !pos.move_is_capture_or_promotion(ttm))
          searchTT = ttMoves[0].move = MOVE_NONE;
  }

  phasePtr += int(!searchTT) - 1;
  go_next_phase();
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movl %ecx, %ebp
movl %edx, %r14d
movq %rsi, %r15
movq %rdi, %rbx
movq %rsi, (%rdi)
movq %r8, 0x8(%rdi)
movl %edx, 0x18(%rdi)
movl $0x0, 0x20(%rdi)
movl 0x1090(%rsi), %esi
movq %r15, %rdi
callq 0x1de74
movq %rax, 0x10(%rbx)
movq 0x1938(%r15), %rax
cmpq $0x0, 0x40(%rax)
je 0x1b436
leaq 0x16514(%rip), %rax     # 0x31948
jmp 0x1b442
cmpl $-0x2, %ebp
jl 0x1b461
leaq 0x16544(%rip), %rax     # 0x31986
movq %rax, 0x40(%rbx)
cmpl $0x1, %r14d
adcq $-0x1, 0x40(%rbx)
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x1b214
leaq 0x16522(%rip), %rax     # 0x3198a
movq %rax, 0x40(%rbx)
testl %r14d, %r14d
je 0x1b4a6
testl $0x1f000, %r14d         # imm = 0x1F000
je 0x1b486
notl %r14d
testl $0xc000, %r14d          # imm = 0xC000
jmp 0x1b492
movq (%rbx), %rax
andl $0x3f, %r14d
cmpl $0x10, (%rax,%r14,4)
setne %al
movl $0x1, %r14d
testb %al, %al
jne 0x1b446
movl $0x0, 0x18(%rbx)
xorl %r14d, %r14d
jmp 0x1b446
nop
// File: /workspace/github_cpp_makefile_star2_O1/ATOMIC-LICHESS[P]ATOMKRAFT/movepick.cpp
// Function: MovePicker::score_captures()
void MovePicker::score_captures() {
  // Winning and equal captures in the main search are ordered by MVV/LVA.
  // Suprisingly, this appears to perform slightly better than SEE based
  // move ordering. The reason is probably that in a position with a winning
  // capture, capturing a more valuable (but sufficiently defended) piece
  // first usually doesn't hurt. The opponent will have to recapture, and
  // the hanging piece will still be hanging (except in the unusual cases
  // where it is possible to recapture with the hanging piece). Exchanging
  // big pieces before capturing a hanging piece probably helps to reduce
  // the subtree size.
  // In main search we want to push captures with negative SEE values to
  // badCaptures[] array, but instead of doing it now we delay till when
  // the move has been picked up in pick_move_from_list(), this way we save
  // some SEE calls in case we get a cutoff (idea from Pablo Vazquez).
  Move m;

  // Use MVV/LVA ordering
  for (MoveStack* cur = moves; cur != lastMove; cur++)
  {
      m = cur->move;
      if (move_is_promotion(m))
          cur->score = QueenValueMidgame; NEW // this never happens in atomic chess
      else
          cur->score =  pos.midgame_value_of_piece_on(move_to(m))
                      - pos.type_of_piece_on(move_from(m));
  }
}

// Assembly:
leaq 0x68(%rdi), %rax
movq 0x50(%rdi), %rcx
cmpq %rcx, %rax
je 0x1b517
movq (%rdi), %rdx
leaq 0x20fa5(%rip), %rsi     # 0x3c468
movl (%rsi), %esi
leaq 0x39fd54(%rip), %rdi    # 0x3bb220
movl (%rax), %r8d
movl %r8d, %r10d
andl $0xc000, %r10d          # imm = 0xC000
movl %esi, %r9d
cmpl $0x4000, %r10d          # imm = 0x4000
je 0x1b50a
movl %r8d, %r9d
andl $0x3f, %r9d
movl (%rdx,%r9,4), %r9d
movl (%rdi,%r9,4), %r9d
shrl $0x4, %r8d
andl $0xfc, %r8d
movl (%rdx,%r8), %r8d
andl $0x7, %r8d
subl %r8d, %r9d
movl %r9d, 0x4(%rax)
addq $0x8, %rax
cmpq %rcx, %rax
jne 0x1b4cc
retq
// File: /workspace/github_cpp_makefile_star2_O1/ATOMIC-LICHESS[P]ATOMKRAFT/movepick.cpp
// Function: MovePicker::score_noncaptures()
void MovePicker::score_noncaptures() {

  Move m;
  Square from;

  for (MoveStack* cur = moves; cur != lastMove; cur++)
  {
      m = cur->move;
      from = move_from(m);
      cur->score = H.value(pos.piece_on(from), move_to(m));
  }
}

// Assembly:
leaq 0x68(%rdi), %rax
movq 0x50(%rdi), %rcx
cmpq %rcx, %rax
je 0x1b55a
movq (%rdi), %rdx
movq 0x8(%rdi), %rsi
movl (%rax), %edi
movl %edi, %r8d
shrl $0x4, %r8d
andl $0xfc, %r8d
movl (%rdx,%r8), %r8d
andl $0x3f, %edi
shlq $0x8, %r8
addq %rsi, %r8
movl (%r8,%rdi,4), %edi
movl %edi, 0x4(%rax)
addq $0x8, %rax
cmpq %rcx, %rax
jne 0x1b52c
retq
nop
// File: /workspace/github_cpp_makefile_star2_O1/ATOMIC-LICHESS[P]ATOMKRAFT/movepick.cpp
// Function: MovePicker::score_evasions()
void MovePicker::score_evasions() {
  // Try good captures ordered by MVV/LVA, then non-captures if
  // destination square is not under attack, ordered by history
  // value, and at the end bad-captures and non-captures with a
  // negative SEE. This last group is ordered by the SEE score.
  Move m;
  int seeScore;

  // Skip if we don't have at least two moves to order
  if (lastMove < moves + 2)
      return;

  for (MoveStack* cur = moves; cur != lastMove; cur++)
  {
      m = cur->move;
      if ((seeScore = pos.see_sign(m)) < 0)
          cur->score = seeScore - History::MaxValue; // Be sure we are at the bottom
      else if (pos.move_is_capture(m))
          cur->score =  pos.midgame_value_of_piece_on(move_to(m))
                      - pos.type_of_piece_on(move_from(m)) + History::MaxValue;
      else
          cur->score = H.value(pos.piece_on(move_from(m)), move_to(m));
  }
}

// Assembly:
leaq 0x78(%rdi), %rax
cmpq %rax, 0x50(%rdi)
jb 0x1b62f
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %rbx
leaq 0x68(%rdi), %r15
cmpq 0x50(%rdi), %r15
je 0x1b624
leaq 0x39fc96(%rip), %r12    # 0x3bb220
movl (%r15), %r14d
movq (%rbx), %rdi
movl %r14d, %esi
callq 0x2073c
testl %eax, %eax
js 0x1b5b4
movq (%rbx), %rcx
testl $0x18000, %r14d         # imm = 0x18000
je 0x1b5bb
movl %r14d, %eax
notl %eax
testl $0xc000, %eax           # imm = 0xC000
jmp 0x1b5c5
addl $0xfffff830, %eax       # imm = 0xFFFFF830
jmp 0x1b612
movl %r14d, %eax
andl $0x3f, %eax
cmpl $0x10, (%rcx,%rax,4)
setne %al
testb %al, %al
je 0x1b5f4
movl %r14d, %eax
andl $0x3f, %eax
movl (%rcx,%rax,4), %eax
movl (%r12,%rax,4), %eax
shrl $0x4, %r14d
andl $0xfc, %r14d
movl (%rcx,%r14), %ecx
andl $0x7, %ecx
subl %ecx, %eax
addl $0x7d0, %eax            # imm = 0x7D0
jmp 0x1b612
movl %r14d, %eax
shrl $0x4, %eax
andl $0xfc, %eax
movl (%rcx,%rax), %eax
andl $0x3f, %r14d
shlq $0x8, %rax
addq 0x8(%rbx), %rax
movl (%rax,%r14,4), %eax
movl %eax, 0x4(%r15)
addq $0x8, %r15
cmpq 0x50(%rbx), %r15
jne 0x1b58a
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
// File: /workspace/github_cpp_makefile_star2_O1/ATOMIC-LICHESS[P]ATOMKRAFT/position.cpp
// Function: Position::Position(Position const&, int)
Position::Position(const Position& pos, int th) {

  memcpy(this, &pos, sizeof(Position));
  detach(); // Always detach() in copy c'tor to avoid surprises
  threadID = th;
  nodes = 0;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movl %edx, %ebx
movq %rdi, %r14
movl $0x1940, %edx           # imm = 0x1940
callq 0x5320
movq 0x1938(%r14), %rsi
leaq 0x1878(%r14), %r15
movl $0xa0, %edx
movq %r15, %rdi
callq 0x5320
movq %r15, 0x1938(%r14)
xorl %eax, %eax
movq %rax, 0x1910(%r14)
movl %ebx, 0x192c(%r14)
movq %rax, 0x1930(%r14)
popq %rbx
popq %r14
popq %r15
retq
nop