// File: tkaczenko[P]asteroids-clone/src/GameEngine.cpp
// Function: GameEngine::spawnRock(int const&, int const&, float const&, float const&)
void GameEngine::spawnRock(const int& type, const int& number, const float& x, const float& y)
{
    for (int numRocks = 0; numRocks != number; numRocks++) {
        SDL_Point tempPos;
        if (x == 0.0 && y == 00) {
            tempPos = {rand() % 700 + 100, rand() % 500 + 100};
            if (tempPos.x < player.getPosition().x + 100 || tempPos.x > player.getPosition().x - 100 ||
                tempPos.y < player.getPosition().y + 100 || tempPos.y > player.getPosition().y - 100) {
                tempPos.x += 200;
                tempPos.y -= 200;
            }
        } else {
            tempPos = {int(x), int(y)};
        }
        float tempVel[2];
        if (rand() % 2 + 1 == 2) {
            tempVel[0] = rand() % 25 + 15;
        } else {
            tempVel[0] = (rand()%25 + 15) * -1;
        }
        if (rand() % 2 + 1 == 2) {
            tempVel[1] = rand() % 25 + 15;
        } else {
            tempVel[1] = (rand() % 25 + 15) * -1;
        }

        std::stringstream number;
        number << rockNum;
        std::string name = "rock" + number.str();
        Rock tempRock = {tempPos, tempVel[0], tempVel[1], type, rockNum};

        rocks.insert(std::pair<std::string, Rock>(name, tempRock));
        rockNum++;
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x4b0, %rsp            # imm = 0x4B0
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x478(%rbp)
movl $0x0, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
movq -0x18(%rbp), %rcx
cmpl (%rcx), %eax
je 0x47d9
movq -0x20(%rbp), %rax
movss (%rax), %xmm0
cvtss2sd %xmm0, %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0x4525
jp 0x4525
movq -0x28(%rbp), %rax
movss (%rax), %xmm0
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jne 0x4525
jp 0x4525
callq 0x3100
movl $0x2bc, %ecx            # imm = 0x2BC
cltd
idivl %ecx
addl $0x64, %edx
movl %edx, -0x3c(%rbp)
callq 0x3100
movq -0x478(%rbp), %rdi
movl $0x1f4, %ecx            # imm = 0x1F4
cltd
idivl %ecx
addl $0x64, %edx
movl %edx, -0x38(%rbp)
movq -0x3c(%rbp), %rax
movq %rax, -0x34(%rbp)
movl -0x34(%rbp), %eax
movl %eax, -0x480(%rbp)
callq 0x5180
movl -0x480(%rbp), %ecx
movq %rax, -0x44(%rbp)
movl -0x44(%rbp), %edx
addl $0x64, %edx
movb $0x1, %al
cmpl %edx, %ecx
movb %al, -0x479(%rbp)
jl 0x4501
movq -0x478(%rbp), %rdi
movl -0x34(%rbp), %eax
movl %eax, -0x484(%rbp)
callq 0x5180
movl -0x484(%rbp), %ecx
movq %rax, -0x4c(%rbp)
movl -0x4c(%rbp), %edx
subl $0x64, %edx
movb $0x1, %al
cmpl %edx, %ecx
movb %al, -0x479(%rbp)
jg 0x4501
movq -0x478(%rbp), %rdi
movl -0x30(%rbp), %eax
movl %eax, -0x488(%rbp)
callq 0x5180
movl -0x488(%rbp), %ecx
movq %rax, -0x54(%rbp)
movl -0x50(%rbp), %edx
addl $0x64, %edx
movb $0x1, %al
cmpl %edx, %ecx
movb %al, -0x479(%rbp)
jl 0x4501
movq -0x478(%rbp), %rdi
movl -0x30(%rbp), %eax
movl %eax, -0x48c(%rbp)
callq 0x5180
movq %rax, %rcx
movl -0x48c(%rbp), %eax
movq %rcx, -0x5c(%rbp)
movl -0x58(%rbp), %ecx
subl $0x64, %ecx
cmpl %ecx, %eax
setg %al
movb %al, -0x479(%rbp)
movb -0x479(%rbp), %al
testb $0x1, %al
jne 0x450d
jmp 0x4523
movl -0x34(%rbp), %eax
addl $0xc8, %eax
movl %eax, -0x34(%rbp)
movl -0x30(%rbp), %eax
subl $0xc8, %eax
movl %eax, -0x30(%rbp)
jmp 0x4543
movq -0x20(%rbp), %rax
cvttss2si (%rax), %eax
movl %eax, -0x64(%rbp)
movq -0x28(%rbp), %rax
cvttss2si (%rax), %eax
movl %eax, -0x60(%rbp)
movq -0x64(%rbp), %rax
movq %rax, -0x34(%rbp)
callq 0x3100
movl $0x2, %ecx
cltd
idivl %ecx
addl $0x1, %edx
cmpl $0x2, %edx
jne 0x4573
callq 0x3100
movl $0x19, %ecx
cltd
idivl %ecx
addl $0xf, %edx
cvtsi2ss %edx, %xmm0
movss %xmm0, -0x6c(%rbp)
jmp 0x458f
callq 0x3100
movl $0x19, %ecx
cltd
idivl %ecx
addl $0xf, %edx
imull $-0x1, %edx, %eax
cvtsi2ss %eax, %xmm0
movss %xmm0, -0x6c(%rbp)
callq 0x3100
movl $0x2, %ecx
cltd
idivl %ecx
addl $0x1, %edx
cmpl $0x2, %edx
jne 0x45bf
callq 0x3100
movl $0x19, %ecx
cltd
idivl %ecx
addl $0xf, %edx
cvtsi2ss %edx, %xmm0
movss %xmm0, -0x68(%rbp)
jmp 0x45db
callq 0x3100
movl $0x19, %ecx
cltd
idivl %ecx
addl $0xf, %edx
imull $-0x1, %edx, %eax
cvtsi2ss %eax, %xmm0
movss %xmm0, -0x68(%rbp)
leaq -0x1f8(%rbp), %rdi
callq 0x31e0
movq -0x478(%rbp), %rax
leaq -0x1e8(%rbp), %rdi
movl 0xc0(%rax), %esi
callq 0x33d0
jmp 0x4602
leaq -0x248(%rbp), %rdi
leaq -0x1f8(%rbp), %rsi
callq 0x32d0
jmp 0x4617
leaq 0x4a52(%rip), %rsi      # 0x9070
leaq -0x228(%rbp), %rdi
leaq -0x248(%rbp), %rdx
callq 0x51a0
jmp 0x4633
leaq -0x248(%rbp), %rdi
callq 0x31b0
movq -0x478(%rbp), %r9
movq -0x34(%rbp), %rax
movq %rax, -0x348(%rbp)
leaq -0x68(%rbp), %rcx
movq -0x10(%rbp), %r8
addq $0xc0, %r9
movq -0x348(%rbp), %rsi
leaq -0x340(%rbp), %rdi
leaq -0x6c(%rbp), %rdx
callq 0x6920
jmp 0x4679
movq -0x478(%rbp), %rax
addq $0x90, %rax
movq %rax, -0x498(%rbp)
leaq -0x460(%rbp), %rdi
leaq -0x228(%rbp), %rsi
leaq -0x340(%rbp), %rdx
callq 0x5230
jmp 0x46a9
movq -0x498(%rbp), %rdi
leaq -0x460(%rbp), %rsi
callq 0x51f0
movb %dl, -0x4a1(%rbp)
movq %rax, -0x4a0(%rbp)
jmp 0x46cb
movb -0x4a1(%rbp), %al
movq -0x4a0(%rbp), %rcx
movq %rcx, -0x470(%rbp)
movb %al, -0x468(%rbp)
leaq -0x460(%rbp), %rdi
callq 0x5270
movq -0x478(%rbp), %rax
movl 0xc0(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0xc0(%rax)
leaq -0x340(%rbp), %rdi
callq 0x6b30
leaq -0x228(%rbp), %rdi
callq 0x31b0
leaq -0x1f8(%rbp), %rdi
callq 0x3210
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x43c1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x200(%rbp)
movl %eax, -0x204(%rbp)
jmp 0x47cb
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x200(%rbp)
movl %eax, -0x204(%rbp)
leaq -0x248(%rbp), %rdi
callq 0x31b0
jmp 0x47cb
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x200(%rbp)
movl %eax, -0x204(%rbp)
jmp 0x47bf
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x200(%rbp)
movl %eax, -0x204(%rbp)
jmp 0x47b3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x200(%rbp)
movl %eax, -0x204(%rbp)
leaq -0x460(%rbp), %rdi
callq 0x5270
leaq -0x340(%rbp), %rdi
callq 0x6b30
leaq -0x228(%rbp), %rdi
callq 0x31b0
leaq -0x1f8(%rbp), %rdi
callq 0x3210
jmp 0x47e2
addq $0x4b0, %rsp            # imm = 0x4B0
popq %rbp
retq
movq -0x200(%rbp), %rdi
callq 0x33e0
nop