
/* This file was automatically generated by pclu.*/

#include "pclu_err.h"
#include "pclu_sys.h"


extern struct dbg_info* dbg_info_e_form;
#undef MY_TRACE_FLAG
#define MY_TRACE_FLAG e_form_TRACE
int e_form_TRACE;
extern struct OPS *int_ops;
static Vlist1 owns_e_form = {0, 1,{ {0, 2, "_init", &int_ops}
}
};
extern errcode intOPlt();
extern errcode intOPequal();
extern errcode _unparse_real();
extern errcode boolOPnot();
extern errcode realOPequal();
extern errcode _round_real();
extern errcode intOPadd();
extern errcode intOPsub();
extern errcode _bytevecOPcreate();
extern errcode _bytevecOPstore();
extern errcode intOPle();
extern errcode _bytevecOPfetch();
extern errcode intOPgt();
extern errcode intOPge();
extern errcode intOPminus();
extern errcode charOPi2c();
extern errcode intOPdiv();
extern errcode intOPmod();
extern errcode _cvt();
extern OWN_req int_ownreqs;
static int e_form_own_init = 0;

/**** BEGIN PROCEDURE e_form ****/

errcode e_form(x, i, f, ret_1)
CLUREF x;
CLUREF i;
CLUREF f;
CLUREF *ret_1;
    {
    struct {
        struct dbg_info *DBG_INFO;
        int DBG_LINE;
        errcode err;
        errcode ecode2;
        CLUREF minus;
        CLUREF digits;
        CLUREF expon;
        CLUREF ndigs;
        CLUREF n;
        CLUREF res;
        CLUREF j;
        CLUREF c;
        CLUREF x;
        CLUREF i;
        CLUREF f;
        } locals;
    locals.minus.num = UNINIT;
    locals.digits.num = UNINIT;
    locals.expon.num = UNINIT;
    locals.ndigs.num = UNINIT;
    locals.n.num = UNINIT;
    locals.res.num = UNINIT;
    locals.j.num = UNINIT;
    locals.c.num = UNINIT;
    locals.x.num = UNINIT;
    locals.i.num = UNINIT;
    locals.f.num = UNINIT;
    locals.DBG_INFO = dbg_info_e_form;
    locals.x = x;
    locals.i = i;
    locals.f = f;
        if (e_form_own_init == 0) {
        e_form_own_init = 1;
    }
    enter_proc(3);

  LINE(7);
    {
    CLUREF T_1_1;
    CLUREF T_1_2;
    CLUREF T_1_3;
    CLUREF T_1_4;
    CLUREF T_1_5;
    CLUREF T_1_6;
    CLUREF T_1_7;
    T_1_3.num = (locals.i.num < 0)? true : false;
    T_1_2.num = T_1_3.num;
    if (!T_1_3.num) {
        T_1_4.num = (locals.f.num < 0)? true : false;
        T_1_2.num = T_1_4.num;
    }
    T_1_1.num = T_1_2.num;
    if (!T_1_2.num) {
        T_1_6.num = (locals.i.num == 0)? true : false;
        T_1_5.num = T_1_6.num;
        if (T_1_6.num) {
            T_1_7.num = (locals.f.num == 0)? true : false;
            T_1_5.num = T_1_7.num;
        }
        T_1_1.num = T_1_5.num;
    }
    if (T_1_1.num == true) {

  LINE(8);
        {
        {signal (ERR_illegal_field_width);}}
        }
        }/* end if */

  LINE(9);
    {
        {CLUREF T_1_1;
        CLUREF T_1_2;
        CLUREF T_1_3;
        locals.err = _unparse_real(locals.x, &T_1_1, &T_1_2, &T_1_3);
        if (locals.err != ERR_ok) goto ex_0;
        locals.minus.num = T_1_1.num;
        locals.digits.num = T_1_2.num;
        locals.expon.num = T_1_3.num;
        }
        }

  LINE(10);
    {
        {locals.ndigs.num = 0;
        }
        }

  LINE(11);
    locals.n.num = UNINIT;

  LINE(12);
    {
    CLUREF T_1_1;
    CLUREF T_1_2;
    CLUREF T_1_3;
    T_1_1.real = 0.000000e+00;
    locals.err = realOPequal(locals.x, T_1_1, &T_1_2);
    if (locals.err != ERR_ok) goto ex_0;
    T_1_3.num = T_1_2.num ^ 1;
    if (T_1_3.num == true) {

  LINE(13);
        {
        CLUREF T_2_1;
        CLUREF T_2_2;
        CLUREF T_2_3;
        locals.err = intOPadd(locals.i, locals.f, &T_2_1);
        if (locals.err != ERR_ok) goto ex_0;
        locals.err = _round_real(locals.digits, T_2_1, &T_2_2, &T_2_3);
        if (locals.err != ERR_ok) goto ex_0;
        locals.n.num = T_2_2.num;
        locals.ndigs.num = T_2_3.num;
        }

  LINE(14);
        {
        CLUREF T_2_1;
        CLUREF T_2_2;
        locals.err = intOPadd(locals.expon, locals.n, &T_2_1);
        if (locals.err != ERR_ok) goto ex_0;
        locals.err = intOPsub(T_2_1, locals.i, &T_2_2);
        if (locals.err != ERR_ok) goto ex_0;
        locals.expon.num = T_2_2.num;
        }
        }
        }/* end if */

  LINE(16);
    {
    CLUREF T_1_1;
    CLUREF T_1_2;
    locals.err = intOPadd(locals.i, locals.f, &T_1_1);
    if (locals.err != ERR_ok) goto ex_0;
    locals.err = intOPadd(T_1_1, CLU_5, &T_1_2);
    if (locals.err != ERR_ok) goto ex_0;
    locals.n.num = T_1_2.num;
    }

  LINE(17);
    {
    if (locals.minus.num == true) {

  LINE(18);
        {
        CLUREF T_2_1;
        locals.err = intOPadd(locals.n, CLU_1, &T_2_1);
        if (locals.err != ERR_ok) goto ex_0;
        locals.n.num = T_2_1.num;
        }
        }
        }/* end if */

  LINE(19);
    {
    CLUREF T_1_1;
    T_1_1.num = (locals.f.num == 0)? true : false;
    if (T_1_1.num == true) {

  LINE(20);
        {
        CLUREF T_2_1;
        locals.err = intOPsub(locals.n, CLU_1, &T_2_1);
        if (locals.err != ERR_ok) goto ex_0;
        locals.n.num = T_2_1.num;
        }
        }
        }/* end if */

  LINE(21);
    {
        {CLUREF T_1_1;
        locals.err = _bytevecOPcreate(locals.n, &T_1_1);
        if (locals.err != ERR_ok) goto ex_0;
        locals.res.num = T_1_1.num;
        }
        }

  LINE(22);
    {
    locals.n.num = 1;
    }

  LINE(23);
    {
    if (locals.minus.num == true) {

  LINE(24);
        {
        CLUREF T_2_1;
        T_2_1.ch = '-';
        locals.err = _bytevecOPstore(locals.res, CLU_1, T_2_1);
        if (locals.err != ERR_ok) goto ex_0;
        }

  LINE(25);
        {
        locals.n.num = 2;
        }
        }
        }/* end if */

  LINE(27);
    {
        {locals.j.num = 1;
        }
        }

  LINE(28);
    for (;;) {
        if (true != true) { break; }

  LINE(29);
        {
        CLUREF T_2_1;
        T_2_1.num = (locals.i.num == 0)? true : false;
        if (T_2_1.num == true) {

  LINE(30);
            {
            CLUREF T_3_1;
            T_3_1.num = (locals.f.num == 0)? true : false;
            if (T_3_1.num == true) {

  LINE(31);
                goto end_while_1;
                }
                }/* end if */

  LINE(32);
            {
            CLUREF T_3_1;
            T_3_1.ch = '.';
            locals.err = _bytevecOPstore(locals.res, locals.n, T_3_1);
            if (locals.err != ERR_ok) goto ex_0;
            }

  LINE(33);
            {
            CLUREF T_3_1;
            locals.err = intOPadd(locals.n, CLU_1, &T_3_1);
            if (locals.err != ERR_ok) goto ex_0;
            locals.n.num = T_3_1.num;
            }

  LINE(34);
            {
            locals.i.num = -1;
            }
            }
            }/* end if */

  LINE(36);
        {
            {CLUREF T_2_1;
            T_2_1.ch = '0';
            locals.c.num = T_2_1.num;
            }
            }

  LINE(37);
        {
        CLUREF T_2_1;
        T_2_1.num = (locals.j.num <= locals.ndigs.num)? true : false;
        if (T_2_1.num == true) {

  LINE(38);
            {
            CLUREF T_3_1;
            locals.err = _bytevecOPfetch(locals.digits, locals.j, &T_3_1);
            if (locals.err != ERR_ok) goto ex_0;
            locals.c.num = T_3_1.num;
            }

  LINE(39);
            {
            CLUREF T_3_1;
            locals.err = intOPadd(locals.j, CLU_1, &T_3_1);
            if (locals.err != ERR_ok) goto ex_0;
            locals.j.num = T_3_1.num;
            }
            }
            }/* end if */

  LINE(41);
        {
        locals.err = _bytevecOPstore(locals.res, locals.n, locals.c);
        if (locals.err != ERR_ok) goto ex_0;
        }

  LINE(42);
        {
        CLUREF T_2_1;
        locals.err = intOPadd(locals.n, CLU_1, &T_2_1);
        if (locals.err != ERR_ok) goto ex_0;
        locals.n.num = T_2_1.num;
        }

  LINE(43);
        {
        CLUREF T_2_1;
        T_2_1.num = (locals.i.num > 0)? true : false;
        if (T_2_1.num == true) {

  LINE(44);
            {
            CLUREF T_3_1;
            locals.err = intOPsub(locals.i, CLU_1, &T_3_1);
            if (locals.err != ERR_ok) goto ex_0;
            locals.i.num = T_3_1.num;
            }

  LINE(45);
            continue;
            }
            }/* end if */

  LINE(47);
        {
        CLUREF T_2_1;
        locals.err = intOPsub(locals.f, CLU_1, &T_2_1);
        if (locals.err != ERR_ok) goto ex_0;
        locals.f.num = T_2_1.num;
        }

  LINE(48);
        {
        CLUREF T_2_1;
        T_2_1.num = (locals.f.num == 0)? true : false;
        if (T_2_1.num == true) {

  LINE(49);
            goto end_while_1;
            }
            }/* end if */
        }
        end_while_1:;

  LINE(51);
    {
    CLUREF T_1_1;
    T_1_1.ch = 'e';
    locals.err = _bytevecOPstore(locals.res, locals.n, T_1_1);
    if (locals.err != ERR_ok) goto ex_0;
    }

  LINE(52);
    {
    CLUREF T_1_1;
    CLUREF T_1_2;
    T_1_1.real = 0.000000e+00;
    locals.err = realOPequal(locals.x, T_1_1, &T_1_2);
    if (locals.err != ERR_ok) goto ex_0;
    if (T_1_2.num == true) {

  LINE(53);
        {
        locals.expon.num = 0;
        }
        }
        }/* end if */

  LINE(54);
    {
    CLUREF T_1_1;
    T_1_1.num = (locals.expon.num >= 0)? true : false;
    if (T_1_1.num == true) {

  LINE(55);
        {
        CLUREF T_2_1;
        CLUREF T_2_2;
        locals.err = intOPadd(locals.n, CLU_1, &T_2_1);
        if (locals.err != ERR_ok) goto ex_0;
        T_2_2.ch = '+';
        locals.err = _bytevecOPstore(locals.res, T_2_1, T_2_2);
        if (locals.err != ERR_ok) goto ex_0;
        }
        }
    else {

  LINE(56);
        {
        CLUREF T_2_1;
        CLUREF T_2_2;
        locals.err = intOPadd(locals.n, CLU_1, &T_2_1);
        if (locals.err != ERR_ok) goto ex_0;
        T_2_2.ch = '-';
        locals.err = _bytevecOPstore(locals.res, T_2_1, T_2_2);
        if (locals.err != ERR_ok) goto ex_0;
        }

  LINE(57);
        {
        CLUREF T_2_1;
        locals.err = intOPminus(locals.expon, &T_2_1);
        if (locals.err != ERR_ok) goto ex_0;
        locals.expon.num = T_2_1.num;
        }
        }}/* end if */

  LINE(59);
    {
    CLUREF T_1_1;
    CLUREF T_1_2;
    CLUREF T_1_3;
    CLUREF T_1_4;
    locals.err = intOPadd(locals.n, CLU_2, &T_1_1);
    if (locals.err != ERR_ok) goto ex_0;
    locals.err = intOPdiv(locals.expon, CLU_10, &T_1_2);
    if (locals.err != ERR_ok) goto ex_0;
    locals.err = intOPadd(T_1_2, CLU_48, &T_1_3);
    if (locals.err != ERR_ok) goto ex_0;
    locals.err = charOPi2c(T_1_3, &T_1_4);
    if (locals.err != ERR_ok) goto ex_0;
    locals.err = _bytevecOPstore(locals.res, T_1_1, T_1_4);
    if (locals.err != ERR_ok) goto ex_0;
    }

  LINE(60);
    {
    CLUREF T_1_1;
    CLUREF T_1_2;
    CLUREF T_1_3;
    CLUREF T_1_4;
    locals.err = intOPadd(locals.n, CLU_3, &T_1_1);
    if (locals.err != ERR_ok) goto ex_0;
    locals.err = intOPmod(locals.expon, CLU_10, &T_1_2);
    if (locals.err != ERR_ok) goto ex_0;
    locals.err = intOPadd(T_1_2, CLU_48, &T_1_3);
    if (locals.err != ERR_ok) goto ex_0;
    locals.err = charOPi2c(T_1_3, &T_1_4);
    if (locals.err != ERR_ok) goto ex_0;
    locals.err = _bytevecOPstore(locals.res, T_1_1, T_1_4);
    if (locals.err != ERR_ok) goto ex_0;
    }

  LINE(61);
    {
    {
    CLUREF T_1_1;
    T_1_1.num = locals.res.num;
    ret_1->num = T_1_1.num;
    }
    {signal (ERR_ok);}}
    goto end_0;
    ex_0:
        {
            if (locals.err == ERR_failure) {signal(ERR_failure);}
            elist[0] = _pclu_erstr(locals.err);
            {signal(ERR_failure);}
        }
    end_0: elist[0].str = no_return_values_STRING;
        {signal(ERR_failure);}
    }

/**** END PROCEDURE e_form ****/

extern struct OPS *string_ops;
extern struct OPS *bool_ops;
extern struct OPS *_bytevec_ops;
extern struct OPS *char_ops;
extern struct OPS *real_ops;
typedef struct {
    int hdr;
    int count;
    char *name;
    char *fname;
    bool is_iter;
    int is_parmd;
    int addr;
    int nargs;
    Vlist1 *vals;
    siglist1 *sigs;
    Vlist13 *locals;
    Vlist1 *owns;
    Vlist0 *ptowns;
    Vlist0 *popowns;
    Slist0 *type_formals;
    Slist0 *op_formals;
    } dbg_info_e_form_actual;
static Vlist1 vals_e_form = {0, 1, { {0, 2, "", &string_ops}}
};
static sig_desc0 sig_e_form_1 = {0, 3, "illegal_field_width", {0, 0
}};
static siglist1 sigs_e_form = {0, 1, (sig_desc*)&sig_e_form_1};
static Vlist13 locals_e_form = {0, 13,{ {0, 2, "err", &int_ops},  {0, 2, "ecode2", &int_ops},  {0, 2, "minus", &bool_ops},  {0, 2, "digits", &_bytevec_ops},  {0, 2, "expon", &int_ops},  {0, 2, "ndigs", &int_ops},  {0, 2, "n", &int_ops},  {0, 2, "res", &_bytevec_ops},  {0, 2, "j", &int_ops},  {0, 2, "c", &char_ops},  {0, 2, "x", &real_ops},  {0, 2, "i", &int_ops},  {0, 2, "f", &int_ops}}
};
static Vlist0 popowns_e_form = {0, 0};
Slist0 tformals_e_form = {0, 0};
Slist0 opformals_e_form = {0, 0};
dbg_info_e_form_actual dbg_info_e_form_data = {0, 12, 
    "e_form", "/common/pub/dcurtis-temp/pclu/sys/clu/e_form", 0, 0, (int)e_form, 3, 
    &vals_e_form, &sigs_e_form, &locals_e_form, &owns_e_form, &NO_VALS, &NO_VALS, &NO_PARMS, &NO_PARMS};
    struct dbg_info *dbg_info_e_form = (struct dbg_info*)&dbg_info_e_form_data;
