#include <stdio.h>
struct __attribute__((__packed__)) {
unsigned char ch8;
unsigned short sh16;
unsigned int l32;
}mystruct1 = { 0xAA, 0xBBBB, 0xCCCCCCCC };
struct __attribute__((__packed__)){
unsigned char ch8_1;
unsigned short sh16;
unsigned char ch8_2;
unsigned int l32;
}mystruct2 = { 0x11, 0x2222, 0x11, 0x33333333 };
struct{
unsigned char ch8_1;
unsigned char ch8_2;
unsigned short sh16;
unsigned int l32;
}mystruct3 = { 0x11, 0x11, 0x2222, 0x33333333 };
struct{
unsigned short sh16;
unsigned char ch8;
unsigned int l32;
}mystruct4 = { 0xBBBB, 0xAA, 0xCCCCCCCC };
void main(void) {
unsigned int struct_size1;
unsigned int struct_size2;
unsigned int struct_size3;
unsigned int struct_size4;
// size here is 8 byte.
struct_size1 = sizeof(mystruct1);
struct_size2 = sizeof(mystruct2);
struct_size3 = sizeof(mystruct3);
struct_size4 = sizeof(mystruct4);
printf("%d %d %d %d", struct_size1
, struct_size2
, struct_size3
, struct_size4
); }
I2luY2x1ZGUgPHN0ZGlvLmg+CgpzdHJ1Y3QgX19hdHRyaWJ1dGVfXygoX19wYWNrZWRfXykpIHsKICAgIHVuc2lnbmVkIGNoYXIgY2g4OwogICAgdW5zaWduZWQgc2hvcnQgc2gxNjsKICAgIHVuc2lnbmVkIGludCBsMzI7Cn1teXN0cnVjdDEgPSB7IDB4QUEsIDB4QkJCQiwgMHhDQ0NDQ0NDQyB9OwoKc3RydWN0IF9fYXR0cmlidXRlX18oKF9fcGFja2VkX18pKXsKICAgIHVuc2lnbmVkIGNoYXIgY2g4XzE7CiAgICB1bnNpZ25lZCBzaG9ydCBzaDE2OwogICAgdW5zaWduZWQgY2hhciBjaDhfMjsKICAgIHVuc2lnbmVkIGludCBsMzI7Cn1teXN0cnVjdDIgPSB7IDB4MTEsIDB4MjIyMiwgMHgxMSwgMHgzMzMzMzMzMyB9OwoKc3RydWN0ewogICAgdW5zaWduZWQgY2hhciBjaDhfMTsKICAgIHVuc2lnbmVk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