// File: /workspace/github_c_makefile_star2_O2/FredTheDino[P]Fog/src/engine/renderer/particle_system.cpp
// Function: Renderer::ParticleSystemInt::generate()
Particle ParticleSystemInt::generate() {
    ASSERT(particles, "Trying to use uninitalized/destroyed particle system");

    f32 particle_spawn_size = spawn_size.random();
    f32 particle_spawn_size_deriv = spawn_size_deriv.random();
    f32 particle_die_size = one_size ? particle_spawn_size : die_size.random();
    f32 particle_die_size_deriv = die_size_deriv.random();

    Vec4 particle_spawn_color = V4(spawn_red.random(), spawn_green.random(),
            spawn_blue.random(), spawn_alpha.random());
    f32 particle_spawn_color_deriv = spawn_color_deriv.random();

    Vec4 particle_die_color;
    f32 particle_die_color_deriv;
    if (one_color) {
        particle_die_color = particle_spawn_color;
        particle_die_color_deriv = particle_spawn_color_deriv;
    } else {
        particle_die_color = V4(die_red.random(), die_green.random(),
                die_blue.random(), particle_spawn_color.w);
        particle_die_color_deriv = die_color_deriv.random();
    }

    if (!one_alpha) {
        particle_die_color.w = die_alpha.random();
    }
    return {
        0,
            1.0f / alive_time.random(),
            (b8) keep_alive,
            true,

            rotation.random(),
            angular_velocity.random(),

            position + V2(position_x.random(), position_y.random()),
            rotate(V2(1, 0), velocity_dir.random()) * velocity.random(),
            rotate(V2(1, 0), acceleration_dir.random()) * acceleration.random(),
            damping.random(),

            particle_spawn_size,
            particle_spawn_size_deriv,
            particle_die_size,
            particle_die_size_deriv,
            &progress_func_size,
            V2(width.random(), height.random()),

            particle_spawn_color,
            particle_spawn_color_deriv,
            particle_die_color,
            particle_die_color_deriv,
            &progress_func_color,
            (s16) (num_sprites ?  random_int() % num_sprites : -1),
    };
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
subq $0x70, %rsp
movq %rsi, %r14
movq %rdi, %rbx
xorl %ecx, %ecx
cmpq $0x0, 0x118(%rsi)
setne %cl
leaq 0xb9d8(%rip), %rdi      # 0x2c3eb
leaq 0xb9f9(%rip), %rdx      # 0x2c413
pushq $0x3e
popq %rsi
callq 0x6903
leaq 0x188(%r14), %rdi
callq 0x29ac0
movss %xmm0, -0x50(%rbp)
leaq 0x190(%r14), %rdi
callq 0x29ac0
movss %xmm0, -0x40(%rbp)
cmpb $0x0, 0x12c(%r14)
movss -0x50(%rbp), %xmm0
jne 0x20a5f
leaq 0x198(%r14), %rdi
callq 0x29ac0
movss %xmm0, -0x3c(%rbp)
leaq 0x1a0(%r14), %rdi
callq 0x29ac0
movss %xmm0, -0x38(%rbp)
leaq 0x1b8(%r14), %rdi
callq 0x29ac0
movaps %xmm0, -0x70(%rbp)
leaq 0x1c0(%r14), %rdi
callq 0x29ac0
movaps %xmm0, -0x30(%rbp)
leaq 0x1c8(%r14), %rdi
callq 0x29ac0
movaps %xmm0, -0x60(%rbp)
leaq 0x1d0(%r14), %rdi
callq 0x29ac0
movaps -0x70(%rbp), %xmm1
unpcklps -0x30(%rbp), %xmm1      # xmm1 = xmm1[0],mem[0],xmm1[1],mem[1]
movaps %xmm1, -0x70(%rbp)
movaps %xmm0, -0x80(%rbp)
movaps -0x60(%rbp), %xmm1
unpcklps %xmm0, %xmm1            # xmm1 = xmm1[0],xmm0[0],xmm1[1],xmm0[1]
movaps %xmm1, -0x60(%rbp)
leaq 0x1d8(%r14), %rdi
callq 0x29ac0
cmpb $0x0, 0x12a(%r14)
movss %xmm0, -0x34(%rbp)
movaps -0x70(%rbp), %xmm1
movaps %xmm1, -0x30(%rbp)
movaps -0x60(%rbp), %xmm1
jne 0x20b46
leaq 0x1e0(%r14), %rdi
callq 0x29ac0
movaps %xmm0, -0x30(%rbp)
leaq 0x1e8(%r14), %rdi
callq 0x29ac0
movaps %xmm0, -0x20(%rbp)
leaq 0x1f0(%r14), %rdi
callq 0x29ac0
movaps %xmm0, %xmm1
movaps -0x30(%rbp), %xmm0
unpcklps -0x20(%rbp), %xmm0      # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
movaps %xmm0, -0x30(%rbp)
unpcklps -0x80(%rbp), %xmm1      # xmm1 = xmm1[0],mem[0],xmm1[1],mem[1]
movaps %xmm1, -0x20(%rbp)
leaq 0x200(%r14), %rdi
callq 0x29ac0
movaps -0x20(%rbp), %xmm1
movss %xmm0, -0x80(%rbp)
cmpb $0x0, 0x12b(%r14)
jne 0x20b73
leaq 0x1f8(%r14), %rdi
movaps %xmm1, -0x20(%rbp)
callq 0x29ac0
movaps -0x20(%rbp), %xmm1
movlhps %xmm1, %xmm0            # xmm0 = xmm0[0],xmm1[0]
shufps $0xe2, %xmm1, %xmm0     # xmm0 = xmm0[2,0],xmm1[2,3]
movaps %xmm0, %xmm1
movaps -0x30(%rbp), %xmm0
movlhps %xmm1, %xmm0            # xmm0 = xmm0[0],xmm1[0]
movaps %xmm0, -0x30(%rbp)
andl $0x0, (%rbx)
leaq 0x138(%r14), %rdi
callq 0x29ac0
movss 0xa46f(%rip), %xmm1     # 0x2b004
divss %xmm0, %xmm1
movss %xmm1, 0x4(%rbx)
movb 0x129(%r14), %al
movb %al, 0x8(%rbx)
movb $0x1, 0x9(%rbx)
leaq 0x140(%r14), %rdi
callq 0x29ac0
movss %xmm0, 0xc(%rbx)
leaq 0x148(%r14), %rdi
callq 0x29ac0
movss %xmm0, 0x10(%rbx)
leaq 0x150(%r14), %rdi
callq 0x29ac0
movaps %xmm0, -0x20(%rbp)
leaq 0x158(%r14), %rdi
callq 0x29ac0
movaps -0x20(%rbp), %xmm1
addss 0x130(%r14), %xmm1
addss 0x134(%r14), %xmm0
unpcklps %xmm0, %xmm1            # xmm1 = xmm1[0],xmm0[0],xmm1[1],xmm0[1]
movlps %xmm1, 0x14(%rbx)
leaq 0x160(%r14), %rdi
callq 0x29ac0
movaps %xmm0, %xmm1
movss 0xa3e6(%rip), %xmm0     # 0x2b004
callq 0x6aaa
movaps %xmm0, -0x20(%rbp)
leaq 0x168(%r14), %rdi
callq 0x29ac0
movaps -0x20(%rbp), %xmm2
movaps %xmm2, %xmm1
mulss %xmm0, %xmm1
shufps $0x55, %xmm2, %xmm2     # xmm2 = xmm2[1,1,1,1]
mulss %xmm0, %xmm2
unpcklps %xmm2, %xmm1            # xmm1 = xmm1[0],xmm2[0],xmm1[1],xmm2[1]
movlps %xmm1, 0x1c(%rbx)
leaq 0x178(%r14), %rdi
callq 0x29ac0
movaps %xmm0, %xmm1
movss 0xa3a0(%rip), %xmm0     # 0x2b004
callq 0x6aaa
movaps %xmm0, -0x20(%rbp)
leaq 0x180(%r14), %rdi
callq 0x29ac0
movaps -0x20(%rbp), %xmm2
movaps %xmm2, %xmm1
mulss %xmm0, %xmm1
shufps $0x55, %xmm2, %xmm2     # xmm2 = xmm2[1,1,1,1]
mulss %xmm0, %xmm2
unpcklps %xmm2, %xmm1            # xmm1 = xmm1[0],xmm2[0],xmm1[1],xmm2[1]
movlps %xmm1, 0x24(%rbx)
leaq 0x170(%r14), %rdi
callq 0x29ac0
movss %xmm0, 0x2c(%rbx)
movss -0x50(%rbp), %xmm0
movss %xmm0, 0x30(%rbx)
movss -0x40(%rbp), %xmm0
movss %xmm0, 0x34(%rbx)
movss -0x3c(%rbp), %xmm0
movss %xmm0, 0x38(%rbx)
movss -0x38(%rbp), %xmm0
movss %xmm0, 0x3c(%rbx)
leaq 0x208(%r14), %rax
movq %rax, 0x40(%rbx)
leaq 0x1a8(%r14), %rdi
callq 0x29ac0
movaps %xmm0, -0x50(%rbp)
leaq 0x1b0(%r14), %rdi
callq 0x29ac0
movaps -0x50(%rbp), %xmm1
unpcklps %xmm0, %xmm1            # xmm1 = xmm1[0],xmm0[0],xmm1[1],xmm0[1]
movlps %xmm1, 0x48(%rbx)
movaps -0x70(%rbp), %xmm0
unpcklpd -0x60(%rbp), %xmm0      # xmm0 = xmm0[0],mem[0]
movups %xmm0, 0x50(%rbx)
movss -0x34(%rbp), %xmm0
movss %xmm0, 0x60(%rbx)
movaps -0x30(%rbp), %xmm0
movups %xmm0, 0x64(%rbx)
movss -0x80(%rbp), %xmm0
movss %xmm0, 0x74(%rbx)
leaq 0x210(%r14), %rax
movq %rax, 0x78(%rbx)
cmpl $0x0, (%r14)
je 0x20d44
callq 0x82e1
xorl %edx, %edx
divl (%r14)
jmp 0x20d48
movw $0xffff, %dx            # imm = 0xFFFF
movw %dx, 0x80(%rbx)
movq %rbx, %rax
addq $0x70, %rsp
popq %rbx
popq %r14
popq %rbp
retq