/*
**
** 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 */

#include "libc/sys/CATS/stat.cats"

#include "libc/sys/CATS/types.cats"

#include "libc/sys/CATS/types.cats"
/* external codes at top */

#include <libc/CATS/stdio.cats>
#include <libc/sys/CATS/stat.cats>


typedef struct {
  ats_char_type atslab_0 ; ats_ptr_type atslab_1 ;
} *charlst ; // end of [typedef]

ATSinline()
ats_ptr_type
string_make_charlst_rev
  (ats_int_type sz, ats_ptr_type cs) {
  char *s0, *s ; charlst cs_next ;
  s0 = (char*)ATS_MALLOC (sz + 1) ; s = s0 + sz ;
  *s-- = '\0' ;
  while (cs != (charlst)0) {
    *s-- = ((charlst)cs)->atslab_0 ;
    cs_next = ((charlst)cs)->atslab_1 ;
    ATS_FREE (cs) ; cs = cs_next ;
  } // end of [while]
  return s0 ;
} /* string_make_charlst_rev */


/* type definitions */
typedef struct {
ats_char_type atslab_0 ;
ats_ptr_type atslab_1 ;
} anairiats_sum_0 ;

typedef struct {
ats_ptr_type atslab_0 ;
ats_ptr_type atslab_1 ;
} anairiats_sum_1 ;

/* external typedefs */
/* external dynamic constructor declarations */
ATSextern_val(ats_sum_type, ATS_2d0_2e2_2e12_2prelude_2basics_sta_2esats__list_vt_cons_0) ;
ATSextern_val(ats_sum_type, ATS_2d0_2e2_2e12_2prelude_2basics_sta_2esats__list_vt_nil_1) ;
ATSextern_val(ats_sum_type, ATS_2d0_2e2_2e12_2prelude_2basics_sta_2esats__stream_nil_0) ;
ATSextern_val(ats_sum_type, ATS_2d0_2e2_2e12_2prelude_2basics_sta_2esats__stream_cons_1) ;
ATSextern_val(ats_sum_type, ATS_2d0_2e2_2e12_2prelude_2basics_sta_2esats__stream_vt_nil_0) ;
ATSextern_val(ats_sum_type, ATS_2d0_2e2_2e12_2prelude_2basics_sta_2esats__stream_vt_cons_1) ;

/* external dynamic constant declarations */
ATSextern_fun(ats_char_type, atspre_char_of_int) (ats_int_type) ;
ATSextern_fun(ats_bool_type, atspre_neq_char_char) (ats_char_type, ats_char_type) ;
ATSextern_fun(ats_bool_type, atspre_gte_int_int) (ats_int_type, ats_int_type) ;
ATSextern_fun(ats_bool_type, atspre_neq_int_int) (ats_int_type, ats_int_type) ;
ATSextern_fun(ats_int_type, atspre_iadd) (ats_int_type, ats_int_type) ;
ATSextern_fun(ats_bool_type, atspre_igt) (ats_int_type, ats_int_type) ;
ATSextern_fun(ats_bool_type, atspre_ieq) (ats_int_type, ats_int_type) ;
ATSextern_fun(ats_bool_type, atspre_eq_lint_lint) (ats_lint_type, ats_lint_type) ;
ATSextern_fun(ats_ssize_type, atspre_ssize1_of_int1) (ats_int_type) ;
ATSextern_fun(ats_ssize_type, atspre_sub_ssize1_ssize1) (ats_ssize_type, ats_ssize_type) ;
ATSextern_fun(ats_bool_type, atspre_neq_ssize1_ssize1) (ats_ssize_type, ats_ssize_type) ;
ATSextern_fun(ats_bool_type, atspre_stropt_is_some) (ats_ptr_type) ;
ATSextern_fun(ats_int_type, ATS_2d0_2e2_2e12_2prelude_2SATS_2filebas_2esats__test_file_mode) (ats_ptr_type, ats_ptr_type) ;
ATSextern_fun(ats_ptr_type, ATS_2d0_2e2_2e12_2prelude_2SATS_2filebas_2esats__input_line) (ats_ptr_type) ;
ATSextern_fun(ats_ptr_type, ATS_2d0_2e2_2e12_2prelude_2SATS_2filebas_2esats__input_line_vt) (ats_ptr_type) ;
ATSextern_fun(ats_ptr_type, ATS_2d0_2e2_2e12_2prelude_2SATS_2filebas_2esats__char_stream_make_file) (ats_ptr_type) ;
ATSextern_fun(ats_ptr_type, ATS_2d0_2e2_2e12_2prelude_2SATS_2filebas_2esats__line_stream_make_file) (ats_ptr_type) ;
ATSextern_fun(ats_ptr_type, ATS_2d0_2e2_2e12_2prelude_2SATS_2filebas_2esats__char_stream_vt_make_file) (ats_ptr_type) ;
ATSextern_fun(ats_ptr_type, ATS_2d0_2e2_2e12_2prelude_2SATS_2filebas_2esats__line_stream_vt_make_file) (ats_ptr_type) ;
ATSextern_fun(ats_void_type, atslib_fclose_exn) (ats_ptr_type) ;
ATSextern_fun(ats_void_type, atslib_fclose_exn) (ats_ptr_type) ;
ATSextern_fun(ats_ptr_type, string_make_charlst_rev) (ats_int_type, ats_ptr_type) ;
ATSextern_fun(ats_void_type, atslib_fputc_exn) (ats_char_type, ats_ptr_type) ;
ATSextern_fun(ats_void_type, atslib_fputs_exn) (ats_ptr_type, ats_ptr_type) ;
ATSextern_fun(ats_void_type, atslib_fflush_exn) (ats_ptr_type) ;
ATSextern_fun(ats_bool_type, atslib_S_ISBLK) (ats_mode_type) ;
ATSextern_fun(ats_bool_type, atslib_S_ISCHR) (ats_mode_type) ;
ATSextern_fun(ats_bool_type, atslib_S_ISDIR) (ats_mode_type) ;
ATSextern_fun(ats_bool_type, atslib_S_ISFIFO) (ats_mode_type) ;
ATSextern_fun(ats_bool_type, atslib_S_ISREG) (ats_mode_type) ;
ATSextern_fun(ats_bool_type, atslib_S_ISLNK) (ats_mode_type) ;

/* external dynamic terminating constant declarations */
#ifdef _ATS_PROOFCHECK
#endif /* _ATS_PROOFCHECK */

