// File: /workspace/github_c_makefile_star2_O1/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 $0x80, %rsp
movq %rsi, %r14
movq %rdi, %rbx
xorl %ecx, %ecx
cmpq $0x0, 0x118(%rsi)
setne %cl
leaq 0xeb81(%rip), %rdi      # 0x31423
leaq 0xeba2(%rip), %rdx      # 0x3144b
movl $0x3e, %esi
callq 0x722f
movss 0x188(%r14), %xmm0
movss 0x18c(%r14), %xmm1
callq 0x91d7
movss %xmm0, -0x60(%rbp)
movss 0x190(%r14), %xmm0
movss 0x194(%r14), %xmm1
callq 0x91d7
movss %xmm0, -0x50(%rbp)
cmpb $0x0, 0x12c(%r14)
movss -0x60(%rbp), %xmm0
jne 0x22911
movss 0x198(%r14), %xmm0
movss 0x19c(%r14), %xmm1
callq 0x91d7
movss %xmm0, -0x4c(%rbp)
movss 0x1a0(%r14), %xmm0
movss 0x1a4(%r14), %xmm1
callq 0x91d7
movss %xmm0, -0x48(%rbp)
movss 0x1b8(%r14), %xmm0
movss 0x1bc(%r14), %xmm1
callq 0x91d7
movaps %xmm0, -0x80(%rbp)
movss 0x1c0(%r14), %xmm0
movss 0x1c4(%r14), %xmm1
callq 0x91d7
movaps %xmm0, -0x30(%rbp)
movss 0x1c8(%r14), %xmm0
movss 0x1cc(%r14), %xmm1
callq 0x91d7
movaps %xmm0, -0x70(%rbp)
movss 0x1d0(%r14), %xmm0
movss 0x1d4(%r14), %xmm1
callq 0x91d7
movaps -0x80(%rbp), %xmm1
unpcklps -0x30(%rbp), %xmm1      # xmm1 = xmm1[0],mem[0],xmm1[1],mem[1]
movaps %xmm1, -0x80(%rbp)
movaps %xmm0, -0x90(%rbp)
movaps -0x70(%rbp), %xmm1
unpcklps %xmm0, %xmm1            # xmm1 = xmm1[0],xmm0[0],xmm1[1],xmm0[1]
movaps %xmm1, -0x70(%rbp)
movss 0x1d8(%r14), %xmm0
movss 0x1dc(%r14), %xmm1
callq 0x91d7
cmpb $0x0, 0x12a(%r14)
movss %xmm0, -0x44(%rbp)
movaps -0x80(%rbp), %xmm1
movaps %xmm1, -0x30(%rbp)
movaps -0x70(%rbp), %xmm1
jne 0x22a70
movss 0x1e0(%r14), %xmm0
movss 0x1e4(%r14), %xmm1
callq 0x91d7
movaps %xmm0, -0x30(%rbp)
movss 0x1e8(%r14), %xmm0
movss 0x1ec(%r14), %xmm1
callq 0x91d7
movaps %xmm0, -0x20(%rbp)
movss 0x1f0(%r14), %xmm0
movss 0x1f4(%r14), %xmm1
callq 0x91d7
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 -0x90(%rbp), %xmm1      # xmm1 = xmm1[0],mem[0],xmm1[1],mem[1]
movaps %xmm1, -0x20(%rbp)
movss 0x200(%r14), %xmm0
movss 0x204(%r14), %xmm1
callq 0x91d7
movaps -0x20(%rbp), %xmm1
movss %xmm0, -0x90(%rbp)
cmpb $0x0, 0x12b(%r14)
jne 0x22aab
movss 0x1f8(%r14), %xmm0
movaps %xmm1, -0x20(%rbp)
movss 0x1fc(%r14), %xmm1
callq 0x91d7
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)
movl $0x0, (%rbx)
movss 0x138(%r14), %xmm0
movss 0x13c(%r14), %xmm1
callq 0x91d7
movss 0xd529(%rip), %xmm1     # 0x30004
divss %xmm0, %xmm1
movss %xmm1, 0x4(%rbx)
movb 0x129(%r14), %al
movb %al, 0x8(%rbx)
movb $0x1, 0x9(%rbx)
movss 0x140(%r14), %xmm0
movss 0x144(%r14), %xmm1
callq 0x91d7
movss %xmm0, 0xc(%rbx)
movss 0x148(%r14), %xmm0
movss 0x14c(%r14), %xmm1
callq 0x91d7
movss %xmm0, 0x10(%rbx)
movss 0x150(%r14), %xmm0
movss 0x154(%r14), %xmm1
callq 0x91d7
movaps %xmm0, -0x20(%rbp)
movss 0x158(%r14), %xmm0
movss 0x15c(%r14), %xmm1
callq 0x91d7
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)
movss 0x160(%r14), %xmm0
movss 0x164(%r14), %xmm1
callq 0x91d7
movss %xmm0, -0x20(%rbp)
callq 0x2050
movss %xmm0, -0x40(%rbp)
movss -0x20(%rbp), %xmm0
callq 0x2350
xorps %xmm1, %xmm1
movss -0x40(%rbp), %xmm4
movaps %xmm4, %xmm2
mulss %xmm1, %xmm2
movaps %xmm0, %xmm3
subss %xmm2, %xmm3
movaps %xmm3, -0x20(%rbp)
mulss %xmm1, %xmm0
addss %xmm4, %xmm0
movaps %xmm0, -0x40(%rbp)
movss 0x168(%r14), %xmm0
movss 0x16c(%r14), %xmm1
callq 0x91d7
movaps -0x20(%rbp), %xmm1
mulss %xmm0, %xmm1
movaps -0x40(%rbp), %xmm2
mulss %xmm0, %xmm2
unpcklps %xmm2, %xmm1            # xmm1 = xmm1[0],xmm2[0],xmm1[1],xmm2[1]
movlps %xmm1, 0x1c(%rbx)
movss 0x178(%r14), %xmm0
movss 0x17c(%r14), %xmm1
callq 0x91d7
movss %xmm0, -0x20(%rbp)
callq 0x2050
movss %xmm0, -0x40(%rbp)
movss -0x20(%rbp), %xmm0
callq 0x2350
movss -0x40(%rbp), %xmm4
movaps %xmm4, %xmm2
xorps %xmm1, %xmm1
mulss %xmm1, %xmm2
movaps %xmm0, %xmm3
subss %xmm2, %xmm3
movaps %xmm3, -0x20(%rbp)
mulss %xmm1, %xmm0
addss %xmm4, %xmm0
movaps %xmm0, -0x40(%rbp)
movss 0x180(%r14), %xmm0
movss 0x184(%r14), %xmm1
callq 0x91d7
movaps -0x20(%rbp), %xmm1
mulss %xmm0, %xmm1
movaps -0x40(%rbp), %xmm2
mulss %xmm0, %xmm2
unpcklps %xmm2, %xmm1            # xmm1 = xmm1[0],xmm2[0],xmm1[1],xmm2[1]
movlps %xmm1, 0x24(%rbx)
movss 0x170(%r14), %xmm0
movss 0x174(%r14), %xmm1
callq 0x91d7
movss %xmm0, 0x2c(%rbx)
movss -0x60(%rbp), %xmm0
movss %xmm0, 0x30(%rbx)
movss -0x50(%rbp), %xmm0
movss %xmm0, 0x34(%rbx)
movss -0x4c(%rbp), %xmm0
movss %xmm0, 0x38(%rbx)
movss -0x48(%rbp), %xmm0
movss %xmm0, 0x3c(%rbx)
leaq 0x208(%r14), %rax
movq %rax, 0x40(%rbx)
movss 0x1a8(%r14), %xmm0
movss 0x1ac(%r14), %xmm1
callq 0x91d7
movaps %xmm0, -0x60(%rbp)
movss 0x1b0(%r14), %xmm0
movss 0x1b4(%r14), %xmm1
callq 0x91d7
movaps -0x60(%rbp), %xmm1
unpcklps %xmm0, %xmm1            # xmm1 = xmm1[0],xmm0[0],xmm1[1],xmm0[1]
movlps %xmm1, 0x48(%rbx)
movaps -0x80(%rbp), %xmm0
unpcklpd -0x70(%rbp), %xmm0      # xmm0 = xmm0[0],mem[0]
movups %xmm0, 0x50(%rbx)
movss -0x44(%rbp), %xmm0
movss %xmm0, 0x60(%rbx)
movaps -0x30(%rbp), %xmm0
movups %xmm0, 0x64(%rbx)
movss -0x90(%rbp), %xmm0
movss %xmm0, 0x74(%rbx)
leaq 0x210(%r14), %rax
movq %rax, 0x78(%rbx)
movl (%r14), %ecx
testl %ecx, %ecx
je 0x22d92
leaq 0x2d092(%rip), %rax     # 0x4fde4
movl 0xc(%rax), %edx
movl (%rax), %esi
movq 0x4(%rax), %rdi
movq %rdi, 0x8(%rax)
movl %esi, 0x4(%rax)
movl %edx, %edi
shrl $0x2, %edi
xorl %edx, %edi
movl %esi, %edx
shll $0x4, %edx
xorl %esi, %edx
xorl %edi, %edx
addl %edi, %edi
xorl %edx, %edi
movl %edi, (%rax)
movl 0x10(%rax), %edx
leal 0x587c5(%rdx), %esi
movl %esi, 0x10(%rax)
leal (%rdx,%rdi), %eax
addl $0x587c5, %eax          # imm = 0x587C5
xorl %edx, %edx
divl %ecx
jmp 0x22d96
movw $0xffff, %dx            # imm = 0xFFFF
movw %dx, 0x80(%rbx)
movq %rbx, %rax
addq $0x80, %rsp
popq %rbx
popq %r14
popq %rbp
retq