// File: /workspace/github_cpp_makefile_star2_O1/therealgymmy[P]HelicopterGame/src/control.cpp
// Function: control(void*)
void processMovement (ControlArg *controlArg) {
    Resources       *resources = controlArg->resources_;
    XHandler        *xhandler  = controlArg->xhandler_;
    pthread_mutex_t *mutex     = controlArg->mutex_;

    BombList      &bombs      = resources->bombs_;
    ExplosionList &explosions = resources->explosions_;
    Helicopter    &heli       = resources->heli_;
    TowerList     &towers     = resources->towers_;
    MissileList   &missiles   = resources->missiles_;
    HealthBar     &hp         = resources->healthBar_;
    Score         &score      = resources->score_;

    while (true) {
        if (!xhandler->showCredit()) {
            if (pthread_mutex_lock(mutex) == -1) {
                error("cannot lock mutex in control thread");
            }

            // helicopter
            heli.move();

            // explosions
            explosions.move();

            // towers
            towers.move();
            towers.fire(missiles);

            // missiles
            missiles.move();
            missiles.recharge();

            // bombs
            bombs.move();
            bombs.recharge();

            // collision detection
            detectCollision(bombs, towers, explosions, hp, score);
            detectCollision(missiles, heli, hp, score);
            detectCollision(heli, towers, hp, score);

            // score
            score.incScore(1);

            if (pthread_mutex_unlock(mutex) == -1) {
                error("cannot unlock mutex in control thread");
            }
        }
        usleep(1000 * 15);
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movq (%rdi), %rax
movq 0x8(%rdi), %r14
movq 0x10(%rdi), %r15
leaq 0x20(%rax), %rcx
movq %rcx, 0x18(%rsp)
leaq 0x38(%rax), %rcx
movq %rcx, 0x28(%rsp)
leaq 0x80(%rax), %r12
movq %rax, (%rsp)
leaq 0x60(%rax), %r13
movq %r14, 0x38(%rsp)
movq %r15, 0x30(%rsp)
movq %r12, 0x10(%rsp)
movq %r13, 0x20(%rsp)
cmpb $0x0, 0xf0(%r14)
jne 0x52b8
movq %r15, %rdi
callq 0x22a0
cmpl $-0x1, %eax
je 0x52c7
movq 0x28(%rsp), %rdi
callq 0x4c94
movq 0x18(%rsp), %rdi
callq 0x598a
movq %r12, %rdi
callq 0x2c52
movq %r12, %rdi
movq %r13, %rsi
callq 0x2cc0
movq %r13, %rdi
callq 0x5784
movq %r13, %rdi
callq 0x582c
movq (%rsp), %rbx
movq %rbx, %rdi
callq 0x55ec
movq %rbx, %rdi
callq 0x56ec
movq %rbx, %rsi
movq 0x80(%rbx), %r13
cmpq %r12, %r13
leaq 0x42e4(%rip), %rdx      # 0x91f8
leaq 0x4349(%rip), %rdi      # 0x9264
je 0x5036
movq (%rsi), %r12
cmpq %rsi, %r12
je 0x5027
movl 0x10(%r13), %r15d
movl 0x18(%r13), %eax
movl %eax, 0xc(%rsp)
movl 0x10(%r12), %r14d
movl %r15d, %eax
subl (%rdi), %eax
cmpl %eax, %r14d
jl 0x501a
movl (%rdx), %eax
addl %r15d, %eax
cmpl %eax, %r14d
jg 0x501a
movl 0x14(%r12), %ebp
movl $0xbb8, %eax            # imm = 0xBB8
cmpl %eax, %ebp
jg 0x501a
leaq 0x4289(%rip), %rax      # 0x91fc
movl (%rax), %eax
imull 0xc(%rsp), %eax
leaq 0x42e7(%rip), %rcx      # 0x9268
addl (%rcx), %eax
movl $0xbb8, %ecx            # imm = 0xBB8
subl %eax, %ecx
cmpl %ecx, %ebp
jl 0x501a
cmpb $0x1, 0x1d(%r13)
jne 0x4fc4
movl 0xa8(%rsi), %eax
cmpl $0x63, %eax
jg 0x4fba
leal 0xa(%rax), %ecx
movl %ecx, 0xa8(%rsi)
leal 0x50(,%rax,8), %eax
movl %eax, 0xa0(%rsi)
addl $0x3e8, 0xb0(%rsi)      # imm = 0x3E8
movq (%r12), %rbx
decq 0x10(%rsi)
movq %r12, %rdi
callq 0x2330
movl $0x20, %esi
movq %r12, %rdi
callq 0x2200
movb $0x0, 0x1d(%r13)
leaq 0x4277(%rip), %r12      # 0x9264
addl (%r12), %r14d
leaq 0x4270(%rip), %rax      # 0x9268
addl (%rax), %ebp
movq 0x18(%rsp), %rdi
movl %r14d, %esi
movl %ebp, %edx
callq 0x5a08
movq %r12, %rdi
movq (%rsp), %rsi
movq %rbx, %r12
leaq 0x41de(%rip), %rdx      # 0x91f8
movq (%r12), %r12
cmpq %rsi, %r12
jne 0x4f39
movq (%r13), %r13
cmpq 0x10(%rsp), %r13
jne 0x4f21
movq 0x20(%rsp), %r13
movq (%r13), %r12
cmpq %r13, %r12
movq 0x38(%rsp), %r14
movq 0x30(%rsp), %r15
je 0x5141
movl 0x10(%r12), %eax
movl 0x4c(%rsi), %ecx
movl %eax, %edx
leaq 0x41e1(%rip), %rdi      # 0x9244
subl (%rdi), %edx
cmpl %edx, %ecx
jl 0x5134
leaq 0x41ac(%rip), %rdx      # 0x9220
addl (%rdx), %eax
cmpl %eax, %ecx
jg 0x5134
movl 0x14(%r12), %eax
movl 0x50(%rsi), %ecx
movl %eax, %edx
leaq 0x41b9(%rip), %rdi      # 0x9248
subl (%rdi), %edx
cmpl %edx, %ecx
jl 0x5134
leaq 0x4184(%rip), %rdx      # 0x9224
addl (%rdx), %eax
cmpl %eax, %ecx
jg 0x5134
movl $0x64, 0x5c(%rsi)
movl 0xa8(%rsi), %eax
testl %eax, %eax
jle 0x50d1
leal -0xa(%rax), %ecx
movl %ecx, 0xa8(%rsi)
leal -0x50(,%rax,8), %eax
movl %eax, 0xa0(%rsi)
cmpl $0x0, 0xa8(%rsi)
jg 0x5106
movabsq $0x1f4000001f4, %rax    # imm = 0x1F4000001F4
movq %rax, 0x4c(%rsi)
addl $0xffffec78, 0xb0(%rsi) # imm = 0xFFFFEC78
movl $0x64, 0xa8(%rsi)
movl $0x320, 0xa0(%rsi)      # imm = 0x320
addl $0xfffffc18, 0xb0(%rsi) # imm = 0xFFFFFC18
movq (%r12), %rbx
decq 0x70(%rsi)
movq %r12, %rdi
callq 0x2330
movl $0x18, %esi
movq %r12, %rdi
callq 0x2200
movq (%rsp), %rsi
movq %rbx, %r12
movq (%r12), %r12
cmpq %r13, %r12
jne 0x5052
movq 0x80(%rsi), %rax
movq 0x10(%rsp), %r12
cmpq %r12, %rax
je 0x529d
movq (%rsp), %rsi
movl 0x4c(%rsi), %ecx
movl 0x50(%rsi), %edx
movl 0xa8(%rsi), %r10d
leaq 0x40d6(%rip), %rsi      # 0x9244
movl (%rsi), %esi
leaq 0x4081(%rip), %rdi      # 0x91f8
movl (%rdi), %edi
leaq 0x407c(%rip), %r8       # 0x91fc
movl (%r8), %r8d
leaq 0x40be(%rip), %r9       # 0x9248
movl (%r9), %r9d
movl 0x10(%rax), %r11d
movl %r11d, %ebx
subl %esi, %ebx
cmpl %ebx, %ecx
jl 0x5291
addl %edi, %r11d
cmpl %r11d, %ecx
jg 0x5291
movl $0xbb8, %r11d           # imm = 0xBB8
cmpl %r11d, %edx
jg 0x5291
movl 0x18(%rax), %r11d
imull %r8d, %r11d
addl %r9d, %r11d
movl $0xbb8, %ebx            # imm = 0xBB8
subl %r11d, %ebx
cmpl %ebx, %edx
jl 0x5291
movq (%rsp), %rbx
movl $0x64, 0x5c(%rbx)
movabsq $0x1f4000001f4, %r11    # imm = 0x1F4000001F4
movq %r11, 0x4c(%rbx)
testl %r10d, %r10d
jle 0x520c
leal -0x50(,%r10,8), %r11d
addl $-0xa, %r10d
movl %r10d, 0xa8(%rbx)
movl %r11d, 0xa0(%rbx)
testl %r10d, %r10d
jle 0x522f
leal -0x50(,%r10,8), %r11d
addl $-0xa, %r10d
movq (%rsp), %rbx
movl %r10d, 0xa8(%rbx)
movl %r11d, 0xa0(%rbx)
testl %r10d, %r10d
jle 0x5252
leal -0x50(,%r10,8), %r11d
addl $-0xa, %r10d
movq (%rsp), %rbx
movl %r10d, 0xa8(%rbx)
movl %r11d, 0xa0(%rbx)
testl %r10d, %r10d
jg 0x5282
movq (%rsp), %r10
addl $0xffffec78, 0xb0(%r10) # imm = 0xFFFFEC78
movl $0x64, 0xa8(%r10)
movl $0x320, 0xa0(%r10) # imm = 0x320
movl $0x64, %r10d
movq (%rsp), %r11
addl $0xffffec78, 0xb0(%r11) # imm = 0xFFFFEC78
movq (%rax), %rax
cmpq %r12, %rax
jne 0x518d
movq (%rsp), %rax
incl 0xb0(%rax)
movq %r15, %rdi
callq 0x2160
cmpl $-0x1, %eax
je 0x5339
movl $0x3a98, %edi           # imm = 0x3A98
callq 0x2280
jmp 0x4e96
leaq 0x58(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x40(%rsp), %rbx
movq $0x23, (%rbx)
leaq 0x48(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rsi
xorl %edx, %edx
callq 0x2380
movq %rax, (%r14)
movq (%rbx), %rcx
movq %rcx, 0x10(%r14)
movups 0xf59(%rip), %xmm0      # 0x6258
movups %xmm0, 0x10(%rax)
movups 0xf3e(%rip), %xmm0      # 0x6248
movups %xmm0, (%rax)
movl $0x64616572, 0x1f(%rax) # imm = 0x64616572
movq %rcx, 0x8(%r14)
movb $0x0, (%rax,%rcx)
movq (%r14), %rsi
movq 0x8(%r14), %rdx
movq 0x3cc6(%rip), %rdi      # 0x8ff0
callq 0x2210
movq %rax, %rdi
callq 0x20c0
jmp 0x53b0
leaq 0x58(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x40(%rsp), %rbx
movq $0x25, (%rbx)
leaq 0x48(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rsi
xorl %edx, %edx
callq 0x2380
movq %rax, (%r14)
movq (%rbx), %rcx
movq %rcx, 0x10(%r14)
movabsq $0x646165726874206c, %rdx # imm = 0x646165726874206C
movq %rdx, 0x1d(%rax)
movups 0xf05(%rip), %xmm0      # 0x6284
movups %xmm0, 0x10(%rax)
movups 0xeea(%rip), %xmm0      # 0x6274
movups %xmm0, (%rax)
movq %rcx, 0x8(%r14)
movb $0x0, (%rax,%rcx)
movq (%r14), %rsi
movq 0x8(%r14), %rdx
movq 0x3c4d(%rip), %rdi      # 0x8ff0
callq 0x2210
movq %rax, %rdi
callq 0x20c0
movl $0x1, %edi
callq 0x2230
jmp 0x53bc
movq %rax, %rbx
movq 0x48(%rsp), %rdi
cmpq %r15, %rdi
je 0x53d4
movq (%r15), %rsi
incq %rsi
callq 0x2200
movq %rbx, %rdi
callq 0x2350