/* Compiler: ECL 26.3.27                                                      */
/* Source: /build/ecl/src/ecl-26.3.27/src/cmp/cmptype-prop.lsp                */
#include <ecl/ecl-cmp.h>
#include "cmp/cmptype-prop.eclh"
/* function definition for INFER-ARG-AND-RETURN-TYPES                         */
/* optimize speed 1, debug 1, space 1, safety 2                               */
static cl_object L3415infer_arg_and_return_types(cl_narg narg, cl_object v1fname, cl_object v2forms, ...)
{
 cl_object T0, T1, T2;
 cl_object env0 = ECL_NIL;
 const cl_env_ptr cl_env_copy = ecl_process_env();
 cl_object value0;
 ecl_cs_check(cl_env_copy,value0);
 if (ecl_unlikely(narg<2)) FEwrong_num_arguments(VV[1]);
 if (ecl_unlikely(narg>3)) FEwrong_num_arguments(VV[1]);
 {
  cl_object v3env;
  va_list args; va_start(args,v2forms);
  {
   int i = 2;
   if (i >= narg) {
    v3env = ecl_cmp_symbol_value(cl_env_copy,VV[0]);
   } else {
    i++;
    v3env = va_arg(args,cl_object);
   }
  }
  va_end(args);
  {
   cl_object v4;
   cl_object v5found;
   cl_object v6arg_types;
   cl_object v7return_type;
   v4 = ecl_gethash_safe(v1fname,ecl_cmp_symbol_value(cl_env_copy,VV[2]),ECL_NIL);
   v5found = v4;
   v6arg_types = ECL_NIL;
   v7return_type = VV[3];
   if (Null(v5found)){
    goto L7;
   }
   {
    cl_object v8;
    v8 = ecl_fdefinition(VV[4]);
    {
     cl_object v9;
     cl_object v10;
     cl_object v11;
     {
      cl_object v12;
      v12 = v2forms;
      if (ecl_unlikely(!ECL_LISTP(v12))) FEtype_error_list(v12);
      value0 = ECL_NIL;
      cl_env_copy->nvalues = 0;
      v9 = v12;
     }
     v10 = ECL_NIL;
     v11 = v9;
     {
      cl_object v12;
      cl_object v13;
      v12 = ecl_list1(ECL_NIL);
      v13 = v12;
L19:;
      if (!(ecl_endp(v11))){
       goto L21;
      }
      goto L20;
L21:;
      v10 = ECL_CONS_CAR(v11);
      {
       cl_object v14;
       v14 = ECL_CONS_CDR(v11);
       if (ecl_unlikely(!ECL_LISTP(v14))) FEtype_error_list(v14);
       value0 = ECL_NIL;
       cl_env_copy->nvalues = 0;
       v11 = v14;
      }
      {
       cl_object v14;
       v14 = v13;
       if (ecl_unlikely(ECL_ATOM(v14))) FEtype_error_cons(v14);
       value0 = ECL_NIL;
       cl_env_copy->nvalues = 0;
       T1 = v14;
      }
      T2 = ecl_function_dispatch(cl_env_copy,v8)(1, v10);
      v13 = ecl_list1(T2);
      (ECL_CONS_CDR(T1)=v13,T1);
      goto L19;
L20:;
      T0 = ecl_cdr(v12);
      goto L10;
     }
    }
   }
L10:;
   value0 = cl_apply(3, v5found, v1fname, T0);
   {
    const int v8 = cl_env_copy->nvalues;
    v6arg_types = value0;
    cl_object v9;
    v9 = (v8<=1)? ECL_NIL : cl_env_copy->values[1];
    v7return_type = v9;
   }
   goto L6;
L7:;
   value0 = (cl_env_copy->function=ecl_fdefinition(VV[10]))->cfun.entry(2, v1fname, v3env) /*  GET-ARG-TYPES */;
   {
    const int v8 = cl_env_copy->nvalues;
    v6arg_types = value0;
    cl_object v9;
    v9 = (v8<=1)? ECL_NIL : cl_env_copy->values[1];
    v5found = v9;
   }
   if (Null(value0)){
    goto L6;
   }
   value0 = (cl_env_copy->function=ecl_fdefinition(VV[11]))->cfun.entry(1, v1fname) /*  GET-RETURN-TYPE */;
   if (value0!=ECL_NIL) {
    goto L41;
   }
   goto L39;
L41:;
   v7return_type = value0;
   goto L39;
L39:;
L6:;
   cl_env_copy->nvalues = 3;
   cl_env_copy->values[2] = v5found;
   cl_env_copy->values[1] = v7return_type;
   cl_env_copy->values[0] = v6arg_types;
   return cl_env_copy->values[0];
  }
 }
}
/* function definition for ENFORCE-TYPES                                      */
/* optimize speed 1, debug 1, space 1, safety 2                               */
static cl_object L3416enforce_types(cl_object v1fname, cl_object v2arg_types, cl_object v3arguments)
{
 cl_object T0;
 cl_object env0 = ECL_NIL;
 const cl_env_ptr cl_env_copy = ecl_process_env();
 cl_object value0;
 ecl_cs_check(cl_env_copy,value0);
L1:;
 {
  cl_object v4types;
  cl_object v5args;
  cl_object v6i;
  cl_object v7in_optionals;
  v4types = v2arg_types;
  v5args = v3arguments;
  v6i = ecl_make_int8_t(1);
  v7in_optionals = ECL_NIL;
  goto L8;
L7:;
  {
   cl_object v8expected_type;
   v8expected_type = ecl_car(v4types);
   {
    cl_object v9;
    v9 = (ECL_SYM("EQ",335)->symbol.gfdef);
    if (!((v8expected_type)==(ECL_SYM("*",20)))){
     goto L18;
    }
    goto L15;
L18:;
    goto L16;
L16:;
    if (!((v8expected_type)==(ECL_SYM("&REST",14)))){
     goto L22;
    }
    goto L15;
L22:;
    goto L20;
L20:;
    if (!((v8expected_type)==(ECL_SYM("&KEY",12)))){
     goto L26;
    }
    goto L15;
L26:;
    goto L24;
L24:;
    if (!((v8expected_type)==(ECL_SYM("&ALLOW-OTHER-KEYS",8)))){
     goto L12;
    }
    goto L13;
L15:;
   }
L13:;
   value0 = ECL_NIL;
   cl_env_copy->nvalues = 1;
   return value0;
L12:;
   if (!((v8expected_type)==(ECL_SYM("&OPTIONAL",13)))){
    goto L29;
   }
   if (Null(v7in_optionals)){
    goto L31;
   }
   (cl_env_copy->function=ecl_fdefinition(VV[18]))->cfun.entry(3, VV[19], v1fname, v2arg_types) /*  CMPWARN */;
L31:;
   v7in_optionals = ECL_T;
   v4types = ecl_cdr(v4types);
   goto L10;
L29:;
   if (!(ecl_endp(v5args))){
    goto L36;
   }
   if (v7in_optionals!=ECL_NIL) {
    goto L38;
   }
   (cl_env_copy->function=ecl_fdefinition(VV[18]))->cfun.entry(2, VV[20], v1fname) /*  CMPWARN */;
L38:;
   value0 = ECL_NIL;
   cl_env_copy->nvalues = 1;
   return value0;
L36:;
   {
    cl_object v9value;
    cl_object v10actual_type;
    cl_object v11intersection;
    v9value = ecl_car(v5args);
    v10actual_type = (cl_env_copy->function=ecl_fdefinition(VV[4]))->cfun.entry(1, v9value) /*  LOCATION-PRIMARY-TYPE */;
    v11intersection = (cl_env_copy->function=ecl_fdefinition(VV[21]))->cfun.entry(2, v10actual_type, v8expected_type) /*  TYPE-AND */;
    if (v11intersection!=ECL_NIL) {
     goto L43;
    }
    (cl_env_copy->function=ecl_fdefinition(VV[22]))->cfun.entry(5, VV[23], v6i, v1fname, v10actual_type, v8expected_type) /*  CMPWARN-STYLE */;
L43:;
    T0 = (cl_env_copy->function=ecl_fdefinition(VV[24]))->cfun.entry(1, ECL_SYM("SAFETY",737)) /*  CMP-ENV-OPTIMIZATION */;
    if (!(ecl_zerop(T0))){
     goto L10;
    }
    ecl_structure_set(v9value,VV[25],(cl_fixnum)(1),v11intersection);
   }
  }
L10:;
  v4types = ecl_cdr(v4types);
  v5args = ecl_cdr(v5args);
  v6i = ecl_one_plus(v6i);
L8:;
  if (ecl_endp(v4types)) {
   goto L52;
  }
  goto L7;
L52:;
  if (Null(v4types)){
   goto L54;
  }
  value0 = (cl_env_copy->function=ecl_fdefinition(VV[18]))->cfun.entry(2, VV[26], v1fname) /*  CMPWARN */;
  return value0;
L54:;
  value0 = ECL_NIL;
  cl_env_copy->nvalues = 1;
  return value0;
 }
}
static cl_object L3416enforce_types_va(cl_narg narg, cl_object v8fname, cl_object v9arg_types, cl_object v10arguments, ...)
{
 if (ecl_unlikely(narg!=3)) FEwrong_num_arguments(VV[13]);
 {
  return L3416enforce_types(v8fname, v9arg_types, v10arguments);
 }
}
/* function definition for PROPAGATE-TYPES                                    */
/* optimize speed 1, debug 1, space 1, safety 2                               */
static cl_object L3417propagate_types(cl_object v1fname, cl_object v2forms)
{
 cl_object env0 = ECL_NIL;
 const cl_env_ptr cl_env_copy = ecl_process_env();
 cl_object value0;
 ecl_cs_check(cl_env_copy,value0);
L1:;
 {
  cl_object v3;                                   /*  ARG-TYPES               */
  cl_object v4;                                   /*  RETURN-TYPE             */
  cl_object v5;                                   /*  FOUND                   */
  value0 = L3415infer_arg_and_return_types(2, v1fname, v2forms);
  {
   const int v6 = cl_env_copy->nvalues;
   v3 = value0;
   cl_object v7;
   v7 = (v6<=1)? ECL_NIL : cl_env_copy->values[1];
   v4 = v7;
   v7 = (v6<=2)? ECL_NIL : cl_env_copy->values[2];
   v5 = v7;
  }
  if (Null(v5)){
   goto L3;
  }
  L3416enforce_types(v1fname, v3, v2forms);
L3:;
  value0 = v4;
  cl_env_copy->nvalues = 1;
  return value0;
 }
}
static cl_object L3417propagate_types_va(cl_narg narg, cl_object v3fname, cl_object v4forms, ...)
{
 if (ecl_unlikely(narg!=2)) FEwrong_num_arguments(VV[28]);
 {
  return L3417propagate_types(v3fname, v4forms);
 }
}
/* local function DEF-TYPE-PROPAGATOR                                         */
/* optimize speed 1, debug 1, space 1, safety 2                               */
static cl_object LC3418def_type_propagator(cl_object v1, cl_object v2)
{
 cl_object T0, T1, T2, T3, T4, T5, T6;
 cl_object env0 = ECL_NIL;
 const cl_env_ptr cl_env_copy = ecl_process_env();
 cl_object value0;
 ecl_cs_check(cl_env_copy,value0);
L1:;
 {
  cl_object v3;
  cl_object v4fname;
  cl_object v5lambda_list;
  cl_object v6body;
  v3 = ecl_cdr(v1);
  if (!(v3==ECL_NIL)){
   goto L4;
  }
  si_dm_too_few_arguments(v1);
L4:;
  {
   cl_object v7;
   v7 = ecl_car(v3);
   v3 = ecl_cdr(v3);
   v4fname = v7;
  }
  if (!(v3==ECL_NIL)){
   goto L10;
  }
  si_dm_too_few_arguments(v1);
L10:;
  {
   cl_object v7;
   v7 = ecl_car(v3);
   v3 = ecl_cdr(v3);
   v5lambda_list = v7;
  }
  v6body = v3;
  {
   cl_object v7;
   cl_object v8;
   v7 = ECL_SYM("&REST",14);
   v8 = v5lambda_list;
   if (ecl_memql(v7,v8)!=ECL_NIL) {
    goto L16;
   }
  }
  {
   cl_object v7var;
   v7var = cl_gensym(0);
   T0 = cl_list(2, ECL_SYM("&REST",14), v7var);
   v5lambda_list = ecl_append(v5lambda_list,T0);
   T0 = cl_list(2, ECL_SYM("IGNORABLE",429), v7var);
   T1 = cl_list(2, ECL_SYM("DECLARE",276), T0);
   v6body = CONS(T1,v6body);
  }
L16:;
  T0 = cl_list(2, ECL_SYM("QUOTE",682), v4fname);
  T1 = cl_list(3, ECL_SYM("GETHASH",415), T0, VV[2]);
  T2 = ecl_car(v5lambda_list);
  T3 = cl_list(2, ECL_SYM("IGNORABLE",429), T2);
  T4 = cl_list(2, ECL_SYM("DECLARE",276), T3);
  T5 = cl_listX(4, ECL_SYM("LAMBDA",454), v5lambda_list, T4, v6body);
  T6 = cl_list(2, ECL_SYM("FUNCTION",398), T5);
  value0 = cl_list(3, ECL_SYM("SETF",753), T1, T6);
  return value0;
 }
}
static cl_object LC3418def_type_propagator_va(cl_narg narg, cl_object v7, cl_object v8, ...)
{
 if (ecl_unlikely(narg!=2)) FEwrong_num_arguments(VV[31]);
 {
  return LC3418def_type_propagator(v7, v8);
 }
}
/* function definition for COPY-TYPE-PROPAGATOR                               */
/* optimize speed 1, debug 1, space 1, safety 2                               */
static cl_object L3419copy_type_propagator(cl_object v1orig, cl_object v2dest_list)
{
 cl_object env0 = ECL_NIL;
 const cl_env_ptr cl_env_copy = ecl_process_env();
 cl_object value0;
 ecl_cs_check(cl_env_copy,value0);
L1:;
 {
  cl_object v3function;
  v3function = ecl_gethash_safe(v1orig,ecl_cmp_symbol_value(cl_env_copy,VV[2]),ECL_NIL);
  {
   cl_object v4;
   cl_object v5name;
   cl_object v6;
   {
    cl_object v7;
    v7 = v2dest_list;
    if (ecl_unlikely(!ECL_LISTP(v7))) FEtype_error_list(v7);
    value0 = ECL_NIL;
    cl_env_copy->nvalues = 0;
    v4 = v7;
   }
   v5name = ECL_NIL;
   v6 = v4;
L8:;
   if (!(ecl_endp(v6))){
    goto L10;
   }
   goto L9;
L10:;
   v5name = ECL_CONS_CAR(v6);
   {
    cl_object v7;
    v7 = ECL_CONS_CDR(v6);
    if (ecl_unlikely(!ECL_LISTP(v7))) FEtype_error_list(v7);
    value0 = ECL_NIL;
    cl_env_copy->nvalues = 0;
    v6 = v7;
   }
   if (Null(v3function)){
    goto L18;
   }
   si_hash_set(v5name, ecl_cmp_symbol_value(cl_env_copy,VV[2]), v3function);
L18:;
   goto L8;
L9:;
   value0 = ECL_NIL;
   cl_env_copy->nvalues = 1;
   return value0;
  }
 }
}
static cl_object L3419copy_type_propagator_va(cl_narg narg, cl_object v7orig, cl_object v8dest_list, ...)
{
 if (ecl_unlikely(narg!=2)) FEwrong_num_arguments(VV[33]);
 {
  return L3419copy_type_propagator(v7orig, v8dest_list);
 }
}
#include "cmp/cmptype-prop.data"
#ifdef __cplusplus
extern "C"
#endif

