// File: /workspace/github_cpp_makefile_star2_O1/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 0x44d3
movss 0x84(%rbx), %xmm0
addss 0xc95(%rip), %xmm0      # 0x5130
movss 0xc91(%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 0x44dd
movl $0x0, 0x84(%rbx)
movl 0x80(%rbx), %eax
cmpl $0x1, %eax
je 0x44f7
cmpl $0x2, %eax
jne 0x4517
movsd 0xc53(%rip), %xmm0      # 0x5148
jmp 0x44ff
movsd 0xc41(%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)
cmpl $0x321, %ecx            # imm = 0x321
jl 0x4561
addl $0xfffffce0, %ecx       # imm = 0xFFFFFCE0
movl %ecx, 0x10(%rbx)
movl 0x10(%rbx), %ecx
testl %ecx, %ecx
jns 0x4571
addl $0x320, %ecx            # imm = 0x320
movl %ecx, 0x10(%rbx)
cmpl $0x259, %eax            # imm = 0x259
jl 0x4580
addl $0xfffffda8, %eax       # imm = 0xFFFFFDA8
movl %eax, 0x14(%rbx)
movl 0x14(%rbx), %eax
testl %eax, %eax
jns 0x458f
addl $0x258, %eax            # imm = 0x258
movl %eax, 0x14(%rbx)
leaq 0x40(%rbx), %r15
movq 0x58(%rbx), %r12
leaq 0x48(%rbx), %r13
cmpq %r13, %r12
je 0x45c8
leaq 0x40(%r12), %rdi
callq 0x2dd2
testb %al, %al
je 0x45bb
movq %r15, %rdi
movq %r12, %rsi
callq 0x3ad0
jmp 0x45c3
movq %r12, %rdi
callq 0x21c0
movq %rax, %r12
jmp 0x459b
movq 0x58(%rbx), %r12
cmpq %r13, %r12
je 0x45f1
leaq 0x40(%r12), %rdi
movq %r14, %rsi
movq %r15, %rdx
callq 0x2ca0
movq %r12, %rdi
callq 0x21c0
movq %rax, %r12
cmpq %r13, %rax
jne 0x45d1
movq 0x10(%rbx), %rax
movq %rax, 0x8(%rbx)
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq