// File: /workspace/github_cpp_makefile_star2_O2/tkaczenko[P]asteroids-clone/src/Ship.cpp
// Function: Ship::updatePosition(float const&)
void Ship::updatePosition(const float& dt)
{
    if (thrust) {
        speed += 1;
        if (speed > 5) {
            speed = 5;
        }
        velocity[0] += speed * cosA;
        velocity[1] += speed * sinA;
    } else {
        speed = 0;
    }
    switch (rot) {
        case LEFT: {
            angle -= 0.175;
            break;
        }
        case RIGHT: {
            angle += 0.175;
            break;
        }
        case NONE: {
            break;
        }
    }

    position.x = prevPosition.x - velocity[0] * dt;
    position.y = prevPosition.y - velocity[1] * dt;

    if (position.x > 800) {
        position.x -= 800;
    }
    if (position.x < 0) {
        position.x += 800;
    }
    if (position.y > 600) {
        position.y -= 600;
    }
    if (position.y < 0) {
        position.y += 600;
    }
    for (auto i = bullets.begin(); i != bullets.end(); ) {
        if ((i -> second).isDead())
            i = bullets.erase(i);
        else
            ++i;
    }
    for (auto i = bullets.begin(); i != bullets.end(); i++) {
        i->second.updatePosition(dt, bullets);
    }
    prevPosition.x = position.x;
    prevPosition.y = position.y;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %r14
movq %rdi, %rbx
cmpb $0x1, 0x89(%rdi)
jne 0x3ff3
movss 0x84(%rbx), %xmm0
addss 0x1145(%rip), %xmm0     # 0x5100
movss 0x1141(%rip), %xmm1     # 0x5104
minss %xmm0, %xmm1
movss %xmm1, 0x84(%rbx)
movss 0x24(%rbx), %xmm0
mulss %xmm1, %xmm0
addss 0x1c(%rbx), %xmm0
movss %xmm0, 0x1c(%rbx)
mulss 0x28(%rbx), %xmm1
addss 0x20(%rbx), %xmm1
movss %xmm1, 0x20(%rbx)
jmp 0x3ffa
andl $0x0, 0x84(%rbx)
movl 0x80(%rbx), %eax
cmpl $0x1, %eax
je 0x4014
cmpl $0x2, %eax
jne 0x402e
movsd 0x1106(%rip), %xmm0     # 0x5118
jmp 0x401c
movsd 0x10f4(%rip), %xmm0     # 0x5110
cvtss2sd 0x18(%rbx), %xmm1
addsd %xmm0, %xmm1
cvtsd2ss %xmm1, %xmm0
movss %xmm0, 0x18(%rbx)
cvtsi2ssl 0x8(%rbx), %xmm0
movss (%r14), %xmm1
movss 0x1c(%rbx), %xmm2
mulss %xmm1, %xmm2
subss %xmm2, %xmm0
cvttss2si %xmm0, %ecx
movl %ecx, 0x10(%rbx)
cvtsi2ssl 0xc(%rbx), %xmm0
mulss 0x20(%rbx), %xmm1
subss %xmm1, %xmm0
cvttss2si %xmm0, %eax
movl %eax, 0x14(%rbx)
movl $0xfffffce0, %edx       # imm = 0xFFFFFCE0
cmpl $0x320, %ecx            # imm = 0x320
jg 0x4077
testl %ecx, %ecx
jns 0x407c
movl $0x320, %edx            # imm = 0x320
addl %ecx, %edx
movl %edx, 0x10(%rbx)
movl $0xfffffda8, %ecx       # imm = 0xFFFFFDA8
cmpl $0x258, %eax            # imm = 0x258
jg 0x4091
testl %eax, %eax
jns 0x4096
movl $0x258, %ecx            # imm = 0x258
addl %eax, %ecx
movl %ecx, 0x14(%rbx)
leaq 0x40(%rbx), %r15
movq 0x58(%rbx), %r12
leaq 0x48(%rbx), %r13
cmpq %r13, %r12
je 0x40d2
leaq 0x40(%r12), %rdi
callq 0x2ce2
testb %al, %al
je 0x40c5
movq %r15, %rdi
movq %r12, %rsi
callq 0x37bc
movq %rax, %r12
jmp 0x40a2
movq %r12, %rdi
callq 0x21d0
movq %rax, %r12
jmp 0x40a2
movq 0x58(%rbx), %r12
cmpq %r13, %r12
je 0x40f8
leaq 0x40(%r12), %rdi
movq %r14, %rsi
movq %r15, %rdx
callq 0x2bba
movq %r12, %rdi
callq 0x21d0
movq %rax, %r12
jmp 0x40d6
movq 0x10(%rbx), %rax
movq %rax, 0x8(%rbx)
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop