/* Compiler: ECL 26.3.27                                                      */
/* Source: /build/ecl/src/ecl-26.3.27/src/cmp/cmpos-run.lsp                   */
#include <ecl/ecl-cmp.h>
#include "cmp/cmpos-run.eclh"
/* function definition for SAFE-SYSTEM                                        */
/* optimize speed 1, debug 1, space 1, safety 2                               */
static cl_object L4111safe_system(cl_object v1string)
{
 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_env_copy->function=ecl_fdefinition(VV[1]))->cfun.entry(2, VV[2], v1string) /*  CMPNOTE */;
 {
  cl_object v2result;
  v2result = si_system(v1string);
  if ((ecl_fixnum(v2result))==0) {
   goto L4;
  }
  value0 = cl_cerror(4, VV[3], VV[4], v1string, v2result);
  return value0;
L4:;
  value0 = ECL_NIL;
  cl_env_copy->nvalues = 1;
  return value0;
 }
}
static cl_object L4111safe_system_va(cl_narg narg, cl_object v3string, ...)
{
 if (ecl_unlikely(narg!=1)) FEwrong_num_arguments(VV[0]);
 {
  return L4111safe_system(v3string);
 }
}
/* function definition for SAVE-DIRECTORY                                     */
/* optimize speed 1, debug 1, space 1, safety 2                               */
static cl_object L4112save_directory(cl_object volatile v1forms)
{
 cl_object T0;
 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);
L1:;
 {
  volatile cl_object v2directory;
  T0 = cl_make_pathname(6, ECL_SYM("NAME",1309), ECL_NIL, ECL_SYM("TYPE",1356), ECL_NIL, ECL_SYM("DEFAULTS",1247), ecl_cmp_symbol_value(cl_env_copy,ECL_SYM("*DEFAULT-PATHNAME-DEFAULTS*",34)));
  v2directory = cl_probe_file(T0);
  if (Null(v2directory)){
   goto L3;
  }
  {
   volatile cl_object v3;
   v3 = si_chdir(1, v2directory);
   ecl_bds_bind(cl_env_copy,ECL_SYM("*DEFAULT-PATHNAME-DEFAULTS*",34),v2directory); /*  *DEFAULT-PATHNAME-DEFAULTS* */
   {
    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 {
     cl_env_copy->values[0] = ecl_function_dispatch(cl_env_copy,v1forms)(0);
     }
    }
    ecl_frs_pop(cl_env_copy);
    ecl_stack_frame_push_values(_ecl_inner_frame);
    si_chdir(1, v3);
    ecl_stack_frame_pop_values(_ecl_inner_frame);
    if (unwinding) ecl_unwind(cl_env_copy,next_fr);
    ecl_stack_frame_close(_ecl_inner_frame);
    ecl_bds_unwind1(cl_env_copy);
    return cl_env_copy->values[0];
   }
  }
L3:;
  value0 = ecl_function_dispatch(cl_env_copy,v1forms)(0);
  return value0;
 }
}
static cl_object L4112save_directory_va(cl_narg narg, cl_object v4forms, ...)
{
 if (ecl_unlikely(narg!=1)) FEwrong_num_arguments(VV[6]);
 {
  return L4112save_directory(v4forms);
 }
}
/* local function WITH-CURRENT-DIRECTORY                                      */
/* optimize speed 1, debug 1, space 1, safety 2                               */
static cl_object LC4113with_current_directory(cl_object v1, cl_object v2)
{
 cl_object T0, T1;
 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;
  v3 = ecl_cdr(v1);
  T0 = cl_listX(3, ECL_SYM("LAMBDA",454), ECL_NIL, v3);
  T1 = cl_list(2, ECL_SYM("FUNCTION",398), T0);
  value0 = cl_list(2, VV[6], T1);
  return value0;
 }
}
static cl_object LC4113with_current_directory_va(cl_narg narg, cl_object v4, cl_object v5, ...)
{
 if (ecl_unlikely(narg!=2)) FEwrong_num_arguments(VV[8]);
 {
  return LC4113with_current_directory(v4, v5);
 }
}
/* function definition for SAFE-RUN-PROGRAM                                   */
/* optimize speed 1, debug 1, space 1, safety 2                               */
static cl_object L4115safe_run_program(cl_object v1program, cl_object v2args)
{
 cl_object T0, T1;
 cl_object env0 = ECL_NIL;
 cl_object CLV0, CLV1, CLV2, CLV3;
 const cl_env_ptr cl_env_copy = ecl_process_env();
 cl_object value0;
 ecl_cs_check(cl_env_copy,value0);
L1:;
 {
  cl_object env1 = env0;
  env1 = ECL_NIL;
  CLV0 = env1 = CONS(ECL_NIL,env1);               /*  RESULT                  */
  CLV1 = env1 = CONS(ECL_NIL,env1);               /*  OUTPUT                  */
  (cl_env_copy->function=ecl_fdefinition(VV[1]))->cfun.entry(3, VV[11], v1program, v2args) /*  CMPNOTE */;
  {
   cl_object v3program;
   cl_object env2 = env1;
   ecl_bds_bind(cl_env_copy,ECL_SYM("*STANDARD-OUTPUT*",69),ecl_cmp_symbol_value(cl_env_copy,ECL_SYM("+PROCESS-STANDARD-OUTPUT+",1921))); /*  *STANDARD-OUTPUT* */
   ecl_bds_bind(cl_env_copy,ECL_SYM("*ERROR-OUTPUT*",35),ecl_cmp_symbol_value(cl_env_copy,ECL_SYM("+PROCESS-ERROR-OUTPUT+",1922))); /*  *ERROR-OUTPUT* */
   v3program = L4119split_program_options(v1program);
   T0 = ecl_cdr(v3program);
   T1 = ecl_append(T0,v2args);
   CLV2 = env2 = CONS(T1,env2);                   /*  ARGS                    */
   T0 = ecl_car(v3program);
   CLV3 = env2 = CONS(T0,env2);                   /*  PROGRAM                 */
   {
    cl_object v4;
    v4 = ecl_make_cclosure_va((cl_objectfn)LC4114__lambda12,env2,Cblock,0);
    T0 = v4;
   }
   L4112save_directory(T0);
   ecl_bds_unwind1(cl_env_copy);
   ecl_bds_unwind1(cl_env_copy);
  }
  if (!(ECL_CONS_CAR(CLV0)==ECL_NIL)){
   goto L7;
  }
  cl_cerror(5, VV[3], VV[15], v1program, v2args, ECL_CONS_CAR(CLV0));
  goto L6;
L7:;
  if (ecl_zerop(ECL_CONS_CAR(CLV0))) {
   goto L6;
  }
  T0 = ECL_CONS_CAR(CLV0);
  cl_cerror(6, VV[3], VV[16], T0, v1program, v2args, ECL_CONS_CAR(CLV1));
L6:;
  value0 = ECL_CONS_CAR(CLV0);
  cl_env_copy->nvalues = 1;
  return value0;
 }
}
static cl_object L4115safe_run_program_va(cl_narg narg, cl_object v3program, cl_object v4args, ...)
{
 if (ecl_unlikely(narg!=2)) FEwrong_num_arguments(VV[10]);
 {
  return L4115safe_run_program(v3program, v4args);
 }
}
/* function definition for SPLIT-PROGRAM-OPTIONS                              */
/* optimize speed 1, debug 1, space 1, safety 2                               */
static cl_object L4119split_program_options(cl_object v1string)
{
 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 v2output;
  v2output = ECL_NIL;
  {
   cl_object v3option;
   v3option = ECL_NIL;
   {
    cl_object v4status;
    v4status = ECL_NIL;
    {
     cl_object v5;
     cl_object v6;
     cl_object v7i;
     v5 = ecl_make_int8_t(0);
     v6 = ecl_make_fixnum(ecl_length(v1string));
     v7i = v5;
     {
      cl_object v8c;
      v8c = ECL_NIL;
      {
       cl_object v9now;
       v9now = ECL_NIL;
L10:;
       if (!(ecl_greatereq(v7i,v6))){
        goto L12;
       }
       goto L11;
L12:;
       v8c = cl_char(v1string, v7i);
       v9now = ecl_car(v4status);
       if (!((v9now)==(ECL_CODE_CHAR(39)))){
        goto L19;
       }
       if (!((v8c)==(ECL_CODE_CHAR(39)))){
        goto L21;
       }
       v4status = ecl_cdr(v4status);
       goto L18;
L21:;
       v3option = LC4118push_char(v8c, v3option);
       goto L18;
L19:;
       if (!((v9now)==(ECL_CODE_CHAR(92)))){
        goto L25;
       }
       v3option = LC4118push_char(v8c, v3option);
       v4status = ecl_cdr(v4status);
       goto L18;
L25:;
       if (!((v9now)==(ECL_CODE_CHAR(34)))){
        goto L30;
       }
       if (!((v8c)==(ECL_CODE_CHAR(34)))){
        goto L32;
       }
       v4status = ecl_cdr(v4status);
       goto L18;
L32:;
       v3option = LC4118push_char(v8c, v3option);
       goto L18;
L30:;
       if (!(((v8c)==ECL_CODE_CHAR((ecl_character)(92))))){
        goto L41;
       }
       goto L38;
L41:;
       goto L39;
L39:;
       if (!(((v8c)==ECL_CODE_CHAR((ecl_character)(39))))){
        goto L45;
       }
       goto L38;
L45:;
       goto L43;
L43:;
       if (!(((v8c)==ECL_CODE_CHAR((ecl_character)(34))))){
        goto L36;
       }
       goto L37;
L38:;
L37:;
       v4status = CONS(v8c,v4status);
       goto L18;
L36:;
       if (!(((v8c)==ECL_CODE_CHAR((ecl_character)(32))))){
        goto L54;
       }
       goto L51;
L54:;
       goto L52;
L52:;
       if (!(((v8c)==ECL_CODE_CHAR((ecl_character)(9))))){
        goto L58;
       }
       goto L51;
L58:;
       goto L56;
L56:;
       if (!(((v8c)==ECL_CODE_CHAR((ecl_character)(13))))){
        goto L62;
       }
       goto L51;
L62:;
       goto L60;
L60:;
       if (!(((v8c)==ECL_CODE_CHAR((ecl_character)(10))))){
        goto L49;
       }
       goto L50;
L51:;
L50:;
       v2output = LC4116maybe_push(v2output, v3option);
       v3option = ECL_NIL;
       goto L18;
L49:;
       v3option = LC4118push_char(v8c, v3option);
L18:;
       v7i = ecl_one_plus(v7i);
       goto L10;
L11:;
       if (Null(v4status)){
        goto L73;
       }
       cl_error(2, VV[32], v1string);
       goto L72;
L73:;
       T0 = LC4116maybe_push(v2output, v3option);
       value0 = cl_nreverse(T0);
       return value0;
L72:;
       value0 = ECL_NIL;
       cl_env_copy->nvalues = 1;
       return value0;
      }
     }
    }
   }
  }
 }
}
static cl_object L4119split_program_options_va(cl_narg narg, cl_object v10string, ...)
{
 if (ecl_unlikely(narg!=1)) FEwrong_num_arguments(VV[12]);
 {
  return L4119split_program_options(v10string);
 }
}
/* closure LAMBDA12                                                           */
/* optimize speed 1, debug 1, space 1, safety 2                               */
static cl_object LC4114__lambda12(cl_narg narg, ...)
{
 cl_object CLV0, CLV1, CLV2, CLV3;
 const cl_env_ptr cl_env_copy = ecl_process_env();
 cl_object env0 = cl_env_copy->function->cclosure.env;
 cl_object value0;
 ecl_cs_check(cl_env_copy,value0);
 /* Scanning closure data ... */
 CLV3 = env0;                                     /*  PROGRAM                 */
 CLV2 = _ecl_cdr(CLV3);
 CLV1 = _ecl_cdr(CLV2);
 CLV0 = _ecl_cdr(CLV1);
 { /* ... closure scanning finished */
 if (ecl_unlikely(narg!=0)) FEwrong_num_arguments(VV[13]);
 {
L1:;
  {
   cl_object v1;                                  /*  OUTPUT-STREAM           */
   cl_object v2;                                  /*  RETURN-STATUS           */
   cl_object v3;                                  /*  PROCESS-OBJ             */
   value0 = si_run_program(4, ECL_CONS_CAR(CLV3), ECL_CONS_CAR(CLV2), ECL_SYM("WAIT",1367), ECL_NIL);
   {
    v1 = value0;
    v2 = cl_env_copy->values[1];
    v3 = cl_env_copy->values[2];
   }
   ECL_CONS_CAR(CLV1) = (cl_env_copy->function=ecl_fdefinition(VV[14]))->cfun.entry(1, v1) /*  COLLECT-LINES */;
   value0 = (cl_env_copy->function=ecl_fdefinition(ECL_SYM("EXTERNAL-PROCESS-WAIT",1850)))->cfun.entry(2, v3, ECL_T) /*  EXTERNAL-PROCESS-WAIT */;
   {
    const int v4 = cl_env_copy->nvalues;
    v2 = value0;
    cl_object v5;
    v5 = (v4<=1)? ECL_NIL : cl_env_copy->values[1];
    ECL_CONS_CAR(CLV0) = v5;
   }
   cl_env_copy->nvalues = 1;
   return value0;
  }
 }
 }
}
/* local function PUSH-CHAR                                                   */
/* optimize speed 1, debug 1, space 1, safety 2                               */
static cl_object LC4118push_char(cl_object v1c, cl_object v2s)
{
 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:;
 if (v2s!=ECL_NIL) {
  goto L2;
 }
 v2s = LC4117new_string();
L2:;
 {
  cl_fixnum v3;
  cl_fixnum v4;
  v3 = ((v2s)->vector.fillp);
  v4 = ((v2s)->array.dim);
  if (!((v3)<(v4))){
   goto L9;
  }
  {
   cl_fixnum v5;
   v5 = ((cl_fixnum)1)+(v3);
   ((v2s)->vector.fillp)=(v5);
  }
  ecl_aset_unsafe(v2s,v3,v1c);
  goto L5;
L9:;
  cl_vector_push_extend(2, v1c, v2s);
 }
L5:;
 value0 = v2s;
 cl_env_copy->nvalues = 1;
 return value0;
}
static cl_object LC4118push_char_va(cl_narg narg, cl_object v3c, cl_object v4s, ...)
{
 if (ecl_unlikely(narg!=2)) FEwrong_num_arguments(VV[20]);
 {
  return LC4118push_char(v3c, v4s);
 }
}
/* local function NEW-STRING                                                  */
/* optimize speed 1, debug 1, space 1, safety 2                               */
static cl_object LC4117new_string()
{
 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:;
 value0 = si_make_vector(ECL_SYM("BASE-CHAR",122), ecl_make_int8_t(32), ECL_T, ecl_make_int8_t(0), ECL_NIL, ecl_make_int8_t(0));
 return value0;
}
static cl_object LC4117new_string_va(cl_narg narg, ...)
{
 if (ecl_unlikely(narg!=0)) FEwrong_num_arguments(VV[19]);
 {
  return LC4117new_string();
 }
}
/* local function MAYBE-PUSH                                                  */
/* optimize speed 1, debug 1, space 1, safety 2                               */
static cl_object LC4116maybe_push(cl_object v1options, cl_object v2current)
{
 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:;
 if (Null(v2current)){
  goto L2;
 }
 value0 = CONS(v2current,v1options);
 cl_env_copy->nvalues = 1;
 return value0;
L2:;
 value0 = v1options;
 cl_env_copy->nvalues = 1;
 return value0;
}
static cl_object LC4116maybe_push_va(cl_narg narg, cl_object v3options, cl_object v4current, ...)
{
 if (ecl_unlikely(narg!=2)) FEwrong_num_arguments(VV[18]);
 {
  return LC4116maybe_push(v3options, v4current);
 }
}
#include "cmp/cmpos-run.data"
#ifdef __cplusplus
extern "C"
#endif

ECL_DLLEXPORT void _eclMXY3tmjLBmPj9_8ig0M881(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;CMPOS-RUN.LSP.NEWEST",-1);
 return;}
 #ifdef ECL_DYNAMIC_VV
 VV = Cblock->cblock.data;
 #endif
 Cblock->cblock.data_text = (const cl_object *)"@EcLtAg:_eclMXY3tmjLBmPj9_8ig0M881@";
 VVtemp = Cblock->cblock.temp_data;
 ECL_DEFINE_SETF_FUNCTIONS
/* MAKE-LOAD-FORMs                                                            */
/* TOP-LEVEL-FORMs                                                            */
  si_select_package(VVtemp[0]);
  ecl_cmp_defun(VV[34]);                          /*  SAFE-SYSTEM             */
  ecl_cmp_defun(VV[35]);                          /*  SAVE-DIRECTORY          */
  ecl_cmp_defmacro(VV[36]);                       /*  WITH-CURRENT-DIRECTORY  */
  ecl_cmp_defun(VV[37]);                          /*  SAFE-RUN-PROGRAM        */
  ecl_cmp_defun(VV[38]);                          /*  SPLIT-PROGRAM-OPTIONS   */
}
