Skip to content

Instantly share code, notes, and snippets.

@emilaxelsson
Last active November 30, 2016 14:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save emilaxelsson/4865e17bde8d43fdc22f1259225b1370 to your computer and use it in GitHub Desktop.
Save emilaxelsson/4865e17bde8d43fdc22f1259225b1370 to your computer and use it in GitHub Desktop.
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <string.h>
#include <tgmath.h>
#include <time.h>
void printTime(clock_t start, clock_t end)
{
printf("CPU time (sec): %f\n", (double) (end - start) / CLOCKS_PER_SEC);
}
#define FELD_PI 3.141592653589793
#define swap_ptr(a,b) do {void* TmP=a; a=b; b=TmP;} while (0)
int main()
{
clock_t obj0;
clock_t obj1;
double _Complex _store2[65536];
double _Complex *store2 = _store2;
double _Complex _store3[65536];
double _Complex *store3 = _store3;
uint32_t r4;
uint32_t v6;
uint32_t v7;
memset(store2, 0, 1048576);
r4 = 16;
double _Complex _a5[1 << (int32_t) r4 - 1];
double _Complex *a5 = _a5;
for (v6 = 0; v6 < 1 << (int32_t) r4 - 1; v6++) {
a5[v6] = exp(I * (2.0 * FELD_PI * (double) v6 / (double) (1 <<
(int32_t) r4)));
}
obj0 = clock();
for (v7 = 0; v7 < 100; v7++) {
uint32_t r8;
int32_t v9;
uint32_t r15;
uint32_t v16;
r8 = 65536;
for (v9 = (int32_t) r4 - 1; v9 >= 0; v9--) {
uint32_t v10;
for (v10 = 0; v10 < 65536; v10++) {
bool let11;
double _Complex let12;
double _Complex let13;
double _Complex let14;
let11 = (bool) (v10 & 1 << (int32_t) (uint32_t) v9);
let12 = store2[v10 ^ 1 << (int32_t) (uint32_t) v9];
let13 = store2[v10];
let14 = let11 ? let12 - let13 : let13 + let12;
store3[v10] = let11 ? a5[(v10 & ~(4294967295 <<
(int32_t) (uint32_t) v9)) <<
(int32_t) r4 - 1 -
(int32_t) (uint32_t) v9] *
let14 : let14;
}
swap_ptr(store2, store3);
r8 = 65536;
}
r15 = r8;
for (v16 = 1; v16 < r4; v16++) {
uint32_t v17;
for (v17 = 0; v17 < r15; v17++) {
uint32_t let18;
let18 = v17 >> 1;
store3[v17] = store2[(let18 >> (int32_t) v16 << 1 | (v17 &
1)) <<
(int32_t) v16 | (let18 & ~(4294967295 <<
(int32_t) v16))];
}
swap_ptr(store2, store3);
r15 = r15;
}
}
obj1 = clock();
printTime(obj0, obj1);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment