/* internal functions */ u3_noun _b_dif_join(u3_noun d, u3_noun e) { if ( u3_nul == d ) { return u3k(e); } else if (u3_nul == e) { return u3k(d); } else { u3_noun n_d, l_d, r_d; u3_noun n_e, l_e, r_e; u3_noun p_n_d, q_n_d; u3_noun p_n_e, q_n_e; if ( c3n == u3r_trel(d, &n_d, &l_d, &r_d) || c3n == u3r_trel(e, &n_e, &l_e, &r_e) || c3n == u3r_cell(n_d, &p_n_d, &q_n_d) || c3n == u3r_cell(n_e, &p_n_e, &q_n_e) ) { return u3m_bail(c3__exit); } else { if ( c3y == u3qc_vor(p_n_d, p_n_e) ) { return u3nt(u3k(n_d), u3k(l_d), _b_dif_join(u3k(r_d), u3k(e))); } else { return u3nt(u3k(n_e), _b_dif_join(u3k(d), u3k(l_e)), u3k(r_e)); } } } }
/* functions */ u3_noun u3qdi_int(u3_noun a, u3_noun b) { if ( u3_nul == a ) { return u3k(u3_nul); } else if ( u3_nul == b ) { return u3k(u3_nul); } else { u3_noun l_a, n_a, r_a, lr_a; u3_noun l_b, n_b, r_b, lr_b; u3_noun c; if ( (c3n == u3r_cell(a, &n_a, &lr_a)) ) { return u3m_bail(c3__exit); } else if ( (c3n == u3r_cell(b, &n_b, &lr_b)) ) { return u3m_bail(c3__exit); } else { if ( c3y == u3qc_mor(n_b, n_a) ) { c = a; a = b; b = c; c = n_a; n_a = n_b; n_b = c; c = lr_a; lr_a = lr_b; lr_b = c; } if ( c3n == u3r_cell(lr_a, &l_a, &r_a) ) { return u3m_bail(c3__exit); } else if ( c3n == u3r_cell(lr_b, &l_b, &r_b) ) { return u3m_bail(c3__exit); } else if ( c3y == u3r_sing(n_a, n_b) ) { return u3nt(u3k(n_a), u3qdi_int(l_a, l_b), u3qdi_int(r_a, r_b)); } else if ( c3y == u3qc_gor(n_b, n_a) ) { return u3qdi_uni(u3qdi_int(l_a, u3nt(n_b, l_b, u3_nul)), u3qdi_int(a, r_b)); } else { return u3qdi_uni(u3qdi_int(r_a, u3nt(n_b, u3_nul, r_b)), u3qdi_int(a, l_b)); } } } }
/* logic */ u3_noun u3qfu_repo( u3_noun van, u3_noun sut) { u3_noun p_sut, q_sut; if ( c3n == u3du(sut) ) switch ( sut ) { default: return u3k(sut); case c3__noun: return u3nt(c3__fork, u3nc(c3__atom, u3_blip), u3nt(c3__cell, c3__noun, c3__noun)); } else switch ( u3h(sut) ) { default: { return u3m_error("repo-flat"); } case c3__bull: { if ( c3n == u3r_cell(u3t(sut), &p_sut, &q_sut)) { return u3m_bail(c3__fail); } else { return u3k(q_sut); } } case c3__core: { if ( c3n == u3r_cell(u3t(sut), &p_sut, &q_sut) ) { return u3m_bail(c3__fail); } else { return u3nt(c3__cell, c3__noun, u3k(p_sut)); } } case c3__cube: { if ( c3n == u3r_cell(u3t(sut), &p_sut, &q_sut)) { return u3m_bail(c3__fail); } else { return u3k(q_sut); } } case c3__face: { if ( c3n == u3r_cell(u3t(sut), &p_sut, &q_sut)) { return u3m_bail(c3__fail); } else { return u3k(q_sut); } } case c3__hold: { p_sut = u3t(sut); return u3qfu_rest(van, sut, p_sut); } } }
u3_noun u3qdb_dif(u3_noun a, u3_noun b) { if ( u3_nul == b ) { return u3k(a); } else { u3_noun n_b, l_b, r_b; u3_noun c, l_c, r_c; if ( c3n == u3r_trel(b, &n_b, &l_b, &r_b) ) { return u3m_bail(c3__exit); } else { c = u3qdb_bif(a, n_b); if ( c3n == u3r_cell(c, &l_c, &r_c) ) { return u3m_bail(c3__exit); } else { u3_noun d; u3_noun e; d = u3qdb_dif(l_c, l_b); e = u3qdb_dif(r_c, r_b); u3z(c); return _b_dif_join(d, e); } } } }
/* functions */ u3_noun u3qdb_has( u3_noun a, u3_noun b) { if ( u3_nul == a ) { return c3n; } else { u3_noun l_a, n_a, r_a; u3_noun pn_a, qn_a; if ( (c3n == u3r_trel(a, &n_a, &l_a, &r_a)) || (c3n == u3r_cell(n_a, &pn_a, &qn_a)) ) { return u3m_bail(c3__exit); } else { if ( (c3y == u3r_sing(b, pn_a)) ) { return c3y; } else { if ( c3y == u3qc_gor(b, pn_a) ) { return u3qdb_has(l_a, b); } else return u3qdb_has(r_a, b); } } } }
/* internal functions */ u3_noun _b_bif_putroot(u3_noun a, u3_noun b) { if ( u3_nul == a) { return u3nt(u3k(b), u3_nul, u3_nul); } else { u3_noun n_a, l_a, r_a; u3_noun p_n_a, q_n_a; u3_noun p_b, q_b; if ( (c3n == u3r_trel(a, &n_a, &l_a, &r_a)) || (c3n == u3r_cell(b, &p_b, &q_b)) || (c3n == u3r_cell(n_a, &p_n_a, &q_n_a)) ) { return u3m_bail(c3__exit); } else if ( c3y == u3r_sing(p_b, p_n_a) ) { return u3nt(u3k(b), u3k(l_a), u3k(r_a)); } else { u3_noun c, n_c, l_c, r_c; u3_noun d; if ( c3y == u3qc_gor(p_b, p_n_a) ) { c = _b_bif_putroot(l_a, b); u3r_trel(c, &n_c, &l_c, &r_c); d = u3nt(u3k(n_c), u3k(l_c), u3nt(u3k(n_a), u3k(r_c), u3k(r_a)) ); u3z(c); return d; } else { c = _b_bif_putroot(r_a, b); u3r_trel(c, &n_c, &l_c, &r_c); d = u3nt(u3k(n_c), u3nt(u3k(n_a), u3k(l_a), u3k(l_c)), u3k(r_c) ); u3z(c); return d; } } } }
u3_noun u3we_argon2(u3_noun cor) { u3_noun // configuration params out, type, version, threads, mem_cost, time_cost, wik, key, wix, extra, // input params wid, dat, wis, sat, // for use during unpacking wmsg, wsat, arg, brg, wkey, wext; // the hoon code for argon2 takes configuration parameters, // and then produces a gate. we jet that inner gate. // this does mean that the config params have gotten buried // pretty deep in the subject, hence the +510. if ( c3n == u3r_mean(cor, u3x_sam_2, &wmsg, u3x_sam_3, &wsat, 510, &arg, 0) || u3r_cell(wmsg, &wid, &dat) || u3ud(wid) || u3ud(dat) || u3r_cell(wsat, &wis, &sat) || u3ud(wis) || u3ud(sat) || // u3r_qual(arg, &out, &type, &version, &brg) || u3ud(out) || u3ud(type) || u3ud(version) || // u3r_qual(brg, &threads, &mem_cost, &time_cost, &arg) || u3ud(threads) || u3ud(mem_cost) || u3ud(time_cost) || // u3r_cell(arg, &wkey, &wext) || u3r_cell(wkey, &wik, &key) || u3ud(wik) || u3ud(key) || u3r_cell(wext, &wix, &extra) || u3ud(wix) || u3ud(extra) ) { return u3m_bail(c3__exit); } else { return u3qe_argon2(out, type, version, threads, mem_cost, time_cost, wik, key, wix, extra, wid, dat, wis, sat); } }
/** rake **/ u3_noun u3qfp_rake(u3_noun gen) { u3_noun p_gen, q_gen; if ( c3y == u3ud(gen) ) { return u3nc(u3k(gen), u3_nul); } else switch ( u3h(gen) ) { default: return u3m_error("rake-twig"); case u3_nul: return u3nc(u3k(gen), u3_nul); case c3__cnzy: { return u3nc(u3k(u3t(gen)), u3_nul); } case c3__cnzz: { return u3k(u3t(gen)); } case c3__cnts: { if ( c3n == u3r_cell(u3t(gen), &p_gen, &q_gen) ) { return u3m_bail(c3__fail); } else { if ( u3_nul != q_gen ) { return u3m_bail(c3__fail); } else { return u3k(p_gen); } } } case c3__zpcb: { if ( c3n == u3r_cell(u3t(gen), &p_gen, &q_gen) ) { return u3m_bail(c3__fail); } else return u3qfp_rake(q_gen); } } }
/* functions */ u3_noun u3qdb_uni( u3_noun a, u3_noun b) { if ( u3_nul == a ) { return u3k(b); } else if ( u3_nul == b ) { return u3k(a); } else { u3_noun l_a, n_a, r_a, lr_a, p_n_a, q_n_a; u3_noun l_b, n_b, r_b, lr_b, p_n_b, q_n_b; if ( (c3n == u3r_cell(a, &n_a, &lr_a)) ) { return u3m_bail(c3__exit); } else if ( (c3n == u3r_cell(b, &n_b, &lr_b)) ) { return u3m_bail(c3__exit); } else if ( (c3n == u3r_cell(n_a, &p_n_a, &q_n_a)) ) { return u3m_bail(c3__exit); } else if ( (c3n == u3r_cell(n_b, &p_n_b, &q_n_b)) ) { return u3m_bail(c3__exit); } else if ( c3n == u3r_cell(lr_a, &l_a, &r_a) ) { return u3m_bail(c3__exit); } else if ( c3n == u3r_cell(lr_b, &l_b, &r_b) ) { return u3m_bail(c3__exit); } else if ( c3y == u3qc_vor(p_n_a, p_n_b) ) { if ( c3y == u3r_sing(p_n_a, p_n_b) ) { return u3nt(u3k(n_b), u3qdb_uni( u3k(l_a), u3k(l_b)), u3qdb_uni( u3k(r_a), u3k(r_b))); } else if ( c3y == u3qc_gor(p_n_b, p_n_a) ) { return u3qdb_uni( u3nt( u3k(n_a), u3qdb_uni( u3k(l_a), u3nt( u3k(n_b), u3k(l_b), u3k(u3_nul))), u3k(r_a)), u3k(r_b)); } else { return u3qdb_uni( u3nt( u3k(n_a), u3k(l_a), u3qdb_uni( u3k(r_a), u3nt( u3k(n_b), u3k(u3_nul), u3k(r_b)))), u3k(l_b)); } } else if ( c3y == u3r_sing(p_n_b, p_n_a) ) { return u3nt( u3k(n_b), u3qdb_uni(u3k(r_b), u3k(r_a)), u3qdb_uni(u3k(l_b), u3k(l_a))); } else if ( c3y == u3qc_gor(p_n_a, p_n_b) ) { return u3qdb_uni( u3k(r_a), u3nt( u3k(n_b), u3qdb_uni( u3nt( u3k(n_a), u3k(l_a), u3k(u3_nul)), u3k(l_b)), u3k(r_b))); } else { return u3qdb_uni( u3k(l_a), u3nt( u3k(n_b), u3k(l_b), u3qdb_uni( u3k(r_b), u3nt( u3k(n_a), u3k(u3_nul), u3k(r_a))))); } } }
/* functions */ u3_noun u3qdb_put(u3_noun a, u3_noun b, u3_noun c) { if ( u3_nul == a ) { return u3nt( u3nc(u3k(b), u3k(c)), u3_nul, u3_nul); } else { u3_noun l_a, n_a, r_a, pn_a, qn_a; u3_noun d, l_d, n_d, r_d; if ( (c3n == u3r_trel(a, &n_a, &l_a, &r_a)) || (c3n == u3r_cell(n_a, &pn_a, &qn_a)) ) { return u3m_bail(c3__exit); } else if ( c3y == u3r_sing(pn_a, b) ) { if ( c3y == u3r_sing(qn_a, c) ) { return u3k(a); } else { return u3nt (u3nc(u3k(b), u3k(c)), u3k(l_a), u3k(r_a)); } } else { if ( c3y == u3qc_gor(b, pn_a) ) { d = u3qdb_put(l_a, b, c); if ( c3y == u3qc_vor(pn_a, u3h(u3h(d))) ) { return u3nt(u3k(n_a), d, u3k(r_a)); } else { u3r_trel(d, &n_d, &l_d, &r_d); { u3_noun e = u3nt (u3k(n_d), u3k(l_d), u3nt(u3k(n_a), u3k(r_d), u3k(r_a))); u3z(d); return e; } } } else { d = u3qdb_put(r_a, b, c); if ( c3y == u3qc_vor(pn_a, u3h(u3h(d))) ) { return u3nt(u3k(n_a), u3k(l_a), d); } else { u3r_trel(d, &n_d, &l_d, &r_d); { u3_noun e = u3nt (u3k(n_d), u3nt(u3k(n_a), u3k(l_a), u3k(l_d)), u3k(r_d)); u3z(d); return e; } } } } } }
static u3_noun _peek_in(u3_noun van, u3_noun sut, u3_noun way, u3_atom axe, u3_noun gil) { u3_noun p_sut, q_sut; u3_noun pro; if ( (c3n == u3du(sut)) ) switch ( sut ) { default: return u3m_bail(c3__fail); case c3__noun: { return c3__noun; } case c3__void: { return c3__void; } } else switch ( u3h(sut) ) { default: return u3m_bail(c3__fail); case c3__atom: { return c3__void; } case c3__bull: { if ( (c3n == u3r_trel(sut, 0, &p_sut, &q_sut)) ) { return u3m_bail(c3__fail); } else { return _peek_in(van, q_sut, way, axe, gil); } } case c3__cell: { if ( (c3n == u3r_trel(sut, 0, &p_sut, &q_sut)) ) { return u3m_bail(c3__fail); } else { u3_atom tip = u3qc_cap(axe); u3_atom tap = u3qc_mas(axe); if ( 2 == tip ) { pro = _cqfu_peek(van, p_sut, way, tap); } else { pro = _cqfu_peek(van, q_sut, way, tap); } u3z(tap); u3z(tip); return pro; } } case c3__core: { u3_noun pq_sut, qq_sut, rq_sut; u3_noun prq_sut, qrq_sut; if ( (c3n == u3r_trel(sut, 0, &p_sut, &q_sut)) || (c3n == u3r_trel(q_sut, &pq_sut, &qq_sut, &rq_sut)) || (c3n == u3r_cell(rq_sut, &prq_sut, &qrq_sut)) ) { return u3m_bail(c3__fail); } else { u3_atom tip = u3qc_cap(axe); u3_atom tap = u3qc_mas(axe); if ( 3 == tip ) { if ( c3n == u3qfu_park(van, sut, way, tap) ) { // u3_noun dun = u3qfu_dunq(van, "type", sut); u3_noun waz = u3qfu_shep (van, "axis", 'd', u3k(axe)); // u3t_push(u3nc(c3__mean, dun)); u3t_push(u3nc(c3__mean, waz)); return u3m_error("peek-park"); } else pro = _cqfu_peek(van, p_sut, way, tap); } else { pro = c3__noun; } u3z(tap); u3z(tip); return pro; } } case c3__cube: { if ( (c3n == u3r_trel(sut, 0, &p_sut, &q_sut)) ) { return u3m_bail(c3__fail); } else { return _peek_in(van, q_sut, way, axe, gil); } } case c3__face: { if ( (c3n == u3r_trel(sut, 0, &p_sut, &q_sut)) ) { return u3m_bail(c3__fail); } else { return _peek_in(van, q_sut, way, axe, gil); } } case c3__fork: { if ( (c3n == u3r_trel(sut, 0, &p_sut, &q_sut)) ) { return u3m_bail(c3__fail); } else { u3_noun hed = _peek_in(van, p_sut, way, axe, gil); u3_noun tal = _peek_in(van, q_sut, way, axe, gil); pro = u3qf_fork(hed, tal); u3z(hed); u3z(tal); return pro; } } case c3__hold: { p_sut = u3t(sut); if ( (c3y == u3qdi_has(gil, sut)) ) { return c3__void; } else { u3_noun zoc = u3qdi_put(gil, sut); u3_noun fop = u3qfu_repo(van, sut); u3_noun pro = _peek_in(van, fop, way, axe, zoc); u3z(fop); u3z(zoc); return pro; } } } }
static u3_noun _fire_each(u3_noun van, u3_noun vet, u3_noun typ, u3_noun gat) { u3_noun p_typ, q_typ, pq_typ, qq_typ, rq_typ; u3_noun h_gat, t_gat; if ( (c3n == u3du(typ)) || (c3__core != u3h(typ)) ) { return u3m_error("fire-core"); } else if ( (c3n == u3r_cell(u3t(typ), &p_typ, &q_typ)) || (c3n == u3r_trel(q_typ, &pq_typ, &qq_typ, &rq_typ)) || (c3n == u3r_cell(gat, &h_gat, &t_gat)) ) { return u3m_bail(c3__fail); } else { u3_noun dox = u3nt (c3__core, u3k(qq_typ), u3k(q_typ)); if ( c3__ash == u3h(gat) ) { if ( (c3y == vet) && (c3n == u3qfu_nest(van, qq_typ, c3y, p_typ)) ) { #if 0 u3_noun dun = u3qfu_dunq(van, "need", qq_typ); u3_noun niz = u3qfu_dunq(van, "have", p_typ); u3t_push(u3nc(c3__mean, niz)); u3t_push(u3nc(c3__mean, dun)); #endif return u3m_error("fire-dry"); } else { return u3nc(dox, u3k(t_gat)); } } else { c3_assert(c3__elm == u3h(gat)); #if 0 u3_noun dun = u3qfu_dunq(van, "wild", typ); u3_noun niz = u3qfu_dunq(van, "tame", dox); u3t_push(u3nc(c3__mean, dun)); u3t_push(u3nc(c3__mean, niz)); #endif if ( (c3y == vet) && (c3n == _fire_mull(van, typ, dox, t_gat)) ) { return u3m_error("fire-wet"); } else { u3z(dox); #if 0 u3t_drop(); u3t_drop(); #endif return u3nc(u3k(typ), u3k(t_gat)); } } } }
static u3_noun _peek_in(u3_noun van, u3_noun sut, u3_noun way, u3_atom axe, u3_noun gil) { u3_noun p_sut, q_sut; u3_noun pro; if ( (c3n == u3du(sut)) ) switch ( sut ) { default: return u3m_bail(c3__fail); case c3__noun: { return c3__noun; } case c3__void: { return c3__void; } } else switch ( u3h(sut) ) { default: return u3m_bail(c3__fail); case c3__atom: { return c3__void; } case c3__cell: { if ( (c3n == u3r_trel(sut, 0, &p_sut, &q_sut)) ) { return u3m_bail(c3__fail); } else { u3_atom tip = u3qc_cap(axe); u3_atom tap = u3qc_mas(axe); if ( 2 == tip ) { pro = _cqfu_peek(van, p_sut, way, tap); } else { pro = _cqfu_peek(van, q_sut, way, tap); } u3z(tap); u3z(tip); return pro; } } case c3__core: { u3_noun pq_sut, qq_sut, rq_sut; u3_noun prq_sut, qrq_sut; if ( (c3n == u3r_trel(sut, 0, &p_sut, &q_sut)) || (c3n == u3r_trel(q_sut, &pq_sut, &qq_sut, &rq_sut)) || (c3n == u3r_cell(rq_sut, &prq_sut, &qrq_sut)) ) { return u3m_bail(c3__fail); } else { u3_atom now = u3qc_cap(axe); u3_atom lat = u3qc_mas(axe); if ( 3 == now ) { u3_noun pec = u3qfu_perk(van, sut, way, pq_sut); u3_noun sam = u3h(pec); u3_noun con = u3t(pec); if ( c3y == c3a(sam, con) ) { pro = _cqfu_peek(van, p_sut, way, lat); } else { u3_noun typ; { u3_noun hed, tal; if ( c3n == sam ) { hed = c3__noun; } else { hed = _cqfu_peek(van, p_sut, way, 2); } if ( c3n == con ) { tal = c3__noun; } else { tal = _cqfu_peek(van, p_sut, way, 3); } typ = u3qf_cell(hed, tal); u3z(hed); u3z(tal); } pro = _cqfu_peek(van, typ, way, lat); u3z(typ); } u3z(pec); } else { pro = c3__noun; } u3z(lat); u3z(now); return pro; } } case c3__face: { if ( (c3n == u3r_trel(sut, 0, &p_sut, &q_sut)) ) { return u3m_bail(c3__fail); } else { return _peek_in(van, q_sut, way, axe, gil); } } case c3__fork: p_sut = u3t(sut); { u3_noun yed = u3qdi_tap(p_sut, u3_nul); u3_noun ret = u3kf_fork(_peek_fork(van, yed, way, axe, gil)); u3z(yed); return ret; } case c3__hold: { if ( (c3y == u3qdi_has(gil, sut)) ) { return c3__void; } else { u3_noun zoc = u3qdi_put(gil, sut); u3_noun fop = u3qfu_repo(van, sut); u3_noun pro = _peek_in(van, fop, way, axe, zoc); u3z(fop); u3z(zoc); return pro; } } } }