original_code:
void
e3_timer_test(jasmine_t *jasmine) {
    test_t test;
    for ((jasmine)->state = 0, (jasmine)->current = 0, (jasmine)->last = 0, puts("the system timer"); (3 == (jasmine)->state) ? (puts(""), 0) : 1; ) {
        for (; 0 == (jasmine)->state; (jasmine)->state = 1) {
            test.counter = 0;
        }
        for (; 2 == (jasmine)->state; (jasmine)->state = ((jasmine)->current == (jasmine)->last) ? 3 : 0) {
        }
        for ((jasmine)->group = 2, (jasmine)->last = (unsigned short) ((jasmine)->last < 64 ? 64 : (jasmine)->last); 1 == (jasmine)->state && (jasmine)->current < 64 && (64 == ((jasmine)->current = 64)); (jasmine)->state = 2, ((jasmine)->group == 2 ? ((jasmine)->ignored++, puts(" ! " "can tick without any timers created"), 2) : ((jasmine)->group == 1 ? ((jasmine)->passed++, puts(" ✓ " "can tick without any timers created"), 1) : ((jasmine)->failed++, printf(" ✗ " "can tick without any timers created" ": expected %s\r\n", (jasmine)->reason), 0)))) {
            if (!(!e3_timer_tick())) { (jasmine)->expects++; (jasmine)->group = 0; (jasmine)->reason = "!e3_timer_tick()"; continue; } else { (jasmine)->group = 1; (jasmine)->expects++; };
            if (!(test.counter == 0)) { (jasmine)->expects++; (jasmine)->group = 0; (jasmine)->reason = "test.counter == 0"; continue; } else { (jasmine)->group = 1; (jasmine)->expects++; };
        }
        for ((jasmine)->group = 2, (jasmine)->last = (unsigned short) ((jasmine)->last < 69 ? 69 : (jasmine)->last); 1 == (jasmine)->state && (jasmine)->current < 69 && (69 == ((jasmine)->current = 69)); (jasmine)->state = 2, ((jasmine)->group == 2 ? ((jasmine)->ignored++, puts(" ! " "does not require an interrupt for a zero tick"), 2) : ((jasmine)->group == 1 ? ((jasmine)->passed++, puts(" ✓ " "does not require an interrupt for a zero tick"), 1) : ((jasmine)->failed++, printf(" ✗ " "does not require an interrupt for a zero tick" ": expected %s\r\n", (jasmine)->reason), 0)))) {
            e3_timer_create(&test.timer_1, 0,
                (e3_timer_function_t) increment, &test);
            if (!(test.counter == 0)) { (jasmine)->expects++; (jasmine)->group = 0; (jasmine)->reason = "test.counter == 0"; continue; } else { (jasmine)->group = 1; (jasmine)->expects++; };
            if (!(!e3_timer_tick())) { (jasmine)->expects++; (jasmine)->group = 0; (jasmine)->reason = "!e3_timer_tick()"; continue; } else { (jasmine)->group = 1; (jasmine)->expects++; };
            if (!(test.counter == 1)) { (jasmine)->expects++; (jasmine)->group = 0; (jasmine)->reason = "test.counter == 1"; continue; } else { (jasmine)->group = 1; (jasmine)->expects++; };
        }
        for ((jasmine)->group = 2, (jasmine)->last = (unsigned short) ((jasmine)->last < 78 ? 78 : (jasmine)->last); 1 == (jasmine)->state && (jasmine)->current < 78 && (78 == ((jasmine)->current = 78)); (jasmine)->state = 2, ((jasmine)->group == 2 ? ((jasmine)->ignored++, puts(" ! " "can have multiple timers with the same ticks"), 2) : ((jasmine)->group == 1 ? ((jasmine)->passed++, puts(" ✓ " "can have multiple timers with the same ticks"), 1) : ((jasmine)->failed++, printf(" ✗ " "can have multiple timers with the same ticks" ": expected %s\r\n", (jasmine)->reason), 0)))) {
            e3_timer_create(&test.timer_1, 0,
                (e3_timer_function_t) increment, &test);
            e3_timer_create(&test.timer_2, 0,
                (e3_timer_function_t) increment, &test);
            if (!(test.counter == 0)) { (jasmine)->expects++; (jasmine)->group = 0; (jasmine)->reason = "test.counter == 0"; continue; } else { (jasmine)->group = 1; (jasmine)->expects++; };
            if (!(!e3_timer_tick())) { (jasmine)->expects++; (jasmine)->group = 0; (jasmine)->reason = "!e3_timer_tick()"; continue; } else { (jasmine)->group = 1; (jasmine)->expects++; };
            if (!(test.counter == 2)) { (jasmine)->expects++; (jasmine)->group = 0; (jasmine)->reason = "test.counter == 2"; continue; } else { (jasmine)->group = 1; (jasmine)->expects++; };
        }
        for ((jasmine)->group = 2, (jasmine)->last = (unsigned short) ((jasmine)->last < 90 ? 90 : (jasmine)->last); 1 == (jasmine)->state && (jasmine)->current < 90 && (90 == ((jasmine)->current = 90)); (jasmine)->state = 2, ((jasmine)->group == 2 ? ((jasmine)->ignored++, puts(" ! " "will ignore invalid timer functions"), 2) : ((jasmine)->group == 1 ? ((jasmine)->passed++, puts(" ✓ " "will ignore invalid timer functions"), 1) : ((jasmine)->failed++, printf(" ✗ " "will ignore invalid timer functions" ": expected %s\r\n", (jasmine)->reason), 0)))) {
            e3_timer_create(&test.timer_1, 0, 0, 0);
            if (!(test.counter == 0)) { (jasmine)->expects++; (jasmine)->group = 0; (jasmine)->reason = "test.counter == 0"; continue; } else { (jasmine)->group = 1; (jasmine)->expects++; };
            if (!(!e3_timer_tick())) { (jasmine)->expects++; (jasmine)->group = 0; (jasmine)->reason = "!e3_timer_tick()"; continue; } else { (jasmine)->group = 1; (jasmine)->expects++; };
            if (!(test.counter == 0)) { (jasmine)->expects++; (jasmine)->group = 0; (jasmine)->reason = "test.counter == 0"; continue; } else { (jasmine)->group = 1; (jasmine)->expects++; };
        }
        for ((jasmine)->group = 2, (jasmine)->last = (unsigned short) ((jasmine)->last < 97 ? 97 : (jasmine)->last); 1 == (jasmine)->state && (jasmine)->current < 97 && (97 == ((jasmine)->current = 97)); (jasmine)->state = 2, ((jasmine)->group == 2 ? ((jasmine)->ignored++, puts(" ! " "can delete a timer that has been created"), 2) : ((jasmine)->group == 1 ? ((jasmine)->passed++, puts(" ✓ " "can delete a timer that has been created"), 1) : ((jasmine)->failed++, printf(" ✗ " "can delete a timer that has been created" ": expected %s\r\n", (jasmine)->reason), 0)))) {
            e3_timer_create(&test.timer_1, 0,
                (e3_timer_function_t) triple, &test);
            e3_timer_create(&test.timer_2, 0,
                (e3_timer_function_t) increment, &test);
            if (!(test.counter == 0)) { (jasmine)->expects++; (jasmine)->group = 0; (jasmine)->reason = "test.counter == 0"; continue; } else { (jasmine)->group = 1; (jasmine)->expects++; };
            e3_timer_delete(&test.timer_1);
            if (!(!e3_timer_tick())) { (jasmine)->expects++; (jasmine)->group = 0; (jasmine)->reason = "!e3_timer_tick()"; continue; } else { (jasmine)->group = 1; (jasmine)->expects++; };
            if (!(test.counter == 1)) { (jasmine)->expects++; (jasmine)->group = 0; (jasmine)->reason = "test.counter == 1"; continue; } else { (jasmine)->group = 1; (jasmine)->expects++; };
        }
        for ((jasmine)->group = 2, (jasmine)->last = (unsigned short) ((jasmine)->last < 110 ? 110 : (jasmine)->last); 1 == (jasmine)->state && (jasmine)->current < 110 && (110 == ((jasmine)->current = 110)); (jasmine)->state = 2, ((jasmine)->group == 2 ? ((jasmine)->ignored++, puts(" ! " "can delete a timer that has not been created"), 2) : ((jasmine)->group == 1 ? ((jasmine)->passed++, puts(" ✓ " "can delete a timer that has not been created"), 1) : ((jasmine)->failed++, printf(" ✗ " "can delete a timer that has not been created" ": expected %s\r\n", (jasmine)->reason), 0)))) {
            e3_timer_delete(&test.timer_1);
            if (!(!e3_timer_tick())) { (jasmine)->expects++; (jasmine)->group = 0; (jasmine)->reason = "!e3_timer_tick()"; continue; } else { (jasmine)->group = 1; (jasmine)->expects++; };
            if (!(test.counter == 0)) { (jasmine)->expects++; (jasmine)->group = 0; (jasmine)->reason = "test.counter == 0"; continue; } else { (jasmine)->group = 1; (jasmine)->expects++; };
        }
        for ((jasmine)->group = 2, (jasmine)->last = (unsigned short) ((jasmine)->last < 116 ? 116 : (jasmine)->last); 1 == (jasmine)->state && (jasmine)->current < 116 && (116 == ((jasmine)->current = 116)); (jasmine)->state = 2, ((jasmine)->group == 2 ? ((jasmine)->ignored++, puts(" ! " "can tick faster than the interrupt"), 2) : ((jasmine)->group == 1 ? ((jasmine)->passed++, puts(" ✓ " "can tick faster than the interrupt"), 1) : ((jasmine)->failed++, printf(" ✗ " "can tick faster than the interrupt" ": expected %s\r\n", (jasmine)->reason), 0)))) {
            e3_timer_create(&test.timer_1, 1,
                (e3_timer_function_t) increment, &test);
            if (!(test.counter == 0)) { (jasmine)->expects++; (jasmine)->group = 0; (jasmine)->reason = "test.counter == 0"; continue; } else { (jasmine)->group = 1; (jasmine)->expects++; };
            if (!(e3_timer_tick())) { (jasmine)->expects++; (jasmine)->group = 0; (jasmine)->reason = "e3_timer_tick()"; continue; } else { (jasmine)->group = 1; (jasmine)->expects++; };
            if (!(test.counter == 0)) { (jasmine)->expects++; (jasmine)->group = 0; (jasmine)->reason = "test.counter == 0"; continue; } else { (jasmine)->group = 1; (jasmine)->expects++; };
            if (!(e3_timer_tick())) { (jasmine)->expects++; (jasmine)->group = 0; (jasmine)->reason = "e3_timer_tick()"; continue; } else { (jasmine)->group = 1; (jasmine)->expects++; };
            if (!(test.counter == 0)) { (jasmine)->expects++; (jasmine)->group = 0; (jasmine)->reason = "test.counter == 0"; continue; } else { (jasmine)->group = 1; (jasmine)->expects++; };
            e3_timer_interrupt();
            if (!(test.counter == 0)) { (jasmine)->expects++; (jasmine)->group = 0; (jasmine)->reason = "test.counter == 0"; continue; } else { (jasmine)->group = 1; (jasmine)->expects++; };
            if (!(!e3_timer_tick())) { (jasmine)->expects++; (jasmine)->group = 0; (jasmine)->reason = "!e3_timer_tick()"; continue; } else { (jasmine)->group = 1; (jasmine)->expects++; };
            if (!(test.counter == 1)) { (jasmine)->expects++; (jasmine)->group = 0; (jasmine)->reason = "test.counter == 1"; continue; } else { (jasmine)->group = 1; (jasmine)->expects++; };
        }
        for ((jasmine)->group = 2, (jasmine)->last = (unsigned short) ((jasmine)->last < 131 ? 131 : (jasmine)->last); 1 == (jasmine)->state && (jasmine)->current < 131 && (131 == ((jasmine)->current = 131)); (jasmine)->state = 2, ((jasmine)->group == 2 ? ((jasmine)->ignored++, puts(" ! " "can tick slower than the interrupt"), 2) : ((jasmine)->group == 1 ? ((jasmine)->passed++, puts(" ✓ " "can tick slower than the interrupt"), 1) : ((jasmine)->failed++, printf(" ✗ " "can tick slower than the interrupt" ": expected %s\r\n", (jasmine)->reason), 0)))) {
            e3_timer_create(&test.timer_1, 2,
                (e3_timer_function_t) triple, &test);
            e3_timer_create(&test.timer_2, 1,
                (e3_timer_function_t) increment, &test);
            if (!(test.counter == 0)) { (jasmine)->expects++; (jasmine)->group = 0; (jasmine)->reason = "test.counter == 0"; continue; } else { (jasmine)->group = 1; (jasmine)->expects++; };
            e3_timer_interrupt();
            e3_timer_interrupt();
            e3_timer_interrupt();
            e3_timer_interrupt();
            if (!(test.counter == 0)) { (jasmine)->expects++; (jasmine)->group = 0; (jasmine)->reason = "test.counter == 0"; continue; } else { (jasmine)->group = 1; (jasmine)->expects++; };
            if (!(!e3_timer_tick())) { (jasmine)->expects++; (jasmine)->group = 0; (jasmine)->reason = "!e3_timer_tick()"; continue; } else { (jasmine)->group = 1; (jasmine)->expects++; };
            if (!(test.counter == 3)) { (jasmine)->expects++; (jasmine)->group = 0; (jasmine)->reason = "test.counter == 3"; continue; } else { (jasmine)->group = 1; (jasmine)->expects++; };
        }
        for ((jasmine)->group = 2, (jasmine)->last = (unsigned short) ((jasmine)->last < 148 ? 148 : (jasmine)->last); 1 == (jasmine)->state && (jasmine)->current < 148 && (148 == ((jasmine)->current = 148)); (jasmine)->state = 2, ((jasmine)->group == 2 ? ((jasmine)->ignored++, puts(" ! " "can create a timer within a timer function"), 2) : ((jasmine)->group == 1 ? ((jasmine)->passed++, puts(" ✓ " "can create a timer within a timer function"), 1) : ((jasmine)->failed++, printf(" ✗ " "can create a timer within a timer function" ": expected %s\r\n", (jasmine)->reason), 0)))) {
            e3_timer_create(&test.timer_1, 0,
                (e3_timer_function_t) reschedule, &test);
            if (!(test.counter == 0)) { (jasmine)->expects++; (jasmine)->group = 0; (jasmine)->reason = "test.counter == 0"; continue; } else { (jasmine)->group = 1; (jasmine)->expects++; };
            if (!(e3_timer_tick())) { (jasmine)->expects++; (jasmine)->group = 0; (jasmine)->reason = "e3_timer_tick()"; continue; } else { (jasmine)->group = 1; (jasmine)->expects++; };
            if (!(test.counter == 1)) { (jasmine)->expects++; (jasmine)->group = 0; (jasmine)->reason = "test.counter == 1"; continue; } else { (jasmine)->group = 1; (jasmine)->expects++; };
            if (!(e3_timer_tick())) { (jasmine)->expects++; (jasmine)->group = 0; (jasmine)->reason = "e3_timer_tick()"; continue; } else { (jasmine)->group = 1; (jasmine)->expects++; };
            if (!(test.counter == 2)) { (jasmine)->expects++; (jasmine)->group = 0; (jasmine)->reason = "test.counter == 2"; continue; } else { (jasmine)->group = 1; (jasmine)->expects++; };
            e3_timer_delete(&test.timer_1);
            if (!(!e3_timer_tick())) { (jasmine)->expects++; (jasmine)->group = 0; (jasmine)->reason = "!e3_timer_tick()"; continue; } else { (jasmine)->group = 1; (jasmine)->expects++; };
            if (!(test.counter == 2)) { (jasmine)->expects++; (jasmine)->group = 0; (jasmine)->reason = "test.counter == 2"; continue; } else { (jasmine)->group = 1; (jasmine)->expects++; };
        }
    }
}

canonical_original_code:
void e3_timer_test(struct jasmine *jasmine) {
    struct test test;
    for ((jasmine)->state = 0, (jasmine)->current = 0, (jasmine)->last = 0, puts("the system timer"); (3 == (jasmine)->state) ? (puts(""), 0) : 1; ) {
        for (; 0 == (jasmine)->state; (jasmine)->state = 1) {
            test.counter = 0;
        }
        for (; 2 == (jasmine)->state; (jasmine)->state = ((jasmine)->current == (jasmine)->last) ? 3 : 0) {
        }
        for ((jasmine)->group = 2, (jasmine)->last = (unsigned short) ((jasmine)->last < 64 ? 64 : (jasmine)->last); 1 == (jasmine)->state && (jasmine)->current < 64 && (64 == ((jasmine)->current = 64)); (jasmine)->state = 2, ((jasmine)->group == 2 ? ((jasmine)->ignored++, puts(" ! " "can tick without any timers created"), 2) : ((jasmine)->group == 1 ? ((jasmine)->passed++, puts(" ✓ " "can tick without any timers created"), 1) : ((jasmine)->failed++, printf(" ✗ " "can tick without any timers created" ": expected %s\r\n", (jasmine)->reason), 0)))) {
            if (!(!e3_timer_tick())) { (jasmine)->expects++; (jasmine)->group = 0; (jasmine)->reason = "!e3_timer_tick()"; continue; } else { (jasmine)->group = 1; (jasmine)->expects++; };
            if (!(test.counter == 0)) { (jasmine)->expects++; (jasmine)->group = 0; (jasmine)->reason = "test.counter == 0"; continue; } else { (jasmine)->group = 1; (jasmine)->expects++; };
        }
        for ((jasmine)->group = 2, (jasmine)->last = (unsigned short) ((jasmine)->last < 69 ? 69 : (jasmine)->last); 1 == (jasmine)->state && (jasmine)->current < 69 && (69 == ((jasmine)->current = 69)); (jasmine)->state = 2, ((jasmine)->group == 2 ? ((jasmine)->ignored++, puts(" ! " "does not require an interrupt for a zero tick"), 2) : ((jasmine)->group == 1 ? ((jasmine)->passed++, puts(" ✓ " "does not require an interrupt for a zero tick"), 1) : ((jasmine)->failed++, printf(" ✗ " "does not require an interrupt for a zero tick" ": expected %s\r\n", (jasmine)->reason), 0)))) {
            e3_timer_create(&test.timer_1, 0,
                (void (*)(void *cookie)) increment, &test);
            if (!(test.counter == 0)) { (jasmine)->expects++; (jasmine)->group = 0; (jasmine)->reason = "test.counter == 0"; continue; } else { (jasmine)->group = 1; (jasmine)->expects++; };
            if (!(!e3_timer_tick())) { (jasmine)->expects++; (jasmine)->group = 0; (jasmine)->reason = "!e3_timer_tick()"; continue; } else { (jasmine)->group = 1; (jasmine)->expects++; };
            if (!(test.counter == 1)) { (jasmine)->expects++; (jasmine)->group = 0; (jasmine)->reason = "test.counter == 1"; continue; } else { (jasmine)->group = 1; (jasmine)->expects++; };
        }
        for ((jasmine)->group = 2, (jasmine)->last = (unsigned short) ((jasmine)->last < 78 ? 78 : (jasmine)->last); 1 == (jasmine)->state && (jasmine)->current < 78 && (78 == ((jasmine)->current = 78)); (jasmine)->state = 2, ((jasmine)->group == 2 ? ((jasmine)->ignored++, puts(" ! " "can have multiple timers with the same ticks"), 2) : ((jasmine)->group == 1 ? ((jasmine)->passed++, puts(" ✓ " "can have multiple timers with the same ticks"), 1) : ((jasmine)->failed++, printf(" ✗ " "can have multiple timers with the same ticks" ": expected %s\r\n", (jasmine)->reason), 0)))) {
            e3_timer_create(&test.timer_1, 0,
                (void (*)(void *cookie)) increment, &test);
            e3_timer_create(&test.timer_2, 0,
                (void (*)(void *cookie)) increment, &test);
            if (!(test.counter == 0)) { (jasmine)->expects++; (jasmine)->group = 0; (jasmine)->reason = "test.counter == 0"; continue; } else { (jasmine)->group = 1; (jasmine)->expects++; };
            if (!(!e3_timer_tick())) { (jasmine)->expects++; (jasmine)->group = 0; (jasmine)->reason = "!e3_timer_tick()"; continue; } else { (jasmine)->group = 1; (jasmine)->expects++; };
            if (!(test.counter == 2)) { (jasmine)->expects++; (jasmine)->group = 0; (jasmine)->reason = "test.counter == 2"; continue; } else { (jasmine)->group = 1; (jasmine)->expects++; };
        }
        for ((jasmine)->group = 2, (jasmine)->last = (unsigned short) ((jasmine)->last < 90 ? 90 : (jasmine)->last); 1 == (jasmine)->state && (jasmine)->current < 90 && (90 == ((jasmine)->current = 90)); (jasmine)->state = 2, ((jasmine)->group == 2 ? ((jasmine)->ignored++, puts(" ! " "will ignore invalid timer functions"), 2) : ((jasmine)->group == 1 ? ((jasmine)->passed++, puts(" ✓ " "will ignore invalid timer functions"), 1) : ((jasmine)->failed++, printf(" ✗ " "will ignore invalid timer functions" ": expected %s\r\n", (jasmine)->reason), 0)))) {
            e3_timer_create(&test.timer_1, 0, 0, 0);
            if (!(test.counter == 0)) { (jasmine)->expects++; (jasmine)->group = 0; (jasmine)->reason = "test.counter == 0"; continue; } else { (jasmine)->group = 1; (jasmine)->expects++; };
            if (!(!e3_timer_tick())) { (jasmine)->expects++; (jasmine)->group = 0; (jasmine)->reason = "!e3_timer_tick()"; continue; } else { (jasmine)->group = 1; (jasmine)->expects++; };
            if (!(test.counter == 0)) { (jasmine)->expects++; (jasmine)->group = 0; (jasmine)->reason = "test.counter == 0"; continue; } else { (jasmine)->group = 1; (jasmine)->expects++; };
        }
        for ((jasmine)->group = 2, (jasmine)->last = (unsigned short) ((jasmine)->last < 97 ? 97 : (jasmine)->last); 1 == (jasmine)->state && (jasmine)->current < 97 && (97 == ((jasmine)->current = 97)); (jasmine)->state = 2, ((jasmine)->group == 2 ? ((jasmine)->ignored++, puts(" ! " "can delete a timer that has been created"), 2) : ((jasmine)->group == 1 ? ((jasmine)->passed++, puts(" ✓ " "can delete a timer that has been created"), 1) : ((jasmine)->failed++, printf(" ✗ " "can delete a timer that has been created" ": expected %s\r\n", (jasmine)->reason), 0)))) {
            e3_timer_create(&test.timer_1, 0,
                (void (*)(void *cookie)) triple, &test);
            e3_timer_create(&test.timer_2, 0,
                (void (*)(void *cookie)) increment, &test);
            if (!(test.counter == 0)) { (jasmine)->expects++; (jasmine)->group = 0; (jasmine)->reason = "test.counter == 0"; continue; } else { (jasmine)->group = 1; (jasmine)->expects++; };
            e3_timer_delete(&test.timer_1);
            if (!(!e3_timer_tick())) { (jasmine)->expects++; (jasmine)->group = 0; (jasmine)->reason = "!e3_timer_tick()"; continue; } else { (jasmine)->group = 1; (jasmine)->expects++; };
            if (!(test.counter == 1)) { (jasmine)->expects++; (jasmine)->group = 0; (jasmine)->reason = "test.counter == 1"; continue; } else { (jasmine)->group = 1; (jasmine)->expects++; };
        }
        for ((jasmine)->group = 2, (jasmine)->last = (unsigned short) ((jasmine)->last < 110 ? 110 : (jasmine)->last); 1 == (jasmine)->state && (jasmine)->current < 110 && (110 == ((jasmine)->current = 110)); (jasmine)->state = 2, ((jasmine)->group == 2 ? ((jasmine)->ignored++, puts(" ! " "can delete a timer that has not been created"), 2) : ((jasmine)->group == 1 ? ((jasmine)->passed++, puts(" ✓ " "can delete a timer that has not been created"), 1) : ((jasmine)->failed++, printf(" ✗ " "can delete a timer that has not been created" ": expected %s\r\n", (jasmine)->reason), 0)))) {
            e3_timer_delete(&test.timer_1);
            if (!(!e3_timer_tick())) { (jasmine)->expects++; (jasmine)->group = 0; (jasmine)->reason = "!e3_timer_tick()"; continue; } else { (jasmine)->group = 1; (jasmine)->expects++; };
            if (!(test.counter == 0)) { (jasmine)->expects++; (jasmine)->group = 0; (jasmine)->reason = "test.counter == 0"; continue; } else { (jasmine)->group = 1; (jasmine)->expects++; };
        }
        for ((jasmine)->group = 2, (jasmine)->last = (unsigned short) ((jasmine)->last < 116 ? 116 : (jasmine)->last); 1 == (jasmine)->state && (jasmine)->current < 116 && (116 == ((jasmine)->current = 116)); (jasmine)->state = 2, ((jasmine)->group == 2 ? ((jasmine)->ignored++, puts(" ! " "can tick faster than the interrupt"), 2) : ((jasmine)->group == 1 ? ((jasmine)->passed++, puts(" ✓ " "can tick faster than the interrupt"), 1) : ((jasmine)->failed++, printf(" ✗ " "can tick faster than the interrupt" ": expected %s\r\n", (jasmine)->reason), 0)))) {
            e3_timer_create(&test.timer_1, 1,
                (void (*)(void *cookie)) increment, &test);
            if (!(test.counter == 0)) { (jasmine)->expects++; (jasmine)->group = 0; (jasmine)->reason = "test.counter == 0"; continue; } else { (jasmine)->group = 1; (jasmine)->expects++; };
            if (!(e3_timer_tick())) { (jasmine)->expects++; (jasmine)->group = 0; (jasmine)->reason = "e3_timer_tick()"; continue; } else { (jasmine)->group = 1; (jasmine)->expects++; };
            if (!(test.counter == 0)) { (jasmine)->expects++; (jasmine)->group = 0; (jasmine)->reason = "test.counter == 0"; continue; } else { (jasmine)->group = 1; (jasmine)->expects++; };
            if (!(e3_timer_tick())) { (jasmine)->expects++; (jasmine)->group = 0; (jasmine)->reason = "e3_timer_tick()"; continue; } else { (jasmine)->group = 1; (jasmine)->expects++; };
            if (!(test.counter == 0)) { (jasmine)->expects++; (jasmine)->group = 0; (jasmine)->reason = "test.counter == 0"; continue; } else { (jasmine)->group = 1; (jasmine)->expects++; };
            e3_timer_interrupt();
            if (!(test.counter == 0)) { (jasmine)->expects++; (jasmine)->group = 0; (jasmine)->reason = "test.counter == 0"; continue; } else { (jasmine)->group = 1; (jasmine)->expects++; };
            if (!(!e3_timer_tick())) { (jasmine)->expects++; (jasmine)->group = 0; (jasmine)->reason = "!e3_timer_tick()"; continue; } else { (jasmine)->group = 1; (jasmine)->expects++; };
            if (!(test.counter == 1)) { (jasmine)->expects++; (jasmine)->group = 0; (jasmine)->reason = "test.counter == 1"; continue; } else { (jasmine)->group = 1; (jasmine)->expects++; };
        }
        for ((jasmine)->group = 2, (jasmine)->last = (unsigned short) ((jasmine)->last < 131 ? 131 : (jasmine)->last); 1 == (jasmine)->state && (jasmine)->current < 131 && (131 == ((jasmine)->current = 131)); (jasmine)->state = 2, ((jasmine)->group == 2 ? ((jasmine)->ignored++, puts(" ! " "can tick slower than the interrupt"), 2) : ((jasmine)->group == 1 ? ((jasmine)->passed++, puts(" ✓ " "can tick slower than the interrupt"), 1) : ((jasmine)->failed++, printf(" ✗ " "can tick slower than the interrupt" ": expected %s\r\n", (jasmine)->reason), 0)))) {
            e3_timer_create(&test.timer_1, 2,
                (void (*)(void *cookie)) triple, &test);
            e3_timer_create(&test.timer_2, 1,
                (void (*)(void *cookie)) increment, &test);
            if (!(test.counter == 0)) { (jasmine)->expects++; (jasmine)->group = 0; (jasmine)->reason = "test.counter == 0"; continue; } else { (jasmine)->group = 1; (jasmine)->expects++; };
            e3_timer_interrupt();
            e3_timer_interrupt();
            e3_timer_interrupt();
            e3_timer_interrupt();
            if (!(test.counter == 0)) { (jasmine)->expects++; (jasmine)->group = 0; (jasmine)->reason = "test.counter == 0"; continue; } else { (jasmine)->group = 1; (jasmine)->expects++; };
            if (!(!e3_timer_tick())) { (jasmine)->expects++; (jasmine)->group = 0; (jasmine)->reason = "!e3_timer_tick()"; continue; } else { (jasmine)->group = 1; (jasmine)->expects++; };
            if (!(test.counter == 3)) { (jasmine)->expects++; (jasmine)->group = 0; (jasmine)->reason = "test.counter == 3"; continue; } else { (jasmine)->group = 1; (jasmine)->expects++; };
        }
        for ((jasmine)->group = 2, (jasmine)->last = (unsigned short) ((jasmine)->last < 148 ? 148 : (jasmine)->last); 1 == (jasmine)->state && (jasmine)->current < 148 && (148 == ((jasmine)->current = 148)); (jasmine)->state = 2, ((jasmine)->group == 2 ? ((jasmine)->ignored++, puts(" ! " "can create a timer within a timer function"), 2) : ((jasmine)->group == 1 ? ((jasmine)->passed++, puts(" ✓ " "can create a timer within a timer function"), 1) : ((jasmine)->failed++, printf(" ✗ " "can create a timer within a timer function" ": expected %s\r\n", (jasmine)->reason), 0)))) {
            e3_timer_create(&test.timer_1, 0,
                (void (*)(void *cookie)) reschedule, &test);
            if (!(test.counter == 0)) { (jasmine)->expects++; (jasmine)->group = 0; (jasmine)->reason = "test.counter == 0"; continue; } else { (jasmine)->group = 1; (jasmine)->expects++; };
            if (!(e3_timer_tick())) { (jasmine)->expects++; (jasmine)->group = 0; (jasmine)->reason = "e3_timer_tick()"; continue; } else { (jasmine)->group = 1; (jasmine)->expects++; };
            if (!(test.counter == 1)) { (jasmine)->expects++; (jasmine)->group = 0; (jasmine)->reason = "test.counter == 1"; continue; } else { (jasmine)->group = 1; (jasmine)->expects++; };
            if (!(e3_timer_tick())) { (jasmine)->expects++; (jasmine)->group = 0; (jasmine)->reason = "e3_timer_tick()"; continue; } else { (jasmine)->group = 1; (jasmine)->expects++; };
            if (!(test.counter == 2)) { (jasmine)->expects++; (jasmine)->group = 0; (jasmine)->reason = "test.counter == 2"; continue; } else { (jasmine)->group = 1; (jasmine)->expects++; };
            e3_timer_delete(&test.timer_1);
            if (!(!e3_timer_tick())) { (jasmine)->expects++; (jasmine)->group = 0; (jasmine)->reason = "!e3_timer_tick()"; continue; } else { (jasmine)->group = 1; (jasmine)->expects++; };
            if (!(test.counter == 2)) { (jasmine)->expects++; (jasmine)->group = 0; (jasmine)->reason = "test.counter == 2"; continue; } else { (jasmine)->group = 1; (jasmine)->expects++; };
        }
    }
}

variable_types: struct jasmine { char *reason; unsigned short state; unsigned short group; unsigned short current; unsigned short last; unsigned short passed; unsigned short failed; unsigned short ignored; unsigned short expects; } *

variable_types: struct test { struct e3_timer { struct e3_timer *next; unsigned long ticks; void (*function)(void *cookie); void *cookie; } timer_1; struct e3_timer timer_2; unsigned int counter; }


main

canonical_name: main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
__int64 v4; // [rsp+0h] [rbp-28h] BYREF
__int16 v5; // [rsp+8h] [rbp-20h]
__int16 v6; // [rsp+Ah] [rbp-1Eh]
__int16 v7; // [rsp+Ch] [rbp-1Ch]
__int16 v8; // [rsp+Eh] [rbp-1Ah]
unsigned __int16 v9; // [rsp+10h] [rbp-18h]
unsigned __int16 v10; // [rsp+12h] [rbp-16h]
unsigned __int16 v11; // [rsp+14h] [rbp-14h]
unsigned __int16 v12; // [rsp+16h] [rbp-12h]

v5 = 0;
v6 = 2;
v7 = 0;
v8 = 0;
v9 = 0;
v10 = 0;
v11 = 0;
v12 = 0;
v4 = 0LL;
e3_timer_test(&v4, argv, envp);
e3_hsm_test(&v4);
e3_event_test(&v4);
e3_tcp_client_test(&v4);
printf("jasmine: %u passed, %u failed, %u ignored, %u expects\r\n", v9, v10, v11, v12);
return v10;
}

original_code:
int main(void) {
    jasmine_t jasmine;
    do { (&jasmine)->state = 0; (&jasmine)->group = 2; (&jasmine)->current = 0; (&jasmine)->last = 0; (&jasmine)->passed = 0; (&jasmine)->failed = 0; (&jasmine)->ignored = 0; (&jasmine)->expects = 0; (&jasmine)->reason = 0; } while (0);
    e3_timer_test(&jasmine);
    e3_hsm_test(&jasmine);
    e3_event_test(&jasmine);
    e3_tcp_client_test(&jasmine);
    printf("jasmine: %u passed, %u failed, %u ignored, %u expects\r\n",
        jasmine.passed, jasmine.failed, jasmine.ignored, jasmine.expects);
    return jasmine.failed;
}

canonical_original_code:
int main() {
    struct jasmine jasmine;
    do { (&jasmine)->state = 0; (&jasmine)->group = 2; (&jasmine)->current = 0; (&jasmine)->last = 0; (&jasmine)->passed = 0; (&jasmine)->failed = 0; (&jasmine)->ignored = 0; (&jasmine)->expects = 0; (&jasmine)->reason = 0; } while (0);
    e3_timer_test(&jasmine);
    e3_hsm_test(&jasmine);
    e3_event_test(&jasmine);
    e3_tcp_client_test(&jasmine);
    printf("jasmine: %u passed, %u failed, %u ignored, %u expects\r\n",
        jasmine.passed, jasmine.failed, jasmine.ignored, jasmine.expects);
    return jasmine.failed;
}

variable_types: struct jasmine { char *reason; unsigned short state; unsigned short group; unsigned short current; unsigned short last; unsigned short passed; unsigned short failed; unsigned short ignored; unsigned short expects; }

return_type: int


connected

decompiled_code:
void __fastcall connected(__int64 a1)
{
++*(_DWORD *)(a1 + 232);
}

original_code:
static void
connected(test_t *test, void *arg) {
    test->connected++;
    (void) arg;
}

canonical_original_code:
static void connected(struct test *test, void *arg) {
    test->connected++;
    (void) arg;
}

variable_types: struct test { struct e3_socket_double { struct e3_socket { struct e3_socket_interface { void (*connect)(struct e3_socket *socket, char *host, int port); int (*is_connected)(struct e3_socket *socket); int (*is_data_available)(struct e3_socket *socket); int (*is_error)(struct e3_socket *socket); } *interface; } socket; char *host; int port; int is_connected; int is_data_available; int is_error; } socket; struct e3_tcp_client { struct e3_socket *socket; unsigned long poll_interval; struct e3_event { struct e3_event_listener { struct e3_event_listener *next; struct e3_event *event; void (*function)(void *hint, void *args); void *cookie; } *listeners; } connected; struct e3_event timeout; struct e3_event disconnected; struct e3_timer { struct e3_timer *next; unsigned long ticks; void (*function)(void *cookie); void *cookie; } poll_timer; struct e3_timer timeout_timer; } client; struct e3_event_listener connect_listener; struct e3_event_listener timeout_listener; struct e3_event_listener disconnect_listener; unsigned int connected; unsigned int timeout; unsigned int disconnected; } *

variable_types:
arg
void *

return_type: void

user_defined_types: struct test { struct e3_socket_double socket; struct e3_tcp_client client; struct e3_event_listener connect_listener; struct e3_event_listener timeout_listener; struct e3_event_listener disconnect_listener; unsigned int connected; unsigned int timeout; unsigned int disconnected; }

user_defined_types: struct e3_socket_double { struct e3_socket socket; char *host; int port; int is_connected; int is_data_available; int is_error; }

user_defined_types: struct e3_tcp_client { struct e3_socket *socket; unsigned long poll_interval; struct e3_event connected; struct e3_event timeout; struct e3_event disconnected; struct e3_timer poll_timer; struct e3_timer timeout_timer; }

user_defined_types: struct e3_socket { struct e3_socket_interface *interface; }

user_defined_types: struct e3_event { struct e3_event_listener *listeners; }


timeout

decompiled_code:
void __fastcall timeout(__int64 a1)
{
++*(_DWORD *)(a1 + 236);
}

original_code:
static void
timeout(test_t *test, void *arg) {
    test->timeout++;
    (void) arg;
}

canonical_original_code:
static void timeout(struct test *test, void *arg) {
    test->timeout++;
    (void) arg;
}

user_defined_types: struct e3_timer { struct e3_timer *next; unsigned long ticks; void (*function)(void *cookie); void *cookie; }

user_defined_types: struct e3_socket_interface { void (*connect)(struct e3_socket *socket, char *host, int port); int (*is_connected)(struct e3_socket *socket); int (*is_data_available)(struct e3_socket *socket); int (*is_error)(struct e3_socket *socket); }

user_defined_types: struct e3_event_listener { struct e3_event_listener *next; struct e3_event *event; void (*function)(void *hint, void *args); void *cookie; }


disconnected

decompiled_code:
void __fastcall disconnected(__int64 a1)
{
++*(_DWORD *)(a1 + 240);
}

original_code:
static void
disconnected(test_t *test, void *arg) {
    test->disconnected++;
    (void) arg;
}

canonical_original_code:
static void disconnected(struct test *test, void *arg) {
    test->disconnected++;
    (void) arg;
}


tick

decompiled_code:
__int64 tick()
{
e3_timer_interrupt();
return e3_timer_tick();
}

canonical_decompiled_code:
__int64 func3()
{
e3_timer_interrupt();
return e3_timer_tick();
}

original_code:
static e3_timer_ticks_t
tick(void) {
    e3_timer_interrupt();
    return e3_timer_tick();
}

canonical_original_code:
static unsigned long tick() {
    e3_timer_interrupt();
    return e3_timer_tick();
}

return_type: unsigned long


original_code:
void
e3_tcp_client_test(jasmine_t *jasmine) {
    test_t test;
    for ((jasmine)->state = 0, (jasmine)->current = 0, (jasmine)->last = 0, puts("a tcp client"); (3 == (jasmine)->state) ? (puts(""), 0) : 1; ) {
        for (; 0 == (jasmine)->state; (jasmine)->state = 1) {
            (&(&test.socket)->socket)->interface = (E3_SOCKET_DOUBLE);
            (&test.socket)->is_connected = (0);
            (&test.socket)->is_data_available = (0);
            (&test.socket)->is_error = (0);
            e3_tcp_client_create(&test.client, &test.socket.socket, 0);
            e3_event_listener_create(&test.connect_listener,
                &test.client.connected,
                (e3_event_handler_t) connected, &test);
            e3_event_listener_create(&test.timeout_listener,
                &test.client.timeout,
                (e3_event_handler_t) timeout, &test);
            e3_event_listener_create(&test.disconnect_listener,
                &test.client.disconnected,
                (e3_event_handler_t) disconnected, &test);
            test.connected = 0;
            test.timeout = 0;
            test.disconnected = 0;
        }
        for (; 2 == (jasmine)->state; (jasmine)->state = ((jasmine)->current == (jasmine)->last) ? 3 : 0) {
            e3_event_listener_delete(&test.connect_listener);
            e3_event_listener_delete(&test.timeout_listener);
            e3_event_listener_delete(&test.disconnect_listener);
            e3_tcp_client_delete(&test.client);
            ;
        }
        for ((jasmine)->group = 2, (jasmine)->last = (unsigned short) ((jasmine)->last < 101 ? 101 : (jasmine)->last); 1 == (jasmine)->state && (jasmine)->current < 101 && (101 == ((jasmine)->current = 101)); (jasmine)->state = 2, ((jasmine)->group == 2 ? ((jasmine)->ignored++, puts(" ! " "can connect before the timeout is reached"), 2) : ((jasmine)->group == 1 ? ((jasmine)->passed++, puts(" ✓ " "can connect before the timeout is reached"), 1) : ((jasmine)->failed++, printf(" ✗ " "can connect before the timeout is reached" ": expected %s\r\n", (jasmine)->reason), 0)))) {
            e3_tcp_client_connect(&test.client, "localhost", 80, 11);
            while (tick()) {
                (&test.socket)->is_connected = (1);
            }
            if (!(test.connected == 1)) { (jasmine)->expects++; (jasmine)->group = 0; (jasmine)->reason = "test.connected == 1"; continue; } else { (jasmine)->group = 1; (jasmine)->expects++; };
            if (!(test.timeout == 0)) { (jasmine)->expects++; (jasmine)->group = 0; (jasmine)->reason = "test.timeout == 0"; continue; } else { (jasmine)->group = 1; (jasmine)->expects++; };
            if (!(test.disconnected == 0)) { (jasmine)->expects++; (jasmine)->group = 0; (jasmine)->reason = "test.disconnected == 0"; continue; } else { (jasmine)->group = 1; (jasmine)->expects++; };
        }
        for ((jasmine)->group = 2, (jasmine)->last = (unsigned short) ((jasmine)->last < 113 ? 113 : (jasmine)->last); 1 == (jasmine)->state && (jasmine)->current < 113 && (113 == ((jasmine)->current = 113)); (jasmine)->state = 2, ((jasmine)->group == 2 ? ((jasmine)->ignored++, puts(" ! " "can timeout while connecting"), 2) : ((jasmine)->group == 1 ? ((jasmine)->passed++, puts(" ✓ " "can timeout while connecting"), 1) : ((jasmine)->failed++, printf(" ✗ " "can timeout while connecting" ": expected %s\r\n", (jasmine)->reason), 0)))) {
            e3_tcp_client_connect(&test.client, "localhost", 80, 11);
            while (tick());
            if (!(test.connected == 0)) { (jasmine)->expects++; (jasmine)->group = 0; (jasmine)->reason = "test.connected == 0"; continue; } else { (jasmine)->group = 1; (jasmine)->expects++; };
            if (!(test.timeout == 1)) { (jasmine)->expects++; (jasmine)->group = 0; (jasmine)->reason = "test.timeout == 1"; continue; } else { (jasmine)->group = 1; (jasmine)->expects++; };
            if (!(test.disconnected == 0)) { (jasmine)->expects++; (jasmine)->group = 0; (jasmine)->reason = "test.disconnected == 0"; continue; } else { (jasmine)->group = 1; (jasmine)->expects++; };
        }
        for ((jasmine)->group = 2, (jasmine)->last = (unsigned short) ((jasmine)->last < 123 ? 123 : (jasmine)->last); 1 == (jasmine)->state && (jasmine)->current < 123 && (123 == ((jasmine)->current = 123)); (jasmine)->state = 2, ((jasmine)->group == 2 ? ((jasmine)->ignored++, puts(" ! " "can disconnect while connecting"), 2) : ((jasmine)->group == 1 ? ((jasmine)->passed++, puts(" ✓ " "can disconnect while connecting"), 1) : ((jasmine)->failed++, printf(" ✗ " "can disconnect while connecting" ": expected %s\r\n", (jasmine)->reason), 0)))) {
            e3_tcp_client_connect(&test.client, "localhost", 80, 11);
            while (tick()) {
                (&test.socket)->is_error = (1);
            }
            if (!(test.connected == 0)) { (jasmine)->expects++; (jasmine)->group = 0; (jasmine)->reason = "test.connected == 0"; continue; } else { (jasmine)->group = 1; (jasmine)->expects++; };
            if (!(test.timeout == 0)) { (jasmine)->expects++; (jasmine)->group = 0; (jasmine)->reason = "test.timeout == 0"; continue; } else { (jasmine)->group = 1; (jasmine)->expects++; };
            if (!(test.disconnected == 1)) { (jasmine)->expects++; (jasmine)->group = 0; (jasmine)->reason = "test.disconnected == 1"; continue; } else { (jasmine)->group = 1; (jasmine)->expects++; };
        }
    }
}

canonical_original_code:
void e3_tcp_client_test(struct jasmine *jasmine) {
    struct test test;
    for ((jasmine)->state = 0, (jasmine)->current = 0, (jasmine)->last = 0, puts("a tcp client"); (3 == (jasmine)->state) ? (puts(""), 0) : 1; ) {
        for (; 0 == (jasmine)->state; (jasmine)->state = 1) {
            (&(&test.socket)->socket)->interface = (E3_SOCKET_DOUBLE);
            (&test.socket)->is_connected = (0);
            (&test.socket)->is_data_available = (0);
            (&test.socket)->is_error = (0);
            e3_tcp_client_create(&test.client, &test.socket.socket, 0);
            e3_event_listener_create(&test.connect_listener,
                &test.client.connected,
                (void (*)(void *hint, void *args)) connected, &test);
            e3_event_listener_create(&test.timeout_listener,
                &test.client.timeout,
                (void (*)(void *hint, void *args)) timeout, &test);
            e3_event_listener_create(&test.disconnect_listener,
                &test.client.disconnected,
                (void (*)(void *hint, void *args)) disconnected, &test);
            test.connected = 0;
            test.timeout = 0;
            test.disconnected = 0;
        }
        for (; 2 == (jasmine)->state; (jasmine)->state = ((jasmine)->current == (jasmine)->last) ? 3 : 0) {
            e3_event_listener_delete(&test.connect_listener);
            e3_event_listener_delete(&test.timeout_listener);
            e3_event_listener_delete(&test.disconnect_listener);
            e3_tcp_client_delete(&test.client);
            ;
        }
        for ((jasmine)->group = 2, (jasmine)->last = (unsigned short) ((jasmine)->last < 101 ? 101 : (jasmine)->last); 1 == (jasmine)->state && (jasmine)->current < 101 && (101 == ((jasmine)->current = 101)); (jasmine)->state = 2, ((jasmine)->group == 2 ? ((jasmine)->ignored++, puts(" ! " "can connect before the timeout is reached"), 2) : ((jasmine)->group == 1 ? ((jasmine)->passed++, puts(" ✓ " "can connect before the timeout is reached"), 1) : ((jasmine)->failed++, printf(" ✗ " "can connect before the timeout is reached" ": expected %s\r\n", (jasmine)->reason), 0)))) {
            e3_tcp_client_connect(&test.client, "localhost", 80, 11);
            while (tick()) {
                (&test.socket)->is_connected = (1);
            }
            if (!(test.connected == 1)) { (jasmine)->expects++; (jasmine)->group = 0; (jasmine)->reason = "test.connected == 1"; continue; } else { (jasmine)->group = 1; (jasmine)->expects++; };
            if (!(test.timeout == 0)) { (jasmine)->expects++; (jasmine)->group = 0; (jasmine)->reason = "test.timeout == 0"; continue; } else { (jasmine)->group = 1; (jasmine)->expects++; };
            if (!(test.disconnected == 0)) { (jasmine)->expects++; (jasmine)->group = 0; (jasmine)->reason = "test.disconnected == 0"; continue; } else { (jasmine)->group = 1; (jasmine)->expects++; };
        }
        for ((jasmine)->group = 2, (jasmine)->last = (unsigned short) ((jasmine)->last < 113 ? 113 : (jasmine)->last); 1 == (jasmine)->state && (jasmine)->current < 113 && (113 == ((jasmine)->current = 113)); (jasmine)->state = 2, ((jasmine)->group == 2 ? ((jasmine)->ignored++, puts(" ! " "can timeout while connecting"), 2) : ((jasmine)->group == 1 ? ((jasmine)->passed++, puts(" ✓ " "can timeout while connecting"), 1) : ((jasmine)->failed++, printf(" ✗ " "can timeout while connecting" ": expected %s\r\n", (jasmine)->reason), 0)))) {
            e3_tcp_client_connect(&test.client, "localhost", 80, 11);
            while (tick());
            if (!(test.connected == 0)) { (jasmine)->expects++; (jasmine)->group = 0; (jasmine)->reason = "test.connected == 0"; continue; } else { (jasmine)->group = 1; (jasmine)->expects++; };
            if (!(test.timeout == 1)) { (jasmine)->expects++; (jasmine)->group = 0; (jasmine)->reason = "test.timeout == 1"; continue; } else { (jasmine)->group = 1; (jasmine)->expects++; };
            if (!(test.disconnected == 0)) { (jasmine)->expects++; (jasmine)->group = 0; (jasmine)->reason = "test.disconnected == 0"; continue; } else { (jasmine)->group = 1; (jasmine)->expects++; };
        }
        for ((jasmine)->group = 2, (jasmine)->last = (unsigned short) ((jasmine)->last < 123 ? 123 : (jasmine)->last); 1 == (jasmine)->state && (jasmine)->current < 123 && (123 == ((jasmine)->current = 123)); (jasmine)->state = 2, ((jasmine)->group == 2 ? ((jasmine)->ignored++, puts(" ! " "can disconnect while connecting"), 2) : ((jasmine)->group == 1 ? ((jasmine)->passed++, puts(" ✓ " "can disconnect while connecting"), 1) : ((jasmine)->failed++, printf(" ✗ " "can disconnect while connecting" ": expected %s\r\n", (jasmine)->reason), 0)))) {
            e3_tcp_client_connect(&test.client, "localhost", 80, 11);
            while (tick()) {
                (&test.socket)->is_error = (1);
            }
            if (!(test.connected == 0)) { (jasmine)->expects++; (jasmine)->group = 0; (jasmine)->reason = "test.connected == 0"; continue; } else { (jasmine)->group = 1; (jasmine)->expects++; };
            if (!(test.timeout == 0)) { (jasmine)->expects++; (jasmine)->group = 0; (jasmine)->reason = "test.timeout == 0"; continue; } else { (jasmine)->group = 1; (jasmine)->expects++; };
            if (!(test.disconnected == 1)) { (jasmine)->expects++; (jasmine)->group = 0; (jasmine)->reason = "test.disconnected == 1"; continue; } else { (jasmine)->group = 1; (jasmine)->expects++; };
        }
    }
}

variable_types: struct test { struct e3_socket_double { struct e3_socket { struct e3_socket_interface { void (*connect)(struct e3_socket *socket, char *host, int port); int (*is_connected)(struct e3_socket *socket); int (*is_data_available)(struct e3_socket *socket); int (*is_error)(struct e3_socket *socket); } *interface; } socket; char *host; int port; int is_connected; int is_data_available; int is_error; } socket; struct e3_tcp_client { struct e3_socket *socket; unsigned long poll_interval; struct e3_event { struct e3_event_listener { struct e3_event_listener *next; struct e3_event *event; void (*function)(void *hint, void *args); void *cookie; } *listeners; } connected; struct e3_event timeout; struct e3_event disconnected; struct e3_timer { struct e3_timer *next; unsigned long ticks; void (*function)(void *cookie); void *cookie; } poll_timer; struct e3_timer timeout_timer; } client; struct e3_event_listener connect_listener; struct e3_event_listener timeout_listener; struct e3_event_listener disconnect_listener; unsigned int connected; unsigned int timeout; unsigned int disconnected; }

user_defined_types: struct jasmine { char *reason; unsigned short state; unsigned short group; unsigned short current; unsigned short last; unsigned short passed; unsigned short failed; unsigned short ignored; unsigned short expects; }


connect

original_code:
static void
connect(e3_socket_t *socket, const char *host, int port) {
    ((e3_socket_double_t *) socket)->host = host;
    ((e3_socket_double_t *) socket)->port = port;
}

canonical_original_code:
static void connect(struct e3_socket *socket, char *host, int port) {
    ((struct e3_socket_double *) socket)->host = host;
    ((struct e3_socket_double *) socket)->port = port;
}

variable_types: struct e3_socket { struct e3_socket_interface { void (*connect)(struct e3_socket *socket, char *host, int port); int (*is_connected)(struct e3_socket *socket); int (*is_data_available)(struct e3_socket *socket); int (*is_error)(struct e3_socket *socket); } *interface; } *

variable_types:
host
char *

variable_types: port int


decompiled_code:
__int64 __fastcall is_connected(__int64 a1)
{
return *(unsigned int *)(a1 + 20);
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1)
{
return *(unsigned int *)(a1 + 20);
}

original_code:
static int
is_connected(e3_socket_t *socket) {
    return ((e3_socket_double_t *) socket)->is_connected;
}

canonical_original_code:
static int is_connected(struct e3_socket *socket) {
    return ((struct e3_socket_double *) socket)->is_connected;
}


decompiled_code:
__int64 __fastcall is_data_available(__int64 a1)
{
return *(unsigned int *)(a1 + 24);
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1)
{
return *(unsigned int *)(a1 + 24);
}

original_code:
static int
is_data_available(e3_socket_t *socket) {
    return ((e3_socket_double_t *) socket)->is_data_available;
}

canonical_original_code:
static int is_data_available(struct e3_socket *socket) {
    return ((struct e3_socket_double *) socket)->is_data_available;
}


decompiled_code:
__int64 __fastcall is_error(__int64 a1)
{
return *(unsigned int *)(a1 + 28);
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1)
{
return *(unsigned int *)(a1 + 28);
}

original_code:
static int
is_error(e3_socket_t *socket) {
    return ((e3_socket_double_t *) socket)->is_error;
}

canonical_original_code:
static int is_error(struct e3_socket *socket) {
    return ((struct e3_socket_double *) socket)->is_error;
}


decompiled_code:
__int64 __fastcall connect_timeout(__int64 a1)
{
__int64 result; // rax

++_gcov0_connect_timeout;
e3_timer_delete(a1 + 40);
++qword_478;
result = e3_event_fire(a1 + 24, 0LL);
++qword_480;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1)
{
__int64 result; // rax

++_gcov0_connect_timeout;
e3_timer_delete(a1 + 40);
++qword_478;
result = e3_event_fire(a1 + 24, 0LL);
++qword_480;
return result;
}

original_code:
static void
connect_timeout(e3_tcp_client_t *client) {
    e3_timer_delete(&client->poll_timer);
    e3_event_fire(&client->timeout, 0);
}

canonical_original_code:
static void connect_timeout(struct e3_tcp_client *client) {
    e3_timer_delete(&client->poll_timer);
    e3_event_fire(&client->timeout, 0);
}

variable_types: struct e3_tcp_client { struct e3_socket { struct e3_socket_interface { void (*connect)(struct e3_socket *socket, char *host, int port); int (*is_connected)(struct e3_socket *socket); int (*is_data_available)(struct e3_socket *socket); int (*is_error)(struct e3_socket *socket); } *interface; } *socket; unsigned long poll_interval; struct e3_event { struct e3_event_listener { struct e3_event_listener *next; struct e3_event *event; void (*function)(void *hint, void *args); void *cookie; } *listeners; } connected; struct e3_event timeout; struct e3_event disconnected; struct e3_timer { struct e3_timer *next; unsigned long ticks; void (*function)(void *cookie); void *cookie; } poll_timer; struct e3_timer timeout_timer; } *


connecting

decompiled_code:
__int64 __fastcall connecting(_QWORD *a1)
{
__int64 result; // rax

++_gcov0_connecting;
if ( (*(unsigned int (__fastcall **)(_QWORD))(*(_QWORD *)*a1 + 8LL))(*a1) )
{
++qword_428;
e3_timer_delete(a1 + 9);
++qword_438;
result = e3_event_fire(a1 + 2, 0LL);
++qword_440;
}
else
{
++qword_430;
if ( (*(unsigned int (__fastcall **)(_QWORD))(*(_QWORD *)*a1 + 24LL))(*a1) )
{
++qword_448;
e3_timer_delete(a1 + 9);
++qword_458;
result = e3_event_fire(a1 + 4, 0LL);
++qword_460;
}
else
{
++qword_450;
result = e3_timer_create(a1 + 5, a1[1], connecting, a1);
++qword_468;
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(_QWORD *a1)
{
__int64 result; // rax

++_gcov0_connecting;
if ( (*(unsigned int (__fastcall **)(_QWORD))(*(_QWORD *)*a1 + 8LL))(*a1) )
{
++qword_428;
e3_timer_delete(a1 + 9);
++qword_438;
result = e3_event_fire(a1 + 2, 0LL);
++qword_440;
}
else
{
++qword_430;
if ( (*(unsigned int (__fastcall **)(_QWORD))(*(_QWORD *)*a1 + 24LL))(*a1) )
{
++qword_448;
e3_timer_delete(a1 + 9);
++qword_458;
result = e3_event_fire(a1 + 4, 0LL);
++qword_460;
}
else
{
++qword_450;
result = e3_timer_create(a1 + 5, a1[1], connecting, a1);
++qword_468;
}
}
return result;
}

original_code:
static void
connecting(e3_tcp_client_t *client) {
    if ((client->socket)->interface->is_connected(client->socket)) {
        e3_timer_delete(&client->timeout_timer);
        e3_event_fire(&client->connected, 0);
    }
    else if ((client->socket)->interface->is_error(client->socket)) {
        e3_timer_delete(&client->timeout_timer);
        e3_event_fire(&client->disconnected, 0);
    }
    else {
        e3_timer_create(&client->poll_timer, client->poll_interval,
            (e3_timer_function_t) connecting, client);
    }
}

canonical_original_code:
static void connecting(struct e3_tcp_client *client) {
    if ((client->socket)->interface->is_connected(client->socket)) {
        e3_timer_delete(&client->timeout_timer);
        e3_event_fire(&client->connected, 0);
    }
    else if ((client->socket)->interface->is_error(client->socket)) {
        e3_timer_delete(&client->timeout_timer);
        e3_event_fire(&client->disconnected, 0);
    }
    else {
        e3_timer_create(&client->poll_timer, client->poll_interval,
            (void (*)(void *cookie)) connecting, client);
    }
}


decompiled_code:
__int64 __fastcall e3_tcp_client_create(_QWORD *a1, __int64 a2, __int64 a3)
{
__int64 result; // rax

++_gcov0_e3_tcp_client_create;
*a1 = a2;
a1[1] = a3;
e3_event_create(a1 + 2);
++qword_4A8;
e3_event_create(a1 + 3);
++qword_4B0;
result = e3_event_create(a1 + 4);
++qword_4B8;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func2(_QWORD *a1, __int64 a2, __int64 a3)
{
__int64 result; // rax

++_gcov0_e3_tcp_client_create;
*a1 = a2;
a1[1] = a3;
e3_event_create(a1 + 2);
++qword_4A8;
e3_event_create(a1 + 3);
++qword_4B0;
result = e3_event_create(a1 + 4);
++qword_4B8;
return result;
}

original_code:
void
e3_tcp_client_create(e3_tcp_client_t *client, e3_socket_t *socket,
    e3_timer_ticks_t poll_interval) {
    client->socket = socket;
    client->poll_interval = poll_interval;
    e3_event_create(&client->connected);
    e3_event_create(&client->timeout);
    e3_event_create(&client->disconnected);
}

canonical_original_code:
void e3_tcp_client_create(struct e3_tcp_client *client, struct e3_socket *socket, unsigned long poll_interval) {
    client->socket = socket;
    client->poll_interval = poll_interval;
    e3_event_create(&client->connected);
    e3_event_create(&client->timeout);
    e3_event_create(&client->disconnected);
}

variable_types:
socket
struct e3_socket *


decompiled_code:
__int64 __fastcall e3_tcp_client_connect(_QWORD *a1, __int64 a2, __int64 a3, __int64 a4)
{
__int64 result; // rax

++_gcov0_e3_tcp_client_connect;
(**(void (__fastcall ***)(_QWORD))*a1)(*a1);
++qword_4C8;
e3_timer_create(a1 + 5, a1[1], connecting, a1);
++qword_4D0;
result = e3_timer_create(a1 + 9, a4, connect_timeout, a1);
++qword_4D8;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func3(_QWORD *a1, __int64 a2, __int64 a3, __int64 a4)
{
__int64 result; // rax

++_gcov0_e3_tcp_client_connect;
(**(void (__fastcall ***)(_QWORD))*a1)(*a1);
++qword_4C8;
e3_timer_create(a1 + 5, a1[1], connecting, a1);
++qword_4D0;
result = e3_timer_create(a1 + 9, a4, connect_timeout, a1);
++qword_4D8;
return result;
}

original_code:
void
e3_tcp_client_connect(e3_tcp_client_t *client, const char *host, int port,
    e3_timer_ticks_t timeout) {
    (client->socket)->interface->connect(client->socket, host, port);
    e3_timer_create(&client->poll_timer, client->poll_interval,
        (e3_timer_function_t) connecting, client);
    e3_timer_create(&client->timeout_timer, timeout,
        (e3_timer_function_t) connect_timeout, client);
}

canonical_original_code:
void e3_tcp_client_connect(struct e3_tcp_client *client, char *host, int port, unsigned long timeout) {
    (client->socket)->interface->connect(client->socket, host, port);
    e3_timer_create(&client->poll_timer, client->poll_interval,
        (void (*)(void *cookie)) connecting, client);
    e3_timer_create(&client->timeout_timer, timeout,
        (void (*)(void *cookie)) connect_timeout, client);
}

variable_types:
timeout
unsigned long


decompiled_code:
__int64 __fastcall e3_tcp_client_delete(__int64 a1)
{
__int64 result; // rax

++_gcov0_e3_tcp_client_delete;
e3_event_delete(a1 + 16);
++qword_4E8;
e3_event_delete(a1 + 24);
++qword_4F0;
e3_event_delete(a1 + 32);
++qword_4F8;
e3_timer_delete(a1 + 40);
++qword_500;
result = e3_timer_delete(a1 + 72);
++qword_508;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func4(__int64 a1)
{
__int64 result; // rax

++_gcov0_e3_tcp_client_delete;
e3_event_delete(a1 + 16);
++qword_4E8;
e3_event_delete(a1 + 24);
++qword_4F0;
e3_event_delete(a1 + 32);
++qword_4F8;
e3_timer_delete(a1 + 40);
++qword_500;
result = e3_timer_delete(a1 + 72);
++qword_508;
return result;
}

original_code:
void
e3_tcp_client_delete(e3_tcp_client_t *client) {
    e3_event_delete(&client->connected);
    e3_event_delete(&client->timeout);
    e3_event_delete(&client->disconnected);
    e3_timer_delete(&client->poll_timer);
    e3_timer_delete(&client->timeout_timer);
}

canonical_original_code:
void e3_tcp_client_delete(struct e3_tcp_client *client) {
    e3_event_delete(&client->connected);
    e3_event_delete(&client->timeout);
    e3_event_delete(&client->disconnected);
    e3_timer_delete(&client->poll_timer);
    e3_timer_delete(&client->timeout_timer);
}


decompiled_code:
void e3_timer_interrupt()
{
++_gcov0_e3_timer_interrupt;
++pending_ticks;
}

canonical_decompiled_code:
void func0()
{
++_gcov0_e3_timer_interrupt;
++pending_ticks;
}

original_code:
void
e3_timer_interrupt(void) {
    pending_ticks++;
}

canonical_original_code:
void e3_timer_interrupt() {
    pending_ticks++;
}


decompiled_code:
_BOOL8 e3_timer_tick()
{
unsigned __int64 v0; // rbp
_QWORD *v1; // rbx
void (__fastcall *v3)(_QWORD); // rdx
_QWORD *v4; // rax
unsigned __int64 v5; // rdx

++_gcov0_e3_timer_tick;
v0 = pending_ticks;
pending_ticks = 0LL;
v1 = (_QWORD *)timers;
timers = 0LL;
while ( v1 )
{
v4 = v1;
v1 = (_QWORD *)*v1;
v5 = v4[1];
if ( v5 <= v0 )
{
v3 = (void (__fastcall *)(_QWORD))v4[2];
if ( v3 )
{
++qword_390;
v3(v4[3]);
}
else
{
++qword_398;
}
}
else
{
++qword_388;
*v4 = timers;
timers = (__int64)v4;
v4[1] = v5 - v0;
}
}
++qword_3A0;
return timers != 0;
}

canonical_decompiled_code:
_BOOL8 func1()
{
unsigned __int64 v0; // rbp
_QWORD *v1; // rbx
void (__fastcall *v3)(_QWORD); // rdx
_QWORD *v4; // rax
unsigned __int64 v5; // rdx

++_gcov0_e3_timer_tick;
v0 = pending_ticks;
pending_ticks = 0LL;
v1 = (_QWORD *)timers;
timers = 0LL;
while ( v1 )
{
v4 = v1;
v1 = (_QWORD *)*v1;
v5 = v4[1];
if ( v5 <= v0 )
{
v3 = (void (__fastcall *)(_QWORD))v4[2];
if ( v3 )
{
++qword_390;
v3(v4[3]);
}
else
{
++qword_398;
}
}
else
{
++qword_388;
*v4 = timers;
timers = (__int64)v4;
v4[1] = v5 - v0;
}
}
++qword_3A0;
return timers != 0;
}

original_code:
e3_timer_ticks_t
e3_timer_tick(void) {
    e3_timer_ticks_t ticks;
    e3_timer_t *current;
    e3_timer_t *next;
    ticks = pending_ticks;
    pending_ticks = 0;
    current = timers;
    timers = 0;
    while (current) {
        next = current->next;
        if (current->ticks > ticks) {
            current->next = timers;
            timers = current;
            current->ticks -= ticks;
        }
        else if (current->function) {
            current->function(current->cookie);
        }
        current = next;
    }
    return (timers != 0);
}

canonical_original_code:
unsigned long e3_timer_tick() {
    unsigned long ticks;
    struct e3_timer *current;
    struct e3_timer *next;
    ticks = pending_ticks;
    pending_ticks = 0;
    current = timers;
    timers = 0;
    while (current) {
        next = current->next;
        if (current->ticks > ticks) {
            current->next = timers;
            timers = current;
            current->ticks -= ticks;
        }
        else if (current->function) {
            current->function(current->cookie);
        }
        current = next;
    }
    return (timers != 0);
}

variable_types:
ticks
unsigned long

variable_types: struct e3_timer { struct e3_timer *next; unsigned long ticks; void (*function)(void *cookie); void *cookie; } *


enter

decompiled_code:
__int64 __fastcall enter(_QWORD *a1, __int64 a2)
{
__int64 result; // rax

if ( *a1 == a2 )
{
++qword_388;
}
else
{
++_gcov0_enter;
enter(a1, *(_QWORD *)a2);
++qword_390;
*a1 = a2;
result = (*(__int64 (__fastcall **)(_QWORD *))(a2 + 24))(a1);
++qword_398;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(_QWORD *a1, __int64 a2)
{
__int64 result; // rax

if ( *a1 == a2 )
{
++qword_388;
}
else
{
++_gcov0_enter;
func0(a1, *(_QWORD *)a2);
++qword_390;
*a1 = a2;
result = (*(__int64 (__fastcall **)(_QWORD *))(a2 + 24))(a1);
++qword_398;
}
return result;
}

original_code:
static void
enter(e3_hsm_t *hsm, const e3_hsm_state_t * const state) {
    if (hsm->state != state) {
        enter(hsm, state->parent);
        hsm->state = state;
        hsm->state->enter(hsm);
    }
}

canonical_original_code:
static void enter(struct e3_hsm *hsm, struct e3_hsm_state *state) {
    if (hsm->state != state) {
        enter(hsm, state->parent);
        hsm->state = state;
        hsm->state->enter(hsm);
    }
}

variable_types: struct e3_hsm { struct e3_hsm_state { struct e3_hsm_state *parent; unsigned long ancestry; struct e3_hsm_state *(*transition)(unsigned long signal); void (*enter)(void *cookie); void (*exit)(void *cookie); } *state; } *

variable_types:
state
struct e3_hsm_state *

user_defined_types: struct e3_hsm { struct e3_hsm_state *state; }


decompiled_code:
__int64 __fastcall e3_hsm_create(_QWORD *a1, __int64 a2)
{
__int64 result; // rax

++_gcov0_e3_hsm_create;
*a1 = 0LL;
result = enter(a1, a2);
++qword_3C8;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(_QWORD *a1, __int64 a2)
{
__int64 result; // rax

++_gcov0_e3_hsm_create;
*a1 = 0LL;
result = func0(a1, a2);
++qword_3C8;
return result;
}

original_code:
void
e3_hsm_create(e3_hsm_t *hsm, const e3_hsm_state_t * const state) {
    hsm->state = 0;
    enter(hsm, state);
}

canonical_original_code:
void e3_hsm_create(struct e3_hsm *hsm, struct e3_hsm_state *state) {
    hsm->state = 0;
    enter(hsm, state);
}

user_defined_types: struct e3_hsm_state { struct e3_hsm_state *parent; unsigned long ancestry; struct e3_hsm_state *(*transition)(unsigned long signal); void (*enter)(void *cookie); void (*exit)(void *cookie); }


callback

decompiled_code:
void __fastcall callback(int a1, __int64 a2)
{
*(_DWORD *)(a2 + 72) += a1;
}

canonical_decompiled_code:
void __fastcall func0(int a1, __int64 a2)
{
*(_DWORD *)(a2 + 72) += a1;
}

original_code:
static void
callback(void *cookie, void *args) {
    int amount = (int) cookie;
    test_t *test = (test_t *) args;
    test->count += amount;
}

canonical_original_code:
static void callback(void *cookie, void *args) {
    int amount = (int) cookie;
    struct test *test = (test_t *) args;
    test->count += amount;
}

variable_types:
cookie
void *

variable_types:
args
void *

variable_types: amount int

variable_types: struct test { struct e3_event { struct e3_event_listener { struct e3_event_listener *next; struct e3_event *event; void (*function)(void *hint, void *args); void *cookie; } *listeners; } e; struct e3_event_listener a; struct e3_event_listener b; int count; } *

user_defined_types: struct test { struct e3_event e; struct e3_event_listener a; struct e3_event_listener b; int count; }


original_code:
void
e3_event_test(jasmine_t *jasmine) {
    test_t test;
    for ((jasmine)->state = 0, (jasmine)->current = 0, (jasmine)->last = 0, puts("an event"); (3 == (jasmine)->state) ? (puts(""), 0) : 1; ) {
        for (; 0 == (jasmine)->state; (jasmine)->state = 1) {
            e3_event_create(&test.e);
            test.count = 0;
        }
        for (; 2 == (jasmine)->state; (jasmine)->state = ((jasmine)->current == (jasmine)->last) ? 3 : 0) {
            e3_event_delete(&test.e);
        }
        for ((jasmine)->group = 2, (jasmine)->last = (unsigned short) ((jasmine)->last < 55 ? 55 : (jasmine)->last); 1 == (jasmine)->state && (jasmine)->current < 55 && (55 == ((jasmine)->current = 55)); (jasmine)->state = 2, ((jasmine)->group == 2 ? ((jasmine)->ignored++, puts(" ! " "can have no listeners"), 2) : ((jasmine)->group == 1 ? ((jasmine)->passed++, puts(" ✓ " "can have no listeners"), 1) : ((jasmine)->failed++, printf(" ✗ " "can have no listeners" ": expected %s\r\n", (jasmine)->reason), 0)))) {
            e3_event_fire(&test.e, 0);
            if (!(test.count == 0)) { (jasmine)->expects++; (jasmine)->group = 0; (jasmine)->reason = "test.count == 0"; continue; } else { (jasmine)->group = 1; (jasmine)->expects++; };
        }
        for ((jasmine)->group = 2, (jasmine)->last = (unsigned short) ((jasmine)->last < 60 ? 60 : (jasmine)->last); 1 == (jasmine)->state && (jasmine)->current < 60 && (60 == ((jasmine)->current = 60)); (jasmine)->state = 2, ((jasmine)->group == 2 ? ((jasmine)->ignored++, puts(" ! " "can have a single listener"), 2) : ((jasmine)->group == 1 ? ((jasmine)->passed++, puts(" ✓ " "can have a single listener"), 1) : ((jasmine)->failed++, printf(" ✗ " "can have a single listener" ": expected %s\r\n", (jasmine)->reason), 0)))) {
            e3_event_listener_create(&test.a, &test.e, callback, (void *) 1);
            e3_event_fire(&test.e, &test);
            if (!(test.count == 1)) { (jasmine)->expects++; (jasmine)->group = 0; (jasmine)->reason = "test.count == 1"; continue; } else { (jasmine)->group = 1; (jasmine)->expects++; };
        }
        for ((jasmine)->group = 2, (jasmine)->last = (unsigned short) ((jasmine)->last < 66 ? 66 : (jasmine)->last); 1 == (jasmine)->state && (jasmine)->current < 66 && (66 == ((jasmine)->current = 66)); (jasmine)->state = 2, ((jasmine)->group == 2 ? ((jasmine)->ignored++, puts(" ! " "can have multiple listeners"), 2) : ((jasmine)->group == 1 ? ((jasmine)->passed++, puts(" ✓ " "can have multiple listeners"), 1) : ((jasmine)->failed++, printf(" ✗ " "can have multiple listeners" ": expected %s\r\n", (jasmine)->reason), 0)))) {
            e3_event_listener_create(&test.a, &test.e, callback, (void *) 1);
            e3_event_listener_create(&test.b, &test.e, callback, (void *) 2);
            e3_event_fire(&test.e, &test);
            if (!(test.count == 3)) { (jasmine)->expects++; (jasmine)->group = 0; (jasmine)->reason = "test.count == 3"; continue; } else { (jasmine)->group = 1; (jasmine)->expects++; };
        }
        for ((jasmine)->group = 2, (jasmine)->last = (unsigned short) ((jasmine)->last < 73 ? 73 : (jasmine)->last); 1 == (jasmine)->state && (jasmine)->current < 73 && (73 == ((jasmine)->current = 73)); (jasmine)->state = 2, ((jasmine)->group == 2 ? ((jasmine)->ignored++, puts(" ! " "will ignore invalid listeners"), 2) : ((jasmine)->group == 1 ? ((jasmine)->passed++, puts(" ✓ " "will ignore invalid listeners"), 1) : ((jasmine)->failed++, printf(" ✗ " "will ignore invalid listeners" ": expected %s\r\n", (jasmine)->reason), 0)))) {
            e3_event_listener_create(&test.a, &test.e, 0, 0);
            e3_event_fire(&test.e, &test);
            if (!(test.count == 0)) { (jasmine)->expects++; (jasmine)->group = 0; (jasmine)->reason = "test.count == 0"; continue; } else { (jasmine)->group = 1; (jasmine)->expects++; };
        }
        for ((jasmine)->group = 2, (jasmine)->last = (unsigned short) ((jasmine)->last < 79 ? 79 : (jasmine)->last); 1 == (jasmine)->state && (jasmine)->current < 79 && (79 == ((jasmine)->current = 79)); (jasmine)->state = 2, ((jasmine)->group == 2 ? ((jasmine)->ignored++, puts(" ! " "can fire multiple times"), 2) : ((jasmine)->group == 1 ? ((jasmine)->passed++, puts(" ✓ " "can fire multiple times"), 1) : ((jasmine)->failed++, printf(" ✗ " "can fire multiple times" ": expected %s\r\n", (jasmine)->reason), 0)))) {
            e3_event_listener_create(&test.a, &test.e, callback, (void *) 1);
            e3_event_listener_create(&test.b, &test.e, callback, (void *) 2);
            e3_event_fire(&test.e, &test);
            if (!(test.count == 3)) { (jasmine)->expects++; (jasmine)->group = 0; (jasmine)->reason = "test.count == 3"; continue; } else { (jasmine)->group = 1; (jasmine)->expects++; };
            e3_event_fire(&test.e, &test);
            if (!(test.count == 6)) { (jasmine)->expects++; (jasmine)->group = 0; (jasmine)->reason = "test.count == 6"; continue; } else { (jasmine)->group = 1; (jasmine)->expects++; };
        }
        for ((jasmine)->group = 2, (jasmine)->last = (unsigned short) ((jasmine)->last < 88 ? 88 : (jasmine)->last); 1 == (jasmine)->state && (jasmine)->current < 88 && (88 == ((jasmine)->current = 88)); (jasmine)->state = 2, ((jasmine)->group == 2 ? ((jasmine)->ignored++, puts(" ! " "can delete a listener"), 2) : ((jasmine)->group == 1 ? ((jasmine)->passed++, puts(" ✓ " "can delete a listener"), 1) : ((jasmine)->failed++, printf(" ✗ " "can delete a listener" ": expected %s\r\n", (jasmine)->reason), 0)))) {
            e3_event_listener_create(&test.a, &test.e, callback, (void *) 1);
            e3_event_listener_create(&test.b, &test.e, callback, (void *) 2);
            e3_event_fire(&test.e, &test);
            if (!(test.count == 3)) { (jasmine)->expects++; (jasmine)->group = 0; (jasmine)->reason = "test.count == 3"; continue; } else { (jasmine)->group = 1; (jasmine)->expects++; };
            e3_event_listener_delete(&test.b);
            e3_event_fire(&test.e, &test);
            if (!(test.count == 4)) { (jasmine)->expects++; (jasmine)->group = 0; (jasmine)->reason = "test.count == 4"; continue; } else { (jasmine)->group = 1; (jasmine)->expects++; };
        }
        for ((jasmine)->group = 2, (jasmine)->last = (unsigned short) ((jasmine)->last < 98 ? 98 : (jasmine)->last); 1 == (jasmine)->state && (jasmine)->current < 98 && (98 == ((jasmine)->current = 98)); (jasmine)->state = 2, ((jasmine)->group == 2 ? ((jasmine)->ignored++, puts(" ! " "cannot fire once deleted"), 2) : ((jasmine)->group == 1 ? ((jasmine)->passed++, puts(" ✓ " "cannot fire once deleted"), 1) : ((jasmine)->failed++, printf(" ✗ " "cannot fire once deleted" ": expected %s\r\n", (jasmine)->reason), 0)))) {
            e3_event_listener_create(&test.a, &test.e, callback, (void *) 1);
            e3_event_listener_create(&test.b, &test.e, callback, (void *) 2);
            e3_event_fire(&test.e, &test);
            if (!(test.count == 3)) { (jasmine)->expects++; (jasmine)->group = 0; (jasmine)->reason = "test.count == 3"; continue; } else { (jasmine)->group = 1; (jasmine)->expects++; };
            e3_event_delete(&test.e);
            e3_event_fire(&test.e, &test);
            if (!(test.count == 3)) { (jasmine)->expects++; (jasmine)->group = 0; (jasmine)->reason = "test.count == 3"; continue; } else { (jasmine)->group = 1; (jasmine)->expects++; };
        }
    }
}

canonical_original_code:
void e3_event_test(struct jasmine *jasmine) {
    struct test test;
    for ((jasmine)->state = 0, (jasmine)->current = 0, (jasmine)->last = 0, puts("an event"); (3 == (jasmine)->state) ? (puts(""), 0) : 1; ) {
        for (; 0 == (jasmine)->state; (jasmine)->state = 1) {
            e3_event_create(&test.e);
            test.count = 0;
        }
        for (; 2 == (jasmine)->state; (jasmine)->state = ((jasmine)->current == (jasmine)->last) ? 3 : 0) {
            e3_event_delete(&test.e);
        }
        for ((jasmine)->group = 2, (jasmine)->last = (unsigned short) ((jasmine)->last < 55 ? 55 : (jasmine)->last); 1 == (jasmine)->state && (jasmine)->current < 55 && (55 == ((jasmine)->current = 55)); (jasmine)->state = 2, ((jasmine)->group == 2 ? ((jasmine)->ignored++, puts(" ! " "can have no listeners"), 2) : ((jasmine)->group == 1 ? ((jasmine)->passed++, puts(" ✓ " "can have no listeners"), 1) : ((jasmine)->failed++, printf(" ✗ " "can have no listeners" ": expected %s\r\n", (jasmine)->reason), 0)))) {
            e3_event_fire(&test.e, 0);
            if (!(test.count == 0)) { (jasmine)->expects++; (jasmine)->group = 0; (jasmine)->reason = "test.count == 0"; continue; } else { (jasmine)->group = 1; (jasmine)->expects++; };
        }
        for ((jasmine)->group = 2, (jasmine)->last = (unsigned short) ((jasmine)->last < 60 ? 60 : (jasmine)->last); 1 == (jasmine)->state && (jasmine)->current < 60 && (60 == ((jasmine)->current = 60)); (jasmine)->state = 2, ((jasmine)->group == 2 ? ((jasmine)->ignored++, puts(" ! " "can have a single listener"), 2) : ((jasmine)->group == 1 ? ((jasmine)->passed++, puts(" ✓ " "can have a single listener"), 1) : ((jasmine)->failed++, printf(" ✗ " "can have a single listener" ": expected %s\r\n", (jasmine)->reason), 0)))) {
            e3_event_listener_create(&test.a, &test.e, callback, (void *) 1);
            e3_event_fire(&test.e, &test);
            if (!(test.count == 1)) { (jasmine)->expects++; (jasmine)->group = 0; (jasmine)->reason = "test.count == 1"; continue; } else { (jasmine)->group = 1; (jasmine)->expects++; };
        }
        for ((jasmine)->group = 2, (jasmine)->last = (unsigned short) ((jasmine)->last < 66 ? 66 : (jasmine)->last); 1 == (jasmine)->state && (jasmine)->current < 66 && (66 == ((jasmine)->current = 66)); (jasmine)->state = 2, ((jasmine)->group == 2 ? ((jasmine)->ignored++, puts(" ! " "can have multiple listeners"), 2) : ((jasmine)->group == 1 ? ((jasmine)->passed++, puts(" ✓ " "can have multiple listeners"), 1) : ((jasmine)->failed++, printf(" ✗ " "can have multiple listeners" ": expected %s\r\n", (jasmine)->reason), 0)))) {
            e3_event_listener_create(&test.a, &test.e, callback, (void *) 1);
            e3_event_listener_create(&test.b, &test.e, callback, (void *) 2);
            e3_event_fire(&test.e, &test);
            if (!(test.count == 3)) { (jasmine)->expects++; (jasmine)->group = 0; (jasmine)->reason = "test.count == 3"; continue; } else { (jasmine)->group = 1; (jasmine)->expects++; };
        }
        for ((jasmine)->group = 2, (jasmine)->last = (unsigned short) ((jasmine)->last < 73 ? 73 : (jasmine)->last); 1 == (jasmine)->state && (jasmine)->current < 73 && (73 == ((jasmine)->current = 73)); (jasmine)->state = 2, ((jasmine)->group == 2 ? ((jasmine)->ignored++, puts(" ! " "will ignore invalid listeners"), 2) : ((jasmine)->group == 1 ? ((jasmine)->passed++, puts(" ✓ " "will ignore invalid listeners"), 1) : ((jasmine)->failed++, printf(" ✗ " "will ignore invalid listeners" ": expected %s\r\n", (jasmine)->reason), 0)))) {
            e3_event_listener_create(&test.a, &test.e, 0, 0);
            e3_event_fire(&test.e, &test);
            if (!(test.count == 0)) { (jasmine)->expects++; (jasmine)->group = 0; (jasmine)->reason = "test.count == 0"; continue; } else { (jasmine)->group = 1; (jasmine)->expects++; };
        }
        for ((jasmine)->group = 2, (jasmine)->last = (unsigned short) ((jasmine)->last < 79 ? 79 : (jasmine)->last); 1 == (jasmine)->state && (jasmine)->current < 79 && (79 == ((jasmine)->current = 79)); (jasmine)->state = 2, ((jasmine)->group == 2 ? ((jasmine)->ignored++, puts(" ! " "can fire multiple times"), 2) : ((jasmine)->group == 1 ? ((jasmine)->passed++, puts(" ✓ " "can fire multiple times"), 1) : ((jasmine)->failed++, printf(" ✗ " "can fire multiple times" ": expected %s\r\n", (jasmine)->reason), 0)))) {
            e3_event_listener_create(&test.a, &test.e, callback, (void *) 1);
            e3_event_listener_create(&test.b, &test.e, callback, (void *) 2);
            e3_event_fire(&test.e, &test);
            if (!(test.count == 3)) { (jasmine)->expects++; (jasmine)->group = 0; (jasmine)->reason = "test.count == 3"; continue; } else { (jasmine)->group = 1; (jasmine)->expects++; };
            e3_event_fire(&test.e, &test);
            if (!(test.count == 6)) { (jasmine)->expects++; (jasmine)->group = 0; (jasmine)->reason = "test.count == 6"; continue; } else { (jasmine)->group = 1; (jasmine)->expects++; };
        }
        for ((jasmine)->group = 2, (jasmine)->last = (unsigned short) ((jasmine)->last < 88 ? 88 : (jasmine)->last); 1 == (jasmine)->state && (jasmine)->current < 88 && (88 == ((jasmine)->current = 88)); (jasmine)->state = 2, ((jasmine)->group == 2 ? ((jasmine)->ignored++, puts(" ! " "can delete a listener"), 2) : ((jasmine)->group == 1 ? ((jasmine)->passed++, puts(" ✓ " "can delete a listener"), 1) : ((jasmine)->failed++, printf(" ✗ " "can delete a listener" ": expected %s\r\n", (jasmine)->reason), 0)))) {
            e3_event_listener_create(&test.a, &test.e, callback, (void *) 1);
            e3_event_listener_create(&test.b, &test.e, callback, (void *) 2);
            e3_event_fire(&test.e, &test);
            if (!(test.count == 3)) { (jasmine)->expects++; (jasmine)->group = 0; (jasmine)->reason = "test.count == 3"; continue; } else { (jasmine)->group = 1; (jasmine)->expects++; };
            e3_event_listener_delete(&test.b);
            e3_event_fire(&test.e, &test);
            if (!(test.count == 4)) { (jasmine)->expects++; (jasmine)->group = 0; (jasmine)->reason = "test.count == 4"; continue; } else { (jasmine)->group = 1; (jasmine)->expects++; };
        }
        for ((jasmine)->group = 2, (jasmine)->last = (unsigned short) ((jasmine)->last < 98 ? 98 : (jasmine)->last); 1 == (jasmine)->state && (jasmine)->current < 98 && (98 == ((jasmine)->current = 98)); (jasmine)->state = 2, ((jasmine)->group == 2 ? ((jasmine)->ignored++, puts(" ! " "cannot fire once deleted"), 2) : ((jasmine)->group == 1 ? ((jasmine)->passed++, puts(" ✓ " "cannot fire once deleted"), 1) : ((jasmine)->failed++, printf(" ✗ " "cannot fire once deleted" ": expected %s\r\n", (jasmine)->reason), 0)))) {
            e3_event_listener_create(&test.a, &test.e, callback, (void *) 1);
            e3_event_listener_create(&test.b, &test.e, callback, (void *) 2);
            e3_event_fire(&test.e, &test);
            if (!(test.count == 3)) { (jasmine)->expects++; (jasmine)->group = 0; (jasmine)->reason = "test.count == 3"; continue; } else { (jasmine)->group = 1; (jasmine)->expects++; };
            e3_event_delete(&test.e);
            e3_event_fire(&test.e, &test);
            if (!(test.count == 3)) { (jasmine)->expects++; (jasmine)->group = 0; (jasmine)->reason = "test.count == 3"; continue; } else { (jasmine)->group = 1; (jasmine)->expects++; };
        }
    }
}

variable_types: struct jasmine { char *reason; unsigned short state; unsigned short group; unsigned short current; unsigned short last; unsigned short passed; unsigned short failed; unsigned short ignored; unsigned short expects; } *

variable_types: struct test { struct e3_event { struct e3_event_listener { struct e3_event_listener *next; struct e3_event *event; void (*function)(void *hint, void *args); void *cookie; } *listeners; } e; struct e3_event_listener a; struct e3_event_listener b; int count; }


decompiled_code:
void __fastcall e3_event_fire(_QWORD **a1, __int64 a2)
{
_QWORD *v2; // rbx
_QWORD *v3; // rdx
void (__fastcall *v4)(_QWORD, __int64); // rax

++_gcov0_e3_event_fire;
v2 = *a1;
while ( v2 )
{
v3 = v2;
v2 = (_QWORD *)*v2;
v4 = (void (__fastcall *)(_QWORD, __int64))v3[2];
if ( v4 )
{
++qword_388;
v4(v3[3], a2);
}
else
{
++qword_390;
}
}
++qword_398;
}

canonical_decompiled_code:
void __fastcall func2(_QWORD **a1, __int64 a2)
{
_QWORD *v2; // rbx
_QWORD *v3; // rdx
void (__fastcall *v4)(_QWORD, __int64); // rax

++_gcov0_e3_event_fire;
v2 = *a1;
while ( v2 )
{
v3 = v2;
v2 = (_QWORD *)*v2;
v4 = (void (__fastcall *)(_QWORD, __int64))v3[2];
if ( v4 )
{
++qword_388;
v4(v3[3], a2);
}
else
{
++qword_390;
}
}
++qword_398;
}

original_code:
void
e3_event_fire(e3_event_t *event, void *args) {
    e3_event_listener_t *current;
    e3_event_listener_t *next;
    current = event->listeners;
    while (current) {
        next = current->next;
        if (current->function) {
            current->function(current->cookie, args);
        }
        current = next;
    }
}

canonical_original_code:
void e3_event_fire(struct e3_event *event, void *args) {
    struct e3_event_listener *current;
    struct e3_event_listener *next;
    current = event->listeners;
    while (current) {
        next = current->next;
        if (current->function) {
            current->function(current->cookie, args);
        }
        current = next;
    }
}

variable_types: struct e3_event { struct e3_event_listener { struct e3_event_listener *next; struct e3_event *event; void (*function)(void *hint, void *args); void *cookie; } *listeners; } *

variable_types: struct e3_event_listener { struct e3_event_listener *next; struct e3_event { struct e3_event_listener *listeners; } *event; void (*function)(void *hint, void *args); void *cookie; } *


repo: bamboolll/goitout

decompiled_code:
unsigned __int64 hash_rand()
{
unsigned int v0; // ebx

v0 = gg_urand();
return v0 | (unsigned __int64)(gg_urand() << 32);
}

canonical_decompiled_code:
unsigned __int64 func0()
{
unsigned int v0; // ebx

v0 = gg_urand();
return v0 | (unsigned __int64)(gg_urand() << 32);
}

original_code:
static Hashvalue
hash_rand(void)
{
  int i;
  Hashvalue h = 0;
  for (i = 0; 32*i < (int) (8*sizeof(Hashvalue)); i++)
    h |= (Hashvalue) gg_urand() << 32*i;
  return h;
}

canonical_original_code:
static unsigned long hash_rand()
{
  int i;
  unsigned long h = 0;
  for (i = 0; 32*i < (int) (8*sizeof(Hashvalue)); i++)
    h |= (unsigned long) gg_urand() << 32*i;
  return h;
}

variable_types: i int

variable_types:
h
unsigned long


decompiled_code:
void __fastcall hash_init_zobrist_array(unsigned __int64 *a1, int a2)
{
unsigned __int64 *v2; // rbx

if ( a2 > 0 )
{
v2 = a1;
do
{
*v2 = hash_rand();
v2[1] = hash_rand();
v2 += 2;
}
while ( v2 != &a1[2 * (unsigned int)(a2 - 1) + 2] );
}
}

canonical_decompiled_code:
void __fastcall func1(unsigned __int64 *a1, int a2)
{
unsigned __int64 *v2; // rbx

if ( a2 > 0 )
{
v2 = a1;
do
{
*v2 = func0();
v2[1] = func0();
v2 += 2;
}
while ( v2 != &a1[2 * (unsigned int)(a2 - 1) + 2] );
}
}

original_code:
void
hash_init_zobrist_array(Hash_data *array, int size)
{
  int i, j;
  for (i = 0; i < size; i++)
    for (j = 0; j < (1 + (64 - 1) / (8 * 4)); j++)
      array[i].hashval[j] = hash_rand();
}

canonical_original_code:
void hash_init_zobrist_array(struct Hash_data *array, int size)
{
  int i; int j;
  for (i = 0; i < size; i++)
    for (j = 0; j < (1 + (64 - 1) / (8 * 4)); j++)
      array[i].hashval[j] = hash_rand();
}

variable_types: struct Hash_data { unsigned long hashval[-1]; } *

variable_types: size int

variable_types: j int


decompiled_code:
void hash_init()
{
if ( !is_initialized_1 )
{
hash_init_zobrist_array((unsigned __int64 *)&black_hash, 400);
hash_init_zobrist_array((unsigned __int64 *)&white_hash, 400);
hash_init_zobrist_array((unsigned __int64 *)&ko_hash, 400);
hash_init_zobrist_array((unsigned __int64 *)&komaster_hash, 7);
hash_init_zobrist_array((unsigned __int64 *)&kom_pos_hash, 400);
hash_init_zobrist_array(goal_hash, 400);
is_initialized_1 = 1;
}
}

canonical_decompiled_code:
void func2()
{
if ( !is_initialized_1 )
{
func1((unsigned __int64 *)&black_hash, 400);
func1((unsigned __int64 *)&white_hash, 400);
func1((unsigned __int64 *)&ko_hash, 400);
func1((unsigned __int64 *)&komaster_hash, 7);
func1((unsigned __int64 *)&kom_pos_hash, 400);
func1(goal_hash, 400);
is_initialized_1 = 1;
}
}

original_code:
void
hash_init(void)
{
  static int is_initialized = 0;
  if (is_initialized)
    return;
  hash_init_zobrist_array(black_hash, (int) (sizeof(black_hash) / sizeof(black_hash[0])));
  hash_init_zobrist_array(white_hash, (int) (sizeof(white_hash) / sizeof(white_hash[0])));
  hash_init_zobrist_array(ko_hash, (int) (sizeof(ko_hash) / sizeof(ko_hash[0])));
  hash_init_zobrist_array(komaster_hash, (int) (sizeof(komaster_hash) / sizeof(komaster_hash[0])));
  hash_init_zobrist_array(kom_pos_hash, (int) (sizeof(kom_pos_hash) / sizeof(kom_pos_hash[0])));
  hash_init_zobrist_array(goal_hash, (int) (sizeof(goal_hash) / sizeof(goal_hash[0])));
  is_initialized = 1;
}

canonical_original_code:
void hash_init()
{
  static int is_initialized = 0;
  if (is_initialized)
    return;
  hash_init_zobrist_array(black_hash, (int) (sizeof(black_hash) / sizeof(black_hash[0])));
  hash_init_zobrist_array(white_hash, (int) (sizeof(white_hash) / sizeof(white_hash[0])));
  hash_init_zobrist_array(ko_hash, (int) (sizeof(ko_hash) / sizeof(ko_hash[0])));
  hash_init_zobrist_array(komaster_hash, (int) (sizeof(komaster_hash) / sizeof(komaster_hash[0])));
  hash_init_zobrist_array(kom_pos_hash, (int) (sizeof(kom_pos_hash) / sizeof(kom_pos_hash[0])));
  hash_init_zobrist_array(goal_hash, (int) (sizeof(goal_hash) / sizeof(goal_hash[0])));
  is_initialized = 1;
}


decompiled_code:
void __fastcall hashdata_clear(_QWORD *a1)
{
*a1 = 0LL;
a1[1] = 0LL;
}

canonical_decompiled_code:
void __fastcall func3(_QWORD *a1)
{
*a1 = 0LL;
a1[1] = 0LL;
}

original_code:
void
hashdata_clear(Hash_data *hd)
{
  int i;
  for (i = 0; i < (1 + (64 - 1) / (8 * 4)); i++)
    hd->hashval[i] = 0;
}

canonical_original_code:
void hashdata_clear(struct Hash_data *hd)
{
  int i;
  for (i = 0; i < (1 + (64 - 1) / (8 * 4)); i++)
    hd->hashval[i] = 0;
}

user_defined_types: struct Hash_data { unsigned long hashval[-1]; }


decompiled_code:
__int64 __fastcall hashdata_recalc(_QWORD *a1, __int64 a2, int a3)
{
_BYTE *v4; // rdx
__int64 result; // rax
__int64 v6; // r12

hashdata_clear(a1);
v4 = (_BYTE *)(a2 + 21);
for ( result = 336LL; result != 6400; result += 16LL )
{
if ( *v4 == 1 )
{
*a1 ^= *(__int64 *)((char *)&white_hash + result);
a1[1] ^= *(__int64 *)((char *)&qword_6908 + result);
}
else if ( *v4 == 2 )
{
*a1 ^= *(__int64 *)((char *)&black_hash + result);
a1[1] ^= *(__int64 *)((char *)&qword_5008 + result);
}
++v4;
}
if ( a3 )
{
v6 = 2LL * a3;
*a1 ^= ko_hash[v6];
result = qword_3708[v6];
a1[1] ^= result;
}
return result;
}

original_code:
void
hashdata_recalc(Hash_data *hd, Intersection *p, int ko_pos)
{
  int pos;
  hashdata_clear(hd);
  for (pos = (19 + 2); pos < (19 + 1) * (19 + 1); pos++) {
    if (p[pos] == WHITE)
      do { (*hd).hashval[0] ^= (white_hash[pos]).hashval[0]; (*hd).hashval[1] ^= (white_hash[pos]).hashval[1]; } while (0);
    else if (p[pos] == BLACK)
      do { (*hd).hashval[0] ^= (black_hash[pos]).hashval[0]; (*hd).hashval[1] ^= (black_hash[pos]).hashval[1]; } while (0);
  }
  if (ko_pos != 0)
    do { (*hd).hashval[0] ^= (ko_hash[ko_pos]).hashval[0]; (*hd).hashval[1] ^= (ko_hash[ko_pos]).hashval[1]; } while (0);
}

canonical_original_code:
void hashdata_recalc(struct Hash_data *hd, unsigned char *p, int ko_pos)
{
  int pos;
  hashdata_clear(hd);
  for (pos = (19 + 2); pos < (19 + 1) * (19 + 1); pos++) {
    if (p[pos] == WHITE)
      do { (*hd).hashval[0] ^= (white_hash[pos]).hashval[0]; (*hd).hashval[1] ^= (white_hash[pos]).hashval[1]; } while (0);
    else if (p[pos] == BLACK)
      do { (*hd).hashval[0] ^= (black_hash[pos]).hashval[0]; (*hd).hashval[1] ^= (black_hash[pos]).hashval[1]; } while (0);
  }
  if (ko_pos != 0)
    do { (*hd).hashval[0] ^= (ko_hash[ko_pos]).hashval[0]; (*hd).hashval[1] ^= (ko_hash[ko_pos]).hashval[1]; } while (0);
}

variable_types:
p
unsigned char *

variable_types: pos int


decompiled_code:
unsigned __int64 __fastcall hashdata_calc_orientation_invariant(unsigned __int64 *a1, __int64 a2, unsigned int a3)
{
unsigned int i; // er13
unsigned __int64 result; // rax
__int64 j; // rbx
__m128i v7; // [rsp+0h] [rbp-48h] BYREF

for ( i = 0; i != 8; ++i )
{
hashdata_clear(&v7);
for ( j = 21LL; j != 400; ++j )
{
result = *(unsigned __int8 *)(a2 + j);
if ( (_BYTE)result == 1 )
{
v7.m128i_i64[0] ^= white_hash[2 * (int)rotate1((unsigned int)j, i)];
result = qword_6908[2 * (int)rotate1((unsigned int)j, i)];
v7.m128i_i64[1] ^= result;
}
else if ( (_BYTE)result == 2 )
{
v7.m128i_i64[0] ^= black_hash[2 * (int)rotate1((unsigned int)j, i)];
result = qword_5008[2 * (int)rotate1((unsigned int)j, i)];
v7.m128i_i64[1] ^= result;
}
}
if ( a3 )
{
v7.m128i_i64[0] ^= ko_hash[2 * (int)rotate1(a3, i)];
result = qword_3708[2 * (int)rotate1(a3, i)];
v7.m128i_i64[1] ^= result;
}
if ( i )
{
result = *a1;
if ( v7.m128i_i64[0] >= *a1 )
{
if ( v7.m128i_i64[0] != *a1 )
continue;
result = a1[1];
if ( v7.m128i_i64[1] >= result )
continue;
}
}
*(__m128i *)a1 = _mm_loadu_si128(&v7);
}
return result;
}

canonical_decompiled_code:
unsigned __int64 __fastcall func9(unsigned __int64 *a1, __int64 a2, unsigned int a3)
{
unsigned int i; // er13
unsigned __int64 result; // rax
__int64 j; // rbx
__m128i v7; // [rsp+0h] [rbp-48h] BYREF

for ( i = 0; i != 8; ++i )
{
func3(&v7);
for ( j = 21LL; j != 400; ++j )
{
result = *(unsigned __int8 *)(a2 + j);
if ( (_BYTE)result == 1 )
{
v7.m128i_i64[0] ^= white_hash[2 * (int)rotate1((unsigned int)j, i)];
result = qword_6908[2 * (int)rotate1((unsigned int)j, i)];
v7.m128i_i64[1] ^= result;
}
else if ( (_BYTE)result == 2 )
{
v7.m128i_i64[0] ^= black_hash[2 * (int)rotate1((unsigned int)j, i)];
result = qword_5008[2 * (int)rotate1((unsigned int)j, i)];
v7.m128i_i64[1] ^= result;
}
}
if ( a3 )
{
v7.m128i_i64[0] ^= ko_hash[2 * (int)rotate1(a3, i)];
result = qword_3708[2 * (int)rotate1(a3, i)];
v7.m128i_i64[1] ^= result;
}
if ( i )
{
result = *a1;
if ( v7.m128i_i64[0] >= *a1 )
{
if ( v7.m128i_i64[0] != *a1 )
continue;
result = a1[1];
if ( v7.m128i_i64[1] >= result )
continue;
}
}
*(__m128i *)a1 = _mm_loadu_si128(&v7);
}
return result;
}

original_code:
void
hashdata_calc_orientation_invariant(Hash_data *hd, Intersection *p, int ko_pos)
{
  int pos;
  int rot;
  Hash_data hd_rot;
  for (rot = 0; rot < 8; rot++) {
    hashdata_clear(&hd_rot);
    for (pos = (19 + 2); pos < (19 + 1) * (19 + 1); pos++) {
      if (p[pos] == WHITE)
 do { (hd_rot).hashval[0] ^= (white_hash[rotate1(pos, rot)]).hashval[0]; (hd_rot).hashval[1] ^= (white_hash[rotate1(pos, rot)]).hashval[1]; } while (0);
      else if (p[pos] == BLACK)
 do { (hd_rot).hashval[0] ^= (black_hash[rotate1(pos, rot)]).hashval[0]; (hd_rot).hashval[1] ^= (black_hash[rotate1(pos, rot)]).hashval[1]; } while (0);
    }
    if (ko_pos != 0)
      do { (hd_rot).hashval[0] ^= (ko_hash[rotate1(ko_pos, rot)]).hashval[0]; (hd_rot).hashval[1] ^= (ko_hash[rotate1(ko_pos, rot)]).hashval[1]; } while (0);
    if (rot == 0 || ((hd_rot).hashval[0] < (*hd).hashval[0] || ((hd_rot).hashval[0] == (*hd).hashval[0] && (hd_rot).hashval[1] < (*hd).hashval[1])))
      *hd = hd_rot;
  }
}

canonical_original_code:
void hashdata_calc_orientation_invariant(struct Hash_data *hd, unsigned char *p, int ko_pos)
{
  int pos;
  int rot;
  struct Hash_data hd_rot;
  for (rot = 0; rot < 8; rot++) {
    hashdata_clear(&hd_rot);
    for (pos = (19 + 2); pos < (19 + 1) * (19 + 1); pos++) {
      if (p[pos] == WHITE)
 do { (hd_rot).hashval[0] ^= (white_hash[rotate1(pos, rot)]).hashval[0]; (hd_rot).hashval[1] ^= (white_hash[rotate1(pos, rot)]).hashval[1]; } while (0);
      else if (p[pos] == BLACK)
 do { (hd_rot).hashval[0] ^= (black_hash[rotate1(pos, rot)]).hashval[0]; (hd_rot).hashval[1] ^= (black_hash[rotate1(pos, rot)]).hashval[1]; } while (0);
    }
    if (ko_pos != 0)
      do { (hd_rot).hashval[0] ^= (ko_hash[rotate1(ko_pos, rot)]).hashval[0]; (hd_rot).hashval[1] ^= (ko_hash[rotate1(ko_pos, rot)]).hashval[1]; } while (0);
    if (rot == 0 || ((hd_rot).hashval[0] < (*hd).hashval[0] || ((hd_rot).hashval[0] == (*hd).hashval[0] && (hd_rot).hashval[1] < (*hd).hashval[1])))
      *hd = hd_rot;
  }
}

variable_types: rot int

variable_types: struct Hash_data { unsigned long hashval[-1]; }


original_code:
Hash_data
goal_to_hashvalue(const signed char *goal)
{
  int pos;
  Hash_data return_value;
  hashdata_clear(&return_value);
  for (pos = (19 + 2); pos < (19 + 1) * (19 + 1); pos++)
    if ((board[pos] != GRAY) && goal[pos])
      do { (return_value).hashval[0] ^= (goal_hash[pos]).hashval[0]; (return_value).hashval[1] ^= (goal_hash[pos]).hashval[1]; } while (0);
  return return_value;
}

canonical_original_code:
struct Hash_data goal_to_hashvalue(char *goal)
{
  int pos;
  struct Hash_data return_value;
  hashdata_clear(&return_value);
  for (pos = (19 + 2); pos < (19 + 1) * (19 + 1); pos++)
    if ((board[pos] != GRAY) && goal[pos])
      do { (return_value).hashval[0] ^= (goal_hash[pos]).hashval[0]; (return_value).hashval[1] ^= (goal_hash[pos]).hashval[1]; } while (0);
  return return_value;
}

variable_types:
goal
char *

return_type: struct Hash_data { unsigned long hashval[-1]; }


variable_types:
buffer
char [-1]

variable_types: n int

variable_types: k int

return_type: char *


decompiled_code:
void __fastcall sgffile_enddump(_BYTE *a1)
{
if ( a1 && *a1 && sgf_dumptree )
{
if ( (unsigned int)writesgf(*sgf_dumptree, a1) )
{
sgfFreeNode(*sgf_dumptree);
sgf_dumptree = 0LL;
}
}
}

canonical_decompiled_code:
void __fastcall func0(_BYTE *a1)
{
if ( a1 && *a1 && sgf_dumptree )
{
if ( (unsigned int)writesgf(*sgf_dumptree, a1) )
{
sgfFreeNode(*sgf_dumptree);
sgf_dumptree = 0LL;
}
}
}

original_code:
void
sgffile_enddump(const char *filename)
{
  if (filename && *filename && sgf_dumptree) {
    if (writesgf(sgf_dumptree->root, filename)) {
      sgfFreeNode(sgf_dumptree->root);
      sgf_dumptree = ((void *)0);
    }
  }
}

canonical_original_code:
void sgffile_enddump(char *filename)
{
  if (filename && *filename && sgf_dumptree) {
    if (writesgf(sgf_dumptree->root, filename)) {
      sgfFreeNode(sgf_dumptree->root);
      sgf_dumptree = ((void *)0);
    }
  }
}

variable_types:
filename
char *


decompiled_code:
__int64 __fastcall sgffile_printboard(__int64 a1)
{
__int64 v1; // rbx
__int64 i; // rbp
int v3; // er12
__int64 v4; // r13
int v6; // er15
int v8; // er15
int v9; // er12
__int64 j; // rbx

if ( !a1 )
{
abortgo("msgffile.c", 201LL, "tree", 0LL);
goto LABEL_5;
}
v4 = *(_QWORD *)(a1 + 8);
v6 = 21;
v3 = 0;
if ( board_size > 0 )
{
do
{
v1 = 0LL;
for ( i = v6 - 21; board_size > (int)v1; ++v1 )
{
if ( board[i + 21 + v1] == 1 )
sgfAddStone(v4, 1LL, (unsigned int)v3, (unsigned int)v1);
LABEL_5:
;
}
++v3;
v6 += 20;
}
while ( board_size > v3 );
if ( board_size > 0 )
{
v8 = 21;
v9 = 0;
do
{
for ( j = 0LL; board_size > (int)j; ++j )
{
if ( board[v8 + j] == 2 )
sgfAddStone(v4, 2LL, (unsigned int)v9, (unsigned int)j);
}
++v9;
v8 += 20;
}
while ( board_size > v9 );
}
}
return sgftreeSetLastNode(a1, v4);
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1)
{
__int64 v1; // rbx
__int64 i; // rbp
int v3; // er12
__int64 v4; // r13
int v6; // er15
int v8; // er15
int v9; // er12
__int64 j; // rbx

if ( !a1 )
{
abortgo("msgffile.c", 201LL, "tree", 0LL);
goto LABEL_5;
}
v4 = *(_QWORD *)(a1 + 8);
v6 = 21;
v3 = 0;
if ( board_size > 0 )
{
do
{
v1 = 0LL;
for ( i = v6 - 21; board_size > (int)v1; ++v1 )
{
if ( board[i + 21 + v1] == 1 )
sgfAddStone(v4, 1LL, (unsigned int)v3, (unsigned int)v1);
LABEL_5:
;
}
++v3;
v6 += 20;
}
while ( board_size > v3 );
if ( board_size > 0 )
{
v8 = 21;
v9 = 0;
do
{
for ( j = 0LL; board_size > (int)j; ++j )
{
if ( board[v8 + j] == 2 )
sgfAddStone(v4, 2LL, (unsigned int)v9, (unsigned int)j);
}
++v9;
v8 += 20;
}
while ( board_size > v9 );
}
}
return sgftreeSetLastNode(a1, v4);
}

original_code:
void
sgffile_printboard(SGFTree *tree)
{
  int i, j;
  SGFNode *node;
  if (tree) ; else abortgo("msgffile.c", 201, "tree", 0);
  node = tree->lastnode;
  for (i = 0; i < board_size; i++) {
    for (j = 0; j < board_size; j++) {
      if (board[((19 + 2) + (i) * (19 + 1) + (j))] == WHITE)
 sgfAddStone(node, WHITE, i, j);
    }
  }
  for (i = 0; i < board_size; i++) {
    for (j = 0; j < board_size; j++) {
      if (board[((19 + 2) + (i) * (19 + 1) + (j))] == BLACK)
 sgfAddStone(node, BLACK, i, j);
    }
  }
  sgftreeSetLastNode(tree, node);
}

canonical_original_code:
void sgffile_printboard(struct SGFTree_t *tree)
{
  int i; int j;
  struct SGFNode_t *node;
  if (tree) ; else abortgo("msgffile.c", 201, "tree", 0);
  node = tree->lastnode;
  for (i = 0; i < board_size; i++) {
    for (j = 0; j < board_size; j++) {
      if (board[((19 + 2) + (i) * (19 + 1) + (j))] == WHITE)
 sgfAddStone(node, WHITE, i, j);
    }
  }
  for (i = 0; i < board_size; i++) {
    for (j = 0; j < board_size; j++) {
      if (board[((19 + 2) + (i) * (19 + 1) + (j))] == BLACK)
 sgfAddStone(node, BLACK, i, j);
    }
  }
  sgftreeSetLastNode(tree, node);
}

variable_types: struct SGFTree_t { struct SGFNode_t { struct SGFProperty_t { struct SGFProperty_t *next; short name; char *value; } *props; struct SGFNode_t *parent; struct SGFNode_t *child; struct SGFNode_t *next; } *root; struct SGFNode_t *lastnode; } *

user_defined_types: struct SGFTree_t { struct SGFNode_t *root; struct SGFNode_t *lastnode; }

user_defined_types: struct SGFNode_t { struct SGFProperty_t *props; struct SGFNode_t *parent; struct SGFNode_t *child; struct SGFNode_t *next; }


decompiled_code:
__int64 __fastcall sgffile_begindump(void *a1)
{
__int64 result; // rax

if ( sgf_dumptree )
{
abortgo("msgffile.c", 116LL, "sgf_dumptree == ((void *)0)", 0LL);
result = sgffile_recordboard();
}
else
{
if ( !a1 )
a1 = &local_tree_0;
sgf_dumptree = a1;
sgftree_clear();
sgftreeCreateHeaderNode(sgf_dumptree, board_size, handicap, komi);
result = sgffile_printboard(sgf_dumptree);
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func2(void *a1)
{
__int64 result; // rax

if ( sgf_dumptree )
{
abortgo("msgffile.c", 116LL, "sgf_dumptree == ((void *)0)", 0LL);
result = func3();
}
else
{
if ( !a1 )
a1 = &local_tree_0;
sgf_dumptree = a1;
sgftree_clear();
sgftreeCreateHeaderNode(sgf_dumptree, board_size, handicap, komi);
result = func1(sgf_dumptree);
}
return result;
}

original_code:
void
sgffile_begindump(SGFTree *tree)
{
  static SGFTree local_tree;
  if (sgf_dumptree == ((void *)0)) ; else abortgo("msgffile.c", 116, "sgf_dumptree == ((void *)0)", 0);
  if (tree == ((void *)0))
    sgf_dumptree = &local_tree;
  else
    sgf_dumptree = tree;
  sgftree_clear(sgf_dumptree);
  sgftreeCreateHeaderNode(sgf_dumptree, board_size, komi, handicap);
  sgffile_printboard(sgf_dumptree);
}

canonical_original_code:
void sgffile_begindump(struct SGFTree_t *tree)
{
  static struct SGFTree_t local_tree;
  if (sgf_dumptree == ((void *)0)) ; else abortgo("msgffile.c", 116, "sgf_dumptree == ((void *)0)", 0);
  if (tree == ((void *)0))
    sgf_dumptree = &local_tree;
  else
    sgf_dumptree = tree;
  sgftree_clear(sgf_dumptree);
  sgftreeCreateHeaderNode(sgf_dumptree, board_size, komi, handicap);
  sgffile_printboard(sgf_dumptree);
}

variable_types: struct SGFTree_t { struct SGFNode_t { struct SGFProperty_t { struct SGFProperty_t *next; short name; char *value; } *props; struct SGFNode_t *parent; struct SGFNode_t *child; struct SGFNode_t *next; } *root; struct SGFNode_t *lastnode; }


decompiled_code:
__int64 __fastcall sgffile_recordboard(__int64 a1)
{
int v1; // er13
int i; // er12
__int64 j; // rbx
__int64 result; // rax

if ( a1 )
{
v1 = 21;
for ( i = 0; board_size > i; v1 += 20 )
{
for ( j = 0LL; board_size > (int)j; ++j )
{
if ( board[v1 + j] == 2 )
result = sgfAddStone(a1, 2LL, (unsigned int)i, (unsigned int)j);
}
++i;
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1)
{
int v1; // er13
int i; // er12
__int64 j; // rbx
__int64 result; // rax

if ( a1 )
{
v1 = 21;
for ( i = 0; board_size > i; v1 += 20 )
{
for ( j = 0LL; board_size > (int)j; ++j )
{
if ( board[v1 + j] == 2 )
result = sgfAddStone(a1, 2LL, (unsigned int)i, (unsigned int)j);
}
++i;
}
}
return result;
}

original_code:
void
sgffile_recordboard(SGFNode *node)
{
  int i, j;
  if (node)
    for (i = 0; i < board_size; i++)
      for (j = 0; j < board_size; j++)
        if (board[((19 + 2) + (i) * (19 + 1) + (j))] == BLACK)
          sgfAddStone(node, BLACK, i, j);
}

canonical_original_code:
void sgffile_recordboard(struct SGFNode_t *node)
{
  int i; int j;
  if (node)
    for (i = 0; i < board_size; i++)
      for (j = 0; j < board_size; j++)
        if (board[((19 + 2) + (i) * (19 + 1) + (j))] == BLACK)
          sgfAddStone(node, BLACK, i, j);
}

variable_types: struct SGFNode_t { struct SGFProperty_t { struct SGFProperty_t *next; short name; char *value; } *props; struct SGFNode_t *parent; struct SGFNode_t *child; struct SGFNode_t *next; } *


decompiled_code:
__int64 __fastcall get_sgfmove(__int64 a1)
{
int v1; // ebx

v1 = get_moveX(a1, board_size);
return (unsigned int)get_moveY(a1, board_size) + 20 * v1 + 21;
}

canonical_decompiled_code:
__int64 __fastcall func4(__int64 a1)
{
int v1; // ebx

v1 = get_moveX(a1, board_size);
return (unsigned int)get_moveY(a1, board_size) + 20 * v1 + 21;
}

original_code:
int
get_sgfmove(SGFProperty *property)
{
  return ((19 + 2) + (get_moveX(property, board_size)) * (19 + 1) + (get_moveY(property, board_size)));
}

canonical_original_code:
int get_sgfmove(struct SGFProperty_t *property)
{
  return ((19 + 2) + (get_moveX(property, board_size)) * (19 + 1) + (get_moveY(property, board_size)));
}

variable_types: struct SGFProperty_t { struct SGFProperty_t *next; short name; char *value; } *