// File: /workspace/github_cpp_makefile_star2_O3/czinn[P]homeworlds/game.cc
// Function: Game::remove_ship(int, Ship const&)
Ship Game::remove_ship(int system_id, const Ship& ship) {
  auto system = find_if(systems_.begin(), systems_.end(),
      [system_id](const System& s) {
        return s.id == system_id;
      });
  const auto& it = find_if(system->ships.begin(), system->ships.end(),
      [&ship](const Ship& ship2) {
        return ship == ship2;
      });
  if (it != system->ships.end()) {
    stash_[ship.pyramid]++;
    system->ships.erase(it);
  }
  return ship;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rdx, %rbx
movq 0x20(%rdi), %r15
movq 0x28(%rdi), %rax
movq %rax, %r9
subq %r15, %r9
movq %r9, %r8
sarq $0x3, %r8
movabsq $0x6db6db6db6db6db7, %rdx # imm = 0x6DB6DB6DB6DB6DB7
imulq %rdx, %r8
sarq $0x2, %r8
testq %r8, %r8
jle 0x39c4
imulq $0xe0, %r8, %rcx
addq %r15, %rcx
incq %r8
addq $0x70, %r15
cmpl %esi, -0x70(%r15)
je 0x39f2
cmpl %esi, -0x38(%r15)
je 0x39f8
cmpl %esi, (%r15)
je 0x3a11
cmpl %esi, 0x38(%r15)
je 0x39fe
decq %r8
addq $0xe0, %r15
cmpq $0x1, %r8
jg 0x3995
movq %rax, %r9
subq %rcx, %r9
jmp 0x39c7
movq %r15, %rcx
sarq $0x3, %r9
imulq %rdx, %r9
cmpq $0x1, %r9
je 0x3a08
cmpq $0x2, %r9
je 0x39e9
cmpq $0x3, %r9
jne 0x3a0e
cmpl %esi, (%rcx)
je 0x39ed
addq $0x38, %rcx
cmpl %esi, (%rcx)
jne 0x3a04
movq %rcx, %r15
jmp 0x3a11
addq $-0x70, %r15
jmp 0x3a11
addq $-0x38, %r15
jmp 0x3a11
addq $0x38, %r15
jmp 0x3a11
addq $0x38, %rcx
cmpl %esi, (%rcx)
cmoveq %rcx, %rax
movq %rax, %r15
movq 0x20(%r15), %rcx
movq 0x28(%r15), %rax
movq %rax, %r8
subq %rcx, %r8
movq %r8, %rsi
sarq $0x2, %rsi
movabsq $-0x5555555555555555, %rdx # imm = 0xAAAAAAAAAAAAAAAB
imulq %rdx, %rsi
sarq $0x2, %rsi
testq %rsi, %rsi
jle 0x3aca
movl (%rbx), %r8d
movl 0x4(%rbx), %r9d
leaq (%rsi,%rsi,2), %r14
shlq $0x4, %r14
addq %rcx, %r14
movl 0x8(%rbx), %r10d
incq %rsi
addq $0x18, %rcx
cmpl -0x18(%rcx), %r8d
jne 0x3a74
cmpl -0x14(%rcx), %r9d
jne 0x3a74
cmpl -0x10(%rcx), %r10d
je 0x3b65
cmpl -0xc(%rcx), %r8d
jne 0x3a8a
cmpl -0x8(%rcx), %r9d
jne 0x3a8a
cmpl -0x4(%rcx), %r10d
je 0x3b6b
cmpl (%rcx), %r8d
jne 0x3a9f
cmpl 0x4(%rcx), %r9d
jne 0x3a9f
cmpl 0x8(%rcx), %r10d
je 0x3b75
cmpl 0xc(%rcx), %r8d
jne 0x3ab5
cmpl 0x10(%rcx), %r9d
jne 0x3ab5
cmpl 0x14(%rcx), %r10d
je 0x3b71
decq %rsi
addq $0x30, %rcx
cmpq $0x1, %rsi
jg 0x3a5e
movq %rax, %r8
subq %r14, %r8
jmp 0x3acd
movq %rcx, %r14
sarq $0x2, %r8
imulq %rdx, %r8
cmpq $0x3, %r8
je 0x3af3
cmpq $0x2, %r8
je 0x3aef
cmpq $0x1, %r8
jne 0x3bb0
movl (%rbx), %ecx
jmp 0x3b41
movl (%rbx), %ecx
jmp 0x3b1b
movl (%rbx), %ecx
cmpl (%r14), %ecx
jne 0x3b17
movq 0x4(%rbx), %xmm0
movq 0x4(%r14), %xmm1
pcmpeqd %xmm0, %xmm1
pshufd $0x50, %xmm1, %xmm0     # xmm0 = xmm1[0,0,1,1]
movmskpd %xmm0, %edx
cmpl $0x3, %edx
je 0x3b78
addq $0xc, %r14
cmpl (%r14), %ecx
jne 0x3b3d
movq 0x4(%rbx), %xmm0
movq 0x4(%r14), %xmm1
pcmpeqd %xmm0, %xmm1
pshufd $0x50, %xmm1, %xmm0     # xmm0 = xmm1[0,0,1,1]
movmskpd %xmm0, %edx
cmpl $0x3, %edx
je 0x3b78
addq $0xc, %r14
cmpl (%r14), %ecx
jne 0x3bb0
movq 0x4(%rbx), %xmm0
movq 0x4(%r14), %xmm1
pcmpeqd %xmm0, %xmm1
pshufd $0x50, %xmm1, %xmm0     # xmm0 = xmm1[0,0,1,1]
movmskpd %xmm0, %ecx
cmpl $0x3, %ecx
je 0x3b78
jmp 0x3bb0
addq $-0x18, %rcx
jmp 0x3b75
addq $-0xc, %rcx
jmp 0x3b75
addq $0xc, %rcx
movq %rcx, %r14
cmpq %rax, %r14
je 0x3bb0
addq $0x38, %rdi
leaq 0x4(%rbx), %rsi
callq 0x427c
incl (%rax)
leaq 0xc(%r14), %rsi
movq 0x28(%r15), %rdx
cmpq %rdx, %rsi
je 0x3ba8
subq %rsi, %rdx
movq %r14, %rdi
callq 0x2280
movq 0x28(%r15), %rdx
addq $-0xc, %rdx
movq %rdx, 0x28(%r15)
movq (%rbx), %rax
movl 0x8(%rbx), %edx
popq %rbx
popq %r14
popq %r15
retq