/*
**
** The C code is generated by ATS/Anairiats
** The compilation time is: 2020-11-4: 18h:10m
**
*/

/* include some .h files */
#ifndef _ATS_HEADER_NONE
#include "ats_config.h"
#include "ats_basics.h"
#include "ats_types.h"
#include "ats_exception.h"
#include "ats_memory.h"
#endif /* _ATS_HEADER_NONE */

/* include some .cats files */
#ifndef _ATS_PRELUDE_NONE
#include "prelude/CATS/basics.cats"
#include "prelude/CATS/bool.cats"
#include "prelude/CATS/char.cats"
#include "prelude/CATS/byte.cats"
#include "prelude/CATS/float.cats"
#include "prelude/CATS/integer.cats"
#include "prelude/CATS/integer_ptr.cats"
#include "prelude/CATS/integer_fixed.cats"
#include "prelude/CATS/sizetype.cats"
#include "prelude/CATS/pointer.cats"
#include "prelude/CATS/reference.cats"
#include "prelude/CATS/string.cats"
#include "prelude/CATS/lazy.cats"
#include "prelude/CATS/lazy_vt.cats"
#include "prelude/CATS/printf.cats"
#include "prelude/CATS/list.cats"
#include "prelude/CATS/option.cats"
#include "prelude/CATS/array.cats"
#include "prelude/CATS/matrix.cats"
#endif /* _ATS_PRELUDE_NONE */
/* prologues from statically loaded files */
/* external codes at top */

#include "prelude/CATS/array.cats"

#define atspre_matrix_szdiv(i, n) (i / n)

/* type definitions */
typedef
struct {
ats_ptr_type atslab_2 ;
ats_size_type atslab_3 ;
} anairiats_rec_0 ;

/* external typedefs */
/* external dynamic constructor declarations */
/* external dynamic constant declarations */
ATSextern_fun(ats_size_type, atspre_size1_of_int1) (ats_int_type) ;
ATSextern_fun(ats_size_type, atspre_add_size1_int1) (ats_size_type, ats_int_type) ;
ATSextern_fun(ats_size_type, atspre_mul2_size1_size1) (ats_size_type, ats_size_type) ;
ATSextern_fun(ats_size_type, atspre_mod1_size1_size1) (ats_size_type, ats_size_type) ;
ATSextern_fun(ats_bool_type, atspre_lt_size1_size1) (ats_size_type, ats_size_type) ;
ATSextern_fun(ats_ptr_type, atspre_array_ptr_alloc_tsz) (ats_size_type, ats_size_type) ;
ATSextern_fun(ats_void_type, atspre_array_ptr_initialize_cloenv_tsz) (ats_ref_type, ats_size_type, ats_ref_type, ats_size_type, ats_ptr_type) ;
ATSextern_fun(ats_ptr_type, atspre_matrix_ptr_takeout_row_tsz) (ats_ptr_type, ats_size_type, ats_size_type, ats_size_type) ;
ATSextern_fun(ats_ptr_type, atspre_matrix_ptr_takeout_elt_tsz) (ats_ptr_type, ats_size_type, ats_size_type, ats_size_type, ats_size_type) ;
ATSextern_fun(ats_ptr_type, atspre_matrix_make_arrpsz__main) (ats_size_type, ats_size_type, anairiats_rec_0) ;
ATSextern_fun(ats_ptr_type, atspre_matrix_make_funenv_tsz) (ats_size_type, ats_size_type, ats_ptr_type, ats_size_type, ats_ptr_type) ;
ATSextern_fun(ats_void_type, atspre_vbox_make_view_ptr) (ats_ptr_type) ;

/* external dynamic terminating constant declarations */
#ifdef _ATS_PROOFCHECK
extern
ats_void_type ATS_2d0_2e2_2e12_2prelude_2SATS_2arith_2esats__mul_istot_prfck () ;
extern
ats_void_type ATS_2d0_2e2_2e12_2prelude_2SATS_2arith_2esats__mul_nat_nat_nat_prfck () ;
extern
ats_void_type ATS_2d0_2e2_2e12_2prelude_2SATS_2matrix_2esats__array_v_of_matrix_v_prfck () ;
extern
ats_void_type ATS_2d0_2e2_2e12_2prelude_2SATS_2matrix_2esats__matrix_v_of_array_v_prfck () ;
#endif /* _ATS_PROOFCHECK */

/* assuming abstract types */
int ATS_2d0_2e2_2e12_2prelude_2basics_sta_2esats__sasp__matrix_viewt0ype_int_int_type = 0 ;
int ATS_2d0_2e2_2e12_2prelude_2SATS_2matrix_2esats__sasp__mtrxt = 0 ;

/* sum constructor declarations */
/* exn constructor declarations */
/* global dynamic (non-functional) constant declarations */
/* internal function declarations */
static
ats_void_type __ats_fun_5 (ats_size_type env0, ats_ptr_type env1, ats_size_type arg0, ats_ref_type arg1, ats_ptr_type arg2) ;
static
ats_clo_ptr_type __ats_fun_5_closure_make (ats_size_type env0, ats_ptr_type env1) ;
static
ats_void_type __ats_fun_5_clofun (ats_clo_ptr_type cloptr, ats_size_type arg0, ats_ref_type arg1, ats_ptr_type arg2) ;

/* partial value template declarations */
/* static temporary variable declarations */
/* external value variable declarations */

/* function implementations */

#ifdef _ATS_PROOFCHECK
/*
// /nix/store/rfja8ixrs5wb4kj3kiwlch1apnh7qgvy-ats-0.2.12/lib/ats-anairiats-0.2.12/prelude/DATS/matrix.dats: 1981(line=66, offs=1) -- 2175(line=74, offs=4)
*/
ATSglobaldec()
ats_void_type
ATS_2d0_2e2_2e12_2prelude_2SATS_2matrix_2esats__array_v_of_matrix_v_prfck () {
/* local vardec */
// ATSlocal_void (tmp0) ;

ats_proofcheck_beg_mac(ATS_2d0_2e2_2e12_2prelude_2SATS_2matrix_2esats__array_v_of_matrix_v) ;
ATS_2d0_2e2_2e12_2prelude_2SATS_2arith_2esats__mul_istot_prfck () ;
ATS_2d0_2e2_2e12_2prelude_2SATS_2arith_2esats__mul_nat_nat_nat_prfck () ;
ATS_2d0_2e2_2e12_2prelude_2SATS_2array_2esats__array_v_ungroup_prfck () ;
ats_proofcheck_end_mac(ATS_2d0_2e2_2e12_2prelude_2SATS_2matrix_2esats__array_v_of_matrix_v) ;
return /* (tmp0) */ ;
} /* end of [ATS_2d0_2e2_2e12_2prelude_2SATS_2matrix_2esats__array_v_of_matrix_v_prfck] */
#endif /* _ATS_PROOFCHECK */

#ifdef _ATS_PROOFCHECK
/*
// /nix/store/rfja8ixrs5wb4kj3kiwlch1apnh7qgvy-ats-0.2.12/lib/ats-anairiats-0.2.12/prelude/DATS/matrix.dats: 2209(line=76, offs=1) -- 2288(line=78, offs=50)
*/
ATSglobaldec()
ats_void_type
ATS_2d0_2e2_2e12_2prelude_2SATS_2matrix_2esats__matrix_v_of_array_v_prfck () {
/* local vardec */
// ATSlocal_void (tmp1) ;

ats_proofcheck_beg_mac(ATS_2d0_2e2_2e12_2prelude_2SATS_2matrix_2esats__matrix_v_of_array_v) ;
ATS_2d0_2e2_2e12_2prelude_2SATS_2array_2esats__array_v_group_prfck () ;
ats_proofcheck_end_mac(ATS_2d0_2e2_2e12_2prelude_2SATS_2matrix_2esats__matrix_v_of_array_v) ;
return /* (tmp1) */ ;
} /* end of [ATS_2d0_2e2_2e12_2prelude_2SATS_2matrix_2esats__matrix_v_of_array_v_prfck] */
#endif /* _ATS_PROOFCHECK */

/*
// /nix/store/rfja8ixrs5wb4kj3kiwlch1apnh7qgvy-ats-0.2.12/lib/ats-anairiats-0.2.12/prelude/DATS/matrix.dats: 3222(line=124, offs=13) -- 3362(line=129, offs=4)
*/
ATSglobaldec()
ats_ptr_type
ATS_2d0_2e2_2e12_2prelude_2SATS_2matrix_2esats__matrix_make_arrpsz (ats_size_type arg0, ats_size_type arg1, anairiats_rec_0 arg2) {
/* local vardec */
ATSlocal (ats_ptr_type, tmp2) ;

__ats_lab_ATS_2d0_2e2_2e12_2prelude_2SATS_2matrix_2esats__matrix_make_arrpsz:
tmp2 = atspre_matrix_make_arrpsz__main (arg0, arg1, arg2) ;
return (tmp2) ;
} /* end of [ATS_2d0_2e2_2e12_2prelude_2SATS_2matrix_2esats__matrix_make_arrpsz] */

/*
// /nix/store/rfja8ixrs5wb4kj3kiwlch1apnh7qgvy-ats-0.2.12/lib/ats-anairiats-0.2.12/prelude/DATS/matrix.dats: 3436(line=133, offs=7) -- 3687(line=139, offs=6)
*/
ATSglobaldec()
ats_ptr_type
atspre_matrix_make_arrpsz__main (ats_size_type arg0, ats_size_type arg1, anairiats_rec_0 arg2) {
/* local vardec */
ATSlocal (ats_ptr_type, tmp3) ;
// ATSlocal_void (tmp4) ;
ATSlocal (ats_ptr_type, tmp5) ;
// ATSlocal_void (tmp6) ;

__ats_lab_atspre_matrix_make_arrpsz__main:
tmp5 = ats_select_mac(arg2, atslab_2) ;
/* tmp4 = */ atspre_vbox_make_view_ptr (tmp5) ;
/* tmp6 = ats_selsin_mac(tmp4, atslab_1) */ ;
tmp3 = ats_select_mac(arg2, atslab_2) ;
return (tmp3) ;
} /* end of [atspre_matrix_make_arrpsz__main] */

/*
// /nix/store/rfja8ixrs5wb4kj3kiwlch1apnh7qgvy-ats-0.2.12/lib/ats-anairiats-0.2.12/prelude/DATS/matrix.dats: 5006(line=187, offs=15) -- 5172(line=192, offs=6)
*/
ATSstaticdec()
ats_void_type
__ats_fun_5 (ats_size_type env0, ats_ptr_type env1, ats_size_type arg0, ats_ref_type arg1, ats_ptr_type arg2) {
/* local vardec */
// ATSlocal_void (tmp13) ;
ATSlocal (ats_size_type, tmp14) ;
ATSlocal (ats_size_type, tmp15) ;

__ats_lab___ats_fun_5:
tmp14 = atspre_matrix_szdiv (arg0, env0) ;
tmp15 = atspre_mod1_size1_size1 (arg0, env0) ;
/* tmp13 = */ ((ats_void_type(*)(ats_size_type, ats_size_type, ats_ref_type, ats_ptr_type))env1) (tmp14, tmp15, arg1, arg2) ;
return /* (tmp13) */ ;
} /* end of [__ats_fun_5] */

typedef struct {
ats_fun_ptr_type closure_fun ;
ats_size_type closure_env_0 ;
ats_ptr_type closure_env_1 ;
} __ats_fun_5_closure_type ;

ats_void_type
__ats_fun_5_clofun (ats_clo_ptr_type cloptr, ats_size_type arg0, ats_ref_type arg1, ats_ptr_type arg2) {
__ats_fun_5 (((__ats_fun_5_closure_type*)cloptr)->closure_env_0, ((__ats_fun_5_closure_type*)cloptr)->closure_env_1, arg0, arg1, arg2) ; return ;
} /* end of function */

ATSinline()
ats_void_type
__ats_fun_5_closure_init (__ats_fun_5_closure_type *p_clo, ats_size_type env0, ats_ptr_type env1) {
p_clo->closure_fun = (ats_fun_ptr_type)&__ats_fun_5_clofun ;
p_clo->closure_env_0 = env0 ;
p_clo->closure_env_1 = env1 ;
return ;
} /* end of function */

