// File: /workspace/github_c_makefile_star2_O1/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 0x73d4(%rip), %r12      # 0xbca0
movq 0x75d8(%rip), %xmm0     # 0xbeac
pcmpeqd %xmm1, %xmm1
paddd %xmm0, %xmm1
movq %xmm1, 0x75c8(%rip)     # 0xbeac
pshufd $0x55, %xmm1, %xmm0     # xmm0 = xmm1[1,1,1,1]
movd %xmm0, %eax
cltq
leaq (%rax,%rax,2), %rax
movl 0x270(%r12,%rax,8), %r15d
movl %r15d, %ebx
andl $0x7f, %ebx
movslq 0x759c(%rip), %rcx      # 0xbea4
cmpq $0x63, %rcx
je 0x4920
leaq 0x1f78b(%rip), %rdx     # 0x240a0
movq (%rdx,%rcx,8), %rcx
xorq %rcx, 0x75a0(%rip)      # 0xbec0
movl %r15d, %r14d
shrl $0x7, %r14d
movslq 0x7586(%rip), %rdx      # 0xbeb4
leaq 0x1f6eb(%rip), %rcx     # 0x24020
movq 0x7584(%rip), %rsi      # 0xbec0
xorq (%rcx,%rdx,8), %rsi
movq %rsi, 0x7579(%rip)      # 0xbec0
movslq 0x274(%r12,%rax,8), %rdx
movl %edx, 0x755f(%rip)      # 0xbeb4
movq 0x278(%r12,%rax,8), %rax
movq %rax, 0x7540(%rip)      # 0xbea4
cmpl $0x63, %eax
je 0x497d
cltq
leaq 0x1f72e(%rip), %rdi     # 0x240a0
xorq (%rdi,%rax,8), %rsi
movq %rsi, 0x7543(%rip)      # 0xbec0
andl $0x7f, %r14d
movq 0x7538(%rip), %rsi      # 0xbec0
xorq (%rcx,%rdx,8), %rsi
movl 0x750e(%rip), %eax      # 0xbea0
movl %eax, %ecx
xorl $0x1, %ecx
movl %ecx, 0x7503(%rip)      # 0xbea0
xorq 0x227bc(%rip), %rsi     # 0x27160
movq %rsi, 0x7515(%rip)      # 0xbec0
btl $0x12, %r15d
jb 0x49d7
btl $0x18, %r15d
jae 0x4a2a
cmpl $0x5c, %r14d
jg 0x49f7
cmpl $0x17, %r14d
je 0x4a0f
cmpl $0x1b, %r14d
jne 0x4a2a
movl $0x1a, %edi
movl $0x1c, %esi
jmp 0x4a25
cmpl $0x1, %eax
jne 0x49e7
leal -0xa(%r14), %edi
movl $0x7, %esi
jmp 0x49f0
leal 0xa(%r14), %edi
movl $0x1, %esi
callq 0x4819
jmp 0x4a2a
cmpl $0x5d, %r14d
je 0x4a1b
cmpl $0x61, %r14d
jne 0x4a2a
movl $0x60, %edi
movl $0x62, %esi
jmp 0x4a25
movl $0x18, %edi
movl $0x15, %esi
jmp 0x4a25
movl $0x5e, %edi
movl $0x5b, %esi
callq 0x4739
movl %r14d, %edi
movl %ebx, %esi
callq 0x4739
movl (%r12,%rbx,4), %eax
cmpl $0xc, %eax
je 0x4a42
cmpl $0x6, %eax
jne 0x4a51
movslq 0x7457(%rip), %rax      # 0xbea0
movl %ebx, 0x1f8(%r12,%rax,4)
movl %r15d, %esi
shrl $0xe, %esi
andl $0xf, %esi
je 0x4a64
movl %r14d, %edi
callq 0x4819
shrl $0x14, %r15d
andl $0xf, %r15d
je 0x4a98
movl %ebx, %edi
callq 0x465a
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 0x4819
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq