decompiled_code:
__int64 __fastcall test_compare_and_swap(_DWORD *a1)
{
__int64 v1; // rax
__int64 v2; // rbx
__int64 v3; // rax
__int64 v4; // rbp

v1 = PICC_create_atomic_bool(0LL, a1);
if ( *a1 )
_assert_fail("!(*error).id > 0", "tests/atomic_test.c", 0x25u, "test_compare_and_swap");
v2 = v1;
if ( (unsigned __int8)PICC_atomic_bool_get(v1) )
_assert_fail("PICC_atomic_bool_get(abool) == 0", "tests/atomic_test.c", 0x26u, "test_compare_and_swap");
if ( (unsigned __int8)PICC_atomic_bool_compare_and_swap(v2, 0LL, 1LL) )
_assert_fail("bret == 0", "tests/atomic_test.c", 0x29u, "test_compare_and_swap");
if ( !(unsigned __int8)PICC_atomic_bool_get(v2) )
_assert_fail("PICC_atomic_bool_get(abool) == 1", "tests/atomic_test.c", 0x2Au, "test_compare_and_swap");
if ( !(unsigned __int8)PICC_atomic_bool_compare_and_swap(v2, 0LL, 0LL) )
_assert_fail("bret == 1", "tests/atomic_test.c", 0x2Du, "test_compare_and_swap");
if ( !(unsigned __int8)PICC_atomic_bool_get(v2) )
_assert_fail("PICC_atomic_bool_get(abool) == 1", "tests/atomic_test.c", 0x2Eu, "test_compare_and_swap");
if ( !(unsigned __int8)PICC_atomic_bool_compare_and_swap(v2, 1LL, 1LL) )
_assert_fail("bret == 1", "tests/atomic_test.c", 0x31u, "test_compare_and_swap");
if ( !(unsigned __int8)PICC_atomic_bool_get(v2) )
_assert_fail("PICC_atomic_bool_get(abool) == 1", "tests/atomic_test.c", 0x32u, "test_compare_and_swap");
v3 = PICC_create_atomic_int(0LL, a1);
v4 = v3;
if ( *a1 )
_assert_fail("!(*error).id > 0", "tests/atomic_test.c", 0x35u, "test_compare_and_swap");
if ( (unsigned int)PICC_atomic_int_get(v3) )
_assert_fail("PICC_atomic_int_get(aint) == 0", "tests/atomic_test.c", 0x36u, "test_compare_and_swap");
if ( (unsigned int)PICC_atomic_int_compare_and_swap(v4, 0LL, 2LL) )
_assert_fail("iret == 0", "tests/atomic_test.c", 0x39u, "test_compare_and_swap");
if ( (unsigned int)PICC_atomic_int_get(v4) != 2 )
_assert_fail("PICC_atomic_int_get(aint) == 2", "tests/atomic_test.c", 0x3Au, "test_compare_and_swap");
if ( (unsigned int)PICC_atomic_int_compare_and_swap(v4, 1LL, 3LL) != 2 )
_assert_fail("iret == 2", "tests/atomic_test.c", 0x3Du, "test_compare_and_swap");
if ( (unsigned int)PICC_atomic_int_get(v4) != 2 )
_assert_fail("PICC_atomic_int_get(aint) == 2", "tests/atomic_test.c", 0x3Eu, "test_compare_and_swap");
if ( (unsigned int)PICC_atomic_int_compare_and_swap(v4, 2LL, 2LL) != 2 )
_assert_fail("iret == 2", "tests/atomic_test.c", 0x41u, "test_compare_and_swap");
if ( (unsigned int)PICC_atomic_int_get(v4) != 2 )
_assert_fail("PICC_atomic_int_get(aint) == 2", "tests/atomic_test.c", 0x42u, "test_compare_and_swap");
PICC_free_atomic_bool(v2);
return PICC_free_atomic_int(v4);
}

canonical_decompiled_code:
__int64 __fastcall func1(_DWORD *a1)
{
__int64 v1; // rax
__int64 v2; // rbx
__int64 v3; // rax
__int64 v4; // rbp

v1 = PICC_create_atomic_bool(0LL, a1);
if ( *a1 )
_assert_fail("!(*error).id > 0", "tests/atomic_test.c", 0x25u, "test_compare_and_swap");
v2 = v1;
if ( (unsigned __int8)PICC_atomic_bool_get(v1) )
_assert_fail("PICC_atomic_bool_get(abool) == 0", "tests/atomic_test.c", 0x26u, "test_compare_and_swap");
if ( (unsigned __int8)PICC_atomic_bool_compare_and_swap(v2, 0LL, 1LL) )
_assert_fail("bret == 0", "tests/atomic_test.c", 0x29u, "test_compare_and_swap");
if ( !(unsigned __int8)PICC_atomic_bool_get(v2) )
_assert_fail("PICC_atomic_bool_get(abool) == 1", "tests/atomic_test.c", 0x2Au, "test_compare_and_swap");
if ( !(unsigned __int8)PICC_atomic_bool_compare_and_swap(v2, 0LL, 0LL) )
_assert_fail("bret == 1", "tests/atomic_test.c", 0x2Du, "test_compare_and_swap");
if ( !(unsigned __int8)PICC_atomic_bool_get(v2) )
_assert_fail("PICC_atomic_bool_get(abool) == 1", "tests/atomic_test.c", 0x2Eu, "test_compare_and_swap");
if ( !(unsigned __int8)PICC_atomic_bool_compare_and_swap(v2, 1LL, 1LL) )
_assert_fail("bret == 1", "tests/atomic_test.c", 0x31u, "test_compare_and_swap");
if ( !(unsigned __int8)PICC_atomic_bool_get(v2) )
_assert_fail("PICC_atomic_bool_get(abool) == 1", "tests/atomic_test.c", 0x32u, "test_compare_and_swap");
v3 = PICC_create_atomic_int(0LL, a1);
v4 = v3;
if ( *a1 )
_assert_fail("!(*error).id > 0", "tests/atomic_test.c", 0x35u, "test_compare_and_swap");
if ( (unsigned int)PICC_atomic_int_get(v3) )
_assert_fail("PICC_atomic_int_get(aint) == 0", "tests/atomic_test.c", 0x36u, "test_compare_and_swap");
if ( (unsigned int)PICC_atomic_int_compare_and_swap(v4, 0LL, 2LL) )
_assert_fail("iret == 0", "tests/atomic_test.c", 0x39u, "test_compare_and_swap");
if ( (unsigned int)PICC_atomic_int_get(v4) != 2 )
_assert_fail("PICC_atomic_int_get(aint) == 2", "tests/atomic_test.c", 0x3Au, "test_compare_and_swap");
if ( (unsigned int)PICC_atomic_int_compare_and_swap(v4, 1LL, 3LL) != 2 )
_assert_fail("iret == 2", "tests/atomic_test.c", 0x3Du, "test_compare_and_swap");
if ( (unsigned int)PICC_atomic_int_get(v4) != 2 )
_assert_fail("PICC_atomic_int_get(aint) == 2", "tests/atomic_test.c", 0x3Eu, "test_compare_and_swap");
if ( (unsigned int)PICC_atomic_int_compare_and_swap(v4, 2LL, 2LL) != 2 )
_assert_fail("iret == 2", "tests/atomic_test.c", 0x41u, "test_compare_and_swap");
if ( (unsigned int)PICC_atomic_int_get(v4) != 2 )
_assert_fail("PICC_atomic_int_get(aint) == 2", "tests/atomic_test.c", 0x42u, "test_compare_and_swap");
PICC_free_atomic_bool(v2);
return PICC_free_atomic_int(v4);
}

original_code:
void test_compare_and_swap(PICC_Error *error)
{
    _Bool bret;
    int iret;
    PICC_AtomicBoolean *abool = PICC_create_atomic_bool(0, error);
    ((!(*error).id > 0) ? (void) (0) : __assert_fail ("!(*error).id > 0", "tests/atomic_test.c", 37, __extension__ __PRETTY_FUNCTION__));;
    ((PICC_atomic_bool_get(abool) == 0) ? (void) (0) : __assert_fail ("PICC_atomic_bool_get(abool) == 0", "tests/atomic_test.c", 38, __extension__ __PRETTY_FUNCTION__));;
    bret = PICC_atomic_bool_compare_and_swap(abool, 0, 1);
    ((bret == 0) ? (void) (0) : __assert_fail ("bret == 0", "tests/atomic_test.c", 41, __extension__ __PRETTY_FUNCTION__));;
    ((PICC_atomic_bool_get(abool) == 1) ? (void) (0) : __assert_fail ("PICC_atomic_bool_get(abool) == 1", "tests/atomic_test.c", 42, __extension__ __PRETTY_FUNCTION__));;
    bret = PICC_atomic_bool_compare_and_swap(abool, 0, 0);
    ((bret == 1) ? (void) (0) : __assert_fail ("bret == 1", "tests/atomic_test.c", 45, __extension__ __PRETTY_FUNCTION__));;
    ((PICC_atomic_bool_get(abool) == 1) ? (void) (0) : __assert_fail ("PICC_atomic_bool_get(abool) == 1", "tests/atomic_test.c", 46, __extension__ __PRETTY_FUNCTION__));;
    bret = PICC_atomic_bool_compare_and_swap(abool, 1, 1);
    ((bret == 1) ? (void) (0) : __assert_fail ("bret == 1", "tests/atomic_test.c", 49, __extension__ __PRETTY_FUNCTION__));;
    ((PICC_atomic_bool_get(abool) == 1) ? (void) (0) : __assert_fail ("PICC_atomic_bool_get(abool) == 1", "tests/atomic_test.c", 50, __extension__ __PRETTY_FUNCTION__));;
    PICC_AtomicInt *aint = PICC_create_atomic_int(0, error);
    ((!(*error).id > 0) ? (void) (0) : __assert_fail ("!(*error).id > 0", "tests/atomic_test.c", 53, __extension__ __PRETTY_FUNCTION__));;
    ((PICC_atomic_int_get(aint) == 0) ? (void) (0) : __assert_fail ("PICC_atomic_int_get(aint) == 0", "tests/atomic_test.c", 54, __extension__ __PRETTY_FUNCTION__));;
    iret = PICC_atomic_int_compare_and_swap(aint, 0, 2);
    ((iret == 0) ? (void) (0) : __assert_fail ("iret == 0", "tests/atomic_test.c", 57, __extension__ __PRETTY_FUNCTION__));;
    ((PICC_atomic_int_get(aint) == 2) ? (void) (0) : __assert_fail ("PICC_atomic_int_get(aint) == 2", "tests/atomic_test.c", 58, __extension__ __PRETTY_FUNCTION__));;
    iret = PICC_atomic_int_compare_and_swap(aint, 1, 3);
    ((iret == 2) ? (void) (0) : __assert_fail ("iret == 2", "tests/atomic_test.c", 61, __extension__ __PRETTY_FUNCTION__));;
    ((PICC_atomic_int_get(aint) == 2) ? (void) (0) : __assert_fail ("PICC_atomic_int_get(aint) == 2", "tests/atomic_test.c", 62, __extension__ __PRETTY_FUNCTION__));;
    iret = PICC_atomic_int_compare_and_swap(aint, 2, 2);
    ((iret == 2) ? (void) (0) : __assert_fail ("iret == 2", "tests/atomic_test.c", 65, __extension__ __PRETTY_FUNCTION__));;
    ((PICC_atomic_int_get(aint) == 2) ? (void) (0) : __assert_fail ("PICC_atomic_int_get(aint) == 2", "tests/atomic_test.c", 66, __extension__ __PRETTY_FUNCTION__));;
    PICC_free_atomic_bool(abool);
    PICC_free_atomic_int(aint);
}

canonical_original_code:
void test_compare_and_swap(struct _PICC_Error *error)
{
    _Bool bret;
    int iret;
    struct _PICC_AtomicBoolean *abool = PICC_create_atomic_bool(0, error);
    ((!(*error).id > 0) ? (void) (0) : __assert_fail ("!(*error).id > 0", "tests/atomic_test.c", 37, __extension__ __PRETTY_FUNCTION__));;
    ((PICC_atomic_bool_get(abool) == 0) ? (void) (0) : __assert_fail ("PICC_atomic_bool_get(abool) == 0", "tests/atomic_test.c", 38, __extension__ __PRETTY_FUNCTION__));;
    bret = PICC_atomic_bool_compare_and_swap(abool, 0, 1);
    ((bret == 0) ? (void) (0) : __assert_fail ("bret == 0", "tests/atomic_test.c", 41, __extension__ __PRETTY_FUNCTION__));;
    ((PICC_atomic_bool_get(abool) == 1) ? (void) (0) : __assert_fail ("PICC_atomic_bool_get(abool) == 1", "tests/atomic_test.c", 42, __extension__ __PRETTY_FUNCTION__));;
    bret = PICC_atomic_bool_compare_and_swap(abool, 0, 0);
    ((bret == 1) ? (void) (0) : __assert_fail ("bret == 1", "tests/atomic_test.c", 45, __extension__ __PRETTY_FUNCTION__));;
    ((PICC_atomic_bool_get(abool) == 1) ? (void) (0) : __assert_fail ("PICC_atomic_bool_get(abool) == 1", "tests/atomic_test.c", 46, __extension__ __PRETTY_FUNCTION__));;
    bret = PICC_atomic_bool_compare_and_swap(abool, 1, 1);
    ((bret == 1) ? (void) (0) : __assert_fail ("bret == 1", "tests/atomic_test.c", 49, __extension__ __PRETTY_FUNCTION__));;
    ((PICC_atomic_bool_get(abool) == 1) ? (void) (0) : __assert_fail ("PICC_atomic_bool_get(abool) == 1", "tests/atomic_test.c", 50, __extension__ __PRETTY_FUNCTION__));;
    struct _PICC_AtomicInt *aint = PICC_create_atomic_int(0, error);
    ((!(*error).id > 0) ? (void) (0) : __assert_fail ("!(*error).id > 0", "tests/atomic_test.c", 53, __extension__ __PRETTY_FUNCTION__));;
    ((PICC_atomic_int_get(aint) == 0) ? (void) (0) : __assert_fail ("PICC_atomic_int_get(aint) == 0", "tests/atomic_test.c", 54, __extension__ __PRETTY_FUNCTION__));;
    iret = PICC_atomic_int_compare_and_swap(aint, 0, 2);
    ((iret == 0) ? (void) (0) : __assert_fail ("iret == 0", "tests/atomic_test.c", 57, __extension__ __PRETTY_FUNCTION__));;
    ((PICC_atomic_int_get(aint) == 2) ? (void) (0) : __assert_fail ("PICC_atomic_int_get(aint) == 2", "tests/atomic_test.c", 58, __extension__ __PRETTY_FUNCTION__));;
    iret = PICC_atomic_int_compare_and_swap(aint, 1, 3);
    ((iret == 2) ? (void) (0) : __assert_fail ("iret == 2", "tests/atomic_test.c", 61, __extension__ __PRETTY_FUNCTION__));;
    ((PICC_atomic_int_get(aint) == 2) ? (void) (0) : __assert_fail ("PICC_atomic_int_get(aint) == 2", "tests/atomic_test.c", 62, __extension__ __PRETTY_FUNCTION__));;
    iret = PICC_atomic_int_compare_and_swap(aint, 2, 2);
    ((iret == 2) ? (void) (0) : __assert_fail ("iret == 2", "tests/atomic_test.c", 65, __extension__ __PRETTY_FUNCTION__));;
    ((PICC_atomic_int_get(aint) == 2) ? (void) (0) : __assert_fail ("PICC_atomic_int_get(aint) == 2", "tests/atomic_test.c", 66, __extension__ __PRETTY_FUNCTION__));;
    PICC_free_atomic_bool(abool);
    PICC_free_atomic_int(aint);
}

variable_types: iret int


repo: fredokun/libpiccolort

