// File: /workspace/github_c_makefile_star2_O0/FredTheDino[P]Fog/src/engine/renderer/particle_system.cpp
// Function: Renderer::create_particle_system(unsigned int, unsigned int, Vec2)
ParticleSystem create_particle_system(u32 layer, u32 num_particles, Vec2 position) {
    ASSERT(num_particles > 1, "Too small particle system");
    Util::MemoryArena *arena = Util::request_arena();
    Particle *particles = arena->push<Particle>(num_particles);

    for (u32 i = 0; i < num_particles; i++) {
        particles[i].progress = 2.0;
    }
    ParticleSystem particle_system = {};
    particle_system.memory = arena;
    particle_system.num_sprites = 0;
    particle_system.layer = 1;
    particle_system.head = 1;
    particle_system.max_num_particles = num_particles;
    particle_system.particles = particles;
    particle_system.layer = layer;

    particle_system.relative = false;
    particle_system.keep_alive = false;
    particle_system.one_color = true;
    particle_system.one_alpha = false;
    particle_system.one_size = false;
    particle_system.drop_oldest = false;

    particle_system.num_sprites = 0;

    particle_system.position = position;

    particle_system.alive_time = {2, 2};
    particle_system.rotation = {0, 2 * PI};
    particle_system.angular_velocity = {0, 0};

    particle_system.spawn_size = {0.5, 1.0};
    particle_system.die_size = {0.0, 0.0};
    particle_system.progress_func_size = std_progress_func_f32;

    particle_system.width = {1.0, 1.0};
    particle_system.height = {1.0, 1.0};

    particle_system.position_x = {0.0, 0.0};
    particle_system.position_y = {0.0, 0.0};
    particle_system.velocity_dir = {PI / 2.0, PI / 2.0};
    particle_system.velocity = {3.0, 5.0};
    particle_system.damping = {0.90, 1.0};
    particle_system.acceleration_dir = {-PI / 2.0, -PI / 2.0};
    particle_system.acceleration = {0.0, 0.0};

    particle_system.spawn_red = {1.0, 1.0};
    particle_system.spawn_green = {1.0, 1.0};
    particle_system.spawn_blue = {1.0, 1.0};
    particle_system.spawn_alpha = {1.0, 1.0};

    particle_system.die_red = {};
    particle_system.die_green = {};
    particle_system.die_blue = {};
    particle_system.die_alpha = {};

    particle_system.progress_func_color = std_progress_func_vec4;

    return particle_system;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xf0, %rsp
movq %rdi, -0xe8(%rbp)
movq %rdi, -0xe0(%rbp)
movlpd %xmm0, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movl %edx, -0x10(%rbp)
cmpl $0x1, -0x10(%rbp)
seta %al
andb $0x1, %al
movzbl %al, %eax
cmpl $0x0, %eax
setne %al
andb $0x1, %al
leaq 0x16bf4(%rip), %rdi     # 0x463e3
movl $0xb4, %esi
leaq 0x16cdb(%rip), %rdx     # 0x464d6
movzbl %al, %ecx
callq 0xb210
xorl %edi, %edi
callq 0x10890
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rdi
movl -0x10(%rbp), %eax
movl %eax, %esi
callq 0x42280
movq %rax, -0x20(%rbp)
movl $0x0, -0x24(%rbp)
movl -0x24(%rbp), %eax
cmpl -0x10(%rbp), %eax
jae 0x2f857
movq -0x20(%rbp), %rax
movl -0x24(%rbp), %ecx
imulq $0x88, %rcx, %rcx
addq %rcx, %rax
movss 0x159b0(%rip), %xmm0    # 0x451f8
movss %xmm0, (%rax)
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x2f827
movq -0xe8(%rbp), %rdi
xorl %esi, %esi
movl $0x218, %edx            # imm = 0x218
callq 0x21c0
movq -0xe8(%rbp), %rcx
movq -0xe0(%rbp), %rax
movq $0x0, 0x118(%rcx)
movq -0x18(%rbp), %rdx
movq %rdx, 0x120(%rcx)
movl $0x0, (%rcx)
movl $0x1, 0x4(%rcx)
movl $0x1, 0x108(%rcx)
movl -0x10(%rbp), %edx
movl %edx, 0x110(%rcx)
movq -0x20(%rbp), %rdx
movq %rdx, 0x118(%rcx)
movl -0xc(%rbp), %edx
movl %edx, 0x4(%rcx)
movb $0x0, 0x128(%rcx)
movb $0x0, 0x129(%rcx)
movb $0x1, 0x12a(%rcx)
movb $0x0, 0x12b(%rcx)
movb $0x0, 0x12c(%rcx)
movb $0x0, 0x12d(%rcx)
movl $0x0, (%rcx)
movq -0x8(%rbp), %rdx
movq %rdx, 0x130(%rcx)
movss 0x158f6(%rip), %xmm0    # 0x451f8
movss %xmm0, -0x2c(%rbp)
movss 0x158e9(%rip), %xmm0    # 0x451f8
movss %xmm0, -0x28(%rbp)
movq -0x2c(%rbp), %rdx
movq %rdx, 0x138(%rcx)
xorps %xmm0, %xmm0
movss %xmm0, -0x34(%rbp)
movss 0x15901(%rip), %xmm0    # 0x45230
movss %xmm0, -0x30(%rbp)
movq -0x34(%rbp), %rdx
movq %rdx, 0x140(%rcx)
xorps %xmm0, %xmm0
movss %xmm0, -0x3c(%rbp)
xorps %xmm0, %xmm0
movss %xmm0, -0x38(%rbp)
movq -0x3c(%rbp), %rdx
movq %rdx, 0x148(%rcx)
movss 0x156ae(%rip), %xmm0    # 0x45010
movss %xmm0, -0x44(%rbp)
movss 0x15699(%rip), %xmm0    # 0x45008
movss %xmm0, -0x40(%rbp)
movq -0x44(%rbp), %rdx
movq %rdx, 0x188(%rcx)
xorps %xmm0, %xmm0
movss %xmm0, -0x4c(%rbp)
xorps %xmm0, %xmm0
movss %xmm0, -0x48(%rbp)
movq -0x4c(%rbp), %rdx
movq %rdx, 0x198(%rcx)
leaq -0x21b31(%rip), %rdx    # 0xde70
movq %rdx, 0x208(%rcx)
movss 0x15658(%rip), %xmm0    # 0x45008
movss %xmm0, -0x54(%rbp)
movss 0x1564b(%rip), %xmm0    # 0x45008
movss %xmm0, -0x50(%rbp)
movq -0x54(%rbp), %rdx
movq %rdx, 0x1a8(%rcx)
movss 0x15633(%rip), %xmm0    # 0x45008
movss %xmm0, -0x5c(%rbp)
movss 0x15626(%rip), %xmm0    # 0x45008
movss %xmm0, -0x58(%rbp)
movq -0x5c(%rbp), %rdx
movq %rdx, 0x1b0(%rcx)
xorps %xmm0, %xmm0
movss %xmm0, -0x64(%rbp)
xorps %xmm0, %xmm0
movss %xmm0, -0x60(%rbp)
movq -0x64(%rbp), %rdx
movq %rdx, 0x150(%rcx)
xorps %xmm0, %xmm0
movss %xmm0, -0x6c(%rbp)
xorps %xmm0, %xmm0
movss %xmm0, -0x68(%rbp)
movq -0x6c(%rbp), %rdx
movq %rdx, 0x158(%rcx)
movss 0x157fc(%rip), %xmm0    # 0x4522c
movss %xmm0, -0x74(%rbp)
movss 0x157ef(%rip), %xmm0    # 0x4522c
movss %xmm0, -0x70(%rbp)
movq -0x74(%rbp), %rdx
movq %rdx, 0x160(%rcx)
movss 0x157a7(%rip), %xmm0    # 0x451fc
movss %xmm0, -0x7c(%rbp)
movss 0x155b2(%rip), %xmm0    # 0x45014
movss %xmm0, -0x78(%rbp)
movq -0x7c(%rbp), %rdx
movq %rdx, 0x168(%rcx)
movss 0x157ae(%rip), %xmm0    # 0x45228
movss %xmm0, -0x84(%rbp)
movss 0x1557e(%rip), %xmm0    # 0x45008
movss %xmm0, -0x80(%rbp)
movq -0x84(%rbp), %rdx
movq %rdx, 0x170(%rcx)
movss 0x1577f(%rip), %xmm0    # 0x45224
movss %xmm0, -0x8c(%rbp)
movss 0x1576f(%rip), %xmm0    # 0x45224
movss %xmm0, -0x88(%rbp)
movq -0x8c(%rbp), %rdx
movq %rdx, 0x178(%rcx)
xorps %xmm0, %xmm0
movss %xmm0, -0x94(%rbp)
xorps %xmm0, %xmm0
movss %xmm0, -0x90(%rbp)
movq -0x94(%rbp), %rdx
movq %rdx, 0x180(%rcx)
movss 0x15511(%rip), %xmm0    # 0x45008
movss %xmm0, -0x9c(%rbp)
movss 0x15501(%rip), %xmm0    # 0x45008
movss %xmm0, -0x98(%rbp)
movq -0x9c(%rbp), %rdx
movq %rdx, 0x1b8(%rcx)
movss 0x154e3(%rip), %xmm0    # 0x45008
movss %xmm0, -0xa4(%rbp)
movss 0x154d3(%rip), %xmm0    # 0x45008
movss %xmm0, -0xa0(%rbp)
movq -0xa4(%rbp), %rdx
movq %rdx, 0x1c0(%rcx)
movss 0x154b5(%rip), %xmm0    # 0x45008
movss %xmm0, -0xac(%rbp)
movss 0x154a5(%rip), %xmm0    # 0x45008
movss %xmm0, -0xa8(%rbp)
movq -0xac(%rbp), %rdx
movq %rdx, 0x1c8(%rcx)
movss 0x15487(%rip), %xmm0    # 0x45008
movss %xmm0, -0xb4(%rbp)
movss 0x15477(%rip), %xmm0    # 0x45008
movss %xmm0, -0xb0(%rbp)
movq -0xb4(%rbp), %rdx
movq %rdx, 0x1d0(%rcx)
xorps %xmm0, %xmm0
movss %xmm0, -0xbc(%rbp)
xorps %xmm0, %xmm0
movss %xmm0, -0xb8(%rbp)
movq -0xbc(%rbp), %rdx
movq %rdx, 0x1e0(%rcx)
xorps %xmm0, %xmm0
movss %xmm0, -0xc4(%rbp)
xorps %xmm0, %xmm0
movss %xmm0, -0xc0(%rbp)
movq -0xc4(%rbp), %rdx
movq %rdx, 0x1e8(%rcx)
xorps %xmm0, %xmm0
movss %xmm0, -0xcc(%rbp)
xorps %xmm0, %xmm0
movss %xmm0, -0xc8(%rbp)
movq -0xcc(%rbp), %rdx
movq %rdx, 0x1f0(%rcx)
xorps %xmm0, %xmm0
movss %xmm0, -0xd4(%rbp)
xorps %xmm0, %xmm0
movss %xmm0, -0xd0(%rbp)
movq -0xd4(%rbp), %rdx
movq %rdx, 0x1f8(%rcx)
leaq -0x21c9e(%rip), %rdx    # 0xdfa0
movq %rdx, 0x210(%rcx)
addq $0xf0, %rsp
popq %rbp
retq
nop