#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
int get_byte(char b) {
if (b >= 'A' && b <='F')
return b - 'A' + 10;
else if (b >= '0' && b <='9')
return b - '0';
return -1;
}
char* output_string(char *src) { // Assumes a nul terminated string
char *output
= malloc(length
/2 + 1); char *to_ret = output;
while(*src) {
int nibble1 = get_byte(src[0]);
int nibble2 = get_byte(src[1]);
assert(nibble1
!= -1 && nibble2
!= -1); *output = (nibble1 << 4) | nibble2;
output++;
src+=2;
}
*output = 0;
return to_ret;
}
int main(void) {
char *output = output_string("E5A682E682A8");
return 0;
}
I2luY2x1ZGUgPHN0ZGlvLmg+CiNpbmNsdWRlIDxzdGRsaWIuaD4KI2luY2x1ZGUgPHN0cmluZy5oPgojaW5jbHVkZSA8YXNzZXJ0Lmg+CgppbnQgZ2V0X2J5dGUoY2hhciBiKSB7CiAgICBpZiAoYiA+PSAnQScgJiYgYiA8PSdGJykKICAgICAgICByZXR1cm4gYiAtICdBJyArIDEwOwogICAgZWxzZSBpZiAoYiA+PSAnMCcgJiYgYiA8PSc5JykgCiAgICAgICAgcmV0dXJuIGIgLSAnMCc7CiAgICByZXR1cm4gLTE7Cn0KCgpjaGFyKiBvdXRwdXRfc3RyaW5nKGNoYXIgKnNyYykgeyAvLyBBc3N1bWVzIGEgbnVsIHRlcm1pbmF0ZWQgc3RyaW5nICAgIAogICAgaW50IGxlbmd0aCA9IHN0cmxlbihzcmMpOwogICAgYXNzZXJ0KGxlbmd0aCAlIDIgPT0gMCk7CiAgICBjaGFyICpvdXRwdXQgPSBtYWxsb2MobGVuZ3RoLzIgKyAxKTsKICAgIGNoYXIgKnRvX3JldCA9IG91dHB1dDsKICAgIGFzc2VydChvdXRwdXQgIT0gTlVMTCk7CiAgICB3aGlsZSgqc3JjKSB7CiAgICAgICAgaW50IG5pYmJsZTEgPSBnZXRfYnl0ZShzcmNbMF0pOwogICAgICAgIGludCBuaWJibGUyID0gZ2V0X2J5dGUoc3JjWzFdKTsKICAgICA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