// File: /workspace/github_cpp_makefile_star2_O2/ATOMIC-LICHESS[P]ATOMKRAFT/movegen.cpp
// Function: MoveStack* generate<(MoveType)3>(Position const&, MoveStack*)
MoveStack* generate<MV_NON_CAPTURE_CHECK>(const Position& pos, MoveStack* mlist) {
  NEW assert(pos.piece_count(WHITE, KING) && pos.piece_count(BLACK, KING));
		
  assert(pos.is_ok());
  assert(!pos.in_check());

  Bitboard b, dc;
  Square from;
  Color us = pos.side_to_move();
  NEW assert(pos.piece_count(opposite_color(us), KING));
  Square ksq = pos.king_square(opposite_color(us));

  assert(pos.piece_on(ksq) == make_piece(opposite_color(us), KING));

  // Discovered non-capture checks
  b = dc = pos.discovered_check_candidates(us);

  while (b)
  {
     from = pop_1st_bit(&b);
     switch (pos.type_of_piece_on(from))
     {
      case PAWN:   /* Will be generated togheter with pawns direct checks */     break;
      case KNIGHT: mlist = generate_discovered_checks<KNIGHT>(pos, mlist, from); break;
      case BISHOP: mlist = generate_discovered_checks<BISHOP>(pos, mlist, from); break;
      case ROOK:   mlist = generate_discovered_checks<ROOK>(pos, mlist, from);   break;
      case KING:   mlist = generate_discovered_checks<KING>(pos, mlist, from);   break;
      default: assert(false); break;
     }
  }

  // Direct non-capture checks
  mlist = generate_direct_checks<PAWN>(pos, mlist, us, dc, ksq);
  mlist = generate_direct_checks<KNIGHT>(pos, mlist, us, dc, ksq);
  mlist = generate_direct_checks<BISHOP>(pos, mlist, us, dc, ksq);
  mlist = generate_direct_checks<ROOK>(pos, mlist, us, dc, ksq);
  return  generate_direct_checks<QUEEN>(pos, mlist, us, dc, ksq);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rsi, %rbx
movq %rdi, %r14
movl 0x1090(%rdi), %esi
movq %rsi, %rax
xorq $0x1, %rax
leaq 0x190(%rdi), %rcx
movq %rcx, 0x20(%rsp)
shlq $0x9, %rax
movslq 0x310(%rdi,%rax), %rcx
movq %rcx, 0x30(%rsp)
movl %ecx, %eax
movq %rax, 0x28(%rsp)
movq %rsi, 0x8(%rsp)
callq 0x17348
leaq 0x40(%rsp), %rcx
movq %rcx, %r15
movq %rax, (%rcx)
leaq 0x15134(%rip), %rbp     # 0x295f0
movq %rsp, %r13
movq %rax, 0x18(%rsp)
testq %rax, %rax
je 0x14622
movq %r15, %rdi
callq 0x7b62
movl %eax, %r12d
cltq
movl (%r14,%rax,4), %ecx
andl $0x7, %ecx
addl $-0x2, %ecx
cmpl $0x4, %ecx
ja 0x14618
movslq (%rbp,%rcx,4), %rcx
addq %rbp, %rcx
jmpq *%rcx
movq 0x100(%r14), %rcx
notq %rcx
leaq 0xfd248(%rip), %rdx     # 0x111750
andq 0x400(%rdx,%rax,8), %rcx
movq %rcx, (%rsp)
shll $0x6, %r12d
testq %rcx, %rcx
je 0x14618
movq %r13, %rdi
callq 0x7b62
orl %r12d, %eax
movl %eax, (%rbx)
addq $0x8, %rbx
movq (%rsp), %rcx
jmp 0x14518
movq %r14, %rdi
movl %r12d, %esi
callq 0x12330
movq 0x100(%r14), %rcx
notq %rcx
andq %rax, %rcx
movq %rcx, (%rsp)
shll $0x6, %r12d
testq %rcx, %rcx
je 0x14618
movq %r13, %rdi
callq 0x7b62
orl %r12d, %eax
movl %eax, (%rbx)
addq $0x8, %rbx
movq (%rsp), %rcx
jmp 0x14558
movq %r14, %rdi
movl %r12d, %esi
callq 0xcf20
movq 0x100(%r14), %rcx
notq %rcx
andq %rax, %rcx
movq %rcx, (%rsp)
shll $0x6, %r12d
testq %rcx, %rcx
je 0x14618
movq %r13, %rdi
callq 0x7b62
orl %r12d, %eax
movl %eax, (%rbx)
addq $0x8, %rbx
movq (%rsp), %rcx
jmp 0x14598
movl 0x1090(%r14), %ecx
xorq $0x1, %rcx
shlq $0x9, %rcx
movq 0x20(%rsp), %rdx
movslq 0x180(%rdx,%rcx), %rcx
leaq 0x108179(%rip), %rdx    # 0x11c750
movq (%rdx,%rcx,8), %rcx
orq 0x100(%r14), %rcx
notq %rcx
leaq 0xfd164(%rip), %rdx     # 0x111750
andq 0xc00(%rdx,%rax,8), %rcx
movq %rcx, (%rsp)
shll $0x6, %r12d
testq %rcx, %rcx
je 0x14618
movq %r13, %rdi
callq 0x7b62
orl %r12d, %eax
movl %eax, (%rbx)
addq $0x8, %rbx
movq (%rsp), %rcx
jmp 0x145fc
movq 0x40(%rsp), %rax
jmp 0x144c4
movabsq $0xffffffffffff00, %rbp # imm = 0xFFFFFFFFFFFF00
movq 0x8(%rsp), %r15
testq %r15, %r15
je 0x147b3
movq 0x148(%r14), %rsi
andq 0x108(%r14), %rsi
movq 0x100(%r14), %rdi
notq %rdi
movq %rsi, %rax
shrq $0x8, %rax
andq %rdi, %rbp
andq %rax, %rbp
movq %rsi, %rcx
andq $0xff00, %rcx           # imm = 0xFF00
je 0x146e0
movq %rsi, 0x38(%rsp)
shrl $0x8, %ecx
movq %rdi, %r13
movl %edi, %eax
andl %ecx, %eax
movq %rsp, %r12
movq %rax, (%r12)
leaq 0xfcb18(%rip), %r15     # 0x1111a0
testq %rax, %rax
je 0x146d3
movq %r12, %rdi
callq 0x7b62
movslq %eax, %rcx
movslq 0x310(%r14), %rdx
movq (%r15,%rdx,8), %rdx
leaq 0xfd0a6(%rip), %rsi     # 0x111750
testq %rdx, 0x400(%rsi,%rcx,8)
je 0x146cd
movl %eax, %ecx
shll $0x6, %ecx
addl $0x200, %ecx            # imm = 0x200
orl %eax, %ecx
orl $0x4000, %ecx           # imm = 0x4000
movl %ecx, (%rbx)
addq $0x8, %rbx
movq (%rsp), %rax
jmp 0x14688
movq 0x8(%rsp), %r15
movq 0x38(%rsp), %rsi
movq %r13, %rdi
movq %rbp, %r13
shrq $0x8, %r13
movabsq $0xff00000000, %rax     # imm = 0xFF00000000
andq %rdi, %rax
andq %rax, %r13
movq 0x30(%rsp), %rcx
leaq 0xfd04d(%rip), %rdx     # 0x111750
movq 0x200(%rdx,%rcx,8), %rcx
andq %rcx, %rbp
movq %rbp, (%rsp)
andq %rcx, %r13
movq %r13, 0x10(%rsp)
andq 0x18(%rsp), %rsi
je 0x1475a
movq 0x28(%rsp), %rcx
andl $0x7, %ecx
leaq 0xfcea0(%rip), %rdx     # 0x1115d0
movq (%rdx,%rcx,8), %rcx
notq %rcx
andq %rcx, %rsi
shrq $0x8, %rsi
andq %rdi, %rsi
movq %rsi, %rcx
shrq $0x8, %rcx
andq %rax, %rcx
orq %rsi, %rbp
movq %rbp, (%rsp)
orq %rcx, %r13
movq %r13, 0x10(%rsp)
movq %rsp, %r12
testq %rbp, %rbp
je 0x14783
movq %r12, %rdi
callq 0x7b62
movl %eax, %ecx
shll $0x6, %ecx
addl $0x200, %ecx            # imm = 0x200
orl %eax, %ecx
movl %ecx, (%rbx)
addq $0x8, %rbx
movq (%rsp), %rbp
jmp 0x1475d
leaq 0x10(%rsp), %r12
testq %r13, %r13
je 0x14922
movq %r12, %rdi
callq 0x7b62
movl %eax, %ecx
shll $0x6, %ecx
addl $0x400, %ecx            # imm = 0x400
orl %eax, %ecx
movl %ecx, (%rbx)
addq $0x8, %rbx
movq 0x10(%rsp), %r13
jmp 0x14788
movq 0x140(%r14), %rdi
andq 0x108(%r14), %rdi
movq 0x100(%r14), %r8
notq %r8
movq %rdi, %rax
shlq $0x8, %rax
andq %r8, %rbp
andq %rax, %rbp
movabsq $0xff000000000000, %rax # imm = 0xFF000000000000
andq %rdi, %rax
je 0x1485c
movq %rdi, 0x38(%rsp)
shlq $0x8, %rax
movq %r8, %r13
andq %r8, %rax
movq %rsp, %r12
movq %rax, (%r12)
leaq 0xfc99c(%rip), %r15     # 0x1111a0
testq %rax, %rax
je 0x1484f
movq %r12, %rdi
callq 0x7b62
movslq %eax, %rcx
movslq 0x510(%r14), %rdx
movq (%r15,%rdx,8), %rdx
leaq 0xfcf2a(%rip), %rsi     # 0x111750
testq %rdx, 0x400(%rsi,%rcx,8)
je 0x14849
movl %eax, %ecx
shll $0x6, %ecx
addl $0xfffffe00, %ecx       # imm = 0xFFFFFE00
orl %eax, %ecx
orl $0x4000, %ecx           # imm = 0x4000
movl %ecx, (%rbx)
addq $0x8, %rbx
movq (%rsp), %rax
jmp 0x14804
movq 0x8(%rsp), %r15
movq 0x38(%rsp), %rdi
movq %r13, %r8
movl %ebp, %ecx
shll $0x8, %ecx
movl %r8d, %eax
andl $0xff000000, %eax       # imm = 0xFF000000
movl %eax, %edx
andl %ecx, %edx
movq 0x30(%rsp), %rcx
leaq 0xfced7(%rip), %rsi     # 0x111750
movq 0x1200(%rsi,%rcx,8), %r13
andq %r13, %rbp
movq %rbp, (%rsp)
andl %edx, %r13d
movq %r13, 0x10(%rsp)
andq 0x18(%rsp), %rdi
je 0x148cd
movq 0x28(%rsp), %rcx
andl $0x7, %ecx
leaq 0xfcd2a(%rip), %rdx     # 0x1115d0
movq (%rdx,%rcx,8), %rcx
notq %rcx
andq %rcx, %rdi
shlq $0x8, %rdi
andq %r8, %rdi
movl %edi, %ecx
shll $0x8, %ecx
andl %ecx, %eax
orq %rdi, %rbp
movq %rbp, (%rsp)
orq %rax, %r13
movq %r13, 0x10(%rsp)
movq %rsp, %r12
testq %rbp, %rbp
je 0x148f6
movq %r12, %rdi
callq 0x7b62
movl %eax, %ecx
shll $0x6, %ecx
addl $0xfffffe00, %ecx       # imm = 0xFFFFFE00
orl %eax, %ecx
movl %ecx, (%rbx)
addq $0x8, %rbx
movq (%rsp), %rbp
jmp 0x148d0
leaq 0x10(%rsp), %r12
testq %r13, %r13
je 0x14922
movq %r12, %rdi
callq 0x7b62
movl %eax, %ecx
shll $0x6, %ecx
addl $0xfffffc00, %ecx       # imm = 0xFFFFFC00
orl %eax, %ecx
movl %ecx, (%rbx)
addq $0x8, %rbx
movq 0x10(%rsp), %r13
jmp 0x148fb
shlq $0x9, %r15
movq 0x20(%rsp), %rcx
movl 0x80(%rcx,%r15), %eax
cmpl $0x40, %eax
movq %r15, 0x8(%rsp)
jne 0x14ac5
movq 0x8(%rsp), %rax
movq 0x20(%rsp), %rcx
movl 0xc0(%rcx,%rax), %ebp
cmpl $0x40, %ebp
je 0x149ed
leaq (%rcx,%rax), %r13
addq $0xc0, %r13
movq %r14, %rdi
movq 0x30(%rsp), %rsi
callq 0xcf20
movq 0x100(%r14), %r15
notq %r15
andq %rax, %r15
leaq 0x1079c9(%rip), %rdx    # 0x11c350
movq %rsp, %r12
movslq %ebp, %rax
testq %r15, (%rdx,%rax,8)
je 0x149e0
movq 0x18(%rsp), %rcx
testq %rcx, %rcx
je 0x149aa
leaq 0xfc7fc(%rip), %rsi     # 0x1111a0
testq %rcx, (%rsi,%rax,8)
jne 0x149e0
movq %r14, %rdi
movl %ebp, %esi
callq 0xcf20
andq %r15, %rax
movq %rax, (%rsp)
shll $0x6, %ebp
testq %rax, %rax
je 0x149d9
movq %r12, %rdi
callq 0x7b62
orl %ebp, %eax
movl %eax, (%rbx)
addq $0x8, %rbx
movq (%rsp), %rax
jmp 0x149be
leaq 0x107970(%rip), %rdx    # 0x11c350
addq $0x4, %r13
movl (%r13), %ebp
cmpl $0x40, %ebp
jne 0x1498a
movq 0x8(%rsp), %rax
movq 0x20(%rsp), %rcx
movl 0x100(%rcx,%rax), %ebp
cmpl $0x40, %ebp
je 0x14a99
leaq (%rcx,%rax), %r13
addq $0x100, %r13            # imm = 0x100
movq %r14, %rdi
movq 0x28(%rsp), %rsi
callq 0x12330
movq 0x100(%r14), %r15
notq %r15
andq %rax, %r15
leaq 0x107b1d(%rip), %rdx    # 0x11c550
movq %rsp, %r12
movslq %ebp, %rax
testq %r15, (%rdx,%rax,8)
je 0x14a8c
movq 0x18(%rsp), %rcx
testq %rcx, %rcx
je 0x14a56
leaq 0xfc750(%rip), %rsi     # 0x1111a0
testq %rcx, (%rsi,%rax,8)
jne 0x14a8c
movq %r14, %rdi
movl %ebp, %esi
callq 0x12330
andq %r15, %rax
movq %rax, (%rsp)
shll $0x6, %ebp
testq %rax, %rax
je 0x14a85
movq %r12, %rdi
callq 0x7b62
orl %ebp, %eax
movl %eax, (%rbx)
addq $0x8, %rbx
movq (%rsp), %rax
jmp 0x14a6a
leaq 0x107ac4(%rip), %rdx    # 0x11c550
addq $0x4, %r13
movl (%r13), %ebp
cmpl $0x40, %ebp
jne 0x14a36
movq 0x8(%rsp), %rax
movq 0x20(%rsp), %rcx
movl 0x140(%rcx,%rax), %ebp
cmpl $0x40, %ebp
jne 0x14b4f
movq %rbx, %rax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
addq %rcx, %r15
addq $0x80, %r15
movslq 0x28(%rsp), %rcx
movq 0x100(%r14), %r13
notq %r13
leaq 0xfcc6b(%rip), %rdx     # 0x111750
andq 0x400(%rdx,%rcx,8), %r13
movq %rsp, %r12
movslq %eax, %rbp
movq 0x18(%rsp), %rax
testq %rax, %rax
je 0x14b1b
leaq 0xfc69c(%rip), %rcx     # 0x1111a0
testq %rax, (%rcx,%rbp,8)
je 0x14b1b
addq $0x4, %r15
movl (%r15), %eax
cmpl $0x40, %eax
jne 0x14af0
jmp 0x14941
leaq 0xfcc2e(%rip), %rax     # 0x111750
movq 0x400(%rax,%rbp,8), %rax
andq %r13, %rax
movq %rax, (%rsp)
shll $0x6, %ebp
testq %rax, %rax
je 0x14b0a
movq %r12, %rdi
callq 0x7b62
orl %ebp, %eax
movl %eax, (%rbx)
addq $0x8, %rbx
movq (%rsp), %rax
jmp 0x14b34
leaq (%rcx,%rax), %r13
addq $0x140, %r13            # imm = 0x140
movq %r14, %rdi
movq 0x30(%rsp), %rsi
callq 0x1230a
movq 0x100(%r14), %r15
notq %r15
andq %rax, %r15
movq %rsp, %r12
movslq %ebp, %rax
leaq 0x107bcf(%rip), %rcx    # 0x11c750
testq %r15, (%rcx,%rax,8)
je 0x14b9e
movq 0x18(%rsp), %rcx
testq %rcx, %rcx
je 0x14bb0
leaq 0xfc608(%rip), %rdx     # 0x1111a0
testq %rcx, (%rdx,%rax,8)
je 0x14bb0
addq $0x4, %r13
movl (%r13), %ebp
cmpl $0x40, %ebp
jne 0x14b77
jmp 0x14ab3
movq %r14, %rdi
movl %ebp, %esi
callq 0x1230a
andq %r15, %rax
movq %rax, (%rsp)
shll $0x6, %ebp
testq %rax, %rax
je 0x14b9e
movq %r12, %rdi
callq 0x7b62
orl %ebp, %eax
movl %eax, (%rbx)
addq $0x8, %rbx
movq (%rsp), %rax
jmp 0x14bc4