frac32 time
frac32 M
frac32 D
bool32 mGate
bool32 dGate
frac32 time
bool32 gate
combo base1
combo base2
combo base3
combo bases
combo total
int M[attr_total];
int i;
int32_t m;
int32_t d;
int32_t Time;
int mtrig;
int dtrig;
int32_t temp1;
int32_t temp2;
int gate;
if (attr_bases == 1) {
for (i = 0; i < attr_total; i++) {
M[i] = attr_base1 << i;
}
}
if (attr_bases == 2) {
for (i = 0; i < attr_total; i++) {
M[i] = ((attr_base1 * ((i + 1) & 1)) + attr_base2 * ((i)&1)) << (i / 2);
}
}
if (attr_bases == 3) {
for (i = 0; i < attr_total; i++) {
int j = i - (i / 3) * 3;
M[i] =
(attr_base1 * (j == 0) + attr_base2 * (j == 1) + attr_base3 * (j == 2))
<< (i / 3);
}
}
int update = 1;
while (update > 0) {
update = 0;
for (i = 0; i < attr_total - 1; i++) {
if (M[i] > M[i + 1]) {
update = 1;
temp1 = M[i];
M[i] = M[i + 1];
M[i + 1] = temp1;
}
}
}
m = 1;
d = 1;
temp1 = 1;
temp2 = 1;
if (inlet_mGate > 0) {
m = ((inlet_M >> 21) * (attr_total - 1)) >> 6;
}
if (inlet_dGate > 0) {
d = ((inlet_D >> 21) * (attr_total - 1)) >> 6;
}
if ((inlet_mGate > 0) && !mtrig) {
mtrig = 1;
temp1 = m;
Time = inlet_time;
} else if (inlet_mGate == 0) {
mtrig = 0;
m = temp1;
}
if ((inlet_dGate > 0) && !dtrig) {
dtrig = 1;
temp2 = d;
Time = inlet_time;
} else if (inlet_dGate == 0) {
dtrig = 0;
d = temp2;
}
if (!(inlet_mGate || inlet_dGate)) {
gate = 0;
} else {
gate = 1;
}
outlet_time = Time / M[d] * M[m] >> 1;
outlet_gate = gate;