// File: /workspace/github_cpp_makefile_star2_O1/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)
cmpl $0x0, 0x8(%rdi)
je 0x2b46
movq %rdi, %rbx
xorl %r14d, %r14d
xorl %ebp, %ebp
movq 0x2740(%rbx), %rcx
movq 0x2748(%rbx), %rax
movss (%rax,%r14,8), %xmm0
movss 0x1612(%rip), %xmm3     # 0x4034
divss %xmm3, %xmm0
movq (%rcx,%r14,8), %rcx
movss 0xc(%rsp), %xmm2
mulss %xmm2, %xmm0
addss (%rcx), %xmm0
movss %xmm0, (%rcx)
movss 0x4(%rax,%r14,8), %xmm1
divss %xmm3, %xmm1
mulss %xmm2, %xmm1
addss 0x4(%rcx), %xmm1
movss %xmm1, 0x4(%rcx)
cvttss2si %xmm0, %ecx
movq 0x2738(%rbx), %rsi
movw %cx, (%rsi,%r14,8)
cvttss2si %xmm1, %edx
movw %dx, 0x2(%rsi,%r14,8)
movswl %cx, %edx
movzwl 0x4(%rsi,%r14,8), %ecx
addl %edx, %ecx
movl (%rbx), %edx
cmpl %edx, %ecx
jle 0x2aa1
cmpl 0x1c(%rbx), %ebp
jge 0x2aba
movss 0x4(%rax,%r14,8), %xmm0
ucomiss 0x15a5(%rip), %xmm0     # 0x4038
jbe 0x2ad6
movq %rbx, %rdi
xorl %esi, %esi
xorl %ecx, %ecx
xorl %r8d, %r8d
jmp 0x2ae1
movswl 0x2(%rsi,%r14,8), %edi
movzwl 0x6(%rsi,%r14,8), %esi
addl %edi, %esi
cmpl 0x4(%rbx), %esi
jg 0x2a80
orl %ecx, %esi
jns 0x2b37
jmp 0x2a80
movss (%rax,%r14,8), %xmm0
ucomiss 0x1571(%rip), %xmm0     # 0x4038
jbe 0x2aea
movl 0x4(%rbx), %r8d
movq %rbx, %rdi
xorl %esi, %esi
xorl %edx, %edx
jmp 0x2af5
movl 0x4(%rbx), %ecx
movq %rbx, %rdi
xorl %esi, %esi
movl %ecx, %r8d
callq 0x2718
incl %ebp
jmp 0x2afc
movl 0x4(%rbx), %r8d
xorl %ebp, %ebp
movq %rbx, %rdi
movl %edx, %esi
xorl %ecx, %ecx
callq 0x2718
xorps %xmm0, %xmm0
cvtsi2ss %eax, %xmm0
movq %rax, %rcx
shrq $0x20, %rcx
movq 0x2740(%rbx), %rdx
movq (%rdx,%r14,8), %rdx
movss %xmm0, (%rdx)
xorps %xmm0, %xmm0
cvtsi2ss %ecx, %xmm0
movss %xmm0, 0x4(%rdx)
movq 0x2738(%rbx), %rdx
movw %ax, (%rdx,%r14,8)
movw %cx, 0x2(%rdx,%r14,8)
incq %r14
movl 0x8(%rbx), %eax
cmpq %rax, %r14
jb 0x2a06
addq $0x10, %rsp
popq %rbx
popq %r14
popq %rbp
retq