// File: /workspace/github_cpp_makefile_star2_O3/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)
movl 0x8(%rdi), %eax
testl %eax, %eax
je 0x2b37
movq %rdi, %rbx
movq 0x2738(%rdi), %rsi
movq 0x2740(%rdi), %rcx
xorl %r14d, %r14d
xorl %ebp, %ebp
movq 0x2748(%rbx), %rdi
movss (%rdi,%r14,8), %xmm0
movss 0x1650(%rip), %xmm3     # 0x4064
divss %xmm3, %xmm0
movq (%rcx,%r14,8), %rdx
movss 0xc(%rsp), %xmm2
mulss %xmm2, %xmm0
addss (%rdx), %xmm0
movss %xmm0, (%rdx)
movss 0x4(%rdi,%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, (%rsi,%r14,8)
movzwl 0x4(%rsi,%r14,8), %r8d
addl %edx, %r8d
movl (%rbx), %edx
cmpl %edx, %r8d
jle 0x2a8d
cmpl 0x1c(%rbx), %ebp
jge 0x2aad
movss 0x4(%rdi,%r14,8), %xmm0
ucomiss 0x15e9(%rip), %xmm0     # 0x4068
jbe 0x2ac9
movq %rbx, %rdi
xorl %esi, %esi
xorl %ecx, %ecx
xorl %r8d, %r8d
jmp 0x2ad4
pextrw $0x1, %xmm0, %r9d
movswl %r9w, %r10d
movzwl 0x6(%rsi,%r14,8), %r9d
addl %r10d, %r9d
cmpl 0x4(%rbx), %r9d
jg 0x2a6c
orl %r8d, %r9d
jns 0x2b29
jmp 0x2a6c
movss (%rdi,%r14,8), %xmm0
ucomiss 0x15ae(%rip), %xmm0     # 0x4068
movl 0x4(%rbx), %r8d
jbe 0x2add
movq %rbx, %rdi
xorl %esi, %esi
xorl %edx, %edx
jmp 0x2ae4
movl 0x4(%rbx), %ecx
movq %rbx, %rdi
xorl %esi, %esi
movl %ecx, %r8d
callq 0x2728
incl %ebp
jmp 0x2aeb
xorl %ebp, %ebp
movq %rbx, %rdi
movl %edx, %esi
xorl %ecx, %ecx
callq 0x2728
movq %rax, %rdx
xorps %xmm0, %xmm0
cvtsi2ss %eax, %xmm0
shrq $0x20, %rdx
movq 0x2740(%rbx), %rcx
movq (%rcx,%r14,8), %rsi
movss %xmm0, (%rsi)
xorps %xmm0, %xmm0
cvtsi2ss %edx, %xmm0
movss %xmm0, 0x4(%rsi)
movq 0x2738(%rbx), %rsi
movw %ax, (%rsi,%r14,8)
movw %dx, 0x2(%rsi,%r14,8)
movl 0x8(%rbx), %eax
incq %r14
movl %eax, %edx
cmpq %rdx, %r14
jb 0x29ff
addq $0x10, %rsp
popq %rbx
popq %r14
popq %rbp
retq