// File: 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
movq %rsp, %rbp
subq $0x70, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rdi
movq %rdi, -0x58(%rbp)
callq 0x37b0
movq -0x58(%rbp), %rax
movl 0x8(%rax), %eax
movl $0x8, %ecx
mulq %rcx
movq %rax, %rdi
seto %cl
movq $-0x1, %rax
testb $0x1, %cl
cmovneq %rax, %rdi
callq 0x3030
movq %rax, %rcx
movq -0x58(%rbp), %rax
movq %rcx, 0x2738(%rax)
movl 0x8(%rax), %eax
movq %rax, -0x48(%rbp)
movl $0x8, %ecx
mulq %rcx
movq %rax, %rdi
seto %cl
movq $-0x1, %rax
testb $0x1, %cl
cmovneq %rax, %rdi
movq %rdi, -0x50(%rbp)
callq 0x3030
movq %rax, %rcx
movq -0x48(%rbp), %rax
movq %rcx, -0x40(%rbp)
cmpq $0x0, %rax
je 0x3bba
movq -0x40(%rbp), %rax
movq -0x48(%rbp), %rdx
shlq $0x3, %rdx
movq %rax, %rcx
addq %rdx, %rcx
movq %rcx, -0x68(%rbp)
movq %rax, -0x60(%rbp)
movq -0x60(%rbp), %rdi
movq %rdi, -0x70(%rbp)
callq 0x5500
jmp 0x3ba5
movq -0x68(%rbp), %rcx
movq -0x70(%rbp), %rax
addq $0x8, %rax
cmpq %rcx, %rax
movq %rax, -0x60(%rbp)
jne 0x3b96
movq -0x58(%rbp), %rax
movq -0x40(%rbp), %rcx
movq %rcx, 0x2748(%rax)
movl 0x8(%rax), %eax
movl $0x8, %ecx
mulq %rcx
movq %rax, %rdi
seto %cl
movq $-0x1, %rax
testb $0x1, %cl
cmovneq %rax, %rdi
callq 0x3030
movq %rax, %rcx
movq -0x58(%rbp), %rax
movq %rcx, 0x2740(%rax)
movl $0x0, -0x18(%rbp)
movq -0x58(%rbp), %rcx
movl -0x18(%rbp), %eax
cmpl 0x8(%rcx), %eax
jae 0x3c56
movl $0x8, %edi
callq 0x3030
movq %rax, %rdx
movq -0x58(%rbp), %rax
movq 0x2740(%rax), %rax
movl -0x18(%rbp), %ecx
movq %rdx, (%rax,%rcx,8)
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
jmp 0x3c02
movq -0x50(%rbp), %rsi
movq -0x40(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x10(%rbp)
movl %eax, -0x14(%rbp)
callq 0x3450
jmp 0x3d96
leaq -0x20(%rbp), %rdi
callq 0x5520
movl $0x0, -0x28(%rbp)
movq -0x58(%rbp), %rcx
movl -0x28(%rbp), %eax
cmpl 0x8(%rcx), %eax
jae 0x3d90
movq -0x58(%rbp), %rdi
movl (%rdi), %edx
movl 0x4(%rdi), %r8d
xorl %ecx, %ecx
movl %ecx, %esi
callq 0x39a0
movq %rax, -0x30(%rbp)
leaq -0x20(%rbp), %rdi
leaq -0x30(%rbp), %rsi
callq 0x5540
movq -0x58(%rbp), %rdi
movw -0x20(%rbp), %dx
movq 0x2738(%rdi), %rax
movl -0x28(%rbp), %ecx
movw %dx, (%rax,%rcx,8)
movw -0x1c(%rbp), %dx
movq 0x2738(%rdi), %rax
movl -0x28(%rbp), %ecx
movw %dx, 0x2(%rax,%rcx,8)
cvtsi2ssl -0x20(%rbp), %xmm0
movq 0x2740(%rdi), %rax
movl -0x28(%rbp), %ecx
movq (%rax,%rcx,8), %rax
movss %xmm0, (%rax)
cvtsi2ssl -0x1c(%rbp), %xmm0
movq 0x2740(%rdi), %rax
movl -0x28(%rbp), %ecx
movq (%rax,%rcx,8), %rax
movss %xmm0, 0x4(%rax)
movl 0x20(%rdi), %esi
movl 0x24(%rdi), %edx
callq 0x3aa0
movq -0x58(%rbp), %rdi
movl %eax, -0x24(%rbp)
movw -0x24(%rbp), %dx
movq 0x2738(%rdi), %rax
movl -0x28(%rbp), %ecx
movw %dx, 0x6(%rax,%rcx,8)
movw -0x24(%rbp), %dx
movq 0x2738(%rdi), %rax
movl -0x28(%rbp), %ecx
movw %dx, 0x4(%rax,%rcx,8)
movss 0xc(%rdi), %xmm0
movss 0x10(%rdi), %xmm1
movss 0x14(%rdi), %xmm2
movss 0x18(%rdi), %xmm3
callq 0x3a30
movlpd %xmm0, -0x38(%rbp)
leaq -0x20(%rbp), %rdi
leaq -0x38(%rbp), %rsi
callq 0x5570
movq -0x58(%rbp), %rax
cvtsi2ssl -0x20(%rbp), %xmm0
movq 0x2748(%rax), %rcx
movl -0x28(%rbp), %edx
movss %xmm0, (%rcx,%rdx,8)
cvtsi2ssl -0x1c(%rbp), %xmm0
movq 0x2748(%rax), %rax
movl -0x28(%rbp), %ecx
movss %xmm0, 0x4(%rax,%rcx,8)
movl -0x28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x28(%rbp)
jmp 0x3c66
addq $0x70, %rsp
popq %rbp
retq
movq -0x10(%rbp), %rdi
callq 0x3400
nop