// File: therealgymmy[P]HelicopterGame/src/control.cpp
// Function: detectCollision(Helicopter&, TowerList&, HealthBar&, Score&)
void detectCollision (Helicopter &heli,
                      TowerList &towers,
                      HealthBar &hp,
                      Score &score) {
    TowerList::Towers &towerlist = towers.towers();
    int hx = heli.x();
    int hy = heli.y();

    for (TowerList::Towers::iterator itr = towerlist.begin();
         itr != towerlist.end();
         ++itr) {
        int th = itr->numBlocks();
        int tx = itr->x();
        if (hx >= tx - Helicopter::Size::w() &&
            hx <= tx + Tower::Size::w() &&
            hy >= PLANE_H - th * Tower::Size::h() - Helicopter::Size::h() &&
            hy <= PLANE_H) {
            heli.setBlink();
            heli.setX(500);
            heli.setY(500);

            hp.decHealth();
            hp.decHealth();
            hp.decHealth();
            if (hp.health() <= 0) {
                score.decScore(5000);
                hp.restore();
            }

            score.decScore(5000);
        }
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq -0x10(%rbp), %rdi
callq 0x9b40
movq %rax, -0x28(%rbp)
movq -0x8(%rbp), %rdi
callq 0x8210
movl %eax, -0x2c(%rbp)
movq -0x8(%rbp), %rdi
callq 0x8240
movl %eax, -0x30(%rbp)
movq -0x28(%rbp), %rdi
callq 0x4ed0
movq %rax, -0x38(%rbp)
movq -0x28(%rbp), %rdi
callq 0x4f70
movq %rax, -0x40(%rbp)
leaq -0x38(%rbp), %rdi
leaq -0x40(%rbp), %rsi
callq 0x4f40
testb $0x1, %al
jne 0x99dd
jmp 0x9b0b
leaq -0x38(%rbp), %rdi
callq 0x4f00
movq %rax, %rdi
callq 0x9b60
movl %eax, -0x44(%rbp)
leaq -0x38(%rbp), %rdi
callq 0x4f00
movq %rax, %rdi
callq 0x4f20
movl %eax, -0x48(%rbp)
movl -0x2c(%rbp), %eax
movl %eax, -0x4c(%rbp)
movl -0x48(%rbp), %eax
movl %eax, -0x50(%rbp)
callq 0x8230
movl -0x50(%rbp), %ecx
movl %eax, %edx
movl -0x4c(%rbp), %eax
subl %edx, %ecx
cmpl %ecx, %eax
jl 0x9afb
movl -0x2c(%rbp), %eax
movl %eax, -0x54(%rbp)
movl -0x48(%rbp), %eax
movl %eax, -0x58(%rbp)
callq 0x4e80
movl -0x58(%rbp), %ecx
movl %eax, %edx
movl -0x54(%rbp), %eax
addl %edx, %ecx
cmpl %ecx, %eax
jg 0x9afb
movl -0x30(%rbp), %eax
movl %eax, -0x5c(%rbp)
movl -0x44(%rbp), %eax
movl %eax, -0x64(%rbp)
callq 0x4db0
movl -0x64(%rbp), %ecx
imull %eax, %ecx
movl $0xbb8, %eax            # imm = 0xBB8
subl %ecx, %eax
movl %eax, -0x60(%rbp)
callq 0x8260
movl -0x60(%rbp), %ecx
movl %eax, %edx
movl -0x5c(%rbp), %eax
subl %edx, %ecx
cmpl %ecx, %eax
jl 0x9afb
cmpl $0xbb8, -0x30(%rbp)     # imm = 0xBB8
jg 0x9afb
movq -0x8(%rbp), %rdi
callq 0x9fb0
movq -0x8(%rbp), %rdi
movl $0x1f4, %esi            # imm = 0x1F4
callq 0xa020
movq -0x8(%rbp), %rdi
movl $0x1f4, %esi            # imm = 0x1F4
callq 0xa050
movq -0x18(%rbp), %rdi
callq 0x9fd0
movq -0x18(%rbp), %rdi
callq 0x9fd0
movq -0x18(%rbp), %rdi
callq 0x9fd0
movq -0x18(%rbp), %rdi
callq 0xa000
cmpl $0x0, %eax
jg 0x9aed
movq -0x20(%rbp), %rdi
movl $0x1388, %esi           # imm = 0x1388
callq 0xa080
movq -0x18(%rbp), %rdi
callq 0xa0a0
movq -0x20(%rbp), %rdi
movl $0x1388, %esi           # imm = 0x1388
callq 0xa080
jmp 0x9afd
leaq -0x38(%rbp), %rdi
callq 0x4fa0
jmp 0x99ba
addq $0x70, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
nopl (%rax,%rax)