// File: therealgymmy[P]HelicopterGame/src/control.cpp
// Function: detectCollision(MissileList&, Helicopter&, HealthBar&, Score&)
void detectCollision (MissileList &mlist,
                      Helicopter &heli,
                      HealthBar &hp,
                      Score &score) {
    MissileList::Missiles &missiles = mlist.missiles();

    for (MissileList::Missiles::iterator itr = missiles.begin();
         itr != missiles.end();
         ++itr) {
        int mx = itr->x();
        int my = itr->y();
        int hx = heli.x();
        int hy = heli.y();

        if (hx >= mx - Helicopter::Size::w() &&
            hx <= mx + Missile::Size::w() &&
            hy >= my - Helicopter::Size::h() &&
            hy <= my + Missile::Size::h()) {
            heli.setBlink();
            hp.decHealth();
            if (hp.health() <= 0) {
                heli.setX(500);
                heli.setY(500);
                score.decScore(5000);
                hp.restore();
            }
            score.decScore(1000);

            itr = missiles.erase(itr);
        }
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x80, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq -0x8(%rbp), %rdi
callq 0x9e90
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rdi
callq 0x9ea0
movq %rax, -0x30(%rbp)
movq -0x28(%rbp), %rdi
callq 0x9f00
movq %rax, -0x38(%rbp)
leaq -0x30(%rbp), %rdi
leaq -0x38(%rbp), %rsi
callq 0x9ed0
testb $0x1, %al
jne 0x97f8
jmp 0x9963
leaq -0x30(%rbp), %rdi
callq 0x9f30
movq %rax, %rdi
callq 0x9f60
movl %eax, -0x3c(%rbp)
leaq -0x30(%rbp), %rdi
callq 0x9f30
movq %rax, %rdi
callq 0x9f80
movl %eax, -0x40(%rbp)
movq -0x10(%rbp), %rdi
callq 0x8210
movl %eax, -0x44(%rbp)
movq -0x10(%rbp), %rdi
callq 0x8240
movl %eax, -0x48(%rbp)
movl -0x44(%rbp), %eax
movl %eax, -0x5c(%rbp)
movl -0x3c(%rbp), %eax
movl %eax, -0x60(%rbp)
callq 0x8230
movl -0x60(%rbp), %ecx
movl %eax, %edx
movl -0x5c(%rbp), %eax
subl %edx, %ecx
cmpl %ecx, %eax
jl 0x9953
movl -0x44(%rbp), %eax
movl %eax, -0x64(%rbp)
movl -0x3c(%rbp), %eax
movl %eax, -0x68(%rbp)
callq 0x4ea0
movl -0x68(%rbp), %ecx
movl %eax, %edx
movl -0x64(%rbp), %eax
addl %edx, %ecx
cmpl %ecx, %eax
jg 0x9953
movl -0x48(%rbp), %eax
movl %eax, -0x6c(%rbp)
movl -0x40(%rbp), %eax
movl %eax, -0x70(%rbp)
callq 0x8260
movl -0x70(%rbp), %ecx
movl %eax, %edx
movl -0x6c(%rbp), %eax
subl %edx, %ecx
cmpl %ecx, %eax
jl 0x9953
movl -0x48(%rbp), %eax
movl %eax, -0x74(%rbp)
movl -0x40(%rbp), %eax
movl %eax, -0x78(%rbp)
callq 0x9fa0
movl -0x78(%rbp), %ecx
movl %eax, %edx
movl -0x74(%rbp), %eax
addl %edx, %ecx
cmpl %ecx, %eax
jg 0x9953
movq -0x10(%rbp), %rdi
callq 0x9fb0
movq -0x18(%rbp), %rdi
callq 0x9fd0
movq -0x18(%rbp), %rdi
callq 0xa000
cmpl $0x0, %eax
jg 0x9917
movq -0x10(%rbp), %rdi
movl $0x1f4, %esi            # imm = 0x1F4
callq 0xa020
movq -0x10(%rbp), %rdi
movl $0x1f4, %esi            # imm = 0x1F4
callq 0xa050
movq -0x20(%rbp), %rdi
movl $0x1388, %esi           # imm = 0x1388
callq 0xa080
movq -0x18(%rbp), %rdi
callq 0xa0a0
movq -0x20(%rbp), %rdi
movl $0x3e8, %esi            # imm = 0x3E8
callq 0xa080
movq -0x28(%rbp), %rax
movq %rax, -0x80(%rbp)
leaq -0x58(%rbp), %rdi
leaq -0x30(%rbp), %rsi
callq 0xa110
movq -0x80(%rbp), %rdi
movq -0x58(%rbp), %rsi
callq 0xa0c0
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rax
movq %rax, -0x30(%rbp)
jmp 0x9955
leaq -0x30(%rbp), %rdi
callq 0xa130
jmp 0x97d5
addq $0x80, %rsp
popq %rbp
retq
nopl (%rax)