/* assuming abstract types */
/* sum constructor declarations */
/* exn constructor declarations */
/* global dynamic (non-functional) constant declarations */
/* internal function declarations */
static
ats_ptr_type loop_1 (ats_ptr_type arg0, ats_int_type arg1, ats_ptr_type arg2) ;
static
ats_bool_type __ats_fun_7 (ats_uint_type arg0) ;
static
ats_bool_type __ats_fun_9 (ats_uint_type arg0) ;
static
ats_bool_type __ats_fun_11 (ats_uint_type arg0) ;
static
ats_bool_type __ats_fun_13 (ats_uint_type arg0) ;
static
ats_bool_type __ats_fun_15 (ats_uint_type arg0) ;
static
ats_void_type loop_18 (ats_ptr_type arg0, ats_ref_type arg1, ats_ssize_type arg2) ;
static
ats_ptr_type __ats_fun_22 (ats_ptr_type env0) ;
static
ats_clo_ptr_type __ats_fun_22_closure_make (ats_ptr_type env0) ;
static
ats_ptr_type __ats_fun_22_clofun (ats_clo_ptr_type cloptr) ;
static
ats_ptr_type __ats_fun_24 (ats_ptr_type env0) ;
static
ats_clo_ptr_type __ats_fun_24_closure_make (ats_ptr_type env0) ;
static
ats_ptr_type __ats_fun_24_clofun (ats_clo_ptr_type cloptr) ;
static
ats_ptr_type __ats_fun_26 (ats_ptr_type env0, ats_bool_type arg0) ;
static
ats_clo_ptr_type __ats_fun_26_closure_make (ats_ptr_type env0) ;
static
ats_ptr_type __ats_fun_26_clofun (ats_clo_ptr_type cloptr, ats_bool_type arg0) ;
static
ats_ptr_type __ats_fun_29 (ats_bool_type arg0) ;
static
ats_clo_ptr_type __ats_fun_29_closure_make () ;
static
ats_ptr_type __ats_fun_29_clofun (ats_clo_ptr_type cloptr, ats_bool_type arg0) ;
static
ats_ptr_type loop_28 (ats_ptr_type arg0, ats_int_type arg1, ats_ptr_type arg2) ;
static
ats_ptr_type __ats_fun_30 (ats_ptr_type env0, ats_bool_type arg0) ;
static
ats_clo_ptr_type __ats_fun_30_closure_make (ats_ptr_type env0) ;
static
ats_ptr_type __ats_fun_30_clofun (ats_clo_ptr_type cloptr, ats_bool_type arg0) ;

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

/* function implementations */

/*
// /nix/store/rfja8ixrs5wb4kj3kiwlch1apnh7qgvy-ats-0.2.12/lib/ats-anairiats-0.2.12/prelude/DATS/filebas.dats: 3688(line=135, offs=7) -- 4242(line=155, offs=6)
*/
ATSstaticdec()
ats_ptr_type
loop_1 (ats_ptr_type arg0, ats_int_type arg1, ats_ptr_type arg2) {
/* local vardec */
ATSlocal (ats_ptr_type, tmp1) ;
ATSlocal (ats_int_type, tmp2) ;
ATSlocal (ats_bool_type, tmp3) ;
ATSlocal (ats_char_type, tmp4) ;
ATSlocal (ats_bool_type, tmp5) ;
ATSlocal (ats_int_type, tmp6) ;
ATSlocal (ats_ptr_type, tmp7) ;
ATSlocal (ats_bool_type, tmp8) ;

__ats_lab_loop_1:
tmp2 = atslib_fgetc_err (arg0) ;
tmp3 = atspre_neq_int_int (tmp2, EOF) ;
if (tmp3) {
tmp4 = atspre_char_of_int (tmp2) ;
tmp5 = atspre_neq_char_char (tmp4, '\n') ;
if (tmp5) {
tmp6 = atspre_iadd (arg1, 1) ;
tmp7 = ATS_MALLOC(sizeof(anairiats_sum_0)) ;
ats_selptrset_mac(anairiats_sum_0, tmp7, atslab_0, tmp4) ;
ats_selptrset_mac(anairiats_sum_0, tmp7, atslab_1, arg2) ;
arg0 = arg0 ;
arg1 = tmp6 ;
arg2 = tmp7 ;
goto __ats_lab_loop_1 ; // tail call
} else {
tmp1 = string_make_charlst_rev (arg1, arg2) ;
} /* end of [if] */
} else {
tmp8 = atspre_ieq (arg1, 0) ;
if (tmp8) {
// if (arg2 != (ats_sum_ptr_type)0) { ats_deadcode_failure_handle () ; }
tmp1 = atspre_strptr_null () ;
} else {
tmp1 = string_make_charlst_rev (arg1, arg2) ;
} /* end of [if] */
} /* end of [if] */
return (tmp1) ;
} /* end of [loop_1] */

/*
// /nix/store/rfja8ixrs5wb4kj3kiwlch1apnh7qgvy-ats-0.2.12/lib/ats-anairiats-0.2.12/prelude/DATS/filebas.dats: 3670(line=134, offs=15) -- 4298(line=158, offs=4)
*/
ATSglobaldec()
ats_ptr_type
ATS_2d0_2e2_2e12_2prelude_2SATS_2filebas_2esats__input_line_vt (ats_ptr_type arg0) {
/* local vardec */
ATSlocal (ats_ptr_type, tmp0) ;
ATSlocal (ats_ptr_type, tmp9) ;

__ats_lab_ATS_2d0_2e2_2e12_2prelude_2SATS_2filebas_2esats__input_line_vt:
tmp9 = (ats_sum_ptr_type)0 ;
tmp0 = loop_1 (arg0, 0, tmp9) ;
return (tmp0) ;
} /* end of [ATS_2d0_2e2_2e12_2prelude_2SATS_2filebas_2esats__input_line_vt] */

/*
// /nix/store/rfja8ixrs5wb4kj3kiwlch1apnh7qgvy-ats-0.2.12/lib/ats-anairiats-0.2.12/prelude/DATS/filebas.dats: 4347(line=161, offs=12) -- 4420(line=163, offs=4)
*/
ATSglobaldec()
ats_ptr_type
ATS_2d0_2e2_2e12_2prelude_2SATS_2filebas_2esats__input_line (ats_ptr_type arg0) {
/* local vardec */
ATSlocal (ats_ptr_type, tmp10) ;
ATSlocal (ats_ptr_type, tmp11) ;

__ats_lab_ATS_2d0_2e2_2e12_2prelude_2SATS_2filebas_2esats__input_line:
tmp11 = ATS_2d0_2e2_2e12_2prelude_2SATS_2filebas_2esats__input_line_vt (arg0) ;
tmp10 = ats_castfn_mac(ats_ptr_type, tmp11) ;
return (tmp10) ;
} /* end of [ATS_2d0_2e2_2e12_2prelude_2SATS_2filebas_2esats__input_line] */

/*
// /nix/store/rfja8ixrs5wb4kj3kiwlch1apnh7qgvy-ats-0.2.12/lib/ats-anairiats-0.2.12/prelude/DATS/filebas.dats: 4871(line=186, offs=13) -- 4956(line=188, offs=2)
*/
ATSglobaldec()
ats_void_type
ATS_2d0_2e2_2e12_2prelude_2SATS_2filebas_2esats__output_line (ats_ptr_type arg0, ats_ptr_type arg1) {
/* local vardec */
// ATSlocal_void (tmp12) ;
// ATSlocal_void (tmp13) ;
// ATSlocal_void (tmp14) ;

__ats_lab_ATS_2d0_2e2_2e12_2prelude_2SATS_2filebas_2esats__output_line:
/* tmp13 = */ atslib_fputs_exn (arg1, arg0) ;
/* tmp14 = */ atslib_fputc_exn ('\n', arg0) ;
/* tmp12 = */ atslib_fflush_exn (arg0) ;
return /* (tmp12) */ ;
} /* end of [ATS_2d0_2e2_2e12_2prelude_2SATS_2filebas_2esats__output_line] */

/*
// /nix/store/rfja8ixrs5wb4kj3kiwlch1apnh7qgvy-ats-0.2.12/lib/ats-anairiats-0.2.12/prelude/DATS/filebas.dats: 5197(line=203, offs=18) -- 5418(line=212, offs=4)
*/
ATSglobaldec()
ats_bool_type
atspre_test_file_exists (ats_ptr_type arg0) {
/* local vardec */
ATSlocal (ats_bool_type, tmp15) ;
ATSlocal (ats_stat_type, tmp16) ;
ATSlocal (ats_int_type, tmp17) ;
ATSlocal (ats_bool_type, tmp18) ;

__ats_lab_atspre_test_file_exists:
/* ats_stat_type tmp16 ; */
tmp17 = atslib_stat_err (arg0, (&tmp16)) ;
tmp18 = atspre_ieq (tmp17, 0) ;
if (tmp18) {
tmp15 = ats_true_bool ;
} else {
tmp15 = ats_false_bool ;
} /* end of [if] */
return (tmp15) ;
} /* end of [atspre_test_file_exists] */

/*
// /nix/store/rfja8ixrs5wb4kj3kiwlch1apnh7qgvy-ats-0.2.12/lib/ats-anairiats-0.2.12/prelude/DATS/filebas.dats: 5497(line=218, offs=3) -- 5766(line=228, offs=4)
*/
ATSglobaldec()
ats_int_type
ATS_2d0_2e2_2e12_2prelude_2SATS_2filebas_2esats__test_file_mode (ats_ptr_type arg0, ats_ptr_type arg1) {
/* local vardec */
ATSlocal (ats_int_type, tmp19) ;
ATSlocal (ats_stat_type, tmp20) ;
ATSlocal (ats_int_type, tmp21) ;
ATSlocal (ats_bool_type, tmp22) ;
ATSlocal (ats_bool_type, tmp23) ;
ATSlocal (ats_mode_type, tmp24) ;

__ats_lab_ATS_2d0_2e2_2e12_2prelude_2SATS_2filebas_2esats__test_file_mode:
/* ats_stat_type tmp20 ; */
tmp21 = atslib_stat_err (arg0, (&tmp20)) ;
tmp22 = atspre_ieq (tmp21, 0) ;
if (tmp22) {
tmp24 = ats_select_mac(tmp20, st_mode) ;
tmp23 = ((ats_bool_type(*)(ats_uint_type))arg1) (ats_castfn_mac(ats_uint_type, tmp24)) ;
if (tmp23) {
tmp19 = 1 ;
} else {
tmp19 = 0 ;
} /* end of [if] */
} else {
tmp19 = -1 ;
} /* end of [if] */
return (tmp19) ;
} /* end of [ATS_2d0_2e2_2e12_2prelude_2SATS_2filebas_2esats__test_file_mode] */

/*
// /nix/store/rfja8ixrs5wb4kj3kiwlch1apnh7qgvy-ats-0.2.12/lib/ats-anairiats-0.2.12/prelude/DATS/filebas.dats: 5875(line=233, offs=34) -- 5900(line=233, offs=59)
*/
ATSstaticdec()
ats_bool_type
__ats_fun_7 (ats_uint_type arg0) {
/* local vardec */
ATSlocal (ats_bool_type, tmp26) ;

__ats_lab___ats_fun_7:
tmp26 = atslib_S_ISBLK (ats_castfn_mac(ats_mode_type, arg0)) ;
return (tmp26) ;
} /* end of [__ats_fun_7] */

/*
// /nix/store/rfja8ixrs5wb4kj3kiwlch1apnh7qgvy-ats-0.2.12/lib/ats-anairiats-0.2.12/prelude/DATS/filebas.dats: 5844(line=233, offs=3) -- 5901(line=233, offs=60)
*/
ATSglobaldec()
ats_int_type
atspre_test_file_isblk (ats_ptr_type arg0) {
/* local vardec */
ATSlocal (ats_int_type, tmp25) ;

__ats_lab_atspre_test_file_isblk:
tmp25 = ATS_2d0_2e2_2e12_2prelude_2SATS_2filebas_2esats__test_file_mode (arg0, &__ats_fun_7) ;
return (tmp25) ;
} /* end of [atspre_test_file_isblk] */

/*
// /nix/store/rfja8ixrs5wb4kj3kiwlch1apnh7qgvy-ats-0.2.12/lib/ats-anairiats-0.2.12/prelude/DATS/filebas.dats: 5990(line=237, offs=34) -- 6015(line=237, offs=59)
*/
ATSstaticdec()
ats_bool_type
__ats_fun_9 (ats_uint_type arg0) {
/* local vardec */
ATSlocal (ats_bool_type, tmp28) ;

__ats_lab___ats_fun_9:
tmp28 = atslib_S_ISCHR (ats_castfn_mac(ats_mode_type, arg0)) ;
return (tmp28) ;
} /* end of [__ats_fun_9] */

/*
// /nix/store/rfja8ixrs5wb4kj3kiwlch1apnh7qgvy-ats-0.2.12/lib/ats-anairiats-0.2.12/prelude/DATS/filebas.dats: 5959(line=237, offs=3) -- 6016(line=237, offs=60)
*/
ATSglobaldec()
ats_int_type
atspre_test_file_ischr (ats_ptr_type arg0) {
/* local vardec */
ATSlocal (ats_int_type, tmp27) ;

__ats_lab_atspre_test_file_ischr:
tmp27 = ATS_2d0_2e2_2e12_2prelude_2SATS_2filebas_2esats__test_file_mode (arg0, &__ats_fun_9) ;
return (tmp27) ;
} /* end of [atspre_test_file_ischr] */

/*
// /nix/store/rfja8ixrs5wb4kj3kiwlch1apnh7qgvy-ats-0.2.12/lib/ats-anairiats-0.2.12/prelude/DATS/filebas.dats: 6105(line=241, offs=34) -- 6130(line=241, offs=59)
*/
ATSstaticdec()
ats_bool_type
__ats_fun_11 (ats_uint_type arg0) {
/* local vardec */
ATSlocal (ats_bool_type, tmp30) ;

__ats_lab___ats_fun_11:
tmp30 = atslib_S_ISDIR (ats_castfn_mac(ats_mode_type, arg0)) ;
return (tmp30) ;
} /* end of [__ats_fun_11] */

/*
// /nix/store/rfja8ixrs5wb4kj3kiwlch1apnh7qgvy-ats-0.2.12/lib/ats-anairiats-0.2.12/prelude/DATS/filebas.dats: 6074(line=241, offs=3) -- 6131(line=241, offs=60)
*/
ATSglobaldec()
ats_int_type
atspre_test_file_isdir (ats_ptr_type arg0) {
/* local vardec */
ATSlocal (ats_int_type, tmp29) ;

__ats_lab_atspre_test_file_isdir:
tmp29 = ATS_2d0_2e2_2e12_2prelude_2SATS_2filebas_2esats__test_file_mode (arg0, &__ats_fun_11) ;
return (tmp29) ;
} /* end of [atspre_test_file_isdir] */

/*
// /nix/store/rfja8ixrs5wb4kj3kiwlch1apnh7qgvy-ats-0.2.12/lib/ats-anairiats-0.2.12/prelude/DATS/filebas.dats: 6221(line=245, offs=34) -- 6247(line=245, offs=60)
*/
ATSstaticdec()
ats_bool_type
__ats_fun_13 (ats_uint_type arg0) {
/* local vardec */
ATSlocal (ats_bool_type, tmp32) ;

__ats_lab___ats_fun_13:
tmp32 = atslib_S_ISFIFO (ats_castfn_mac(ats_mode_type, arg0)) ;
return (tmp32) ;
} /* end of [__ats_fun_13] */

/*
// /nix/store/rfja8ixrs5wb4kj3kiwlch1apnh7qgvy-ats-0.2.12/lib/ats-anairiats-0.2.12/prelude/DATS/filebas.dats: 6190(line=245, offs=3) -- 6248(line=245, offs=61)
*/
ATSglobaldec()
ats_int_type
atspre_test_file_isfifo (ats_ptr_type arg0) {
/* local vardec */
ATSlocal (ats_int_type, tmp31) ;

__ats_lab_atspre_test_file_isfifo:
tmp31 = ATS_2d0_2e2_2e12_2prelude_2SATS_2filebas_2esats__test_file_mode (arg0, &__ats_fun_13) ;
return (tmp31) ;
} /* end of [atspre_test_file_isfifo] */

/*
// /nix/store/rfja8ixrs5wb4kj3kiwlch1apnh7qgvy-ats-0.2.12/lib/ats-anairiats-0.2.12/prelude/DATS/filebas.dats: 6338(line=249, offs=34) -- 6363(line=249, offs=59)
*/
ATSstaticdec()
ats_bool_type
__ats_fun_15 (ats_uint_type arg0) {
/* local vardec */
ATSlocal (ats_bool_type, tmp34) ;

__ats_lab___ats_fun_15:
tmp34 = atslib_S_ISREG (ats_castfn_mac(ats_mode_type, arg0)) ;
return (tmp34) ;
} /* end of [__ats_fun_15] */

/*
// /nix/store/rfja8ixrs5wb4kj3kiwlch1apnh7qgvy-ats-0.2.12/lib/ats-anairiats-0.2.12/prelude/DATS/filebas.dats: 6307(line=249, offs=3) -- 6364(line=249, offs=60)
*/
ATSglobaldec()
ats_int_type
atspre_test_file_isreg (ats_ptr_type arg0) {
/* local vardec */
ATSlocal (ats_int_type, tmp33) ;

__ats_lab_atspre_test_file_isreg:
tmp33 = ATS_2d0_2e2_2e12_2prelude_2SATS_2filebas_2esats__test_file_mode (arg0, &__ats_fun_15) ;
return (tmp33) ;
} /* end of [atspre_test_file_isreg] */

/*
// /nix/store/rfja8ixrs5wb4kj3kiwlch1apnh7qgvy-ats-0.2.12/lib/ats-anairiats-0.2.12/prelude/DATS/filebas.dats: 6441(line=255, offs=17) -- 6721(line=265, offs=4)
*/
ATSglobaldec()
ats_int_type
ATS_2d0_2e2_2e12_2prelude_2SATS_2filebas_2esats__test_file_isemp (ats_ptr_type arg0) {
/* local vardec */
ATSlocal (ats_int_type, tmp35) ;
ATSlocal (ats_stat_type, tmp36) ;
ATSlocal (ats_int_type, tmp37) ;
ATSlocal (ats_bool_type, tmp38) ;
ATSlocal (ats_bool_type, tmp39) ;
ATSlocal (ats_off_type, tmp40) ;

__ats_lab_ATS_2d0_2e2_2e12_2prelude_2SATS_2filebas_2esats__test_file_isemp:
/* ats_stat_type tmp36 ; */
tmp37 = atslib_lstat_err (arg0, (&tmp36)) ;
tmp38 = atspre_ieq (tmp37, 0) ;
if (tmp38) {
tmp40 = ats_select_mac(tmp36, st_size) ;
tmp39 = atspre_eq_lint_lint (ats_castfn_mac(ats_lint_type, tmp40), 0L) ;
if (tmp39) {
tmp35 = 1 ;
} else {
tmp35 = 0 ;
} /* end of [if] */
} else {
tmp35 = -1 ;
} /* end of [if] */
return (tmp35) ;
} /* end of [ATS_2d0_2e2_2e12_2prelude_2SATS_2filebas_2esats__test_file_isemp] */

/*
// /nix/store/rfja8ixrs5wb4kj3kiwlch1apnh7qgvy-ats-0.2.12/lib/ats-anairiats-0.2.12/prelude/DATS/filebas.dats: 6777(line=268, offs=17) -- 7045(line=278, offs=4)
*/
ATSglobaldec()
ats_int_type
ATS_2d0_2e2_2e12_2prelude_2SATS_2filebas_2esats__test_file_islnk (ats_ptr_type arg0) {
/* local vardec */
ATSlocal (ats_int_type, tmp41) ;
ATSlocal (ats_stat_type, tmp42) ;
ATSlocal (ats_int_type, tmp43) ;
ATSlocal (ats_bool_type, tmp44) ;
ATSlocal (ats_bool_type, tmp45) ;
ATSlocal (ats_mode_type, tmp46) ;

__ats_lab_ATS_2d0_2e2_2e12_2prelude_2SATS_2filebas_2esats__test_file_islnk:
/* ats_stat_type tmp42 ; */
tmp43 = atslib_lstat_err (arg0, (&tmp42)) ;
tmp44 = atspre_ieq (tmp43, 0) ;
if (tmp44) {
tmp46 = ats_select_mac(tmp42, st_mode) ;
tmp45 = atslib_S_ISLNK (tmp46) ;
if (tmp45) {
tmp41 = 1 ;
} else {
tmp41 = 0 ;
} /* end of [if] */
} else {
tmp41 = -1 ;
} /* end of [if] */
return (tmp41) ;
} /* end of [ATS_2d0_2e2_2e12_2prelude_2SATS_2filebas_2esats__test_file_islnk] */

/*
// /nix/store/rfja8ixrs5wb4kj3kiwlch1apnh7qgvy-ats-0.2.12/lib/ats-anairiats-0.2.12/prelude/DATS/filebas.dats: 7224(line=290, offs=5) -- 7714(line=314, offs=4)
*/
ATSstaticdec()
ats_void_type
loop_18 (ats_ptr_type arg0, ats_ref_type arg1, ats_ssize_type arg2) {
/* local vardec */
// ATSlocal_void (tmp47) ;
ATSlocal (ats_bool_type, tmp48) ;
ATSlocal (ats_ssize_type, tmp49) ;
ATSlocal (ats_int_type, tmp50) ;
ATSlocal (ats_bool_type, tmp51) ;
ATSlocal (ats_char_type, tmp52) ;
ATSlocal (ats_ptr_type, tmp53) ;
ATSlocal (ats_ptr_type, tmp54) ;
ATSlocal (ats_ssize_type, tmp55) ;
ATSlocal (ats_ssize_type, tmp56) ;
ATSlocal (ats_ptr_type, tmp57) ;
ATSlocal (ats_ptr_type, tmp58) ;

__ats_lab_loop_18:
tmp49 = atspre_ssize1_of_int1 (0) ;
tmp48 = atspre_neq_ssize1_ssize1 (arg2, tmp49) ;
if (tmp48) {
tmp50 = atslib_fgetc_err (arg0) ;
tmp51 = atspre_gte_int_int (tmp50, 0) ;
if (tmp51) {
tmp52 = atspre_char_of_int (tmp50) ;
tmp53 = ATS_MALLOC(sizeof(anairiats_sum_0)) ;
ats_selptrset_mac(anairiats_sum_0, tmp53, atslab_0, tmp52) ;
ats_ptrget_mac(ats_ptr_type, arg1) = tmp53 ;
// if (ats_ptrget_mac(ats_ptr_type, arg1) == (ats_sum_ptr_type)0) { ats_deadcode_failure_handle () ; }
tmp54 = &ats_caselptrlab_mac(anairiats_sum_0, ats_ptrget_mac(ats_ptr_type, arg1), atslab_1) ;
tmp56 = atspre_ssize1_of_int1 (1) ;
tmp55 = atspre_sub_ssize1_ssize1 (arg2, tmp56) ;
arg0 = arg0 ;
arg1 = tmp54 ;
arg2 = tmp55 ;
goto __ats_lab_loop_18 ; // tail call
} else {
tmp57 = (ats_sum_ptr_type)0 ;
ats_ptrget_mac(ats_ptr_type, arg1) = tmp57 ;
} /* end of [if] */
} else {
tmp58 = (ats_sum_ptr_type)0 ;
ats_ptrget_mac(ats_ptr_type, arg1) = tmp58 ;
} /* end of [if] */
return /* (tmp47) */ ;
} /* end of [loop_18] */

/*
// /nix/store/rfja8ixrs5wb4kj3kiwlch1apnh7qgvy-ats-0.2.12/lib/ats-anairiats-0.2.12/prelude/DATS/filebas.dats: 7789(line=320, offs=3) -- 7868(line=327, offs=4)
*/
ATSglobaldec()
ats_ptr_type
ATS_2d0_2e2_2e12_2prelude_2SATS_2filebas_2esats__char_list_vt_make_file (ats_ptr_type arg0) {
/* local vardec */
ATSlocal (ats_ptr_type, tmp59) ;
ATSlocal (ats_ptr_type, tmp60) ;
// ATSlocal_void (tmp61) ;
ATSlocal (ats_ssize_type, tmp62) ;

__ats_lab_ATS_2d0_2e2_2e12_2prelude_2SATS_2filebas_2esats__char_list_vt_make_file:
/* ats_ptr_type tmp60 ; */
tmp62 = atspre_ssize1_of_int1 (-1) ;
/* tmp61 = */ loop_18 (arg0, (&tmp60), tmp62) ;
tmp59 = tmp60 ;
return (tmp59) ;
} /* end of [ATS_2d0_2e2_2e12_2prelude_2SATS_2filebas_2esats__char_list_vt_make_file] */

/*
// /nix/store/rfja8ixrs5wb4kj3kiwlch1apnh7qgvy-ats-0.2.12/lib/ats-anairiats-0.2.12/prelude/DATS/filebas.dats: 7944(line=331, offs=3) -- 8052(line=339, offs=4)
*/
ATSglobaldec()
ats_ptr_type
ATS_2d0_2e2_2e12_2prelude_2SATS_2filebas_2esats__char_list_vt_make_file_len (ats_ptr_type arg0, ats_size_type arg1) {
/* local vardec */
ATSlocal (ats_ptr_type, tmp63) ;
ATSlocal (ats_ptr_type, tmp64) ;
// ATSlocal_void (tmp65) ;

__ats_lab_ATS_2d0_2e2_2e12_2prelude_2SATS_2filebas_2esats__char_list_vt_make_file_len:
/* ats_ptr_type tmp64 ; */
/* tmp65 = */ loop_18 (arg0, (&tmp64), ats_castfn_mac(ats_ssize_type, ats_castfn_mac(ats_size_type, arg1))) ;
tmp63 = tmp64 ;
return (tmp63) ;
} /* end of [ATS_2d0_2e2_2e12_2prelude_2SATS_2filebas_2esats__char_list_vt_make_file_len] */

/*
// /nix/store/rfja8ixrs5wb4kj3kiwlch1apnh7qgvy-ats-0.2.12/lib/ats-anairiats-0.2.12/prelude/DATS/filebas.dats: 8179(line=347, offs=11) -- 8427(line=356, offs=22)
*/
ATSstaticdec()
ats_ptr_type
__ats_fun_22 (ats_ptr_type env0) {
/* local vardec */
ATSlocal (ats_ptr_type, tmp67) ;
ATSlocal (ats_int_type, tmp68) ;
ATSlocal (ats_bool_type, tmp69) ;
ATSlocal (ats_char_type, tmp70) ;
ATSlocal (ats_ptr_type, tmp71) ;
// ATSlocal_void (tmp72) ;

__ats_lab___ats_fun_22:
tmp68 = atslib_fgetc_err (env0) ;
tmp69 = atspre_neq_int_int (tmp68, EOF) ;
if (tmp69) {
tmp70 = atspre_char_of_int (tmp68) ;
tmp71 = ATS_2d0_2e2_2e12_2prelude_2SATS_2filebas_2esats__char_stream_make_file (env0) ;
tmp67 = ATS_MALLOC(sizeof(anairiats_sum_0)) ;
ats_selptrset_mac(anairiats_sum_0, tmp67, atslab_0, tmp70) ;
ats_selptrset_mac(anairiats_sum_0, tmp67, atslab_1, tmp71) ;
} else {
/* tmp72 = */ atslib_fclose_exn (env0) ;
tmp67 = (ats_sum_ptr_type)0 ;
} /* end of [if] */
return (tmp67) ;
} /* end of [__ats_fun_22] */

typedef struct {
ats_fun_ptr_type closure_fun ;
ats_ptr_type closure_env_0 ;
} __ats_fun_22_closure_type ;

ats_ptr_type
__ats_fun_22_clofun (ats_clo_ptr_type cloptr) {
return __ats_fun_22 (((__ats_fun_22_closure_type*)cloptr)->closure_env_0) ;
} /* end of function */

ATSinline()
ats_void_type
__ats_fun_22_closure_init (__ats_fun_22_closure_type *p_clo, ats_ptr_type env0) {
p_clo->closure_fun = (ats_fun_ptr_type)&__ats_fun_22_clofun ;
p_clo->closure_env_0 = env0 ;
return ;
} /* end of function */

ats_clo_ptr_type
__ats_fun_22_closure_make (ats_ptr_type env0) {
__ats_fun_22_closure_type *p_clo = ATS_MALLOC(sizeof(__ats_fun_22_closure_type)) ;
__ats_fun_22_closure_init (p_clo, env0) ;
return (ats_clo_ptr_type)p_clo ;
} /* end of function */

/*
// /nix/store/rfja8ixrs5wb4kj3kiwlch1apnh7qgvy-ats-0.2.12/lib/ats-anairiats-0.2.12/prelude/DATS/filebas.dats: 8171(line=347, offs=3) -- 8427(line=356, offs=22)
*/
ATSglobaldec()
ats_ptr_type
ATS_2d0_2e2_2e12_2prelude_2SATS_2filebas_2esats__char_stream_make_file (ats_ptr_type arg0) {
/* local vardec */
ATSlocal (ats_ptr_type, tmp66) ;

__ats_lab_ATS_2d0_2e2_2e12_2prelude_2SATS_2filebas_2esats__char_stream_make_file:
ats_instr_move_lazy_delay_mac (tmp66, ats_ptr_type, __ats_fun_22_closure_make (arg0)) ;
return (tmp66) ;
} /* end of [ATS_2d0_2e2_2e12_2prelude_2SATS_2filebas_2esats__char_stream_make_file] */

/*
// /nix/store/rfja8ixrs5wb4kj3kiwlch1apnh7qgvy-ats-0.2.12/lib/ats-anairiats-0.2.12/prelude/DATS/filebas.dats: 8531(line=363, offs=11) -- 8815(line=372, offs=24)
*/
ATSstaticdec()
ats_ptr_type
__ats_fun_24 (ats_ptr_type env0) {
/* local vardec */
ATSlocal (ats_ptr_type, tmp74) ;
ATSlocal (ats_ptr_type, tmp75) ;
ATSlocal (ats_bool_type, tmp76) ;
ATSlocal (ats_ptr_type, tmp77) ;
// ATSlocal_void (tmp78) ;

__ats_lab___ats_fun_24:
tmp75 = ATS_2d0_2e2_2e12_2prelude_2SATS_2filebas_2esats__input_line (env0) ;
tmp76 = atspre_stropt_is_some (tmp75) ;
if (tmp76) {
tmp77 = ATS_2d0_2e2_2e12_2prelude_2SATS_2filebas_2esats__line_stream_make_file (env0) ;
tmp74 = ATS_MALLOC(sizeof(anairiats_sum_1)) ;
ats_selptrset_mac(anairiats_sum_1, tmp74, atslab_0, ats_castfn_mac(ats_ptr_type, tmp75)) ;
ats_selptrset_mac(anairiats_sum_1, tmp74, atslab_1, tmp77) ;
} else {
/* tmp78 = */ atslib_fclose_exn (env0) ;
tmp74 = (ats_sum_ptr_type)0 ;
} /* end of [if] */
return (tmp74) ;
} /* end of [__ats_fun_24] */

typedef struct {
ats_fun_ptr_type closure_fun ;
ats_ptr_type closure_env_0 ;
} __ats_fun_24_closure_type ;

ats_ptr_type
__ats_fun_24_clofun (ats_clo_ptr_type cloptr) {
return __ats_fun_24 (((__ats_fun_24_closure_type*)cloptr)->closure_env_0) ;
} /* end of function */

ATSinline()
ats_void_type
__ats_fun_24_closure_init (__ats_fun_24_closure_type *p_clo, ats_ptr_type env0) {
p_clo->closure_fun = (ats_fun_ptr_type)&__ats_fun_24_clofun ;
p_clo->closure_env_0 = env0 ;
return ;
} /* end of function */

ats_clo_ptr_type
__ats_fun_24_closure_make (ats_ptr_type env0) {
__ats_fun_24_closure_type *p_clo = ATS_MALLOC(sizeof(__ats_fun_24_closure_type)) ;
__ats_fun_24_closure_init (p_clo, env0) ;
return (ats_clo_ptr_type)p_clo ;
} /* end of function */

/*
// /nix/store/rfja8ixrs5wb4kj3kiwlch1apnh7qgvy-ats-0.2.12/lib/ats-anairiats-0.2.12/prelude/DATS/filebas.dats: 8523(line=363, offs=3) -- 8815(line=372, offs=24)
*/
ATSglobaldec()
ats_ptr_type
ATS_2d0_2e2_2e12_2prelude_2SATS_2filebas_2esats__line_stream_make_file (ats_ptr_type arg0) {
/* local vardec */
ATSlocal (ats_ptr_type, tmp73) ;

__ats_lab_ATS_2d0_2e2_2e12_2prelude_2SATS_2filebas_2esats__line_stream_make_file:
ats_instr_move_lazy_delay_mac (tmp73, ats_ptr_type, __ats_fun_24_closure_make (arg0)) ;
return (tmp73) ;
} /* end of [ATS_2d0_2e2_2e12_2prelude_2SATS_2filebas_2esats__line_stream_make_file] */

