decompiled_code:
__int64 test_types()
{
__int64 result; // rax

if ( (unsigned int)est_fonction(1LL) )
_assert_fail("est_fonction(Variable) == 0", "test_types.c", 0x10u, "test_types");
if ( (unsigned int)est_fonction(2LL) )
_assert_fail("est_fonction(Constante) == 0", "test_types.c", 0x11u, "test_types");
if ( (unsigned int)est_fonction(30LL) != 1 )
_assert_fail("est_fonction(Fonction) == 1", "test_types.c", 0x12u, "test_types");
if ( (unsigned int)est_fonction(33LL) != 1 )
_assert_fail("est_fonction(Fonction+3) == 1", "test_types.c", 0x13u, "test_types");
if ( (unsigned int)est_fonction(29LL) )
_assert_fail("est_fonction(Fonction-1) == 0", "test_types.c", 0x14u, "test_types");
result = est_fonction(34LL);
if ( (_DWORD)result )
_assert_fail("est_fonction(Fonction+4) == 0", "test_types.c", 0x15u, "test_types");
return result;
}

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

if ( (unsigned int)est_fonction(1LL) )
_assert_fail("est_fonction(Variable) == 0", "test_types.c", 0x10u, "test_types");
if ( (unsigned int)est_fonction(2LL) )
_assert_fail("est_fonction(Constante) == 0", "test_types.c", 0x11u, "test_types");
if ( (unsigned int)est_fonction(30LL) != 1 )
_assert_fail("est_fonction(Fonction) == 1", "test_types.c", 0x12u, "test_types");
if ( (unsigned int)est_fonction(33LL) != 1 )
_assert_fail("est_fonction(Fonction+3) == 1", "test_types.c", 0x13u, "test_types");
if ( (unsigned int)est_fonction(29LL) )
_assert_fail("est_fonction(Fonction-1) == 0", "test_types.c", 0x14u, "test_types");
result = est_fonction(34LL);
if ( (_DWORD)result )
_assert_fail("est_fonction(Fonction+4) == 0", "test_types.c", 0x15u, "test_types");
return result;
}

original_code:
void test_types(void)
{
 ((void) sizeof ((est_fonction(Variable) == 0) ? 1 : 0), __extension__ ({ if (est_fonction(Variable) == 0) ; else __assert_fail ("est_fonction(Variable) == 0", "test_types.c", 16, __extension__ __PRETTY_FUNCTION__); }));
 ((void) sizeof ((est_fonction(Constante) == 0) ? 1 : 0), __extension__ ({ if (est_fonction(Constante) == 0) ; else __assert_fail ("est_fonction(Constante) == 0", "test_types.c", 17, __extension__ __PRETTY_FUNCTION__); }));
 ((void) sizeof ((est_fonction(Fonction) == 1) ? 1 : 0), __extension__ ({ if (est_fonction(Fonction) == 1) ; else __assert_fail ("est_fonction(Fonction) == 1", "test_types.c", 18, __extension__ __PRETTY_FUNCTION__); }));
 ((void) sizeof ((est_fonction(Fonction+3) == 1) ? 1 : 0), __extension__ ({ if (est_fonction(Fonction+3) == 1) ; else __assert_fail ("est_fonction(Fonction+3) == 1", "test_types.c", 19, __extension__ __PRETTY_FUNCTION__); }));
 ((void) sizeof ((est_fonction(Fonction-1) == 0) ? 1 : 0), __extension__ ({ if (est_fonction(Fonction-1) == 0) ; else __assert_fail ("est_fonction(Fonction-1) == 0", "test_types.c", 20, __extension__ __PRETTY_FUNCTION__); }));
 ((void) sizeof ((est_fonction(Fonction+4) == 0) ? 1 : 0), __extension__ ({ if (est_fonction(Fonction+4) == 0) ; else __assert_fail ("est_fonction(Fonction+4) == 0", "test_types.c", 21, __extension__ __PRETTY_FUNCTION__); }));
}

canonical_original_code:
void test_types()
{
 ((void) sizeof ((est_fonction(Variable) == 0) ? 1 : 0), __extension__ ({ if (est_fonction(Variable) == 0) ; else __assert_fail ("est_fonction(Variable) == 0", "test_types.c", 16, __extension__ __PRETTY_FUNCTION__); }));
 ((void) sizeof ((est_fonction(Constante) == 0) ? 1 : 0), __extension__ ({ if (est_fonction(Constante) == 0) ; else __assert_fail ("est_fonction(Constante) == 0", "test_types.c", 17, __extension__ __PRETTY_FUNCTION__); }));
 ((void) sizeof ((est_fonction(Fonction) == 1) ? 1 : 0), __extension__ ({ if (est_fonction(Fonction) == 1) ; else __assert_fail ("est_fonction(Fonction) == 1", "test_types.c", 18, __extension__ __PRETTY_FUNCTION__); }));
 ((void) sizeof ((est_fonction(Fonction+3) == 1) ? 1 : 0), __extension__ ({ if (est_fonction(Fonction+3) == 1) ; else __assert_fail ("est_fonction(Fonction+3) == 1", "test_types.c", 19, __extension__ __PRETTY_FUNCTION__); }));
 ((void) sizeof ((est_fonction(Fonction-1) == 0) ? 1 : 0), __extension__ ({ if (est_fonction(Fonction-1) == 0) ; else __assert_fail ("est_fonction(Fonction-1) == 0", "test_types.c", 20, __extension__ __PRETTY_FUNCTION__); }));
 ((void) sizeof ((est_fonction(Fonction+4) == 0) ? 1 : 0), __extension__ ({ if (est_fonction(Fonction+4) == 0) ; else __assert_fail ("est_fonction(Fonction+4) == 0", "test_types.c", 21, __extension__ __PRETTY_FUNCTION__); }));
}


decompiled_code:
int test_affichage()
{
__int64 v0; // rax
__int64 v1; // rax
__int64 v2; // rax
__int64 v3; // rax
__int64 v4; // rax
__int64 v5; // rax
__int64 v6; // rax
__int64 v7; // rax

puts("Comparer X1=2 avec:");
v0 = creer_systeme_depuis_texte("X1=2");
afficher_systeme(v0);
puts("Comparer X1=F2(X2),X2=3 avec:");
v1 = creer_systeme_depuis_texte("X1=F2(X2),X2=3");
afficher_systeme(v1);
puts("Comparer X3 avec:");
v2 = text_creer_depuis_texte("X3");
v3 = parse_terme(v2);
afficher_terme(v3);
puts(&byte_127);
puts("Comparer F3(X1,X2,3230987) avec:");
v4 = text_creer_depuis_texte("F3(X1,X2,3230987)");
v5 = parse_terme(v4);
afficher_terme(v5);
puts(&byte_127);
puts("Comparer X1,X2,3230987 avec:");
v6 = text_creer_depuis_texte("X1,X2,3230987");
v7 = parse_arguments(v6);
afficher_argument(v7);
return puts(&byte_127);
}

canonical_decompiled_code:
int func0()
{
__int64 v0; // rax
__int64 v1; // rax
__int64 v2; // rax
__int64 v3; // rax
__int64 v4; // rax
__int64 v5; // rax
__int64 v6; // rax
__int64 v7; // rax

puts("Comparer X1=2 avec:");
v0 = creer_systeme_depuis_texte("X1=2");
afficher_systeme(v0);
puts("Comparer X1=F2(X2),X2=3 avec:");
v1 = creer_systeme_depuis_texte("X1=F2(X2),X2=3");
afficher_systeme(v1);
puts("Comparer X3 avec:");
v2 = text_creer_depuis_texte("X3");
v3 = parse_terme(v2);
afficher_terme(v3);
puts(&byte_127);
puts("Comparer F3(X1,X2,3230987) avec:");
v4 = text_creer_depuis_texte("F3(X1,X2,3230987)");
v5 = parse_terme(v4);
afficher_terme(v5);
puts(&byte_127);
puts("Comparer X1,X2,3230987 avec:");
v6 = text_creer_depuis_texte("X1,X2,3230987");
v7 = parse_arguments(v6);
afficher_argument(v7);
return puts(&byte_127);
}

original_code:
void test_affichage(void)
{
 puts("Comparer X1=2 avec:");
 afficher_systeme(creer_systeme_depuis_texte("X1=2"));
 puts("Comparer X1=F2(X2),X2=3 avec:");
 afficher_systeme(creer_systeme_depuis_texte("X1=F2(X2),X2=3"));
 puts("Comparer X3 avec:");
 afficher_terme(parse_terme(text_creer_depuis_texte("X3")));
 puts("");
 puts("Comparer F3(X1,X2,3230987) avec:");
 afficher_terme(parse_terme(text_creer_depuis_texte("F3(X1,X2,3230987)")));
 puts("");
 puts("Comparer X1,X2,3230987 avec:");
 afficher_argument(parse_arguments(text_creer_depuis_texte("X1,X2,3230987")));
 puts("");
}

canonical_original_code:
void test_affichage()
{
 puts("Comparer X1=2 avec:");
 afficher_systeme(creer_systeme_depuis_texte("X1=2"));
 puts("Comparer X1=F2(X2),X2=3 avec:");
 afficher_systeme(creer_systeme_depuis_texte("X1=F2(X2),X2=3"));
 puts("Comparer X3 avec:");
 afficher_terme(parse_terme(text_creer_depuis_texte("X3")));
 puts("");
 puts("Comparer F3(X1,X2,3230987) avec:");
 afficher_terme(parse_terme(text_creer_depuis_texte("F3(X1,X2,3230987)")));
 puts("");
 puts("Comparer X1,X2,3230987 avec:");
 afficher_argument(parse_arguments(text_creer_depuis_texte("X1,X2,3230987")));
 puts("");
}

return_type: void


decompiled_code:
__int64 test_resolution()
{
__int64 v0; // rax
__int64 v1; // rax
__int64 v2; // rax
__int64 v3; // rax
__int64 v4; // rax
__int64 v5; // rax
__int64 v6; // rax
__int64 v7; // rbp
__int64 v8; // rax
__int64 v9; // rax
__int64 v10; // rbp
__int64 v11; // rax
__int64 v12; // rax
__int64 v13; // rbp
__int64 v14; // rax
__int64 v15; // rbp
__int64 v16; // rax
__int64 result; // rax
char v18[4]; // [rsp+Ch] [rbp-1Ch] BYREF
char v19[8]; // [rsp+10h] [rbp-18h] BYREF
char v20[16]; // [rsp+18h] [rbp-10h] BYREF

if ( traiter_systeme(0LL, 0LL) )
_assert_fail("traiter_systeme(NULL, NULL) == NULL", "test_resolution.c", 0x15u, "test_resolution");
v0 = creer_systeme_depuis_texte("X1=34");
if ( !traiter_systeme(v0, 0LL) )
_assert_fail(
"traiter_systeme(creer_systeme_depuis_texte(\"X1=34\"), NULL) != NULL",
"test_resolution.c",
0x16u,
"test_resolution");
if ( traiter_systeme(0LL, v18) )
_assert_fail("traiter_systeme(NULL, &err) == NULL", "test_resolution.c", 0x17u, "test_resolution");
v1 = creer_systeme_depuis_texte("X1=34");
if ( !traiter_systeme(v1, v18) )
_assert_fail(
"traiter_systeme(creer_systeme_depuis_texte(\"X1=34\"), &err) != NULL",
"test_resolution.c",
0x18u,
"test_resolution");
v2 = creer_systeme_depuis_texte("X1=34,X1=2");
if ( traiter_systeme(v2, v18) )
_assert_fail(
"traiter_systeme(creer_systeme_depuis_texte(\"X1=34,X1=2\"), &err) == NULL",
"test_resolution.c",
0x19u,
"test_resolution");
if ( (unsigned int)traiter_equation(0LL, 0LL, 0LL, 0LL) != -2 )
_assert_fail("traiter_equation(NULL, NULL, NULL, NULL) == -2", "test_resolution.c", 0x1Cu, "test_resolution");
v3 = creer_solutions();
if ( (unsigned int)traiter_equation(v3, 0LL, 0LL, 0LL) != -2 )
_assert_fail(
"traiter_equation(creer_solutions(), NULL, NULL, NULL) == -2",
"test_resolution.c",
0x1Du,
"test_resolution");
v4 = text_creer_depuis_texte("X1=2");
v5 = parse_equation(v4);
if ( (unsigned int)traiter_equation(0LL, v5, 0LL, 0LL) != -2 )
_assert_fail(
"traiter_equation(NULL, parse_equation(text_creer_depuis_texte(\"X1=2\")), NULL, NULL) == -2",
"test_resolution.c",
0x1Eu,
"test_resolution");
v6 = text_creer_depuis_texte("X1=2");
v7 = parse_equation(v6);
v8 = creer_solutions();
if ( (unsigned int)traiter_equation(v8, v7, 0LL, 0LL) != -2 )
_assert_fail(
"traiter_equation(creer_solutions(), parse_equation(text_creer_depuis_texte(\"X1=2\")), NULL, NULL) == -2",
"test_resolution.c",
0x1Fu,
"test_resolution");
v9 = text_creer_depuis_texte("X1=2");
v10 = parse_equation(v9);
v11 = creer_solutions();
if ( (unsigned int)traiter_equation(v11, v10, v19, v20) )
_assert_fail(
"traiter_equation(creer_solutions(), parse_equation(text_creer_depuis_texte(\"X1=2\")), &dansSys, &dansSolu) == 0",
"test_resolution.c",
0x20u,
"test_resolution");
v12 = text_creer_depuis_texte("X1=2,X1=3");
v13 = parse_equation(v12);
v14 = creer_solutions();
if ( (unsigned int)traiter_equation(v14, v13, v19, v20) != -2 )
_assert_fail(
"traiter_equation(creer_solutions(), parse_equation(text_creer_depuis_texte(\"X1=2,X1=3\")), &dansSys, &dansSolu) == -2",
"test_resolution.c",
0x21u,
"test_resolution");
if ( (unsigned int)contient_terme(0LL, 0LL) )
_assert_fail("contient_terme(NULL, NULL) == 0", "test_resolution.c", 0x23u, "test_resolution");
v15 = creer_terme();
v16 = creer_terme();
if ( (unsigned int)contient_terme(v16, v15) )
_assert_fail("contient_terme(creer_terme(), creer_terme()) == 0", "test_resolution.c", 0x24u, "test_resolution");
if ( decapsuler_fonctions(0LL, 0LL) )
_assert_fail("decapsuler_fonctions(NULL, NULL) == NULL", "test_resolution.c", 0x25u, "test_resolution");
if ( (unsigned int)compter_arguments(0LL) != -1 )
_assert_fail("compter_arguments(NULL) == -1", "test_resolution.c", 0x26u, "test_resolution");
result = id_fonction(0LL);
if ( (_DWORD)result != -1 )
_assert_fail("id_fonction(NULL) == -1", "test_resolution.c", 0x27u, "test_resolution");
return result;
}

canonical_decompiled_code:
__int64 func0()
{
__int64 v0; // rax
__int64 v1; // rax
__int64 v2; // rax
__int64 v3; // rax
__int64 v4; // rax
__int64 v5; // rax
__int64 v6; // rax
__int64 v7; // rbp
__int64 v8; // rax
__int64 v9; // rax
__int64 v10; // rbp
__int64 v11; // rax
__int64 v12; // rax
__int64 v13; // rbp
__int64 v14; // rax
__int64 v15; // rbp
__int64 v16; // rax
__int64 result; // rax
char v18[4]; // [rsp+Ch] [rbp-1Ch] BYREF
char v19[8]; // [rsp+10h] [rbp-18h] BYREF
char v20[16]; // [rsp+18h] [rbp-10h] BYREF

if ( traiter_systeme(0LL, 0LL) )
_assert_fail("traiter_systeme(NULL, NULL) == NULL", "test_resolution.c", 0x15u, "test_resolution");
v0 = creer_systeme_depuis_texte("X1=34");
if ( !traiter_systeme(v0, 0LL) )
_assert_fail(
"traiter_systeme(creer_systeme_depuis_texte(\"X1=34\"), NULL) != NULL",
"test_resolution.c",
0x16u,
"test_resolution");
if ( traiter_systeme(0LL, v18) )
_assert_fail("traiter_systeme(NULL, &err) == NULL", "test_resolution.c", 0x17u, "test_resolution");
v1 = creer_systeme_depuis_texte("X1=34");
if ( !traiter_systeme(v1, v18) )
_assert_fail(
"traiter_systeme(creer_systeme_depuis_texte(\"X1=34\"), &err) != NULL",
"test_resolution.c",
0x18u,
"test_resolution");
v2 = creer_systeme_depuis_texte("X1=34,X1=2");
if ( traiter_systeme(v2, v18) )
_assert_fail(
"traiter_systeme(creer_systeme_depuis_texte(\"X1=34,X1=2\"), &err) == NULL",
"test_resolution.c",
0x19u,
"test_resolution");
if ( (unsigned int)traiter_equation(0LL, 0LL, 0LL, 0LL) != -2 )
_assert_fail("traiter_equation(NULL, NULL, NULL, NULL) == -2", "test_resolution.c", 0x1Cu, "test_resolution");
v3 = creer_solutions();
if ( (unsigned int)traiter_equation(v3, 0LL, 0LL, 0LL) != -2 )
_assert_fail(
"traiter_equation(creer_solutions(), NULL, NULL, NULL) == -2",
"test_resolution.c",
0x1Du,
"test_resolution");
v4 = text_creer_depuis_texte("X1=2");
v5 = parse_equation(v4);
if ( (unsigned int)traiter_equation(0LL, v5, 0LL, 0LL) != -2 )
_assert_fail(
"traiter_equation(NULL, parse_equation(text_creer_depuis_texte(\"X1=2\")), NULL, NULL) == -2",
"test_resolution.c",
0x1Eu,
"test_resolution");
v6 = text_creer_depuis_texte("X1=2");
v7 = parse_equation(v6);
v8 = creer_solutions();
if ( (unsigned int)traiter_equation(v8, v7, 0LL, 0LL) != -2 )
_assert_fail(
"traiter_equation(creer_solutions(), parse_equation(text_creer_depuis_texte(\"X1=2\")), NULL, NULL) == -2",
"test_resolution.c",
0x1Fu,
"test_resolution");
v9 = text_creer_depuis_texte("X1=2");
v10 = parse_equation(v9);
v11 = creer_solutions();
if ( (unsigned int)traiter_equation(v11, v10, v19, v20) )
_assert_fail(
"traiter_equation(creer_solutions(), parse_equation(text_creer_depuis_texte(\"X1=2\")), &dansSys, &dansSolu) == 0",
"test_resolution.c",
0x20u,
"test_resolution");
v12 = text_creer_depuis_texte("X1=2,X1=3");
v13 = parse_equation(v12);
v14 = creer_solutions();
if ( (unsigned int)traiter_equation(v14, v13, v19, v20) != -2 )
_assert_fail(
"traiter_equation(creer_solutions(), parse_equation(text_creer_depuis_texte(\"X1=2,X1=3\")), &dansSys, &dansSolu) == -2",
"test_resolution.c",
0x21u,
"test_resolution");
if ( (unsigned int)contient_terme(0LL, 0LL) )
_assert_fail("contient_terme(NULL, NULL) == 0", "test_resolution.c", 0x23u, "test_resolution");
v15 = creer_terme();
v16 = creer_terme();
if ( (unsigned int)contient_terme(v16, v15) )
_assert_fail("contient_terme(creer_terme(), creer_terme()) == 0", "test_resolution.c", 0x24u, "test_resolution");
if ( decapsuler_fonctions(0LL, 0LL) )
_assert_fail("decapsuler_fonctions(NULL, NULL) == NULL", "test_resolution.c", 0x25u, "test_resolution");
if ( (unsigned int)compter_arguments(0LL) != -1 )
_assert_fail("compter_arguments(NULL) == -1", "test_resolution.c", 0x26u, "test_resolution");
result = id_fonction(0LL);
if ( (_DWORD)result != -1 )
_assert_fail("id_fonction(NULL) == -1", "test_resolution.c", 0x27u, "test_resolution");
return result;
}

original_code:
void test_resolution(void)
{
 ResolutionErr err;
 ((void) sizeof ((traiter_systeme(((void *)0), ((void *)0)) == ((void *)0)) ? 1 : 0), __extension__ ({ if (traiter_systeme(((void *)0), ((void *)0)) == ((void *)0)) ; else __assert_fail ("traiter_systeme(NULL, NULL) == NULL", "test_resolution.c", 21, __extension__ __PRETTY_FUNCTION__); }));
 ((void) sizeof ((traiter_systeme(creer_systeme_depuis_texte("X1=34"), ((void *)0)) != ((void *)0)) ? 1 : 0), __extension__ ({ if (traiter_systeme(creer_systeme_depuis_texte("X1=34"), ((void *)0)) != ((void *)0)) ; else __assert_fail ("traiter_systeme(creer_systeme_depuis_texte(\"X1=34\"), NULL) != NULL", "test_resolution.c", 22, __extension__ __PRETTY_FUNCTION__); }));
 ((void) sizeof ((traiter_systeme(((void *)0), &err) == ((void *)0)) ? 1 : 0), __extension__ ({ if (traiter_systeme(((void *)0), &err) == ((void *)0)) ; else __assert_fail ("traiter_systeme(NULL, &err) == NULL", "test_resolution.c", 23, __extension__ __PRETTY_FUNCTION__); }));
 ((void) sizeof ((traiter_systeme(creer_systeme_depuis_texte("X1=34"), &err) != ((void *)0)) ? 1 : 0), __extension__ ({ if (traiter_systeme(creer_systeme_depuis_texte("X1=34"), &err) != ((void *)0)) ; else __assert_fail ("traiter_systeme(creer_systeme_depuis_texte(\"X1=34\"), &err) != NULL", "test_resolution.c", 24, __extension__ __PRETTY_FUNCTION__); }));
 ((void) sizeof ((traiter_systeme(creer_systeme_depuis_texte("X1=34,X1=2"), &err) == ((void *)0)) ? 1 : 0), __extension__ ({ if (traiter_systeme(creer_systeme_depuis_texte("X1=34,X1=2"), &err) == ((void *)0)) ; else __assert_fail ("traiter_systeme(creer_systeme_depuis_texte(\"X1=34,X1=2\"), &err) == NULL", "test_resolution.c", 25, __extension__ __PRETTY_FUNCTION__); }));
 Equation *dansSys, *dansSolu;
 ((void) sizeof ((traiter_equation(((void *)0), ((void *)0), ((void *)0), ((void *)0)) == -2) ? 1 : 0), __extension__ ({ if (traiter_equation(((void *)0), ((void *)0), ((void *)0), ((void *)0)) == -2) ; else __assert_fail ("traiter_equation(NULL, NULL, NULL, NULL) == -2", "test_resolution.c", 28, __extension__ __PRETTY_FUNCTION__); }));
 ((void) sizeof ((traiter_equation(creer_solutions(), ((void *)0), ((void *)0), ((void *)0)) == -2) ? 1 : 0), __extension__ ({ if (traiter_equation(creer_solutions(), ((void *)0), ((void *)0), ((void *)0)) == -2) ; else __assert_fail ("traiter_equation(creer_solutions(), NULL, NULL, NULL) == -2", "test_resolution.c", 29, __extension__ __PRETTY_FUNCTION__); }));
 ((void) sizeof ((traiter_equation(((void *)0), parse_equation(text_creer_depuis_texte("X1=2")), ((void *)0), ((void *)0)) == -2) ? 1 : 0), __extension__ ({ if (traiter_equation(((void *)0), parse_equation(text_creer_depuis_texte("X1=2")), ((void *)0), ((void *)0)) == -2) ; else __assert_fail ("traiter_equation(NULL, parse_equation(text_creer_depuis_texte(\"X1=2\")), NULL, NULL) == -2", "test_resolution.c", 30, __extension__ __PRETTY_FUNCTION__); }));
 ((void) sizeof ((traiter_equation(creer_solutions(), parse_equation(text_creer_depuis_texte("X1=2")), ((void *)0), ((void *)0)) == -2) ? 1 : 0), __extension__ ({ if (traiter_equation(creer_solutions(), parse_equation(text_creer_depuis_texte("X1=2")), ((void *)0), ((void *)0)) == -2) ; else __assert_fail ("traiter_equation(creer_solutions(), parse_equation(text_creer_depuis_texte(\"X1=2\")), NULL, NULL) == -2", "test_resolution.c", 31, __extension__ __PRETTY_FUNCTION__); }));
 ((void) sizeof ((traiter_equation(creer_solutions(), parse_equation(text_creer_depuis_texte("X1=2")), &dansSys, &dansSolu) == 0) ? 1 : 0), __extension__ ({ if (traiter_equation(creer_solutions(), parse_equation(text_creer_depuis_texte("X1=2")), &dansSys, &dansSolu) == 0) ; else __assert_fail ("traiter_equation(creer_solutions(), parse_equation(text_creer_depuis_texte(\"X1=2\")), &dansSys, &dansSolu) == 0", "test_resolution.c", 32, __extension__ __PRETTY_FUNCTION__); }));
 ((void) sizeof ((traiter_equation(creer_solutions(), parse_equation(text_creer_depuis_texte("X1=2,X1=3")), &dansSys, &dansSolu) == -2) ? 1 : 0), __extension__ ({ if (traiter_equation(creer_solutions(), parse_equation(text_creer_depuis_texte("X1=2,X1=3")), &dansSys, &dansSolu) == -2) ; else __assert_fail ("traiter_equation(creer_solutions(), parse_equation(text_creer_depuis_texte(\"X1=2,X1=3\")), &dansSys, &dansSolu) == -2", "test_resolution.c", 33, __extension__ __PRETTY_FUNCTION__); }));
 ((void) sizeof ((contient_terme(((void *)0), ((void *)0)) == 0) ? 1 : 0), __extension__ ({ if (contient_terme(((void *)0), ((void *)0)) == 0) ; else __assert_fail ("contient_terme(NULL, NULL) == 0", "test_resolution.c", 35, __extension__ __PRETTY_FUNCTION__); }));
 ((void) sizeof ((contient_terme(creer_terme(), creer_terme()) == 0) ? 1 : 0), __extension__ ({ if (contient_terme(creer_terme(), creer_terme()) == 0) ; else __assert_fail ("contient_terme(creer_terme(), creer_terme()) == 0", "test_resolution.c", 36, __extension__ __PRETTY_FUNCTION__); }));
 ((void) sizeof ((decapsuler_fonctions(((void *)0), ((void *)0)) == ((void *)0)) ? 1 : 0), __extension__ ({ if (decapsuler_fonctions(((void *)0), ((void *)0)) == ((void *)0)) ; else __assert_fail ("decapsuler_fonctions(NULL, NULL) == NULL", "test_resolution.c", 37, __extension__ __PRETTY_FUNCTION__); }));
 ((void) sizeof ((compter_arguments(((void *)0)) == -1) ? 1 : 0), __extension__ ({ if (compter_arguments(((void *)0)) == -1) ; else __assert_fail ("compter_arguments(NULL) == -1", "test_resolution.c", 38, __extension__ __PRETTY_FUNCTION__); }));
 ((void) sizeof ((id_fonction(((void *)0)) == -1) ? 1 : 0), __extension__ ({ if (id_fonction(((void *)0)) == -1) ; else __assert_fail ("id_fonction(NULL) == -1", "test_resolution.c", 39, __extension__ __PRETTY_FUNCTION__); }));
}

canonical_original_code:
void test_resolution()
{
 enum ResolutionErr err;
 ((void) sizeof ((traiter_systeme(((void *)0), ((void *)0)) == ((void *)0)) ? 1 : 0), __extension__ ({ if (traiter_systeme(((void *)0), ((void *)0)) == ((void *)0)) ; else __assert_fail ("traiter_systeme(NULL, NULL) == NULL", "test_resolution.c", 21, __extension__ __PRETTY_FUNCTION__); }));
 ((void) sizeof ((traiter_systeme(creer_systeme_depuis_texte("X1=34"), ((void *)0)) != ((void *)0)) ? 1 : 0), __extension__ ({ if (traiter_systeme(creer_systeme_depuis_texte("X1=34"), ((void *)0)) != ((void *)0)) ; else __assert_fail ("traiter_systeme(creer_systeme_depuis_texte(\"X1=34\"), NULL) != NULL", "test_resolution.c", 22, __extension__ __PRETTY_FUNCTION__); }));
 ((void) sizeof ((traiter_systeme(((void *)0), &err) == ((void *)0)) ? 1 : 0), __extension__ ({ if (traiter_systeme(((void *)0), &err) == ((void *)0)) ; else __assert_fail ("traiter_systeme(NULL, &err) == NULL", "test_resolution.c", 23, __extension__ __PRETTY_FUNCTION__); }));
 ((void) sizeof ((traiter_systeme(creer_systeme_depuis_texte("X1=34"), &err) != ((void *)0)) ? 1 : 0), __extension__ ({ if (traiter_systeme(creer_systeme_depuis_texte("X1=34"), &err) != ((void *)0)) ; else __assert_fail ("traiter_systeme(creer_systeme_depuis_texte(\"X1=34\"), &err) != NULL", "test_resolution.c", 24, __extension__ __PRETTY_FUNCTION__); }));
 ((void) sizeof ((traiter_systeme(creer_systeme_depuis_texte("X1=34,X1=2"), &err) == ((void *)0)) ? 1 : 0), __extension__ ({ if (traiter_systeme(creer_systeme_depuis_texte("X1=34,X1=2"), &err) == ((void *)0)) ; else __assert_fail ("traiter_systeme(creer_systeme_depuis_texte(\"X1=34,X1=2\"), &err) == NULL", "test_resolution.c", 25, __extension__ __PRETTY_FUNCTION__); }));
 struct equation_s *dansSys; struct equation_s *dansSolu;
 ((void) sizeof ((traiter_equation(((void *)0), ((void *)0), ((void *)0), ((void *)0)) == -2) ? 1 : 0), __extension__ ({ if (traiter_equation(((void *)0), ((void *)0), ((void *)0), ((void *)0)) == -2) ; else __assert_fail ("traiter_equation(NULL, NULL, NULL, NULL) == -2", "test_resolution.c", 28, __extension__ __PRETTY_FUNCTION__); }));
 ((void) sizeof ((traiter_equation(creer_solutions(), ((void *)0), ((void *)0), ((void *)0)) == -2) ? 1 : 0), __extension__ ({ if (traiter_equation(creer_solutions(), ((void *)0), ((void *)0), ((void *)0)) == -2) ; else __assert_fail ("traiter_equation(creer_solutions(), NULL, NULL, NULL) == -2", "test_resolution.c", 29, __extension__ __PRETTY_FUNCTION__); }));
 ((void) sizeof ((traiter_equation(((void *)0), parse_equation(text_creer_depuis_texte("X1=2")), ((void *)0), ((void *)0)) == -2) ? 1 : 0), __extension__ ({ if (traiter_equation(((void *)0), parse_equation(text_creer_depuis_texte("X1=2")), ((void *)0), ((void *)0)) == -2) ; else __assert_fail ("traiter_equation(NULL, parse_equation(text_creer_depuis_texte(\"X1=2\")), NULL, NULL) == -2", "test_resolution.c", 30, __extension__ __PRETTY_FUNCTION__); }));
 ((void) sizeof ((traiter_equation(creer_solutions(), parse_equation(text_creer_depuis_texte("X1=2")), ((void *)0), ((void *)0)) == -2) ? 1 : 0), __extension__ ({ if (traiter_equation(creer_solutions(), parse_equation(text_creer_depuis_texte("X1=2")), ((void *)0), ((void *)0)) == -2) ; else __assert_fail ("traiter_equation(creer_solutions(), parse_equation(text_creer_depuis_texte(\"X1=2\")), NULL, NULL) == -2", "test_resolution.c", 31, __extension__ __PRETTY_FUNCTION__); }));
 ((void) sizeof ((traiter_equation(creer_solutions(), parse_equation(text_creer_depuis_texte("X1=2")), &dansSys, &dansSolu) == 0) ? 1 : 0), __extension__ ({ if (traiter_equation(creer_solutions(), parse_equation(text_creer_depuis_texte("X1=2")), &dansSys, &dansSolu) == 0) ; else __assert_fail ("traiter_equation(creer_solutions(), parse_equation(text_creer_depuis_texte(\"X1=2\")), &dansSys, &dansSolu) == 0", "test_resolution.c", 32, __extension__ __PRETTY_FUNCTION__); }));
 ((void) sizeof ((traiter_equation(creer_solutions(), parse_equation(text_creer_depuis_texte("X1=2,X1=3")), &dansSys, &dansSolu) == -2) ? 1 : 0), __extension__ ({ if (traiter_equation(creer_solutions(), parse_equation(text_creer_depuis_texte("X1=2,X1=3")), &dansSys, &dansSolu) == -2) ; else __assert_fail ("traiter_equation(creer_solutions(), parse_equation(text_creer_depuis_texte(\"X1=2,X1=3\")), &dansSys, &dansSolu) == -2", "test_resolution.c", 33, __extension__ __PRETTY_FUNCTION__); }));
 ((void) sizeof ((contient_terme(((void *)0), ((void *)0)) == 0) ? 1 : 0), __extension__ ({ if (contient_terme(((void *)0), ((void *)0)) == 0) ; else __assert_fail ("contient_terme(NULL, NULL) == 0", "test_resolution.c", 35, __extension__ __PRETTY_FUNCTION__); }));
 ((void) sizeof ((contient_terme(creer_terme(), creer_terme()) == 0) ? 1 : 0), __extension__ ({ if (contient_terme(creer_terme(), creer_terme()) == 0) ; else __assert_fail ("contient_terme(creer_terme(), creer_terme()) == 0", "test_resolution.c", 36, __extension__ __PRETTY_FUNCTION__); }));
 ((void) sizeof ((decapsuler_fonctions(((void *)0), ((void *)0)) == ((void *)0)) ? 1 : 0), __extension__ ({ if (decapsuler_fonctions(((void *)0), ((void *)0)) == ((void *)0)) ; else __assert_fail ("decapsuler_fonctions(NULL, NULL) == NULL", "test_resolution.c", 37, __extension__ __PRETTY_FUNCTION__); }));
 ((void) sizeof ((compter_arguments(((void *)0)) == -1) ? 1 : 0), __extension__ ({ if (compter_arguments(((void *)0)) == -1) ; else __assert_fail ("compter_arguments(NULL) == -1", "test_resolution.c", 38, __extension__ __PRETTY_FUNCTION__); }));
 ((void) sizeof ((id_fonction(((void *)0)) == -1) ? 1 : 0), __extension__ ({ if (id_fonction(((void *)0)) == -1) ; else __assert_fail ("id_fonction(NULL) == -1", "test_resolution.c", 39, __extension__ __PRETTY_FUNCTION__); }));
}

variable_types: enum ResolutionErr { ResolutionErrNone=0, ResolutionErrImpossible=-1 }

variable_types: struct equation_s { struct terme_s { int type_terme; union { int val; struct argument_s { struct terme_s *terme_argument; struct argument_s *suivant; } *arguments; } contenu_terme; } *terme_gauche; struct terme_s *terme_droit; struct equation_s *suivant; } *

user_defined_types: struct equation_s { struct terme_s *terme_gauche; struct terme_s *terme_droit; struct equation_s *suivant; }

user_defined_types: struct terme_s { int type_terme; union { int val; struct argument_s *arguments; } contenu_terme; }


main

canonical_name: main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
int v3; // ebx
pthread_t *v4; // r13
pthread_t *v5; // rbp
pthread_t *v6; // r12
_DWORD *v7; // rax
_DWORD *v8; // rax
int v9; // edi
int v10; // esi
_DWORD *v11; // rax
pthread_t *v12; // rdi
pthread_t v13; // rdi
unsigned int v15; // [rsp+0h] [rbp-48h] BYREF
unsigned int v16; // [rsp+4h] [rbp-44h] BYREF
unsigned int v17; // [rsp+8h] [rbp-40h] BYREF
unsigned int v18; // [rsp+Ch] [rbp-3Ch] BYREF
pthread_t newthread; // [rsp+10h] [rbp-38h] BYREF
pthread_t th[6]; // [rsp+18h] [rbp-30h] BYREF

v3 = 0;
v4 = (pthread_t *)malloc(0x30uLL);
operation_init(48LL, argv);
v5 = v4;
v6 = v4;
cercle_init(16LL);
printf("Nb de P1 : ");
_isoc99_scanf("%d", &v15);
printf("Nb de P2 : ");
_isoc99_scanf("%d", &v16);
printf("Nb de P3 : ");
_isoc99_scanf("%d", &v17);
printf("Nb de P4 : ");
_isoc99_scanf("%d", &v18);
printf(aProductionDema, v15, v16, v17, v18);
v7 = init_cercle_args(7, 16);
pthread_create(&newthread, 0LL, (void *(*)(void *))&cercle_run, v7);
v8 = init_tapis_args(v15, v16, v17, v18, 6, 16, 0);
pthread_create(th, 0LL, (void *(*)(void *))&tapis_run, v8);
do
{
v9 = 2 * v3 + 4;
v10 = v3++;
v11 = init_robot_args(v9, v10);
v12 = v6++;
pthread_create(v12, 0LL, (void *(*)(void *))&robot_run, v11);
}
while ( v3 != 6 );
pthread_join(newthread, 0LL);
puts("Cercle termine");
pthread_join(th[0], 0LL);
puts("Tapis termine");
do
{
v13 = *v5++;
pthread_join(v13, 0LL);
}
while ( v4 + 6 != v5 );
puts("Robots termine");
cercle_destroy();
operation_destroy();
free(v4);
puts(aM);
return 0;
}

original_code:
int main()
{
    pthread_t cercle, tapis;
    pthread_t * robots = (pthread_t *)malloc(6*sizeof(pthread_t));
    int i, no_section_robot, nb_p1, nb_p2, nb_p3, nb_p4;
    operation_init();
    cercle_init(16);
    printf("Nb de P1 : "); scanf("%d", &nb_p1);
    printf("Nb de P2 : "); scanf("%d", &nb_p2);
    printf("Nb de P3 : "); scanf("%d", &nb_p3);
    printf("Nb de P4 : "); scanf("%d", &nb_p4);
    printf("Production demandée : %d P1, %d P2, %d P3, %d P4\n", nb_p1, nb_p2, nb_p3, nb_p4);
    pthread_create(&cercle, ((void *)0), cercle_run, init_cercle_args(6 + 1, 16));
    pthread_create(&tapis, ((void *)0), tapis_run, init_tapis_args(nb_p1, nb_p2, nb_p3, nb_p4, 6, 16, 0));
    no_section_robot = 16 % (6);
    for(i = 0; i < 6; i++){
        pthread_create(&robots[i], ((void *)0), robot_run, init_robot_args(no_section_robot, i));
        no_section_robot += 16 % (6 +1);
    }
    pthread_join(cercle, ((void *)0));
    printf("Cercle termine\n");
    pthread_join(tapis, ((void *)0));
    printf("Tapis termine\n");
    for(i = 0; i < 6; i++) {
        pthread_join(robots[i], ((void *)0));
    }
    printf("Robots termine\n");
    cercle_destroy();
    operation_destroy();
    free(robots);
    printf("Ménage fait\n");
    return 0;
}

canonical_original_code:
int main()
{
    unsigned long cercle; unsigned long tapis;
    unsigned long *robots = (pthread_t *)malloc(6*sizeof(pthread_t));
    int i; int no_section_robot; int nb_p1; int nb_p2; int nb_p3; int nb_p4;
    operation_init();
    cercle_init(16);
    printf("Nb de P1 : "); scanf("%d", &nb_p1);
    printf("Nb de P2 : "); scanf("%d", &nb_p2);
    printf("Nb de P3 : "); scanf("%d", &nb_p3);
    printf("Nb de P4 : "); scanf("%d", &nb_p4);
    printf("Production demandée : %d P1, %d P2, %d P3, %d P4\n", nb_p1, nb_p2, nb_p3, nb_p4);
    pthread_create(&cercle, ((void *)0), cercle_run, init_cercle_args(6 + 1, 16));
    pthread_create(&tapis, ((void *)0), tapis_run, init_tapis_args(nb_p1, nb_p2, nb_p3, nb_p4, 6, 16, 0));
    no_section_robot = 16 % (6);
    for(i = 0; i < 6; i++){
        pthread_create(&robots[i], ((void *)0), robot_run, init_robot_args(no_section_robot, i));
        no_section_robot += 16 % (6 +1);
    }
    pthread_join(cercle, ((void *)0));
    printf("Cercle termine\n");
    pthread_join(tapis, ((void *)0));
    printf("Tapis termine\n");
    for(i = 0; i < 6; i++) {
        pthread_join(robots[i], ((void *)0));
    }
    printf("Robots termine\n");
    cercle_destroy();
    operation_destroy();
    free(robots);
    printf("Ménage fait\n");
    return 0;
}

variable_types:
cercle
unsigned long

variable_types:
tapis
unsigned long

variable_types:
robots
unsigned long *

variable_types: i int

return_type: int


decompiled_code:
int __fastcall cercle_init(int a1)
{
__int64 v1; // r13
size_t v2; // rbx
_DWORD *v3; // rbp
char *v4; // rax
__int64 v5; // rbx
__int64 v6; // rdx

nb_sections = a1;
nb_robot_fini = 0;
nb_produit = 0;
stop_machine = 0;
pthread_mutex_init(&mutex_cercle, 0LL);
pthread_cond_init(&cond_fin_robot, 0LL);
pthread_cond_init(&cond_start_robot, 0LL);
v1 = nb_sections;
v2 = 4LL * nb_sections;
les_sections = malloc(v2);
v3 = les_sections;
v4 = (char *)malloc(8 * (v2 + v1));
mutex_sections = v4;
if ( (int)v1 > 0 )
{
v5 = 0LL;
while ( 1 )
{
v3[v5] = 1;
v6 = 5 * v5++;
LODWORD(v4) = pthread_mutex_init((pthread_mutex_t *)&v4[8 * v6], 0LL);
if ( nb_sections <= (int)v5 )
break;
v3 = les_sections;
v4 = (char *)mutex_sections;
}
}
return (int)v4;
}

canonical_decompiled_code:
int __fastcall func0(int a1)
{
__int64 v1; // r13
size_t v2; // rbx
_DWORD *v3; // rbp
char *v4; // rax
__int64 v5; // rbx
__int64 v6; // rdx

nb_sections = a1;
nb_robot_fini = 0;
nb_produit = 0;
stop_machine = 0;
pthread_mutex_init(&mutex_cercle, 0LL);
pthread_cond_init(&cond_fin_robot, 0LL);
pthread_cond_init(&cond_start_robot, 0LL);
v1 = nb_sections;
v2 = 4LL * nb_sections;
les_sections = malloc(v2);
v3 = les_sections;
v4 = (char *)malloc(8 * (v2 + v1));
mutex_sections = v4;
if ( (int)v1 > 0 )
{
v5 = 0LL;
while ( 1 )
{
v3[v5] = 1;
v6 = 5 * v5++;
LODWORD(v4) = pthread_mutex_init((pthread_mutex_t *)&v4[8 * v6], 0LL);
if ( nb_sections <= (int)v5 )
break;
v3 = les_sections;
v4 = (char *)mutex_sections;
}
}
return (int)v4;
}

original_code:
void cercle_init(int nb_section) {
    int i;
    nb_robot_fini = 0;
    nb_produit = 0;
    stop_machine = 0;
    nb_sections = nb_section;
    pthread_mutex_init(&mutex_cercle, ((void *)0));
    pthread_cond_init(&cond_fin_robot, ((void *)0));
    pthread_cond_init(&cond_start_robot, ((void *)0));
    les_sections = malloc(nb_sections * sizeof(Produit));
    mutex_sections = malloc(nb_sections * sizeof(pthread_mutex_t));
    for (i = 0; i < nb_sections; i++) {
        les_sections[i] = VIDE;
        pthread_mutex_init(&mutex_sections[i], ((void *)0));
    }
}


decompiled_code:
int cercle_destroy()
{
__int64 v0; // rbp
int v1; // ebx
pthread_mutex_t *v2; // rdi

free(les_sections);
if ( nb_sections > 0 )
{
v0 = 0LL;
v1 = 0;
do
{
++v1;
v2 = (pthread_mutex_t *)((char *)mutex_sections + v0);
v0 += 40LL;
pthread_mutex_destroy(v2);
}
while ( nb_sections > v1 );
}
free(mutex_sections);
pthread_mutex_destroy(&mutex_cercle);
pthread_cond_destroy(&cond_fin_robot);
return pthread_cond_destroy(&cond_start_robot);
}

canonical_decompiled_code:
int func1()
{
__int64 v0; // rbp
int v1; // ebx
pthread_mutex_t *v2; // rdi

free(les_sections);
if ( nb_sections > 0 )
{
v0 = 0LL;
v1 = 0;
do
{
++v1;
v2 = (pthread_mutex_t *)((char *)mutex_sections + v0);
v0 += 40LL;
pthread_mutex_destroy(v2);
}
while ( nb_sections > v1 );
}
free(mutex_sections);
pthread_mutex_destroy(&mutex_cercle);
pthread_cond_destroy(&cond_fin_robot);
return pthread_cond_destroy(&cond_start_robot);
}

original_code:
void cercle_destroy() {
    int i;
    free(les_sections);
    for(i = 0; i < nb_sections; i++) {
        pthread_mutex_destroy(&mutex_sections[i]);
    }
    free(mutex_sections);
    pthread_mutex_destroy(&mutex_cercle);
    pthread_cond_destroy(&cond_fin_robot);
    pthread_cond_destroy(&cond_start_robot);
}


decompiled_code:
int afficher_sections()
{
__int64 v0; // rbx
__int64 v1; // rdi
const char *v2; // rax

putchar(91);
if ( nb_sections > 0 )
{
v0 = 0LL;
do
{
v1 = *((unsigned int *)les_sections + v0++);
v2 = (const char *)get_nom_produit(v1);
printf("%s, ", v2);
}
while ( nb_sections > (int)v0 );
}
return puts("]");
}

canonical_decompiled_code:
int func2()
{
__int64 v0; // rbx
__int64 v1; // rdi
const char *v2; // rax

putchar(91);
if ( nb_sections > 0 )
{
v0 = 0LL;
do
{
v1 = *((unsigned int *)les_sections + v0++);
v2 = (const char *)get_nom_produit(v1);
printf("%s, ", v2);
}
while ( nb_sections > (int)v0 );
}
return puts("]");
}

original_code:
void afficher_sections() {
int i;
    printf("[");
    for(i = 0; i < nb_sections; i++) {
        printf("%s, ", get_nom_produit(les_sections[i]));
    }
    printf("]\n");
}


decompiled_code:
int cercle_tourner()
{
_DWORD *v0; // rcx
int v1; // esi
__int64 v2; // rax
int v3; // edx

afficher_sections();
v0 = les_sections;
v1 = *((_DWORD *)les_sections + nb_sections - 1);
LODWORD(v2) = nb_sections - 1;
nb_produit = v1 != 1;
if ( nb_sections - 1 > 0 )
{
v2 = (int)v2;
do
{
v3 = v0[v2 - 1];
v0[v2] = v3;
if ( v3 != 1 )
++nb_produit;
--v2;
}
while ( (int)v2 > 0 );
}
*v0 = v1;
return afficher_sections();
}

canonical_decompiled_code:
int func3()
{
_DWORD *v0; // rcx
int v1; // esi
__int64 v2; // rax
int v3; // edx

func2();
v0 = les_sections;
v1 = *((_DWORD *)les_sections + nb_sections - 1);
LODWORD(v2) = nb_sections - 1;
nb_produit = v1 != 1;
if ( nb_sections - 1 > 0 )
{
v2 = (int)v2;
do
{
v3 = v0[v2 - 1];
v0[v2] = v3;
if ( v3 != 1 )
++nb_produit;
--v2;
}
while ( (int)v2 > 0 );
}
*v0 = v1;
return func2();
}

original_code:
void cercle_tourner() {
    Produit tmp;
    int i;
    afficher_sections();
    tmp = les_sections[nb_sections-1];
    nb_produit = tmp == VIDE ? 0 : 1;
    for (i = nb_sections-1; i > 0; i--) {
        les_sections[i] = les_sections[i-1];
        if(les_sections[i] != VIDE) {
            nb_produit++;
        }
    }
    les_sections[0] = tmp;
    afficher_sections();
}

canonical_original_code:
void cercle_tourner() {
    enum Produit tmp;
    int i;
    afficher_sections();
    tmp = les_sections[nb_sections-1];
    nb_produit = tmp == VIDE ? 0 : 1;
    for (i = nb_sections-1; i > 0; i--) {
        les_sections[i] = les_sections[i-1];
        if(les_sections[i] != VIDE) {
            nb_produit++;
        }
    }
    les_sections[0] = tmp;
    afficher_sections();
}


clearscreen

decompiled_code:
void clearscreen()
{
;
}

canonical_decompiled_code:
void func4()
{
;
}

original_code:
void clearscreen() {
}

canonical_original_code:
void clearscreen() {
}


decompiled_code:
int __fastcall mutex_section_lock(int a1)
{
return pthread_mutex_lock((pthread_mutex_t *)mutex_sections + a1);
}

canonical_decompiled_code:
int __fastcall func5(int a1)
{
return pthread_mutex_lock((pthread_mutex_t *)mutex_sections + a1);
}

original_code:
void mutex_section_lock(int no_section) {
    pthread_mutex_lock(&mutex_sections[no_section]);
}


decompiled_code:
int __fastcall mutex_section_unlock(int a1)
{
return pthread_mutex_unlock((pthread_mutex_t *)mutex_sections + a1);
}

canonical_decompiled_code:
int __fastcall func6(int a1)
{
return pthread_mutex_unlock((pthread_mutex_t *)mutex_sections + a1);
}

original_code:
void mutex_section_unlock(int no_section) {
    pthread_mutex_unlock(&mutex_sections[no_section]);
}


