#include <iostream>
using namespace std;
#define ALIGNOF(type) ((int)(offsetof(struct {char c; type t;}, t)))
union ull {
unsigned long long m;
};
struct sll {
unsigned long long m;
};
struct sull {
ull m;
};
union ulla {
unsigned long long m;
} __attribute__ ((aligned(8)));
struct slla {
unsigned long long m;
};
struct sulla {
ulla m;
} __attribute__ ((aligned(8)));;
long long a;
char b;
long long c;
char d;
ull e;
int main() {
#define pr(v) cout << #v ": " << (v) << endl
#define prt(t) pr(sizeof(t)); pr(__alignof__(t)); pr(ALIGNOF(t))
prt(unsigned long long);
prt(ull);
prt(ull);
prt(sll);
prt(ulla);
prt(ulla);
prt(slla);
// test real alignment of long long
pr(size_t((void*)&a));
pr(size_t((void*)&b));
pr(size_t((void*)&c));
pr(size_t((void*)&d));
pr(size_t((void*)&e));
pr(size_t((void*)&c) - size_t((void*)&b));
pr(size_t((void*)&e) - size_t((void*)&d));
{ // test local objects
long long a;
char b;
long long c;
char d;
ull e;
pr(size_t((void*)&a));
pr(size_t((void*)&b));
pr(size_t((void*)&c));
pr(size_t((void*)&d));
pr(size_t((void*)&e));
pr(size_t((void*)&c) - size_t((void*)&b));
pr(size_t((void*)&e) - size_t((void*)&d));
}
};
I2luY2x1ZGUgPGlvc3RyZWFtPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKI2RlZmluZSBBTElHTk9GKHR5cGUpICgoaW50KShvZmZzZXRvZihzdHJ1Y3Qge2NoYXIgYzsgdHlwZSB0O30sIHQpKSkKCnVuaW9uIHVsbCB7CiAgdW5zaWduZWQgbG9uZyBsb25nIG07Cn07CgpzdHJ1Y3Qgc2xsIHsKICB1bnNpZ25lZCBsb25nIGxvbmcgbTsKfTsKCnN0cnVjdCBzdWxsIHsKICB1bGwgbTsKfTsKCnVuaW9uIHVsbGEgewogIHVuc2lnbmVkIGxvbmcgbG9uZyBtOwp9IF9fYXR0cmlidXRlX18gKChhbGlnbmVkKDgpKSk7CgpzdHJ1Y3Qgc2xsYSB7CiAgdW5zaWduZWQgbG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