/*
// /nix/store/rfja8ixrs5wb4kj3kiwlch1apnh7qgvy-ats-0.2.12/lib/ats-anairiats-0.2.12/prelude/DATS/filebas.dats: 8969(line=381, offs=5) -- 9381(line=397, offs=2)
*/
ATSstaticdec()
ats_ptr_type
__ats_fun_26 (ats_ptr_type env0, ats_bool_type arg0) {
/* local vardec */
ATSlocal (ats_ptr_type, tmp80) ;
ATSlocal (ats_int_type, tmp81) ;
ATSlocal (ats_bool_type, tmp82) ;
ATSlocal (ats_char_type, tmp83) ;
ATSlocal (ats_ptr_type, tmp84) ;
// ATSlocal_void (tmp85) ;

__ats_lab___ats_fun_26:
if (arg0) {
tmp81 = atslib_fgetc_err (env0) ;
tmp82 = atspre_gte_int_int (tmp81, 0) ;
if (tmp82) {
tmp83 = atspre_char_of_int (tmp81) ;
tmp84 = ATS_2d0_2e2_2e12_2prelude_2SATS_2filebas_2esats__char_stream_vt_make_file (env0) ;
tmp80 = ATS_MALLOC(sizeof(anairiats_sum_0)) ;
ats_selptrset_mac(anairiats_sum_0, tmp80, atslab_0, tmp83) ;
ats_selptrset_mac(anairiats_sum_0, tmp80, atslab_1, tmp84) ;
} else {
/* tmp85 = */ atslib_fclose_exn (env0) ;
tmp80 = (ats_sum_ptr_type)0 ;
} /* end of [if] */
} else {
/* tmp80 = */ atslib_fclose_exn (env0) ;
} /* end of [if] */
return (tmp80) ;
} /* end of [__ats_fun_26] */

typedef struct {
ats_fun_ptr_type closure_fun ;
ats_ptr_type closure_env_0 ;
} __ats_fun_26_closure_type ;

ats_ptr_type
__ats_fun_26_clofun (ats_clo_ptr_type cloptr, ats_bool_type arg0) {
return __ats_fun_26 (((__ats_fun_26_closure_type*)cloptr)->closure_env_0, arg0) ;
} /* end of function */

ATSinline()
ats_void_type
__ats_fun_26_closure_init (__ats_fun_26_closure_type *p_clo, ats_ptr_type env0) {
p_clo->closure_fun = (ats_fun_ptr_type)&__ats_fun_26_clofun ;
p_clo->closure_env_0 = env0 ;
return ;
} /* end of function */

ats_clo_ptr_type
__ats_fun_26_closure_make (ats_ptr_type env0) {
__ats_fun_26_closure_type *p_clo = ATS_MALLOC(sizeof(__ats_fun_26_closure_type)) ;
__ats_fun_26_closure_init (p_clo, env0) ;
return (ats_clo_ptr_type)p_clo ;
} /* end of function */

/*
// /nix/store/rfja8ixrs5wb4kj3kiwlch1apnh7qgvy-ats-0.2.12/lib/ats-anairiats-0.2.12/prelude/DATS/filebas.dats: 8938(line=379, offs=11) -- 9381(line=397, offs=2)
*/
ATSglobaldec()
ats_ptr_type
ATS_2d0_2e2_2e12_2prelude_2SATS_2filebas_2esats__char_stream_vt_make_file (ats_ptr_type arg0) {
/* local vardec */
ATSlocal (ats_ptr_type, tmp79) ;

__ats_lab_ATS_2d0_2e2_2e12_2prelude_2SATS_2filebas_2esats__char_stream_vt_make_file:
ats_instr_move_lazy_ldelay_mac (tmp79, ats_ptr_type, __ats_fun_26_closure_make (arg0)) ;
return (tmp79) ;
} /* end of [ATS_2d0_2e2_2e12_2prelude_2SATS_2filebas_2esats__char_stream_vt_make_file] */

/*
// /nix/store/rfja8ixrs5wb4kj3kiwlch1apnh7qgvy-ats-0.2.12/lib/ats-anairiats-0.2.12/prelude/DATS/filebas.dats: 10213(line=427, offs=29) -- 10234(line=427, offs=50)
*/
ATSstaticdec()
ats_ptr_type
__ats_fun_29 (ats_bool_type arg0) {
/* local vardec */
ATSlocal (ats_ptr_type, tmp100) ;

__ats_lab___ats_fun_29:
if (arg0) {
tmp100 = (ats_sum_ptr_type)0 ;
} else {
/* empty */
} /* end of [if] */
return (tmp100) ;
} /* end of [__ats_fun_29] */

typedef struct {
ats_fun_ptr_type closure_fun ;
} __ats_fun_29_closure_type ;

ats_ptr_type
__ats_fun_29_clofun (ats_clo_ptr_type cloptr, ats_bool_type arg0) {
return __ats_fun_29 (arg0) ;
} /* end of function */

ATSinline()
ats_void_type
__ats_fun_29_closure_init (__ats_fun_29_closure_type *p_clo) {
p_clo->closure_fun = (ats_fun_ptr_type)&__ats_fun_29_clofun ;
return ;
} /* end of function */

ats_clo_ptr_type
__ats_fun_29_closure_make () {
__ats_fun_29_closure_type *p_clo = ATS_MALLOC(sizeof(__ats_fun_29_closure_type)) ;
__ats_fun_29_closure_init (p_clo) ;
return (ats_clo_ptr_type)p_clo ;
} /* end of function */

