#include <iostream>
#include <string>
#include <vector>
#include <cassert>
#include <cmath>
#include <complex>
#include <Kokkos_Core.hpp>
#include <lfortran_intrinsics.h>

template <typename T>
Kokkos::View<T*> from_std_vector(const std::vector<T> &v)
{
    Kokkos::View<T*> r("r", v.size());
    for (size_t i=0; i < v.size(); i++) {
        r(i) = v[i];
    }
    return r;
}


struct dimension_descriptor
{
    int32_t lower_bound, length, stride;
};

struct f32_5_1
{
    Kokkos::View<float*>* data;
    dimension_descriptor dims[1];
    bool is_allocated;

    f32_5_1(Kokkos::View<float*>* data_): data{data_} {};
};


struct i32_3_1
{
    Kokkos::View<int32_t*>* data;
    dimension_descriptor dims[1];
    bool is_allocated;

    i32_3_1(Kokkos::View<int32_t*>* data_): data{data_} {};
};


struct f32_2_3_2
{
    Kokkos::View<float*>* data;
    dimension_descriptor dims[2];
    bool is_allocated;

    f32_2_3_2(Kokkos::View<float*>* data_): data{data_} {};
};


struct i32_3_4_2
{
    Kokkos::View<int32_t*>* data;
    dimension_descriptor dims[2];
    bool is_allocated;

    i32_3_4_2(Kokkos::View<int32_t*>* data_): data{data_} {};
};


struct f32_2_3_4_3
{
    Kokkos::View<float*>* data;
    dimension_descriptor dims[3];
    bool is_allocated;

    f32_2_3_4_3(Kokkos::View<float*>* data_): data{data_} {};
};


struct i32_3_4_3_3
{
    Kokkos::View<int32_t*>* data;
    dimension_descriptor dims[3];
    bool is_allocated;

    i32_3_4_3_3(Kokkos::View<int32_t*>* data_): data{data_} {};
};

// Forward declarations
namespace {
}

// Implementations
namespace {

void main2() {
    Kokkos::View<float*> a_data("a_data", 5);
    f32_5_1 a_value(&a_data);
    f32_5_1* a = &a_value;
    a->dims[0].lower_bound = 1;
    a->dims[0].length = 5;
    Kokkos::View<float*> b_data("b_data", 5);
    f32_5_1 b_value(&b_data);
    f32_5_1* b = &b_value;
    b->dims[0].lower_bound = 1;
    b->dims[0].length = 5;
    Kokkos::View<int32_t*> c_data("c_data", 3);
    i32_3_1 c_value(&c_data);
    i32_3_1* c = &c_value;
    c->dims[0].lower_bound = 1;
    c->dims[0].length = 3;
    Kokkos::View<bool[2]>& d;
    Kokkos::View<float*> e_data("e_data", 6);
    f32_2_3_2 e_value(&e_data);
    f32_2_3_2* e = &e_value;
    e->dims[0].lower_bound = 1;
    e->dims[0].length = 2;
    e->dims[1].lower_bound = 1;
    e->dims[1].length = 3;
    Kokkos::View<int32_t*> f_data("f_data", 12);
    i32_3_4_2 f_value(&f_data);
    i32_3_4_2* f = &f_value;
    f->dims[0].lower_bound = 1;
    f->dims[0].length = 3;
    f->dims[1].lower_bound = 1;
    f->dims[1].length = 4;
    Kokkos::View<bool[5][2]>& g;
    Kokkos::View<float*> h_data("h_data", 24);
    f32_2_3_4_3 h_value(&h_data);
    f32_2_3_4_3* h = &h_value;
    h->dims[0].lower_bound = 1;
    h->dims[0].length = 2;
    h->dims[1].lower_bound = 1;
    h->dims[1].length = 3;
    h->dims[2].lower_bound = 1;
    h->dims[2].length = 4;
    Kokkos::View<int32_t*> i_data("i_data", 36);
    i32_3_4_3_3 i_value(&i_data);
    i32_3_4_3_3* i = &i_value;
    i->dims[0].lower_bound = 1;
    i->dims[0].length = 3;
    i->dims[1].lower_bound = 1;
    i->dims[1].length = 4;
    i->dims[2].lower_bound = 1;
    i->dims[2].length = 3;
    Kokkos::View<bool[5][2][2]>& j;
}

}
int main(int argc, char* argv[])
{
    Kokkos::initialize(argc, argv);
    main2();
    Kokkos::finalize();
    return 0;
}
