#include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>
typedef struct atomic_flags {
unsigned int flags1 : 2;
unsigned int flags2 : 2;
unsigned int flags3 : 2;
unsigned int flags4 : 2;
unsigned int flags5 : 8;
unsigned int reserved : 16;
}atomic_flags;
union data {
atomic_flags i;
uint32_t q;
} data;
int main() {
union data test1;
union data test2;
test1.i.flags1 = 1;
test1.i.flags2 = 2;
test1.i.flags3 = 3;
test1.i.flags4 = 2;
test1.i.flags5 = 241;
test1.i.reserved = 1337;
__atomic_store_n(&test2.q, test1.q, __ATOMIC_SEQ_CST);
printf("test1 flags1: %u\n", test1.
i.
flags1); printf("test1 flags2: %u\n", test1.
i.
flags2); printf("test1 flags3: %u\n", test1.
i.
flags3); printf("test1 flags4: %u\n", test1.
i.
flags4); printf("test1 flags5: %u\n", test1.
i.
flags5); printf("test1 reserved: %u\n", test1.
i.
reserved);
printf("test2 flags1: %u\n", test2.
i.
flags1); printf("test2 flags2: %u\n", test2.
i.
flags2); printf("test2 flags3: %u\n", test2.
i.
flags3); printf("test2 flags4: %u\n", test2.
i.
flags4); printf("test2 flags5: %u\n", test2.
i.
flags5); printf("test2 reserved: %u\n", test2.
i.
reserved);
return 0;
}
I2luY2x1ZGUgPHN0ZGlvLmg+CiNpbmNsdWRlIDxzdGRsaWIuaD4KI2luY2x1ZGUgPGludHR5cGVzLmg+Cgp0eXBlZGVmIHN0cnVjdCBhdG9taWNfZmxhZ3MgewogICAgdW5zaWduZWQgaW50ICAgICAgICBmbGFnczEgICAgICAgOiAyOwogICAgdW5zaWduZWQgaW50ICAgICAgICBmbGFnczIgICAgICAgOiAyOwogICAgdW5zaWduZWQgaW50ICAgICAgICBmbGFnczMgICAgICAgOiAyOwogICAgdW5zaWduZWQgaW50ICAgICAgICBmbGFnczQgICAgICAgOiAyOwogICAgdW5zaWduZWQgaW50ICAgICAgICBmbGFnczUgICAgICAgOiA4OwogICAgdW5zaWduZWQgaW50ICAgICAgICByZXNlcnZlZCAgICAgOiAxN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