/*
// /nix/store/rfja8ixrs5wb4kj3kiwlch1apnh7qgvy-ats-0.2.12/lib/ats-anairiats-0.2.12/prelude/DATS/filebas.dats: 9524(line=405, offs=5) -- 10355(line=432, offs=4)
*/
ATSstaticdec()
ats_ptr_type
loop_28 (ats_ptr_type arg0, ats_int_type arg1, ats_ptr_type arg2) {
/* local vardec */
ATSlocal (ats_ptr_type, tmp87) ;
ATSlocal (ats_int_type, tmp88) ;
ATSlocal (ats_bool_type, tmp89) ;
ATSlocal (ats_char_type, tmp90) ;
ATSlocal (ats_bool_type, tmp91) ;
ATSlocal (ats_int_type, tmp92) ;
ATSlocal (ats_ptr_type, tmp93) ;
ATSlocal (ats_ptr_type, tmp94) ;
ATSlocal (ats_ptr_type, tmp95) ;
// ATSlocal_void (tmp96) ;
ATSlocal (ats_bool_type, tmp97) ;
ATSlocal (ats_ptr_type, tmp98) ;
ATSlocal (ats_ptr_type, tmp99) ;

__ats_lab_loop_28:
tmp88 = atslib_fgetc_err (arg0) ;
tmp89 = atspre_gte_int_int (tmp88, 0) ;
if (tmp89) {
tmp90 = atspre_char_of_int (tmp88) ;
tmp91 = atspre_neq_char_char (tmp90, '\n') ;
if (tmp91) {
tmp92 = atspre_iadd (arg1, 1) ;
tmp93 = ATS_MALLOC(sizeof(anairiats_sum_0)) ;
ats_selptrset_mac(anairiats_sum_0, tmp93, atslab_0, tmp90) ;
ats_selptrset_mac(anairiats_sum_0, tmp93, atslab_1, arg2) ;
arg0 = arg0 ;
arg1 = tmp92 ;
arg2 = tmp93 ;
goto __ats_lab_loop_28 ; // tail call
} else {
tmp94 = string_make_charlst_rev (arg1, arg2) ;
tmp95 = ATS_2d0_2e2_2e12_2prelude_2SATS_2filebas_2esats__line_stream_vt_make_file (arg0) ;
tmp87 = ATS_MALLOC(sizeof(anairiats_sum_1)) ;
ats_selptrset_mac(anairiats_sum_1, tmp87, atslab_0, tmp94) ;
ats_selptrset_mac(anairiats_sum_1, tmp87, atslab_1, tmp95) ;
} /* end of [if] */
} else {
/* tmp96 = */ atslib_fclose_exn (arg0) ;
tmp97 = atspre_igt (arg1, 0) ;
if (tmp97) {
tmp98 = string_make_charlst_rev (arg1, arg2) ;
ats_instr_move_lazy_ldelay_mac (tmp99, ats_ptr_type, __ats_fun_29_closure_make ()) ;
tmp87 = ATS_MALLOC(sizeof(anairiats_sum_1)) ;
ats_selptrset_mac(anairiats_sum_1, tmp87, atslab_0, tmp98) ;
ats_selptrset_mac(anairiats_sum_1, tmp87, atslab_1, tmp99) ;
} else {
// if (arg2 != (ats_sum_ptr_type)0) { ats_deadcode_failure_handle () ; }
tmp87 = (ats_sum_ptr_type)0 ;
} /* end of [if] */
} /* end of [if] */
return (tmp87) ;
} /* end of [loop_28] */

/*
// /nix/store/rfja8ixrs5wb4kj3kiwlch1apnh7qgvy-ats-0.2.12/lib/ats-anairiats-0.2.12/prelude/DATS/filebas.dats: 10385(line=436, offs=1) -- 10525(line=442, offs=2)
*/
ATSstaticdec()
ats_ptr_type
__ats_fun_30 (ats_ptr_type env0, ats_bool_type arg0) {
/* local vardec */
ATSlocal (ats_ptr_type, tmp101) ;
ATSlocal (ats_ptr_type, tmp102) ;

__ats_lab___ats_fun_30:
if (arg0) {
tmp102 = (ats_sum_ptr_type)0 ;
tmp101 = loop_28 (env0, 0, tmp102) ;
} else {
/* tmp101 = */ atslib_fclose_exn (env0) ;
} /* end of [if] */
return (tmp101) ;
} /* end of [__ats_fun_30] */

typedef struct {
ats_fun_ptr_type closure_fun ;
ats_ptr_type closure_env_0 ;
} __ats_fun_30_closure_type ;

ats_ptr_type
__ats_fun_30_clofun (ats_clo_ptr_type cloptr, ats_bool_type arg0) {
return __ats_fun_30 (((__ats_fun_30_closure_type*)cloptr)->closure_env_0, arg0) ;
} /* end of function */

ATSinline()
ats_void_type
__ats_fun_30_closure_init (__ats_fun_30_closure_type *p_clo, ats_ptr_type env0) {
p_clo->closure_fun = (ats_fun_ptr_type)&__ats_fun_30_clofun ;
p_clo->closure_env_0 = env0 ;
return ;
} /* end of function */

ats_clo_ptr_type
__ats_fun_30_closure_make (ats_ptr_type env0) {
__ats_fun_30_closure_type *p_clo = ATS_MALLOC(sizeof(__ats_fun_30_closure_type)) ;
__ats_fun_30_closure_init (p_clo, env0) ;
return (ats_clo_ptr_type)p_clo ;
} /* end of function */

/*
// /nix/store/rfja8ixrs5wb4kj3kiwlch1apnh7qgvy-ats-0.2.12/lib/ats-anairiats-0.2.12/prelude/DATS/filebas.dats: 9486(line=403, offs=11) -- 10552(line=444, offs=4)
*/
ATSglobaldec()
ats_ptr_type
ATS_2d0_2e2_2e12_2prelude_2SATS_2filebas_2esats__line_stream_vt_make_file (ats_ptr_type arg0) {
/* local vardec */
ATSlocal (ats_ptr_type, tmp86) ;

__ats_lab_ATS_2d0_2e2_2e12_2prelude_2SATS_2filebas_2esats__line_stream_vt_make_file:
ats_instr_move_lazy_ldelay_mac (tmp86, ats_ptr_type, __ats_fun_30_closure_make (arg0)) ;
return (tmp86) ;
} /* end of [ATS_2d0_2e2_2e12_2prelude_2SATS_2filebas_2esats__line_stream_vt_make_file] */

/* static load function */

// extern ats_void_type ATS_2d0_2e2_2e12_2prelude_2SATS_2filebas_2esats__staload (void) ;
extern ats_void_type ATS_2d0_2e2_2e12_2libc_2sys_2SATS_2stat_2esats__staload (void) ;
extern ats_void_type ATS_2d0_2e2_2e12_2libc_2sys_2SATS_2types_2esats__staload (void) ;

ats_void_type
ATS_2d0_2e2_2e12_2prelude_2DATS_2filebas_2edats__staload () {
static int ATS_2d0_2e2_2e12_2prelude_2DATS_2filebas_2edats__staload_flag = 0 ;
if (ATS_2d0_2e2_2e12_2prelude_2DATS_2filebas_2edats__staload_flag) return ;
ATS_2d0_2e2_2e12_2prelude_2DATS_2filebas_2edats__staload_flag = 1 ;

// ATS_2d0_2e2_2e12_2prelude_2SATS_2filebas_2esats__staload () ;
ATS_2d0_2e2_2e12_2libc_2sys_2SATS_2stat_2esats__staload () ;
ATS_2d0_2e2_2e12_2libc_2sys_2SATS_2types_2esats__staload () ;

return ;
} /* staload function */

/* dynamic load function */

// dynload flag declaration
// extern ats_int_type ATS_2d0_2e2_2e12_2prelude_2DATS_2filebas_2edats__dynload_flag ;

ats_void_type
ATS_2d0_2e2_2e12_2prelude_2DATS_2filebas_2edats__dynload () {
// ATS_2d0_2e2_2e12_2prelude_2DATS_2filebas_2edats__dynload_flag = 1 ;
ATS_2d0_2e2_2e12_2prelude_2DATS_2filebas_2edats__staload () ;

#ifdef _ATS_PROOFCHECK
#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_filebas_dats.c] */
