// File: /workspace/github_c_makefile_star2_O0/ArchLuke[P]YouSuck/Engine.c
// Function: EvalCapture
static int EvalCapture(const S_BOARD *pos, const int capture, int pvMove)
{

    int fromsq, tosq, attackingSide, defendingSide, attackingPce, attackedPce, score;

    int attackers[MAXPIECES]={0};
    int defenders[MAXPIECES]={0};

    fromsq=FROMSQ(capture);
    tosq=TOSQ(capture);
    attackingPce=pos->pieces[fromsq];
    attackedPce=pos->pieces[tosq];
    attackingSide=PieceCol[attackingPce];
    defendingSide=attackingSide ^ 1;

    attackers[0]=fromsq;
    if(pvMove & MFLAGCAP)
    {
	int capturedSq=TOSQ(pvMove);
	if(capturedSq != tosq)
	{
		if((PieceVal[attackedPce])<PieceVal[CAPTURED(pvMove)])
			return FALSE;
	}	
    } 

    FillPieces(pos, attackers, attackingSide, tosq, fromsq);
    FillPieces(pos, defenders, defendingSide, tosq, NO_SQ);	

    score=PieceVal[attackedPce];

    for(int index=0;index<MAXPIECES;index++)
    {

	int attackerLocation=attackers[index];
	int defenderLocation=defenders[index];	

	if(index>0)
	{
		int captured=defenders[index-1];
		score += PieceVal[pos->pieces[captured]];
	}

	if(score<0)
		return FALSE;
	if(!attackerLocation)
		return FALSE;
	
	if(defenderLocation)
	{
		score -= PieceVal[pos->pieces[attackerLocation]];
	}
	if(score>=0)
		return TRUE;

    }
    return FALSE;

}

// Assembly:
subq $0xb8, %rsp
movq %rdi, 0xa8(%rsp)
movl %esi, 0xa4(%rsp)
movl %edx, 0xa0(%rsp)
leaq 0x50(%rsp), %rdi
xorl %esi, %esi
movl $0x28, %edx
callq 0x1080
leaq 0x20(%rsp), %rdi
xorl %esi, %esi
movl $0x28, %edx
callq 0x1080
movl 0xa4(%rsp), %eax
andl $0x7f, %eax
movl %eax, 0x9c(%rsp)
movl 0xa4(%rsp), %eax
sarl $0x7, %eax
andl $0x7f, %eax
movl %eax, 0x98(%rsp)
movq 0xa8(%rsp), %rax
movslq 0x9c(%rsp), %rcx
movl (%rax,%rcx,4), %eax
movl %eax, 0x8c(%rsp)
movq 0xa8(%rsp), %rax
movslq 0x98(%rsp), %rcx
movl (%rax,%rcx,4), %eax
movl %eax, 0x88(%rsp)
movslq 0x8c(%rsp), %rcx
leaq 0x2e59(%rip), %rax      # 0xb360
movl (%rax,%rcx,4), %eax
movl %eax, 0x94(%rsp)
movl 0x94(%rsp), %eax
xorl $0x1, %eax
movl %eax, 0x90(%rsp)
movl 0x9c(%rsp), %eax
movl %eax, 0x50(%rsp)
movl 0xa0(%rsp), %eax
andl $0x7c000, %eax          # imm = 0x7C000
cmpl $0x0, %eax
je 0x859e
movl 0xa0(%rsp), %eax
sarl $0x7, %eax
andl $0x7f, %eax
movl %eax, 0x1c(%rsp)
movl 0x1c(%rsp), %eax
cmpl 0x98(%rsp), %eax
je 0x859c
movslq 0x88(%rsp), %rcx
leaq 0x2e35(%rip), %rax      # 0xb3a0
movl (%rax,%rcx,4), %eax
movl 0xa0(%rsp), %ecx
sarl $0xe, %ecx
andl $0xf, %ecx
movslq %ecx, %rdx
leaq 0x2e1b(%rip), %rcx      # 0xb3a0
cmpl (%rcx,%rdx,4), %eax
jge 0x859a
movl $0x0, 0xb4(%rsp)
jmp 0x8704
jmp 0x859c
jmp 0x859e
movq 0xa8(%rsp), %rdi
leaq 0x50(%rsp), %rsi
movl 0x94(%rsp), %edx
movl 0x98(%rsp), %ecx
movl 0x9c(%rsp), %r8d
callq 0x8720
movq 0xa8(%rsp), %rdi
leaq 0x20(%rsp), %rsi
movl 0x90(%rsp), %edx
movl 0x98(%rsp), %ecx
movl $0x63, %r8d
callq 0x8720
movslq 0x88(%rsp), %rcx
leaq 0x2da5(%rip), %rax      # 0xb3a0
movl (%rax,%rcx,4), %eax
movl %eax, 0x84(%rsp)
movl $0x0, 0x18(%rsp)
cmpl $0xa, 0x18(%rsp)
jge 0x86f9
movslq 0x18(%rsp), %rax
movl 0x50(%rsp,%rax,4), %eax
movl %eax, 0x14(%rsp)
movslq 0x18(%rsp), %rax
movl 0x20(%rsp,%rax,4), %eax
movl %eax, 0x10(%rsp)
cmpl $0x0, 0x18(%rsp)
jle 0x8673
movl 0x18(%rsp), %eax
subl $0x1, %eax
cltq
movl 0x20(%rsp,%rax,4), %eax
movl %eax, 0xc(%rsp)
movq 0xa8(%rsp), %rax
movslq 0xc(%rsp), %rcx
movslq (%rax,%rcx,4), %rcx
leaq 0x2d3e(%rip), %rax      # 0xb3a0
movl (%rax,%rcx,4), %eax
addl 0x84(%rsp), %eax
movl %eax, 0x84(%rsp)
cmpl $0x0, 0x84(%rsp)
jge 0x868a
movl $0x0, 0xb4(%rsp)
jmp 0x8704
cmpl $0x0, 0x14(%rsp)
jne 0x869e
movl $0x0, 0xb4(%rsp)
jmp 0x8704
cmpl $0x0, 0x10(%rsp)
je 0x86d0
movq 0xa8(%rsp), %rax
movslq 0x14(%rsp), %rcx
movslq (%rax,%rcx,4), %rcx
leaq 0x2ce3(%rip), %rax      # 0xb3a0
movl (%rax,%rcx,4), %ecx
movl 0x84(%rsp), %eax
subl %ecx, %eax
movl %eax, 0x84(%rsp)
cmpl $0x0, 0x84(%rsp)
jl 0x86e7
movl $0x1, 0xb4(%rsp)
jmp 0x8704
jmp 0x86e9
movl 0x18(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x18(%rsp)
jmp 0x860d
movl $0x0, 0xb4(%rsp)
movl 0xb4(%rsp), %eax
addq $0xb8, %rsp
retq
nopw %cs:(%rax,%rax)