decompiled_code:
__int64 __fastcall test_compare_and_swap_check(_DWORD *a1)
{
__int64 v1; // rax
__int64 v2; // rbx
__int64 v3; // rax
__int64 v4; // rbp

v1 = PICC_create_atomic_bool(0LL, a1);
if ( *a1 )
_assert_fail("!(*error).id > 0", "tests/atomic_test.c", 0x4Du, "test_compare_and_swap_check");
v2 = v1;
if ( (unsigned __int8)PICC_atomic_bool_get(v1) )
_assert_fail("PICC_atomic_bool_get(abool) == 0", "tests/atomic_test.c", 0x4Eu, "test_compare_and_swap_check");
if ( !(unsigned __int8)PICC_atomic_bool_compare_and_swap_check(v2, 0LL, 1LL) )
_assert_fail("ret == 1", "tests/atomic_test.c", 0x51u, "test_compare_and_swap_check");
if ( !(unsigned __int8)PICC_atomic_bool_get(v2) )
_assert_fail("PICC_atomic_bool_get(abool) == 1", "tests/atomic_test.c", 0x52u, "test_compare_and_swap_check");
if ( (unsigned __int8)PICC_atomic_bool_compare_and_swap_check(v2, 0LL, 0LL) )
_assert_fail("ret == 0", "tests/atomic_test.c", 0x55u, "test_compare_and_swap_check");
if ( !(unsigned __int8)PICC_atomic_bool_get(v2) )
_assert_fail("PICC_atomic_bool_get(abool) == 1", "tests/atomic_test.c", 0x56u, "test_compare_and_swap_check");
if ( !(unsigned __int8)PICC_atomic_bool_compare_and_swap_check(v2, 1LL, 1LL) )
_assert_fail("ret == 1", "tests/atomic_test.c", 0x59u, "test_compare_and_swap_check");
if ( !(unsigned __int8)PICC_atomic_bool_get(v2) )
_assert_fail("PICC_atomic_bool_get(abool) == 1", "tests/atomic_test.c", 0x5Au, "test_compare_and_swap_check");
v3 = PICC_create_atomic_int(0LL, a1);
v4 = v3;
if ( *a1 )
_assert_fail("!(*error).id > 0", "tests/atomic_test.c", 0x5Du, "test_compare_and_swap_check");
if ( (unsigned int)PICC_atomic_int_get(v3) )
_assert_fail("PICC_atomic_int_get(aint) == 0", "tests/atomic_test.c", 0x5Eu, "test_compare_and_swap_check");
if ( !(unsigned __int8)PICC_atomic_int_compare_and_swap_check(v4, 0LL, 2LL) )
_assert_fail("ret == 1", "tests/atomic_test.c", 0x61u, "test_compare_and_swap_check");
if ( (unsigned int)PICC_atomic_int_get(v4) != 2 )
_assert_fail("PICC_atomic_int_get(aint) == 2", "tests/atomic_test.c", 0x62u, "test_compare_and_swap_check");
if ( (unsigned __int8)PICC_atomic_int_compare_and_swap_check(v4, 1LL, 3LL) )
_assert_fail("ret == 0", "tests/atomic_test.c", 0x65u, "test_compare_and_swap_check");
if ( (unsigned int)PICC_atomic_int_get(v4) != 2 )
_assert_fail("PICC_atomic_int_get(aint) == 2", "tests/atomic_test.c", 0x66u, "test_compare_and_swap_check");
if ( !(unsigned __int8)PICC_atomic_int_compare_and_swap_check(v4, 2LL, 2LL) )
_assert_fail("ret == 1", "tests/atomic_test.c", 0x69u, "test_compare_and_swap_check");
if ( (unsigned int)PICC_atomic_int_get(v4) != 2 )
_assert_fail("PICC_atomic_int_get(aint) == 2", "tests/atomic_test.c", 0x6Au, "test_compare_and_swap_check");
PICC_free_atomic_bool(v2);
return PICC_free_atomic_int(v4);
}

canonical_decompiled_code:
__int64 __fastcall func2(_DWORD *a1)
{
__int64 v1; // rax
__int64 v2; // rbx
__int64 v3; // rax
__int64 v4; // rbp

v1 = PICC_create_atomic_bool(0LL, a1);
if ( *a1 )
_assert_fail("!(*error).id > 0", "tests/atomic_test.c", 0x4Du, "test_compare_and_swap_check");
v2 = v1;
if ( (unsigned __int8)PICC_atomic_bool_get(v1) )
_assert_fail("PICC_atomic_bool_get(abool) == 0", "tests/atomic_test.c", 0x4Eu, "test_compare_and_swap_check");
if ( !(unsigned __int8)PICC_atomic_bool_compare_and_swap_check(v2, 0LL, 1LL) )
_assert_fail("ret == 1", "tests/atomic_test.c", 0x51u, "test_compare_and_swap_check");
if ( !(unsigned __int8)PICC_atomic_bool_get(v2) )
_assert_fail("PICC_atomic_bool_get(abool) == 1", "tests/atomic_test.c", 0x52u, "test_compare_and_swap_check");
if ( (unsigned __int8)PICC_atomic_bool_compare_and_swap_check(v2, 0LL, 0LL) )
_assert_fail("ret == 0", "tests/atomic_test.c", 0x55u, "test_compare_and_swap_check");
if ( !(unsigned __int8)PICC_atomic_bool_get(v2) )
_assert_fail("PICC_atomic_bool_get(abool) == 1", "tests/atomic_test.c", 0x56u, "test_compare_and_swap_check");
if ( !(unsigned __int8)PICC_atomic_bool_compare_and_swap_check(v2, 1LL, 1LL) )
_assert_fail("ret == 1", "tests/atomic_test.c", 0x59u, "test_compare_and_swap_check");
if ( !(unsigned __int8)PICC_atomic_bool_get(v2) )
_assert_fail("PICC_atomic_bool_get(abool) == 1", "tests/atomic_test.c", 0x5Au, "test_compare_and_swap_check");
v3 = PICC_create_atomic_int(0LL, a1);
v4 = v3;
if ( *a1 )
_assert_fail("!(*error).id > 0", "tests/atomic_test.c", 0x5Du, "test_compare_and_swap_check");
if ( (unsigned int)PICC_atomic_int_get(v3) )
_assert_fail("PICC_atomic_int_get(aint) == 0", "tests/atomic_test.c", 0x5Eu, "test_compare_and_swap_check");
if ( !(unsigned __int8)PICC_atomic_int_compare_and_swap_check(v4, 0LL, 2LL) )
_assert_fail("ret == 1", "tests/atomic_test.c", 0x61u, "test_compare_and_swap_check");
if ( (unsigned int)PICC_atomic_int_get(v4) != 2 )
_assert_fail("PICC_atomic_int_get(aint) == 2", "tests/atomic_test.c", 0x62u, "test_compare_and_swap_check");
if ( (unsigned __int8)PICC_atomic_int_compare_and_swap_check(v4, 1LL, 3LL) )
_assert_fail("ret == 0", "tests/atomic_test.c", 0x65u, "test_compare_and_swap_check");
if ( (unsigned int)PICC_atomic_int_get(v4) != 2 )
_assert_fail("PICC_atomic_int_get(aint) == 2", "tests/atomic_test.c", 0x66u, "test_compare_and_swap_check");
if ( !(unsigned __int8)PICC_atomic_int_compare_and_swap_check(v4, 2LL, 2LL) )
_assert_fail("ret == 1", "tests/atomic_test.c", 0x69u, "test_compare_and_swap_check");
if ( (unsigned int)PICC_atomic_int_get(v4) != 2 )
_assert_fail("PICC_atomic_int_get(aint) == 2", "tests/atomic_test.c", 0x6Au, "test_compare_and_swap_check");
PICC_free_atomic_bool(v2);
return PICC_free_atomic_int(v4);
}

original_code:
void test_compare_and_swap_check(PICC_Error *error)
{
    _Bool ret;
    PICC_AtomicBoolean *abool = PICC_create_atomic_bool(0, error);
    ((!(*error).id > 0) ? (void) (0) : __assert_fail ("!(*error).id > 0", "tests/atomic_test.c", 77, __extension__ __PRETTY_FUNCTION__));;
    ((PICC_atomic_bool_get(abool) == 0) ? (void) (0) : __assert_fail ("PICC_atomic_bool_get(abool) == 0", "tests/atomic_test.c", 78, __extension__ __PRETTY_FUNCTION__));;
    ret = PICC_atomic_bool_compare_and_swap_check(abool, 0, 1);
    ((ret == 1) ? (void) (0) : __assert_fail ("ret == 1", "tests/atomic_test.c", 81, __extension__ __PRETTY_FUNCTION__));;
    ((PICC_atomic_bool_get(abool) == 1) ? (void) (0) : __assert_fail ("PICC_atomic_bool_get(abool) == 1", "tests/atomic_test.c", 82, __extension__ __PRETTY_FUNCTION__));;
    ret = PICC_atomic_bool_compare_and_swap_check(abool, 0, 0);
    ((ret == 0) ? (void) (0) : __assert_fail ("ret == 0", "tests/atomic_test.c", 85, __extension__ __PRETTY_FUNCTION__));;
    ((PICC_atomic_bool_get(abool) == 1) ? (void) (0) : __assert_fail ("PICC_atomic_bool_get(abool) == 1", "tests/atomic_test.c", 86, __extension__ __PRETTY_FUNCTION__));;
    ret = PICC_atomic_bool_compare_and_swap_check(abool, 1, 1);
    ((ret == 1) ? (void) (0) : __assert_fail ("ret == 1", "tests/atomic_test.c", 89, __extension__ __PRETTY_FUNCTION__));;
    ((PICC_atomic_bool_get(abool) == 1) ? (void) (0) : __assert_fail ("PICC_atomic_bool_get(abool) == 1", "tests/atomic_test.c", 90, __extension__ __PRETTY_FUNCTION__));;
    PICC_AtomicInt *aint = PICC_create_atomic_int(0, error);
    ((!(*error).id > 0) ? (void) (0) : __assert_fail ("!(*error).id > 0", "tests/atomic_test.c", 93, __extension__ __PRETTY_FUNCTION__));;
    ((PICC_atomic_int_get(aint) == 0) ? (void) (0) : __assert_fail ("PICC_atomic_int_get(aint) == 0", "tests/atomic_test.c", 94, __extension__ __PRETTY_FUNCTION__));;
    ret = PICC_atomic_int_compare_and_swap_check(aint, 0, 2);
    ((ret == 1) ? (void) (0) : __assert_fail ("ret == 1", "tests/atomic_test.c", 97, __extension__ __PRETTY_FUNCTION__));;
    ((PICC_atomic_int_get(aint) == 2) ? (void) (0) : __assert_fail ("PICC_atomic_int_get(aint) == 2", "tests/atomic_test.c", 98, __extension__ __PRETTY_FUNCTION__));;
    ret = PICC_atomic_int_compare_and_swap_check(aint, 1, 3);
    ((ret == 0) ? (void) (0) : __assert_fail ("ret == 0", "tests/atomic_test.c", 101, __extension__ __PRETTY_FUNCTION__));;
    ((PICC_atomic_int_get(aint) == 2) ? (void) (0) : __assert_fail ("PICC_atomic_int_get(aint) == 2", "tests/atomic_test.c", 102, __extension__ __PRETTY_FUNCTION__));;
    ret = PICC_atomic_int_compare_and_swap_check(aint, 2, 2);
    ((ret == 1) ? (void) (0) : __assert_fail ("ret == 1", "tests/atomic_test.c", 105, __extension__ __PRETTY_FUNCTION__));;
    ((PICC_atomic_int_get(aint) == 2) ? (void) (0) : __assert_fail ("PICC_atomic_int_get(aint) == 2", "tests/atomic_test.c", 106, __extension__ __PRETTY_FUNCTION__));;
    PICC_free_atomic_bool(abool);
    PICC_free_atomic_int(aint);
}

canonical_original_code:
void test_compare_and_swap_check(struct _PICC_Error *error)
{
    _Bool ret;
    struct _PICC_AtomicBoolean *abool = PICC_create_atomic_bool(0, error);
    ((!(*error).id > 0) ? (void) (0) : __assert_fail ("!(*error).id > 0", "tests/atomic_test.c", 77, __extension__ __PRETTY_FUNCTION__));;
    ((PICC_atomic_bool_get(abool) == 0) ? (void) (0) : __assert_fail ("PICC_atomic_bool_get(abool) == 0", "tests/atomic_test.c", 78, __extension__ __PRETTY_FUNCTION__));;
    ret = PICC_atomic_bool_compare_and_swap_check(abool, 0, 1);
    ((ret == 1) ? (void) (0) : __assert_fail ("ret == 1", "tests/atomic_test.c", 81, __extension__ __PRETTY_FUNCTION__));;
    ((PICC_atomic_bool_get(abool) == 1) ? (void) (0) : __assert_fail ("PICC_atomic_bool_get(abool) == 1", "tests/atomic_test.c", 82, __extension__ __PRETTY_FUNCTION__));;
    ret = PICC_atomic_bool_compare_and_swap_check(abool, 0, 0);
    ((ret == 0) ? (void) (0) : __assert_fail ("ret == 0", "tests/atomic_test.c", 85, __extension__ __PRETTY_FUNCTION__));;
    ((PICC_atomic_bool_get(abool) == 1) ? (void) (0) : __assert_fail ("PICC_atomic_bool_get(abool) == 1", "tests/atomic_test.c", 86, __extension__ __PRETTY_FUNCTION__));;
    ret = PICC_atomic_bool_compare_and_swap_check(abool, 1, 1);
    ((ret == 1) ? (void) (0) : __assert_fail ("ret == 1", "tests/atomic_test.c", 89, __extension__ __PRETTY_FUNCTION__));;
    ((PICC_atomic_bool_get(abool) == 1) ? (void) (0) : __assert_fail ("PICC_atomic_bool_get(abool) == 1", "tests/atomic_test.c", 90, __extension__ __PRETTY_FUNCTION__));;
    struct _PICC_AtomicInt *aint = PICC_create_atomic_int(0, error);
    ((!(*error).id > 0) ? (void) (0) : __assert_fail ("!(*error).id > 0", "tests/atomic_test.c", 93, __extension__ __PRETTY_FUNCTION__));;
    ((PICC_atomic_int_get(aint) == 0) ? (void) (0) : __assert_fail ("PICC_atomic_int_get(aint) == 0", "tests/atomic_test.c", 94, __extension__ __PRETTY_FUNCTION__));;
    ret = PICC_atomic_int_compare_and_swap_check(aint, 0, 2);
    ((ret == 1) ? (void) (0) : __assert_fail ("ret == 1", "tests/atomic_test.c", 97, __extension__ __PRETTY_FUNCTION__));;
    ((PICC_atomic_int_get(aint) == 2) ? (void) (0) : __assert_fail ("PICC_atomic_int_get(aint) == 2", "tests/atomic_test.c", 98, __extension__ __PRETTY_FUNCTION__));;
    ret = PICC_atomic_int_compare_and_swap_check(aint, 1, 3);
    ((ret == 0) ? (void) (0) : __assert_fail ("ret == 0", "tests/atomic_test.c", 101, __extension__ __PRETTY_FUNCTION__));;
    ((PICC_atomic_int_get(aint) == 2) ? (void) (0) : __assert_fail ("PICC_atomic_int_get(aint) == 2", "tests/atomic_test.c", 102, __extension__ __PRETTY_FUNCTION__));;
    ret = PICC_atomic_int_compare_and_swap_check(aint, 2, 2);
    ((ret == 1) ? (void) (0) : __assert_fail ("ret == 1", "tests/atomic_test.c", 105, __extension__ __PRETTY_FUNCTION__));;
    ((PICC_atomic_int_get(aint) == 2) ? (void) (0) : __assert_fail ("PICC_atomic_int_get(aint) == 2", "tests/atomic_test.c", 106, __extension__ __PRETTY_FUNCTION__));;
    PICC_free_atomic_bool(abool);
    PICC_free_atomic_int(aint);
}

variable_types: struct _PICC_Error { enum _PICC_ErrorId { ERR_DEAD_CODE_REACHED=0, ERR_DEADLOCK=1, ERR_ALLOC_QUEUE_CELL=2, ERR_READY_QUEUE_PUSH=3, ERR_READY_QUEUE_ADD=4, ERR_WAIT_QUEUE_PUSH=5, ERR_WAIT_QUEUE_ADD=6, ERR_WAIT_QUEUE_PUSH_OLD=7, ERR_NOT_IMPLEMENTED=8, ERR_OUT_OF_MEMORY=9, ERR_COMMIT_CREATE=10, ERR_ADD_COMMIT_TO_LIST=11, ERR_REGISTER_OUT_COMMIT=12, ERR_REGISTER_IN_COMMIT=13, ERR_THREAD_CREATE=14, ERR_THREAD_YIELD=15, ERR_PTHREAD_CREATE=16, ERR_SCHED_POOL_CREATE=17, ERR_CLOCK_CREATE=18, ERR_MUTEX_ALREADY_UNLOCKED=19, ERR_CONDITION_SIGNAL=20, ERR_CONDITION_BROADCAST=21, ERR_NULLPOINTER_PITHREAD=22, ERR_NULLPOINTER_CHANNEL=23, ERR_NULLPOINTER_COMMIT=24, ERR_NULLPOINTER_COMMITLISTELEM=25, ERR_NULLPOINTER_COMMITLIST=26, ERR_CHANNEL_GLOBAL_RC=27, ERR_INVALID_COMMIT=28, ERR_INVALID_VALUE=29, ERR_INVALID_TYPE=30, ERR_INVALID_KNOWNSET_STATE=31 } id; char *file; int line; struct _PICC_Error *prev; } *

variable_types: struct _PICC_AtomicBoolean { _Bool val; union pthread_mutex_t { struct __pthread_mutex_s { int __lock; unsigned int __count; int __owner; unsigned int __nusers; int __kind; short __spins; short __elision; struct __pthread_internal_list { struct __pthread_internal_list *__prev; struct __pthread_internal_list *__next; } __list; } __data; char __size[40]; long __align; } lock; } *

