// File: /workspace/github_cpp_makefile_star2_O2/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
pushq %r14
pushq %rbx
subq $0x10, %rsp
movss %xmm0, 0xc(%rsp)
movq %rdi, %rbx
xorl %r14d, %r14d
xorl %ebp, %ebp
movl 0x8(%rbx), %eax
cmpq %rax, %r14
jae 0x2982
movq 0x2748(%rbx), %rax
movss (%rax,%r14,8), %xmm0
movss 0x17bd(%rip), %xmm3     # 0x4024
divss %xmm3, %xmm0
movq 0x2738(%rbx), %rcx
movq 0x2740(%rbx), %rdx
movq (%rdx,%r14,8), %rdx
movss 0xc(%rsp), %xmm2
mulss %xmm2, %xmm0
addss (%rdx), %xmm0
movss %xmm0, (%rdx)
movss 0x4(%rax,%r14,8), %xmm1
divss %xmm3, %xmm1
mulss %xmm2, %xmm1
addss 0x4(%rdx), %xmm1
movss %xmm1, 0x4(%rdx)
unpcklps %xmm1, %xmm0            # xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
cvttps2dq %xmm0, %xmm0
movd %xmm0, %edx
packssdw %xmm0, %xmm0
movd %xmm0, (%rcx,%r14,8)
movzwl 0x4(%rcx,%r14,8), %esi
addl %edx, %esi
movl (%rbx), %edx
cmpl %edx, %esi
jle 0x28ec
cmpl 0x1c(%rbx), %ebp
jge 0x2907
movss 0x4(%rax,%r14,8), %xmm0
ucomiss 0x174a(%rip), %xmm0     # 0x4028
jbe 0x2923
movq %rbx, %rdi
xorl %esi, %esi
xorl %ecx, %ecx
xorl %r8d, %r8d
jmp 0x292e
pextrw $0x1, %xmm0, %edi
movswl %di, %edi
movzwl 0x6(%rcx,%r14,8), %ecx
addl %edi, %ecx
cmpl 0x4(%rbx), %ecx
jg 0x28cb
orl %esi, %ecx
jns 0x297a
jmp 0x28cb
movss (%rax,%r14,8), %xmm0
ucomiss 0x1714(%rip), %xmm0     # 0x4028
movl 0x4(%rbx), %r8d
jbe 0x2937
movq %rbx, %rdi
xorl %esi, %esi
xorl %edx, %edx
jmp 0x293e
movl 0x4(%rbx), %ecx
movq %rbx, %rdi
xorl %esi, %esi
movl %ecx, %r8d
callq 0x2654
incl %ebp
jmp 0x2945
xorl %ebp, %ebp
movq %rbx, %rdi
movl %edx, %esi
xorl %ecx, %ecx
callq 0x2654
cvtsi2ss %eax, %xmm0
movq %rax, %rcx
shrq $0x20, %rcx
movq 0x2740(%rbx), %rdx
movq (%rdx,%r14,8), %rdx
movss %xmm0, (%rdx)
cvtsi2ss %ecx, %xmm0
movss %xmm0, 0x4(%rdx)
movq 0x2738(%rbx), %rdx
movw %ax, (%rdx,%r14,8)
movw %cx, 0x2(%rdx,%r14,8)
incq %r14
jmp 0x2846
addq $0x10, %rsp
popq %rbx
popq %r14
popq %rbp
retq