/*
    DO NOT EDIT THIS FILE!
    This file was automatically generated by the bstruct generator.
*/

#include <stdint.h>

#include <misc/balign.h>


typedef struct str0_struct str0;

typedef struct {
    int x_off;
    int x_size;
    #ifndef NDEBUG
    int x_count;
    #endif

    int len;
    int align;
} str0Params;

static void str0Params_Init (str0Params *o, int n)
{
    int cur_size;
    int cur_align;
    int cur_count;

    o->len = 0;
    o->align = 1;

    cur_size = (sizeof(int));
    cur_align = (__alignof__(int));
    cur_count = (n);
    o->x_off = BALIGN_UP_N(o->len, cur_align);
    o->x_size = cur_size;
    #ifndef NDEBUG
    o->x_count = cur_count;
    #endif
    o->len = o->x_off + (cur_count * cur_size);
    o->align = (cur_align > o->align ? cur_align : o->align);

}

static int * str0_x (str0Params *o, str0 *s)
{
    return (int *)((uint8_t *)s + o->x_off);
}

static int * str0_x_at (str0Params *o, str0 *s, int i)
{
    ASSERT(i >= 0)
    ASSERT(i < o->x_count)

    return (int *)((uint8_t *)s + o->x_off + i * o->x_size);
}

typedef struct str1_struct str1;

typedef struct {
    int a_off;
    int a_size;
    #ifndef NDEBUG
    int a_count;
    #endif

    int b_off;
    int b_size;
    #ifndef NDEBUG
    int b_count;
    #endif

    int c_off;
    int c_size;
    #ifndef NDEBUG
    int c_count;
    #endif

    str0Params d_params;
    int d_off;
    int d_size;
    #ifndef NDEBUG
    int d_count;
    #endif

    int len;
    int align;
} str1Params;

static void str1Params_Init (str1Params *o, int nb, int nc, int m)
{
    int cur_size;
    int cur_align;
    int cur_count;

    o->len = 0;
    o->align = 1;

    cur_size = (sizeof(int));
    cur_align = (__alignof__(int));
    cur_count = (1);
    o->a_off = BALIGN_UP_N(o->len, cur_align);
    o->a_size = cur_size;
    #ifndef NDEBUG
    o->a_count = cur_count;
    #endif
    o->len = o->a_off + (cur_count * cur_size);
    o->align = (cur_align > o->align ? cur_align : o->align);

    cur_size = (sizeof(char));
    cur_align = (__alignof__(char));
    cur_count = (nb);
    o->b_off = BALIGN_UP_N(o->len, cur_align);
    o->b_size = cur_size;
    #ifndef NDEBUG
    o->b_count = cur_count;
    #endif
    o->len = o->b_off + (cur_count * cur_size);
    o->align = (cur_align > o->align ? cur_align : o->align);

    cur_size = (sizeof(double));
    cur_align = (__alignof__(double));
    cur_count = (nc);
    o->c_off = BALIGN_UP_N(o->len, cur_align);
    o->c_size = cur_size;
    #ifndef NDEBUG
    o->c_count = cur_count;
    #endif
    o->len = o->c_off + (cur_count * cur_size);
    o->align = (cur_align > o->align ? cur_align : o->align);

    str0Params_Init(&o->d_params, m);
    cur_size = o->d_params.len;
    cur_align = o->d_params.align;
    cur_count = (1);
    o->d_off = BALIGN_UP_N(o->len, cur_align);
    o->d_size = cur_size;
    #ifndef NDEBUG
    o->d_count = cur_count;
    #endif
    o->len = o->d_off + (cur_count * cur_size);
    o->align = (cur_align > o->align ? cur_align : o->align);

}

static int * str1_a (str1Params *o, str1 *s)
{
    return (int *)((uint8_t *)s + o->a_off);
}

static int * str1_a_at (str1Params *o, str1 *s, int i)
{
    ASSERT(i >= 0)
    ASSERT(i < o->a_count)

    return (int *)((uint8_t *)s + o->a_off + i * o->a_size);
}

static char * str1_b (str1Params *o, str1 *s)
{
    return (char *)((uint8_t *)s + o->b_off);
}

static char * str1_b_at (str1Params *o, str1 *s, int i)
{
    ASSERT(i >= 0)
    ASSERT(i < o->b_count)

    return (char *)((uint8_t *)s + o->b_off + i * o->b_size);
}

static double * str1_c (str1Params *o, str1 *s)
{
    return (double *)((uint8_t *)s + o->c_off);
}

static double * str1_c_at (str1Params *o, str1 *s, int i)
{
    ASSERT(i >= 0)
    ASSERT(i < o->c_count)

    return (double *)((uint8_t *)s + o->c_off + i * o->c_size);
}

static str0 * str1_d (str1Params *o, str1 *s)
{
    return (str0 *)((uint8_t *)s + o->d_off);
}

static str0 * str1_d_at (str1Params *o, str1 *s, int i)
{
    ASSERT(i >= 0)
    ASSERT(i < o->d_count)

    return (str0 *)((uint8_t *)s + o->d_off + i * o->d_size);
}

