// File: /workspace/github_cpp_makefile_star2_O1/ATOMIC-LICHESS[P]ATOMKRAFT/position.cpp
// Function: CheckInfo::CheckInfo(Position const&)
CheckInfo::CheckInfo(const Position& pos) {

  Color us = pos.side_to_move();
  Color them = opposite_color(us);
  
  STARTNEW
  // FIXME: this cuts the possibility of detecting errors
  // but seems to be the easiest way to handle calls in qsearch and search
  if (pos.piece_count(them, KING) == 0 || pos.piece_count(us, KING) == 0) {
	  return;
  }
  ENDNEW
  
  NEW assert(pos.piece_count(them, KING));
  NEW assert(pos.piece_count(us, KING));
  NEW Square us_ksq = pos.king_square(us);
  ksq = pos.king_square(them);
  dcCandidates = pos.discovered_check_candidates(us);
  
  STARTNEW if (squares_touch[ksq][us_ksq]) {
	  checkSq[PAWN] 	= EmptyBoardBB;
	  checkSq[KNIGHT] 	= EmptyBoardBB;
	  checkSq[BISHOP] 	= EmptyBoardBB;
	  checkSq[ROOK] 	= EmptyBoardBB;
	  checkSq[QUEEN] 	= EmptyBoardBB;
	  checkSq[KING] 	= EmptyBoardBB;
  ENDNEW } else {
	  checkSq[PAWN] 	= pos.attacks_from<PAWN>(ksq, them);
	  checkSq[KNIGHT] 	= pos.attacks_from<KNIGHT>(ksq);
	  checkSq[BISHOP] 	= pos.attacks_from<BISHOP>(ksq);
	  checkSq[ROOK] 	= pos.attacks_from<ROOK>(ksq);
	  checkSq[QUEEN] 	= checkSq[BISHOP] | checkSq[ROOK];
	  checkSq[KING] 	= EmptyBoardBB;
  NEW }
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %r14
movl 0x1090(%rsi), %esi
movq %rsi, %r15
xorq $0x1, %r15
movq %r15, %rax
shlq $0x5, %rax
cmpl $0x0, 0x168(%r14,%rax)
je 0x1c720
leaq 0x150(%r14), %rax
movq %rsi, %rcx
shlq $0x5, %rcx
cmpl $0x0, 0x18(%rax,%rcx)
je 0x1c720
movq %rdi, %rbx
movq %rsi, %rax
shlq $0x9, %rax
movslq 0x310(%r14,%rax), %r12
movq %r15, %rax
shlq $0x9, %rax
movl 0x310(%r14,%rax), %eax
movl %eax, 0x48(%rdi)
movq %r14, %rdi
callq 0x20f7c
movq %rax, (%rbx)
movslq 0x48(%rbx), %rax
movq %rax, %rcx
shlq $0x6, %rcx
addq 0x1f958(%rip), %rcx     # 0x3bf78
cmpb $0x0, (%r12,%rcx)
je 0x1c63b
xorps %xmm0, %xmm0
movups %xmm0, 0x30(%rbx)
movups %xmm0, 0x20(%rbx)
movups %xmm0, 0x10(%rbx)
jmp 0x1c720
leal 0x1(,%r15,8), %ecx
shlq $0x9, %rcx
leaq 0xfc102(%rip), %rdx     # 0x118750
leaq (%rdx,%rax,8), %rsi
movq (%rcx,%rsi), %rcx
movq %rcx, 0x10(%rbx)
movq 0x400(%rdx,%rax,8), %rcx
movq %rcx, 0x18(%rbx)
leaq 0xf1433(%rip), %rcx     # 0x10daa0
movq (%rcx,%rax,8), %rcx
andq 0x100(%r14), %rcx
leaq 0x11cc1(%rip), %rdx     # 0x2e340
movq (%rdx,%rax,8), %rdx
movl %edx, %esi
imull %ecx, %esi
shrq $0x20, %rcx
shrq $0x20, %rdx
imull %ecx, %edx
xorl %esi, %edx
leaq 0x120a4(%rip), %rcx     # 0x2e740
movb (%rcx,%rax,4), %cl
shrl %cl, %edx
leaq 0xf15f8(%rip), %rcx     # 0x10dca0
addl (%rcx,%rax,4), %edx
leaq 0xf16ee(%rip), %rcx     # 0x10dda0
movq (%rcx,%rdx,8), %rdx
movq %rdx, 0x20(%rbx)
leaq 0x290df(%rip), %rcx     # 0x457a0
movq (%rcx,%rax,8), %rcx
andq 0x100(%r14), %rcx
leaq 0x292cd(%rip), %rsi     # 0x459a0
leaq 0x11e66(%rip), %rdi     # 0x2e540
movq (%rdi,%rax,8), %rdi
movl %edi, %r8d
imull %ecx, %r8d
shrq $0x20, %rcx
shrq $0x20, %rdi
imull %ecx, %edi
xorl %r8d, %edi
leaq 0x12146(%rip), %rcx     # 0x2e840
movb (%rcx,%rax,4), %cl
shrl %cl, %edi
addl (%rsi,%rax,4), %edi
leaq 0x29397(%rip), %rax     # 0x45aa0
movq (%rax,%rdi,8), %rax
movq %rax, 0x28(%rbx)
orq %rdx, %rax
movq %rax, 0x30(%rbx)
movq $0x0, 0x38(%rbx)
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq