#include <iostream>
using namespace std;
enum WindingOrder {
BOTTOM = 0,
RIGHT,
TOP,
LEFT
};
void DoWinding1(unsigned int const *const in, unsigned int *const out, const enum WindingOrder ord)
{
static const unsigned int order[4][4] = { [BOTTOM] = {0,1,2,1},
[RIGHT] = {2,1,2,3},
[TOP] = {3,4,0,3},
[LEFT] = {0,3,0,1} };
out[0] = in[order[ord][0]];
out[1] = in[order[ord][1]];
out[2] = in[order[ord][2]];
out[3] = in[order[ord][3]];
}
int main() {
unsigned int idx;
unsigned int rect[4] = {1, 3, 4, 5};
unsigned int out[4] = {0};
DoWinding1(rect, out, BOTTOM);
std::cout << out[0] << out[1] << out[2] << out[3] << std::endl;
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgoKdXNpbmcgbmFtZXNwYWNlIHN0ZDsKCmVudW0gV2luZGluZ09yZGVyIHsKICAgIEJPVFRPTSA9IDAsCiAgICBSSUdIVCwKICAgIFRPUCwKICAgIExFRlQKfTsKCnZvaWQgRG9XaW5kaW5nMSh1bnNpZ25lZCBpbnQgY29uc3QgKmNvbnN0IGluLCB1bnNpZ25lZCBpbnQgKmNvbnN0IG91dCwgY29uc3QgZW51bSBXaW5kaW5nT3JkZXIgb3JkKQp7CglzdGF0aWMgY29uc3QgdW5zaWduZWQgaW50IG9yZGVyWzRdWzRdID0geyBbQk9UVE9NXSA9IHswLDEsMiwxfSwKCSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIFtSSUdIVF0gID0gezIsMSwyLDN9LAoJICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgW1RPUF0gICAgPSB7Myw0LDAsM30sCgkgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBbTEVGVF0gICA9IHswLDMsMCwxfSB9OwoJb3V0WzBdID0gaW5bb3JkZXJbb3JkXVswXV07IAoJb3V0WzFdID0gaW5bb3JkZXJbb3JkXVsxXV07CglvdXRbMl0gPSBpbltvcmRlcltvcmRdWzJdXTsKCW91dFszXSA9IGluW29yZGVyW29yZF1bM11dOwp9CgoKaW50IG1haW4oKSB7Cgl1bnNpZ25lZCBpbnQgaWR4OwoJdW5zaWduZWQgaW50IHJlY3RbNF0gPSB7MSwgMywgNCwgNX07Cgl1bnNpZ25lZCBpbnQgb3V0WzRdID0gezB9OwoKCURvV2luZGluZzEocmVjdCwgb3V0LCBCT1RUT00pOwogICAgCglzdGQ6OmNvdXQgPDwgb3V0WzBdIDw8IG91dFsxXSA8PCBvdXRbMl0gPDwgb3V0WzNdIDw8IHN0ZDo6ZW5kbDsKCglyZXR1cm4gMDsKfQ==