// File: /workspace/github_cpp_makefile_star2_O3/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 0x43f9
movss 0x84(%rbx), %xmm0
addss 0xd6f(%rip), %xmm0      # 0x5130
movss 0xd6b(%rip), %xmm1      # 0x5134
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 0x4403
movl $0x0, 0x84(%rbx)
movl 0x80(%rbx), %eax
cmpl $0x1, %eax
je 0x441d
cmpl $0x2, %eax
jne 0x443d
movsd 0xd2d(%rip), %xmm0      # 0x5148
jmp 0x4425
movsd 0xd1b(%rip), %xmm0      # 0x5140
xorps %xmm1, %xmm1
cvtss2sd 0x18(%rbx), %xmm1
addsd %xmm0, %xmm1
xorps %xmm0, %xmm0
cvtsd2ss %xmm1, %xmm0
movss %xmm0, 0x18(%rbx)
xorps %xmm0, %xmm0
cvtsi2ssl 0x8(%rbx), %xmm0
movss (%r14), %xmm1
movss 0x1c(%rbx), %xmm2
mulss %xmm1, %xmm2
subss %xmm2, %xmm0
cvttss2si %xmm0, %ecx
movl %ecx, 0x10(%rbx)
xorps %xmm0, %xmm0
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 0x448c
testl %ecx, %ecx
jns 0x4491
movl $0x320, %edx            # imm = 0x320
addl %ecx, %edx
movl %edx, 0x10(%rbx)
movl $0xfffffda8, %ecx       # imm = 0xFFFFFDA8
cmpl $0x258, %eax            # imm = 0x258
jg 0x44a6
testl %eax, %eax
jns 0x44ab
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 0x44eb
leaq 0x40(%r12), %rdi
callq 0x2de0
testb %al, %al
je 0x44d7
movq %r15, %rdi
movq %r12, %rsi
callq 0x39fa
jmp 0x44df
movq %r12, %rdi
callq 0x21c0
movq %rax, %r12
cmpq %r13, %rax
jne 0x44bc
movq 0x58(%rbx), %r12
cmpq %r13, %r12
je 0x4510
leaq 0x40(%r12), %rdi
movq %r14, %rsi
movq %r15, %rdx
callq 0x2cb0
movq %r12, %rdi
callq 0x21c0
movq %rax, %r12
cmpq %r13, %rax
jne 0x44f0
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