// File: kobanium[P]Ray/src/feature/Semeai.cpp
// Function: IsAlreadyCaptured(game_info_t const*, int, int*, int)
bool 
IsAlreadyCaptured( const game_info_t *game, const int id, int player_id[], int player_ids )
{
  const string_t *string = game->string;
  const int *string_id = game->string_id;
  int lib1, lib2;
  bool checked;
  int neighbor4[4];
  int i, j;

  if (string[id].libs == 1) {
    return true;
  } else if (string[id].libs == 2) {
    lib1 = string[id].lib[0];
    lib2 = string[id].lib[lib1];

    GetNeighbor4(neighbor4, lib1);
    checked = false;
    for (i = 0; i < 4; i++) {
      for (j = 0; j < player_ids; j++) {
        if (player_id[j] == string_id[neighbor4[i]]) {
          checked = true;
          player_id[j] = 0;
        }
      }
    }
    if (checked == false) return false;

    GetNeighbor4(neighbor4, lib2);
    checked = false;
    for (i = 0; i < 4; i++) {
      for (j = 0; j < player_ids; j++) {
        if (player_id[j] == string_id[neighbor4[i]]) {
          checked = true;
          player_id[j] = 0;
        }
      }
    }
    if (checked == false) return false;

    for (i = 0; i < player_ids; i++) {
      if (player_id[i] != 0) {
        return false;
      }
    }

    return true;
  } else {
    return false;
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movq %rdx, -0x20(%rbp)
movl %ecx, -0x24(%rbp)
movq -0x10(%rbp), %rax
addq $0x9620, %rax           # imm = 0x9620
movq %rax, -0x30(%rbp)
movq -0x10(%rbp), %rax
addq $0x95720, %rax          # imm = 0x95720
movq %rax, -0x38(%rbp)
movq -0x30(%rbp), %rax
movslq -0x14(%rbp), %rcx
imulq $0x7c8, %rcx, %rcx      # imm = 0x7C8
addq %rcx, %rax
cmpl $0x1, 0x4(%rax)
jne 0xa9723
movb $0x1, -0x1(%rbp)
jmp 0xa98c5
movq -0x30(%rbp), %rax
movslq -0x14(%rbp), %rcx
imulq $0x7c8, %rcx, %rcx      # imm = 0x7C8
addq %rcx, %rax
cmpl $0x2, 0x4(%rax)
jne 0xa98c1
movq -0x30(%rbp), %rax
movslq -0x14(%rbp), %rcx
imulq $0x7c8, %rcx, %rcx      # imm = 0x7C8
addq %rcx, %rax
movswl 0x8(%rax), %eax
movl %eax, -0x3c(%rbp)
movq -0x30(%rbp), %rax
movslq -0x14(%rbp), %rcx
imulq $0x7c8, %rcx, %rcx      # imm = 0x7C8
addq %rcx, %rax
movslq -0x3c(%rbp), %rcx
movswl 0x8(%rax,%rcx,2), %eax
movl %eax, -0x40(%rbp)
leaq -0x60(%rbp), %rdi
movl -0x3c(%rbp), %esi
callq 0x9bc90
movb $0x0, -0x41(%rbp)
movl $0x0, -0x64(%rbp)
cmpl $0x4, -0x64(%rbp)
jge 0xa97ec
movl $0x0, -0x68(%rbp)
movl -0x68(%rbp), %eax
cmpl -0x24(%rbp), %eax
jge 0xa97df
movq -0x20(%rbp), %rax
movslq -0x68(%rbp), %rcx
movl (%rax,%rcx,4), %eax
movq -0x38(%rbp), %rcx
movslq -0x64(%rbp), %rdx
movslq -0x60(%rbp,%rdx,4), %rdx
cmpl (%rcx,%rdx,4), %eax
jne 0xa97d2
movb $0x1, -0x41(%rbp)
movq -0x20(%rbp), %rax
movslq -0x68(%rbp), %rcx
movl $0x0, (%rax,%rcx,4)
jmp 0xa97d4
movl -0x68(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x68(%rbp)
jmp 0xa979a
jmp 0xa97e1
movl -0x64(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x64(%rbp)
jmp 0xa978d
movb -0x41(%rbp), %al
andb $0x1, %al
movzbl %al, %eax
cmpl $0x0, %eax
jne 0xa9802
movb $0x0, -0x1(%rbp)
jmp 0xa98c5
leaq -0x60(%rbp), %rdi
movl -0x40(%rbp), %esi
callq 0x9bc90
movb $0x0, -0x41(%rbp)
movl $0x0, -0x64(%rbp)
cmpl $0x4, -0x64(%rbp)
jge 0xa9878
movl $0x0, -0x68(%rbp)
movl -0x68(%rbp), %eax
cmpl -0x24(%rbp), %eax
jge 0xa986b
movq -0x20(%rbp), %rax
movslq -0x68(%rbp), %rcx
movl (%rax,%rcx,4), %eax
movq -0x38(%rbp), %rcx
movslq -0x64(%rbp), %rdx
movslq -0x60(%rbp,%rdx,4), %rdx
cmpl (%rcx,%rdx,4), %eax
jne 0xa985e
movb $0x1, -0x41(%rbp)
movq -0x20(%rbp), %rax
movslq -0x68(%rbp), %rcx
movl $0x0, (%rax,%rcx,4)
jmp 0xa9860
movl -0x68(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x68(%rbp)
jmp 0xa9826
jmp 0xa986d
movl -0x64(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x64(%rbp)
jmp 0xa9819
movb -0x41(%rbp), %al
andb $0x1, %al
movzbl %al, %eax
cmpl $0x0, %eax
jne 0xa988b
movb $0x0, -0x1(%rbp)
jmp 0xa98c5
movl $0x0, -0x64(%rbp)
movl -0x64(%rbp), %eax
cmpl -0x24(%rbp), %eax
jge 0xa98bb
movq -0x20(%rbp), %rax
movslq -0x64(%rbp), %rcx
cmpl $0x0, (%rax,%rcx,4)
je 0xa98ae
movb $0x0, -0x1(%rbp)
jmp 0xa98c5
jmp 0xa98b0
movl -0x64(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x64(%rbp)
jmp 0xa9892
movb $0x1, -0x1(%rbp)
jmp 0xa98c5
movb $0x0, -0x1(%rbp)
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0x70, %rsp
popq %rbp
retq