+#undef PSI_CALC
+
+token_t psi_calc_mod(token_t t1, impl_val *v1, token_t t2, impl_val *v2, impl_val *res)
+{
+ impl_val i1, i2;
+
+ PSI_CALC_CAST(t1, v1, =, PSI_T_INT64, &i1);
+ PSI_CALC_CAST(t2, v2, =, PSI_T_INT64, &i2);
+
+ res->i64 = i1.i64 % i2.i64;
+
+ return PSI_T_INT64;
+}
+
+#define PSI_CALC_BIT_FN(op) token_t psi_calc_##op(token_t t1, impl_val *v1, token_t t2, impl_val *v2, impl_val *res) \
+{ \
+ impl_val i1, i2; \
+ PSI_CALC_CAST(t1, v1, =, PSI_T_UINT64, &i1); \
+ PSI_CALC_CAST(t2, v2, =, PSI_T_UINT64, &i2); \
+ res->u64 = PSI_CALC(i1.u64, i2.u64); \
+ return PSI_T_UINT64; \
+}
+
+#define PSI_CALC(var1, var2) (var1) << (var2)
+PSI_CALC_BIT_FN(bin_lshift)
+#undef PSI_CALC
+#define PSI_CALC(var1, var2) (var1) >> (var2)
+PSI_CALC_BIT_FN(bin_rshift)
+#undef PSI_CALC
+#define PSI_CALC(var1, var2) (var1) & (var2)
+PSI_CALC_BIT_FN(bin_and)
+#undef PSI_CALC
+#define PSI_CALC(var1, var2) (var1) ^ (var2)
+PSI_CALC_BIT_FN(bin_xor)
+#undef PSI_CALC
+#define PSI_CALC(var1, var2) (var1) | (var2)
+PSI_CALC_BIT_FN(bin_or)
+#undef PSI_CALC
+
+token_t psi_calc_not(token_t t1, impl_val *v1, token_t t2, impl_val *v2, impl_val *res)
+{
+ (void) t2;
+ (void) v2;
+
+ PSI_CALC_CAST(t1, v1, =!, t1, res);
+ return t1;
+}
+
+token_t psi_calc_bin_not(token_t t1, impl_val *v1, token_t t2, impl_val *v2, impl_val *res)
+{
+ impl_val i1;
+
+ (void) t2;
+ (void) v2;
+
+ PSI_CALC_CAST(t1, v1, =, PSI_T_UINT64, &i1);
+ PSI_CALC_CAST_INT(t1, &i1, =~, t1, res);
+ return t1;
+}