// File: /workspace/github_cpp_makefile_star2_O1/4shadoww[P]xwinter/xwinter.cpp
// Function: sky::create_sky()
void sky::create_sky(){
    // Check is there an old sky
    sky::free_memory();

    // Reverse memory
    this->snowflakes = new XRectangle[this->particle_count];
    this->snowflakespeeds = new flakespeed[this->particle_count];
    this->positions = new float*[this->particle_count];

    for(unsigned int i = 0; i < this->particle_count; i++){
        this->positions[i] = new float[2];
    }

    // Temp variables
    std::pair<int, int> temp_pair;
    int temp_int;

    // Create randomised flakes
    for(unsigned int i = 0; i < this->particle_count; i++){
        // Get random position
        temp_pair = sky::get_random_position(0, this->screen_width, 0, this->screen_heigth);
        // Set position on screen
        this->snowflakes[i].x = temp_pair.first;
        this->snowflakes[i].y = temp_pair.second;
        // Set position to float number table
        this->positions[i][0] = temp_pair.first;
        this->positions[i][1] = temp_pair.second;
        // Set random size
        temp_int = sky::get_random_size(this->min_size, this->max_size);
        this->snowflakes[i].height = temp_int;
        this->snowflakes[i].width = temp_int;
        // Set random speed
        temp_pair = this->get_random_speed(this->min_speed_x, this->max_speed_x, this->min_speed_y, this->max_speed_y);
        this->snowflakespeeds[i].speed_x = temp_pair.first;
        this->snowflakespeeds[i].speed_y = temp_pair.second;
    }
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rdi, %rbx
callq 0x263c
movl 0x8(%rbx), %r12d
leaq (,%r12,8), %r14
movq %r14, %rdi
callq 0x2030
movq %rax, 0x2738(%rbx)
movq %r14, %rdi
callq 0x2030
movq %rax, %r15
testq %r12, %r12
je 0x2855
movq %r15, %rdi
xorl %esi, %esi
movq %r14, %rdx
callq 0x2120
movq %r15, 0x2748(%rbx)
movq %r14, %rdi
callq 0x2030
movq %rax, 0x2740(%rbx)
testq %r12, %r12
je 0x2890
xorl %r14d, %r14d
movl $0x8, %edi
callq 0x2030
movq 0x2740(%rbx), %rcx
movq %rax, (%rcx,%r14,8)
incq %r14
cmpq %r14, %r12
jne 0x2873
cmpl $0x0, 0x8(%rbx)
je 0x29d9
leaq 0x13b0(%rbx), %r14
xorl %r12d, %r12d
leaq 0x28(%rsp), %r15
movl (%rbx), %edx
movl 0x4(%rbx), %r8d
movq %rbx, %rdi
xorl %esi, %esi
xorl %ecx, %ecx
callq 0x2718
movq 0x2738(%rbx), %rcx
movw %ax, (%rcx,%r12,8)
xorps %xmm0, %xmm0
cvtsi2ss %eax, %xmm0
shrq $0x20, %rax
movw %ax, 0x2(%rcx,%r12,8)
movq 0x2740(%rbx), %rcx
movq (%rcx,%r12,8), %rcx
xorps %xmm1, %xmm1
cvtsi2ss %eax, %xmm1
movss %xmm0, (%rcx)
movss %xmm1, 0x4(%rcx)
movq 0x20(%rbx), %rax
movq %rax, 0x28(%rsp)
movq %r15, %rdi
movq %r14, %rsi
movq %r15, %rdx
callq 0x3a78
movq 0x2738(%rbx), %rcx
movw %ax, 0x6(%rcx,%r12,8)
movw %ax, 0x4(%rcx,%r12,8)
movss 0xc(%rbx), %xmm0
movss %xmm0, 0x8(%rsp)
movss 0x10(%rbx), %xmm0
movaps %xmm0, 0x10(%rsp)
movss 0x14(%rbx), %xmm0
movss %xmm0, 0xc(%rsp)
movss 0x18(%rbx), %xmm0
movaps %xmm0, 0x30(%rsp)
callq 0x2080
xorps %xmm0, %xmm0
cvtsi2ss %eax, %xmm0
movss 0x16d5(%rip), %xmm1     # 0x4030
mulss %xmm1, %xmm0
movaps 0x10(%rsp), %xmm1
movss 0x8(%rsp), %xmm2
subss %xmm2, %xmm1
mulss %xmm0, %xmm1
addss %xmm2, %xmm1
movaps %xmm1, 0x10(%rsp)
callq 0x2080
xorps %xmm0, %xmm0
cvtsi2ss %eax, %xmm0
mulss 0x16a1(%rip), %xmm0     # 0x4030
movaps 0x30(%rsp), %xmm1
movss 0xc(%rsp), %xmm2
subss %xmm2, %xmm1
mulss %xmm0, %xmm1
addss %xmm2, %xmm1
cvttps2dq 0x10(%rsp), %xmm0
cvtdq2ps %xmm0, %xmm0
movq 0x2748(%rbx), %rax
movss %xmm0, (%rax,%r12,8)
cvttps2dq %xmm1, %xmm0
cvtdq2ps %xmm0, %xmm0
movss %xmm0, 0x4(%rax,%r12,8)
incq %r12
movl 0x8(%rbx), %eax
cmpq %rax, %r12
jb 0x28a9
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
nop