// File: /workspace/github_c_makefile_star2_O3/ArchLuke[P]YouSuck/Engine.c
// Function: TakeMove
static void TakeMove(S_BOARD *pos) {
    
    
    pos->hisPly--;
    pos->ply--;
    
    int move = pos->history[pos->hisPly].move;
    int from = FROMSQ(move);
    int to = TOSQ(move);    
    
    
    if(pos->enPas != NO_SQ) HASH_EP;
    HASH_CA;

    pos->castlePerm = pos->history[pos->hisPly].castlePerm;
    pos->fiftyMove = pos->history[pos->hisPly].fiftyMove;
    pos->enPas = pos->history[pos->hisPly].enPas;

    if(pos->enPas != NO_SQ) HASH_EP;
    HASH_CA;

    pos->side ^= 1;
    HASH_SIDE;
    
    if(MFLAGEP & move) {
        if(pos->side == WHITE) {
            AddPiece(to-10, pos, bP);
        } else {
            AddPiece(to+10, pos, wP);
        }
    } else if(MFLAGCA & move) {
        switch(to) {
            case C1: MovePiece(D1, A1, pos); break;
            case C8: MovePiece(D8, A8, pos); break;
            case G1: MovePiece(F1, H1, pos); break;
            case G8: MovePiece(F8, H8, pos); break;
            default: break;
        }
    }
    
    MovePiece(to, from, pos);
    
    if(PieceKing[pos->pieces[from]]) {
        pos->KingSq[pos->side] = from;
    }
    
    int captured = CAPTURED(move);
    if(captured != EMPTY) {
        AddPiece(to, pos, captured);
    }
    
    if(PROMOTED(move) != EMPTY)   {
        ClearPiece(from, pos);
        AddPiece(from, pos, (PieceCol[PROMOTED(move)] == WHITE ? wP : bP));
    }
    
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
leaq 0x7408(%rip), %r12      # 0xbca0
movq 0x760c(%rip), %xmm0     # 0xbeac
pcmpeqd %xmm1, %xmm1
paddd %xmm0, %xmm1
movq %xmm1, 0x75fc(%rip)     # 0xbeac
pshufd $0x55, %xmm1, %xmm0     # xmm0 = xmm1[1,1,1,1]
movd %xmm0, %eax
cltq
leaq (%rax,%rax,2), %rcx
movl 0x270(%r12,%rcx,8), %r15d
movl %r15d, %ebx
andl $0x7f, %ebx
movslq 0x75d0(%rip), %rdx      # 0xbea4
movq 0x75e5(%rip), %rax      # 0xbec0
cmpq $0x63, %rdx
je 0x48ec
leaq 0x1f7b8(%rip), %rsi     # 0x240a0
xorq (%rsi,%rdx,8), %rax
movl %r15d, %r14d
shrl $0x7, %r14d
movslq 0x75ba(%rip), %rsi      # 0xbeb4
leaq 0x1f71f(%rip), %rdx     # 0x24020
xorq (%rdx,%rsi,8), %rax
movslq 0x274(%r12,%rcx,8), %rsi
movl %esi, 0x75a1(%rip)      # 0xbeb4
movq 0x278(%r12,%rcx,8), %rcx
movq %rcx, 0x7582(%rip)      # 0xbea4
cmpl $0x63, %ecx
je 0x4935
movslq %ecx, %rcx
leaq 0x1f76f(%rip), %rdi     # 0x240a0
xorq (%rdi,%rcx,8), %rax
andl $0x7f, %r14d
xorq (%rdx,%rsi,8), %rax
movl 0x755d(%rip), %ecx      # 0xbea0
movl %ecx, %edx
xorl $0x1, %edx
movl %edx, 0x7552(%rip)      # 0xbea0
xorq 0x2280b(%rip), %rax     # 0x27160
movq %rax, 0x7564(%rip)      # 0xbec0
btl $0x12, %r15d
jb 0x4988
btl $0x18, %r15d
jae 0x49db
cmpl $0x5c, %r14d
jg 0x49a8
cmpl $0x17, %r14d
je 0x49c0
cmpl $0x1b, %r14d
jne 0x49db
movl $0x1a, %edi
movl $0x1c, %esi
jmp 0x49d6
cmpl $0x1, %ecx
jne 0x4998
leal -0xa(%r14), %edi
movl $0x7, %esi
jmp 0x49a1
leal 0xa(%r14), %edi
movl $0x1, %esi
callq 0x47e5
jmp 0x49db
cmpl $0x5d, %r14d
je 0x49cc
cmpl $0x61, %r14d
jne 0x49db
movl $0x60, %edi
movl $0x62, %esi
jmp 0x49d6
movl $0x18, %edi
movl $0x15, %esi
jmp 0x49d6
movl $0x5e, %edi
movl $0x5b, %esi
callq 0x470c
movl %r14d, %edi
movl %ebx, %esi
callq 0x470c
movl (%r12,%rbx,4), %eax
cmpl $0xc, %eax
je 0x49f3
cmpl $0x6, %eax
jne 0x4a02
movslq 0x74a6(%rip), %rax      # 0xbea0
movl %ebx, 0x1f8(%r12,%rax,4)
movl %r15d, %esi
shrl $0xe, %esi
andl $0xf, %esi
je 0x4a15
movl %r14d, %edi
callq 0x47e5
shrl $0x14, %r15d
andl $0xf, %r15d
je 0x4a49
movl %ebx, %edi
callq 0x462d
cmpl $0x7, %r15d
movl $0x1, %eax
movl $0x7, %esi
cmovbl %eax, %esi
movl %ebx, %edi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
jmp 0x47e5
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq