---
source: framec/tests/c_snapshots.rs
expression: "compile_fixture(\"01_linear_fsm\", \"c\")"
---
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <stdbool.h>
#include <stdint.h>

// ============================================================================
// LinearFsm_FrameDict - String-keyed dictionary
// ============================================================================

typedef struct LinearFsm_FrameDictEntry {
    char* key;
    void* value;
    struct LinearFsm_FrameDictEntry* next;
} LinearFsm_FrameDictEntry;

typedef struct {
    LinearFsm_FrameDictEntry** buckets;
    int bucket_count;
    int size;
} LinearFsm_FrameDict;

static unsigned int LinearFsm_hash_string(const char* str) {
    unsigned int hash = 5381;
    int c;
    while ((c = *str++)) {
        hash = ((hash << 5) + hash) + c;
    }
    return hash;
}

static LinearFsm_FrameDict* LinearFsm_FrameDict_new(void) {
    LinearFsm_FrameDict* d = malloc(sizeof(LinearFsm_FrameDict));
    d->bucket_count = 16;
    d->buckets = calloc(d->bucket_count, sizeof(LinearFsm_FrameDictEntry*));
    d->size = 0;
    return d;
}

static void LinearFsm_FrameDict_set(LinearFsm_FrameDict* d, const char* key, void* value) {
    unsigned int idx = LinearFsm_hash_string(key) % d->bucket_count;
    LinearFsm_FrameDictEntry* entry = d->buckets[idx];
    while (entry) {
        if (strcmp(entry->key, key) == 0) {
            entry->value = value;
            return;
        }
        entry = entry->next;
    }
    LinearFsm_FrameDictEntry* new_entry = malloc(sizeof(LinearFsm_FrameDictEntry));
    new_entry->key = strdup(key);
    new_entry->value = value;
    new_entry->next = d->buckets[idx];
    d->buckets[idx] = new_entry;
    d->size++;
}

static void* LinearFsm_FrameDict_get(LinearFsm_FrameDict* d, const char* key) {
    unsigned int idx = LinearFsm_hash_string(key) % d->bucket_count;
    LinearFsm_FrameDictEntry* entry = d->buckets[idx];
    while (entry) {
        if (strcmp(entry->key, key) == 0) {
            return entry->value;
        }
        entry = entry->next;
    }
    return NULL;
}

static int LinearFsm_FrameDict_has(LinearFsm_FrameDict* d, const char* key) {
    unsigned int idx = LinearFsm_hash_string(key) % d->bucket_count;
    LinearFsm_FrameDictEntry* entry = d->buckets[idx];
    while (entry) {
        if (strcmp(entry->key, key) == 0) {
            return 1;
        }
        entry = entry->next;
    }
    return 0;
}

static LinearFsm_FrameDict* LinearFsm_FrameDict_copy(LinearFsm_FrameDict* src) {
    LinearFsm_FrameDict* dst = LinearFsm_FrameDict_new();
    for (int i = 0; i < src->bucket_count; i++) {
        LinearFsm_FrameDictEntry* entry = src->buckets[i];
        while (entry) {
            LinearFsm_FrameDict_set(dst, entry->key, entry->value);
            entry = entry->next;
        }
    }
    return dst;
}

static void LinearFsm_FrameDict_destroy(LinearFsm_FrameDict* d) {
    for (int i = 0; i < d->bucket_count; i++) {
        LinearFsm_FrameDictEntry* entry = d->buckets[i];
        while (entry) {
            LinearFsm_FrameDictEntry* next = entry->next;
            free(entry->key);
            free(entry);
            entry = next;
        }
    }
    free(d->buckets);
    free(d);
}

// ============================================================================
// LinearFsm_FrameVec - Dynamic array
// ============================================================================

typedef struct {
    void** items;
    int size;
    int capacity;
} LinearFsm_FrameVec;

static LinearFsm_FrameVec* LinearFsm_FrameVec_new(void) {
    LinearFsm_FrameVec* v = malloc(sizeof(LinearFsm_FrameVec));
    v->capacity = 8;
    v->size = 0;
    v->items = malloc(sizeof(void*) * v->capacity);
    return v;
}

static void LinearFsm_FrameVec_push(LinearFsm_FrameVec* v, void* item) {
    if (v->size >= v->capacity) {
        v->capacity *= 2;
        v->items = realloc(v->items, sizeof(void*) * v->capacity);
    }
    v->items[v->size++] = item;
}

static void* LinearFsm_FrameVec_pop(LinearFsm_FrameVec* v) {
    if (v->size == 0) return NULL;
    return v->items[--v->size];
}

static void* LinearFsm_FrameVec_last(LinearFsm_FrameVec* v) {
    if (v->size == 0) return NULL;
    return v->items[v->size - 1];
}

static void* LinearFsm_FrameVec_get(LinearFsm_FrameVec* v, int index) {
    if (index < 0 || index >= v->size) return NULL;
    return v->items[index];
}

static int LinearFsm_FrameVec_size(LinearFsm_FrameVec* v) {
    return v->size;
}

static void LinearFsm_FrameVec_destroy(LinearFsm_FrameVec* v) {
    if (!v) return;
    free(v->items);
    free(v);
}

static LinearFsm_FrameVec* LinearFsm_FrameVec_copy(LinearFsm_FrameVec* src) {
    if (!src) return NULL;
    LinearFsm_FrameVec* v = LinearFsm_FrameVec_new();
    for (int i = 0; i < src->size; i++) {
        LinearFsm_FrameVec_push(v, src->items[i]);
    }
    return v;
}

// ============================================================================
// LinearFsm_pack_double / LinearFsm_unpack_double — bit-pun doubles through void*
// ============================================================================

static inline void* LinearFsm_pack_double(double v) {
    void* p = 0;
    memcpy(&p, &v, sizeof(double));
    return p;
}

static inline double LinearFsm_unpack_double(void* p) {
    double d;
    memcpy(&d, &p, sizeof(double));
    return d;
}

// ============================================================================
// LinearFsm_FrameEvent - Event routing object
// ============================================================================

typedef struct {
    const char* _message;
    LinearFsm_FrameVec* _parameters;
    int _owns_parameters;
} LinearFsm_FrameEvent;

static LinearFsm_FrameEvent* LinearFsm_FrameEvent_new(const char* message, LinearFsm_FrameVec* parameters, int owns_parameters) {
    LinearFsm_FrameEvent* e = malloc(sizeof(LinearFsm_FrameEvent));
    e->_message = message;
    e->_parameters = parameters;
    e->_owns_parameters = owns_parameters;
    return e;
}

static void LinearFsm_FrameEvent_destroy(LinearFsm_FrameEvent* e) {
    if (e->_owns_parameters && e->_parameters) LinearFsm_FrameVec_destroy(e->_parameters);
    free(e);
}

// ============================================================================
// LinearFsm_FrameContext - Interface call context
// ============================================================================

typedef struct {
    LinearFsm_FrameEvent* event;
    void* _return;
    LinearFsm_FrameDict* _data;
    int _transitioned;
} LinearFsm_FrameContext;

static LinearFsm_FrameContext* LinearFsm_FrameContext_new(LinearFsm_FrameEvent* event, void* default_return) {
    LinearFsm_FrameContext* ctx = malloc(sizeof(LinearFsm_FrameContext));
    ctx->event = event;
    ctx->_return = default_return;
    ctx->_data = LinearFsm_FrameDict_new();
    ctx->_transitioned = 0;
    return ctx;
}

static void LinearFsm_FrameContext_destroy(LinearFsm_FrameContext* ctx) {
    LinearFsm_FrameDict_destroy(ctx->_data);
    free(ctx);
}

// ============================================================================
// LinearFsm_Compartment - State closure
// ============================================================================

typedef struct LinearFsm_Compartment {
    const char* state;
    LinearFsm_FrameVec* state_args;
    LinearFsm_FrameDict* state_vars;
    LinearFsm_FrameVec* enter_args;
    LinearFsm_FrameVec* exit_args;
    LinearFsm_FrameEvent* forward_event;
    struct LinearFsm_Compartment* parent_compartment;
    int _ref_count;
} LinearFsm_Compartment;

static LinearFsm_Compartment* LinearFsm_Compartment_new(const char* state) {
    LinearFsm_Compartment* c = malloc(sizeof(LinearFsm_Compartment));
    c->state = state;
    c->state_args = LinearFsm_FrameVec_new();
    c->state_vars = LinearFsm_FrameDict_new();
    c->enter_args = LinearFsm_FrameVec_new();
    c->exit_args = LinearFsm_FrameVec_new();
    c->forward_event = NULL;
    c->parent_compartment = NULL;
    c->_ref_count = 1;
    return c;
}

static LinearFsm_Compartment* LinearFsm_Compartment_ref(LinearFsm_Compartment* c) {
    if (c) c->_ref_count++;
    return c;
}

static void LinearFsm_Compartment_unref(LinearFsm_Compartment* c);
static void LinearFsm_Compartment_unref(LinearFsm_Compartment* c) {
    if (c == NULL) return;
    c->_ref_count--;
    if (c->_ref_count <= 0) {
        LinearFsm_Compartment_unref(c->parent_compartment);
        LinearFsm_FrameVec_destroy(c->state_args);
        LinearFsm_FrameDict_destroy(c->state_vars);
        LinearFsm_FrameVec_destroy(c->enter_args);
        LinearFsm_FrameVec_destroy(c->exit_args);
        free(c);
    }
}

static LinearFsm_Compartment* LinearFsm_Compartment_copy(LinearFsm_Compartment* src) {
    LinearFsm_Compartment* c = malloc(sizeof(LinearFsm_Compartment));
    c->state = src->state;
    c->state_args = LinearFsm_FrameVec_copy(src->state_args);
    c->state_vars = LinearFsm_FrameDict_copy(src->state_vars);
    c->enter_args = LinearFsm_FrameVec_copy(src->enter_args);
    c->exit_args = LinearFsm_FrameVec_copy(src->exit_args);
    c->forward_event = src->forward_event;  // Shallow copy OK
    c->parent_compartment = src->parent_compartment;
    return c;
}

static void LinearFsm_Compartment_destroy(LinearFsm_Compartment* c) {
    LinearFsm_FrameVec_destroy(c->state_args);
    LinearFsm_FrameDict_destroy(c->state_vars);
    LinearFsm_FrameVec_destroy(c->enter_args);
    LinearFsm_FrameVec_destroy(c->exit_args);
    free(c);
}

// Helper macros for context access
#define LinearFsm_CTX(self) ((LinearFsm_FrameContext*)LinearFsm_FrameVec_last((self)->_context_stack))
#define LinearFsm_PARAM(self, key) LinearFsm_FrameDict_get(LinearFsm_CTX(self)->event->_parameters, key)
#define LinearFsm_RETURN(self) LinearFsm_CTX(self)->_return
#define LinearFsm_DATA(self, key) LinearFsm_FrameDict_get(LinearFsm_CTX(self)->_data, key)
#define LinearFsm_DATA_SET(self, key, val) LinearFsm_FrameDict_set(LinearFsm_CTX(self)->_data, key, val)

// Forward declarations
typedef struct LinearFsm LinearFsm;
static void LinearFsm_kernel(LinearFsm* self, LinearFsm_FrameEvent* __e);
static void LinearFsm_router(LinearFsm* self, LinearFsm_FrameEvent* __e);
static void LinearFsm_transition(LinearFsm* self, LinearFsm_Compartment* next);
static int LinearFsm_hsm_chain(LinearFsm* self, const char* leaf, const char*** out_chain);
static LinearFsm_Compartment* LinearFsm_prepareEnter(LinearFsm* self, const char* leaf, LinearFsm_FrameVec* state_args, LinearFsm_FrameVec* enter_args);
static void LinearFsm_prepareExit(LinearFsm* self, LinearFsm_FrameVec* exit_args);
static void LinearFsm_state_Idle(LinearFsm* self, LinearFsm_FrameEvent* __e, LinearFsm_Compartment* compartment);
static void LinearFsm_state_Active(LinearFsm* self, LinearFsm_FrameEvent* __e, LinearFsm_Compartment* compartment);
static void LinearFsm_state_Done(LinearFsm* self, LinearFsm_FrameEvent* __e, LinearFsm_Compartment* compartment);
static void LinearFsm_s_Idle_hdl_user_start(LinearFsm* self, LinearFsm_FrameEvent* __e, LinearFsm_Compartment* compartment);
static void LinearFsm_s_Active_hdl_user_finish(LinearFsm* self, LinearFsm_FrameEvent* __e, LinearFsm_Compartment* compartment);
static void LinearFsm_s_Active_hdl_user_progress(LinearFsm* self, LinearFsm_FrameEvent* __e, LinearFsm_Compartment* compartment);
void LinearFsm_start (LinearFsm* self);
void LinearFsm_progress (LinearFsm* self, int amount);
void LinearFsm_finish (LinearFsm* self);

struct LinearFsm {
    LinearFsm_FrameVec* _state_stack;
    LinearFsm_Compartment* __compartment;
    LinearFsm_Compartment* __next_compartment;
    LinearFsm_FrameVec* _context_stack;
    int total;
};

LinearFsm* LinearFsm_new(void) {
    LinearFsm* self = calloc(1, sizeof(LinearFsm));
    self->_state_stack = LinearFsm_FrameVec_new();
    self->_context_stack = LinearFsm_FrameVec_new();
    self->total = 0;
    LinearFsm_FrameVec* __sa = NULL;
    LinearFsm_FrameVec* __ea = NULL;
    self->__compartment = LinearFsm_prepareEnter(self, "Idle", __sa, __ea);
    self->__next_compartment = NULL;
    LinearFsm_FrameEvent* __e = LinearFsm_FrameEvent_new("$>", self->__compartment->enter_args, 0);
    LinearFsm_FrameContext* __ctx = LinearFsm_FrameContext_new(__e, NULL);
    LinearFsm_FrameVec_push(self->_context_stack, __ctx);
    LinearFsm_FrameContext* __init_ctx = (LinearFsm_FrameContext*)LinearFsm_FrameVec_pop(self->_context_stack);
    LinearFsm_FrameContext_destroy(__init_ctx);
    LinearFsm_FrameEvent_destroy(__e);
    return self;
}

LinearFsm* LinearFsm_create(void) {
    LinearFsm* self = LinearFsm_new();
    self->_state_stack = LinearFsm_FrameVec_new();
    self->_context_stack = LinearFsm_FrameVec_new();
    self->total = 0;
    LinearFsm_FrameVec* __sa = NULL;
    LinearFsm_FrameVec* __ea = NULL;
    self->__compartment = LinearFsm_prepareEnter(self, "Idle", __sa, __ea);
    self->__next_compartment = NULL;
    LinearFsm_FrameEvent* __e = LinearFsm_FrameEvent_new("$>", self->__compartment->enter_args, 0);
    LinearFsm_FrameContext* __ctx = LinearFsm_FrameContext_new(__e, NULL);
    LinearFsm_FrameVec_push(self->_context_stack, __ctx);
    LinearFsm_kernel(self, __e);
    LinearFsm_FrameContext* __init_ctx = (LinearFsm_FrameContext*)LinearFsm_FrameVec_pop(self->_context_stack);
    LinearFsm_FrameContext_destroy(__init_ctx);
    LinearFsm_FrameEvent_destroy(__e);
    return self;
}

static int LinearFsm_hsm_chain(LinearFsm* self, const char* leaf, const char*** out_chain) {
    if (false) { (void)0; }
        else if (strcmp(leaf, "Idle") == 0) {
            static const char* __chain[] = { "Idle" };
            *out_chain = __chain;
            return 1;
        }
        else if (strcmp(leaf, "Active") == 0) {
            static const char* __chain[] = { "Active" };
            *out_chain = __chain;
            return 1;
        }
        else if (strcmp(leaf, "Done") == 0) {
            static const char* __chain[] = { "Done" };
            *out_chain = __chain;
            return 1;
        }
        *out_chain = NULL;
        return 0;
}

static LinearFsm_Compartment* LinearFsm_prepareEnter(LinearFsm* self, const char* leaf, LinearFsm_FrameVec* state_args, LinearFsm_FrameVec* enter_args) {
    const char** chain = NULL;
    int n = LinearFsm_hsm_chain(self, leaf, &chain);
    LinearFsm_Compartment* comp = NULL;
    for (int i = 0; i < n; i++) {
        LinearFsm_Compartment* nc = LinearFsm_Compartment_new(chain[i]);
        if (state_args) {
            for (int j = 0; j < state_args->size; j++) LinearFsm_FrameVec_push(nc->state_args, state_args->items[j]);
        }
        if (enter_args) {
            for (int j = 0; j < enter_args->size; j++) LinearFsm_FrameVec_push(nc->enter_args, enter_args->items[j]);
        }
        nc->parent_compartment = comp;  // adopts ref
        comp = nc;
    }
    return comp;
}

static void LinearFsm_prepareExit(LinearFsm* self, LinearFsm_FrameVec* exit_args) {
    LinearFsm_Compartment* comp = self->__compartment;
    while (comp != NULL) {
        // Clear any prior exit_args before copying the new ones in.
        while (comp->exit_args->size > 0) comp->exit_args->size--;
        if (exit_args) {
            for (int j = 0; j < exit_args->size; j++) LinearFsm_FrameVec_push(comp->exit_args, exit_args->items[j]);
        }
        comp = comp->parent_compartment;
    }
}

static void LinearFsm_kernel(LinearFsm* self, LinearFsm_FrameEvent* __e) {
    LinearFsm_router(self, __e);
    while (self->__next_compartment != NULL) {
        LinearFsm_Compartment* next_compartment = self->__next_compartment;
        self->__next_compartment = NULL;
        // Exit the current (leaf) state
        LinearFsm_FrameEvent* __exit_event = LinearFsm_FrameEvent_new("<$", self->__compartment->exit_args, 0);
        LinearFsm_router(self, __exit_event);
        LinearFsm_FrameEvent_destroy(__exit_event);
        LinearFsm_Compartment_unref(self->__compartment);
        self->__compartment = next_compartment;
        if (next_compartment->forward_event == NULL) {
            // No forwarded event — synthesize a fresh $>
            LinearFsm_FrameEvent* __enter_event = LinearFsm_FrameEvent_new("$>", self->__compartment->enter_args, 0);
            LinearFsm_router(self, __enter_event);
            LinearFsm_FrameEvent_destroy(__enter_event);
        } else if (strcmp(next_compartment->forward_event->_message, "$>") == 0) {
            // Forwarded event IS $> — dispatch directly so the
            // destination's $> handler receives the caller's payload.
            // The forward_event is borrowed (owned by the wrapper that
            // queued the transition) — do NOT destroy it here.
            LinearFsm_FrameEvent* forward_event = next_compartment->forward_event;
            next_compartment->forward_event = NULL;
            LinearFsm_router(self, forward_event);
        } else {
            // Forwarded event is not $> — initialize the destination
            // with a fresh $>, then dispatch the forward to it. The
            // forward_event is borrowed; only the synthesized $> belongs
            // to the kernel and is freed here.
            LinearFsm_FrameEvent* forward_event = next_compartment->forward_event;
            next_compartment->forward_event = NULL;
            LinearFsm_FrameEvent* __enter_event = LinearFsm_FrameEvent_new("$>", self->__compartment->enter_args, 0);
            LinearFsm_router(self, __enter_event);
            LinearFsm_FrameEvent_destroy(__enter_event);
            LinearFsm_router(self, forward_event);
        }
        // Mark every stacked context as having transitioned. Read by
        // @@:self.X() guard so outer self-calls short-circuit.
        for (int __i = 0; __i < self->_context_stack->size; __i++) {
            ((LinearFsm_FrameContext*)self->_context_stack->items[__i])->_transitioned = 1;
        }
    }
}

static void LinearFsm_router(LinearFsm* self, LinearFsm_FrameEvent* __e) {
    if (strcmp(self->__compartment->state, "Idle") == 0) {
        LinearFsm_state_Idle(self, __e, self->__compartment);
    } else if (strcmp(self->__compartment->state, "Active") == 0) {
        LinearFsm_state_Active(self, __e, self->__compartment);
    } else if (strcmp(self->__compartment->state, "Done") == 0) {
        LinearFsm_state_Done(self, __e, self->__compartment);
    }
}

static void LinearFsm_transition(LinearFsm* self, LinearFsm_Compartment* next_compartment) {
    self->__next_compartment = next_compartment;
}

void LinearFsm_destroy(LinearFsm* self) {
    // Unref current compartment (may free if not on stack)
    if (self->__compartment) LinearFsm_Compartment_unref(self->__compartment);
    if (self->__next_compartment) LinearFsm_Compartment_unref(self->__next_compartment);
    // Unref all state stack entries
    if (self->_state_stack) {
        for (int __i = 0; __i < self->_state_stack->size; __i++) {
            LinearFsm_Compartment_unref((LinearFsm_Compartment*)self->_state_stack->items[__i]);
        }
        LinearFsm_FrameVec_destroy(self->_state_stack);
    }
    if (self->_context_stack) LinearFsm_FrameVec_destroy(self->_context_stack);
    free(self);
}

void LinearFsm_start(LinearFsm* self) {
    LinearFsm_FrameEvent* __e = LinearFsm_FrameEvent_new("start", NULL, 0);
    LinearFsm_FrameContext* __ctx = LinearFsm_FrameContext_new(__e, NULL);
    LinearFsm_FrameVec_push(self->_context_stack, __ctx);
    LinearFsm_kernel(self, __e);
    LinearFsm_FrameContext* __result_ctx = (LinearFsm_FrameContext*)LinearFsm_FrameVec_pop(self->_context_stack);
    LinearFsm_FrameContext_destroy(__result_ctx);
    LinearFsm_FrameEvent_destroy(__e);
}

void LinearFsm_progress(LinearFsm* self, int amount) {
    LinearFsm_FrameVec* __params = LinearFsm_FrameVec_new();
    LinearFsm_FrameVec_push(__params, (void*)(intptr_t)amount);
    LinearFsm_FrameEvent* __e = LinearFsm_FrameEvent_new("progress", __params, 1);
    LinearFsm_FrameContext* __ctx = LinearFsm_FrameContext_new(__e, NULL);
    LinearFsm_FrameVec_push(self->_context_stack, __ctx);
    LinearFsm_kernel(self, __e);
    LinearFsm_FrameContext* __result_ctx = (LinearFsm_FrameContext*)LinearFsm_FrameVec_pop(self->_context_stack);
    LinearFsm_FrameContext_destroy(__result_ctx);
    LinearFsm_FrameEvent_destroy(__e);
}

void LinearFsm_finish(LinearFsm* self) {
    LinearFsm_FrameEvent* __e = LinearFsm_FrameEvent_new("finish", NULL, 0);
    LinearFsm_FrameContext* __ctx = LinearFsm_FrameContext_new(__e, NULL);
    LinearFsm_FrameVec_push(self->_context_stack, __ctx);
    LinearFsm_kernel(self, __e);
    LinearFsm_FrameContext* __result_ctx = (LinearFsm_FrameContext*)LinearFsm_FrameVec_pop(self->_context_stack);
    LinearFsm_FrameContext_destroy(__result_ctx);
    LinearFsm_FrameEvent_destroy(__e);
}

static void LinearFsm_state_Idle(LinearFsm* self, LinearFsm_FrameEvent* __e, LinearFsm_Compartment* compartment) {
    if (strcmp(__e->_message, "start") == 0) {
        LinearFsm_s_Idle_hdl_user_start(self, __e, compartment);
        return;
    }
}

static void LinearFsm_state_Active(LinearFsm* self, LinearFsm_FrameEvent* __e, LinearFsm_Compartment* compartment) {
    if (strcmp(__e->_message, "finish") == 0) {
        LinearFsm_s_Active_hdl_user_finish(self, __e, compartment);
        return;
    }
    if (strcmp(__e->_message, "progress") == 0) {
        LinearFsm_s_Active_hdl_user_progress(self, __e, compartment);
        return;
    }
}

static void LinearFsm_state_Done(LinearFsm* self, LinearFsm_FrameEvent* __e, LinearFsm_Compartment* compartment) {
}

static void LinearFsm_s_Idle_hdl_user_start(LinearFsm* self, LinearFsm_FrameEvent* __e, LinearFsm_Compartment* compartment) {
    {
        LinearFsm_FrameVec* __sa = NULL;
        LinearFsm_FrameVec* __ea = NULL;
        LinearFsm_Compartment* __compartment = LinearFsm_prepareEnter(self, "Active", __sa, __ea);
        LinearFsm_transition(self, __compartment);
    }
    return;
}

static void LinearFsm_s_Active_hdl_user_finish(LinearFsm* self, LinearFsm_FrameEvent* __e, LinearFsm_Compartment* compartment) {
    {
        LinearFsm_FrameVec* __sa = NULL;
        LinearFsm_FrameVec* __ea = NULL;
        LinearFsm_Compartment* __compartment = LinearFsm_prepareEnter(self, "Done", __sa, __ea);
        LinearFsm_transition(self, __compartment);
    }
    return;
}

static void LinearFsm_s_Active_hdl_user_progress(LinearFsm* self, LinearFsm_FrameEvent* __e, LinearFsm_Compartment* compartment) {
    int amount = (int)(intptr_t)LinearFsm_FrameVec_get(__e->_parameters, 0);
    (void)amount;
    self.total = self.total + amount
}
