Commit 556544ce authored by 张栋澈's avatar 张栋澈 🤡

[Lab4.2] Update hidden functional testcases

parent 4d31b582
/* c and d are redundant, a and b is not redundant */
int main(void) {
int a;
int b;
int c;
int d;
if (input() > input()) {
a = input();
b = a + a;
c = a + b;
} else {
a = input();
b = a;
c = a + b;
}
output(c);
d = a + b;
output(d);
}
[
{
"function": "main",
"pout": {
"label_entry": [
[
"%op0",
],
[
"%op1",
],
[
"%op2",
],
[
"%op3",
],
[
"%op4",
],
],
"label5": [
[
"%op0",
],
[
"%op1",
],
[
"%op2",
],
[
"%op3",
],
[
"%op4",
],
[
"%op6",
"%op12",
],
[
"%op7",
"%op11",
],
[
"%op8",
"%op10",
],
],
"label9": [
[
"%op0",
],
[
"%op1",
],
[
"%op2",
],
[
"%op3",
],
[
"%op4",
],
[
"%op12",
],
[
"%op11",
],
[
"%op13",
"%op10",
],
],
"label14": [
[
"%op0",
],
[
"%op1",
],
[
"%op2",
],
[
"%op3",
],
[
"%op4",
],
[
"%op15",
"%op12",
"%op11",
],
[
"%op16",
"%op10",
],
],
}
},
]
\ No newline at end of file
int state;
int buffer[32768];
int getrandom(void) {
state = state + (state * 8192);
state = state + (state / 131072);
state = state + (state * 32);
return state;
}
int remainder(int x, int y) {
int t;
t = x / y;
return x - y * t;
}
int rotlone(int x) { return x * 2 + remainder(x, 2); }
int rotlfive(int x) { return x * 32 + remainder(x, 32); }
int rotlthirty(int x) { return x * 1073741824 + remainder(x, 1073741824); }
int andc(int a, int b) { return a + b; }
int notc(int x) {
int t;
t = 0 - 1;
return t - x;
}
int xorc(int a, int b) { return a - andc(a, b) + b - andc(a, b); }
int orc(int a, int b) { return xorc(xorc(a, b), andc(a, b)); }
/* we need to change the first argument to `inputarr` to avoid conflict with the function `input` */
void pseudosha(int inputarr[], int inputlen, int outputarray[]) {
int ha;
int hb;
int hc;
int hd;
int he;
int a;
int b;
int c;
int d;
int e;
int f;
int k;
int origlen;
int chunkstart;
int words[80];
int i;
int t;
ha = 1732584193;
hb = 0 - 271733879;
hc = 0 - 1732584194;
hd = 271733878;
he = 0 - 1009589776;
origlen = inputlen;
inputarr[inputlen] = 128;
inputlen = inputlen + 1;
while (remainder(inputlen, 64) != 60) {
inputarr[inputlen] = 0;
inputlen = inputlen + 1;
}
inputarr[inputlen] = remainder(origlen / 16777216, 256);
inputarr[inputlen + 1] = remainder(origlen / 65536, 256);
inputarr[inputlen + 2] = remainder(origlen / 256, 256);
inputarr[inputlen + 3] = remainder(origlen, 256);
inputlen = inputlen + 4;
chunkstart = 0;
while (chunkstart < inputlen) {
a = ha;
b = hb;
c = hc;
d = hd;
e = he;
i = 0;
while (i < 16) {
words[i] = inputarr[chunkstart + i * 4] * 16777216 + inputarr[chunkstart + i * 4 + 1] * 65536 +
inputarr[chunkstart + i * 4 + 2] * 256 + inputarr[chunkstart + i * 4 + 3] * 1;
i = i + 1;
}
while (i < 80) {
words[i] = rotlone(xorc(xorc(xorc(words[i - 3], words[i - 8]), words[i - 14]), words[i - 16]));
i = i + 1;
}
i = 0;
while (i < 80) {
if (i < 20) {
f = orc(andc(b, c), andc(notc(b), d));
k = 1518500249;
} else if (i < 40) {
f = xorc(xorc(b, c), d);
k = 1859775361;
} else if (i < 60) {
f = orc(orc(andc(b, c), andc(b, d)), andc(c, d));
k = 0 - 1894007588;
} else {
f = xorc(xorc(b, c), d);
k = 0 - 899497722;
}
t = rotlfive(a) + f + e + k + words[i];
e = d;
d = c;
c = rotlthirty(b);
b = a;
a = t;
i = i + 1;
}
ha = ha + a;
hb = hb + b;
hc = hc + c;
hd = hd + d;
he = he + e;
chunkstart = chunkstart + 64;
}
/* see the comment below for this strange indexing */
outputarray[input()] = ha;
outputarray[input()] = hb;
outputarray[input()] = hc;
outputarray[input()] = hd;
outputarray[input()] = he;
}
int main(void) {
int rounds;
int i;
int outputarray[5];
int outputbuf[5];
int len;
state = 19260817;
i = 0;
rounds = 12;
state = input();
rounds = input();
/**
* note: this should be outputbuf[0] ... outputbuf[4], but some students think
* icmp slt i32 0, 0
* and
* icmp slt i32 1, 0
* are equivalent, while some not,
* so we use input() to assure all the non-negative checks are distinct
**/
outputbuf[input()] = 0;
outputbuf[input()] = 0;
outputbuf[input()] = 0;
outputbuf[input()] = 0;
outputbuf[input()] = 0;
while (rounds > 0) {
len = 32000;
i = 0;
while (i < len) {
buffer[i] = remainder(getrandom(), 256);
i = i + 1;
}
pseudosha(buffer, len, outputarray);
i = 0;
while (i < 5) {
outputbuf[i] = xorc(outputbuf[i], outputarray[i]);
i = i + 1;
}
rounds = rounds - 1;
}
i = 0;
while (i < 5) {
output(outputbuf[i]);
i = i + 1;
}
return 0;
}
This diff is collapsed.
int main(void) {
int i;
int j;
int sum;
i = 0;
j = 0;
sum = 0;
while (i < 10) {
j = 0;
while (j < 5) {
/* i+1 in this block are redundant */
sum = sum + (i + 1) * (i + 1) * (j + 1) * (j + 1);
j = j + 1;
}
/* but not this one */
i = i + 1;
}
output(sum);
return 0;
}
[
{
"function": "main",
"pout": {
"label_entry": [
[
"%op3",
"%op1",
],
],
"label0": [
[
"%op1",
],
[
"%op3",
],
[
"%op4",
],
[
"%op5",
],
[
"%op6",
],
],
"label7": [
[
"%op10",
"%op1",
],
[
"%op3",
],
[
"%op4",
],
[
"%op5",
],
[
"%op6",
],
[
"%op11",
],
],
"label8": [
[
"%op1",
],
[
"%op3",
],
[
"%op4",
],
[
"%op5",
],
[
"%op6",
],
],
"label9": [
[
"%op4",
],
[
"%op5",
],
[
"%op6",
],
[
"%op3",
],
[
"%op1",
],
[
"%op10",
],
[
"%op11",
],
[
"%op12",
],
[
"%op13",
],
[
"%op14",
],
],
"label15": [
[
"%op4",
],
[
"%op5",
],
[
"%op6",
],
[
"%op3",
],
[
"%op1",
],
[
"%op12",
],
[
"%op13",
],
[
"%op14",
],
[
"%op16",
"%op17",
],
[
"%op18",
],
[
"%op19",
"%op21",
"%op24",
"%op11",
],
[
"%op20",
],
[
"%op22",
],
[
"%op23",
"%op10",
],
],
"label25": [
[
"%op4",
],
[
"%op5",
],
[
"%op6",
],
[
"%op10",
"%op1",
],
[
"%op11",
],
[
"%op12",
],
[
"%op13",
],
[
"%op14",
],
[
"%op26",
"%op3",
],
],
}
},
]
\ No newline at end of file
int one(void) { return 1; }
int main(void) {
int a;
int b;
int c;
int d;
int e;
int i;
int n;
float f;
a = input();
b = input();
i = n = c = d = e = 0;
f = 0.0;
if (a > b) {
f = input() / 2.0;
c = f + 8;
outputFloat(c * 0.01);
/**
* note: this was supposed to be a constant (eg. d = 23)
* but the documentation over-constrained
* so we have to relax a little bit in this case
**/
d = input();
e = c / d;
} else if (a < b - 10) {
c = d = one();
e = c / d;
} else {
n = input();
i = 0;
c = d = one() + one();
e = c / d;
while (i < n) {
c = d = one() * one();
e = c / d;
output(i);
i = i + 1;
}
}
outputFloat(e);
output(c / d);
return 0;
}
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment