LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_cpp_makefile_star2_O3/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, %r14
movq %rdi, %r15
leaq 0x20(%rsp), %r12
movq %r12, %rsi
callq 0x1a5c0
movq %rax, %r13
xorl %eax, %eax
cmpq %r13, %r12
je 0x17dde
movl (%r12), %esi
movzbl 0x1924(%r15), %edx
movq %rsp, %rdi
callq 0x179d4
movq 0x8(%r14), %rdx
cmpq 0x8(%rsp), %rdx
jne 0x17da3
movq (%rsp), %rbx
testq %rdx, %rdx
je 0x17dab
movq (%r14), %rdi
movq %rbx, %rsi
callq 0x5410
testl %eax, %eax
sete %bpl
jmp 0x17dae
movq (%rsp), %rbx
xorl %ebp, %ebp
jmp 0x17dae
movb $0x1, %bpl
leaq 0x10(%rsp), %rax
cmpq %rax, %rbx
je 0x17dc8
movq 0x10(%rsp), %rsi
incq %rsi
movq %rbx, %rdi
callq 0x5400
testb %bpl, %bpl
jne 0x17dda
addq $0x8, %r12
cmpq %r13, %r12
jne 0x17d68
xorl %eax, %eax
jmp 0x17dde
movl (%r12), %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_O3/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 0x1a62d
movq %rdi, %r14
cmpl $0x0, 0x188(%rdi)
je 0x1a62d
movl 0x1090(%r14), %esi
movq %r14, %rdi
callq 0x1e396
movq %rax, %r12
movq %r14, %rdi
movq %rbx, %rsi
callq 0x1a593
movq %rax, %r15
cmpq %rbx, %rax
je 0x1a630
movl (%rbx), %esi
movq %r14, %rdi
movq %r12, %rdx
callq 0x1e96c
testb %al, %al
je 0x1a61c
addq $0x8, %rbx
jmp 0x1a626
movl -0x8(%r15), %eax
addq $-0x8, %r15
movl %eax, (%rbx)
cmpq %r15, %rbx
jne 0x1a605
jmp 0x1a630
movq %rbx, %r15
movq %r15, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
// File: /workspace/github_cpp_makefile_star2_O3/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 0x1e396
movq %rax, 0x10(%rbx)
movq 0x1938(%r12), %rax
cmpq $0x0, 0x40(%rax)
je 0x1b6d3
xorl %eax, %eax
movl %eax, 0x30(%rbx)
movl %eax, 0x28(%rbx)
movl %eax, 0x20(%rbx)
leaq 0x172f7(%rip), %rax     # 0x329c8
jmp 0x1b715
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 0x17308(%rip), %rax     # 0x32a00
cmpl $0x5, %r15d
jg 0x1b715
leaq 0x21d43(%rip), %rcx     # 0x3d448
movl (%rcx), %ecx
subl %ecx, %r13d
cmpl %r13d, 0x20(%r14)
jge 0x1b715
negl %ecx
movl %ecx, 0x38(%rbx)
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 0x1b736
// File: /workspace/github_cpp_makefile_star2_O3/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 0x1e396
movq %rax, 0x10(%rbx)
movq 0x1938(%r15), %rax
cmpq $0x0, 0x40(%rax)
je 0x1b958
leaq 0x17072(%rip), %rax     # 0x329c8
jmp 0x1b964
cmpl $-0x3, %ebp
jle 0x1b984
leaq 0x170a2(%rip), %rax     # 0x32a06
movl %r14d, %ecx
cmpl $0x1, %ecx
adcq $-0x1, %rax
movq %rax, 0x40(%rbx)
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x1b736
xorl %ecx, %ecx
leaq 0x1707d(%rip), %rax     # 0x32a0a
testl %r14d, %r14d
je 0x1b967
testl $0x1f000, %r14d         # imm = 0x1F000
je 0x1b9b0
notl %r14d
testl $0xc000, %r14d          # imm = 0xC000
jne 0x1b9be
movl $0x0, 0x18(%rbx)
jmp 0x1b967
movq (%rbx), %rdx
andl $0x3f, %r14d
cmpl $0x10, (%rdx,%r14,4)
je 0x1b9a7
movl $0x1, %ecx
jmp 0x1b967
nop
// File: /workspace/github_cpp_makefile_star2_O3/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 0x1ba31
movq (%rdi), %rdx
leaq 0x21a8b(%rip), %rsi     # 0x3d468
movl (%rsi), %esi
leaq 0x3a083a(%rip), %rdi    # 0x3bc220
movl (%rax), %r8d
movl %r8d, %r10d
andl $0xc000, %r10d          # imm = 0xC000
movl %esi, %r9d
cmpl $0x4000, %r10d          # imm = 0x4000
je 0x1ba24
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 0x1b9e6
retq
// File: /workspace/github_cpp_makefile_star2_O3/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 0x1ba74
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 0x1ba46
retq
nop
// File: /workspace/github_cpp_makefile_star2_O3/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 0x1bb39
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %rbx
leaq 0x68(%rdi), %r15
leaq 0x3a0786(%rip), %r12    # 0x3bc220
movl (%r15), %r14d
movq (%rbx), %rdi
movl %r14d, %esi
callq 0x20bf8
testl %eax, %eax
js 0x1bae7
movq (%rbx), %rcx
testl $0x18000, %r14d         # imm = 0x18000
je 0x1baee
movl %r14d, %edx
notl %edx
movl %r14d, %eax
andl $0x3f, %eax
testl $0xc000, %edx           # imm = 0xC000
jne 0x1bafc
shrl $0x4, %r14d
andl $0xfc, %r14d
movl (%rcx,%r14), %ecx
shlq $0x8, %rcx
addq 0x8(%rbx), %rcx
movl (%rcx,%rax,4), %eax
jmp 0x1bb1c
addl $0xfffff830, %eax       # imm = 0xFFFFF830
jmp 0x1bb1c
movl %r14d, %eax
andl $0x3f, %eax
movl %eax, %edx
cmpl $0x10, (%rcx,%rdx,4)
je 0x1bacb
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
movl %eax, 0x4(%r15)
addq $0x8, %r15
cmpq 0x50(%rbx), %r15
jne 0x1ba9a
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
// File: /workspace/github_cpp_makefile_star2_O3/ATOMIC-LICHESS[P]ATOMKRAFT/position.cpp
// Function: Position::clear()
void Position::clear() {

  st = &startState;
  memset(st, 0, sizeof(StateInfo));
  st->epSquare = SQ_NONE;
  startPosPlyCounter = 0;
  nodes = 0;

  memset(byColorBB,  0, sizeof(Bitboard) * 2);
  memset(byTypeBB,   0, sizeof(Bitboard) * 8);
  memset(pieceCount, 0, sizeof(int) * 2 * 8);
  memset(index,      0, sizeof(int) * 64);

  for (int i = 0; i < 64; i++)
      board[i] = PIECE_NONE;

  for (int i = 0; i < 8; i++)
      for (int j = 0; j < 16; j++)
          pieceList[0][i][j] = pieceList[1][i][j] = SQ_NONE;

  for (Square sq = SQ_A1; sq <= SQ_H8; sq++)
      castleRightsMask[sq] = ALL_CASTLES;

  sideToMove = WHITE;
  initialKFile = FILE_E;
  initialKRFile = FILE_H;
  initialQRFile = FILE_A;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rdi, %rbx
addq $0x1878, %rdi           # imm = 0x1878
movq %rdi, 0x1938(%rbx)
xorl %r15d, %r15d
movl $0xa0, %edx
xorl %esi, %esi
callq 0x5210
movl $0x40, 0x1898(%rbx)
movl $0x0, 0x1928(%rbx)
movq $0x0, 0x1930(%rbx)
leaq 0x100(%rbx), %r14
leaq 0x590(%rbx), %rdi
movl $0x100, %edx            # imm = 0x100
xorl %esi, %esi
callq 0x5210
movl $0x90, %edx
movq %r14, %rdi
xorl %esi, %esi
callq 0x5210
movaps 0x11e96(%rip), %xmm0    # 0x2f130
movups %xmm0, (%rbx,%r15,4)
addq $0x4, %r15
cmpq $0x40, %r15
jne 0x1d29a
leaq 0x390(%rbx), %rax
xorl %ecx, %ecx
movaps 0x15957(%rip), %xmm0    # 0x32c10
xorl %edx, %edx
movups %xmm0, (%rax,%rdx,4)
movups %xmm0, -0x200(%rax,%rdx,4)
addq $0x4, %rdx
cmpq $0x10, %rdx
jne 0x1d2bb
incq %rcx
addq $0x40, %rax
cmpq $0x8, %rcx
jne 0x1d2b9
xorl %eax, %eax
movaps 0x15939(%rip), %xmm0    # 0x32c20
movups %xmm0, 0x1778(%rbx,%rax,4)
addq $0x4, %rax
cmpq $0x40, %rax
jne 0x1d2e7
xorl %eax, %eax
movl %eax, 0x1090(%rbx)
movabsq $0x700000004, %rcx      # imm = 0x700000004
movq %rcx, 0x1918(%rbx)
movl %eax, 0x1920(%rbx)
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_cpp_makefile_star2_O3/ATOMIC-LICHESS[P]ATOMKRAFT/position.cpp
// Function: Position::compute_key() const
Key Position::compute_key() const {

  Key result = zobCastle[st->castleRights];

  for (Square s = SQ_A1; s <= SQ_H8; s++)
      if (square_is_occupied(s))
          result ^= zobrist[color_of_piece_on(s)][type_of_piece_on(s)][s];

  if (ep_square() != SQ_NONE)
      result ^= zobEp[ep_square()];

  if (side_to_move() == BLACK)
      result ^= zobSideToMove;

  return result;
}

// Assembly:
movq 0x1938(%rdi), %rax
movslq 0x10(%rax), %rcx
leaq 0x39db14(%rip), %rdx    # 0x3bb190
movq (%rdx,%rcx,8), %rcx
xorl %edx, %edx
leaq 0x39b907(%rip), %rsi    # 0x3b8f90
movq %rdi, %r8
movl (%r8), %r9d
cmpq $0x10, %r9
je 0x1d6b2
movl %r9d, %r10d
sarl $0x3, %r10d
andl $0x7, %r9d
shlq $0xc, %r10
shll $0x9, %r9d
orq %r10, %r9
addq %rdx, %r9
xorq (%rsi,%r9), %rcx
addq $0x8, %rdx
addq $0x4, %r8
cmpq $0x200, %rdx            # imm = 0x200
jne 0x1d68c
movslq 0x20(%rax), %rax
cmpq $0x40, %rax
je 0x1d6d8
leaq 0x39d8bc(%rip), %rdx    # 0x3baf90
xorq (%rdx,%rax,8), %rcx
cmpl $0x1, 0x1090(%rdi)
jne 0x1d6ea
movq 0x39db28(%rip), %rax    # 0x3bb210
jmp 0x1d6ec
xorl %eax, %eax
xorq %rcx, %rax
retq
// File: /workspace/github_cpp_makefile_star2_O3/ATOMIC-LICHESS[P]ATOMKRAFT/position.cpp
// Function: Position::compute_pawn_key() const
Key Position::compute_pawn_key() const {

  Bitboard b;
  Key result = 0;

  for (Color c = WHITE; c <= BLACK; c++)
  {
      b = pieces(PAWN, c);
      while (b)
          result ^= zobrist[c][PAWN][pop_1st_bit(&b)];
  }
  return result;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %rbx
movb $0x1, %bpl
xorl %r13d, %r13d
movq %rsp, %r14
leaq 0x39b882(%rip), %r12    # 0x3b8f90
xorl %r15d, %r15d
movq 0x140(%rbx,%r13,8), %rax
andq 0x108(%rbx), %rax
movq %rax, (%rsp)
je 0x1d746
shlq $0xc, %r13
addq %r12, %r13
movq %r14, %rdi
callq 0x827b
cltq
xorq 0x200(%r13,%rax,8), %r15
cmpq $0x0, (%rsp)
jne 0x1d72d
movl $0x1, %r13d
testb $0x1, %bpl
movl $0x0, %ebp
jne 0x1d711
movq %r15, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop
// File: /workspace/github_cpp_makefile_star2_O3/ATOMIC-LICHESS[P]ATOMKRAFT/position.cpp
// Function: Position::compute_material_key() const
Key Position::compute_material_key() const {

  int count;
  Key result = 0;

  for (Color c = WHITE; c <= BLACK; c++)
      for (PieceType pt = PAWN; pt <= QUEEN; pt++)
      {
          count = piece_count(c, pt);
          for (int i = 0; i < count; i++)
              result ^= zobrist[c][pt][i];
      }
  return result;
}

// Assembly:
addq $0x150, %rdi            # imm = 0x150
movb $0x1, %cl
xorl %edx, %edx
leaq 0x39b814(%rip), %rsi    # 0x3b8f90
xorl %eax, %eax
movq %rdx, %r8
shlq $0xc, %r8
addq %rsi, %r8
addq $0x200, %r8             # imm = 0x200
movl $0x1, %r9d
shlq $0x5, %rdx
addq %rdi, %rdx
movslq (%rdx,%r9,4), %r10
testq %r10, %r10
jle 0x1d7b4
xorl %r11d, %r11d
xorq (%r8,%r11,8), %rax
incq %r11
cmpq %r11, %r10
jne 0x1d7a8
incq %r9
addq $0x200, %r8             # imm = 0x200
cmpq $0x6, %r9
jne 0x1d79c
movl $0x1, %edx
testb $0x1, %cl
movl $0x0, %ecx
jne 0x1d77e
retq
// File: /workspace/github_cpp_makefile_star2_O3/ATOMIC-LICHESS[P]ATOMKRAFT/position.cpp
// Function: Position::compute_value() const
Score Position::compute_value() const {

  Bitboard b;
  Score result = SCORE_ZERO;

  for (Color c = WHITE; c <= BLACK; c++)
      for (PieceType pt = PAWN; pt <= KING; pt++)
      {
          b = pieces(pt, c);
          while (b)
              result += pst(c, pt, pop_1st_bit(&b));
      }

  result += (side_to_move() == WHITE ? TempoValue / 2 : -TempoValue / 2);
  return result;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdi, %rbx
xorl %r15d, %r15d
movb $0x1, %al
leaq 0x8(%rsp), %r14
xorl %ebp, %ebp
movl %eax, 0x4(%rsp)
leaq (,%r15,8), %rax
movq %rax, 0x10(%rsp)
movl $0x1, %r13d
movq 0x140(%rbx,%r15,8), %rax
andq 0x100(%rbx,%r13,8), %rax
movq %rax, 0x8(%rsp)
je 0x1d84c
movq 0x10(%rsp), %rax
leaq (%rax,%r13), %r12
shlq $0x8, %r12
leaq 0x39d9ed(%rip), %rax    # 0x3bb220
addq %rax, %r12
movq %r14, %rdi
callq 0x827b
cltq
addl (%r12,%rax,4), %ebp
cmpq $0x0, 0x8(%rsp)
jne 0x1d836
incq %r13
cmpq $0x7, %r13
jne 0x1d808
movl $0x1, %r15d
testb $0x1, 0x4(%rsp)
movl $0x0, %eax
jne 0x1d7f1
movl 0x39ea73(%rip), %eax    # 0x3bc2e0
movl %eax, %ecx
negl %ecx
cmpl $0x0, 0x1090(%rbx)
cmovel %eax, %ecx
movl $0x8000, %edx           # imm = 0x8000
leal (%rcx,%rdx), %eax
movl %eax, %esi
shrl $0x10, %esi
shrl $0x1f, %eax
addl %esi, %eax
cwtl
movl %ecx, %esi
andl $0x7fff, %esi           # imm = 0x7FFF
andl %edx, %ecx
subl %ecx, %esi
movzwl %si, %ecx
shrl $0xf, %ecx
addl %esi, %ecx
movswl %cx, %ecx
sarl %ecx
andl $-0x2, %eax
shll $0xf, %eax
addl %ebp, %eax
addl %ecx, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O3/ATOMIC-LICHESS[P]ATOMKRAFT/position.cpp
// Function: Position::compute_non_pawn_material(Color) const
Value Position::compute_non_pawn_material(Color c) const {

  Value result = VALUE_ZERO;

  for (PieceType pt = KNIGHT; pt <= QUEEN; pt++)
      result += piece_count(c, pt) * PieceValueMidgame[pt];

  return result;
}

// Assembly:
movl %esi, %eax
movdqu 0x39e95e(%rip), %xmm0   # 0x3bc228
shlq $0x5, %rax
movdqu 0x158(%rdi,%rax), %xmm1
pshufd $0xf5, %xmm0, %xmm2     # xmm2 = xmm0[1,1,3,3]
pmuludq %xmm1, %xmm0
pshufd $0xe8, %xmm0, %xmm0     # xmm0 = xmm0[0,2,2,3]
pshufd $0xf5, %xmm1, %xmm1     # xmm1 = xmm1[1,1,3,3]
pmuludq %xmm2, %xmm1
pshufd $0xe8, %xmm1, %xmm1     # xmm1 = xmm1[0,2,2,3]
punpckldq %xmm1, %xmm0    # xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
pshufd $0xee, %xmm0, %xmm1     # xmm1 = xmm0[2,3,2,3]
paddd %xmm0, %xmm1
pshufd $0x55, %xmm1, %xmm0     # xmm0 = xmm1[1,1,1,1]
paddd %xmm1, %xmm0
movd %xmm0, %eax
retq
// File: /workspace/github_cpp_makefile_star2_O3/ATOMIC-LICHESS[P]ATOMKRAFT/position.cpp
// Function: Position::neigh_is_ok()
bool Position::neigh_is_ok() {
	
	Square noSquares[64][9];
	Value neValue[64];
	
	write_neigh_arrays(noSquares, neValue);
	
	for (Square s = SQ_A1; s < SQ_NONE; ++s) {
		cout << s << endl;
		
		if (neValue[s] != neigh_expl_value(s)) {
			
#ifndef NDEBUG
			cout << "neValue - Square: " << s 
				 << ", neValue: " << neValue[s] 
				 << ", neigh_expl_value: " << neigh_expl_value(s) << endl;
#endif
			
			return false;
		}
		
		
		Bitboard b1 = EmptyBoardBB;
		Bitboard b2 = EmptyBoardBB;
		
		for (int k = 1; k <= noSquares[s][0]; ++k) {
			set_bit(&b1, noSquares[s][k]);
		}
		for (int k = 1; k <= neighOccSquares[s][0]; ++k) {
			set_bit(&b2, neighOccSquares[s][k]);
		}
		
		if (b1 != b2) {
			return false;
		}
	}
	
	return true;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xa18, %rsp            # imm = 0xA18
movq %rdi, %rbx
leaq 0x110(%rsp), %r14
leaq 0x10(%rsp), %rdx
movq %r14, %rsi
callq 0x1d90e
leaq 0x690(%rbx), %rax
movq %rax, (%rsp)
movq %rbx, 0x8(%rsp)
leaq 0x694(%rbx), %r15
xorl %r13d, %r13d
leaq 0xfb5f2(%rip), %rbx     # 0x1191a0
xorl %r12d, %r12d
movq 0x1f3e8(%rip), %rdi     # 0x3cfa0
movl %r13d, %esi
callq 0x5760
movq %rax, %rbp
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbp, %rdi
movl $0xa, %esi
callq 0x53c0
movsbl %al, %esi
movq %rbp, %rdi
callq 0x5050
movq %rax, %rdi
callq 0x5270
movl 0x10(%rsp,%r13,4), %eax
movq 0x8(%rsp), %rcx
cmpl 0xf90(%rcx,%r13,4), %eax
jne 0x1dc7b
leaq (,%r13,8), %rcx
addq %r13, %rcx
movl 0x110(%rsp,%rcx,4), %edx
testl %edx, %edx
jle 0x1dc30
incq %rdx
movl $0x1, %esi
xorl %eax, %eax
movslq (%r14,%rsi,4), %rdi
orq (%rbx,%rdi,8), %rax
incq %rsi
cmpq %rsi, %rdx
jne 0x1dc1e
jmp 0x1dc32
xorl %eax, %eax
movq (%rsp), %rdx
movl (%rdx,%rcx,4), %ecx
testl %ecx, %ecx
jle 0x1dc53
xorl %esi, %esi
xorl %edx, %edx
movslq (%r15,%rsi,4), %rdi
orq (%rbx,%rdi,8), %rdx
incq %rsi
cmpq %rsi, %rcx
jne 0x1dc41
jmp 0x1dc55
xorl %edx, %edx
cmpq %rdx, %rax
jne 0x1dc7b
cmpq $0x3f, %r13
leaq 0x1(%r13), %rax
setae %r12b
addq $0x24, %r14
addq $0x24, %r15
movq %rax, %r13
cmpq $0x40, %rax
jne 0x1dbb1
andb $0x1, %r12b
movl %r12d, %eax
addq $0xa18, %rsp            # imm = 0xA18
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O3/ATOMIC-LICHESS[P]ATOMKRAFT/position.cpp
// Function: Position::attacks_from(Piece, Square) const
Bitboard Position::attacks_from(Piece p, Square s) const {

  assert(square_is_ok(s));

  switch (p)
  {
  case WB: case BB: return attacks_from<BISHOP>(s);
  case WR: case BR: return attacks_from<ROOK>(s);
  case WQ: case BQ: return attacks_from<QUEEN>(s);
  default: return StepAttacksBB[p][s];
  }
}

// Assembly:
cmpl $0xd, %esi
ja 0x1e62c
movl $0x808, %eax            # imm = 0x808
btl %esi, %eax
jb 0x1e5d8
movl $0x1010, %eax           # imm = 0x1010
btl %esi, %eax
jb 0x1e587
movl $0x2020, %eax           # imm = 0x2020
btl %esi, %eax
jae 0x1e62c
movq 0x100(%rdi), %rsi
movslq %edx, %rax
leaq 0x282a8(%rip), %rcx     # 0x467a0
movq (%rcx,%rax,8), %rcx
andq %rsi, %rcx
leaq 0x110ba(%rip), %rdx     # 0x2f5c0
movq (%rdx,%rax,8), %rdx
movl %edx, %edi
imull %ecx, %edi
shrq $0x20, %rcx
shrq $0x20, %rdx
imull %ecx, %edx
xorl %edi, %edx
leaq 0x1139d(%rip), %rcx     # 0x2f8c0
movb (%rcx,%rax,4), %cl
shrl %cl, %edx
leaq 0x28471(%rip), %rcx     # 0x469a0
addl (%rcx,%rax,4), %edx
leaq 0xf0567(%rip), %rcx     # 0x10eaa0
andq (%rcx,%rax,8), %rsi
leaq 0x10e7c(%rip), %rcx     # 0x2f3c0
movq (%rcx,%rax,8), %rdi
movl %edi, %ecx
imull %esi, %ecx
shrq $0x20, %rsi
shrq $0x20, %rdi
imull %esi, %edi
xorl %ecx, %edi
leaq 0x1125f(%rip), %rcx     # 0x2f7c0
movb (%rcx,%rax,4), %cl
shrl %cl, %edi
leaq 0x28533(%rip), %rcx     # 0x46aa0
leaq 0xf072c(%rip), %rsi     # 0x10eca0
addl (%rsi,%rax,4), %edi
leaq 0xf0822(%rip), %rax     # 0x10eda0
movq (%rax,%rdi,8), %rax
orq (%rcx,%rdx,8), %rax
retq
movslq %edx, %rax
leaq 0x2820f(%rip), %rcx     # 0x467a0
movq (%rcx,%rax,8), %rcx
andq 0x100(%rdi), %rcx
leaq 0x283fd(%rip), %rdx     # 0x469a0
leaq 0x11016(%rip), %rsi     # 0x2f5c0
movq (%rsi,%rax,8), %rsi
movl %esi, %edi
imull %ecx, %edi
shrq $0x20, %rcx
shrq $0x20, %rsi
imull %ecx, %esi
xorl %edi, %esi
leaq 0x112f9(%rip), %rcx     # 0x2f8c0
movb (%rcx,%rax,4), %cl
shrl %cl, %esi
addl (%rdx,%rax,4), %esi
leaq 0x284ca(%rip), %rax     # 0x46aa0
jmp 0x1e627
movslq %edx, %rax
leaq 0xf04be(%rip), %rcx     # 0x10eaa0
movq (%rcx,%rax,8), %rcx
andq 0x100(%rdi), %rcx
leaq 0xf06ac(%rip), %rdx     # 0x10eca0
leaq 0x10dc5(%rip), %rsi     # 0x2f3c0
movq (%rsi,%rax,8), %rsi
movl %esi, %edi
imull %ecx, %edi
shrq $0x20, %rcx
shrq $0x20, %rsi
imull %ecx, %esi
xorl %edi, %esi
leaq 0x111a8(%rip), %rcx     # 0x2f7c0
movb (%rcx,%rax,4), %cl
shrl %cl, %esi
addl (%rdx,%rax,4), %esi
leaq 0xf0779(%rip), %rax     # 0x10eda0
movq (%rax,%rsi,8), %rax
retq
movl %esi, %eax
movslq %edx, %rcx
shlq $0x9, %rax
addq 0x1e99c(%rip), %rax     # 0x3cfd8
movq (%rax,%rcx,8), %rax
retq
nop
// File: /workspace/github_cpp_makefile_star2_O3/ATOMIC-LICHESS[P]ATOMKRAFT/position.cpp
// Function: Position::attacks_from(Piece, Square, unsigned long)
Bitboard Position::attacks_from(Piece p, Square s, Bitboard occ) {

  assert(square_is_ok(s));

  switch (p)
  {
  case WB: case BB: return bishop_attacks_bb(s, occ);
  case WR: case BR: return rook_attacks_bb(s, occ);
  case WQ: case BQ: return bishop_attacks_bb(s, occ) | rook_attacks_bb(s, occ);
  default: return StepAttacksBB[p][s];
  }
}

// Assembly:
cmpl $0xd, %edi
ja 0x1e7a5
movl $0x808, %eax            # imm = 0x808
btl %edi, %eax
jb 0x1e758
movl $0x1010, %eax           # imm = 0x1010
btl %edi, %eax
jb 0x1e70e
movl $0x2020, %eax           # imm = 0x2020
btl %edi, %eax
jae 0x1e7a5
movslq %esi, %rax
leaq 0xf0421(%rip), %rcx     # 0x10eaa0
movq (%rcx,%rax,8), %rcx
andq %rdx, %rcx
leaq 0x10d33(%rip), %rsi     # 0x2f3c0
movq (%rsi,%rax,8), %rsi
movl %esi, %edi
imull %ecx, %edi
shrq $0x20, %rcx
shrq $0x20, %rsi
imull %ecx, %esi
xorl %edi, %esi
leaq 0x11116(%rip), %rcx     # 0x2f7c0
movb (%rcx,%rax,4), %cl
shrl %cl, %esi
leaq 0xf05ea(%rip), %rcx     # 0x10eca0
addl (%rcx,%rax,4), %esi
leaq 0x280e0(%rip), %rcx     # 0x467a0
andq (%rcx,%rax,8), %rdx
leaq 0x10ef5(%rip), %rcx     # 0x2f5c0
movq (%rcx,%rax,8), %rdi
movl %edi, %ecx
imull %edx, %ecx
shrq $0x20, %rdx
shrq $0x20, %rdi
imull %edx, %edi
xorl %ecx, %edi
leaq 0x111d8(%rip), %rcx     # 0x2f8c0
movb (%rcx,%rax,4), %cl
shrl %cl, %edi
leaq 0xf06ac(%rip), %rcx     # 0x10eda0
leaq 0x282a5(%rip), %rdx     # 0x469a0
addl (%rdx,%rax,4), %edi
leaq 0x2839b(%rip), %rax     # 0x46aa0
movq (%rax,%rdi,8), %rax
orq (%rcx,%rsi,8), %rax
retq
movslq %esi, %rax
leaq 0x28088(%rip), %rcx     # 0x467a0
andq (%rcx,%rax,8), %rdx
leaq 0x2827d(%rip), %rsi     # 0x469a0
leaq 0x10e96(%rip), %rcx     # 0x2f5c0
movq (%rcx,%rax,8), %rdi
movl %edi, %ecx
imull %edx, %ecx
shrq $0x20, %rdx
shrq $0x20, %rdi
imull %edx, %edi
xorl %ecx, %edi
leaq 0x11179(%rip), %rcx     # 0x2f8c0
movb (%rcx,%rax,4), %cl
shrl %cl, %edi
addl (%rsi,%rax,4), %edi
leaq 0x2834a(%rip), %rax     # 0x46aa0
jmp 0x1e7a0
movslq %esi, %rax
leaq 0xf033e(%rip), %rcx     # 0x10eaa0
andq (%rcx,%rax,8), %rdx
leaq 0xf0533(%rip), %rsi     # 0x10eca0
leaq 0x10c4c(%rip), %rcx     # 0x2f3c0
movq (%rcx,%rax,8), %rdi
movl %edi, %ecx
imull %edx, %ecx
shrq $0x20, %rdx
shrq $0x20, %rdi
imull %edx, %edi
xorl %ecx, %edi
leaq 0x1102f(%rip), %rcx     # 0x2f7c0
movb (%rcx,%rax,4), %cl
shrl %cl, %edi
addl (%rsi,%rax,4), %edi
leaq 0xf0600(%rip), %rax     # 0x10eda0
movq (%rax,%rdi,8), %rax
retq
movl %edi, %eax
movslq %esi, %rcx
shlq $0x9, %rax
addq 0x1e823(%rip), %rax     # 0x3cfd8
movq (%rax,%rcx,8), %rax
retq
// File: /workspace/github_cpp_makefile_star2_O3/ATOMIC-LICHESS[P]ATOMKRAFT/position.cpp
// Function: Position::pl_move_is_evasion(Move, unsigned long) const
bool Position::pl_move_is_evasion(Move m, Bitboard pinned) const
{
  assert(in_check());

  NEW assert(color_of_piece_on(move_from(m)) == side_to_move());
  
  Color us = side_to_move();
  Square from = move_from(m);
  Square to = move_to(m);

  // King moves and en-passant captures are verified in pl_move_is_legal()
  if (type_of_piece_on(from) == KING || move_is_ep(m))
      return pl_move_is_legal(m, pinned);

  Bitboard target = checkers();
  Square checksq = pop_1st_bit(&target);

  if (target) // double check ?
      return false;

  // Our move must be a blocking evasion or a capture of the checking piece
  NEW assert(piece_count(us, KING));
  target = squares_between(checksq, king_square(us)) | checkers();
  return bit_is_set(target, to) && pl_move_is_legal(m, pinned);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x10, %rsp
movq %rdx, %rbx
movl %esi, %ebp
movq %rdi, %r14
movl %esi, %eax
andl $0xc000, %eax           # imm = 0xC000
cmpl $0x8000, %eax           # imm = 0x8000
je 0x1ec6e
movl %ebp, %eax
shrl $0x4, %eax
andl $0xfc, %eax
movl (%r14,%rax), %eax
andl $0x7, %eax
cmpl $0x6, %eax
je 0x1ec6e
movl 0x1090(%r14), %r12d
movq 0x1938(%r14), %rax
movq 0x40(%rax), %rax
leaq 0x8(%rsp), %r15
movq %rax, (%r15)
movq %r15, %rdi
callq 0x827b
cmpq $0x0, (%r15)
je 0x1ec87
xorl %eax, %eax
jmp 0x1ecd5
movq %r14, %rdi
movl %ebp, %esi
movq %rbx, %rdx
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x1e96c
movl %ebp, %ecx
andl $0x3f, %ecx
shlq $0x9, %r12
movslq 0x310(%r14,%r12), %rdx
cltq
shlq $0x9, %rax
addq 0x1e303(%rip), %rax     # 0x3cfa8
movq 0x1938(%r14), %rsi
movq 0x40(%rsi), %rsi
orq (%rax,%rdx,8), %rsi
movq %rsi, 0x8(%rsp)
movl %ecx, %eax
leaq 0xfa4de(%rip), %rcx     # 0x1191a0
testq %rsi, (%rcx,%rax,8)
je 0x1ec6a
movq %r14, %rdi
movl %ebp, %esi
movq %rbx, %rdx
callq 0x1e96c
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O3/ATOMIC-LICHESS[P]ATOMKRAFT/position.cpp
// Function: Position::move_is_legal(Move) const
bool Position::move_is_legal(const Move m) const {
	
	NEW // don't test that since it might be a tested tt
	//NEW assert(color_of_piece_on(move_from(m)) == side_to_move());
	
  MoveStack mlist[MAX_MOVES];
  MoveStack *cur, *last = generate<MV_PSEUDO_LEGAL>(*this, mlist);

   for (cur = mlist; cur != last; cur++)
      if (cur->move == m)
          return pl_move_is_legal(m, pinned_pieces(sideToMove));

  return false;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x800, %rsp            # imm = 0x800
movl %esi, %ebx
movq %rdi, %r14
movq %rsp, %r15
movq %r15, %rsi
callq 0x1a593
cmpq %rax, %r15
je 0x1ed0e
cmpl %ebx, (%r15)
je 0x1ed12
addq $0x8, %r15
jmp 0x1ecfe
xorl %eax, %eax
jmp 0x1ed2e
movl 0x1090(%r14), %esi
movq %r14, %rdi
callq 0x2132c
movq %r14, %rdi
movl %ebx, %esi
movq %rax, %rdx
callq 0x1e96c
addq $0x800, %rsp            # imm = 0x800
popq %rbx
popq %r14
popq %r15
retq
nop
// File: /workspace/github_cpp_makefile_star2_O3/ATOMIC-LICHESS[P]ATOMKRAFT/position.cpp
// Function: Position::do_setup_move(Move)
void Position::do_setup_move(Move m) {

  StateInfo newSt;

  do_move(m, newSt);

  // Reset "game ply" in case we made a non-reversible move.
  // "game ply" is used for repetition detection.
  if (st->rule50 == 0)
      st->gamePly = 0;

  // Update the number of plies played from the starting position
  startPosPlyCounter++;

  // Our StateInfo newSt is about going out of scope so copy
  // its content before it disappears.
  detach();
}

// Assembly:
pushq %r14
pushq %rbx
subq $0xa8, %rsp
movq %rdi, %rbx
leaq 0x8(%rsp), %rdx
callq 0x1f3d6
movq 0x1938(%rbx), %rsi
cmpl $0x0, 0x14(%rsi)
jne 0x1f39f
movl $0x0, 0x18(%rsi)
incl 0x1928(%rbx)
leaq 0x1878(%rbx), %r14
movl $0x98, %edx
movq %r14, %rdi
callq 0x5320
movq %r14, 0x1938(%rbx)
movq $0x0, 0x1910(%rbx)
addq $0xa8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_cpp_makefile_star2_O3/ATOMIC-LICHESS[P]ATOMKRAFT/position.cpp
// Function: Position::restore_piece(Color, Square, PieceType)
void Position::restore_piece(Color color, Square square, PieceType type) {
	// Restore the attacking piece 
	set_bit(&(byColorBB[color]), square);
	set_bit(&(byTypeBB[type]), square);
	set_bit(&(byTypeBB[0]), square); 

	board[square] = make_piece(color, type);

	// Update piece count
	pieceCount[color][type]++;

	// Update piece list, add a new captured piece in capsq square
	index[square] = pieceCount[color][type] - 1;
	pieceList[color][type][index[square]] = square;
}

// Assembly:
movl %esi, %r8d
movslq %edx, %rax
leaq 0xf8cef(%rip), %rdx     # 0x1191a0
movq (%rdx,%rax,8), %r9
orq %r9, 0x140(%rdi,%r8,8)
movl %ecx, %r9d
movq (%rdx,%rax,8), %r10
orq %r10, 0x100(%rdi,%r9,8)
movq (%rdx,%rax,8), %rdx
orq %rdx, 0x100(%rdi)
shll $0x3, %esi
orl %ecx, %esi
movl %esi, (%rdi,%rax,4)
movq %r8, %rcx
shlq $0x5, %rcx
addq %rdi, %rcx
movslq 0x150(%rcx,%r9,4), %rdx
leal 0x1(%rdx), %esi
movl %esi, 0x150(%rcx,%r9,4)
movl %edx, 0x590(%rdi,%rax,4)
shlq $0x9, %r8
addq %rdi, %r8
shlq $0x6, %r9
addq %r8, %r9
movl %eax, 0x190(%r9,%rdx,4)
retq
// File: /workspace/github_cpp_makefile_star2_O3/ATOMIC-LICHESS[P]ATOMKRAFT/position.cpp
// Function: Position::do_null_move(StateInfo&)
void Position::do_null_move(StateInfo& backupSt) {

  assert(is_ok());
  assert(!in_check());

  // Back up the information necessary to undo the null move to the supplied
  // StateInfo object.
  // Note that differently from normal case here backupSt is actually used as
  // a backup storage not as a new state to be used.
  backupSt.key      = st->key;
  backupSt.epSquare = st->epSquare;
  backupSt.value    = st->value;
  backupSt.previous = st->previous;
  backupSt.pliesFromNull = st->pliesFromNull;
  st->previous = &backupSt;

  // Save the current key to the history[] array, in order to be able to
  // detect repetition draws.
  history[st->gamePly++] = st->key;

  // Update the necessary information
  if (st->epSquare != SQ_NONE)
      st->key ^= zobEp[st->epSquare];

  st->key ^= zobSideToMove;
  
  // TODO: PREFETCH
  prefetch((char*)TT.first_entry(st->key));

  sideToMove = opposite_color(sideToMove);
  st->epSquare = SQ_NONE;
  st->rule50++;
  st->pliesFromNull = 0;
  st->value += (sideToMove == WHITE) ?  TempoValue : -TempoValue;
}

// Assembly:
pushq %rbx
movq %rdi, %rbx
movq 0x1938(%rdi), %rax
movq 0x38(%rax), %rcx
movq %rcx, 0x38(%rsi)
movq 0x20(%rax), %rdx
movq %rdx, 0x20(%rsi)
movq 0x98(%rax), %rdi
movq %rdi, 0x98(%rsi)
movl 0x1c(%rax), %edi
movl %edi, 0x1c(%rsi)
movq %rsi, 0x98(%rax)
movslq 0x18(%rax), %rsi
leal 0x1(%rsi), %edi
movl %edi, 0x18(%rax)
movq %rcx, 0x1098(%rbx,%rsi,8)
movq 0x38(%rax), %rcx
cmpl $0x40, %edx
je 0x20a81
movslq %edx, %rdx
leaq 0x39a513(%rip), %rsi    # 0x3baf90
xorq (%rsi,%rdx,8), %rcx
xorq 0x39a788(%rip), %rcx    # 0x3bb210
movq %rcx, 0x38(%rax)
leaq 0x3abc4d(%rip), %rax    # 0x3cc6e0
movl (%rax), %edi
decl %edi
andl %ecx, %edi
shlq $0x6, %rdi
addq 0x8(%rax), %rdi
callq 0x17542
movl 0x1090(%rbx), %eax
movl %eax, %ecx
xorl $0x1, %ecx
movl %ecx, 0x1090(%rbx)
movq 0x1938(%rbx), %rcx
incl 0x14(%rcx)
movabsq $0x4000000000, %rdx     # imm = 0x4000000000
movq %rdx, 0x1c(%rcx)
movl 0x39b80b(%rip), %edx    # 0x3bc2e0
movl %edx, %esi
negl %esi
cmpl $0x1, %eax
cmovel %edx, %esi
addl %esi, 0x24(%rcx)
popq %rbx
retq
// File: /workspace/github_cpp_makefile_star2_O3/ATOMIC-LICHESS[P]ATOMKRAFT/position.cpp
// Function: Position::init_zobrist()
void Position::init_zobrist() {

  int i,j, k;
  RKISS rk;

  for (i = 0; i < 2; i++) for (j = 0; j < 8; j++) for (k = 0; k < 64; k++)
      zobrist[i][j][k] = rk.rand<Key>();

  for (i = 0; i < 64; i++)
      zobEp[i] = rk.rand<Key>();

  for (i = 0; i < 16; i++)
      zobCastle[i] = rk.rand<Key>();

  zobSideToMove = rk.rand<Key>();
  zobExclusion  = rk.rand<Key>();
}

// Assembly:
pushq %r14
pushq %rbx
movabsq $-0x2c1f8a302bb644e2, %rax # imm = 0xD3E075CFD449BB1E
movabsq $-0x440b26c48dff17a8, %rsi # imm = 0xBBF4D93B7200E858
movabsq $-0x3bf8842205306785, %rdx # imm = 0xC4077BDDFACF987B
movabsq $0x46dd577ff603b540, %rcx # imm = 0x46DD577FF603B540
movb $0x1, %dil
xorl %r8d, %r8d
leaq 0x398306(%rip), %r9     # 0x3b8f90
shlq $0xc, %r8
addq %r9, %r8
xorl %r10d, %r10d
xorl %r11d, %r11d
movq %rsi, %rbx
movq %rdx, %rsi
rolq $0x7, %rsi
movq %rcx, %r14
movq %rbx, %rcx
rolq $0xd, %rcx
subq %rsi, %r14
leaq (%r14,%rax), %rsi
rolq $0x25, %rax
xorq %rdx, %rcx
movq %rax, %rdx
addq %rbx, %rdx
movq %r14, %rax
addq %rcx, %rax
movq %rax, (%r8,%r11,8)
incq %r11
cmpq $0x40, %r11
jne 0x20c97
incq %r10
addq $0x200, %r8             # imm = 0x200
cmpq $0x8, %r10
jne 0x20c94
movl $0x1, %r8d
testb $0x1, %dil
movl $0x0, %edi
jne 0x20c8a
xorl %edi, %edi
leaq 0x39a294(%rip), %r8     # 0x3baf90
movq %rsi, %r9
movq %rdx, %rsi
rolq $0x7, %rsi
movq %rcx, %r10
movq %r9, %rcx
rolq $0xd, %rcx
subq %rsi, %r10
leaq (%r10,%rax), %rsi
rolq $0x25, %rax
xorq %rdx, %rcx
movq %rax, %rdx
addq %r9, %rdx
movq %r10, %rax
addq %rcx, %rax
movq %rax, (%rdi,%r8)
addq $0x8, %rdi
cmpq $0x200, %rdi            # imm = 0x200
jne 0x20cfc
xorl %edi, %edi
leaq 0x39a44c(%rip), %r8     # 0x3bb190
movq %rsi, %r9
movq %rdx, %rsi
rolq $0x7, %rsi
movq %rcx, %r10
movq %r9, %rcx
rolq $0xd, %rcx
subq %rsi, %r10
leaq (%r10,%rax), %rsi
rolq $0x25, %rax
xorq %rdx, %rcx
movq %rax, %rdx
addq %r9, %rdx
movq %r10, %rax
addq %rcx, %rax
movq %rax, (%rdi,%r8)
addq $0x8, %rdi
cmpq $0x80, %rdi
jne 0x20d44
movq %rdx, %rdi
rolq $0x7, %rdi
subq %rdi, %rcx
movq %rsi, %rdi
rolq $0xd, %rdi
xorq %rdx, %rdi
leaq (%rcx,%rax), %rdx
rolq $0x25, %rax
addq %rsi, %rax
addq %rdi, %rcx
movq %rcx, 0x39a464(%rip)    # 0x3bb210
movq %rax, %rcx
rolq $0x7, %rcx
rolq $0xd, %rdx
subq %rcx, %rdi
xorq %rax, %rdx
addq %rdi, %rdx
movq %rdx, 0x39a451(%rip)    # 0x3bb218
popq %rbx
popq %r14
retq
nop
// File: /workspace/github_cpp_makefile_star2_O3/ATOMIC-LICHESS[P]ATOMKRAFT/position.cpp
// Function: Position::init_piece_square_tables()
void Position::init_piece_square_tables() {

  for (Square s = SQ_A1; s <= SQ_H8; s++)
      for (Piece p = WP; p <= WK; p++)
          PieceSquareTable[p][s] = make_score(MgPST[p][s], EgPST[p][s]);

  for (Square s = SQ_A1; s <= SQ_H8; s++)
      for (Piece p = BP; p <= BK; p++)
          PieceSquareTable[p][s] = -PieceSquareTable[p-8][flip_square(s)];
}

// Assembly:
leaq 0x39322d(%rip), %rcx    # 0x3b4000
movl $0x100, %edx            # imm = 0x100
addq %rdx, %rcx
leaq 0x39393e(%rip), %rsi    # 0x3b4720
addq %rdx, %rsi
leaq 0x39a434(%rip), %rax    # 0x3bb220
addq %rax, %rdx
xorl %edi, %edi
xorl %r8d, %r8d
movl (%rcx,%r8), %r9d
shll $0x10, %r9d
addl (%rsi,%r8), %r9d
movl %r9d, (%rdx,%r8)
addq $0x100, %r8             # imm = 0x100
cmpq $0x600, %r8             # imm = 0x600
jne 0x20df4
incq %rdi
addq $0x4, %rcx
addq $0x4, %rsi
addq $0x4, %rdx
cmpq $0x40, %rdi
jne 0x20df1
leaq 0x39acf0(%rip), %rcx    # 0x3bbb20
xorl %edx, %edx
movl %edx, %esi
xorq $0x38, %rsi
leaq (%rax,%rsi,4), %rsi
addq $0x100, %rsi            # imm = 0x100
xorl %edi, %edi
xorl %r8d, %r8d
subl (%rsi,%rdi), %r8d
movl %r8d, (%rcx,%rdi)
addq $0x100, %rdi            # imm = 0x100
cmpq $0x600, %rdi            # imm = 0x600
jne 0x20e45
incq %rdx
addq $0x4, %rcx
cmpq $0x40, %rdx
jne 0x20e32
retq
// File: /workspace/github_cpp_makefile_star2_O3/ATOMIC-LICHESS[P]ATOMKRAFT/position.cpp
// Function: bool Position::is_draw<false>() const
bool Position::is_draw() const {

  // Draw by material?
  if (   !pieces(PAWN)
      && (non_pawn_material(WHITE) + non_pawn_material(BLACK) <= BishopValueMidgame))
      return true;

  // Draw by the 50 moves rule?
  if (st->rule50 > 99 && !is_mate())
      return true;

  // Draw by repetition?

#if 0
  if (false && !SkipRepetition) // not working in Atomic :(
  {
      int i = 4, e = Min(st->rule50, st->pliesFromNull);

      if (st && st->previous && i <= e)
      {
          StateInfo* stp = st->previous->previous;
	  if (stp && stp->previous)
	    {
	      do {
		stp = stp->previous->previous;

		if (stp && stp->key == st->key)
                  return true;

		i +=2;
		
	      } while (i <= e);
	    }
      }
  }
#else // here is the SF 2.1.1 code, not sure what ATOMKRAFT was doing ?
      // seems to have mixed-matched from later code, with state->previous
      // rather than history to detect draws
  for (int i = 4, e = Min(Min(st->gamePly, st->rule50), st->pliesFromNull);
       i <= e; i += 2)
    if (history[st->gamePly - i] == st->key)
      return true;
#endif
  return false;
}

// Assembly:
pushq %rbx
movq %rdi, %rbx
cmpq $0x0, 0x108(%rdi)
movq 0x1938(%rdi), %rcx
jne 0x21726
movl 0x2c(%rcx), %edx
addl 0x28(%rcx), %edx
leaq 0x1bd38(%rip), %rsi     # 0x3d458
movb $0x1, %al
cmpl (%rsi), %edx
jle 0x21790
movl 0x14(%rcx), %eax
cmpl $0x64, %eax
jl 0x21748
movq %rbx, %rdi
callq 0x20c08
movl %eax, %ecx
movb $0x1, %al
testb %cl, %cl
je 0x21790
movq 0x1938(%rbx), %rcx
movl 0x14(%rcx), %eax
movslq 0x18(%rcx), %rsi
cmpl %eax, %esi
cmovll %esi, %eax
movl 0x1c(%rcx), %edx
cmpl %edx, %eax
cmovgel %edx, %eax
cmpl $0x4, %eax
jl 0x2178e
movq 0x38(%rcx), %rcx
movl %eax, %edx
leaq (%rbx,%rsi,8), %rsi
addq $0x1078, %rsi           # imm = 0x1078
movl $0x6, %edi
cmpq %rcx, (%rsi)
sete %al
je 0x21790
leaq 0x2(%rdi), %r8
addq $-0x10, %rsi
cmpq %rdx, %rdi
movq %r8, %rdi
jbe 0x21774
jmp 0x21790
xorl %eax, %eax
popq %rbx
retq
// File: /workspace/github_cpp_makefile_star2_O3/ATOMIC-LICHESS[P]ATOMKRAFT/search.cpp
// Function: (anonymous namespace)::speed_to_uci[abi:cxx11](long)
std::string speed_to_uci(int64_t nodes) {

    std::stringstream s;
    int64_t t = current_search_time();
    int64_t us = int64_t(current_cpu_usage()); // mult by 1000
    HACK_NPS = t>0 ? (nodes*1000)/t : 0;
    s << " nodes " << nodes << " nps " << HACK_NPS << " time " << t;
    if (t>1000) s << " cpuload " << (t>0 ? (1000*us)/t : 0)
		  << " hashfull " << TT.full (nodes);
    return s.str();
  }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x188, %rsp            # imm = 0x188
movq %rsi, %r14
movq %rdi, %rbx
movq %rsp, %rdi
callq 0x5290
callq 0x173f0
movq %rax, %r15
subq 0x39cc62(%rip), %r15    # 0x3c1a70
callq 0x1742e
movq %rax, %r12
subq 0x39cc5b(%rip), %r12    # 0x3c1a78
testq %r15, %r15
jle 0x24e30
imulq $0x3e8, %r14, %rax      # imm = 0x3E8
cqto
idivq %r15
jmp 0x24e32
xorl %eax, %eax
movq %rax, 0x39abef(%rip)    # 0x3bfa28
leaq 0x10(%rsp), %r13
leaq 0xe6ae(%rip), %rsi      # 0x334f3
movl $0x7, %edx
movq %r13, %rdi
callq 0x5460
movq %r13, %rdi
movq %r14, %rsi
callq 0x5390
movq %rax, %rbp
leaq 0xe694(%rip), %rsi      # 0x334fb
movl $0x5, %edx
movq %rax, %rdi
callq 0x5460
movq 0x39abad(%rip), %rsi    # 0x3bfa28
movq %rbp, %rdi
callq 0x5390
movq %rax, %rbp
leaq 0xe62d(%rip), %rsi      # 0x334ba
movl $0x6, %edx
movq %rax, %rdi
callq 0x5460
movq %rbp, %rdi
movq %r15, %rsi
callq 0x5390
cmpq $0x3e9, %r15            # imm = 0x3E9
jl 0x24f09
leaq 0xe64c(%rip), %rsi      # 0x33501
movl $0x9, %edx
movq %r13, %rdi
callq 0x5460
imulq $0x3e8, %r12, %rax      # imm = 0x3E8
cqto
idivq %r15
movq %r13, %rdi
movq %rax, %rsi
callq 0x5390
movq %rax, %r15
leaq 0xe628(%rip), %rsi      # 0x3350b
movl $0xa, %edx
movq %rax, %rdi
callq 0x5460
leaq 0x3a77e9(%rip), %rdi    # 0x3cc6e0
movq %r14, %rsi
callq 0x2a30e
movl %eax, %esi
movq %r15, %rdi
callq 0x5260
leaq 0x18(%rsp), %rsi
movq %rbx, %rdi
callq 0x5690
movq 0x1801b(%rip), %rsi     # 0x3cf38
movq %rsp, %rdi
callq 0x52c0
leaq 0x80(%rsp), %rdi
callq 0x5140
addq $0x188, %rsp            # imm = 0x188
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x24f46
movq %rax, %rbx
movq 0x17fe8(%rip), %rsi     # 0x3cf38
movq %rsp, %rdi
callq 0x52c0
leaq 0x80(%rsp), %rdi
callq 0x5140
movq %rbx, %rdi
callq 0x5790
nop
// File: /workspace/github_cpp_makefile_star2_O3/ATOMIC-LICHESS[P]ATOMKRAFT/search.cpp
// Function: (anonymous namespace)::value_to_uci[abi:cxx11](Value)
std::string value_to_uci(Value v) {

    std::stringstream s;

    if (abs(v) < VALUE_MATE - PLY_MAX * ONE_PLY)
        s << "cp " << int(v) * 100 / int(PawnValueMidgame); // Scale to centipawns
    else
        s << "mate " << (v > 0 ? VALUE_MATE - v + 1 : -VALUE_MATE - v) / 2;

    return s.str();
  }

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
subq $0x190, %rsp            # imm = 0x190
movl %esi, %ebp
movq %rdi, %rbx
leaq 0x8(%rsp), %rdi
callq 0x5290
movl %ebp, %eax
negl %eax
cmovsl %ebp, %eax
leaq 0x18(%rsp), %r14
cmpl $0x7467, %eax           # imm = 0x7467
ja 0x25e40
leaq 0xd644(%rip), %rsi      # 0x33466
movl $0x3, %edx
movq %r14, %rdi
callq 0x5460
imull $0x64, %ebp, %eax
leaq 0x1760f(%rip), %rcx     # 0x3d448
cltd
idivl (%rcx)
movl %eax, %esi
jmp 0x25e6e
leaq 0xd623(%rip), %rsi      # 0x3346a
movl $0x5, %edx
movq %r14, %rdi
callq 0x5460
testl %ebp, %ebp
movl $0x7531, %eax           # imm = 0x7531
movl $0xffff8ad0, %ecx       # imm = 0xFFFF8AD0
cmovgl %eax, %ecx
subl %ebp, %ecx
movl %ecx, %esi
shrl $0x1f, %esi
addl %ecx, %esi
sarl %esi
movq %r14, %rdi
callq 0x5760
leaq 0x20(%rsp), %rsi
movq %rbx, %rdi
callq 0x5690
movq 0x170ae(%rip), %rsi     # 0x3cf38
leaq 0x8(%rsp), %rdi
callq 0x52c0
leaq 0x88(%rsp), %rdi
callq 0x5140
addq $0x190, %rsp            # imm = 0x190
popq %rbx
popq %r14
popq %rbp
retq
movq %rax, %rbx
movq 0x17081(%rip), %rsi     # 0x3cf38
leaq 0x8(%rsp), %rdi
callq 0x52c0
leaq 0x88(%rsp), %rdi
callq 0x5140
movq %rbx, %rdi
callq 0x5790
// File: /workspace/github_cpp_makefile_star2_O3/ATOMIC-LICHESS[P]ATOMKRAFT/search.cpp
// Function: (anonymous namespace)::update_gains(Position const&, Move, Value, Value)
void update_gains(const Position& pos, Move m, Value before, Value after) {

    if (   m != MOVE_NULL
        && before != VALUE_NONE
        && after != VALUE_NONE
        && pos.captured_piece_type() == PIECE_TYPE_NONE
        && !move_is_special(m))
        H.update_gain(pos.piece_on(move_to(m)), move_to(m), -(before + after));
  }

// Assembly:
cmpl $0x41, %esi
sete %al
movl $0x7532, %r8d           # imm = 0x7532
cmpl %r8d, %edx
sete %r9b
orb %al, %r9b
cmpl %r8d, %ecx
sete %al
orb %r9b, %al
jne 0x265d4
movq 0x1938(%rdi), %rax
movl %esi, %r8d
andl $0xc000, %r8d           # imm = 0xC000
orl 0x30(%rax), %r8d
je 0x265d5
retq
andl $0x3f, %esi
shll $0x2, %esi
movl (%rdi,%rsi), %eax
addl %ecx, %edx
negl %edx
shlq $0x8, %rax
leaq 0x399453(%rip), %rcx    # 0x3bfa40
addq %rax, %rcx
movl 0x1000(%rsi,%rcx), %eax
decl %eax
cmpl %edx, %eax
cmovlel %edx, %eax
movl %eax, 0x1000(%rsi,%rcx)
retq