/*
// /nix/store/rfja8ixrs5wb4kj3kiwlch1apnh7qgvy-ats-0.2.12/lib/ats-anairiats-0.2.12/prelude/DATS/matrix.dats: 4664(line=178, offs=3) -- 5472(line=200, offs=6)
*/
ATSglobaldec()
ats_ptr_type
atspre_matrix_make_funenv_tsz (ats_size_type arg0, ats_size_type arg1, ats_ptr_type arg2, ats_size_type arg3, ats_ptr_type arg4) {
/* local vardec */
ATSlocal (ats_ptr_type, tmp7) ;
ATSlocal (ats_size_type, tmp8) ;
ATSlocal (ats_size_type, tmp9) ;
ATSlocal (ats_ptr_type, tmp10) ;
ATSlocal (ats_ptr_type, tmp11) ;
ATSlocal (ats_ptr_type, tmp12) ;
ATSlocal (__ats_fun_5_closure_type, tmp16) ;
// ATSlocal_void (tmp17) ;
// ATSlocal_void (tmp18) ;
// ATSlocal_void (tmp19) ;

__ats_lab_atspre_matrix_make_funenv_tsz:
tmp8 = atspre_mul2_size1_size1 (arg0, arg1) ;
tmp9 = ats_selsin_mac(tmp8, atslab_1) ;
tmp10 = atspre_array_ptr_alloc_tsz (tmp9, arg3) ;
tmp11 = ats_selsin_mac(tmp10, atslab_2) ;
/* ats_ptr_type tmp12 ; */
tmp12 = &(tmp16) ;
__ats_fun_5_closure_init (tmp12, arg1, arg2) ; // closure initialization
/* tmp17 = */ atspre_array_ptr_initialize_cloenv_tsz (tmp11, tmp9, tmp12, arg3, arg4) ;
/* tmp18 = */ atspre_vbox_make_view_ptr (tmp11) ;
/* tmp19 = ats_selsin_mac(tmp18, atslab_1) */ ;
tmp7 = tmp11 ;
return (tmp7) ;
} /* end of [atspre_matrix_make_funenv_tsz] */

/* static load function */

// extern ats_void_type ATS_2d0_2e2_2e12_2prelude_2SATS_2matrix_2esats__staload (void) ;

ats_void_type
ATS_2d0_2e2_2e12_2prelude_2DATS_2matrix_2edats__staload () {
static int ATS_2d0_2e2_2e12_2prelude_2DATS_2matrix_2edats__staload_flag = 0 ;
if (ATS_2d0_2e2_2e12_2prelude_2DATS_2matrix_2edats__staload_flag) return ;
ATS_2d0_2e2_2e12_2prelude_2DATS_2matrix_2edats__staload_flag = 1 ;

// ATS_2d0_2e2_2e12_2prelude_2SATS_2matrix_2esats__staload () ;

return ;
} /* staload function */

/* dynamic load function */

// dynload flag declaration
// extern ats_int_type ATS_2d0_2e2_2e12_2prelude_2DATS_2matrix_2edats__dynload_flag ;

ats_void_type
ATS_2d0_2e2_2e12_2prelude_2DATS_2matrix_2edats__dynload () {
// ATS_2d0_2e2_2e12_2prelude_2DATS_2matrix_2edats__dynload_flag = 1 ;
ATS_2d0_2e2_2e12_2prelude_2DATS_2matrix_2edats__staload () ;

#ifdef _ATS_PROOFCHECK
ATS_2d0_2e2_2e12_2prelude_2SATS_2arith_2esats__mul_istot_prfck () ;
ATS_2d0_2e2_2e12_2prelude_2SATS_2arith_2esats__mul_nat_nat_nat_prfck () ;
ATS_2d0_2e2_2e12_2prelude_2SATS_2matrix_2esats__array_v_of_matrix_v_prfck () ;
ATS_2d0_2e2_2e12_2prelude_2SATS_2matrix_2esats__matrix_v_of_array_v_prfck () ;
#endif /* _ATS_PROOFCHECK */

/* marking static variables for GC */

/* marking external values for GC */

/* code for dynamic loading */
return ;
} /* end of [dynload function] */

/* external codes at mid */
/* external codes at bot */

/* ****** ****** */

/* end of [DATS_matrix_dats.c] */
