#include <stdio.h>
#include <stdlib.h>
#include <limits.h>
#include <inttypes.h>
uint32_t multiply (uint16_t a, uint16_t b)
{
register uint32_t result = 0;
char n = 0, n2 = 15;
result += (a & ( (int16_t)( ( b & (1 << n) ) << n2 ) ) / ( 1 << 15) ) << n;
n++; n2--;
result += (a & ( (int16_t)( ( b & (1 << n) ) << n2 ) ) / ( 1 << 15) ) << n;
n++; n2--;
result += (a & ( (int16_t)( ( b & (1 << n) ) << n2 ) ) / ( 1 << 15) ) << n;
n++; n2--;
result += (a & ( (int16_t)( ( b & (1 << n) ) << n2 ) ) / ( 1 << 15) ) << n;
n++; n2--;
result += (a & ( (int16_t)( ( b & (1 << n) ) << n2 ) ) / ( 1 << 15) ) << n;
n++; n2--;
result += (a & ( (int16_t)( ( b & (1 << n) ) << n2 ) ) / ( 1 << 15) ) << n;
n++; n2--;
result += (a & ( (int16_t)( ( b & (1 << n) ) << n2 ) ) / ( 1 << 15) ) << n;
n++; n2--;
result += (a & ( (int16_t)( ( b & (1 << n) ) << n2 ) ) / ( 1 << 15) ) << n;
n++; n2--;
result += (a & ( (int16_t)( ( b & (1 << n) ) << n2 ) ) / ( 1 << 15) ) << n;
n++; n2--;
result += (a & ( (int16_t)( ( b & (1 << n) ) << n2 ) ) / ( 1 << 15) ) << n;
n++; n2--;
result += (a & ( (int16_t)( ( b & (1 << n) ) << n2 ) ) / ( 1 << 15) ) << n;
n++; n2--;
result += (a & ( (int16_t)( ( b & (1 << n) ) << n2 ) ) / ( 1 << 15) ) << n;
n++; n2--;
result += (a & ( (int16_t)( ( b & (1 << n) ) << n2 ) ) / ( 1 << 15) ) << n;
n++; n2--;
result += (a & ( (int16_t)( ( b & (1 << n) ) << n2 ) ) / ( 1 << 15) ) << n;
n++; n2--;
result += (a & ( (int16_t)( ( b & (1 << n) ) << n2 ) ) / ( 1 << 15) ) << n;
n++; n2--;
result += (a & ( (int16_t)( ( b & (1 << n) ) << n2 ) ) / ( 1 << 15) ) << n;
return result;
}
int main(void)
{
uint16_t a, b;
a = 0;
b = 0;
do
{
if (multiply(a, b) != a * b)
"ERROR:\n"
"my: %u\n"
"norm: %u\n"
"%hu * %hu\n"
"\n",
multiply(a, b), (a * b),a, b
);
if (UINT16_MAX == a)
{
b++;
}
a++;
//fprintf(stderr, "%hu * %hu\n", a, b);
} while ( ( a != 0 ) || (b != 0) );
fprintf(stderr
, "%"PRIu16
"* ""%"PRIu16
"\n", a
, b
);
return 0;
}
I2luY2x1ZGUgPHN0ZGlvLmg+CiNpbmNsdWRlIDxzdGRsaWIuaD4KI2luY2x1ZGUgPGxpbWl0cy5oPgojaW5jbHVkZSA8aW50dHlwZXMuaD4KIAp1aW50MzJfdCBtdWx0aXBseSAodWludDE2X3QgYSwgdWludDE2X3QgYikKewogIHJlZ2lzdGVyIHVpbnQzMl90IHJlc3VsdCA9IDA7CiAgY2hhciBuID0gMCwgbjIgPSAxNTsKCiAgICByZXN1bHQgKz0gKGEgJiAgKCAoaW50MTZfdCkoICggYiAmICgxIDw8IG4pICkgPDwgbjIgKSApIC8gKCAxIDw8IDE1KSApIDw8IG47ICAKICBuKys7IG4yLS07CgogICAgcmVzdWx0ICs9IChhICYgICggKGludDE2X3QpKCAoIGIgJiAoMSA8PCBuKSApIDw8IG4yICkgKSAvICggMSA8PCAxNSkgKSA8PCBuOyAgCiAgbisrOyBuMi0tOwoKICAgIHJlc3VsdCArPSAoYSAmICAoIChpbnQxNl90KSggKCBiICYgKDEgPDwgbikgKSA8PCBuMiApICkgLyAoIDEgPDwgMTUpICkgPDwgbjsgIAogIG4rKzsgbjItLTsKCiAgICByZXN1bHQgKz0gKGEgJiAgKCAoaW50MTZfdCkoICggYiAmICgxIDw8IG4pICkgPDwgbjIgKSApIC8gKCAxIDw8IDE1KSApIDw8IG47ICAKICBuKys7IG4yLS07CgogICAgcmVzdWx0ICs9IChhICYgICggKGludDE2X3QpKCAoIGIgJiAoMSA8PCBuKSApIDw8IG4yICkgKSAvICggMSA8PCAxNSkgKSA8PCBuOyAgCiAgbisrOyBuMi0tOwoKICAgIHJlc3VsdCArPSAoYSAmICAoIChpbnQxNl90KSggKCBiICYgKDEgPDwgbikgKSA8PCBuMiApICkgLyAoIDEgPDwgMTUpICkgPDwgbjsgIAogIG4rKzsgbjItLTsKCiAgICByZXN1bHQgKz0gKGEgJiAgKCAoaW50MTZfdCkoICggYiAmICgxIDw8IG4pICkgPDwgbjIgKSApIC8gKCAxIDw8IDE1KSApIDw8IG47ICAKICBuKys7IG4yLS07CgogICAgcmVzdWx0ICs9IChhICYgICggKGludDE2X3QpKCAoIGIgJiAoMSA8PCBuKSApIDw8IG4yICkgKSAvICggMSA8PCAxNSkgKSA8PCBuOyAgCiAgbisrOyBuMi0tOwoKICAgIHJlc3VsdCArPSAoYSAmICAoIChpbnQxNl90KSggKCBiICYgKDEgPDwgbikgKSA8PCBuMiApICkgLyAoIDEgPDwgMTUpICkgPDwgbjsgIAogIG4rKzsgbjItLTsKCiAgICByZXN1bHQgKz0gKGEgJiAgKCAoaW50MTZfdCkoICggYiAmICgxIDw8IG4pICkgPDwgbjIgKSApIC8gKCAxIDw8IDE1KSApIDw8IG47ICAKICBuKys7IG4yLS07CgogICAgcmVzdWx0ICs9IChhICYgICggKGludDE2X3QpKCAoIGIgJiAoMSA8PCBuKSApIDw8IG4yICkgKSAvICggMSA8PCAxNSkgKSA8PCBuOyAgCiAgbisrOyBuMi0tOwoKICAgIHJlc3VsdCArPSAoYSAmICAoIChpbnQxNl90KSggKCBiICYgKDEgPDwgbikgKSA8PCBuMiApICkgLyAoIDEgPDwgMTUpICkgPDwgbjsgIAogIG4rKzsgbjItLTsKCiAgICByZXN1bHQgKz0gKGEgJiAgKCAoaW50MTZfdCkoICggYiAmICgxIDw8IG4pICkgPDwgbjIgKSApIC8gKCAxIDw8IDE1KSApIDw8IG47ICAKICBuKys7IG4yLS07CgogICAgcmVzdWx0ICs9IChhICYgICggKGludDE2X3QpKCAoIGIgJiAoMSA8PCBuKSApIDw8IG4yICkgKSAvICggMSA8PCAxNSkgKSA8PCBuOyAgCiAgbisrOyBuMi0tOwoKICAgIHJlc3VsdCArPSAoYSAmICAoIChpbnQxNl90KSggKCBiICYgKDEgPDwgbikgKSA8PCBuMiApICkgLyAoIDEgPDwgMTUpICkgPDwgbjsgIAogIG4rKzsgbjItLTsKCiAgICByZXN1bHQgKz0gKGEgJiAgKCAoaW50MTZfdCkoICggYiAmICgxIDw8IG4pICkgPDwgbjIgKSApIC8gKCAxIDw8IDE1KSApIDw8IG47ICAKICByZXR1cm4gcmVzdWx0Owp9CiAKaW50IG1haW4odm9pZCkKewogCiAgdWludDE2X3QgYSwgYjsKICBhID0gMDsKICBiID0gMDsKICAKICBkbwogIHsKICAgIGlmIChtdWx0aXBseShhLCBiKSAhPSBhICogYikKICAgIAogICAgCiAgICAgIGZwcmludGYoc3RkZXJyLAogICAgICAgICAgICAgICAiRVJST1I6XG4iCiAgICAgICAgICAgICAgICJteTogJXVcbiIKICAgICAgICAgICAgICAgIm5vcm06ICV1XG4iCiAgICAgICAgICAgICAgICIlaHUgKiAlaHVcbiIKICAgICAgICAgICAgICAgIlxuIiwKICAgICAgICAgICAgICAgbXVsdGlwbHkoYSwgYiksIChhICogYiksYSwgYgogICAgICAgICAgICAgKTsKCiAgICBpZiAoVUlOVDE2X01BWCA9PSBhKQogICAgewogICAgICBiKys7CiAgICB9CiAgICBhKys7CiAgLy9mcHJpbnRmKHN0ZGVyciwgIiVodSAqICVodVxuIiwgYSwgYik7CiAgfSB3aGlsZSAoICggYSAhPSAwICkgfHwgKGIgIT0gMCkgKTsKICAKICBmcHJpbnRmKHN0ZGVyciwgIiUiUFJJdTE2IiogIiIlIlBSSXUxNiJcbiIsIGEsIGIpOwogIHByaW50ZigiRG9uZSFcbiIpOwogCiAgcmV0dXJuIDA7Cn0=