#include <stdint.h>
#include <stdio.h>

//int _check_conditions_OLD(uint32_t flg, uint8_t condflgs) {
//    printf("%x\n",condflgs);
//    /* Check conditions encoded into instructions */
//    int ret = (flg >> ((condflgs>>2)+1)) & 1;
//    if (condflgs&1) {
//        ret = !ret;
//    } if (!((condflgs>>1)&1)) {
//        ret = 1;
//    }
//    return ret;
//}

int check_conditions(uint32_t cpuflags, uint8_t check) {
    int ret = 1;

    if (check & 1) {
        int flag = (check >> 2) + 1;
        ret = (cpuflags >> flag) & 1;

        if ((check >> 1) & 1)
            ret = !ret;
    }

    return ret;
}

int test_bit(uint32_t bts, uint32_t bt) {
    /* Check if bit is set */
    return (bts >> bt) & 1;
}