variable_types: struct _PICC_AtomicInt { int val; union pthread_mutex_t { struct __pthread_mutex_s { int __lock; unsigned int __count; int __owner; unsigned int __nusers; int __kind; short __spins; short __elision; struct __pthread_internal_list { struct __pthread_internal_list *__prev; struct __pthread_internal_list *__next; } __list; } __data; char __size[40]; long __align; } lock; } *

return_type: void

user_defined_types: struct _PICC_Error { enum _PICC_ErrorId id; char *file; int line; struct _PICC_Error *prev; }

user_defined_types: struct _PICC_AtomicBoolean { _Bool val; union pthread_mutex_t lock; }

user_defined_types: struct _PICC_AtomicInt { int val; union pthread_mutex_t lock; }

user_defined_types: union pthread_mutex_t { struct __pthread_mutex_s __data; char __size[40]; long __align; }

user_defined_types: struct __pthread_mutex_s { int __lock; unsigned int __count; int __owner; unsigned int __nusers; int __kind; short __spins; short __elision; struct __pthread_internal_list __list; }


decompiled_code:
__int64 __fastcall test_get_and_set(_DWORD *a1)
{
__int64 v1; // rax
__int64 v2; // rbp
__int64 v3; // r12
__int64 result; // rax

v1 = PICC_create_atomic_bool(0LL, a1);
if ( *a1 )
_assert_fail("!(*error).id > 0", "tests/atomic_test.c", 0x74u, "test_get_and_set");
v2 = v1;
v3 = PICC_create_atomic_int(0LL, a1);
if ( *a1 )
_assert_fail("!(*error).id > 0", "tests/atomic_test.c", 0x76u, "test_get_and_set");
if ( (unsigned __int8)PICC_atomic_bool_get_and_set(v2, 1LL) )
_assert_fail("PICC_atomic_bool_get_and_set(abool, 1) == 0", "tests/atomic_test.c", 0x78u, "test_get_and_set");
if ( !(unsigned __int8)PICC_atomic_bool_get(v2) )
_assert_fail("PICC_atomic_bool_get(abool) == 1", "tests/atomic_test.c", 0x79u, "test_get_and_set");
if ( (unsigned int)PICC_atomic_int_get_and_set(v3, 3LL) )
_assert_fail("PICC_atomic_int_get_and_set(aint, 3) == 0", "tests/atomic_test.c", 0x7Bu, "test_get_and_set");
result = PICC_atomic_int_get(v3);
if ( (_DWORD)result != 3 )
_assert_fail("PICC_atomic_int_get(aint) == 3", "tests/atomic_test.c", 0x7Cu, "test_get_and_set");
return result;
}

canonical_decompiled_code:
__int64 __fastcall func3(_DWORD *a1)
{
__int64 v1; // rax
__int64 v2; // rbp
__int64 v3; // r12
__int64 result; // rax

v1 = PICC_create_atomic_bool(0LL, a1);
if ( *a1 )
_assert_fail("!(*error).id > 0", "tests/atomic_test.c", 0x74u, "test_get_and_set");
v2 = v1;
v3 = PICC_create_atomic_int(0LL, a1);
if ( *a1 )
_assert_fail("!(*error).id > 0", "tests/atomic_test.c", 0x76u, "test_get_and_set");
if ( (unsigned __int8)PICC_atomic_bool_get_and_set(v2, 1LL) )
_assert_fail("PICC_atomic_bool_get_and_set(abool, 1) == 0", "tests/atomic_test.c", 0x78u, "test_get_and_set");
if ( !(unsigned __int8)PICC_atomic_bool_get(v2) )
_assert_fail("PICC_atomic_bool_get(abool) == 1", "tests/atomic_test.c", 0x79u, "test_get_and_set");
if ( (unsigned int)PICC_atomic_int_get_and_set(v3, 3LL) )
_assert_fail("PICC_atomic_int_get_and_set(aint, 3) == 0", "tests/atomic_test.c", 0x7Bu, "test_get_and_set");
result = PICC_atomic_int_get(v3);
if ( (_DWORD)result != 3 )
_assert_fail("PICC_atomic_int_get(aint) == 3", "tests/atomic_test.c", 0x7Cu, "test_get_and_set");
return result;
}

original_code:
void test_get_and_set(PICC_Error *error)
{
    PICC_AtomicBoolean *abool = PICC_create_atomic_bool(0, error);
    ((!(*error).id > 0) ? (void) (0) : __assert_fail ("!(*error).id > 0", "tests/atomic_test.c", 116, __extension__ __PRETTY_FUNCTION__));;
    PICC_AtomicInt *aint = PICC_create_atomic_int(0, error);
    ((!(*error).id > 0) ? (void) (0) : __assert_fail ("!(*error).id > 0", "tests/atomic_test.c", 118, __extension__ __PRETTY_FUNCTION__));;
    ((PICC_atomic_bool_get_and_set(abool, 1) == 0) ? (void) (0) : __assert_fail ("PICC_atomic_bool_get_and_set(abool, 1) == 0", "tests/atomic_test.c", 120, __extension__ __PRETTY_FUNCTION__));;
    ((PICC_atomic_bool_get(abool) == 1) ? (void) (0) : __assert_fail ("PICC_atomic_bool_get(abool) == 1", "tests/atomic_test.c", 121, __extension__ __PRETTY_FUNCTION__));;
    ((PICC_atomic_int_get_and_set(aint, 3) == 0) ? (void) (0) : __assert_fail ("PICC_atomic_int_get_and_set(aint, 3) == 0", "tests/atomic_test.c", 123, __extension__ __PRETTY_FUNCTION__));;
    ((PICC_atomic_int_get(aint) == 3) ? (void) (0) : __assert_fail ("PICC_atomic_int_get(aint) == 3", "tests/atomic_test.c", 124, __extension__ __PRETTY_FUNCTION__));;
}

canonical_original_code:
void test_get_and_set(struct _PICC_Error *error)
{
    struct _PICC_AtomicBoolean *abool = PICC_create_atomic_bool(0, error);
    ((!(*error).id > 0) ? (void) (0) : __assert_fail ("!(*error).id > 0", "tests/atomic_test.c", 116, __extension__ __PRETTY_FUNCTION__));;
    struct _PICC_AtomicInt *aint = PICC_create_atomic_int(0, error);
    ((!(*error).id > 0) ? (void) (0) : __assert_fail ("!(*error).id > 0", "tests/atomic_test.c", 118, __extension__ __PRETTY_FUNCTION__));;
    ((PICC_atomic_bool_get_and_set(abool, 1) == 0) ? (void) (0) : __assert_fail ("PICC_atomic_bool_get_and_set(abool, 1) == 0", "tests/atomic_test.c", 120, __extension__ __PRETTY_FUNCTION__));;
    ((PICC_atomic_bool_get(abool) == 1) ? (void) (0) : __assert_fail ("PICC_atomic_bool_get(abool) == 1", "tests/atomic_test.c", 121, __extension__ __PRETTY_FUNCTION__));;
    ((PICC_atomic_int_get_and_set(aint, 3) == 0) ? (void) (0) : __assert_fail ("PICC_atomic_int_get_and_set(aint, 3) == 0", "tests/atomic_test.c", 123, __extension__ __PRETTY_FUNCTION__));;
    ((PICC_atomic_int_get(aint) == 3) ? (void) (0) : __assert_fail ("PICC_atomic_int_get(aint) == 3", "tests/atomic_test.c", 124, __extension__ __PRETTY_FUNCTION__));;
}

user_defined_types: enum _PICC_ErrorId { ERR_DEAD_CODE_REACHED=0, ERR_DEADLOCK=1, ERR_ALLOC_QUEUE_CELL=2, ERR_READY_QUEUE_PUSH=3, ERR_READY_QUEUE_ADD=4, ERR_WAIT_QUEUE_PUSH=5, ERR_WAIT_QUEUE_ADD=6, ERR_WAIT_QUEUE_PUSH_OLD=7, ERR_NOT_IMPLEMENTED=8, ERR_OUT_OF_MEMORY=9, ERR_COMMIT_CREATE=10, ERR_ADD_COMMIT_TO_LIST=11, ERR_REGISTER_OUT_COMMIT=12, ERR_REGISTER_IN_COMMIT=13, ERR_THREAD_CREATE=14, ERR_THREAD_YIELD=15, ERR_PTHREAD_CREATE=16, ERR_SCHED_POOL_CREATE=17, ERR_CLOCK_CREATE=18, ERR_MUTEX_ALREADY_UNLOCKED=19, ERR_CONDITION_SIGNAL=20, ERR_CONDITION_BROADCAST=21, ERR_NULLPOINTER_PITHREAD=22, ERR_NULLPOINTER_CHANNEL=23, ERR_NULLPOINTER_COMMIT=24, ERR_NULLPOINTER_COMMITLISTELEM=25, ERR_NULLPOINTER_COMMITLIST=26, ERR_CHANNEL_GLOBAL_RC=27, ERR_INVALID_COMMIT=28, ERR_INVALID_VALUE=29, ERR_INVALID_TYPE=30, ERR_INVALID_KNOWNSET_STATE=31 }

user_defined_types: struct __pthread_internal_list { struct __pthread_internal_list *__prev; struct __pthread_internal_list *__next; }


decompiled_code:
__int64 __fastcall test_increment_and_decrement(_DWORD *a1)
{
__int64 v1; // rax
__int64 v2; // rbx
__int64 result; // rax

v1 = PICC_create_atomic_int(0LL, a1);
if ( *a1 )
_assert_fail("!(*error).id > 0", "tests/atomic_test.c", 0x82u, "test_increment_and_decrement");
v2 = v1;
if ( (unsigned int)PICC_atomic_int_get_and_increment(v1) )
_assert_fail(
"PICC_atomic_int_get_and_increment(aint) == 0",
"tests/atomic_test.c",
0x84u,
"test_increment_and_decrement");
if ( (unsigned int)PICC_atomic_int_get(v2) != 1 )
_assert_fail("PICC_atomic_int_get(aint) == 1", "tests/atomic_test.c", 0x85u, "test_increment_and_decrement");
if ( (unsigned int)PICC_atomic_int_get_and_increment(v2) != 1 )
_assert_fail(
"PICC_atomic_int_get_and_increment(aint) == 1",
"tests/atomic_test.c",
0x86u,
"test_increment_and_decrement");
if ( (unsigned int)PICC_atomic_int_get(v2) != 2 )
_assert_fail("PICC_atomic_int_get(aint) == 2", "tests/atomic_test.c", 0x87u, "test_increment_and_decrement");
if ( (unsigned int)PICC_atomic_int_get_and_decrement(v2) != 2 )
_assert_fail(
"PICC_atomic_int_get_and_decrement(aint) == 2",
"tests/atomic_test.c",
0x88u,
"test_increment_and_decrement");
if ( (unsigned int)PICC_atomic_int_get(v2) != 1 )
_assert_fail("PICC_atomic_int_get(aint) == 1", "tests/atomic_test.c", 0x89u, "test_increment_and_decrement");
if ( (unsigned int)PICC_atomic_int_get_and_decrement(v2) != 1 )
_assert_fail(
"PICC_atomic_int_get_and_decrement(aint) == 1",
"tests/atomic_test.c",
0x8Au,
"test_increment_and_decrement");
result = PICC_atomic_int_get(v2);
if ( (_DWORD)result )
_assert_fail("PICC_atomic_int_get(aint) == 0", "tests/atomic_test.c", 0x8Bu, "test_increment_and_decrement");
return result;
}

canonical_decompiled_code:
__int64 __fastcall func4(_DWORD *a1)
{
__int64 v1; // rax
__int64 v2; // rbx
__int64 result; // rax

v1 = PICC_create_atomic_int(0LL, a1);
if ( *a1 )
_assert_fail("!(*error).id > 0", "tests/atomic_test.c", 0x82u, "test_increment_and_decrement");
v2 = v1;
if ( (unsigned int)PICC_atomic_int_get_and_increment(v1) )
_assert_fail(
"PICC_atomic_int_get_and_increment(aint) == 0",
"tests/atomic_test.c",
0x84u,
"test_increment_and_decrement");
if ( (unsigned int)PICC_atomic_int_get(v2) != 1 )
_assert_fail("PICC_atomic_int_get(aint) == 1", "tests/atomic_test.c", 0x85u, "test_increment_and_decrement");
if ( (unsigned int)PICC_atomic_int_get_and_increment(v2) != 1 )
_assert_fail(
"PICC_atomic_int_get_and_increment(aint) == 1",
"tests/atomic_test.c",
0x86u,
"test_increment_and_decrement");
if ( (unsigned int)PICC_atomic_int_get(v2) != 2 )
_assert_fail("PICC_atomic_int_get(aint) == 2", "tests/atomic_test.c", 0x87u, "test_increment_and_decrement");
if ( (unsigned int)PICC_atomic_int_get_and_decrement(v2) != 2 )
_assert_fail(
"PICC_atomic_int_get_and_decrement(aint) == 2",
"tests/atomic_test.c",
0x88u,
"test_increment_and_decrement");
if ( (unsigned int)PICC_atomic_int_get(v2) != 1 )
_assert_fail("PICC_atomic_int_get(aint) == 1", "tests/atomic_test.c", 0x89u, "test_increment_and_decrement");
if ( (unsigned int)PICC_atomic_int_get_and_decrement(v2) != 1 )
_assert_fail(
"PICC_atomic_int_get_and_decrement(aint) == 1",
"tests/atomic_test.c",
0x8Au,
"test_increment_and_decrement");
result = PICC_atomic_int_get(v2);
if ( (_DWORD)result )
_assert_fail("PICC_atomic_int_get(aint) == 0", "tests/atomic_test.c", 0x8Bu, "test_increment_and_decrement");
return result;
}

original_code:
void test_increment_and_decrement(PICC_Error *error)
{
    PICC_AtomicInt *aint = PICC_create_atomic_int(0, error);
    ((!(*error).id > 0) ? (void) (0) : __assert_fail ("!(*error).id > 0", "tests/atomic_test.c", 130, __extension__ __PRETTY_FUNCTION__));;
    ((PICC_atomic_int_get_and_increment(aint) == 0) ? (void) (0) : __assert_fail ("PICC_atomic_int_get_and_increment(aint) == 0", "tests/atomic_test.c", 132, __extension__ __PRETTY_FUNCTION__));;
    ((PICC_atomic_int_get(aint) == 1) ? (void) (0) : __assert_fail ("PICC_atomic_int_get(aint) == 1", "tests/atomic_test.c", 133, __extension__ __PRETTY_FUNCTION__));;
    ((PICC_atomic_int_get_and_increment(aint) == 1) ? (void) (0) : __assert_fail ("PICC_atomic_int_get_and_increment(aint) == 1", "tests/atomic_test.c", 134, __extension__ __PRETTY_FUNCTION__));;
    ((PICC_atomic_int_get(aint) == 2) ? (void) (0) : __assert_fail ("PICC_atomic_int_get(aint) == 2", "tests/atomic_test.c", 135, __extension__ __PRETTY_FUNCTION__));;
    ((PICC_atomic_int_get_and_decrement(aint) == 2) ? (void) (0) : __assert_fail ("PICC_atomic_int_get_and_decrement(aint) == 2", "tests/atomic_test.c", 136, __extension__ __PRETTY_FUNCTION__));;
    ((PICC_atomic_int_get(aint) == 1) ? (void) (0) : __assert_fail ("PICC_atomic_int_get(aint) == 1", "tests/atomic_test.c", 137, __extension__ __PRETTY_FUNCTION__));;
    ((PICC_atomic_int_get_and_decrement(aint) == 1) ? (void) (0) : __assert_fail ("PICC_atomic_int_get_and_decrement(aint) == 1", "tests/atomic_test.c", 138, __extension__ __PRETTY_FUNCTION__));;
    ((PICC_atomic_int_get(aint) == 0) ? (void) (0) : __assert_fail ("PICC_atomic_int_get(aint) == 0", "tests/atomic_test.c", 139, __extension__ __PRETTY_FUNCTION__));;
}

canonical_original_code:
void test_increment_and_decrement(struct _PICC_Error *error)
{
    struct _PICC_AtomicInt *aint = PICC_create_atomic_int(0, error);
    ((!(*error).id > 0) ? (void) (0) : __assert_fail ("!(*error).id > 0", "tests/atomic_test.c", 130, __extension__ __PRETTY_FUNCTION__));;
    ((PICC_atomic_int_get_and_increment(aint) == 0) ? (void) (0) : __assert_fail ("PICC_atomic_int_get_and_increment(aint) == 0", "tests/atomic_test.c", 132, __extension__ __PRETTY_FUNCTION__));;
    ((PICC_atomic_int_get(aint) == 1) ? (void) (0) : __assert_fail ("PICC_atomic_int_get(aint) == 1", "tests/atomic_test.c", 133, __extension__ __PRETTY_FUNCTION__));;
    ((PICC_atomic_int_get_and_increment(aint) == 1) ? (void) (0) : __assert_fail ("PICC_atomic_int_get_and_increment(aint) == 1", "tests/atomic_test.c", 134, __extension__ __PRETTY_FUNCTION__));;
    ((PICC_atomic_int_get(aint) == 2) ? (void) (0) : __assert_fail ("PICC_atomic_int_get(aint) == 2", "tests/atomic_test.c", 135, __extension__ __PRETTY_FUNCTION__));;
    ((PICC_atomic_int_get_and_decrement(aint) == 2) ? (void) (0) : __assert_fail ("PICC_atomic_int_get_and_decrement(aint) == 2", "tests/atomic_test.c", 136, __extension__ __PRETTY_FUNCTION__));;
    ((PICC_atomic_int_get(aint) == 1) ? (void) (0) : __assert_fail ("PICC_atomic_int_get(aint) == 1", "tests/atomic_test.c", 137, __extension__ __PRETTY_FUNCTION__));;
    ((PICC_atomic_int_get_and_decrement(aint) == 1) ? (void) (0) : __assert_fail ("PICC_atomic_int_get_and_decrement(aint) == 1", "tests/atomic_test.c", 138, __extension__ __PRETTY_FUNCTION__));;
    ((PICC_atomic_int_get(aint) == 0) ? (void) (0) : __assert_fail ("PICC_atomic_int_get(aint) == 0", "tests/atomic_test.c", 139, __extension__ __PRETTY_FUNCTION__));;
}


decompiled_code:
__int64 PICC_test_atomic()
{
__int64 result; // rax
int v1; // [rsp+0h] [rbp-28h] BYREF
__int64 v2; // [rsp+8h] [rbp-20h]
int v3; // [rsp+10h] [rbp-18h]
__int64 v4; // [rsp+18h] [rbp-10h]

v1 = 0;
v2 = 0LL;
v3 = 0;
v4 = 0LL;
test_creation(&v1);
test_compare_and_swap(&v1);
test_compare_and_swap_check(&v1);
test_get_and_set(&v1);
result = test_increment_and_decrement(&v1);
if ( v1 )
result = PICC_print_error(&v1, "tests/atomic_test.c", "PICC_test_atomic");
return result;
}

canonical_decompiled_code:
__int64 func5()
{
__int64 result; // rax
int v1; // [rsp+0h] [rbp-28h] BYREF
__int64 v2; // [rsp+8h] [rbp-20h]
int v3; // [rsp+10h] [rbp-18h]
__int64 v4; // [rsp+18h] [rbp-10h]

v1 = 0;
v2 = 0LL;
v3 = 0;
v4 = 0LL;
func0(&v1);
func1(&v1);
func2(&v1);
func3(&v1);
result = func4(&v1);
if ( v1 )
result = PICC_print_error(&v1, "tests/atomic_test.c", "PICC_test_atomic");
return result;
}

original_code:
void PICC_test_atomic()
{
    PICC_Error error = (PICC_Error){.id = 0, .file = ((void *)0), .line = 0, .prev = ((void *)0)};
    test_creation(&error);
    test_compare_and_swap(&error);
    test_compare_and_swap_check(&error);
    test_get_and_set(&error);
    test_increment_and_decrement(&error);
    if (error.id > 0)
        PICC_print_error(&error, "tests/atomic_test.c", __FUNCTION__);
}

canonical_original_code:
void PICC_test_atomic()
{
    struct _PICC_Error error = (PICC_Error){.id = 0, .file = ((void *)0), .line = 0, .prev = ((void *)0)};
    test_creation(&error);
    test_compare_and_swap(&error);
    test_compare_and_swap_check(&error);
    test_get_and_set(&error);
    test_increment_and_decrement(&error);
    if (error.id > 0)
        PICC_print_error(&error, "tests/atomic_test.c", __FUNCTION__);
}

variable_types: struct _PICC_Error { enum _PICC_ErrorId { ERR_DEAD_CODE_REACHED=0, ERR_DEADLOCK=1, ERR_ALLOC_QUEUE_CELL=2, ERR_READY_QUEUE_PUSH=3, ERR_READY_QUEUE_ADD=4, ERR_WAIT_QUEUE_PUSH=5, ERR_WAIT_QUEUE_ADD=6, ERR_WAIT_QUEUE_PUSH_OLD=7, ERR_NOT_IMPLEMENTED=8, ERR_OUT_OF_MEMORY=9, ERR_COMMIT_CREATE=10, ERR_ADD_COMMIT_TO_LIST=11, ERR_REGISTER_OUT_COMMIT=12, ERR_REGISTER_IN_COMMIT=13, ERR_THREAD_CREATE=14, ERR_THREAD_YIELD=15, ERR_PTHREAD_CREATE=16, ERR_SCHED_POOL_CREATE=17, ERR_CLOCK_CREATE=18, ERR_MUTEX_ALREADY_UNLOCKED=19, ERR_CONDITION_SIGNAL=20, ERR_CONDITION_BROADCAST=21, ERR_NULLPOINTER_PITHREAD=22, ERR_NULLPOINTER_CHANNEL=23, ERR_NULLPOINTER_COMMIT=24, ERR_NULLPOINTER_COMMITLISTELEM=25, ERR_NULLPOINTER_COMMITLIST=26, ERR_CHANNEL_GLOBAL_RC=27, ERR_INVALID_COMMIT=28, ERR_INVALID_VALUE=29, ERR_INVALID_TYPE=30, ERR_INVALID_KNOWNSET_STATE=31 } id; char *file; int line; struct _PICC_Error *prev; }


decompiled_code:
__int64 __fastcall PICC_reclaim_pi_thread(__int64 a1)
{
free(*(void **)(a1 + 8));
PICC_free_knownset(*(_QWORD *)(a1 + 24));
free(*(void **)(a1 + 32));
free(*(void **)(a1 + 96));
free(*(void **)(a1 + 56));
return PICC_lock_free(*(_QWORD *)(a1 + 112));
}

original_code:
void PICC_reclaim_pi_thread(PICC_PiThread *pt)
{
    free(pt->enabled);
    PICC_free_knownset(pt->knowns);
    free(pt->env);
    free(pt->clock);
    free(pt->commits);
    PICC_lock_free(pt->lock);
}

canonical_original_code:
void PICC_reclaim_pi_thread(struct _PICC_PiThread *pt)
{
    free(pt->enabled);
    PICC_free_knownset(pt->knowns);
    free(pt->env);
    free(pt->clock);
    free(pt->commits);
    PICC_lock_free(pt->lock);
}

variable_types: struct _PICC_PiThread { enum _PICC_StatusKind { PICC_STATUS_RUN=0, PICC_STATUS_CALL=1, PICC_STATUS_WAIT=2, PICC_STATUS_ENDED=3, PICC_STATUS_BLOCKED=4 } status; _Bool *enabled; int enabled_length; struct _PICC_KnownSet { int max_size; int current_size; struct _PICC_KnownElement { enum _PICC_KnownState { PICC_UNKNOWN=0, PICC_KNOWN=1, PICC_FORGET=2 } state; struct _PICC_KnownValue { unsigned int header; struct _PICC_Handle { int global_rc; union pthread_mutex_t { struct __pthread_mutex_s { int __lock; unsigned int __count; int __owner; unsigned int __nusers; int __kind; short __spins; short __elision; struct __pthread_internal_list { struct __pthread_internal_list *__prev; struct __pthread_internal_list *__next; } __list; } __data; char __size[40]; long __align; } *lock; void (*reclaim)(struct _PICC_Handle *handled, struct _PICC_Error { enum _PICC_ErrorId { ERR_DEAD_CODE_REACHED=0, ERR_DEADLOCK=1, ERR_ALLOC_QUEUE_CELL=2, ERR_READY_QUEUE_PUSH=3, ERR_READY_QUEUE_ADD=4, ERR_WAIT_QUEUE_PUSH=5, ERR_WAIT_QUEUE_ADD=6, ERR_WAIT_QUEUE_PUSH_OLD=7, ERR_NOT_IMPLEMENTED=8, ERR_OUT_OF_MEMORY=9, ERR_COMMIT_CREATE=10, ERR_ADD_COMMIT_TO_LIST=11, ERR_REGISTER_OUT_COMMIT=12, ERR_REGISTER_IN_COMMIT=13, ERR_THREAD_CREATE=14, ERR_THREAD_YIELD=15, ERR_PTHREAD_CREATE=16, ERR_SCHED_POOL_CREATE=17, ERR_CLOCK_CREATE=18, ERR_MUTEX_ALREADY_UNLOCKED=19, ERR_CONDITION_SIGNAL=20, ERR_CONDITION_BROADCAST=21, ERR_NULLPOINTER_PITHREAD=22, ERR_NULLPOINTER_CHANNEL=23, ERR_NULLPOINTER_COMMIT=24, ERR_NULLPOINTER_COMMITLISTELEM=25, ERR_NULLPOINTER_COMMITLIST=26, ERR_CHANNEL_GLOBAL_RC=27, ERR_INVALID_COMMIT=28, ERR_INVALID_VALUE=29, ERR_INVALID_TYPE=30, ERR_INVALID_KNOWNSET_STATE=31 } id; char *file; int line; struct _PICC_Error *prev; } *error); } *handle; } value; } *content; } *knowns; struct _PICC_Value { unsigned int header; void *data; } *env; int env_length; struct _PICC_Commit { enum _PICC_CommitType { PICC_IN_COMMIT=0, PICC_OUT_COMMIT=1 } type; struct _PICC_PiThread *thread; struct _PICC_Clock { struct _PICC_AtomicInt { int val; union pthread_mutex_t lock; } *val; } *clock; int clockval; int cont_pc; struct _PICC_Channel { int global_rc; union pthread_mutex_t *lock; void (*reclaim)(struct _PICC_Handle *handled, struct _PICC_Error *error); struct _PICC_CommitList { struct _PICC_CommitListElement { struct _PICC_Commit *commit; struct _PICC_CommitListElement *next; } *head; struct _PICC_CommitListElement *tail; int size; } *incommits; struct _PICC_CommitList *outcommits; } *channel; union { struct _PICC_InCommit { int refvar; } *in; struct _PICC_OutCommit { struct _PICC_Value (*eval_func)(struct _PICC_PiThread *); } *out; } content; } *commit; struct _PICC_CommitList *commits; void (*proc)(struct _PICC_SchedPool { struct _PICC_ReadyQueue { struct _PICC_Queue { struct _PICC_QueueCell { struct _PICC_PiThread *thread; struct _PICC_QueueCell *next; } *head; struct _PICC_QueueCell *tail; int size; } q; union pthread_mutex_t *lock; } *ready; struct _PICC_WaitQueue { struct _PICC_Queue active; struct _PICC_Queue old; union pthread_mutex_t *lock; } *wait; union pthread_mutex_t lock; union pthread_cond_t { struct __pthread_cond_s { union { unsigned long long __wseq; struct { unsigned int __low; unsigned int __high; } __wseq32; }; union { unsigned long long __g1_start; struct { unsigned int __low; unsigned int __high; } __g1_start32; }; unsigned int __g_refs[2]; unsigned int __g_size[2]; unsigned int __g1_orig_size; unsigned int __wrefs; unsigned int __g_signals[2]; } __data; char __size[48]; long long __align; } cond; int nb_slaves; int nb_waiting_slaves; _Bool running; } *, struct _PICC_PiThread *); int pc; struct _PICC_Value val; struct _PICC_Clock *clock; int fuel; union pthread_mutex_t *lock; } *

user_defined_types: struct _PICC_PiThread { enum _PICC_StatusKind status; _Bool *enabled; int enabled_length; struct _PICC_KnownSet *knowns; struct _PICC_Value *env; int env_length; struct _PICC_Commit *commit; struct _PICC_CommitList *commits; void (*proc)(struct _PICC_SchedPool *, struct _PICC_PiThread *); int pc; struct _PICC_Value val; struct _PICC_Clock *clock; int fuel; union pthread_mutex_t *lock; }

user_defined_types: struct _PICC_KnownSet { int max_size; int current_size; struct _PICC_KnownElement *content; }

user_defined_types: struct _PICC_Commit { enum _PICC_CommitType type; struct _PICC_PiThread *thread; struct _PICC_Clock *clock; int clockval; int cont_pc; struct _PICC_Channel *channel; union { struct _PICC_InCommit *in; struct _PICC_OutCommit *out; } content; }

user_defined_types: struct _PICC_KnownElement { enum _PICC_KnownState state; struct _PICC_KnownValue value; }

user_defined_types: struct _PICC_Clock { struct _PICC_AtomicInt *val; }

user_defined_types: struct _PICC_Channel { int global_rc; union pthread_mutex_t *lock; void (*reclaim)(struct _PICC_Handle *handled, struct _PICC_Error *error); struct _PICC_CommitList *incommits; struct _PICC_CommitList *outcommits; }

user_defined_types: struct _PICC_SchedPool { struct _PICC_ReadyQueue *ready; struct _PICC_WaitQueue *wait; union pthread_mutex_t lock; union pthread_cond_t cond; int nb_slaves; int nb_waiting_slaves; _Bool running; }

user_defined_types: struct _PICC_KnownValue { unsigned int header; struct _PICC_Handle *handle; }

user_defined_types: union pthread_cond_t { struct __pthread_cond_s __data; char __size[48]; long long __align; }

user_defined_types: struct _PICC_CommitList { struct _PICC_CommitListElement *head; struct _PICC_CommitListElement *tail; int size; }

user_defined_types: struct _PICC_ReadyQueue { struct _PICC_Queue q; union pthread_mutex_t *lock; }

user_defined_types: struct _PICC_Handle { int global_rc; union pthread_mutex_t *lock; void (*reclaim)(struct _PICC_Handle *handled, struct _PICC_Error *error); }

user_defined_types: struct _PICC_Queue { struct _PICC_QueueCell *head; struct _PICC_QueueCell *tail; int size; }


decompiled_code:
__int64 __fastcall PICC_process_end(__int64 a1, int a2)
{
__int64 v2; // r13
__int64 i; // rbx
__int64 v4; // r13
__int64 j; // rbx
__int64 result; // rax
__int64 v7[6]; // [rsp+8h] [rbp-30h] BYREF

v2 = PICC_knownset_known(*(_QWORD *)(a1 + 24));
for ( i = 0LL; *(_DWORD *)(v2 + 4) > (int)i; ++i )
{
v7[0] = *(_QWORD *)(*(_QWORD *)(v2 + 8) + 24 * i + 16);
if ( !v7[0] )
break;
PICC_handle_dec_ref_count(v7);
PICC_free_knownset(v2);
}
v4 = PICC_knownset_forget(*(_QWORD *)(a1 + 24));
for ( j = 0LL; *(_DWORD *)(v4 + 4) > (int)j; ++j )
{
v7[0] = *(_QWORD *)(*(_QWORD *)(v4 + 8) + 24 * j + 16);
if ( !v7[0] )
break;
PICC_handle_dec_ref_count(v7);
}
result = PICC_free_knownset(v4);
*(_DWORD *)a1 = a2;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1, int a2)
{
__int64 v2; // r13
__int64 i; // rbx
__int64 v4; // r13
__int64 j; // rbx
__int64 result; // rax
__int64 v7[6]; // [rsp+8h] [rbp-30h] BYREF

v2 = PICC_knownset_known(*(_QWORD *)(a1 + 24));
for ( i = 0LL; *(_DWORD *)(v2 + 4) > (int)i; ++i )
{
v7[0] = *(_QWORD *)(*(_QWORD *)(v2 + 8) + 24 * i + 16);
if ( !v7[0] )
break;
PICC_handle_dec_ref_count(v7);
PICC_free_knownset(v2);
}
v4 = PICC_knownset_forget(*(_QWORD *)(a1 + 24));
for ( j = 0LL; *(_DWORD *)(v4 + 4) > (int)j; ++j )
{
v7[0] = *(_QWORD *)(*(_QWORD *)(v4 + 8) + 24 * j + 16);
if ( !v7[0] )
break;
PICC_handle_dec_ref_count(v7);
}
result = PICC_free_knownset(v4);
*(_DWORD *)a1 = a2;
return result;
}

original_code:
void PICC_process_end(PICC_PiThread *pt, PICC_StatusKind status) {
  PICC_KnownValue chan;
  PICC_KnownSet* s=PICC_knownset_known( pt->knowns );
  for(int i = 0; i < (s)->current_size && ( (chan).header = (s)->content[i].value.header, (chan).handle = (s)->content[i].value.handle ); i++){
    PICC_handle_dec_ref_count( &((PICC_KnownValue*) (&chan))->handle );
    PICC_free_knownset(s);
  }
  s=PICC_knownset_forget( pt->knowns );
  for(int i = 0; i < (s)->current_size && ( (chan).header = (s)->content[i].value.header, (chan).handle = (s)->content[i].value.handle ); i++){
    PICC_handle_dec_ref_count( &((PICC_KnownValue*) (&chan))->handle );
  }
  PICC_free_knownset(s);
  pt->status = status;
}

canonical_original_code:
void PICC_process_end(struct _PICC_PiThread *pt, enum _PICC_StatusKind status) {
  struct _PICC_KnownValue chan;
  struct _PICC_KnownSet *s = PICC_knownset_known( pt->knowns );
  for(int i = 0; i < (s)->current_size && ( (chan).header = (s)->content[i].value.header, (chan).handle = (s)->content[i].value.handle ); i++){
    PICC_handle_dec_ref_count( &((struct _PICC_KnownValue *) (&chan))->handle );
    PICC_free_knownset(s);
  }
  s=PICC_knownset_forget( pt->knowns );
  for(int i = 0; i < (s)->current_size && ( (chan).header = (s)->content[i].value.header, (chan).handle = (s)->content[i].value.handle ); i++){
    PICC_handle_dec_ref_count( &((struct _PICC_KnownValue *) (&chan))->handle );
  }
  PICC_free_knownset(s);
  pt->status = status;
}

variable_types: enum _PICC_StatusKind { PICC_STATUS_RUN=0, PICC_STATUS_CALL=1, PICC_STATUS_WAIT=2, PICC_STATUS_ENDED=3, PICC_STATUS_BLOCKED=4 }

variable_types: struct _PICC_KnownSet { int max_size; int current_size; struct _PICC_KnownElement { enum _PICC_KnownState { PICC_UNKNOWN=0, PICC_KNOWN=1, PICC_FORGET=2 } state; struct _PICC_KnownValue { unsigned int header; struct _PICC_Handle { int global_rc; union pthread_mutex_t { struct __pthread_mutex_s { int __lock; unsigned int __count; int __owner; unsigned int __nusers; int __kind; short __spins; short __elision; struct __pthread_internal_list { struct __pthread_internal_list *__prev; struct __pthread_internal_list *__next; } __list; } __data; char __size[40]; long __align; } *lock; void (*reclaim)(struct _PICC_Handle *handled, struct _PICC_Error { enum _PICC_ErrorId { ERR_DEAD_CODE_REACHED=0, ERR_DEADLOCK=1, ERR_ALLOC_QUEUE_CELL=2, ERR_READY_QUEUE_PUSH=3, ERR_READY_QUEUE_ADD=4, ERR_WAIT_QUEUE_PUSH=5, ERR_WAIT_QUEUE_ADD=6, ERR_WAIT_QUEUE_PUSH_OLD=7, ERR_NOT_IMPLEMENTED=8, ERR_OUT_OF_MEMORY=9, ERR_COMMIT_CREATE=10, ERR_ADD_COMMIT_TO_LIST=11, ERR_REGISTER_OUT_COMMIT=12, ERR_REGISTER_IN_COMMIT=13, ERR_THREAD_CREATE=14, ERR_THREAD_YIELD=15, ERR_PTHREAD_CREATE=16, ERR_SCHED_POOL_CREATE=17, ERR_CLOCK_CREATE=18, ERR_MUTEX_ALREADY_UNLOCKED=19, ERR_CONDITION_SIGNAL=20, ERR_CONDITION_BROADCAST=21, ERR_NULLPOINTER_PITHREAD=22, ERR_NULLPOINTER_CHANNEL=23, ERR_NULLPOINTER_COMMIT=24, ERR_NULLPOINTER_COMMITLISTELEM=25, ERR_NULLPOINTER_COMMITLIST=26, ERR_CHANNEL_GLOBAL_RC=27, ERR_INVALID_COMMIT=28, ERR_INVALID_VALUE=29, ERR_INVALID_TYPE=30, ERR_INVALID_KNOWNSET_STATE=31 } id; char *file; int line; struct _PICC_Error *prev; } *error); } *handle; } value; } *content; } *

variable_types: i int

user_defined_types: struct _PICC_Value { unsigned int header; void *data; }

user_defined_types: enum _PICC_CommitType { PICC_IN_COMMIT=0, PICC_OUT_COMMIT=1 }

user_defined_types: union pthread_mutex_t { struct __pthread_mutex_s __data; char __size[40]; long __align; }

user_defined_types: struct _PICC_OutCommit { struct _PICC_Value (*eval_func)(struct _PICC_PiThread *); }

user_defined_types: struct _PICC_Error { enum _PICC_ErrorId id; char *file; int line; struct _PICC_Error *prev; }

user_defined_types: struct _PICC_AtomicInt { int val; union pthread_mutex_t lock; }

user_defined_types: struct _PICC_WaitQueue { struct _PICC_Queue active; struct _PICC_Queue old; union pthread_mutex_t *lock; }

user_defined_types: struct __pthread_cond_s { union { unsigned long long __wseq; struct { unsigned int __low; unsigned int __high; } __wseq32; }; union { unsigned long long __g1_start; struct { unsigned int __low; unsigned int __high; } __g1_start32; }; unsigned int __g_refs[2]; unsigned int __g_size[2]; unsigned int __g1_orig_size; unsigned int __wrefs; unsigned int __g_signals[2]; }

user_defined_types: struct _PICC_CommitListElement { struct _PICC_Commit *commit; struct _PICC_CommitListElement *next; }

user_defined_types: struct _PICC_QueueCell { struct _PICC_PiThread *thread; struct _PICC_QueueCell *next; }


decompiled_code:
int PICC_low_level_yield()
{
int result; // eax
int v1; // [rsp+0h] [rbp-28h] BYREF
__int64 v2; // [rsp+8h] [rbp-20h]
int v3; // [rsp+10h] [rbp-18h]
__int64 v4; // [rsp+18h] [rbp-10h]

result = sched_yield();
if ( result )
{
v1 = 0;
v2 = 0LL;
v3 = 0;
v4 = 0LL;
PICC_init_error(&v1, 15LL, "src/pi_thread.c", 301LL);
result = PICC_crash(&v1, "src/pi_thread.c", "PICC_low_level_yield");
}
return result;
}

canonical_decompiled_code:
int func2()
{
int result; // eax
int v1; // [rsp+0h] [rbp-28h] BYREF
__int64 v2; // [rsp+8h] [rbp-20h]
int v3; // [rsp+10h] [rbp-18h]
__int64 v4; // [rsp+18h] [rbp-10h]

result = sched_yield();
if ( result )
{
v1 = 0;
v2 = 0LL;
v3 = 0;
v4 = 0LL;
PICC_init_error(&v1, 15LL, "src/pi_thread.c", 301LL);
result = PICC_crash(&v1, "src/pi_thread.c", "PICC_low_level_yield");
}
return result;
}

original_code:
void PICC_low_level_yield()
{
    int status = sched_yield();
    if (status) {
        PICC_Error error = (PICC_Error){.id = 0, .file = ((void *)0), .line = 0, .prev = ((void *)0)}; PICC_init_error(&error, ERR_THREAD_YIELD, "src/pi_thread.c", 301); PICC_crash(&error, "src/pi_thread.c", __FUNCTION__);;
    }
}

canonical_original_code:
void PICC_low_level_yield()
{
    int status = sched_yield();
    if (status) {
        struct _PICC_Error error = (PICC_Error){.id = 0, .file = ((void *)0), .line = 0, .prev = ((void *)0)}; PICC_init_error(&error, ERR_THREAD_YIELD, "src/pi_thread.c", 301); PICC_crash(&error, "src/pi_thread.c", __FUNCTION__);;
    }
}

variable_types: status int

user_defined_types: enum _PICC_ErrorId { ERR_DEAD_CODE_REACHED=0, ERR_DEADLOCK=1, ERR_ALLOC_QUEUE_CELL=2, ERR_READY_QUEUE_PUSH=3, ERR_READY_QUEUE_ADD=4, ERR_WAIT_QUEUE_PUSH=5, ERR_WAIT_QUEUE_ADD=6, ERR_WAIT_QUEUE_PUSH_OLD=7, ERR_NOT_IMPLEMENTED=8, ERR_OUT_OF_MEMORY=9, ERR_COMMIT_CREATE=10, ERR_ADD_COMMIT_TO_LIST=11, ERR_REGISTER_OUT_COMMIT=12, ERR_REGISTER_IN_COMMIT=13, ERR_THREAD_CREATE=14, ERR_THREAD_YIELD=15, ERR_PTHREAD_CREATE=16, ERR_SCHED_POOL_CREATE=17, ERR_CLOCK_CREATE=18, ERR_MUTEX_ALREADY_UNLOCKED=19, ERR_CONDITION_SIGNAL=20, ERR_CONDITION_BROADCAST=21, ERR_NULLPOINTER_PITHREAD=22, ERR_NULLPOINTER_CHANNEL=23, ERR_NULLPOINTER_COMMIT=24, ERR_NULLPOINTER_COMMITLISTELEM=25, ERR_NULLPOINTER_COMMITLIST=26, ERR_CHANNEL_GLOBAL_RC=27, ERR_INVALID_COMMIT=28, ERR_INVALID_VALUE=29, ERR_INVALID_TYPE=30, ERR_INVALID_KNOWNSET_STATE=31 }


decompiled_code:
void __fastcall PICC_reclaim_clock(void *ptr)
{
PICC_free_atomic_int(*(_QWORD *)ptr);
free(ptr);
}

canonical_decompiled_code:
void __fastcall func3(void *ptr)
{
PICC_free_atomic_int(*(_QWORD *)ptr);
free(ptr);
}

original_code:
void PICC_reclaim_clock(PICC_Clock *clock)
{
    PICC_free_atomic_int(clock->val);
    free(clock);
}

canonical_original_code:
void PICC_reclaim_clock(struct _PICC_Clock *clock)
{
    PICC_free_atomic_int(clock->val);
    free(clock);
}

variable_types: struct _PICC_Clock { struct _PICC_AtomicInt { int val; union pthread_mutex_t { struct __pthread_mutex_s { int __lock; unsigned int __count; int __owner; unsigned int __nusers; int __kind; short __spins; short __elision; struct __pthread_internal_list { struct __pthread_internal_list *__prev; struct __pthread_internal_list *__next; } __list; } __data; char __size[40]; long __align; } lock; } *val; } *

user_defined_types: struct _PICC_Clock { struct _PICC_AtomicInt *val; }

user_defined_types: struct __pthread_mutex_s { int __lock; unsigned int __count; int __owner; unsigned int __nusers; int __kind; short __spins; short __elision; struct __pthread_internal_list __list; }


decompiled_code:
void __fastcall PICC_PiThread_inv(__int64 a1)
{
int v1; // edx
int i; // eax

if ( !a1 )
_assert_fail("pt != ((void *)0)", "src/pi_thread.c", 0x168u, "PICC_PiThread_inv");
if ( *(_DWORD *)a1 > 4u )
_assert_fail("pt->status <= PICC_STATUS_BLOCKED", "src/pi_thread.c", 0x16Au, "PICC_PiThread_inv");
v1 = *(_DWORD *)(a1 + 16);
if ( v1 < 0 )
_assert_fail("pt->enabled_length >= 0", "src/pi_thread.c", 0x16Bu, "PICC_PiThread_inv");
if ( v1 )
{
for ( i = 0; i != v1; ++i )
;
}
else if ( *(_QWORD *)(a1 + 8) )
{
_assert_fail("pt->enabled == ((void *)0)", "src/pi_thread.c", 0x16Eu, "PICC_PiThread_inv");
}
if ( !*(_QWORD *)(a1 + 24) )
_assert_fail("pt->knowns != ((void *)0)", "src/pi_thread.c", 0x176u, "PICC_PiThread_inv");
if ( *(_DWORD *)(a1 + 40) )
{
if ( !*(_QWORD *)(a1 + 32) )
_assert_fail("pt->env != ((void *)0)", "src/pi_thread.c", 0x17Au, "PICC_PiThread_inv");
}
else if ( *(_QWORD *)(a1 + 32) )
{
_assert_fail("pt->env == ((void *)0)", "src/pi_thread.c", 0x178u, "PICC_PiThread_inv");
}
if ( !*(_QWORD *)(a1 + 56) )
_assert_fail("pt->commits != ((void *)0)", "src/pi_thread.c", 0x17Cu, "PICC_PiThread_inv");
if ( !*(_QWORD *)(a1 + 96) )
_assert_fail("pt->clock != ((void *)0)", "src/pi_thread.c", 0x17Du, "PICC_PiThread_inv");
}

canonical_decompiled_code:
void __fastcall func4(__int64 a1)
{
int v1; // edx
int i; // eax

if ( !a1 )
_assert_fail("pt != ((void *)0)", "src/pi_thread.c", 0x168u, "PICC_PiThread_inv");
if ( *(_DWORD *)a1 > 4u )
_assert_fail("pt->status <= PICC_STATUS_BLOCKED", "src/pi_thread.c", 0x16Au, "PICC_PiThread_inv");
v1 = *(_DWORD *)(a1 + 16);
if ( v1 < 0 )
_assert_fail("pt->enabled_length >= 0", "src/pi_thread.c", 0x16Bu, "PICC_PiThread_inv");
if ( v1 )
{
for ( i = 0; i != v1; ++i )
;
}
else if ( *(_QWORD *)(a1 + 8) )
{
_assert_fail("pt->enabled == ((void *)0)", "src/pi_thread.c", 0x16Eu, "PICC_PiThread_inv");
}
if ( !*(_QWORD *)(a1 + 24) )
_assert_fail("pt->knowns != ((void *)0)", "src/pi_thread.c", 0x176u, "PICC_PiThread_inv");
if ( *(_DWORD *)(a1 + 40) )
{
if ( !*(_QWORD *)(a1 + 32) )
_assert_fail("pt->env != ((void *)0)", "src/pi_thread.c", 0x17Au, "PICC_PiThread_inv");
}
else if ( *(_QWORD *)(a1 + 32) )
{
_assert_fail("pt->env == ((void *)0)", "src/pi_thread.c", 0x178u, "PICC_PiThread_inv");
}
if ( !*(_QWORD *)(a1 + 56) )
_assert_fail("pt->commits != ((void *)0)", "src/pi_thread.c", 0x17Cu, "PICC_PiThread_inv");
if ( !*(_QWORD *)(a1 + 96) )
_assert_fail("pt->clock != ((void *)0)", "src/pi_thread.c", 0x17Du, "PICC_PiThread_inv");
}

original_code:
void PICC_PiThread_inv(PICC_PiThread *pt)
{
    ((pt != ((void *)0)) ? (void) (0) : __assert_fail ("pt != ((void *)0)", "src/pi_thread.c", 360, __extension__ __PRETTY_FUNCTION__));;
    ((pt->status >= PICC_STATUS_RUN) ? (void) (0) : __assert_fail ("pt->status >= PICC_STATUS_RUN", "src/pi_thread.c", 361, __extension__ __PRETTY_FUNCTION__));;
    ((pt->status <= PICC_STATUS_BLOCKED) ? (void) (0) : __assert_fail ("pt->status <= PICC_STATUS_BLOCKED", "src/pi_thread.c", 362, __extension__ __PRETTY_FUNCTION__));;
    ((pt->enabled_length >= 0) ? (void) (0) : __assert_fail ("pt->enabled_length >= 0", "src/pi_thread.c", 363, __extension__ __PRETTY_FUNCTION__));;
    int i;
    if (pt->enabled_length == 0) {
        ((pt->enabled == ((void *)0)) ? (void) (0) : __assert_fail ("pt->enabled == ((void *)0)", "src/pi_thread.c", 366, __extension__ __PRETTY_FUNCTION__));;
    }
    for (i = 0; i < pt->enabled_length; ++i) {
        ((pt->enabled[i] == 0 || pt->enabled[i] == 1) ? (void) (0) : __assert_fail ("pt->enabled[i] == 0 || pt->enabled[i] == 1", "src/pi_thread.c", 369, __extension__ __PRETTY_FUNCTION__));;
    }
    if (pt->enabled_length == 0) {
        ((pt->enabled == ((void *)0)) ? (void) (0) : __assert_fail ("pt->enabled == ((void *)0)", "src/pi_thread.c", 372, __extension__ __PRETTY_FUNCTION__));;
    }
    ((pt->knowns != ((void *)0)) ? (void) (0) : __assert_fail ("pt->knowns != ((void *)0)", "src/pi_thread.c", 374, __extension__ __PRETTY_FUNCTION__));;
    if (pt->env_length == 0) {
        ((pt->env == ((void *)0)) ? (void) (0) : __assert_fail ("pt->env == ((void *)0)", "src/pi_thread.c", 376, __extension__ __PRETTY_FUNCTION__));;
    } else {
        ((pt->env != ((void *)0)) ? (void) (0) : __assert_fail ("pt->env != ((void *)0)", "src/pi_thread.c", 378, __extension__ __PRETTY_FUNCTION__));;
    }
    ((pt->commits != ((void *)0)) ? (void) (0) : __assert_fail ("pt->commits != ((void *)0)", "src/pi_thread.c", 380, __extension__ __PRETTY_FUNCTION__));;
    ((pt->clock != ((void *)0)) ? (void) (0) : __assert_fail ("pt->clock != ((void *)0)", "src/pi_thread.c", 381, __extension__ __PRETTY_FUNCTION__));;
}

canonical_original_code:
void PICC_PiThread_inv(struct _PICC_PiThread *pt)
{
    ((pt != ((void *)0)) ? (void) (0) : __assert_fail ("pt != ((void *)0)", "src/pi_thread.c", 360, __extension__ __PRETTY_FUNCTION__));;
    ((pt->status >= PICC_STATUS_RUN) ? (void) (0) : __assert_fail ("pt->status >= PICC_STATUS_RUN", "src/pi_thread.c", 361, __extension__ __PRETTY_FUNCTION__));;
    ((pt->status <= PICC_STATUS_BLOCKED) ? (void) (0) : __assert_fail ("pt->status <= PICC_STATUS_BLOCKED", "src/pi_thread.c", 362, __extension__ __PRETTY_FUNCTION__));;
    ((pt->enabled_length >= 0) ? (void) (0) : __assert_fail ("pt->enabled_length >= 0", "src/pi_thread.c", 363, __extension__ __PRETTY_FUNCTION__));;
    int i;
    if (pt->enabled_length == 0) {
        ((pt->enabled == ((void *)0)) ? (void) (0) : __assert_fail ("pt->enabled == ((void *)0)", "src/pi_thread.c", 366, __extension__ __PRETTY_FUNCTION__));;
    }
    for (i = 0; i < pt->enabled_length; ++i) {
        ((pt->enabled[i] == 0 || pt->enabled[i] == 1) ? (void) (0) : __assert_fail ("pt->enabled[i] == 0 || pt->enabled[i] == 1", "src/pi_thread.c", 369, __extension__ __PRETTY_FUNCTION__));;
    }
    if (pt->enabled_length == 0) {
        ((pt->enabled == ((void *)0)) ? (void) (0) : __assert_fail ("pt->enabled == ((void *)0)", "src/pi_thread.c", 372, __extension__ __PRETTY_FUNCTION__));;
    }
    ((pt->knowns != ((void *)0)) ? (void) (0) : __assert_fail ("pt->knowns != ((void *)0)", "src/pi_thread.c", 374, __extension__ __PRETTY_FUNCTION__));;
    if (pt->env_length == 0) {
        ((pt->env == ((void *)0)) ? (void) (0) : __assert_fail ("pt->env == ((void *)0)", "src/pi_thread.c", 376, __extension__ __PRETTY_FUNCTION__));;
    } else {
        ((pt->env != ((void *)0)) ? (void) (0) : __assert_fail ("pt->env != ((void *)0)", "src/pi_thread.c", 378, __extension__ __PRETTY_FUNCTION__));;
    }
    ((pt->commits != ((void *)0)) ? (void) (0) : __assert_fail ("pt->commits != ((void *)0)", "src/pi_thread.c", 380, __extension__ __PRETTY_FUNCTION__));;
    ((pt->clock != ((void *)0)) ? (void) (0) : __assert_fail ("pt->clock != ((void *)0)", "src/pi_thread.c", 381, __extension__ __PRETTY_FUNCTION__));;
}

user_defined_types: struct _PICC_PiThread { enum _PICC_StatusKind status; _Bool *enabled; int enabled_length; struct _PICC_KnownSet *knowns; struct _PICC_Value *env; int env_length; struct _PICC_Commit *commit; struct _PICC_CommitList *commits; void (*proc)(struct _PICC_SchedPool *, struct _PICC_PiThread *); int pc; struct _PICC_Value val; struct _PICC_Clock *clock; int fuel; union pthread_mutex_t *lock; }

user_defined_types: enum _PICC_StatusKind { PICC_STATUS_RUN=0, PICC_STATUS_CALL=1, PICC_STATUS_WAIT=2, PICC_STATUS_ENDED=3, PICC_STATUS_BLOCKED=4 }

user_defined_types: struct _PICC_KnownSet { int max_size; int current_size; struct _PICC_KnownElement *content; }

user_defined_types: struct _PICC_Commit { enum _PICC_CommitType type; struct _PICC_PiThread *thread; struct _PICC_Clock *clock; int clockval; int cont_pc; struct _PICC_Channel *channel; union { struct _PICC_InCommit *in; struct _PICC_OutCommit *out; } content; }

user_defined_types: struct _PICC_KnownElement { enum _PICC_KnownState state; struct _PICC_KnownValue value; }

user_defined_types: struct _PICC_Channel { int global_rc; union pthread_mutex_t *lock; void (*reclaim)(struct _PICC_Handle *handled, struct _PICC_Error *error); struct _PICC_CommitList *incommits; struct _PICC_CommitList *outcommits; }

user_defined_types: struct _PICC_SchedPool { struct _PICC_ReadyQueue *ready; struct _PICC_WaitQueue *wait; union pthread_mutex_t lock; union pthread_cond_t cond; int nb_slaves; int nb_waiting_slaves; _Bool running; }

user_defined_types: enum _PICC_KnownState { PICC_UNKNOWN=0, PICC_KNOWN=1, PICC_FORGET=2 }

user_defined_types: struct _PICC_KnownValue { unsigned int header; struct _PICC_Handle *handle; }

user_defined_types: union pthread_cond_t { struct __pthread_cond_s __data; char __size[48]; long long __align; }

user_defined_types: struct _PICC_CommitList { struct _PICC_CommitListElement *head; struct _PICC_CommitListElement *tail; int size; }

user_defined_types: struct __pthread_internal_list { struct __pthread_internal_list *__prev; struct __pthread_internal_list *__next; }


decompiled_code:
__int64 __fastcall PICC_can_awake(_QWORD *a1, __int64 a2)
{
_QWORD *v2; // rax
unsigned int v3; // ebp
int v4; // er12

PICC_PiThread_inv((__int64)a1);
if ( !a2 )
_assert_fail("commit != ((void *)0)", "src/pi_thread.c", 0x96u, "PICC_can_awake");
PICC_Commit_inv(a2);
if ( !(unsigned __int8)PICC_try_acquire(a1[14]) )
{
v3 = 0;
goto LABEL_11;
}
v2 = *(_QWORD **)(a2 + 16);
if ( v2 != (_QWORD *)a1[12] || (v4 = *(_DWORD *)(a2 + 24), v4 != (unsigned int)PICC_atomic_int_get(*v2)) )
{
PICC_release(a1[14]);
v3 = 2;
LABEL_11:
PICC_PiThread_inv((__int64)a1);
return v3;
}
a1[6] = a2;
PICC_release(a1[14]);
PICC_PiThread_inv((__int64)a1);
if ( a1[6] != a2 )
_assert_fail("pt->commit == commit", "src/pi_thread.c", 0xB1u, "PICC_can_awake");
return 1;
}

canonical_decompiled_code:
__int64 __fastcall func5(_QWORD *a1, __int64 a2)
{
_QWORD *v2; // rax
unsigned int v3; // ebp
int v4; // er12

func4((__int64)a1);
if ( !a2 )
_assert_fail("commit != ((void *)0)", "src/pi_thread.c", 0x96u, "PICC_can_awake");
PICC_Commit_inv(a2);
if ( !(unsigned __int8)PICC_try_acquire(a1[14]) )
{
v3 = 0;
goto LABEL_11;
}
v2 = *(_QWORD **)(a2 + 16);
if ( v2 != (_QWORD *)a1[12] || (v4 = *(_DWORD *)(a2 + 24), v4 != (unsigned int)PICC_atomic_int_get(*v2)) )
{
PICC_release(a1[14]);
v3 = 2;
LABEL_11:
func4((__int64)a1);
return v3;
}
a1[6] = a2;
PICC_release(a1[14]);
func4((__int64)a1);
if ( a1[6] != a2 )
_assert_fail("pt->commit == commit", "src/pi_thread.c", 0xB1u, "PICC_can_awake");
return 1;
}

original_code:
PICC_CommitStatus PICC_can_awake(PICC_PiThread *pt, PICC_Commit *commit)
{
        PICC_PiThread_inv(pt);
        ((commit != ((void *)0)) ? (void) (0) : __assert_fail ("commit != ((void *)0)", "src/pi_thread.c", 150, __extension__ __PRETTY_FUNCTION__));;
        PICC_Commit_inv(commit);
    PICC_CommitStatus status;
    if (!PICC_try_acquire(pt->lock)) {
        status = PICC_CANNOT_ACQUIRE;
    } else if (commit->clock != pt->clock || commit->clockval != PICC_atomic_int_get(commit->clock->val)) {
        PICC_release(pt->lock);
        status = PICC_INVALID_COMMIT;
    } else {
        pt->commit = commit;
        PICC_release(pt->lock);
        status = PICC_VALID_COMMIT;
    }
        PICC_PiThread_inv(pt);
        if (status == PICC_VALID_COMMIT) {
            ((pt->commit == commit) ? (void) (0) : __assert_fail ("pt->commit == commit", "src/pi_thread.c", 177, __extension__ __PRETTY_FUNCTION__));;
        }
    return status;
}

canonical_original_code:
enum _PICC_CommitStatus PICC_can_awake(struct _PICC_PiThread *pt, struct _PICC_Commit *commit)
{
        PICC_PiThread_inv(pt);
        ((commit != ((void *)0)) ? (void) (0) : __assert_fail ("commit != ((void *)0)", "src/pi_thread.c", 150, __extension__ __PRETTY_FUNCTION__));;
        PICC_Commit_inv(commit);
    enum _PICC_CommitStatus status;
    if (!PICC_try_acquire(pt->lock)) {
        status = PICC_CANNOT_ACQUIRE;
    } else if (commit->clock != pt->clock || commit->clockval != PICC_atomic_int_get(commit->clock->val)) {
        PICC_release(pt->lock);
        status = PICC_INVALID_COMMIT;
    } else {
        pt->commit = commit;
        PICC_release(pt->lock);
        status = PICC_VALID_COMMIT;
    }
        PICC_PiThread_inv(pt);
        if (status == PICC_VALID_COMMIT) {
            ((pt->commit == commit) ? (void) (0) : __assert_fail ("pt->commit == commit", "src/pi_thread.c", 177, __extension__ __PRETTY_FUNCTION__));;
        }
    return status;
}

variable_types:
commit
struct _PICC_Commit *

variable_types: enum _PICC_CommitStatus { PICC_CANNOT_ACQUIRE=0, PICC_VALID_COMMIT=1, PICC_INVALID_COMMIT=2 }

user_defined_types: struct _PICC_Value { unsigned int header; void *data; }

user_defined_types: enum _PICC_CommitType { PICC_IN_COMMIT=0, PICC_OUT_COMMIT=1 }

user_defined_types: struct _PICC_OutCommit { struct _PICC_Value (*eval_func)(struct _PICC_PiThread *); }

user_defined_types: struct _PICC_AtomicInt { int val; union pthread_mutex_t lock; }

user_defined_types: struct _PICC_ReadyQueue { struct _PICC_Queue q; union pthread_mutex_t *lock; }

user_defined_types: struct _PICC_WaitQueue { struct _PICC_Queue active; struct _PICC_Queue old; union pthread_mutex_t *lock; }

user_defined_types: struct __pthread_cond_s { union { unsigned long long __wseq; struct { unsigned int __low; unsigned int __high; } __wseq32; }; union { unsigned long long __g1_start; struct { unsigned int __low; unsigned int __high; } __g1_start32; }; unsigned int __g_refs[2]; unsigned int __g_size[2]; unsigned int __g1_orig_size; unsigned int __wrefs; unsigned int __g_signals[2]; }

user_defined_types: struct _PICC_Handle { int global_rc; union pthread_mutex_t *lock; void (*reclaim)(struct _PICC_Handle *handled, struct _PICC_Error *error); }

user_defined_types: struct _PICC_Queue { struct _PICC_QueueCell *head; struct _PICC_QueueCell *tail; int size; }

user_defined_types: struct _PICC_CommitListElement { struct _PICC_Commit *commit; struct _PICC_CommitListElement *next; }

user_defined_types: union pthread_mutex_t { struct __pthread_mutex_s __data; char __size[40]; long __align; }

user_defined_types: struct _PICC_Error { enum _PICC_ErrorId id; char *file; int line; struct _PICC_Error *prev; }


decompiled_code:
__int64 __fastcall PICC_awake(_QWORD *a1, __int64 a2, __int64 a3)
{
unsigned int v4; // eax
int v6; // [rsp+0h] [rbp-38h] BYREF
__int64 v7; // [rsp+8h] [rbp-30h]
int v8; // [rsp+10h] [rbp-28h]
__int64 v9; // [rsp+18h] [rbp-20h]

if ( !a3 )
_assert_fail("commit != ((void *)0)", "src/pi_thread.c", 0xCAu, "PICC_awake");
if ( !a1 )
_assert_fail("sched != ((void *)0)", "src/pi_thread.c", 0xCBu, "PICC_awake");
PICC_PiThread_inv(a2);
PICC_Commit_inv(a3);
PICC_acquire(*(_QWORD *)(a2 + 112));
if ( *(_QWORD *)(a2 + 48) != a3 )
{
v6 = 0;
v7 = 0LL;
v8 = 0;
v9 = 0LL;
PICC_init_error(&v6, 28LL, "src/pi_thread.c", 215LL);
PICC_crash(&v6, "src/pi_thread.c", "PICC_awake");
}
while ( !PICC_wait_queue_fetch(a1[1], a2) )
;
*(_QWORD *)(a2 + 48) = 0LL;
*(_DWORD *)(a2 + 72) = *(_DWORD *)(a3 + 28);
*(_DWORD *)a2 = 0;
v4 = PICC_atomic_int_get(**(_QWORD **)(a2 + 96));
if ( v4 == 1000 )
{
PICC_reclaim_clock(*(void **)(a2 + 96));
*(_QWORD *)(a2 + 96) = 0LL;
v6 = 0;
v7 = 0LL;
v8 = 0;
v9 = 0LL;
*(_QWORD *)(a2 + 96) = PICC_create_clock((__int64)&v6);
if ( v6 )
PICC_crash(&v6, "src/pi_thread.c", "PICC_awake");
}
else
{
PICC_atomic_int_compare_and_swap(**(_QWORD **)(a2 + 96), v4, v4 + 1);
}
PICC_PiThread_inv(a2);
if ( *(_QWORD *)(a2 + 48) )
_assert_fail("pt->commit == ((void *)0)", "src/pi_thread.c", 0xF7u, "PICC_awake");
if ( *(_DWORD *)(a2 + 72) != *(_DWORD *)(a3 + 28) )
_assert_fail("pt->pc == commit->cont_pc", "src/pi_thread.c", 0xF8u, "PICC_awake");
if ( *(_DWORD *)a2 )
_assert_fail("pt->status == PICC_STATUS_RUN", "src/pi_thread.c", 0xF9u, "PICC_awake");
if ( (int)PICC_atomic_int_get(**(_QWORD **)(a2 + 96)) > 1000 )
_assert_fail("PICC_atomic_int_get(pt->clock->val) <= PICC_CLOCK_MAX_INT", "src/pi_thread.c", 0xFAu, "PICC_awake");
PICC_release(*(_QWORD *)(a2 + 112));
return PICC_ready_queue_add(*a1, a2);
}

canonical_decompiled_code:
__int64 __fastcall func6(_QWORD *a1, __int64 a2, __int64 a3)
{
unsigned int v4; // eax
int v6; // [rsp+0h] [rbp-38h] BYREF
__int64 v7; // [rsp+8h] [rbp-30h]
int v8; // [rsp+10h] [rbp-28h]
__int64 v9; // [rsp+18h] [rbp-20h]

if ( !a3 )
_assert_fail("commit != ((void *)0)", "src/pi_thread.c", 0xCAu, "PICC_awake");
if ( !a1 )
_assert_fail("sched != ((void *)0)", "src/pi_thread.c", 0xCBu, "PICC_awake");
func4(a2);
PICC_Commit_inv(a3);
PICC_acquire(*(_QWORD *)(a2 + 112));
if ( *(_QWORD *)(a2 + 48) != a3 )
{
v6 = 0;
v7 = 0LL;
v8 = 0;
v9 = 0LL;
PICC_init_error(&v6, 28LL, "src/pi_thread.c", 215LL);
PICC_crash(&v6, "src/pi_thread.c", "PICC_awake");
}
while ( !PICC_wait_queue_fetch(a1[1], a2) )
;
*(_QWORD *)(a2 + 48) = 0LL;
*(_DWORD *)(a2 + 72) = *(_DWORD *)(a3 + 28);
*(_DWORD *)a2 = 0;
v4 = PICC_atomic_int_get(**(_QWORD **)(a2 + 96));
if ( v4 == 1000 )
{
func3(*(void **)(a2 + 96));
*(_QWORD *)(a2 + 96) = 0LL;
v6 = 0;
v7 = 0LL;
v8 = 0;
v9 = 0LL;
*(_QWORD *)(a2 + 96) = PICC_create_clock((__int64)&v6);
if ( v6 )
PICC_crash(&v6, "src/pi_thread.c", "PICC_awake");
}
else
{
PICC_atomic_int_compare_and_swap(**(_QWORD **)(a2 + 96), v4, v4 + 1);
}
func4(a2);
if ( *(_QWORD *)(a2 + 48) )
_assert_fail("pt->commit == ((void *)0)", "src/pi_thread.c", 0xF7u, "PICC_awake");
if ( *(_DWORD *)(a2 + 72) != *(_DWORD *)(a3 + 28) )
_assert_fail("pt->pc == commit->cont_pc", "src/pi_thread.c", 0xF8u, "PICC_awake");
if ( *(_DWORD *)a2 )
_assert_fail("pt->status == PICC_STATUS_RUN", "src/pi_thread.c", 0xF9u, "PICC_awake");
if ( (int)PICC_atomic_int_get(**(_QWORD **)(a2 + 96)) > 1000 )
_assert_fail("PICC_atomic_int_get(pt->clock->val) <= PICC_CLOCK_MAX_INT", "src/pi_thread.c", 0xFAu, "PICC_awake");
PICC_release(*(_QWORD *)(a2 + 112));
return PICC_ready_queue_add(*a1, a2);
}

original_code:
void PICC_awake(PICC_SchedPool *sched, PICC_PiThread *pt, PICC_Commit *commit)
{
        ((commit != ((void *)0)) ? (void) (0) : __assert_fail ("commit != ((void *)0)", "src/pi_thread.c", 202, __extension__ __PRETTY_FUNCTION__));;
        ((sched != ((void *)0)) ? (void) (0) : __assert_fail ("sched != ((void *)0)", "src/pi_thread.c", 203, __extension__ __PRETTY_FUNCTION__));;
        PICC_PiThread_inv(pt);
        PICC_Commit_inv(commit);
    PICC_acquire(pt->lock);
    if (pt->commit != commit) {
        PICC_Error error = (PICC_Error){.id = 0, .file = ((void *)0), .line = 0, .prev = ((void *)0)}; PICC_init_error(&error, ERR_INVALID_COMMIT, "src/pi_thread.c", 215); PICC_crash(&error, "src/pi_thread.c", __FUNCTION__);;
    }
    PICC_PiThread *fetched;
    do {
        fetched = PICC_wait_queue_fetch(sched->wait, pt);
    } while (fetched == ((void *)0));
    pt->commit = ((void *)0);
    pt->pc = commit->cont_pc;
    pt->status = PICC_STATUS_RUN;
    int clock_val = PICC_atomic_int_get(pt->clock->val);
    if (clock_val == PICC_CLOCK_MAX_INT) {
        PICC_reclaim_clock(pt->clock);
        pt->clock = ((void *)0);
        PICC_Error error = (PICC_Error){.id = 0, .file = ((void *)0), .line = 0, .prev = ((void *)0)};
        pt->clock = PICC_create_clock(&error);
        if (error.id > 0) {
            PICC_crash(&error, "src/pi_thread.c", __FUNCTION__);
        }
    } else {
        PICC_atomic_int_compare_and_swap(pt->clock->val, clock_val, clock_val + 1);
    }
        PICC_PiThread_inv(pt);
        ((pt->commit == ((void *)0)) ? (void) (0) : __assert_fail ("pt->commit == ((void *)0)", "src/pi_thread.c", 247, __extension__ __PRETTY_FUNCTION__));;
        ((pt->pc == commit->cont_pc) ? (void) (0) : __assert_fail ("pt->pc == commit->cont_pc", "src/pi_thread.c", 248, __extension__ __PRETTY_FUNCTION__));;
        ((pt->status == PICC_STATUS_RUN) ? (void) (0) : __assert_fail ("pt->status == PICC_STATUS_RUN", "src/pi_thread.c", 249, __extension__ __PRETTY_FUNCTION__));;
        ((PICC_atomic_int_get(pt->clock->val) <= PICC_CLOCK_MAX_INT) ? (void) (0) : __assert_fail ("PICC_atomic_int_get(pt->clock->val) <= PICC_CLOCK_MAX_INT", "src/pi_thread.c", 250, __extension__ __PRETTY_FUNCTION__));;
    PICC_release(pt->lock);
    PICC_ready_queue_add(sched->ready, pt);
}

canonical_original_code:
void PICC_awake(struct _PICC_SchedPool *sched, struct _PICC_PiThread *pt, struct _PICC_Commit *commit)
{
        ((commit != ((void *)0)) ? (void) (0) : __assert_fail ("commit != ((void *)0)", "src/pi_thread.c", 202, __extension__ __PRETTY_FUNCTION__));;
        ((sched != ((void *)0)) ? (void) (0) : __assert_fail ("sched != ((void *)0)", "src/pi_thread.c", 203, __extension__ __PRETTY_FUNCTION__));;
        PICC_PiThread_inv(pt);
        PICC_Commit_inv(commit);
    PICC_acquire(pt->lock);
    if (pt->commit != commit) {
        struct _PICC_Error error = (PICC_Error){.id = 0, .file = ((void *)0), .line = 0, .prev = ((void *)0)}; PICC_init_error(&error, ERR_INVALID_COMMIT, "src/pi_thread.c", 215); PICC_crash(&error, "src/pi_thread.c", __FUNCTION__);;
    }
    struct _PICC_PiThread *fetched;
    do {
        fetched = PICC_wait_queue_fetch(sched->wait, pt);
    } while (fetched == ((void *)0));
    pt->commit = ((void *)0);
    pt->pc = commit->cont_pc;
    pt->status = PICC_STATUS_RUN;
    int clock_val = PICC_atomic_int_get(pt->clock->val);
    if (clock_val == PICC_CLOCK_MAX_INT) {
        PICC_reclaim_clock(pt->clock);
        pt->clock = ((void *)0);
        struct _PICC_Error error = (PICC_Error){.id = 0, .file = ((void *)0), .line = 0, .prev = ((void *)0)};
        pt->clock = PICC_create_clock(&error);
        if (error.id > 0) {
            PICC_crash(&error, "src/pi_thread.c", __FUNCTION__);
        }
    } else {
        PICC_atomic_int_compare_and_swap(pt->clock->val, clock_val, clock_val + 1);
    }
        PICC_PiThread_inv(pt);
        ((pt->commit == ((void *)0)) ? (void) (0) : __assert_fail ("pt->commit == ((void *)0)", "src/pi_thread.c", 247, __extension__ __PRETTY_FUNCTION__));;
        ((pt->pc == commit->cont_pc) ? (void) (0) : __assert_fail ("pt->pc == commit->cont_pc", "src/pi_thread.c", 248, __extension__ __PRETTY_FUNCTION__));;
        ((pt->status == PICC_STATUS_RUN) ? (void) (0) : __assert_fail ("pt->status == PICC_STATUS_RUN", "src/pi_thread.c", 249, __extension__ __PRETTY_FUNCTION__));;
        ((PICC_atomic_int_get(pt->clock->val) <= PICC_CLOCK_MAX_INT) ? (void) (0) : __assert_fail ("PICC_atomic_int_get(pt->clock->val) <= PICC_CLOCK_MAX_INT", "src/pi_thread.c", 250, __extension__ __PRETTY_FUNCTION__));;
    PICC_release(pt->lock);
    PICC_ready_queue_add(sched->ready, pt);
}

variable_types: struct _PICC_SchedPool { struct _PICC_ReadyQueue { struct _PICC_Queue { struct _PICC_QueueCell { struct _PICC_PiThread { enum _PICC_StatusKind { PICC_STATUS_RUN=0, PICC_STATUS_CALL=1, PICC_STATUS_WAIT=2, PICC_STATUS_ENDED=3, PICC_STATUS_BLOCKED=4 } status; _Bool *enabled; int enabled_length; struct _PICC_KnownSet { int max_size; int current_size; struct _PICC_KnownElement { enum _PICC_KnownState { PICC_UNKNOWN=0, PICC_KNOWN=1, PICC_FORGET=2 } state; struct _PICC_KnownValue { unsigned int header; struct _PICC_Handle { int global_rc; union pthread_mutex_t { struct __pthread_mutex_s { int __lock; unsigned int __count; int __owner; unsigned int __nusers; int __kind; short __spins; short __elision; struct __pthread_internal_list { struct __pthread_internal_list *__prev; struct __pthread_internal_list *__next; } __list; } __data; char __size[40]; long __align; } *lock; void (*reclaim)(struct _PICC_Handle *handled, struct _PICC_Error { enum _PICC_ErrorId { ERR_DEAD_CODE_REACHED=0, ERR_DEADLOCK=1, ERR_ALLOC_QUEUE_CELL=2, ERR_READY_QUEUE_PUSH=3, ERR_READY_QUEUE_ADD=4, ERR_WAIT_QUEUE_PUSH=5, ERR_WAIT_QUEUE_ADD=6, ERR_WAIT_QUEUE_PUSH_OLD=7, ERR_NOT_IMPLEMENTED=8, ERR_OUT_OF_MEMORY=9, ERR_COMMIT_CREATE=10, ERR_ADD_COMMIT_TO_LIST=11, ERR_REGISTER_OUT_COMMIT=12, ERR_REGISTER_IN_COMMIT=13, ERR_THREAD_CREATE=14, ERR_THREAD_YIELD=15, ERR_PTHREAD_CREATE=16, ERR_SCHED_POOL_CREATE=17, ERR_CLOCK_CREATE=18, ERR_MUTEX_ALREADY_UNLOCKED=19, ERR_CONDITION_SIGNAL=20, ERR_CONDITION_BROADCAST=21, ERR_NULLPOINTER_PITHREAD=22, ERR_NULLPOINTER_CHANNEL=23, ERR_NULLPOINTER_COMMIT=24, ERR_NULLPOINTER_COMMITLISTELEM=25, ERR_NULLPOINTER_COMMITLIST=26, ERR_CHANNEL_GLOBAL_RC=27, ERR_INVALID_COMMIT=28, ERR_INVALID_VALUE=29, ERR_INVALID_TYPE=30, ERR_INVALID_KNOWNSET_STATE=31 } id; char *file; int line; struct _PICC_Error *prev; } *error); } *handle; } value; } *content; } *knowns; struct _PICC_Value { unsigned int header; void *data; } *env; int env_length; struct _PICC_Commit { enum _PICC_CommitType { PICC_IN_COMMIT=0, PICC_OUT_COMMIT=1 } type; struct _PICC_PiThread *thread; struct _PICC_Clock { struct _PICC_AtomicInt { int val; union pthread_mutex_t lock; } *val; } *clock; int clockval; int cont_pc; struct _PICC_Channel { int global_rc; union pthread_mutex_t *lock; void (*reclaim)(struct _PICC_Handle *handled, struct _PICC_Error *error); struct _PICC_CommitList { struct _PICC_CommitListElement { struct _PICC_Commit *commit; struct _PICC_CommitListElement *next; } *head; struct _PICC_CommitListElement *tail; int size; } *incommits; struct _PICC_CommitList *outcommits; } *channel; union { struct _PICC_InCommit { int refvar; } *in; struct _PICC_OutCommit { struct _PICC_Value (*eval_func)(struct _PICC_PiThread *); } *out; } content; } *commit; struct _PICC_CommitList *commits; void (*proc)(struct _PICC_SchedPool *, struct _PICC_PiThread *); int pc; struct _PICC_Value val; struct _PICC_Clock *clock; int fuel; union pthread_mutex_t *lock; } *thread; struct _PICC_QueueCell *next; } *head; struct _PICC_QueueCell *tail; int size; } q; union pthread_mutex_t *lock; } *ready; struct _PICC_WaitQueue { struct _PICC_Queue active; struct _PICC_Queue old; union pthread_mutex_t *lock; } *wait; union pthread_mutex_t lock; union pthread_cond_t { struct __pthread_cond_s { union { unsigned long long __wseq; struct { unsigned int __low; unsigned int __high; } __wseq32; }; union { unsigned long long __g1_start; struct { unsigned int __low; unsigned int __high; } __g1_start32; }; unsigned int __g_refs[2]; unsigned int __g_size[2]; unsigned int __g1_orig_size; unsigned int __wrefs; unsigned int __g_signals[2]; } __data; char __size[48]; long long __align; } cond; int nb_slaves; int nb_waiting_slaves; _Bool running; } *

variable_types:
pt
struct _PICC_PiThread *

user_defined_types: struct _PICC_SchedPool { struct _PICC_ReadyQueue *ready; struct _PICC_WaitQueue *wait; union pthread_mutex_t lock; union pthread_cond_t cond; int nb_slaves; int nb_waiting_slaves; _Bool running; }

user_defined_types: struct _PICC_PiThread { enum _PICC_StatusKind status; _Bool *enabled; int enabled_length; struct _PICC_KnownSet *knowns; struct _PICC_Value *env; int env_length; struct _PICC_Commit *commit; struct _PICC_CommitList *commits; void (*proc)(struct _PICC_SchedPool *, struct _PICC_PiThread *); int pc; struct _PICC_Value val; struct _PICC_Clock *clock; int fuel; union pthread_mutex_t *lock; }

user_defined_types: struct _PICC_KnownSet { int max_size; int current_size; struct _PICC_KnownElement *content; }

user_defined_types: struct _PICC_Commit { enum _PICC_CommitType type; struct _PICC_PiThread *thread; struct _PICC_Clock *clock; int clockval; int cont_pc; struct _PICC_Channel *channel; union { struct _PICC_InCommit *in; struct _PICC_OutCommit *out; } content; }

user_defined_types: struct _PICC_KnownElement { enum _PICC_KnownState state; struct _PICC_KnownValue value; }

user_defined_types: struct _PICC_Clock { struct _PICC_AtomicInt *val; }

user_defined_types: struct _PICC_Channel { int global_rc; union pthread_mutex_t *lock; void (*reclaim)(struct _PICC_Handle *handled, struct _PICC_Error *error); struct _PICC_CommitList *incommits; struct _PICC_CommitList *outcommits; }

user_defined_types: struct _PICC_QueueCell { struct _PICC_PiThread *thread; struct _PICC_QueueCell *next; }

user_defined_types: struct __pthread_mutex_s { int __lock; unsigned int __count; int __owner; unsigned int __nusers; int __kind; short __spins; short __elision; struct __pthread_internal_list __list; }


original_code:
void test_int(PICC_Error *error)
{
    PICC_Value v, v2, vresult;
    do{ (&v)->header = ((unsigned int) (((TAG_INTEGER) << (32 - 8)) | ((0) & (~(0xFF << (32 - 8) ))))); ((PICC_IntValue*) (&v))->data = (3); }while(0);
    do{ (&v2)->header = ((unsigned int) (((TAG_INTEGER) << (32 - 8)) | ((0) & (~(0xFF << (32 - 8) ))))); ((PICC_IntValue*) (&v2))->data = (4); }while(0);
    do{ (&vresult)->header = ((unsigned int) (((TAG_INTEGER) << (32 - 8)) | ((0) & (~(0xFF << (32 - 8) ))))); ((PICC_IntValue*) (&vresult))->data = (0); }while(0);
    PICC_Int_add(&vresult,&v,&v2);
    PICC_Int_multiply(&vresult,&v,&v2);
    PICC_Int_divide(&vresult,&v,&v2);
    PICC_Int_substract(&vresult,&v,&v2);
    PICC_equals(&vresult, &v, &v2);
    (((((&vresult)->header) & (~(0xFF << (32 - 8) ))) == 0) ? (void) (0) : __assert_fail ("(((&vresult)->header) & (~(0xFF << (32 - 8) ))) == 0", "tests/value_test.c", 33, __extension__ __PRETTY_FUNCTION__));;
    do{ (&v2)->header = ((unsigned int) (((TAG_INTEGER) << (32 - 8)) | ((0) & (~(0xFF << (32 - 8) ))))); ((PICC_IntValue*) (&v2))->data = (3); }while(0);
    PICC_equals(&vresult, &v, &v2);
    (((((&vresult)->header) & (~(0xFF << (32 - 8) ))) == 1) ? (void) (0) : __assert_fail ("(((&vresult)->header) & (~(0xFF << (32 - 8) ))) == 1", "tests/value_test.c", 39, __extension__ __PRETTY_FUNCTION__));;
}

canonical_original_code:
void test_int(struct _PICC_Error *error)
{
    struct _PICC_Value v; struct _PICC_Value v2; struct _PICC_Value vresult;
    do{ (&v)->header = ((unsigned int) (((TAG_INTEGER) << (32 - 8)) | ((0) & (~(0xFF << (32 - 8) ))))); ((struct _int_value_t *) (&v))->data = (3); }while(0);
    do{ (&v2)->header = ((unsigned int) (((TAG_INTEGER) << (32 - 8)) | ((0) & (~(0xFF << (32 - 8) ))))); ((struct _int_value_t *) (&v2))->data = (4); }while(0);
    do{ (&vresult)->header = ((unsigned int) (((TAG_INTEGER) << (32 - 8)) | ((0) & (~(0xFF << (32 - 8) ))))); ((struct _int_value_t *) (&vresult))->data = (0); }while(0);
    PICC_Int_add(&vresult,&v,&v2);
    PICC_Int_multiply(&vresult,&v,&v2);
    PICC_Int_divide(&vresult,&v,&v2);
    PICC_Int_substract(&vresult,&v,&v2);
    PICC_equals(&vresult, &v, &v2);
    (((((&vresult)->header) & (~(0xFF << (32 - 8) ))) == 0) ? (void) (0) : __assert_fail ("(((&vresult)->header) & (~(0xFF << (32 - 8) ))) == 0", "tests/value_test.c", 33, __extension__ __PRETTY_FUNCTION__));;
    do{ (&v2)->header = ((unsigned int) (((TAG_INTEGER) << (32 - 8)) | ((0) & (~(0xFF << (32 - 8) ))))); ((struct _int_value_t *) (&v2))->data = (3); }while(0);
    PICC_equals(&vresult, &v, &v2);
    (((((&vresult)->header) & (~(0xFF << (32 - 8) ))) == 1) ? (void) (0) : __assert_fail ("(((&vresult)->header) & (~(0xFF << (32 - 8) ))) == 1", "tests/value_test.c", 39, __extension__ __PRETTY_FUNCTION__));;
}

variable_types: struct _PICC_Value { unsigned int header; void *data; }

user_defined_types: struct _int_value_t { unsigned int header; int data; }

user_defined_types: enum _PICC_ErrorId { ERR_DEAD_CODE_REACHED=0, ERR_DEADLOCK=1, ERR_ALLOC_QUEUE_CELL=2, ERR_READY_QUEUE_PUSH=3, ERR_READY_QUEUE_ADD=4, ERR_WAIT_QUEUE_PUSH=5, ERR_WAIT_QUEUE_ADD=6, ERR_WAIT_QUEUE_PUSH_OLD=7, ERR_NOT_IMPLEMENTED=8, ERR_OUT_OF_MEMORY=9, ERR_COMMIT_CREATE=10, ERR_ADD_COMMIT_TO_LIST=11, ERR_REGISTER_OUT_COMMIT=12, ERR_REGISTER_IN_COMMIT=13, ERR_THREAD_CREATE=14, ERR_THREAD_YIELD=15, ERR_PTHREAD_CREATE=16, ERR_SCHED_POOL_CREATE=17, ERR_CLOCK_CREATE=18, ERR_MUTEX_ALREADY_UNLOCKED=19, ERR_CONDITION_SIGNAL=20, ERR_CONDITION_BROADCAST=21, ERR_NULLPOINTER_PITHREAD=22, ERR_NULLPOINTER_CHANNEL=23, ERR_NULLPOINTER_COMMIT=24, ERR_NULLPOINTER_COMMITLISTELEM=25, ERR_NULLPOINTER_COMMITLIST=26, ERR_CHANNEL_GLOBAL_RC=27, ERR_INVALID_COMMIT=28, ERR_INVALID_VALUE=29, ERR_INVALID_TYPE=30, ERR_INVALID_KNOWNSET_STATE=31 }


decompiled_code:
__int64 test_bool()
{
__int64 v0; // rbp
__int64 v1; // rbx
__int64 v2; // rbp
__int64 v3; // rbp
__int64 result; // rax
__int64 v5[4]; // [rsp+8h] [rbp-20h] BYREF

v5[0] = PICC_create_bool_value(1LL);
v0 = PICC_create_bool_value(0LL);
v1 = PICC_create_bool_value(0LL);
PICC_Bool_and(v1, v5[0], v0);
PICC_Bool_or(v1, v5[0], v0);
PICC_Bool_xor(v1, v5[0], v0);
PICC_Bool_not(v1, v5[0]);
v5[0] = PICC_create_bool_value(0LL);
v2 = PICC_create_bool_value(0LL);
PICC_Bool_and(v1, v5[0], v2);
PICC_Bool_or(v1, v5[0], v2);
PICC_Bool_xor(v1, v5[0], v2);
v5[0] = PICC_create_bool_value(0LL);
v3 = PICC_create_bool_value(1LL);
PICC_Bool_and(v1, v5[0], v3);
PICC_Bool_or(v1, v5[0], v3);
PICC_Bool_xor(v1, v5[0], v3);
PICC_Bool_not(v1, v5[0]);
if ( !(unsigned __int8)PICC_copy_value(v5, v3) )
_assert_fail("PICC_copy_value(&b, b2)", "tests/value_test.c", 0x44u, "test_bool");
PICC_Bool_not(v1, v5[0]);
result = PICC_copy_value(v5, v1);
if ( !(_BYTE)result )
_assert_fail("PICC_copy_value(&b, result)", "tests/value_test.c", 0x48u, "test_bool");
return result;
}

canonical_decompiled_code:
__int64 func1()
{
__int64 v0; // rbp
__int64 v1; // rbx
__int64 v2; // rbp
__int64 v3; // rbp
__int64 result; // rax
__int64 v5[4]; // [rsp+8h] [rbp-20h] BYREF

v5[0] = PICC_create_bool_value(1LL);
v0 = PICC_create_bool_value(0LL);
v1 = PICC_create_bool_value(0LL);
PICC_Bool_and(v1, v5[0], v0);
PICC_Bool_or(v1, v5[0], v0);
PICC_Bool_xor(v1, v5[0], v0);
PICC_Bool_not(v1, v5[0]);
v5[0] = PICC_create_bool_value(0LL);
v2 = PICC_create_bool_value(0LL);
PICC_Bool_and(v1, v5[0], v2);
PICC_Bool_or(v1, v5[0], v2);
PICC_Bool_xor(v1, v5[0], v2);
v5[0] = PICC_create_bool_value(0LL);
v3 = PICC_create_bool_value(1LL);
PICC_Bool_and(v1, v5[0], v3);
PICC_Bool_or(v1, v5[0], v3);
PICC_Bool_xor(v1, v5[0], v3);
PICC_Bool_not(v1, v5[0]);
if ( !(unsigned __int8)PICC_copy_value(v5, v3) )
_assert_fail("PICC_copy_value(&b, b2)", "tests/value_test.c", 0x44u, "test_bool");
PICC_Bool_not(v1, v5[0]);
result = PICC_copy_value(v5, v1);
if ( !(_BYTE)result )
_assert_fail("PICC_copy_value(&b, result)", "tests/value_test.c", 0x48u, "test_bool");
return result;
}

original_code:
void test_bool(PICC_Error *error)
{
    PICC_Value *b = PICC_create_bool_value(1);
    PICC_Value *b2 = PICC_create_bool_value(0);
    PICC_Value *result = PICC_create_bool_value(0);
    PICC_Bool_and(result,b,b2);
    PICC_Bool_or(result,b,b2);
    PICC_Bool_xor(result,b,b2);
    PICC_Bool_not(result,b);
    b = PICC_create_bool_value(0);
    b2 = PICC_create_bool_value(0);
    PICC_Bool_and(result,b,b2);
    PICC_Bool_or(result,b,b2);
    PICC_Bool_xor(result,b,b2);
    b = PICC_create_bool_value(0);
    b2 = PICC_create_bool_value(1);
    PICC_Bool_and(result,b,b2);
    PICC_Bool_or(result,b,b2);
    PICC_Bool_xor(result,b,b2);
    PICC_Bool_not(result,b);
    ((PICC_copy_value(&b, b2)) ? (void) (0) : __assert_fail ("PICC_copy_value(&b, b2)", "tests/value_test.c", 68, __extension__ __PRETTY_FUNCTION__));;
    PICC_Bool_not(result,b);
    ((PICC_copy_value(&b, result)) ? (void) (0) : __assert_fail ("PICC_copy_value(&b, result)", "tests/value_test.c", 72, __extension__ __PRETTY_FUNCTION__));;
}

canonical_original_code:
void test_bool(struct _PICC_Error *error)
{
    struct _PICC_Value *b = PICC_create_bool_value(1);
    struct _PICC_Value *b2 = PICC_create_bool_value(0);
    struct _PICC_Value *result = PICC_create_bool_value(0);
    PICC_Bool_and(result,b,b2);
    PICC_Bool_or(result,b,b2);
    PICC_Bool_xor(result,b,b2);
    PICC_Bool_not(result,b);
    b = PICC_create_bool_value(0);
    b2 = PICC_create_bool_value(0);
    PICC_Bool_and(result,b,b2);
    PICC_Bool_or(result,b,b2);
    PICC_Bool_xor(result,b,b2);
    b = PICC_create_bool_value(0);
    b2 = PICC_create_bool_value(1);
    PICC_Bool_and(result,b,b2);
    PICC_Bool_or(result,b,b2);
    PICC_Bool_xor(result,b,b2);
    PICC_Bool_not(result,b);
    ((PICC_copy_value(&b, b2)) ? (void) (0) : __assert_fail ("PICC_copy_value(&b, b2)", "tests/value_test.c", 68, __extension__ __PRETTY_FUNCTION__));;
    PICC_Bool_not(result,b);
    ((PICC_copy_value(&b, result)) ? (void) (0) : __assert_fail ("PICC_copy_value(&b, result)", "tests/value_test.c", 72, __extension__ __PRETTY_FUNCTION__));;
}

variable_types: struct _PICC_Value { unsigned int header; void *data; } *


decompiled_code:
__int64 test_string()
{
__int64 v0; // rbp
__int64 v1; // rbx
__int64 v3[4]; // [rsp+8h] [rbp-20h] BYREF

v0 = PICC_create_string_value("test");
v1 = PICC_create_string_value("test2");
v3[0] = PICC_create_empty_string_value();
if ( !(unsigned __int8)PICC_copy_value(v3, v1) )
_assert_fail("PICC_copy_value(&result, s2)", "tests/value_test.c", 0x51u, "test_string");
if ( !(unsigned __int8)PICC_copy_value(v3, v0) )
_assert_fail("PICC_copy_value(&result, s)", "tests/value_test.c", 0x52u, "test_string");
v3[0] = PICC_create_empty_string_value();
return PICC_free_value(v3[0]);
}

canonical_decompiled_code:
__int64 func2()
{
__int64 v0; // rbp
__int64 v1; // rbx
__int64 v3[4]; // [rsp+8h] [rbp-20h] BYREF

v0 = PICC_create_string_value("test");
v1 = PICC_create_string_value("test2");
v3[0] = PICC_create_empty_string_value();
if ( !(unsigned __int8)PICC_copy_value(v3, v1) )
_assert_fail("PICC_copy_value(&result, s2)", "tests/value_test.c", 0x51u, "test_string");
if ( !(unsigned __int8)PICC_copy_value(v3, v0) )
_assert_fail("PICC_copy_value(&result, s)", "tests/value_test.c", 0x52u, "test_string");
v3[0] = PICC_create_empty_string_value();
return PICC_free_value(v3[0]);
}

original_code:
void test_string(PICC_Error *error)
{
    PICC_Value *s = PICC_create_string_value("test");
    PICC_Value *s2 = PICC_create_string_value("test2");
    PICC_Value *result = (PICC_Value *) PICC_create_empty_string_value();
    ((PICC_copy_value(&result, s2)) ? (void) (0) : __assert_fail ("PICC_copy_value(&result, s2)", "tests/value_test.c", 81, __extension__ __PRETTY_FUNCTION__));;
    ((PICC_copy_value(&result, s)) ? (void) (0) : __assert_fail ("PICC_copy_value(&result, s)", "tests/value_test.c", 82, __extension__ __PRETTY_FUNCTION__));;
    result = (PICC_Value *) PICC_create_empty_string_value();
    PICC_free_value(result);
}

canonical_original_code:
void test_string(struct _PICC_Error *error)
{
    struct _PICC_Value *s = PICC_create_string_value("test");
    struct _PICC_Value *s2 = PICC_create_string_value("test2");
    struct _PICC_Value *result = (PICC_Value *) PICC_create_empty_string_value();
    ((PICC_copy_value(&result, s2)) ? (void) (0) : __assert_fail ("PICC_copy_value(&result, s2)", "tests/value_test.c", 81, __extension__ __PRETTY_FUNCTION__));;
    ((PICC_copy_value(&result, s)) ? (void) (0) : __assert_fail ("PICC_copy_value(&result, s)", "tests/value_test.c", 82, __extension__ __PRETTY_FUNCTION__));;
    result = (struct _PICC_Value *) PICC_create_empty_string_value();
    PICC_free_value(result);
}

user_defined_types: struct _PICC_Value { unsigned int header; void *data; }


decompiled_code:
__int64 PICC_test_value()
{
__int64 result; // rax
int v1; // [rsp+0h] [rbp-28h] BYREF
__int64 v2; // [rsp+8h] [rbp-20h]
int v3; // [rsp+10h] [rbp-18h]
__int64 v4; // [rsp+18h] [rbp-10h]

v1 = 0;
v2 = 0LL;
v3 = 0;
v4 = 0LL;
test_int(&v1);
test_bool(&v1);
test_string(&v1);
test_tuples(&v1);
result = test_channels(&v1);
if ( v1 )
result = PICC_print_error(&v1, "tests/value_test.c", "PICC_test_value");
return result;
}

canonical_decompiled_code:
__int64 func5()
{
__int64 result; // rax
int v1; // [rsp+0h] [rbp-28h] BYREF
__int64 v2; // [rsp+8h] [rbp-20h]
int v3; // [rsp+10h] [rbp-18h]
__int64 v4; // [rsp+18h] [rbp-10h]

v1 = 0;
v2 = 0LL;
v3 = 0;
v4 = 0LL;
func0(&v1);
func1(&v1);
func2(&v1);
func3(&v1);
result = func4(&v1);
if ( v1 )
result = PICC_print_error(&v1, "tests/value_test.c", "PICC_test_value");
return result;
}

original_code:
void PICC_test_value()
{
    PICC_Error error = (PICC_Error){.id = 0, .file = ((void *)0), .line = 0, .prev = ((void *)0)};
    test_int(&error);
    test_bool(&error);
    test_string(&error);
    test_tuples(&error);
    test_channels(&error);
    if (error.id > 0)
        PICC_print_error(&error, "tests/value_test.c", __FUNCTION__);
}

canonical_original_code:
void PICC_test_value()
{
    struct _PICC_Error error = (PICC_Error){.id = 0, .file = ((void *)0), .line = 0, .prev = ((void *)0)};
    test_int(&error);
    test_bool(&error);
    test_string(&error);
    test_tuples(&error);
    test_channels(&error);
    if (error.id > 0)
        PICC_print_error(&error, "tests/value_test.c", __FUNCTION__);
}


decompiled_code:
void __fastcall PICC_lock_free(void *ptr)
{
pthread_mutex_destroy((pthread_mutex_t *)ptr);
free(ptr);
}

canonical_decompiled_code:
void __fastcall func0(void *ptr)
{
pthread_mutex_destroy((pthread_mutex_t *)ptr);
free(ptr);
}

original_code:
void PICC_lock_free(PICC_Lock *l){
    pthread_mutex_destroy(l);
    free(l);
}

canonical_original_code:
void PICC_lock_free(union pthread_mutex_t *l){
    pthread_mutex_destroy(l);
    free(l);
}

variable_types: union pthread_mutex_t { struct __pthread_mutex_s { int __lock; unsigned int __count; int __owner; unsigned int __nusers; int __kind; short __spins; short __elision; struct __pthread_internal_list { struct __pthread_internal_list *__prev; struct __pthread_internal_list *__next; } __list; } __data; char __size[40]; long __align; } *


decompiled_code:
int __fastcall PICC_init_lock(pthread_mutex_t *a1)
{
if ( !a1 )
_assert_fail("lock != ((void *)0)", "src/concurrent.c", 0x2Au, "PICC_init_lock");
return pthread_mutex_init(a1, 0LL);
}

canonical_decompiled_code:
int __fastcall func1(pthread_mutex_t *a1)
{
if ( !a1 )
_assert_fail("lock != ((void *)0)", "src/concurrent.c", 0x2Au, "PICC_init_lock");
return pthread_mutex_init(a1, 0LL);
}

original_code:
void PICC_init_lock(PICC_Lock *lock)
{
        ((lock != ((void *)0)) ? (void) (0) : __assert_fail ("lock != ((void *)0)", "src/concurrent.c", 42, __extension__ __PRETTY_FUNCTION__));;
    pthread_mutex_init(lock, ((void *)0));
}

canonical_original_code:
void PICC_init_lock(union pthread_mutex_t *lock)
{
        ((lock != ((void *)0)) ? (void) (0) : __assert_fail ("lock != ((void *)0)", "src/concurrent.c", 42, __extension__ __PRETTY_FUNCTION__));;
    pthread_mutex_init(lock, ((void *)0));
}

user_defined_types: struct __pthread_internal_list { struct __pthread_internal_list *__prev; struct __pthread_internal_list *__next; }