// File: 4shadoww[P]xwinter/xwinter.cpp
// Function: sky::update(float)
void sky::update(float delta){
    // Temp variables
    std::pair<int, int> temp_pair;
    // Spawm flake positions
    int y = 0;

    // Loop
    for(unsigned int i = 0; i < this->particle_count; i++){
        // Update position
        this->positions[i][0] += this->snowflakespeeds[i].speed_x / 100.f * (delta);
        this->positions[i][1] += this->snowflakespeeds[i].speed_y / 100.f * (delta);
        this->snowflakes[i].x = this->positions[i][0];
        this->snowflakes[i].y = this->positions[i][1];

        // If out of screen spawn again
        if(this->snowflakes[i].x + this->snowflakes[i].width > (int)this->screen_width ||
           this->snowflakes[i].y + this->snowflakes[i].height > (int)this->screen_heigth ||
           this->snowflakes[i].x + this->snowflakes[i].width < 0 ||
           this->snowflakes[i].y + this->snowflakes[i].height < 0){

            // Get new random position
            if(y < this->x_spawn_intensity){
                if(this->snowflakespeeds[i].speed_y > 0){
                    temp_pair = sky::get_random_position(0, this->screen_width, 0, 0);
                }else{
                    temp_pair = sky::get_random_position(0, this->screen_width, this->screen_heigth, this->screen_heigth);
                }
                y++;
            }else{
                if(this->snowflakespeeds[i].speed_x > 0){
                    temp_pair = sky::get_random_position(0, 0, 0, this->screen_heigth);
                }else{
                    temp_pair = sky::get_random_position(this->screen_width, this->screen_width, 0, this->screen_heigth);
                y = 0;
                }
            }
            // Set position
            this->positions[i][0] = temp_pair.first;
            this->positions[i][1] = temp_pair.second;
            this->snowflakes[i].x = temp_pair.first;
            this->snowflakes[i].y = temp_pair.second;
        }
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x8(%rbp)
movss %xmm0, -0xc(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x48(%rbp)
leaq -0x14(%rbp), %rdi
callq 0x5520
movl $0x0, -0x18(%rbp)
movl $0x0, -0x1c(%rbp)
movq -0x48(%rbp), %rcx
movl -0x1c(%rbp), %eax
cmpl 0x8(%rcx), %eax
jae 0x4095
movq -0x48(%rbp), %rcx
movq 0x2740(%rcx), %rax
movq 0x2748(%rcx), %rsi
movl -0x1c(%rbp), %edx
movss (%rsi,%rdx,8), %xmm0
movss 0x3206(%rip), %xmm1     # 0x7008
divss %xmm1, %xmm0
movss -0xc(%rbp), %xmm3
movq (%rax,%rdx,8), %rax
movss (%rax), %xmm2
mulss %xmm3, %xmm0
addss %xmm2, %xmm0
movss %xmm0, (%rax)
movq 0x2740(%rcx), %rax
movq 0x2748(%rcx), %rsi
movl -0x1c(%rbp), %edx
movss 0x4(%rsi,%rdx,8), %xmm0
divss %xmm1, %xmm0
movss -0xc(%rbp), %xmm2
movq (%rax,%rdx,8), %rax
movss 0x4(%rax), %xmm1
mulss %xmm2, %xmm0
addss %xmm1, %xmm0
movss %xmm0, 0x4(%rax)
movq 0x2738(%rcx), %rax
movq 0x2740(%rcx), %rsi
movl -0x1c(%rbp), %edx
movq (%rsi,%rdx,8), %rsi
cvttss2si (%rsi), %esi
movw %si, (%rax,%rdx,8)
movq 0x2740(%rcx), %rax
movl -0x1c(%rbp), %edx
movq (%rax,%rdx,8), %rax
movss 0x4(%rax), %xmm0
cvttss2si %xmm0, %eax
movw %ax, %si
movq 0x2738(%rcx), %rax
movl -0x1c(%rbp), %edx
movw %si, 0x2(%rax,%rdx,8)
movq 0x2738(%rcx), %rax
movl -0x1c(%rbp), %edx
movswl (%rax,%rdx,8), %eax
movq 0x2738(%rcx), %rdx
movl -0x1c(%rbp), %esi
movzwl 0x4(%rdx,%rsi,8), %edx
addl %edx, %eax
cmpl (%rcx), %eax
jg 0x3f3c
movq -0x48(%rbp), %rcx
movq 0x2738(%rcx), %rax
movl -0x1c(%rbp), %edx
movswl 0x2(%rax,%rdx,8), %eax
movq 0x2738(%rcx), %rdx
movl -0x1c(%rbp), %esi
movzwl 0x6(%rdx,%rsi,8), %edx
addl %edx, %eax
cmpl 0x4(%rcx), %eax
jg 0x3f3c
movq -0x48(%rbp), %rcx
movq 0x2738(%rcx), %rax
movl -0x1c(%rbp), %edx
movswl (%rax,%rdx,8), %eax
movq 0x2738(%rcx), %rcx
movl -0x1c(%rbp), %edx
movzwl 0x4(%rcx,%rdx,8), %ecx
addl %ecx, %eax
cmpl $0x0, %eax
jl 0x3f3c
movq -0x48(%rbp), %rcx
movq 0x2738(%rcx), %rax
movl -0x1c(%rbp), %edx
movswl 0x2(%rax,%rdx,8), %eax
movq 0x2738(%rcx), %rcx
movl -0x1c(%rbp), %edx
movzwl 0x6(%rcx,%rdx,8), %ecx
addl %ecx, %eax
cmpl $0x0, %eax
jge 0x4085
movq -0x48(%rbp), %rcx
movl -0x18(%rbp), %eax
cmpl 0x1c(%rcx), %eax
jge 0x3fbb
movq -0x48(%rbp), %rax
movq 0x2748(%rax), %rax
movl -0x1c(%rbp), %ecx
movss 0x4(%rax,%rcx,8), %xmm0
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jbe 0x3f8b
movq -0x48(%rbp), %rdi
movl (%rdi), %edx
xorl %r8d, %r8d
movl %r8d, %esi
movl %r8d, %ecx
callq 0x39a0
movq %rax, -0x24(%rbp)
leaq -0x14(%rbp), %rdi
leaq -0x24(%rbp), %rsi
callq 0x5540
jmp 0x3fb0
movq -0x48(%rbp), %rdi
movl (%rdi), %edx
movl 0x4(%rdi), %ecx
movl 0x4(%rdi), %r8d
xorl %esi, %esi
callq 0x39a0
movq %rax, -0x2c(%rbp)
leaq -0x14(%rbp), %rdi
leaq -0x2c(%rbp), %rsi
callq 0x5540
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
jmp 0x4029
movq -0x48(%rbp), %rax
movq 0x2748(%rax), %rax
movl -0x1c(%rbp), %ecx
movss (%rax,%rcx,8), %xmm0
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jbe 0x3ffc
movq -0x48(%rbp), %rdi
movl 0x4(%rdi), %r8d
xorl %ecx, %ecx
movl %ecx, %esi
movl %ecx, %edx
callq 0x39a0
movq %rax, -0x34(%rbp)
leaq -0x14(%rbp), %rdi
leaq -0x34(%rbp), %rsi
callq 0x5540
jmp 0x4027
movq -0x48(%rbp), %rdi
movl (%rdi), %esi
movl (%rdi), %edx
movl 0x4(%rdi), %r8d
xorl %ecx, %ecx
callq 0x39a0
movq %rax, -0x3c(%rbp)
leaq -0x14(%rbp), %rdi
leaq -0x3c(%rbp), %rsi
callq 0x5540
movl $0x0, -0x18(%rbp)
jmp 0x4029
movq -0x48(%rbp), %rax
cvtsi2ssl -0x14(%rbp), %xmm0
movq 0x2740(%rax), %rcx
movl -0x1c(%rbp), %edx
movq (%rcx,%rdx,8), %rcx
movss %xmm0, (%rcx)
cvtsi2ssl -0x10(%rbp), %xmm0
movq 0x2740(%rax), %rcx
movl -0x1c(%rbp), %edx
movq (%rcx,%rdx,8), %rcx
movss %xmm0, 0x4(%rcx)
movl -0x14(%rbp), %ecx
movw %cx, %si
movq 0x2738(%rax), %rcx
movl -0x1c(%rbp), %edx
movw %si, (%rcx,%rdx,8)
movl -0x10(%rbp), %ecx
movw %cx, %dx
movq 0x2738(%rax), %rax
movl -0x1c(%rbp), %ecx
movw %dx, 0x2(%rax,%rcx,8)
jmp 0x4087
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x3dd0
addq $0x50, %rsp
popq %rbp
retq
nopl (%rax,%rax)