ECL_DLLEXPORT void _eclQV7Nhk42G83l9_WDS0M881(cl_object flag)
{
 const cl_env_ptr cl_env_copy = ecl_process_env();
 cl_object value0;
 cl_object *VVtemp;
 if (flag != OBJNULL){
 Cblock = flag;
 #ifndef ECL_DYNAMIC_VV
 flag->cblock.data = VV;
 #endif
 flag->cblock.data_size = VM;
 flag->cblock.temp_data_size = VMtemp;
 flag->cblock.data_text = compiler_data_text;
 flag->cblock.cfuns_size = compiler_cfuns_size;
 flag->cblock.cfuns = compiler_cfuns;
 flag->cblock.source = ecl_make_constant_base_string("SRC:CMP;CMPTYPE-PROP.LSP.NEWEST",-1);
 return;}
 #ifdef ECL_DYNAMIC_VV
 VV = Cblock->cblock.data;
 #endif
 Cblock->cblock.data_text = (const cl_object *)"@EcLtAg:_eclQV7Nhk42G83l9_WDS0M881@";
 VVtemp = Cblock->cblock.temp_data;
 ECL_DEFINE_SETF_FUNCTIONS
/* MAKE-LOAD-FORMs                                                            */
/* TOP-LEVEL-FORMs                                                            */
  si_select_package(VVtemp[0]);
  ecl_cmp_defun(VV[35]);                          /*  INFER-ARG-AND-RETURN-TYPES */
  ecl_cmp_defun(VV[36]);                          /*  ENFORCE-TYPES           */
  ecl_cmp_defun(VV[37]);                          /*  PROPAGATE-TYPES         */
  ecl_cmp_defmacro(VV[38]);                       /*  DEF-TYPE-PROPAGATOR     */
  ecl_cmp_defun(VV[39]);                          /*  COPY-TYPE-PROPAGATOR    */
}