decompiled_code:
__int64 __fastcall see_section(int a1)
{
__int64 result; // rax
unsigned int *v2; // rdx

result = 0LL;
if ( nb_sections > a1 )
{
v2 = (unsigned int *)((char *)les_sections + 4 * a1);
if ( v2 )
result = *v2;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func7(int a1)
{
__int64 result; // rax
unsigned int *v2; // rdx

result = 0LL;
if ( nb_sections > a1 )
{
v2 = (unsigned int *)((char *)les_sections + 4 * a1);
if ( v2 )
result = *v2;
}
return result;
}

original_code:
Produit see_section(int no_section) {
    Produit produit = FAIL;
    if (no_section < nb_sections && &les_sections[no_section] != ((void *)0)) {
        produit = les_sections[no_section];
    }
    return produit;
}

canonical_original_code:
enum Produit see_section(int no_section) {
    enum Produit produit = FAIL;
    if (no_section < nb_sections && &les_sections[no_section] != ((void *)0)) {
        produit = les_sections[no_section];
    }
    return produit;
}


decompiled_code:
__int64 __fastcall get_produit(int a1)
{
__int64 result; // rax
_DWORD *v2; // rdx

result = 0LL;
if ( nb_sections > a1 )
{
v2 = (char *)les_sections + 4 * a1;
if ( v2 )
{
result = (unsigned int)*v2;
*v2 = 1;
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func8(int a1)
{
__int64 result; // rax
_DWORD *v2; // rdx

result = 0LL;
if ( nb_sections > a1 )
{
v2 = (char *)les_sections + 4 * a1;
if ( v2 )
{
result = (unsigned int)*v2;
*v2 = 1;
}
}
return result;
}

original_code:
Produit get_produit(int no_section) {
    Produit produit = FAIL;
    if (no_section < nb_sections && &les_sections[no_section] != ((void *)0)) {
        produit = les_sections[no_section];
        les_sections[no_section] = VIDE;
    }
    return produit;
}

canonical_original_code:
enum Produit get_produit(int no_section) {
    enum Produit produit = FAIL;
    if (no_section < nb_sections && &les_sections[no_section] != ((void *)0)) {
        produit = les_sections[no_section];
        les_sections[no_section] = VIDE;
    }
    return produit;
}


decompiled_code:
__int64 __fastcall set_produit(int a1, int a2)
{
__int64 result; // rax
_DWORD *v3; // rdx

result = 1LL;
if ( nb_sections > a1 )
{
v3 = (char *)les_sections + 4 * a1;
if ( v3 )
{
if ( *v3 == 1 )
{
*v3 = a2;
result = 0LL;
}
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func9(int a1, int a2)
{
__int64 result; // rax
_DWORD *v3; // rdx

result = 1LL;
if ( nb_sections > a1 )
{
v3 = (char *)les_sections + 4 * a1;
if ( v3 )
{
if ( *v3 == 1 )
{
*v3 = a2;
result = 0LL;
}
}
}
return result;
}

original_code:
int set_produit(int no_section, Produit produit) {
    int result = 1;
    if (no_section < nb_sections && &les_sections[no_section] != ((void *)0) && les_sections[no_section] == VIDE) {
        les_sections[no_section] = produit;
        result = 0;
    }
    return result;
}

canonical_original_code:
int set_produit(int no_section, enum Produit produit) {
    int result = 1;
    if (no_section < nb_sections && &les_sections[no_section] != ((void *)0) && les_sections[no_section] == VIDE) {
        les_sections[no_section] = produit;
        result = 0;
    }
    return result;
}

variable_types: result int


decompiled_code:
void stop_machines()
{
stop_machine = 1;
}

canonical_decompiled_code:
void func10()
{
stop_machine = 1;
}


decompiled_code:
__int64 get_stop_machine()
{
return (unsigned int)stop_machine;
}

canonical_decompiled_code:
__int64 func11()
{
return (unsigned int)stop_machine;
}

original_code:
int get_stop_machine() {
    return stop_machine;
}


decompiled_code:
__int64 __fastcall cercle_run(void *ptr)
{
while ( (unsigned int)get_stop_machine() != 1 )
{
pthread_mutex_lock(&mutex_cercle);
puts("On attend que les robots soient prets");
while ( *(_DWORD *)ptr > nb_robot_fini )
{
if ( (unsigned int)get_stop_machine() == 1 )
break;
pthread_cond_wait(&cond_fin_robot, &mutex_cercle);
printf("arrivee d'un robot (%d/%d)\n", (unsigned int)nb_robot_fini, *(unsigned int *)ptr);
}
puts("On fait tourner le cercle");
cercle_tourner();
puts(aOnPrevientTout);
pthread_cond_broadcast(&cond_start_robot);
nb_robot_fini = 0;
pthread_mutex_unlock(&mutex_cercle);
}
pthread_cond_broadcast(&cond_start_robot);
free(ptr);
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func12(void *ptr)
{
while ( (unsigned int)func11() != 1 )
{
pthread_mutex_lock(&mutex_cercle);
puts("On attend que les robots soient prets");
while ( *(_DWORD *)ptr > nb_robot_fini )
{
if ( (unsigned int)func11() == 1 )
break;
pthread_cond_wait(&cond_fin_robot, &mutex_cercle);
printf("arrivee d'un robot (%d/%d)\n", (unsigned int)nb_robot_fini, *(unsigned int *)ptr);
}
puts("On fait tourner le cercle");
func3();
puts(aOnPrevientTout);
pthread_cond_broadcast(&cond_start_robot);
nb_robot_fini = 0;
pthread_mutex_unlock(&mutex_cercle);
}
pthread_cond_broadcast(&cond_start_robot);
free(ptr);
return 0LL;
}

original_code:
void * cercle_run(void * args) {
    struct cercle_run_args * the_args = args;
    while(get_stop_machine() != 1) {
        pthread_mutex_lock(&mutex_cercle);
        printf("On attend que les robots soient prets\n");
        while(nb_robot_fini < the_args->nb_robot && get_stop_machine() != 1) {
            pthread_cond_wait(&cond_fin_robot, &mutex_cercle);
            printf("arrivee d'un robot (%d/%d)\n", nb_robot_fini, the_args->nb_robot);
        }
        clearscreen();
        printf("On fait tourner le cercle\n");
        cercle_tourner(the_args->nb_sections);
        printf("On previent tout les robots que le cercle a tourné\n");
        pthread_cond_broadcast(&cond_start_robot);
        nb_robot_fini = 0;
        pthread_mutex_unlock(&mutex_cercle);
    }
    pthread_cond_broadcast(&cond_start_robot);
    free(the_args);
    return (void *) 0;
}

canonical_original_code:
void *cercle_run(void *args) {
    struct cercle_run_args *the_args = args;
    while(get_stop_machine() != 1) {
        pthread_mutex_lock(&mutex_cercle);
        printf("On attend que les robots soient prets\n");
        while(nb_robot_fini < the_args->nb_robot && get_stop_machine() != 1) {
            pthread_cond_wait(&cond_fin_robot, &mutex_cercle);
            printf("arrivee d'un robot (%d/%d)\n", nb_robot_fini, the_args->nb_robot);
        }
        clearscreen();
        printf("On fait tourner le cercle\n");
        cercle_tourner(the_args->nb_sections);
        printf("On previent tout les robots que le cercle a tourné\n");
        pthread_cond_broadcast(&cond_start_robot);
        nb_robot_fini = 0;
        pthread_mutex_unlock(&mutex_cercle);
    }
    pthread_cond_broadcast(&cond_start_robot);
    free(the_args);
    return (void *) 0;
}

variable_types:
args
void *

variable_types: struct cercle_run_args { int nb_robot; int nb_sections; } *

return_type: void *


decompiled_code:
__int64 get_nb_produit_cercle()
{
return (unsigned int)nb_produit;
}

canonical_decompiled_code:
__int64 func13()
{
return (unsigned int)nb_produit;
}

original_code:
int get_nb_produit_cercle() {
    return nb_produit;
}


original_code:
void operation_init() {
    int i = 0;
    OP1_t.operation = OP1;
    OP1_t.nb_transformation = 5;
    OP1_t.transformations = malloc(OP1_t.nb_transformation*sizeof(struct transformation_t));
    OP1_t.transformations[i++] = C1toP1_01;
    OP1_t.transformations[i++] = P2_04toP2_01;
    OP1_t.transformations[i++] = P3_03toP3_01;
    OP1_t.transformations[i++] = P3_05toP3_11;
    OP1_t.transformations[i++] = P4_06toP4;
    i = 0;
    OP2_t.operation = OP2;
    OP2_t.nb_transformation = 2;
    OP2_t.transformations = malloc(OP2_t.nb_transformation*sizeof(struct transformation_t));
    OP2_t.transformations[i++] = C2toP2_02;
    OP2_t.transformations[i++] = P1_01toP1_02;
    i = 0;
    OP3_t.operation = OP3;
    OP3_t.nb_transformation = 3;
    OP3_t.transformations = malloc(OP3_t.nb_transformation*sizeof(struct transformation_t));
    OP3_t.transformations[i++] = C3toP3_03;
    OP3_t.transformations[i++] = P1_02toP1_03;
    OP3_t.transformations[i++] = P3_11toP3;
    i = 0;
    OP4_t.operation = OP4;
    OP4_t.nb_transformation = 2;
    OP4_t.transformations = malloc(OP4_t.nb_transformation*sizeof(struct transformation_t));
    OP4_t.transformations[i++] = C4toP4_04;
    OP4_t.transformations[i++] = P2_02toP2_04;
    i = 0;
    OP5_t.operation = OP5;
    OP5_t.nb_transformation = 2;
    OP5_t.transformations = malloc(OP5_t.nb_transformation*sizeof(struct transformation_t));
    OP5_t.transformations[i++] = P1_03toP1;
    OP5_t.transformations[i++] = P3_01toP3_05;
    i = 0;
    OP6_t.operation = OP6;
    OP6_t.nb_transformation = 2;
    OP6_t.transformations = malloc(OP6_t.nb_transformation*sizeof(struct transformation_t));
    OP6_t.transformations[i++] = P2_01toP2;
    OP6_t.transformations[i++] = P4_04toP4_06;
}

user_defined_types: struct transformation_t { enum Produit entree; int nb_produit_entree; enum Produit sortie; int nb_cycles; }


original_code:
void operation_destroy() {
    free(OP1_t.transformations);
    free(OP2_t.transformations);
    free(OP3_t.transformations);
    free(OP4_t.transformations);
    free(OP5_t.transformations);
    free(OP6_t.transformations);
}


decompiled_code:
__int64 __fastcall robot_run(void *ptr)
{
unsigned int v1; // er15
__int64 v2; // r14
signed int v3; // er13
signed int v4; // er12
signed int v6; // ebx
unsigned int v7; // eax
unsigned int v8; // eax
const char *v9; // rax
__int64 v11; // rsi
__int64 v12; // rdx
int v13; // ecx
_DWORD *v14; // rdx
_DWORD *v15; // rcx
int v16; // er10
int v17; // edi
int v18; // er9
__int64 v19; // r8
signed int v20; // eax
char v21; // al
int v22; // esi
unsigned int *v23; // rdx
unsigned int v24; // eax
int v25; // ecx
bool v26; // cc
signed int v27; // eax
int v28; // eax
signed int v29; // eax
int v30; // [rsp+0h] [rbp-48h]
_DWORD *v31; // [rsp+0h] [rbp-48h]
const char *v32; // [rsp+8h] [rbp-40h]

v1 = 1;
v2 = 0LL;
v3 = 0;
v4 = 0;
v6 = 0;
v30 = 0;
if ( (unsigned int)get_stop_machine() != 1 )
{
while ( 1 )
{
pthread_mutex_lock(&mutex_cercle);
++nb_robot_fini;
pthread_cond_signal(&cond_fin_robot);
pthread_cond_wait(&cond_start_robot, &mutex_cercle);
pthread_mutex_unlock(&mutex_cercle);
mutex_section_lock(*(unsigned int *)ptr);
--v30;
v7 = see_section(*(unsigned int *)ptr);
if ( v7 == 1 )
{
if ( v1 != 1 )
{
if ( v30 > 0 )
goto LABEL_5;
set_produit(*(unsigned int *)ptr, v1);
}
goto LABEL_32;
}
if ( *((int *)ptr + 4) <= 0 )
goto LABEL_5;
v11 = 0LL;
while ( 1 )
{
v12 = *((_QWORD *)ptr + 1) + 16 * v11;
v13 = *(_DWORD *)(v12 + 4);
v14 = *(_DWORD **)(v12 + 8);
if ( v13 > 0 )
break;
LABEL_23:
if ( *((_DWORD *)ptr + 4) <= (int)++v11 )
goto LABEL_5;
}
v15 = &v14[4 * (v13 - 1)];
if ( *v14 != v7 )
break;
LABEL_14:
if ( v7 == 4 )
{
if ( v14[1] > v3 )
{
++v3;
get_produit(*(unsigned int *)ptr, v11, v14, v15);
}
goto LABEL_5;
}
if ( v7 > 4 )
{
if ( v7 != 5 )
goto LABEL_25;
if ( v14[1] > (int)v2 )
{
v2 = (unsigned int)(v2 + 1);
get_produit(*(unsigned int *)ptr, v11, v14, v15);
}
goto LABEL_5;
}
if ( v7 == 2 )
{
if ( v14[1] > v6 )
{
++v6;
get_produit(*(unsigned int *)ptr, v11, v14, v15);
}
LABEL_5:
if ( v1 != 1 )
goto LABEL_6;
LABEL_32:
v16 = *((_DWORD *)ptr + 4);
v1 = 1;
if ( v16 <= 0 )
goto LABEL_6;
v17 = 0;
v1 = 1;
v18 = 0;
v19 = *((_QWORD *)ptr + 1) + 4LL;
while ( 2 )
{
v22 = *(_DWORD *)v19;
v23 = *(unsigned int **)(v19 + 4);
if ( *(int *)v19 > 0 )
{
if ( v17 == 1 )
goto LABEL_6;
v24 = *v23;
v25 = v17 + 1;
v26 = *v23 <= 4;
if ( *v23 == 4 )
goto LABEL_54;
LABEL_45:
if ( v26 )
{
if ( v24 == 2 )
{
v27 = v23[1];
if ( v27 > v6 )
goto LABEL_52;
v6 -= v27;
goto LABEL_37;
}
if ( v24 == 3 )
{
v20 = v23[1];
if ( v20 > v4 )
goto LABEL_52;
v4 -= v20;
goto LABEL_37;
}
LABEL_56:
if ( v25 < v22 )
goto LABEL_53;
v21 = 1;
LABEL_40:
++v18;
v19 += 16LL;
if ( v18 >= v16 || !v21 )
goto LABEL_6;
continue;
}
if ( v24 != 5 )
goto LABEL_56;
v28 = v23[1];
if ( v28 > (int)v2 )
{
do
{
LABEL_52:
if ( v25 >= v22 )
goto LABEL_39;
LABEL_53:
v24 = v23[4];
v23 += 4;
++v25;
v26 = v24 <= 4;
if ( v24 != 4 )
goto LABEL_45;
LABEL_54:
v29 = v23[1];
}
while ( v29 > v3 );
v3 -= v29;
}
else
{
v2 = (unsigned int)(v2 - v28);
}
LABEL_37:
v1 = v23[2];
v30 = v23[3];
if ( v25 < v22 )
goto LABEL_6;
v17 = 1;
}
break;
}
LABEL_39:
v21 = v17 ^ 1;
goto LABEL_40;
}
if ( v7 == 3 )
{
if ( v14[1] > v4 )
{
++v4;
get_produit(*(unsigned int *)ptr, v11, v14, v15);
}
goto LABEL_5;
}
LABEL_25:
if ( v1 == 1 )
{
v31 = v14;
get_produit(*(unsigned int *)ptr, v11, v14, v15);
v1 = v31[2];
v30 = v31[3];
goto LABEL_5;
}
LABEL_6:
v32 = (const char *)get_nom_produit(v1);
v8 = see_section(*(unsigned int *)ptr);
v9 = (const char *)get_nom_produit(v8);
printf(
"Section %d\t: %s\t, c1 : %d\t, c2 : %d\t, c3 : %d\t, c4 : %d\t, prod : %s\t, countdown : %d\t\n",
*(unsigned int *)ptr,
v9,
(unsigned int)v6,
(unsigned int)v4,
(unsigned int)v3,
v2,
v32,
(unsigned int)v30);
mutex_section_unlock(*(unsigned int *)ptr);
if ( (unsigned int)get_stop_machine() == 1 )
goto LABEL_7;
}
while ( v14 != v15 )
{
v14 += 4;
if ( *v14 == v7 )
goto LABEL_14;
}
goto LABEL_23;
}
LABEL_7:
pthread_cond_signal(&cond_fin_robot);
free(*((void **)ptr + 1));
free(ptr);
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func0(void *ptr)
{
unsigned int v1; // er15
__int64 v2; // r14
signed int v3; // er13
signed int v4; // er12
signed int v6; // ebx
unsigned int v7; // eax
unsigned int v8; // eax
const char *v9; // rax
__int64 v11; // rsi
__int64 v12; // rdx
int v13; // ecx
_DWORD *v14; // rdx
_DWORD *v15; // rcx
int v16; // er10
int v17; // edi
int v18; // er9
__int64 v19; // r8
signed int v20; // eax
char v21; // al
int v22; // esi
unsigned int *v23; // rdx
unsigned int v24; // eax
int v25; // ecx
bool v26; // cc
signed int v27; // eax
int v28; // eax
signed int v29; // eax
int v30; // [rsp+0h] [rbp-48h]
_DWORD *v31; // [rsp+0h] [rbp-48h]
const char *v32; // [rsp+8h] [rbp-40h]

v1 = 1;
v2 = 0LL;
v3 = 0;
v4 = 0;
v6 = 0;
v30 = 0;
if ( (unsigned int)get_stop_machine() != 1 )
{
while ( 1 )
{
pthread_mutex_lock(&mutex_cercle);
++nb_robot_fini;
pthread_cond_signal(&cond_fin_robot);
pthread_cond_wait(&cond_start_robot, &mutex_cercle);
pthread_mutex_unlock(&mutex_cercle);
mutex_section_lock(*(unsigned int *)ptr);
--v30;
v7 = see_section(*(unsigned int *)ptr);
if ( v7 == 1 )
{
if ( v1 != 1 )
{
if ( v30 > 0 )
goto LABEL_5;
set_produit(*(unsigned int *)ptr, v1);
}
goto LABEL_32;
}
if ( *((int *)ptr + 4) <= 0 )
goto LABEL_5;
v11 = 0LL;
while ( 1 )
{
v12 = *((_QWORD *)ptr + 1) + 16 * v11;
v13 = *(_DWORD *)(v12 + 4);
v14 = *(_DWORD **)(v12 + 8);
if ( v13 > 0 )
break;
LABEL_23:
if ( *((_DWORD *)ptr + 4) <= (int)++v11 )
goto LABEL_5;
}
v15 = &v14[4 * (v13 - 1)];
if ( *v14 != v7 )
break;
LABEL_14:
if ( v7 == 4 )
{
if ( v14[1] > v3 )
{
++v3;
get_produit(*(unsigned int *)ptr, v11, v14, v15);
}
goto LABEL_5;
}
if ( v7 > 4 )
{
if ( v7 != 5 )
goto LABEL_25;
if ( v14[1] > (int)v2 )
{
v2 = (unsigned int)(v2 + 1);
get_produit(*(unsigned int *)ptr, v11, v14, v15);
}
goto LABEL_5;
}
if ( v7 == 2 )
{
if ( v14[1] > v6 )
{
++v6;
get_produit(*(unsigned int *)ptr, v11, v14, v15);
}
LABEL_5:
if ( v1 != 1 )
goto LABEL_6;
LABEL_32:
v16 = *((_DWORD *)ptr + 4);
v1 = 1;
if ( v16 <= 0 )
goto LABEL_6;
v17 = 0;
v1 = 1;
v18 = 0;
v19 = *((_QWORD *)ptr + 1) + 4LL;
while ( 2 )
{
v22 = *(_DWORD *)v19;
v23 = *(unsigned int **)(v19 + 4);
if ( *(int *)v19 > 0 )
{
if ( v17 == 1 )
goto LABEL_6;
v24 = *v23;
v25 = v17 + 1;
v26 = *v23 <= 4;
if ( *v23 == 4 )
goto LABEL_54;
LABEL_45:
if ( v26 )
{
if ( v24 == 2 )
{
v27 = v23[1];
if ( v27 > v6 )
goto LABEL_52;
v6 -= v27;
goto LABEL_37;
}
if ( v24 == 3 )
{
v20 = v23[1];
if ( v20 > v4 )
goto LABEL_52;
v4 -= v20;
goto LABEL_37;
}
LABEL_56:
if ( v25 < v22 )
goto LABEL_53;
v21 = 1;
LABEL_40:
++v18;
v19 += 16LL;
if ( v18 >= v16 || !v21 )
goto LABEL_6;
continue;
}
if ( v24 != 5 )
goto LABEL_56;
v28 = v23[1];
if ( v28 > (int)v2 )
{
do
{
LABEL_52:
if ( v25 >= v22 )
goto LABEL_39;
LABEL_53:
v24 = v23[4];
v23 += 4;
++v25;
v26 = v24 <= 4;
if ( v24 != 4 )
goto LABEL_45;
LABEL_54:
v29 = v23[1];
}
while ( v29 > v3 );
v3 -= v29;
}
else
{
v2 = (unsigned int)(v2 - v28);
}
LABEL_37:
v1 = v23[2];
v30 = v23[3];
if ( v25 < v22 )
goto LABEL_6;
v17 = 1;
}
break;
}
LABEL_39:
v21 = v17 ^ 1;
goto LABEL_40;
}
if ( v7 == 3 )
{
if ( v14[1] > v4 )
{
++v4;
get_produit(*(unsigned int *)ptr, v11, v14, v15);
}
goto LABEL_5;
}
LABEL_25:
if ( v1 == 1 )
{
v31 = v14;
get_produit(*(unsigned int *)ptr, v11, v14, v15);
v1 = v31[2];
v30 = v31[3];
goto LABEL_5;
}
LABEL_6:
v32 = (const char *)get_nom_produit(v1);
v8 = see_section(*(unsigned int *)ptr);
v9 = (const char *)get_nom_produit(v8);
printf(
"Section %d\t: %s\t, c1 : %d\t, c2 : %d\t, c3 : %d\t, c4 : %d\t, prod : %s\t, countdown : %d\t\n",
*(unsigned int *)ptr,
v9,
(unsigned int)v6,
(unsigned int)v4,
(unsigned int)v3,
v2,
v32,
(unsigned int)v30);
mutex_section_unlock(*(unsigned int *)ptr);
if ( (unsigned int)get_stop_machine() == 1 )
goto LABEL_7;
}
while ( v14 != v15 )
{
v14 += 4;
if ( *v14 == v7 )
goto LABEL_14;
}
goto LABEL_23;
}
LABEL_7:
pthread_cond_signal(&cond_fin_robot);
free(*((void **)ptr + 1));
free(ptr);
return 0LL;
}

original_code:
void * robot_run(void * args) {
    struct robot_run_args * the_args = args;
    int id_op;
    int id_tf;
    int res_c1 = 0, res_c2 = 0, res_c3 = 0, res_c4 = 0;
    Produit res_produit = VIDE;
    int countdown = 0;
    struct operation_t operation;
    int getout = 0;
    while(get_stop_machine() != 1) {
        pthread_mutex_lock(&mutex_cercle);
        nb_robot_fini++;
        pthread_cond_signal(&cond_fin_robot);
        pthread_cond_wait(&cond_start_robot, &mutex_cercle);
        pthread_mutex_unlock(&mutex_cercle);
        mutex_section_lock(the_args->no_section);
        countdown--;
        Produit produit = see_section(the_args->no_section);
        if (produit == VIDE) {
            if(res_produit != VIDE && countdown <= 0) {
                set_produit(the_args->no_section, res_produit);
                res_produit = VIDE;
            }
        } else {
            for(id_op = 0, getout = 0; id_op < the_args->nb_operations && getout != 1; id_op++) {
                operation = the_args->operations[id_op];
                for(id_tf = 0; id_tf < operation.nb_transformation && getout != 1; id_tf++) {
                    if (operation.transformations[id_tf].entree == produit) {
                        switch(produit) {
                        case C1:
                            if(res_c1 < operation.transformations[id_tf].nb_produit_entree) {
                                res_c1++;
                                get_produit(the_args->no_section);
                            }
                            break;
                        case C2:
                            if(res_c2 < operation.transformations[id_tf].nb_produit_entree) {
                                res_c2++;
                                get_produit(the_args->no_section);
                            }
                            break;
                        case C3:
                            if(res_c3 < operation.transformations[id_tf].nb_produit_entree) {
                                res_c3++;
                                get_produit(the_args->no_section);
                            }
                            break;
                        case C4:
                            if(res_c4 < operation.transformations[id_tf].nb_produit_entree) {
                                res_c4++;
                                get_produit(the_args->no_section);
                            }
                            break;
                        default:
                            if(res_produit == VIDE){
                                get_produit(the_args->no_section);
                                res_produit = operation.transformations[id_tf].sortie;
                                countdown = operation.transformations[id_tf].nb_cycles;
                            }
                            break;
                        }
                        getout = 1;
                    }
                }
            }
        }
        if (res_produit == VIDE) {
            for(id_op = 0, getout = 0; id_op < the_args->nb_operations && getout != 1; id_op++) {
                operation = the_args->operations[id_op];
                for(id_tf = 0; id_tf < operation.nb_transformation && getout != 1; id_tf++) {
                    switch(operation.transformations[id_tf].entree) {
                    case C1:
                        if (operation.transformations[id_tf].nb_produit_entree <= res_c1) {
                            res_c1 -= operation.transformations[id_tf].nb_produit_entree;
                            getout = 1;
                        }
                        break;
                    case C2:
                        if (operation.transformations[id_tf].nb_produit_entree <= res_c2) {
                            res_c2 -= operation.transformations[id_tf].nb_produit_entree;
                            getout = 1;
                        }
                        break;
                    case C3:
                        if (operation.transformations[id_tf].nb_produit_entree <= res_c3) {
                            res_c3 -= operation.transformations[id_tf].nb_produit_entree;
                            getout = 1;
                        }
                        break;
                    case C4:
                        if (operation.transformations[id_tf].nb_produit_entree <= res_c4) {
                            res_c4 -= operation.transformations[id_tf].nb_produit_entree;
                            getout = 1;
                        }
                        break;
                    default:
                        break;
                    }
                    if (getout == 1) {
                        res_produit = operation.transformations[id_tf].sortie;
                        countdown = operation.transformations[id_tf].nb_cycles;
                    }
                }
            }
        }
        printf("Section %d\t: %s\t, c1 : %d\t, c2 : %d\t, c3 : %d\t, c4 : %d\t, prod : %s\t, countdown : %d\t\n", the_args->no_section, get_nom_produit(see_section(the_args->no_section)),
                res_c1, res_c2, res_c3, res_c4, get_nom_produit(res_produit), countdown);
        mutex_section_unlock(the_args->no_section);
    }
    pthread_cond_signal(&cond_fin_robot);
    free(the_args->operations);
    free(the_args);
    return (void *) 0;
}

canonical_original_code:
void *robot_run(void *args) {
    struct robot_run_args *the_args = args;
    int id_op;
    int id_tf;
    int res_c1 = 0; int res_c2 = 0; int res_c3 = 0; int res_c4 = 0;
    enum Produit res_produit = VIDE;
    int countdown = 0;
    struct operation_t operation;
    int getout = 0;
    while(get_stop_machine() != 1) {
        pthread_mutex_lock(&mutex_cercle);
        nb_robot_fini++;
        pthread_cond_signal(&cond_fin_robot);
        pthread_cond_wait(&cond_start_robot, &mutex_cercle);
        pthread_mutex_unlock(&mutex_cercle);
        mutex_section_lock(the_args->no_section);
        countdown--;
        enum Produit produit = see_section(the_args->no_section);
        if (produit == VIDE) {
            if(res_produit != VIDE && countdown <= 0) {
                set_produit(the_args->no_section, res_produit);
                res_produit = VIDE;
            }
        } else {
            for(id_op = 0, getout = 0; id_op < the_args->nb_operations && getout != 1; id_op++) {
                operation = the_args->operations[id_op];
                for(id_tf = 0; id_tf < operation.nb_transformation && getout != 1; id_tf++) {
                    if (operation.transformations[id_tf].entree == produit) {
                        switch(produit) {
                        case C1:
                            if(res_c1 < operation.transformations[id_tf].nb_produit_entree) {
                                res_c1++;
                                get_produit(the_args->no_section);
                            }
                            break;
                        case C2:
                            if(res_c2 < operation.transformations[id_tf].nb_produit_entree) {
                                res_c2++;
                                get_produit(the_args->no_section);
                            }
                            break;
                        case C3:
                            if(res_c3 < operation.transformations[id_tf].nb_produit_entree) {
                                res_c3++;
                                get_produit(the_args->no_section);
                            }
                            break;
                        case C4:
                            if(res_c4 < operation.transformations[id_tf].nb_produit_entree) {
                                res_c4++;
                                get_produit(the_args->no_section);
                            }
                            break;
                        default:
                            if(res_produit == VIDE){
                                get_produit(the_args->no_section);
                                res_produit = operation.transformations[id_tf].sortie;
                                countdown = operation.transformations[id_tf].nb_cycles;
                            }
                            break;
                        }
                        getout = 1;
                    }
                }
            }
        }
        if (res_produit == VIDE) {
            for(id_op = 0, getout = 0; id_op < the_args->nb_operations && getout != 1; id_op++) {
                operation = the_args->operations[id_op];
                for(id_tf = 0; id_tf < operation.nb_transformation && getout != 1; id_tf++) {
                    switch(operation.transformations[id_tf].entree) {
                    case C1:
                        if (operation.transformations[id_tf].nb_produit_entree <= res_c1) {
                            res_c1 -= operation.transformations[id_tf].nb_produit_entree;
                            getout = 1;
                        }
                        break;
                    case C2:
                        if (operation.transformations[id_tf].nb_produit_entree <= res_c2) {
                            res_c2 -= operation.transformations[id_tf].nb_produit_entree;
                            getout = 1;
                        }
                        break;
                    case C3:
                        if (operation.transformations[id_tf].nb_produit_entree <= res_c3) {
                            res_c3 -= operation.transformations[id_tf].nb_produit_entree;
                            getout = 1;
                        }
                        break;
                    case C4:
                        if (operation.transformations[id_tf].nb_produit_entree <= res_c4) {
                            res_c4 -= operation.transformations[id_tf].nb_produit_entree;
                            getout = 1;
                        }
                        break;
                    default:
                        break;
                    }
                    if (getout == 1) {
                        res_produit = operation.transformations[id_tf].sortie;
                        countdown = operation.transformations[id_tf].nb_cycles;
                    }
                }
            }
        }
        printf("Section %d\t: %s\t, c1 : %d\t, c2 : %d\t, c3 : %d\t, c4 : %d\t, prod : %s\t, countdown : %d\t\n", the_args->no_section, get_nom_produit(see_section(the_args->no_section)),
                res_c1, res_c2, res_c3, res_c4, get_nom_produit(res_produit), countdown);
        mutex_section_unlock(the_args->no_section);
    }
    pthread_cond_signal(&cond_fin_robot);
    free(the_args->operations);
    free(the_args);
    return (void *) 0;
}

variable_types: countdown int

variable_types: getout int

user_defined_types: struct operation_t { enum Operation operation; int nb_transformation; struct transformation_t *transformations; }

user_defined_types: struct robot_run_args { int no_section; struct operation_t *operations; int nb_operations; }

user_defined_types: enum Operation { OP1=0, OP2=1, OP3=2, OP4=3, OP5=4, OP6=5 }


decompiled_code:
__int64 __fastcall tapis_run(void *ptr)
{
unsigned int v1; // er15
unsigned int v2; // er14
unsigned int v3; // er13
unsigned int v4; // er12
unsigned int v6; // ebx
unsigned int v7; // edi
__int64 v8; // r8
__int64 v9; // rcx
__int64 v10; // rdx
__int64 v11; // rsi
unsigned __int64 v12; // rax
__int64 v13; // rcx
const char *v14; // rax
int v15; // eax
unsigned int v16; // er8
const char *v17; // rax
int v18; // eax
unsigned int v20; // [rsp+Ch] [rbp-3Ch]
unsigned int v21; // [rsp+Ch] [rbp-3Ch]

v1 = 0;
v2 = 0;
v3 = 0;
v4 = 0;
v6 = *((_DWORD *)ptr + 3) / 3 + *((_DWORD *)ptr + 4) / 3 + *((_DWORD *)ptr + 5) + *((_DWORD *)ptr + 6) / 2;
v7 = time(0LL);
srand(v7);
while ( (unsigned int)get_stop_machine() != 1 )
{
pthread_mutex_lock(&mutex_cercle);
++nb_robot_fini;
pthread_cond_signal(&cond_fin_robot);
pthread_cond_wait(&cond_start_robot, &mutex_cercle);
pthread_mutex_unlock(&mutex_cercle);
mutex_section_lock(*(unsigned int *)ptr);
v12 = see_section(*(unsigned int *)ptr);
if ( (unsigned int)v12 <= 0x15 )
{
v13 = 2368000LL;
if ( _bittest64(&v13, v12) )
{
v20 = get_produit(*(unsigned int *)ptr);
v14 = (const char *)get_nom_produit(v20);
printf("Tapis \t: ### Produit %s sort ###\n", v14);
if ( v20 == 18 )
{
++v1;
}
else if ( v20 > 0x12 )
{
v4 += v20 == 21;
}
else if ( v20 == 9 )
{
++v3;
}
else if ( v20 == 13 )
{
++v2;
}
--v6;
}
}
if ( !v6 )
stop_machines();
printf("Tapis sortie \t: P1 : %d\t, P2 : %d\t, P3 : %d\t, P4 : %d\t restant : %d\n", v3, v2, v1, v4, v6);
if ( (unsigned int)see_section(*(unsigned int *)ptr) != 1
|| (int)get_nb_produit_cercle() >= *((_DWORD *)ptr + 1) - *((_DWORD *)ptr + 2) )
{
goto LABEL_3;
}
v11 = *((unsigned int *)ptr + 3);
if ( (int)v11 > 0
|| (v10 = *((unsigned int *)ptr + 4), (int)v10 > 0)
|| (v9 = *((unsigned int *)ptr + 5), (int)v9 > 0)
|| (v8 = *((unsigned int *)ptr + 6), (int)v8 > 0) )
{
v15 = rand();
v11 = *((unsigned int *)ptr + 3);
if ( (int)v11 > 0 && (v15 & 3) == 0 )
{
v16 = 2;
*((_DWORD *)ptr + 3) = v11 - 1;
LABEL_23:
v21 = v16;
v17 = (const char *)get_nom_produit(v16);
printf("Tapis \t: Ajout d'un produit %s\n", v17);
set_produit(*(unsigned int *)ptr, v21);
LABEL_3:
v8 = *((unsigned int *)ptr + 6);
v9 = *((unsigned int *)ptr + 5);
v10 = *((unsigned int *)ptr + 4);
v11 = *((unsigned int *)ptr + 3);
goto LABEL_4;
}
v18 = v15 % 4;
v10 = *((unsigned int *)ptr + 4);
if ( v18 <= 1 && (int)v10 > 0 )
{
v16 = 3;
*((_DWORD *)ptr + 4) = v10 - 1;
goto LABEL_23;
}
v9 = *((unsigned int *)ptr + 5);
if ( v18 != 3 && (int)v9 > 0 )
{
v16 = 4;
*((_DWORD *)ptr + 5) = v9 - 1;
goto LABEL_23;
}
v8 = *((unsigned int *)ptr + 6);
if ( (int)v8 > 0 )
{
*((_DWORD *)ptr + 6) = v8 - 1;
v16 = 5;
goto LABEL_23;
}
}
LABEL_4:
printf("Tapis entree \t: C1 : %d\t, C2 : %d\t, C3 : %d\t, C4 : %d\t\n", v11, v10, v9, v8);
mutex_section_unlock(*(unsigned int *)ptr);
}
pthread_cond_signal(&cond_fin_robot);
free(ptr);
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func0(void *ptr)
{
unsigned int v1; // er15
unsigned int v2; // er14
unsigned int v3; // er13
unsigned int v4; // er12
unsigned int v6; // ebx
unsigned int v7; // edi
__int64 v8; // r8
__int64 v9; // rcx
__int64 v10; // rdx
__int64 v11; // rsi
unsigned __int64 v12; // rax
__int64 v13; // rcx
const char *v14; // rax
int v15; // eax
unsigned int v16; // er8
const char *v17; // rax
int v18; // eax
unsigned int v20; // [rsp+Ch] [rbp-3Ch]
unsigned int v21; // [rsp+Ch] [rbp-3Ch]

v1 = 0;
v2 = 0;
v3 = 0;
v4 = 0;
v6 = *((_DWORD *)ptr + 3) / 3 + *((_DWORD *)ptr + 4) / 3 + *((_DWORD *)ptr + 5) + *((_DWORD *)ptr + 6) / 2;
v7 = time(0LL);
srand(v7);
while ( (unsigned int)get_stop_machine() != 1 )
{
pthread_mutex_lock(&mutex_cercle);
++nb_robot_fini;
pthread_cond_signal(&cond_fin_robot);
pthread_cond_wait(&cond_start_robot, &mutex_cercle);
pthread_mutex_unlock(&mutex_cercle);
mutex_section_lock(*(unsigned int *)ptr);
v12 = see_section(*(unsigned int *)ptr);
if ( (unsigned int)v12 <= 0x15 )
{
v13 = 2368000LL;
if ( _bittest64(&v13, v12) )
{
v20 = get_produit(*(unsigned int *)ptr);
v14 = (const char *)get_nom_produit(v20);
printf("Tapis \t: ### Produit %s sort ###\n", v14);
if ( v20 == 18 )
{
++v1;
}
else if ( v20 > 0x12 )
{
v4 += v20 == 21;
}
else if ( v20 == 9 )
{
++v3;
}
else if ( v20 == 13 )
{
++v2;
}
--v6;
}
}
if ( !v6 )
stop_machines();
printf("Tapis sortie \t: P1 : %d\t, P2 : %d\t, P3 : %d\t, P4 : %d\t restant : %d\n", v3, v2, v1, v4, v6);
if ( (unsigned int)see_section(*(unsigned int *)ptr) != 1
|| (int)get_nb_produit_cercle() >= *((_DWORD *)ptr + 1) - *((_DWORD *)ptr + 2) )
{
goto LABEL_3;
}
v11 = *((unsigned int *)ptr + 3);
if ( (int)v11 > 0
|| (v10 = *((unsigned int *)ptr + 4), (int)v10 > 0)
|| (v9 = *((unsigned int *)ptr + 5), (int)v9 > 0)
|| (v8 = *((unsigned int *)ptr + 6), (int)v8 > 0) )
{
v15 = rand();
v11 = *((unsigned int *)ptr + 3);
if ( (int)v11 > 0 && (v15 & 3) == 0 )
{
v16 = 2;
*((_DWORD *)ptr + 3) = v11 - 1;
LABEL_23:
v21 = v16;
v17 = (const char *)get_nom_produit(v16);
printf("Tapis \t: Ajout d'un produit %s\n", v17);
set_produit(*(unsigned int *)ptr, v21);
LABEL_3:
v8 = *((unsigned int *)ptr + 6);
v9 = *((unsigned int *)ptr + 5);
v10 = *((unsigned int *)ptr + 4);
v11 = *((unsigned int *)ptr + 3);
goto LABEL_4;
}
v18 = v15 % 4;
v10 = *((unsigned int *)ptr + 4);
if ( v18 <= 1 && (int)v10 > 0 )
{
v16 = 3;
*((_DWORD *)ptr + 4) = v10 - 1;
goto LABEL_23;
}
v9 = *((unsigned int *)ptr + 5);
if ( v18 != 3 && (int)v9 > 0 )
{
v16 = 4;
*((_DWORD *)ptr + 5) = v9 - 1;
goto LABEL_23;
}
v8 = *((unsigned int *)ptr + 6);
if ( (int)v8 > 0 )
{
*((_DWORD *)ptr + 6) = v8 - 1;
v16 = 5;
goto LABEL_23;
}
}
LABEL_4:
printf("Tapis entree \t: C1 : %d\t, C2 : %d\t, C3 : %d\t, C4 : %d\t\n", v11, v10, v9, v8);
mutex_section_unlock(*(unsigned int *)ptr);
}
pthread_cond_signal(&cond_fin_robot);
free(ptr);
return 0LL;
}

original_code:
void * tapis_run(void * args) {
    struct tapis_run_args * the_args = args;
    Produit produit;
    int tmp;
    int ressources_posee = 0;
    int produits_fini = (the_args->nb_c1 / 3) + (the_args->nb_c2 / 3) + (the_args->nb_c3 / 1) + (the_args->nb_c4 / 2);
    int produits_fini_p1 = 0;
    int produits_fini_p2 = 0;
    int produits_fini_p3 = 0;
    int produits_fini_p4 = 0;
    srand(time(((void *)0)));
    while(get_stop_machine() != 1) {
        pthread_mutex_lock(&mutex_cercle);
        nb_robot_fini++;
        pthread_cond_signal(&cond_fin_robot);
        pthread_cond_wait(&cond_start_robot, &mutex_cercle);
        pthread_mutex_unlock(&mutex_cercle);
        mutex_section_lock(the_args->no_section);
        produit = see_section(the_args->no_section);
        if (produit == P1 || produit == P2 || produit == P3 || produit == P4) {
            produit = get_produit(the_args->no_section);
            printf("Tapis \t: ### Produit %s sort ###\n", get_nom_produit(produit));
            switch (produit) {
            case P1:
                produits_fini_p1++;
                break;
            case P2:
                produits_fini_p2++;
                break;
            case P3:
                produits_fini_p3++;
                break;
            case P4:
                produits_fini_p4++;
                break;
            default:
                break;
            }
            produits_fini--;
        }
 if(produits_fini == 0){
            stop_machines();
        }
        printf("Tapis sortie \t: P1 : %d\t, P2 : %d\t, P3 : %d\t, P4 : %d\t restant : %d\n", produits_fini_p1, produits_fini_p2, produits_fini_p3, produits_fini_p4, produits_fini);
        produit = see_section(the_args->no_section);
        if (produit == VIDE) {
            if(get_nb_produit_cercle() < (the_args->nb_sections - the_args->nb_robots) ) {
                if(the_args->nb_c1 > 0 || the_args->nb_c2 > 0 || the_args->nb_c3 > 0 || the_args->nb_c4 > 0) {
                    tmp = rand() % 4;
                    if(the_args->nb_c1 > 0 && tmp == 0) {
                        the_args->nb_c1--;
                        produit = C1;
                    } else if(the_args->nb_c2 > 0 && tmp <= 1) {
                        the_args->nb_c2--;
                        produit = C2;
                    } else if(the_args->nb_c3 > 0 && tmp <= 2) {
                        the_args->nb_c3--;
                        produit = C3;
                    } else if(the_args->nb_c4 > 0 && tmp <= 3) {
                        the_args->nb_c4--;
                        produit = C4;
                    }
                }
                if(produit != VIDE) {
                    printf("Tapis \t: Ajout d'un produit %s\n", get_nom_produit(produit));
                    set_produit(the_args->no_section, produit);
                    ressources_posee++;
                }
            }
        }
        printf("Tapis entree \t: C1 : %d\t, C2 : %d\t, C3 : %d\t, C4 : %d\t\n", the_args->nb_c1, the_args->nb_c2, the_args->nb_c3, the_args->nb_c4);
        mutex_section_unlock(the_args->no_section);
    }
    pthread_cond_signal(&cond_fin_robot);
    free(the_args);
    return (void *) 0;
}

canonical_original_code:
void *tapis_run(void *args) {
    struct tapis_run_args *the_args = args;
    enum Produit produit;
    int tmp;
    int ressources_posee = 0;
    int produits_fini = (the_args->nb_c1 / 3) + (the_args->nb_c2 / 3) + (the_args->nb_c3 / 1) + (the_args->nb_c4 / 2);
    int produits_fini_p1 = 0;
    int produits_fini_p2 = 0;
    int produits_fini_p3 = 0;
    int produits_fini_p4 = 0;
    srand(time(((void *)0)));
    while(get_stop_machine() != 1) {
        pthread_mutex_lock(&mutex_cercle);
        nb_robot_fini++;
        pthread_cond_signal(&cond_fin_robot);
        pthread_cond_wait(&cond_start_robot, &mutex_cercle);
        pthread_mutex_unlock(&mutex_cercle);
        mutex_section_lock(the_args->no_section);
        produit = see_section(the_args->no_section);
        if (produit == P1 || produit == P2 || produit == P3 || produit == P4) {
            produit = get_produit(the_args->no_section);
            printf("Tapis \t: ### Produit %s sort ###\n", get_nom_produit(produit));
            switch (produit) {
            case P1:
                produits_fini_p1++;
                break;
            case P2:
                produits_fini_p2++;
                break;
            case P3:
                produits_fini_p3++;
                break;
            case P4:
                produits_fini_p4++;
                break;
            default:
                break;
            }
            produits_fini--;
        }
 if(produits_fini == 0){
            stop_machines();
        }
        printf("Tapis sortie \t: P1 : %d\t, P2 : %d\t, P3 : %d\t, P4 : %d\t restant : %d\n", produits_fini_p1, produits_fini_p2, produits_fini_p3, produits_fini_p4, produits_fini);
        produit = see_section(the_args->no_section);
        if (produit == VIDE) {
            if(get_nb_produit_cercle() < (the_args->nb_sections - the_args->nb_robots) ) {
                if(the_args->nb_c1 > 0 || the_args->nb_c2 > 0 || the_args->nb_c3 > 0 || the_args->nb_c4 > 0) {
                    tmp = rand() % 4;
                    if(the_args->nb_c1 > 0 && tmp == 0) {
                        the_args->nb_c1--;
                        produit = C1;
                    } else if(the_args->nb_c2 > 0 && tmp <= 1) {
                        the_args->nb_c2--;
                        produit = C2;
                    } else if(the_args->nb_c3 > 0 && tmp <= 2) {
                        the_args->nb_c3--;
                        produit = C3;
                    } else if(the_args->nb_c4 > 0 && tmp <= 3) {
                        the_args->nb_c4--;
                        produit = C4;
                    }
                }
                if(produit != VIDE) {
                    printf("Tapis \t: Ajout d'un produit %s\n", get_nom_produit(produit));
                    set_produit(the_args->no_section, produit);
                    ressources_posee++;
                }
            }
        }
        printf("Tapis entree \t: C1 : %d\t, C2 : %d\t, C3 : %d\t, C4 : %d\t\n", the_args->nb_c1, the_args->nb_c2, the_args->nb_c3, the_args->nb_c4);
        mutex_section_unlock(the_args->no_section);
    }
    pthread_cond_signal(&cond_fin_robot);
    free(the_args);
    return (void *) 0;
}

variable_types: struct tapis_run_args { int no_section; int nb_sections; int nb_robots; int nb_c1; int nb_c2; int nb_c3; int nb_c4; } *

variable_types: tmp int


decompiled_code:
char *__fastcall get_nom_produit(int a1)
{
return nom_produit[a1];
}

canonical_decompiled_code:
char *__fastcall func0(int a1)
{
return nom_produit[a1];
}

original_code:
char * get_nom_produit(Produit produit) {
    return nom_produit[produit];
}

canonical_original_code:
char *get_nom_produit(enum Produit produit) {
    return nom_produit[produit];
}

return_type: char *


decompiled_code:
__int64 __fastcall init_genrand(unsigned int a1)
{
unsigned __int64 v1; // rdx
__int64 result; // rax

v1 = a1;
result = 1LL;
mt[0] = a1;
while ( 1 )
{
v1 = 1812433253 * ((unsigned int)v1 ^ (unsigned int)(v1 >> 30)) + (unsigned int)result;
mt[result] = v1;
if ( result == 623 )
break;
++result;
}
mti = 624;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(unsigned int a1)
{
unsigned __int64 v1; // rdx
__int64 result; // rax

v1 = a1;
result = 1LL;
mt[0] = a1;
while ( 1 )
{
v1 = 1812433253 * ((unsigned int)v1 ^ (unsigned int)(v1 >> 30)) + (unsigned int)result;
mt[result] = v1;
if ( result == 623 )
break;
++result;
}
mti = 624;
return result;
}

original_code:
void init_genrand(unsigned long s)
{
    mt[0]= s & 0xffffffffUL;
    for (mti=1; mti<624; mti++) {
        mt[mti] =
     (1812433253UL * (mt[mti-1] ^ (mt[mti-1] >> 30)) + mti);
        mt[mti] &= 0xffffffffUL;
    }
}

variable_types:
s
unsigned long


decompiled_code:
unsigned __int64 genrand_int31()
{
return genrand_int32() >> 1;
}

canonical_decompiled_code:
unsigned __int64 func3()
{
return func2() >> 1;
}

original_code:
long genrand_int31(void)
{
    return (long)(genrand_int32()>>1);
}

canonical_original_code:
long genrand_int31()
{
    return (long)(genrand_int32()>>1);
}

return_type: long


original_code:
double genrand_real1(void)
{
    return genrand_int32()*(1.0/4294967295.0);
}

canonical_original_code:
double genrand_real1()
{
    return genrand_int32()*(1.0/4294967295.0);
}

return_type: double


original_code:
double genrand_real2(void)
{
    return genrand_int32()*(1.0/4294967296.0);
}

canonical_original_code:
double genrand_real2()
{
    return genrand_int32()*(1.0/4294967296.0);
}


original_code:
double genrand_real3(void)
{
    return (((double)genrand_int32()) + 0.5)*(1.0/4294967296.0);
}


canonical_original_code:
double genrand_res53()
{
    unsigned long a = genrand_int32()>>5; unsigned long b = genrand_int32()>>6;
    return(a*67108864.0+b)*(1.0/9007199254740992.0);
}

variable_types:
a
unsigned long

variable_types:
b
unsigned long


cmp

decompiled_code:
__int64 __fastcall cmp(const void *a1, const void *a2)
{
__int64 result; // rax

result = 0xFFFFFFFFLL;
if ( *(double *)a2 <= *(double *)a1 )
result = *(double *)a1 > *(double *)a2;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func7(const void *a1, const void *a2)
{
__int64 result; // rax

result = 0xFFFFFFFFLL;
if ( *(double *)a2 <= *(double *)a1 )
result = *(double *)a1 > *(double *)a2;
return result;
}

original_code:
int cmp(const void* x1, const void* x2){
    double y1 = *((double*)x1);
    double y2 = *((double*)x2);
    if (y1<y2) return -1;
    if (y1>y2) return 1;
    return 0;
}

canonical_original_code:
int cmp(void *x1, void *x2){
    double y1 = *((double*)x1);
    double y2 = *((double*)x2);
    if (y1<y2) return -1;
    if (y1>y2) return 1;
    return 0;
}


decompiled_code:
int test_recall()
{
puts("Testing recall...");
return puts("Yup, that's all fine");
}

canonical_decompiled_code:
int func8()
{
puts("Testing recall...");
return puts("Yup, that's all fine");
}

original_code:
void test_recall(void){
    node* n = malloc(sizeof(node));
    int err = 0;
    printf("Testing recall...\n");
    n->pivot = 5;
    n->l = n;
    n->r = n;
    err &= (n->l->pivot == 5);
    err &= (n->r->pivot == 5);
    if (err == 0){
        printf("Yup, that's all fine\n");
    } else {
        printf("Nah, that's borked\n");
    }
}

canonical_original_code:
void test_recall(){
    struct __node__ *n = malloc(sizeof(node));
    int err = 0;
    printf("Testing recall...\n");
    n->pivot = 5;
    n->l = n;
    n->r = n;
    err &= (n->l->pivot == 5);
    err &= (n->r->pivot == 5);
    if (err == 0){
        printf("Yup, that's all fine\n");
    } else {
        printf("Nah, that's borked\n");
    }
}

variable_types: struct __node__ { double pivot; int leaves; struct __node__ *parent; struct __node__ *l; struct __node__ *r; } *

variable_types: err int


sort

decompiled_code:
void __fastcall sort(void *a1, int a2)
{
qsort(a1, a2, 8uLL, (__compar_fn_t)cmp);
}

canonical_decompiled_code:
void __fastcall func9(void *a1, int a2)
{
qsort(a1, a2, 8uLL, (__compar_fn_t)cmp);
}

original_code:
void sort(double* xs, int len){
    qsort(xs,len,sizeof(double),cmp);
}

canonical_original_code:
void sort(double *xs, int len){
    qsort(xs,len,sizeof(double),cmp);
}

variable_types:
xs
double *

variable_types: len int


original_code:
node* build_tree(double* xs, int len){
    node** nodes = malloc(len*sizeof(node*));
    int* indices = malloc(len*sizeof(int));
    node* new_node;
    sort(xs, len);
    for (int i=0; i<len; i++){
        nodes[i] = malloc(sizeof(node));
        nodes[i]->l = ((void *)0);
        nodes[i]->r = ((void *)0);
        nodes[i]->pivot = xs[i];
        nodes[i]->leaves = 1;
        indices[i] = i;
    }
    while (len>0){
        len = len>>1;
        for (int i=0; i<len; i++){
            new_node = malloc(sizeof(node));
            nodes[2*i]->parent = new_node;
            nodes[2*i+1]->parent = new_node;
            new_node->l = nodes[2*i];
            new_node->r = nodes[2*i+1];
            new_node->leaves = new_node->l->leaves + new_node->r->leaves;
            new_node->pivot = xs[(indices[2*i]+indices[2*i+1])/2];
            indices[i] = (indices[2*i]+indices[2*i+1])/2;
            nodes[i] = new_node;
        }
    }
    free(indices);
    return nodes[0];
}

canonical_original_code:
struct __node__ *build_tree(double *xs, int len){
    struct __node__ **nodes = malloc(len*sizeof(node*));
    int *indices = malloc(len*sizeof(int));
    struct __node__ *new_node;
    sort(xs, len);
    for (int i = 0; i<len; i++){
        nodes[i] = malloc(sizeof(node));
        nodes[i]->l = ((void *)0);
        nodes[i]->r = ((void *)0);
        nodes[i]->pivot = xs[i];
        nodes[i]->leaves = 1;
        indices[i] = i;
    }
    while (len>0){
        len = len>>1;
        for (int i = 0; i<len; i++){
            new_node = malloc(sizeof(node));
            nodes[2*i]->parent = new_node;
            nodes[2*i+1]->parent = new_node;
            new_node->l = nodes[2*i];
            new_node->r = nodes[2*i+1];
            new_node->leaves = new_node->l->leaves + new_node->r->leaves;
            new_node->pivot = xs[(indices[2*i]+indices[2*i+1])/2];
            indices[i] = (indices[2*i]+indices[2*i+1])/2;
            nodes[i] = new_node;
        }
    }
    free(indices);
    return nodes[0];
}

variable_types: struct __node__ { double pivot; int leaves; struct __node__ *parent; struct __node__ *l; struct __node__ *r; } **

variable_types:
indices
int *


decompiled_code:
__int64 __fastcall print_dft(__int64 a1, int a2)
{
__int64 v2; // r12
int v4; // ebx
__int64 result; // rax

if ( a1 )
{
v2 = a1;
do
{
v4 = 0;
if ( a2 > 0 )
{
do
{
++v4;
putchar(62);
}
while ( v4 != a2 );
}
++a2;
printf("%lf, leaves = %d\n", *(double *)v2, *(unsigned int *)(v2 + 8));
result = print_dft(*(_QWORD *)(v2 + 24), (unsigned int)a2);
v2 = *(_QWORD *)(v2 + 32);
}
while ( v2 );
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func11(__int64 a1, int a2)
{
__int64 v2; // r12
int v4; // ebx
__int64 result; // rax

if ( a1 )
{
v2 = a1;
do
{
v4 = 0;
if ( a2 > 0 )
{
do
{
++v4;
putchar(62);
}
while ( v4 != a2 );
}
++a2;
printf("%lf, leaves = %d\n", *(double *)v2, *(unsigned int *)(v2 + 8));
result = func11(*(_QWORD *)(v2 + 24), (unsigned int)a2);
v2 = *(_QWORD *)(v2 + 32);
}
while ( v2 );
}
return result;
}

original_code:
void print_dft(node* n, int depth){
    if (n == ((void *)0)) return;
    for (int i = 0; i<depth; i++) printf(">");
    printf("%lf, leaves = %d\n", n->pivot,n->leaves);
    print_dft(n->l, depth+1);
    print_dft(n->r, depth+1);
}

canonical_original_code:
void print_dft(struct __node__ *n, int depth){
    if (n == ((void *)0)) return;
    for (int i = 0; i<depth; i++) printf(">");
    printf("%lf, leaves = %d\n", n->pivot,n->leaves);
    print_dft(n->l, depth+1);
    print_dft(n->r, depth+1);
}

variable_types: depth int

variable_types: i int

user_defined_types: struct __node__ { double pivot; int leaves; struct __node__ *parent; struct __node__ *l; struct __node__ *r; }


decompiled_code:
__int64 __fastcall cmp_x(const void *a1, const void *a2)
{
__int64 result; // rax

result = 0xFFFFFFFFLL;
if ( *(double *)a2 <= *(double *)a1 )
result = *(double *)a1 > *(double *)a2;
return result;
}

original_code:
int cmp_x(const void* x1, const void* x2){
    point p1 = *((point*)x1);
    point p2 = *((point*)x2);
    if (p1.x<p2.x) return -1;
    if (p1.x>p2.x) return 1;
    return 0;
}

canonical_original_code:
int cmp_x(void *x1, void *x2){
    struct point p1 = *((point*)x1);
    struct point p2 = *((point*)x2);
    if (p1.x<p2.x) return -1;
    if (p1.x>p2.x) return 1;
    return 0;
}


decompiled_code:
__int64 __fastcall cmp_y(const void *a1, const void *a2)
{
double v2; // xmm1_8
double v3; // xmm0_8
__int64 result; // rax

v2 = *((double *)a1 + 1);
v3 = *((double *)a2 + 1);
result = 0xFFFFFFFFLL;
if ( v3 <= v2 )
result = v2 > v3;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func8(const void *a1, const void *a2)
{
double v2; // xmm1_8
double v3; // xmm0_8
__int64 result; // rax

v2 = *((double *)a1 + 1);
v3 = *((double *)a2 + 1);
result = 0xFFFFFFFFLL;
if ( v3 <= v2 )
result = v2 > v3;
return result;
}

original_code:
int cmp_y(const void* x1, const void* x2){
    point p1 = *((point*)x1);
    point p2 = *((point*)x2);
    if (p1.y<p2.y) return -1;
    if (p1.y>p2.y) return 1;
    return 0;
}

canonical_original_code:
int cmp_y(void *x1, void *x2){
    struct point p1 = *((point*)x1);
    struct point p2 = *((point*)x2);
    if (p1.y<p2.y) return -1;
    if (p1.y>p2.y) return 1;
    return 0;
}


cmp

canonical_decompiled_code:
__int64 __fastcall func9(const void *a1, const void *a2)
{
__int64 result; // rax

result = 0xFFFFFFFFLL;
if ( *(double *)a2 <= *(double *)a1 )
result = *(double *)a1 > *(double *)a2;
return result;
}


sort

canonical_decompiled_code:
void __fastcall func10(void *a1, int a2)
{
qsort(a1, a2, 8uLL, (__compar_fn_t)cmp);
}


decompiled_code:
void __fastcall sort_x(void *a1, int a2)
{
qsort(a1, a2, 0x10uLL, (__compar_fn_t)cmp_x);
}

canonical_decompiled_code:
void __fastcall func11(void *a1, int a2)
{
qsort(a1, a2, 0x10uLL, (__compar_fn_t)cmp_x);
}

original_code:
void sort_x(point* xs, int len){
    qsort(xs,len,sizeof(point),cmp_x);
}

canonical_original_code:
void sort_x(struct point *xs, int len){
    qsort(xs,len,sizeof(point),cmp_x);
}

variable_types:
xs
struct point { double x; double y; } *


decompiled_code:
void __fastcall sort_y(void *a1, int a2)
{
qsort(a1, a2, 0x10uLL, (__compar_fn_t)cmp_y);
}

canonical_decompiled_code:
void __fastcall func12(void *a1, int a2)
{
qsort(a1, a2, 0x10uLL, (__compar_fn_t)cmp_y);
}

original_code:
void sort_y(point* xs, int len){
    qsort(xs,len,sizeof(point),cmp_y);
}

canonical_original_code:
void sort_y(struct point *xs, int len){
    qsort(xs,len,sizeof(point),cmp_y);
}


original_code:
node* build_ytree(point* ps_, int start, int end){
    printf("Building ytree from %d to %d\n", start, end);
    int i;
    int len;
    int l = end-start;
    point* ps = malloc((l)*sizeof(point));
    memcpy(ps, &ps_[start], (l)*sizeof(point));
    if ((l & (l-1)) != 0) {
        len = 1<<((8*sizeof(int))-__builtin_clz(l));
    } else {
        len = l;
    }
    printf("len=%d, l=%d\n",len,l);
    node** nodes = malloc(len*sizeof(node*));
    int* indices = malloc(len*sizeof(int));
    node* new_node;
    sort_y(ps, l);
    for (i=0; i<l; i++){
        nodes[i] = malloc(sizeof(node));
        nodes[i]->l = ((void *)0);
        nodes[i]->r = ((void *)0);
        nodes[i]->pivot = ps[i];
        nodes[i]->leaves = 1;
        indices[i] = i;
    }
    for (;i<len;i++){
        nodes[i] = malloc(sizeof(node));
        nodes[i]->l = ((void *)0);
        nodes[i]->r = ((void *)0);
        nodes[i]->pivot.x = (__builtin_huge_val ());
        nodes[i]->pivot.y = (__builtin_huge_val ());
        nodes[i]->leaves = 0;
        indices[i] = i;
    }
    while (len>0){
        len = len>>1;
        for (i=0; i<len; i++){
            new_node = malloc(sizeof(node));
            nodes[2*i]->parent = new_node;
            nodes[2*i+1]->parent = new_node;
            new_node->l = nodes[2*i];
            new_node->r = nodes[2*i+1];
            new_node->d = ((void *)0);
            new_node->leaves = new_node->l->leaves + new_node->r->leaves;
            new_node->pivot = ps[(indices[2*i]+indices[2*i+1])/2];
            indices[i] = (indices[2*i]+indices[2*i+1])/2;
            nodes[i] = new_node;
        }
    }
    free(indices);
    return nodes[0];
}

canonical_original_code:
struct __node__ *build_ytree(struct point *ps_, int start, int end){
    printf("Building ytree from %d to %d\n", start, end);
    int i;
    int len;
    int l = end-start;
    struct point *ps = malloc((l)*sizeof(point));
    memcpy(ps, &ps_[start], (l)*sizeof(point));
    if ((l & (l-1)) != 0) {
        len = 1<<((8*sizeof(int))-__builtin_clz(l));
    } else {
        len = l;
    }
    printf("len=%d, l=%d\n",len,l);
    struct __node__ **nodes = malloc(len*sizeof(node*));
    int *indices = malloc(len*sizeof(int));
    struct __node__ *new_node;
    sort_y(ps, l);
    for (i=0; i<l; i++){
        nodes[i] = malloc(sizeof(node));
        nodes[i]->l = ((void *)0);
        nodes[i]->r = ((void *)0);
        nodes[i]->pivot = ps[i];
        nodes[i]->leaves = 1;
        indices[i] = i;
    }
    for (;i<len;i++){
        nodes[i] = malloc(sizeof(node));
        nodes[i]->l = ((void *)0);
        nodes[i]->r = ((void *)0);
        nodes[i]->pivot.x = (__builtin_huge_val ());
        nodes[i]->pivot.y = (__builtin_huge_val ());
        nodes[i]->leaves = 0;
        indices[i] = i;
    }
    while (len>0){
        len = len>>1;
        for (i=0; i<len; i++){
            new_node = malloc(sizeof(node));
            nodes[2*i]->parent = new_node;
            nodes[2*i+1]->parent = new_node;
            new_node->l = nodes[2*i];
            new_node->r = nodes[2*i+1];
            new_node->d = ((void *)0);
            new_node->leaves = new_node->l->leaves + new_node->r->leaves;
            new_node->pivot = ps[(indices[2*i]+indices[2*i+1])/2];
            indices[i] = (indices[2*i]+indices[2*i+1])/2;
            nodes[i] = new_node;
        }
    }
    free(indices);
    return nodes[0];
}

variable_types: start int

variable_types: end int

variable_types: l int

variable_types:
ps
struct point { double x; double y; } *

variable_types: struct __node__ { struct point { double x; double y; } pivot; int level; int leaves; struct __node__ *parent; struct __node__ *l; struct __node__ *r; struct __node__ *d; } **

user_defined_types: struct __node__ { struct point pivot; int level; int leaves; struct __node__ *parent; struct __node__ *l; struct __node__ *r; struct __node__ *d; }


original_code:
node* build_xtree(point* ps, int l){
    int i;
    int len;
    if ((l & (l-1)) != 0) {
        len = 1<<((8*sizeof(int))-__builtin_clz(l));
    } else {
        len = l;
    }
    node** nodes = malloc(len*sizeof(node*));
    int* indices = malloc(len*sizeof(int));
    int* starts = malloc(len*sizeof(int));
    int* ends = malloc(len*sizeof(int));
    node* new_node;
    sort_x(ps, l);
    for (i=0; i<l; i++){
        nodes[i] = malloc(sizeof(node));
        nodes[i]->l = ((void *)0);
        nodes[i]->r = ((void *)0);
        nodes[i]->pivot = ps[i];
        nodes[i]->leaves = 1;
        indices[i] = i;
        starts[i] = i;
        ends[i] = i+1;
        nodes[i]->d = build_ytree(ps, i, i+1);
        printf("(%d,%d)\n", starts[i], ends[i]);
    }
    for (;i<len;i++){
        nodes[i] = malloc(sizeof(node));
        nodes[i]->l = ((void *)0);
        nodes[i]->r = ((void *)0);
        nodes[i]->pivot.x = (__builtin_huge_val ());
        nodes[i]->pivot.y = (__builtin_huge_val ());
        nodes[i]->leaves = 0;
        indices[i] = i;
        starts[i] = l;
        ends[i] = l;
        printf("(%d,%d)\n", starts[i], ends[i]);
    }
    while (len>0){
        len = len>>1;
        for (i=0; i<len; i++){
            new_node = malloc(sizeof(node));
            nodes[2*i]->parent = new_node;
            nodes[2*i+1]->parent = new_node;
            new_node->l = nodes[2*i];
            new_node->r = nodes[2*i+1];
            new_node->d = build_ytree(ps, starts[2*i], ends[2*i+1]);
            new_node->leaves = new_node->l->leaves + new_node->r->leaves;
            new_node->pivot = ps[(indices[2*i]+indices[2*i+1])/2];
            printf("start=%d, end=%d\n", starts[2*i], ends[2*i+1]);
            starts[i] = starts[2*i];
            ends[i] = ends[2*i+1];
            indices[i] = (indices[2*i]+indices[2*i+1])/2;
            nodes[i] = new_node;
        }
    }
    free(indices);
    return nodes[0];
}

canonical_original_code:
struct __node__ *build_xtree(struct point *ps, int l){
    int i;
    int len;
    if ((l & (l-1)) != 0) {
        len = 1<<((8*sizeof(int))-__builtin_clz(l));
    } else {
        len = l;
    }
    struct __node__ **nodes = malloc(len*sizeof(node*));
    int *indices = malloc(len*sizeof(int));
    int *starts = malloc(len*sizeof(int));
    int *ends = malloc(len*sizeof(int));
    struct __node__ *new_node;
    sort_x(ps, l);
    for (i=0; i<l; i++){
        nodes[i] = malloc(sizeof(node));
        nodes[i]->l = ((void *)0);
        nodes[i]->r = ((void *)0);
        nodes[i]->pivot = ps[i];
        nodes[i]->leaves = 1;
        indices[i] = i;
        starts[i] = i;
        ends[i] = i+1;
        nodes[i]->d = build_ytree(ps, i, i+1);
        printf("(%d,%d)\n", starts[i], ends[i]);
    }
    for (;i<len;i++){
        nodes[i] = malloc(sizeof(node));
        nodes[i]->l = ((void *)0);
        nodes[i]->r = ((void *)0);
        nodes[i]->pivot.x = (__builtin_huge_val ());
        nodes[i]->pivot.y = (__builtin_huge_val ());
        nodes[i]->leaves = 0;
        indices[i] = i;
        starts[i] = l;
        ends[i] = l;
        printf("(%d,%d)\n", starts[i], ends[i]);
    }
    while (len>0){
        len = len>>1;
        for (i=0; i<len; i++){
            new_node = malloc(sizeof(node));
            nodes[2*i]->parent = new_node;
            nodes[2*i+1]->parent = new_node;
            new_node->l = nodes[2*i];
            new_node->r = nodes[2*i+1];
            new_node->d = build_ytree(ps, starts[2*i], ends[2*i+1]);
            new_node->leaves = new_node->l->leaves + new_node->r->leaves;
            new_node->pivot = ps[(indices[2*i]+indices[2*i+1])/2];
            printf("start=%d, end=%d\n", starts[2*i], ends[2*i+1]);
            starts[i] = starts[2*i];
            ends[i] = ends[2*i+1];
            indices[i] = (indices[2*i]+indices[2*i+1])/2;
            nodes[i] = new_node;
        }
    }
    free(indices);
    return nodes[0];
}

variable_types:
ps
struct point *

variable_types:
starts
int *

variable_types:
ends
int *

variable_types: struct __node__ { struct point { double x; double y; } pivot; int level; int leaves; struct __node__ *parent; struct __node__ *l; struct __node__ *r; struct __node__ *d; } *


decompiled_code:
__int64 __fastcall print_ytree(__int64 a1, int a2)
{
__int64 v2; // r12
int v4; // ebx
__int64 result; // rax

if ( a1 )
{
v2 = a1;
do
{
v4 = 0;
if ( a2 > 0 )
{
do
{
++v4;
putchar(62);
}
while ( v4 != a2 );
}
++a2;
printf("%lf, leaves = %d\n", *(double *)(v2 + 8), *(unsigned int *)(v2 + 20));
result = print_ytree(*(_QWORD *)(v2 + 32), (unsigned int)a2);
v2 = *(_QWORD *)(v2 + 40);
}
while ( v2 );
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func15(__int64 a1, int a2)
{
__int64 v2; // r12
int v4; // ebx
__int64 result; // rax

if ( a1 )
{
v2 = a1;
do
{
v4 = 0;
if ( a2 > 0 )
{
do
{
++v4;
putchar(62);
}
while ( v4 != a2 );
}
++a2;
printf("%lf, leaves = %d\n", *(double *)(v2 + 8), *(unsigned int *)(v2 + 20));
result = func15(*(_QWORD *)(v2 + 32), (unsigned int)a2);
v2 = *(_QWORD *)(v2 + 40);
}
while ( v2 );
}
return result;
}

original_code:
void print_ytree(node* n, int depth){
    if (n == ((void *)0)) return;
    for (int i = 0; i<depth; i++) printf(">");
    printf("%lf, leaves = %d\n", n->pivot.y, n->leaves);
    print_ytree(n->l, depth+1);
    print_ytree(n->r, depth+1);
}

canonical_original_code:
void print_ytree(struct __node__ *n, int depth){
    if (n == ((void *)0)) return;
    for (int i = 0; i<depth; i++) printf(">");
    printf("%lf, leaves = %d\n", n->pivot.y, n->leaves);
    print_ytree(n->l, depth+1);
    print_ytree(n->r, depth+1);
}