// File: /workspace/github_cpp_makefile_star2_O3/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 %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movq %rdi, %rbx
callq 0x2646
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 0x29ab
xorl %r13d, %r13d
movq %r15, %rdi
xorl %esi, %esi
movq %r14, %rdx
callq 0x2120
movq %r15, 0x2748(%rbx)
movq %r14, %rdi
callq 0x2030
movq %rax, 0x2740(%rbx)
movl $0x8, %edi
callq 0x2030
movq 0x2740(%rbx), %rcx
movq %rax, (%rcx,%r13,8)
incq %r13
cmpq %r13, %r12
jne 0x286b
testq %r12, %r12
je 0x29c1
leaq 0x13b0(%rbx), %r14
xorl %r12d, %r12d
leaq 0x8(%rsp), %r15
movl (%rbx), %edx
movl 0x4(%rbx), %r8d
movq %rbx, %rdi
xorl %esi, %esi
xorl %ecx, %ecx
callq 0x2728
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, 0x8(%rsp)
movq %r15, %rdi
movq %r14, %rsi
movq %r15, %rdx
callq 0x3a76
movq 0x2738(%rbx), %rcx
movw %ax, 0x6(%rcx,%r12,8)
movw %ax, 0x4(%rcx,%r12,8)
movups 0xc(%rbx), %xmm0
movaps %xmm0, 0x40(%rsp)
movups 0x10(%rbx), %xmm0
movaps %xmm0, 0x20(%rsp)
movss 0x18(%rbx), %xmm0
movaps %xmm0, 0x10(%rsp)
movss 0x14(%rbx), %xmm0
movaps %xmm0, 0x30(%rsp)
callq 0x2080
movl %eax, %ebp
callq 0x2080
movq 0x2748(%rbx), %rcx
movd %ebp, %xmm0
movd %eax, %xmm1
punpckldq %xmm1, %xmm0    # xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
cvtdq2ps %xmm0, %xmm0
mulps 0x16bd(%rip), %xmm0     # 0x4020
movaps 0x10(%rsp), %xmm1
movaps 0x20(%rsp), %xmm2
movlhps %xmm2, %xmm1            # xmm1 = xmm1[0],xmm2[0]
shufps $0xe2, %xmm2, %xmm1     # xmm1 = xmm1[2,0],xmm2[2,3]
movaps 0x30(%rsp), %xmm2
movaps 0x40(%rsp), %xmm3
movlhps %xmm3, %xmm2            # xmm2 = xmm2[0],xmm3[0]
shufps $0xe2, %xmm3, %xmm2     # xmm2 = xmm2[2,0],xmm3[2,3]
subps %xmm2, %xmm1
mulps %xmm0, %xmm1
addps %xmm2, %xmm1
cvttps2dq %xmm1, %xmm0
cvtdq2ps %xmm0, %xmm0
movlps %xmm0, (%rcx,%r12,8)
incq %r12
movl 0x8(%rbx), %eax
cmpq %rax, %r12
jb 0x28a0
jmp 0x29c1
movq %r15, 0x2748(%rbx)
movq %r14, %rdi
callq 0x2030
movq %rax, 0x2740(%rbx)
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq