2014-06-02 19:03:48 +04:00
|
|
|
/* j/5/aes.c
|
|
|
|
**
|
|
|
|
** This file is in the public domain.
|
|
|
|
*/
|
|
|
|
#include "all.h"
|
|
|
|
#include "../pit.h"
|
|
|
|
|
|
|
|
union doub {
|
|
|
|
double d;
|
|
|
|
c3_d c;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/* functions
|
2014-06-02 20:43:26 +04:00
|
|
|
*/
|
2014-06-04 23:16:15 +04:00
|
|
|
/* sun
|
|
|
|
*/
|
|
|
|
u2_weak
|
2014-08-20 10:22:41 +04:00
|
|
|
j2_mcd(Pt5, rd, sun)(
|
2014-06-04 23:16:15 +04:00
|
|
|
u2_atom a)
|
|
|
|
{
|
|
|
|
union doub b;
|
2014-08-20 10:22:41 +04:00
|
|
|
b.d = (double) u2_cr_chub(0, a);
|
2014-06-05 06:46:12 +04:00
|
|
|
|
2014-06-04 23:16:15 +04:00
|
|
|
return u2_ci_chubs(1, &b.c);
|
|
|
|
}
|
|
|
|
|
|
|
|
u2_weak
|
2014-08-20 10:22:41 +04:00
|
|
|
j2_mc(Pt5, rd, sun)(
|
2014-06-04 23:16:15 +04:00
|
|
|
u2_noun cor)
|
|
|
|
{
|
|
|
|
u2_noun a;
|
|
|
|
|
2014-08-20 10:22:41 +04:00
|
|
|
if (u2_no == u2_cr_mean(cor, u2_cv_sam, &a, 0)
|
|
|
|
|| u2_no == u2ud(a)) {
|
|
|
|
return u2_cm_bail(c3__exit);
|
2014-06-04 23:16:15 +04:00
|
|
|
}
|
|
|
|
else {
|
2014-08-20 10:22:41 +04:00
|
|
|
return j2_mcd(Pt5, rd, sun)(a);
|
2014-06-04 23:16:15 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-06-02 20:43:26 +04:00
|
|
|
/* mul
|
2014-06-02 19:03:48 +04:00
|
|
|
*/
|
|
|
|
u2_weak
|
2014-08-20 10:22:41 +04:00
|
|
|
j2_mcd(Pt5, rd, mul)(
|
2014-06-02 19:03:48 +04:00
|
|
|
u2_atom a,
|
|
|
|
u2_atom b)
|
|
|
|
{
|
|
|
|
union doub c, d, e;
|
2014-08-20 10:22:41 +04:00
|
|
|
c.c = u2_cr_chub(0, a);
|
|
|
|
d.c = u2_cr_chub(0, b);
|
2014-06-02 19:03:48 +04:00
|
|
|
e.d = c.d * d.d;
|
2014-06-05 06:46:12 +04:00
|
|
|
|
2014-06-02 19:03:48 +04:00
|
|
|
return u2_ci_chubs(1, &e.c);
|
|
|
|
}
|
|
|
|
|
|
|
|
u2_weak
|
2014-08-20 10:22:41 +04:00
|
|
|
j2_mc(Pt5, rd, mul)(
|
2014-06-02 19:03:48 +04:00
|
|
|
u2_noun cor)
|
|
|
|
{
|
|
|
|
u2_noun a, b;
|
|
|
|
|
2014-08-20 10:22:41 +04:00
|
|
|
if ( u2_no == u2_cr_mean(cor, u2_cv_sam_2, &a, u2_cv_sam_3, &b, 0) ||
|
|
|
|
u2_no == u2ud(a) ||
|
|
|
|
u2_no == u2ud(b) )
|
2014-06-02 19:03:48 +04:00
|
|
|
{
|
2014-08-20 10:22:41 +04:00
|
|
|
return u2_cm_bail(c3__exit);
|
2014-06-02 19:03:48 +04:00
|
|
|
}
|
|
|
|
else {
|
2014-08-20 10:22:41 +04:00
|
|
|
return j2_mcd(Pt5, rd, mul)(a, b);
|
2014-06-02 19:03:48 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-06-03 19:41:25 +04:00
|
|
|
/* div
|
|
|
|
*/
|
|
|
|
u2_weak
|
2014-08-20 10:22:41 +04:00
|
|
|
j2_mcd(Pt5, rd, div)(
|
2014-06-03 19:41:25 +04:00
|
|
|
u2_atom a,
|
|
|
|
u2_atom b)
|
|
|
|
{
|
|
|
|
union doub c, d, e;
|
2014-08-20 10:22:41 +04:00
|
|
|
c.c = u2_cr_chub(0, a);
|
|
|
|
d.c = u2_cr_chub(0, b);
|
2014-06-03 19:41:25 +04:00
|
|
|
e.d = c.d / d.d;
|
2014-06-05 06:46:12 +04:00
|
|
|
|
2014-06-03 19:41:25 +04:00
|
|
|
return u2_ci_chubs(1, &e.c);
|
|
|
|
}
|
|
|
|
|
|
|
|
u2_weak
|
2014-08-20 10:22:41 +04:00
|
|
|
j2_mc(Pt5, rd, div)(
|
2014-06-03 19:41:25 +04:00
|
|
|
u2_noun cor)
|
|
|
|
{
|
|
|
|
u2_noun a, b;
|
2014-06-02 20:43:26 +04:00
|
|
|
|
2014-08-20 10:22:41 +04:00
|
|
|
if ( u2_no == u2_cr_mean(cor, u2_cv_sam_2, &a, u2_cv_sam_3, &b, 0) ||
|
|
|
|
u2_no == u2ud(a) ||
|
|
|
|
u2_no == u2ud(b) )
|
2014-06-03 19:41:25 +04:00
|
|
|
{
|
2014-08-20 10:22:41 +04:00
|
|
|
return u2_cm_bail(c3__exit);
|
2014-06-03 19:41:25 +04:00
|
|
|
}
|
|
|
|
else {
|
2014-08-20 10:22:41 +04:00
|
|
|
return j2_mcd(Pt5, rd, div)(a, b);
|
2014-06-03 19:41:25 +04:00
|
|
|
}
|
|
|
|
}
|
2014-06-02 20:43:26 +04:00
|
|
|
|
|
|
|
/* add
|
|
|
|
*/
|
|
|
|
u2_weak
|
2014-08-20 10:22:41 +04:00
|
|
|
j2_mcd(Pt5, rd, add)(
|
2014-06-02 20:43:26 +04:00
|
|
|
u2_atom a,
|
|
|
|
u2_atom b)
|
|
|
|
{
|
|
|
|
union doub c, d, e;
|
2014-08-20 10:22:41 +04:00
|
|
|
c.c = u2_cr_chub(0, a);
|
|
|
|
d.c = u2_cr_chub(0, b);
|
2014-06-02 20:43:26 +04:00
|
|
|
e.d = c.d + d.d;
|
2014-06-05 06:46:12 +04:00
|
|
|
|
2014-06-02 20:43:26 +04:00
|
|
|
return u2_ci_chubs(1, &e.c);
|
|
|
|
}
|
|
|
|
|
|
|
|
u2_weak
|
2014-08-20 10:22:41 +04:00
|
|
|
j2_mc(Pt5, rd, add)(
|
2014-06-02 20:43:26 +04:00
|
|
|
u2_noun cor)
|
|
|
|
{
|
|
|
|
u2_noun a, b;
|
|
|
|
|
2014-08-20 10:22:41 +04:00
|
|
|
if ( u2_no == u2_cr_mean(cor, u2_cv_sam_2, &a, u2_cv_sam_3, &b, 0) ||
|
|
|
|
u2_no == u2ud(a) ||
|
|
|
|
u2_no == u2ud(b) )
|
2014-06-02 20:43:26 +04:00
|
|
|
{
|
2014-08-20 10:22:41 +04:00
|
|
|
return u2_cm_bail(c3__exit);
|
2014-06-02 20:43:26 +04:00
|
|
|
}
|
|
|
|
else {
|
2014-08-20 10:22:41 +04:00
|
|
|
return j2_mcd(Pt5, rd, add)(a, b);
|
2014-06-02 20:43:26 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-06-02 23:13:58 +04:00
|
|
|
/* sub
|
|
|
|
*/
|
|
|
|
u2_weak
|
2014-08-20 10:22:41 +04:00
|
|
|
j2_mcd(Pt5, rd, sub)(
|
2014-06-02 23:13:58 +04:00
|
|
|
u2_atom a,
|
|
|
|
u2_atom b)
|
|
|
|
{
|
|
|
|
union doub c, d, e;
|
2014-08-20 10:22:41 +04:00
|
|
|
c.c = u2_cr_chub(0, a);
|
|
|
|
d.c = u2_cr_chub(0, b);
|
2014-06-02 23:13:58 +04:00
|
|
|
e.d = c.d - d.d;
|
2014-06-05 06:46:12 +04:00
|
|
|
|
2014-06-02 23:13:58 +04:00
|
|
|
return u2_ci_chubs(1, &e.c);
|
|
|
|
}
|
|
|
|
|
|
|
|
u2_weak
|
2014-08-20 10:22:41 +04:00
|
|
|
j2_mc(Pt5, rd, sub)(
|
2014-06-02 23:13:58 +04:00
|
|
|
u2_noun cor)
|
|
|
|
{
|
|
|
|
u2_noun a, b;
|
|
|
|
|
2014-08-20 10:22:41 +04:00
|
|
|
if ( u2_no == u2_cr_mean(cor, u2_cv_sam_2, &a, u2_cv_sam_3, &b, 0) ||
|
|
|
|
u2_no == u2ud(a) ||
|
|
|
|
u2_no == u2ud(b) )
|
2014-06-02 23:13:58 +04:00
|
|
|
{
|
2014-08-20 10:22:41 +04:00
|
|
|
return u2_cm_bail(c3__exit);
|
2014-06-02 23:13:58 +04:00
|
|
|
}
|
|
|
|
else {
|
2014-08-20 10:22:41 +04:00
|
|
|
return j2_mcd(Pt5, rd, sub)(a, b);
|
2014-06-02 23:13:58 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-06-03 22:10:49 +04:00
|
|
|
/* lte
|
|
|
|
*/
|
|
|
|
u2_weak
|
2014-08-20 10:22:41 +04:00
|
|
|
j2_mcd(Pt5, rd, lte)(
|
2014-06-03 22:10:49 +04:00
|
|
|
u2_atom a,
|
|
|
|
u2_atom b)
|
|
|
|
{
|
|
|
|
union doub c, d;
|
2014-08-20 10:22:41 +04:00
|
|
|
c.c = u2_cr_chub(0, a);
|
|
|
|
d.c = u2_cr_chub(0, b);
|
2014-06-05 06:46:12 +04:00
|
|
|
|
2014-06-03 22:10:49 +04:00
|
|
|
return u2_say(c.d <= d.d);
|
|
|
|
}
|
|
|
|
|
|
|
|
u2_weak
|
2014-08-20 10:22:41 +04:00
|
|
|
j2_mc(Pt5, rd, lte)(
|
2014-06-03 22:10:49 +04:00
|
|
|
u2_noun cor)
|
|
|
|
{
|
|
|
|
u2_noun a, b;
|
|
|
|
|
2014-08-20 10:22:41 +04:00
|
|
|
if ( u2_no == u2_cr_mean(cor, u2_cv_sam_2, &a, u2_cv_sam_3, &b, 0) ||
|
|
|
|
u2_no == u2ud(a) ||
|
|
|
|
u2_no == u2ud(b) )
|
2014-06-03 22:10:49 +04:00
|
|
|
{
|
2014-08-20 10:22:41 +04:00
|
|
|
return u2_cm_bail(c3__exit);
|
2014-06-03 22:10:49 +04:00
|
|
|
}
|
|
|
|
else {
|
2014-08-20 10:22:41 +04:00
|
|
|
return j2_mcd(Pt5, rd, lte)(a, b);
|
2014-06-03 22:10:49 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* lth
|
|
|
|
*/
|
|
|
|
u2_weak
|
2014-08-20 10:22:41 +04:00
|
|
|
j2_mcd(Pt5, rd, lth)(
|
2014-06-03 22:10:49 +04:00
|
|
|
u2_atom a,
|
|
|
|
u2_atom b)
|
|
|
|
{
|
|
|
|
union doub c, d;
|
2014-08-20 10:22:41 +04:00
|
|
|
c.c = u2_cr_chub(0, a);
|
|
|
|
d.c = u2_cr_chub(0, b);
|
2014-06-05 06:46:12 +04:00
|
|
|
|
2014-06-03 22:10:49 +04:00
|
|
|
return u2_say(c.d < d.d);
|
|
|
|
}
|
|
|
|
|
|
|
|
u2_weak
|
2014-08-20 10:22:41 +04:00
|
|
|
j2_mc(Pt5, rd, lth)(
|
2014-06-03 22:10:49 +04:00
|
|
|
u2_noun cor)
|
|
|
|
{
|
|
|
|
u2_noun a, b;
|
|
|
|
|
2014-08-20 10:22:41 +04:00
|
|
|
if ( u2_no == u2_cr_mean(cor, u2_cv_sam_2, &a, u2_cv_sam_3, &b, 0) ||
|
|
|
|
u2_no == u2ud(a) ||
|
|
|
|
u2_no == u2ud(b) )
|
2014-06-03 22:10:49 +04:00
|
|
|
{
|
2014-08-20 10:22:41 +04:00
|
|
|
return u2_cm_bail(c3__exit);
|
2014-06-03 22:10:49 +04:00
|
|
|
}
|
|
|
|
else {
|
2014-08-20 10:22:41 +04:00
|
|
|
return j2_mcd(Pt5, rd, lth)(a, b);
|
2014-06-03 22:10:49 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* gte
|
|
|
|
*/
|
|
|
|
u2_weak
|
2014-08-20 10:22:41 +04:00
|
|
|
j2_mcd(Pt5, rd, gte)(
|
2014-06-03 22:10:49 +04:00
|
|
|
u2_atom a,
|
|
|
|
u2_atom b)
|
|
|
|
{
|
|
|
|
union doub c, d;
|
2014-08-20 10:22:41 +04:00
|
|
|
c.c = u2_cr_chub(0, a);
|
|
|
|
d.c = u2_cr_chub(0, b);
|
2014-06-05 06:46:12 +04:00
|
|
|
|
2014-06-03 22:10:49 +04:00
|
|
|
return u2_say(c.d >= d.d);
|
|
|
|
}
|
|
|
|
|
|
|
|
u2_weak
|
2014-08-20 10:22:41 +04:00
|
|
|
j2_mc(Pt5, rd, gte)(
|
2014-06-03 22:10:49 +04:00
|
|
|
u2_noun cor)
|
|
|
|
{
|
|
|
|
u2_noun a, b;
|
|
|
|
|
2014-08-20 10:22:41 +04:00
|
|
|
if ( u2_no == u2_cr_mean(cor, u2_cv_sam_2, &a, u2_cv_sam_3, &b, 0) ||
|
|
|
|
u2_no == u2ud(a) ||
|
|
|
|
u2_no == u2ud(b) )
|
2014-06-03 22:10:49 +04:00
|
|
|
{
|
2014-08-20 10:22:41 +04:00
|
|
|
return u2_cm_bail(c3__exit);
|
2014-06-03 22:10:49 +04:00
|
|
|
}
|
|
|
|
else {
|
2014-08-20 10:22:41 +04:00
|
|
|
return j2_mcd(Pt5, rd, gte)(a, b);
|
2014-06-03 22:10:49 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* gth
|
|
|
|
*/
|
|
|
|
u2_weak
|
2014-08-20 10:22:41 +04:00
|
|
|
j2_mcd(Pt5, rd, gth)(
|
2014-06-03 22:10:49 +04:00
|
|
|
u2_atom a,
|
|
|
|
u2_atom b)
|
|
|
|
{
|
|
|
|
union doub c, d;
|
2014-08-20 10:22:41 +04:00
|
|
|
c.c = u2_cr_chub(0, a);
|
|
|
|
d.c = u2_cr_chub(0, b);
|
2014-06-05 06:46:12 +04:00
|
|
|
|
2014-06-03 22:10:49 +04:00
|
|
|
return u2_say(c.d > d.d);
|
|
|
|
}
|
|
|
|
|
|
|
|
u2_weak
|
2014-08-20 10:22:41 +04:00
|
|
|
j2_mc(Pt5, rd, gth)(
|
2014-06-03 22:10:49 +04:00
|
|
|
u2_noun cor)
|
|
|
|
{
|
|
|
|
u2_noun a, b;
|
|
|
|
|
2014-08-20 10:22:41 +04:00
|
|
|
if ( u2_no == u2_cr_mean(cor, u2_cv_sam_2, &a, u2_cv_sam_3, &b, 0) ||
|
|
|
|
u2_no == u2ud(a) ||
|
|
|
|
u2_no == u2ud(b) )
|
2014-06-03 22:10:49 +04:00
|
|
|
{
|
2014-08-20 10:22:41 +04:00
|
|
|
return u2_cm_bail(c3__exit);
|
2014-06-03 22:10:49 +04:00
|
|
|
}
|
|
|
|
else {
|
2014-08-20 10:22:41 +04:00
|
|
|
return j2_mcd(Pt5, rd, gth)(a, b);
|
2014-06-03 22:10:49 +04:00
|
|
|
}
|
|
|
|
}
|