/* Compiler: ECL 26.3.27                                                      */
/* Source: /build/ecl/src/ecl-26.3.27/contrib/ecl-cdb/ecl-help.lisp           */
#include <ecl/ecl-cmp.h>
#include "clos/ecl-help.eclh"
/* function definition for TO-CDB-VECTOR                                      */
/* optimize speed 1, debug 1, space 1, safety 2                               */
static cl_object L2927to_cdb_vector(cl_object v1object)
{
 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 v2vector;
  cl_object v3stream;
  T0 = si_make_vector(ECL_SYM("BYTE8",1368), ecl_make_uint8_t(128), ECL_T, ecl_make_int8_t(0), ECL_NIL, ecl_make_int8_t(0));
  v2vector = si_fill_array_with_elt(T0, ecl_make_int8_t(0), ecl_make_int8_t(0), ECL_NIL);
  v3stream = si_make_sequence_output_stream(3, v2vector, ECL_SYM("EXTERNAL-FORMAT",1267), ECL_SYM("UTF-8",1759));
  {
   cl_object v4;
   v4 = ecl_cmp_symbol_value(cl_env_copy,ECL_SYM("+IO-SYNTAX-PROGV-LIST+",1805));
   {
    cl_object v6, v7; cl_index v5;
    v6 = ECL_CONS_CAR(v4);
    v7 = ECL_CONS_CDR(v4);
    v5 = ecl_progv(cl_env_copy, v6, v7);
    T0 = cl_find_package(VV[1]);
    ecl_bds_bind(cl_env_copy,ECL_SYM("*PRINT-PACKAGE*",1032),T0); /*  *PRINT-PACKAGE* */
    cl_write(9, v1object, ECL_SYM("STREAM",1350), v3stream, ECL_SYM("PRETTY",1326), ECL_NIL, ECL_SYM("READABLY",1333), ECL_NIL, ECL_SYM("ESCAPE",1261), ECL_T);
    ecl_bds_unwind(cl_env_copy,v5);
   }
  }
  value0 = v2vector;
  cl_env_copy->nvalues = 1;
  return value0;
 }
}
static cl_object L2927to_cdb_vector_va(cl_narg narg, cl_object v4object, ...)
{
 if (ecl_unlikely(narg!=1)) FEwrong_num_arguments(VV[0]);
 {
  return L2927to_cdb_vector(v4object);
 }
}
/* function definition for FROM-CDB-VECTOR                                    */
/* optimize speed 1, debug 1, space 1, safety 2                               */
static cl_object L2928from_cdb_vector(cl_object v1vector)
{
 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 v2stream;
  v2stream = si_make_sequence_input_stream(3, v1vector, ECL_SYM("EXTERNAL-FORMAT",1267), ECL_SYM("UTF-8",1759));
  value0 = cl_read(4, v2stream, ECL_NIL, ECL_NIL, ECL_NIL);
  return value0;
 }
}
static cl_object L2928from_cdb_vector_va(cl_narg narg, cl_object v3vector, ...)
{
 if (ecl_unlikely(narg!=1)) FEwrong_num_arguments(VV[3]);
 {
  return L2928from_cdb_vector(v3vector);
 }
}
/* function definition for SEARCH-HELP-FILE                                   */
/* optimize speed 1, debug 1, space 1, safety 2                               */
static cl_object L2929search_help_file(cl_object v1string, cl_object v2path)
{
 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 v3key;
  cl_object v4value;
  v3key = L2927to_cdb_vector(v1string);
  v4value = (cl_env_copy->function=ecl_fdefinition(VV[6]))->cfun.entry(2, v3key, v2path) /*  LOOKUP-CDB */;
  if (Null(v4value)){
   goto L4;
  }
  value0 = L2928from_cdb_vector(v4value);
  return value0;
L4:;
  value0 = ECL_NIL;
  cl_env_copy->nvalues = 1;
  return value0;
 }
}
static cl_object L2929search_help_file_va(cl_narg narg, cl_object v5string, cl_object v6path, ...)
{
 if (ecl_unlikely(narg!=2)) FEwrong_num_arguments(VV[5]);
 {
  return L2929search_help_file(v5string, v6path);
 }
}
/* function definition for DUMP-HELP-FILE                                     */
/* optimize speed 1, debug 1, space 1, safety 2                               */
static cl_object L2930dump_help_file(volatile cl_narg narg, cl_object volatile v1hash_table, cl_object volatile v2path, ...)
{
 cl_object T0, T1;
 cl_object volatile env0 = ECL_NIL;
 const cl_env_ptr cl_env_copy = ecl_process_env();
 cl_object volatile value0;
 ecl_cs_check(cl_env_copy,value0);
 if (ecl_unlikely(narg<2)) FEwrong_num_arguments(VV[8]);
 if (ecl_unlikely(narg>4)) FEwrong_num_arguments(VV[8]);
 {
  cl_object volatile v3merge;
  cl_object volatile v4test;
  va_list args; va_start(args,v2path);
  {
   int i = 2;
   if (i >= narg) {
    v3merge = ECL_NIL;
   } else {
    i++;
    v3merge = va_arg(args,cl_object);
   }
   if (i >= narg) {
    v4test = ECL_NIL;
   } else {
    i++;
    v4test = va_arg(args,cl_object);
   }
  }
  va_end(args);
  if (Null(v3merge)){
   goto L3;
  }
  cl_error(1, VV[9]);
L3:;
  {
   volatile cl_object v5cdb;
   v5cdb = ECL_NIL;
   {
    struct ecl_stack_frame _ecl_inner_frame_aux;
    volatile cl_object _ecl_inner_frame=ecl_stack_frame_open(cl_env_copy,(cl_object)&_ecl_inner_frame_aux,0);
    volatile bool unwinding = FALSE;
    ecl_frame_ptr next_fr;
    {
     ecl_frs_push(cl_env_copy,ECL_PROTECT_TAG);
     if (__ecl_frs_push_result!=0) {
       unwinding = TRUE; next_fr=cl_env_copy->frs_stack.nlj_fr;
     } else {
     v5cdb = (cl_env_copy->function=ecl_fdefinition(VV[11]))->cfun.entry(2, ECL_NIL, v2path) /*  %MAKE-CDB */;
     {
      cl_object v6;
      cl_object v7k;
      cl_object v8v;
      v6 = ECL_NIL;
      v7k = ECL_NIL;
      v8v = ECL_NIL;
      {
       cl_object v9;
       v9 = si_hash_table_iterator(v1hash_table);
L14:;
       {
        cl_object v10;
        cl_object v11;
        cl_object v12;
        value0 = ecl_function_dispatch(cl_env_copy,v9)(0);
        {
         const int v13 = cl_env_copy->nvalues;
         v10 = value0;
         cl_object v14;
         v14 = (v13<=1)? ECL_NIL : cl_env_copy->values[1];
         v11 = v14;
         v14 = (v13<=2)? ECL_NIL : cl_env_copy->values[2];
         v12 = v14;
        }
        if (Null(v10)){
         goto L19;
        }
        v8v = v12;
        v7k = v11;
L19:;
        v6 = v10;
        if (v6!=ECL_NIL) {
         goto L16;
        }
       }
       goto L15;
L16:;
       T0 = L2927to_cdb_vector(v7k);
       T1 = L2927to_cdb_vector(v8v);
       (cl_env_copy->function=ecl_fdefinition(VV[14]))->cfun.entry(3, T0, T1, v5cdb) /*  ADD-RECORD */;
       goto L14;
L15:;
       cl_env_copy->values[0] = ECL_NIL;
       cl_env_copy->nvalues = 1;
      }
     }
     }
    }
    ecl_frs_pop(cl_env_copy);
    ecl_stack_frame_push_values(_ecl_inner_frame);
    (cl_env_copy->function=ecl_fdefinition(VV[15]))->cfun.entry(1, v5cdb) /*  CLOSE-CDB */;
    ecl_stack_frame_pop_values(_ecl_inner_frame);
    if (unwinding) ecl_unwind(cl_env_copy,next_fr);
    ecl_stack_frame_close(_ecl_inner_frame);
   }
  }
  if (Null(v4test)){
   goto L28;
  }
  {
   cl_object v5;
   cl_object v6k;
   cl_object v7v;
   v5 = ECL_NIL;
   v6k = ECL_NIL;
   v7v = ECL_NIL;
   {
    cl_object v8;
    v8 = si_hash_table_iterator(v1hash_table);
    {
     cl_object v9other_value;
     v9other_value = ECL_NIL;
L35:;
     {
      cl_object v10;
      cl_object v11;
      cl_object v12;
      value0 = ecl_function_dispatch(cl_env_copy,v8)(0);
      {
       const int v13 = cl_env_copy->nvalues;
       v10 = value0;
       cl_object v14;
       v14 = (v13<=1)? ECL_NIL : cl_env_copy->values[1];
       v11 = v14;
       v14 = (v13<=2)? ECL_NIL : cl_env_copy->values[2];
       v12 = v14;
      }
      if (Null(v10)){
       goto L40;
      }
      v7v = v12;
      v6k = v11;
L40:;
      v5 = v10;
      if (v5!=ECL_NIL) {
       goto L37;
      }
     }
     goto L36;
L37:;
     v9other_value = L2929search_help_file(v6k, v2path);
     if (Null(v9other_value)){
      goto L51;
     }
     if (ecl_equalp(v9other_value,v7v)) {
      goto L48;
     }
     goto L49;
L51:;
     goto L49;
L49:;
     cl_error(3, VV[18], v6k, v2path);
L48:;
     goto L35;
L36:;
     value0 = ECL_NIL;
     cl_env_copy->nvalues = 1;
     return value0;
    }
   }
  }
L28:;
  value0 = ECL_NIL;
  cl_env_copy->nvalues = 1;
  return value0;
 }
}
#include "clos/ecl-help.data"
#ifdef __cplusplus
extern "C"
#endif

ECL_DLLEXPORT void _ecl1imiBKKBT3Zq9_pwI0M881(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("EXT:ECL-CDB;ECL-HELP.LISP.NEWEST",-1);
 return;}
 #ifdef ECL_DYNAMIC_VV
 VV = Cblock->cblock.data;
 #endif
 Cblock->cblock.data_text = (const cl_object *)"@EcLtAg:_ecl1imiBKKBT3Zq9_pwI0M881@";
 VVtemp = Cblock->cblock.temp_data;
 ECL_DEFINE_SETF_FUNCTIONS
/* MAKE-LOAD-FORMs                                                            */
/* TOP-LEVEL-FORMs                                                            */
  si_select_package(VVtemp[0]);
  ecl_cmp_defun(VV[20]);                          /*  TO-CDB-VECTOR           */
  ecl_cmp_defun(VV[21]);                          /*  FROM-CDB-VECTOR         */
  ecl_cmp_defun(VV[22]);                          /*  SEARCH-HELP-FILE        */
  ecl_cmp_defun(VV[23]);                          /*  DUMP-HELP-FILE          */
}
