decompiled_code:
__int64 test_ai_add_unsigned_with_lshift()
{
__int64 v0; // r14
__int64 v1; // r13
__int64 v2; // r12
__int64 v3; // rbp
__int64 v4; // rbp
__int64 v5; // rax
__int64 v7; // rdx
const char *v8; // r12
const char *v9; // rax

v0 = AI_NewArbInt_FromLong(57005LL);
v1 = AI_NewArbInt_FromLong(200208384LL);
v2 = ai_add_unsigned_with_lshift(v0, v1, 1LL);
v3 = AI_NewArbInt_FromString("0x0BEEF0000000DEAD");
if ( !(unsigned int)AI_Equal(v2, v3) )
{
v7 = 34LL;
goto LABEL_5;
}
AI_FreeArbInt(v0);
AI_FreeArbInt(v1);
AI_FreeArbInt(v2);
AI_FreeArbInt(v3);
v4 = AI_NewArbInt_FromString("0x12123434565600000000");
v5 = AI_NewArbInt_FromString("0x999988886666");
v2 = ai_add_unsigned_with_lshift(v4, v5, 2LL);
v3 = AI_NewArbInt_FromString("0x9999888878783434565600000000");
if ( !(unsigned int)AI_Equal(v2, v3) )
{
v7 = 54LL;
LABEL_5:
printf("TEST_EQUAL Failure (%s, line %d):\n", "test_ai_add_unsigned_with_lshift", v7);
v8 = (const char *)AI_ToString(v2);
v9 = (const char *)AI_ToString(v3);
printf(" expected %s, got %s\n", v9, v8);
exit(1);
}
printf("PASSED : %s\n", "test_ai_add_unsigned_with_lshift");
return 1LL;
}

canonical_decompiled_code:
__int64 func0()
{
__int64 v0; // r14
__int64 v1; // r13
__int64 v2; // r12
__int64 v3; // rbp
__int64 v4; // rbp
__int64 v5; // rax
__int64 v7; // rdx
const char *v8; // r12
const char *v9; // rax

v0 = AI_NewArbInt_FromLong(57005LL);
v1 = AI_NewArbInt_FromLong(200208384LL);
v2 = ai_add_unsigned_with_lshift(v0, v1, 1LL);
v3 = AI_NewArbInt_FromString("0x0BEEF0000000DEAD");
if ( !(unsigned int)AI_Equal(v2, v3) )
{
v7 = 34LL;
goto LABEL_5;
}
AI_FreeArbInt(v0);
AI_FreeArbInt(v1);
AI_FreeArbInt(v2);
AI_FreeArbInt(v3);
v4 = AI_NewArbInt_FromString("0x12123434565600000000");
v5 = AI_NewArbInt_FromString("0x999988886666");
v2 = ai_add_unsigned_with_lshift(v4, v5, 2LL);
v3 = AI_NewArbInt_FromString("0x9999888878783434565600000000");
if ( !(unsigned int)AI_Equal(v2, v3) )
{
v7 = 54LL;
LABEL_5:
printf("TEST_EQUAL Failure (%s, line %d):\n", "test_ai_add_unsigned_with_lshift", v7);
v8 = (const char *)AI_ToString(v2);
v9 = (const char *)AI_ToString(v3);
printf(" expected %s, got %s\n", v9, v8);
exit(1);
}
printf("PASSED : %s\n", "test_ai_add_unsigned_with_lshift");
return 1LL;
}

original_code:
int test_ai_add_unsigned_with_lshift(void)
{
  ;
  ArbInt *A;
  ArbInt *B;
  ArbInt *C;
  size_t B_shift;
  ArbInt *expected;
  A = AI_NewArbInt_FromLong(0x0000DEAD);
  B = AI_NewArbInt_FromLong(0x0BEEF000);
  B_shift = 1;
  C = ai_add_unsigned_with_lshift(A, B, B_shift);
  expected = AI_NewArbInt_FromString("0x0BEEF0000000DEAD");
  if (!(AI_Equal)((C), (expected))) { printf("TEST_EQUAL Failure (%s, line %d):\n", __func__, 34); printf("    expected %s, got %s\n", (AI_ToString)((expected)), (AI_ToString)((C))); goto test_exit; };
  AI_FreeArbInt(A);
  AI_FreeArbInt(B);
  AI_FreeArbInt(C);
  AI_FreeArbInt(expected);
  A = AI_NewArbInt_FromString("0x12123434565600000000");
  B = AI_NewArbInt_FromString("0x999988886666");
  B_shift = 2;
  C = ai_add_unsigned_with_lshift(A, B, B_shift);
  expected = AI_NewArbInt_FromString("0x9999888878783434565600000000");
  if (!(AI_Equal)((C), (expected))) { printf("TEST_EQUAL Failure (%s, line %d):\n", __func__, 54); printf("    expected %s, got %s\n", (AI_ToString)((expected)), (AI_ToString)((C))); goto test_exit; };
  printf("PASSED : %s\n", __func__); return 1; test_exit: exit(1);
}

canonical_original_code:
int test_ai_add_unsigned_with_lshift()
{
  ;
  struct arbint *A;
  struct arbint *B;
  struct arbint *C;
  unsigned long B_shift;
  struct arbint *expected;
  A = AI_NewArbInt_FromLong(0x0000DEAD);
  B = AI_NewArbInt_FromLong(0x0BEEF000);
  B_shift = 1;
  C = ai_add_unsigned_with_lshift(A, B, B_shift);
  expected = AI_NewArbInt_FromString("0x0BEEF0000000DEAD");
  if (!(AI_Equal)((C), (expected))) { printf("TEST_EQUAL Failure (%s, line %d):\n", __func__, 34); printf("    expected %s, got %s\n", (AI_ToString)((expected)), (AI_ToString)((C))); goto test_exit; };
  AI_FreeArbInt(A);
  AI_FreeArbInt(B);
  AI_FreeArbInt(C);
  AI_FreeArbInt(expected);
  A = AI_NewArbInt_FromString("0x12123434565600000000");
  B = AI_NewArbInt_FromString("0x999988886666");
  B_shift = 2;
  C = ai_add_unsigned_with_lshift(A, B, B_shift);
  expected = AI_NewArbInt_FromString("0x9999888878783434565600000000");
  if (!(AI_Equal)((C), (expected))) { printf("TEST_EQUAL Failure (%s, line %d):\n", __func__, 54); printf("    expected %s, got %s\n", (AI_ToString)((expected)), (AI_ToString)((C))); goto test_exit; };
  printf("PASSED : %s\n", __func__); return 1; test_exit: exit(1);
}

user_defined_types: struct arbint { unsigned int *data; unsigned long dataLen; int sign; }


repo: matthewdalton/arbint

decompiled_code:
__int64 test_ai_div_unsigned_by_subtraction__even_divide()
{
__int64 v0; // r15
__int64 v1; // r14
__int64 v2; // r12
__int64 v3; // rbp
__int64 v4; // r13
__int64 v6; // rdi
const char *v7; // r12
const char *v8; // rax
__int64 v9[6]; // [rsp+8h] [rbp-30h] BYREF

v0 = AI_NewArbInt_FromLong(70LL);
v1 = AI_NewArbInt_FromLong(5LL);
v2 = ai_div_unsigned_by_subtraction(v0, v1, v9);
v3 = AI_NewArbInt_FromLong(14LL);
v4 = AI_NewArbInt_FromLong(0LL);
if ( !(unsigned int)AI_Equal(v2, v3) )
{
printf("TEST_EQUAL Failure (%s, line %d):\n", "test_ai_div_unsigned_by_subtraction__even_divide", 71LL);
v6 = v3;
v7 = (const char *)AI_ToString(v2);
goto LABEL_5;
}
if ( !(unsigned int)AI_Equal(v9[0], v4) )
{
printf("TEST_EQUAL Failure (%s, line %d):\n", "test_ai_div_unsigned_by_subtraction__even_divide", 72LL);
v6 = v4;
v7 = (const char *)AI_ToString(v9[0]);
LABEL_5:
v8 = (const char *)AI_ToString(v6);
printf(" expected %s, got %s\n", v8, v7);
exit(1);
}
AI_FreeArbInt(v0);
AI_FreeArbInt(v1);
AI_FreeArbInt(v2);
AI_FreeArbInt(v9[0]);
AI_FreeArbInt(v3);
AI_FreeArbInt(v4);
printf("PASSED : %s\n", "test_ai_div_unsigned_by_subtraction__even_divide");
return 1LL;
}

canonical_decompiled_code:
__int64 func1()
{
__int64 v0; // r15
__int64 v1; // r14
__int64 v2; // r12
__int64 v3; // rbp
__int64 v4; // r13
__int64 v6; // rdi
const char *v7; // r12
const char *v8; // rax
__int64 v9[6]; // [rsp+8h] [rbp-30h] BYREF

v0 = AI_NewArbInt_FromLong(70LL);
v1 = AI_NewArbInt_FromLong(5LL);
v2 = ai_div_unsigned_by_subtraction(v0, v1, v9);
v3 = AI_NewArbInt_FromLong(14LL);
v4 = AI_NewArbInt_FromLong(0LL);
if ( !(unsigned int)AI_Equal(v2, v3) )
{
printf("TEST_EQUAL Failure (%s, line %d):\n", "test_ai_div_unsigned_by_subtraction__even_divide", 71LL);
v6 = v3;
v7 = (const char *)AI_ToString(v2);
goto LABEL_5;
}
if ( !(unsigned int)AI_Equal(v9[0], v4) )
{
printf("TEST_EQUAL Failure (%s, line %d):\n", "test_ai_div_unsigned_by_subtraction__even_divide", 72LL);
v6 = v4;
v7 = (const char *)AI_ToString(v9[0]);
LABEL_5:
v8 = (const char *)AI_ToString(v6);
printf(" expected %s, got %s\n", v8, v7);
exit(1);
}
AI_FreeArbInt(v0);
AI_FreeArbInt(v1);
AI_FreeArbInt(v2);
AI_FreeArbInt(v9[0]);
AI_FreeArbInt(v3);
AI_FreeArbInt(v4);
printf("PASSED : %s\n", "test_ai_div_unsigned_by_subtraction__even_divide");
return 1LL;
}

original_code:
int test_ai_div_unsigned_by_subtraction__even_divide(void)
{
  ;
  ArbInt *A = AI_NewArbInt_FromLong(70);
  ArbInt *B = AI_NewArbInt_FromLong(5);
  ArbInt *remainder;
  ArbInt *expected_div;
  ArbInt *expected_mod;
  ArbInt *C = ai_div_unsigned_by_subtraction(A, B, &remainder);
  expected_div = AI_NewArbInt_FromLong(14);
  expected_mod = AI_NewArbInt_FromLong(0);
  if (!(AI_Equal)((C), (expected_div))) { printf("TEST_EQUAL Failure (%s, line %d):\n", __func__, 71); printf("    expected %s, got %s\n", (AI_ToString)((expected_div)), (AI_ToString)((C))); goto test_exit; };
  if (!(AI_Equal)((remainder), (expected_mod))) { printf("TEST_EQUAL Failure (%s, line %d):\n", __func__, 72); printf("    expected %s, got %s\n", (AI_ToString)((expected_mod)), (AI_ToString)((remainder))); goto test_exit; };
  AI_FreeArbInt(A);
  AI_FreeArbInt(B);
  AI_FreeArbInt(C);
  AI_FreeArbInt(remainder);
  AI_FreeArbInt(expected_div);
  AI_FreeArbInt(expected_mod);
  printf("PASSED : %s\n", __func__); return 1; test_exit: exit(1);
}

canonical_original_code:
int test_ai_div_unsigned_by_subtraction__even_divide()
{
  ;
  struct arbint *A = AI_NewArbInt_FromLong(70);
  struct arbint *B = AI_NewArbInt_FromLong(5);
  struct arbint *remainder;
  struct arbint *expected_div;
  struct arbint *expected_mod;
  struct arbint *C = ai_div_unsigned_by_subtraction(A, B, &remainder);
  expected_div = AI_NewArbInt_FromLong(14);
  expected_mod = AI_NewArbInt_FromLong(0);
  if (!(AI_Equal)((C), (expected_div))) { printf("TEST_EQUAL Failure (%s, line %d):\n", __func__, 71); printf("    expected %s, got %s\n", (AI_ToString)((expected_div)), (AI_ToString)((C))); goto test_exit; };
  if (!(AI_Equal)((remainder), (expected_mod))) { printf("TEST_EQUAL Failure (%s, line %d):\n", __func__, 72); printf("    expected %s, got %s\n", (AI_ToString)((expected_mod)), (AI_ToString)((remainder))); goto test_exit; };
  AI_FreeArbInt(A);
  AI_FreeArbInt(B);
  AI_FreeArbInt(C);
  AI_FreeArbInt(remainder);
  AI_FreeArbInt(expected_div);
  AI_FreeArbInt(expected_mod);
  printf("PASSED : %s\n", __func__); return 1; test_exit: exit(1);
}

variable_types: struct arbint { unsigned int *data; unsigned long dataLen; int sign; } *

return_type: int


decompiled_code:
__int64 test_ai_div_unsigned_by_subtraction__zero_result()
{
__int64 v0; // r15
__int64 v1; // r14
__int64 v2; // r12
__int64 v3; // rbp
__int64 v4; // r13
__int64 v6; // rdi
const char *v7; // r12
const char *v8; // rax
__int64 v9[6]; // [rsp+8h] [rbp-30h] BYREF

v0 = AI_NewArbInt_FromLong(5LL);
v1 = AI_NewArbInt_FromLong(12LL);
v2 = ai_div_unsigned_by_subtraction(v0, v1, v9);
v3 = AI_NewArbInt_FromLong(0LL);
v4 = AI_NewArbInt_FromLong(5LL);
if ( !(unsigned int)AI_Equal(v2, v3) )
{
printf("TEST_EQUAL Failure (%s, line %d):\n", "test_ai_div_unsigned_by_subtraction__zero_result", 96LL);
v6 = v3;
v7 = (const char *)AI_ToString(v2);
goto LABEL_5;
}
if ( !(unsigned int)AI_Equal(v9[0], v4) )
{
printf("TEST_EQUAL Failure (%s, line %d):\n", "test_ai_div_unsigned_by_subtraction__zero_result", 97LL);
v6 = v4;
v7 = (const char *)AI_ToString(v9[0]);
LABEL_5:
v8 = (const char *)AI_ToString(v6);
printf(" expected %s, got %s\n", v8, v7);
exit(1);
}
AI_FreeArbInt(v0);
AI_FreeArbInt(v1);
AI_FreeArbInt(v2);
AI_FreeArbInt(v9[0]);
AI_FreeArbInt(v3);
AI_FreeArbInt(v4);
printf("PASSED : %s\n", "test_ai_div_unsigned_by_subtraction__zero_result");
return 1LL;
}

canonical_decompiled_code:
__int64 func2()
{
__int64 v0; // r15
__int64 v1; // r14
__int64 v2; // r12
__int64 v3; // rbp
__int64 v4; // r13
__int64 v6; // rdi
const char *v7; // r12
const char *v8; // rax
__int64 v9[6]; // [rsp+8h] [rbp-30h] BYREF

v0 = AI_NewArbInt_FromLong(5LL);
v1 = AI_NewArbInt_FromLong(12LL);
v2 = ai_div_unsigned_by_subtraction(v0, v1, v9);
v3 = AI_NewArbInt_FromLong(0LL);
v4 = AI_NewArbInt_FromLong(5LL);
if ( !(unsigned int)AI_Equal(v2, v3) )
{
printf("TEST_EQUAL Failure (%s, line %d):\n", "test_ai_div_unsigned_by_subtraction__zero_result", 96LL);
v6 = v3;
v7 = (const char *)AI_ToString(v2);
goto LABEL_5;
}
if ( !(unsigned int)AI_Equal(v9[0], v4) )
{
printf("TEST_EQUAL Failure (%s, line %d):\n", "test_ai_div_unsigned_by_subtraction__zero_result", 97LL);
v6 = v4;
v7 = (const char *)AI_ToString(v9[0]);
LABEL_5:
v8 = (const char *)AI_ToString(v6);
printf(" expected %s, got %s\n", v8, v7);
exit(1);
}
AI_FreeArbInt(v0);
AI_FreeArbInt(v1);
AI_FreeArbInt(v2);
AI_FreeArbInt(v9[0]);
AI_FreeArbInt(v3);
AI_FreeArbInt(v4);
printf("PASSED : %s\n", "test_ai_div_unsigned_by_subtraction__zero_result");
return 1LL;
}

original_code:
int test_ai_div_unsigned_by_subtraction__zero_result(void)
{
  ;
  ArbInt *A = AI_NewArbInt_FromLong(5);
  ArbInt *B = AI_NewArbInt_FromLong(12);
  ArbInt *remainder;
  ArbInt *expected_div;
  ArbInt *expected_mod;
  ArbInt *C = ai_div_unsigned_by_subtraction(A, B, &remainder);
  expected_div = AI_NewArbInt_FromLong(0);
  expected_mod = AI_NewArbInt_FromLong(5);
  if (!(AI_Equal)((C), (expected_div))) { printf("TEST_EQUAL Failure (%s, line %d):\n", __func__, 96); printf("    expected %s, got %s\n", (AI_ToString)((expected_div)), (AI_ToString)((C))); goto test_exit; };
  if (!(AI_Equal)((remainder), (expected_mod))) { printf("TEST_EQUAL Failure (%s, line %d):\n", __func__, 97); printf("    expected %s, got %s\n", (AI_ToString)((expected_mod)), (AI_ToString)((remainder))); goto test_exit; };
  AI_FreeArbInt(A);
  AI_FreeArbInt(B);
  AI_FreeArbInt(C);
  AI_FreeArbInt(remainder);
  AI_FreeArbInt(expected_div);
  AI_FreeArbInt(expected_mod);
  printf("PASSED : %s\n", __func__); return 1; test_exit: exit(1);
}

canonical_original_code:
int test_ai_div_unsigned_by_subtraction__zero_result()
{
  ;
  struct arbint *A = AI_NewArbInt_FromLong(5);
  struct arbint *B = AI_NewArbInt_FromLong(12);
  struct arbint *remainder;
  struct arbint *expected_div;
  struct arbint *expected_mod;
  struct arbint *C = ai_div_unsigned_by_subtraction(A, B, &remainder);
  expected_div = AI_NewArbInt_FromLong(0);
  expected_mod = AI_NewArbInt_FromLong(5);
  if (!(AI_Equal)((C), (expected_div))) { printf("TEST_EQUAL Failure (%s, line %d):\n", __func__, 96); printf("    expected %s, got %s\n", (AI_ToString)((expected_div)), (AI_ToString)((C))); goto test_exit; };
  if (!(AI_Equal)((remainder), (expected_mod))) { printf("TEST_EQUAL Failure (%s, line %d):\n", __func__, 97); printf("    expected %s, got %s\n", (AI_ToString)((expected_mod)), (AI_ToString)((remainder))); goto test_exit; };
  AI_FreeArbInt(A);
  AI_FreeArbInt(B);
  AI_FreeArbInt(C);
  AI_FreeArbInt(remainder);
  AI_FreeArbInt(expected_div);
  AI_FreeArbInt(expected_mod);
  printf("PASSED : %s\n", __func__); return 1; test_exit: exit(1);
}


decompiled_code:
__int64 test_AI_Greater()
{
__int64 v0; // rbp
__int64 v1; // r12
__int64 v2; // r13

v0 = AI_NewArbInt_FromLong(4294967291LL);
v1 = AI_NewArbInt_FromLong(0LL);
v2 = AI_NewArbInt_FromLong(6LL);
if ( !(unsigned int)AI_Greater(v1, v0) )
{
printf("TEST_TRUE Failure (%s, %d): %s\n", "test_AI_Greater", 115LL, "AI_Greater(zero, negative)");
goto LABEL_6;
}
if ( !(unsigned int)AI_Greater(v2, v1) )
{
printf("TEST_TRUE Failure (%s, %d): %s\n", "test_AI_Greater", 116LL, "AI_Greater(positive, zero)");
LABEL_6:
exit(1);
}
if ( !(unsigned int)AI_Greater(v2, v0) )
{
printf("TEST_TRUE Failure (%s, %d): %s\n", "test_AI_Greater", 117LL, "AI_Greater(positive, negative)");
goto LABEL_6;
}
printf("PASSED : %s\n", "test_AI_Greater");
return 1LL;
}

canonical_decompiled_code:
__int64 func3()
{
__int64 v0; // rbp
__int64 v1; // r12
__int64 v2; // r13

v0 = AI_NewArbInt_FromLong(4294967291LL);
v1 = AI_NewArbInt_FromLong(0LL);
v2 = AI_NewArbInt_FromLong(6LL);
if ( !(unsigned int)AI_Greater(v1, v0) )
{
printf("TEST_TRUE Failure (%s, %d): %s\n", "test_AI_Greater", 115LL, "AI_Greater(zero, negative)");
goto LABEL_6;
}
if ( !(unsigned int)AI_Greater(v2, v1) )
{
printf("TEST_TRUE Failure (%s, %d): %s\n", "test_AI_Greater", 116LL, "AI_Greater(positive, zero)");
LABEL_6:
exit(1);
}
if ( !(unsigned int)AI_Greater(v2, v0) )
{
printf("TEST_TRUE Failure (%s, %d): %s\n", "test_AI_Greater", 117LL, "AI_Greater(positive, negative)");
goto LABEL_6;
}
printf("PASSED : %s\n", "test_AI_Greater");
return 1LL;
}

original_code:
int test_AI_Greater(void) {
  ;
  ArbInt *negative = AI_NewArbInt_FromLong(-5);
  ArbInt *zero = AI_NewArbInt_FromLong(0);
  ArbInt *positive = AI_NewArbInt_FromLong(6);
  if (!(AI_Greater(zero, negative))) { printf("TEST_TRUE Failure (%s, %d): %s\n", __func__, 115, "AI_Greater(zero, negative)"); goto test_exit; };
  if (!(AI_Greater(positive, zero))) { printf("TEST_TRUE Failure (%s, %d): %s\n", __func__, 116, "AI_Greater(positive, zero)"); goto test_exit; };
  if (!(AI_Greater(positive, negative))) { printf("TEST_TRUE Failure (%s, %d): %s\n", __func__, 117, "AI_Greater(positive, negative)"); goto test_exit; };
  printf("PASSED : %s\n", __func__); return 1; test_exit: exit(1);
}

canonical_original_code:
int test_AI_Greater() {
  ;
  struct arbint *negative = AI_NewArbInt_FromLong(-5);
  struct arbint *zero = AI_NewArbInt_FromLong(0);
  struct arbint *positive = AI_NewArbInt_FromLong(6);
  if (!(AI_Greater(zero, negative))) { printf("TEST_TRUE Failure (%s, %d): %s\n", __func__, 115, "AI_Greater(zero, negative)"); goto test_exit; };
  if (!(AI_Greater(positive, zero))) { printf("TEST_TRUE Failure (%s, %d): %s\n", __func__, 116, "AI_Greater(positive, zero)"); goto test_exit; };
  if (!(AI_Greater(positive, negative))) { printf("TEST_TRUE Failure (%s, %d): %s\n", __func__, 117, "AI_Greater(positive, negative)"); goto test_exit; };
  printf("PASSED : %s\n", __func__); return 1; test_exit: exit(1);
}


decompiled_code:
_BOOL8 test_all()
{
_BOOL8 result; // rax

if ( (unsigned int)test_AI_Greater()
&& (unsigned int)test_ai_add_unsigned_with_lshift()
&& (unsigned int)test_ai_div_unsigned_by_subtraction__zero_result() )
{
result = (unsigned int)test_ai_div_unsigned_by_subtraction__even_divide() != 0;
}
else
{
result = 0LL;
}
return result;
}

canonical_decompiled_code:
_BOOL8 func4()
{
_BOOL8 result; // rax

if ( (unsigned int)func3()
&& (unsigned int)func0()
&& (unsigned int)func2() )
{
result = (unsigned int)func1() != 0;
}
else
{
result = 0LL;
}
return result;
}

original_code:
int test_all(void)
{
  return
    test_AI_Greater() &&
    test_ai_add_unsigned_with_lshift() &&
    test_ai_div_unsigned_by_subtraction__zero_result() &&
    test_ai_div_unsigned_by_subtraction__even_divide() &&
    1;
}

canonical_original_code:
int test_all()
{
  return
    test_AI_Greater() &&
    test_ai_add_unsigned_with_lshift() &&
    test_ai_div_unsigned_by_subtraction__zero_result() &&
    test_ai_div_unsigned_by_subtraction__even_divide() &&
    1;
}


decompiled_code:
__int64 __fastcall next_iteration(__int64 a1, __int64 a2)
{
__int64 v2; // rbp
__int64 v3; // r12
__int64 v4; // rbp
__int64 v5; // r13
__int64 v7[4]; // [rsp+8h] [rbp-20h] BYREF

v2 = AI_Div(a2, a1, v7);
AI_FreeArbInt(v7[0]);
v3 = AI_Add(a1, v2);
AI_FreeArbInt(v2);
v4 = AI_NewArbInt_FromLong(2LL);
v5 = AI_Div(v3, v4, v7);
AI_FreeArbInt(v3);
AI_FreeArbInt(v4);
AI_FreeArbInt(v7[0]);
return v5;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, __int64 a2)
{
__int64 v2; // rbp
__int64 v3; // r12
__int64 v4; // rbp
__int64 v5; // r13
__int64 v7[4]; // [rsp+8h] [rbp-20h] BYREF

v2 = AI_Div(a2, a1, v7);
AI_FreeArbInt(v7[0]);
v3 = AI_Add(a1, v2);
AI_FreeArbInt(v2);
v4 = AI_NewArbInt_FromLong(2LL);
v5 = AI_Div(v3, v4, v7);
AI_FreeArbInt(v3);
AI_FreeArbInt(v4);
AI_FreeArbInt(v7[0]);
return v5;
}

original_code:
ArbInt *next_iteration(const ArbInt *curr, const ArbInt *n)
{
  ArbInt *rem;
  ArbInt *divResult = AI_Div(n, curr, &rem);
  AI_FreeArbInt(rem);
  ArbInt *addResult = AI_Add(curr, divResult);
  AI_FreeArbInt(divResult);
  ArbInt *two = AI_NewArbInt_FromLong(2);
  ArbInt *next = AI_Div(addResult, two, &rem);
  AI_FreeArbInt(addResult);
  AI_FreeArbInt(two);
  AI_FreeArbInt(rem);
  return next;
}

canonical_original_code:
struct arbint *next_iteration(struct arbint *curr, struct arbint *n)
{
  struct arbint *rem;
  struct arbint *divResult = AI_Div(n, curr, &rem);
  AI_FreeArbInt(rem);
  struct arbint *addResult = AI_Add(curr, divResult);
  AI_FreeArbInt(divResult);
  struct arbint *two = AI_NewArbInt_FromLong(2);
  struct arbint *next = AI_Div(addResult, two, &rem);
  AI_FreeArbInt(addResult);
  AI_FreeArbInt(two);
  AI_FreeArbInt(rem);
  return next;
}

variable_types:
curr
struct arbint *

variable_types:
n
struct arbint *

return_type: struct arbint { unsigned int *data; unsigned long dataLen; int sign; } *


decompiled_code:
__int64 __fastcall AI_isqrt(__int64 a1)
{
__int64 v2; // rbp
__int64 v3; // rbp
__int64 v4; // rdi
__int64 v5; // r12
__int64 v6; // r13
__int64 result; // rax

v2 = AI_NewArbInt_From32(0LL);
if ( (unsigned int)AI_Less(a1, v2) )
{
AI_FreeArbInt(v2);
result = 0LL;
}
else
{
AI_FreeArbInt(v2);
v3 = AI_NewArbInt_FromCopy(a1);
while ( 1 )
{
v5 = next_iteration(v3, a1);
v6 = AI_Add_Value(v3, 1LL, 1LL);
if ( (unsigned int)AI_Equal(v5, v3) || (unsigned int)AI_Equal(v5, v6) )
break;
v4 = v3;
v3 = v5;
AI_FreeArbInt(v4);
AI_FreeArbInt(v6);
}
AI_FreeArbInt(v3);
AI_FreeArbInt(v6);
result = v5;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1)
{
__int64 v2; // rbp
__int64 v3; // rbp
__int64 v4; // rdi
__int64 v5; // r12
__int64 v6; // r13
__int64 result; // rax

v2 = AI_NewArbInt_From32(0LL);
if ( (unsigned int)AI_Less(a1, v2) )
{
AI_FreeArbInt(v2);
result = 0LL;
}
else
{
AI_FreeArbInt(v2);
v3 = AI_NewArbInt_FromCopy(a1);
while ( 1 )
{
v5 = func0(v3, a1);
v6 = AI_Add_Value(v3, 1LL, 1LL);
if ( (unsigned int)AI_Equal(v5, v3) || (unsigned int)AI_Equal(v5, v6) )
break;
v4 = v3;
v3 = v5;
AI_FreeArbInt(v4);
AI_FreeArbInt(v6);
}
AI_FreeArbInt(v3);
AI_FreeArbInt(v6);
result = v5;
}
return result;
}

original_code:
ArbInt *AI_isqrt(ArbInt const *n)
{
  ArbInt *zero = AI_NewArbInt_From32(0);
  if (AI_Less(n, zero)) {
    AI_FreeArbInt(zero);
    return ((void *)0);
  }
  AI_FreeArbInt(zero);
  ArbInt *k = AI_NewArbInt_FromCopy(n);
  ArbInt *next_k;
  ArbInt *k_plus_one = ((void *)0);
  for (;;) {
    next_k = next_iteration(k, n);
    k_plus_one = AI_Add_Value(k, 1, 1);
    if (AI_Equal(next_k, k) || AI_Equal(next_k, k_plus_one)) {
      break;
    }
    AI_FreeArbInt(k);
    AI_FreeArbInt(k_plus_one);
    k = next_k;
  }
  AI_FreeArbInt(k);
  AI_FreeArbInt(k_plus_one);
  return next_k;
}

canonical_original_code:
struct arbint *AI_isqrt(struct arbint *n)
{
  struct arbint *zero = AI_NewArbInt_From32(0);
  if (AI_Less(n, zero)) {
    AI_FreeArbInt(zero);
    return ((void *)0);
  }
  AI_FreeArbInt(zero);
  struct arbint *k = AI_NewArbInt_FromCopy(n);
  struct arbint *next_k;
  struct arbint *k_plus_one = ((void *)0);
  for (;;) {
    next_k = next_iteration(k, n);
    k_plus_one = AI_Add_Value(k, 1, 1);
    if (AI_Equal(next_k, k) || AI_Equal(next_k, k_plus_one)) {
      break;
    }
    AI_FreeArbInt(k);
    AI_FreeArbInt(k_plus_one);
    k = next_k;
  }
  AI_FreeArbInt(k);
  AI_FreeArbInt(k_plus_one);
  return next_k;
}


decompiled_code:
// attributes: thunk
void *AI_malloc(size_t size)
{
return malloc(size);
}

canonical_decompiled_code:
void *func0(size_t size)
{
return malloc(size);
}

canonical_original_code:
void *AI_malloc(unsigned long size)
{
  return malloc(size);
}

variable_types:
size
unsigned long

return_type: void *


decompiled_code:
// attributes: thunk
void AI_free(void *ptr)
{
free(ptr);
}

canonical_decompiled_code:
void func1(void *ptr)
{
free(ptr);
}

original_code:
void AI_free(void *mem)
{
  free(mem);
}

canonical_original_code:
void AI_free(void *mem)
{
  free(mem);
}

variable_types:
mem
void *

return_type: void


decompiled_code:
// attributes: thunk
void *AI_memcpy(void *dest, const void *src, size_t n)
{
return memcpy(dest, src, n);
}

canonical_decompiled_code:
void *func2(void *dest, const void *src, size_t n)
{
return memcpy(dest, src, n);
}

original_code:
void *AI_memcpy(void *dest, void const *src, size_t size)
{
  return memcpy(dest, src, size);
}

canonical_original_code:
void *AI_memcpy(void *dest, void *src, unsigned long size)
{
  return memcpy(dest, src, size);
}

variable_types:
dest
void *

variable_types:
src
void *


decompiled_code:
// attributes: thunk
void *AI_memset(void *s, int c, size_t n)
{
return memset(s, c, n);
}

canonical_decompiled_code:
void *func3(void *s, int c, size_t n)
{
return memset(s, c, n);
}

original_code:
void *AI_memset(void *dest, int val, size_t len)
{
  return memset(dest, val, len);
}

canonical_original_code:
void *AI_memset(void *dest, int val, unsigned long len)
{
  return memset(dest, val, len);
}

variable_types: val int

variable_types:
len
unsigned long


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

result = AI_malloc(24LL);
if ( result )
{
*(_QWORD *)result = 0LL;
*(_QWORD *)(result + 8) = 0LL;
*(_DWORD *)(result + 16) = 1;
}
return result;
}

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

result = AI_malloc(24LL);
if ( result )
{
*(_QWORD *)result = 0LL;
*(_QWORD *)(result + 8) = 0LL;
*(_DWORD *)(result + 16) = 1;
}
return result;
}

original_code:
static
ArbInt *ai_new_empty(void)
{
  ArbInt *ai = AI_malloc(sizeof(ArbInt));
  if (ai != ((void *)0)) {
    ai->data = ((void *)0);
    ai->dataLen = 0;
    ai->sign = 1;
  }
  return ai;
}

canonical_original_code:
static struct arbint *ai_new_empty()
{
  struct arbint *ai = AI_malloc(sizeof(ArbInt));
  if (ai != ((void *)0)) {
    ai->data = ((void *)0);
    ai->dataLen = 0;
    ai->sign = 1;
  }
  return ai;
}


decompiled_code:
__int64 __fastcall ai_assign_value(__int64 a1, __int64 a2, __int64 a3, int a4)
{
__int64 result; // rax

if ( !a2 )
_assert_fail("value != NULL", "AI_new.c", 0x174u, "ai_assign_value");
if ( !a3 )
_assert_fail("len > 0", "AI_new.c", 0x175u, "ai_assign_value");
result = (a4 + 1) & 0xFFFFFFFD;
if ( ((a4 + 1) & 0xFFFFFFFD) != 0 )
_assert_fail("sign == -1 || sign == 1", "AI_new.c", 0x176u, "ai_assign_value");
if ( *(_QWORD *)a1 )
result = AI_free();
*(_QWORD *)a1 = a2;
*(_QWORD *)(a1 + 8) = a3;
*(_DWORD *)(a1 + 16) = a4;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1, __int64 a2, __int64 a3, int a4)
{
__int64 result; // rax

if ( !a2 )
_assert_fail("value != NULL", "AI_new.c", 0x174u, "ai_assign_value");
if ( !a3 )
_assert_fail("len > 0", "AI_new.c", 0x175u, "ai_assign_value");
result = (a4 + 1) & 0xFFFFFFFD;
if ( ((a4 + 1) & 0xFFFFFFFD) != 0 )
_assert_fail("sign == -1 || sign == 1", "AI_new.c", 0x176u, "ai_assign_value");
if ( *(_QWORD *)a1 )
result = AI_free();
*(_QWORD *)a1 = a2;
*(_QWORD *)(a1 + 8) = a3;
*(_DWORD *)(a1 + 16) = a4;
return result;
}

original_code:
static void
ai_assign_value(ArbInt *ai, aibase_t *value, unsigned long len, int sign)
{
  ((void) sizeof ((value != ((void *)0)) ? 1 : 0), __extension__ ({ if (value != ((void *)0)) ; else __assert_fail ("value != NULL", "AI_new.c", 372, __extension__ __PRETTY_FUNCTION__); }));
  ((void) sizeof ((len > 0) ? 1 : 0), __extension__ ({ if (len > 0) ; else __assert_fail ("len > 0", "AI_new.c", 373, __extension__ __PRETTY_FUNCTION__); }));
  ((void) sizeof ((sign == -1 || sign == 1) ? 1 : 0), __extension__ ({ if (sign == -1 || sign == 1) ; else __assert_fail ("sign == -1 || sign == 1", "AI_new.c", 374, __extension__ __PRETTY_FUNCTION__); }));
  if (ai->data != ((void *)0)) {
    AI_free(ai->data);
  }
  ai->data = value;
  ai->dataLen = len;
  ai->sign = sign;
}

canonical_original_code:
static void ai_assign_value(struct arbint *ai, unsigned int *value, unsigned long len, int sign)
{
  ((void) sizeof ((value != ((void *)0)) ? 1 : 0), __extension__ ({ if (value != ((void *)0)) ; else __assert_fail ("value != NULL", "AI_new.c", 372, __extension__ __PRETTY_FUNCTION__); }));
  ((void) sizeof ((len > 0) ? 1 : 0), __extension__ ({ if (len > 0) ; else __assert_fail ("len > 0", "AI_new.c", 373, __extension__ __PRETTY_FUNCTION__); }));
  ((void) sizeof ((sign == -1 || sign == 1) ? 1 : 0), __extension__ ({ if (sign == -1 || sign == 1) ; else __assert_fail ("sign == -1 || sign == 1", "AI_new.c", 374, __extension__ __PRETTY_FUNCTION__); }));
  if (ai->data != ((void *)0)) {
    AI_free(ai->data);
  }
  ai->data = value;
  ai->dataLen = len;
  ai->sign = sign;
}

variable_types:
value
unsigned int *

variable_types: sign int


decompiled_code:
__int64 __fastcall AI_NewArbInt_FromValue(int a1, int a2)
{
__int64 v2; // r12
_DWORD *v3; // rax
__int64 v5; // rdi

v2 = ai_new_empty();
if ( v2 )
{
v3 = (_DWORD *)AI_malloc(4LL);
if ( v3 )
{
*v3 = a1;
ai_assign_value(v2, (__int64)v3, 1LL, a2);
}
else
{
v5 = v2;
v2 = 0LL;
AI_free(v5);
}
}
return v2;
}

canonical_decompiled_code:
__int64 __fastcall func2(int a1, int a2)
{
__int64 v2; // r12
_DWORD *v3; // rax
__int64 v5; // rdi

v2 = func0();
if ( v2 )
{
v3 = (_DWORD *)AI_malloc(4LL);
if ( v3 )
{
*v3 = a1;
func1(v2, (__int64)v3, 1LL, a2);
}
else
{
v5 = v2;
v2 = 0LL;
AI_free(v5);
}
}
return v2;
}

original_code:
ArbInt *AI_NewArbInt_FromValue(aibase_t value, int sign)
{
  ArbInt *ai = ai_new_empty();
  if (ai != ((void *)0)) {
    aibase_t *lv = AI_malloc(sizeof(aibase_t));
    if (lv == ((void *)0)) {
      goto error_exit;
    }
    *lv = value;
    ai_assign_value(ai, lv, 1, sign);
  }
  return ai;
 error_exit:
  if (ai != ((void *)0)) {
    AI_free(ai);
  }
  return ((void *)0);
}

canonical_original_code:
struct arbint *AI_NewArbInt_FromValue(unsigned int value, int sign)
{
  struct arbint *ai = ai_new_empty();
  if (ai != ((void *)0)) {
    unsigned int *lv = AI_malloc(sizeof(aibase_t));
    if (lv == ((void *)0)) {
      goto error_exit;
    }
    *lv = value;
    ai_assign_value(ai, lv, 1, sign);
  }
  return ai;
 error_exit:
  if (ai != ((void *)0)) {
    AI_free(ai);
  }
  return ((void *)0);
}

variable_types:
value
unsigned int

variable_types:
lv
unsigned int *


decompiled_code:
__int64 __fastcall AI_NewArbInt_FromLong(int a1)
{
int v1; // esi

v1 = 1;
if ( a1 < 0 )
{
a1 = -a1;
v1 = -1;
}
return AI_NewArbInt_FromValue(a1, v1);
}

canonical_decompiled_code:
__int64 __fastcall func3(int a1)
{
int v1; // esi

v1 = 1;
if ( a1 < 0 )
{
a1 = -a1;
v1 = -1;
}
return func2(a1, v1);
}

original_code:
ArbInt *AI_NewArbInt_FromLong(int32_t value)
{
  int sign = 1;
  if (value < 0) {
    value = -value;
    sign = -1;
  }
  return AI_NewArbInt_FromValue((aibase_t)value, sign);
}

canonical_original_code:
struct arbint *AI_NewArbInt_FromLong(int value)
{
  int sign = 1;
  if (value < 0) {
    value = -value;
    sign = -1;
  }
  return AI_NewArbInt_FromValue((unsigned int)value, sign);
}

variable_types: value int


decompiled_code:
__int64 AI_NewArbInt()
{
return AI_NewArbInt_FromLong(0);
}

canonical_decompiled_code:
__int64 func4()
{
return func3(0);
}

original_code:
ArbInt *AI_NewArbInt(void)
{
  return AI_NewArbInt_FromLong(0);
}

canonical_original_code:
struct arbint *AI_NewArbInt()
{
  return AI_NewArbInt_FromLong(0);
}


decompiled_code:
// attributes: thunk
__int64 __fastcall AI_NewArbInt_From32(int a1)
{
return AI_NewArbInt_FromLong(a1);
}

canonical_decompiled_code:
__int64 __fastcall func5(int a1)
{
return func3(a1);
}

original_code:
ArbInt *AI_NewArbInt_From32(int32_t value)
{
  return AI_NewArbInt_FromLong(value);
}

canonical_original_code:
struct arbint *AI_NewArbInt_From32(int value)
{
  return AI_NewArbInt_FromLong(value);
}


decompiled_code:
__int64 __fastcall AI_FreeArbInt(__int64 *a1)
{
__int64 v2; // rdi

v2 = *a1;
if ( v2 )
AI_free(v2);
return AI_free(a1);
}

canonical_decompiled_code:
__int64 __fastcall func6(__int64 *a1)
{
__int64 v2; // rdi

v2 = *a1;
if ( v2 )
AI_free(v2);
return AI_free(a1);
}

original_code:
void AI_FreeArbInt(ArbInt *aival)
{
  if (aival->data != ((void *)0)) {
    AI_free(aival->data);
  }
  if (aival != ((void *)0)) {
    AI_free(aival);
  }
}

canonical_original_code:
void AI_FreeArbInt(struct arbint *aival)
{
  if (aival->data != ((void *)0)) {
    AI_free(aival->data);
  }
  if (aival != ((void *)0)) {
    AI_free(aival);
  }
}


decompiled_code:
__int64 __fastcall AI_NewArbInt_FromCopy(const void **a1)
{
__int64 v1; // r12
__int64 v2; // rbp
const void *v3; // rdx
__int64 *v5; // rdi

v1 = ai_new_empty();
if ( v1 )
{
v2 = AI_malloc(4LL * (_QWORD)a1[1]);
if ( v2 )
{
AI_memcpy(v2, *a1, 4LL * (_QWORD)a1[1]);
ai_assign_value(v1, v2, (__int64)a1[1], *((_DWORD *)a1 + 4));
v3 = a1[1];
if ( v3 != *(const void **)(v1 + 8) )
_assert_fail("ai->dataLen == ret->dataLen", "AI_new.c", 0xD7u, "AI_NewArbInt_FromCopy");
if ( memcmp(*a1, *(const void **)v1, 4LL * (_QWORD)v3) )
_assert_fail(
"memcmp(ai->data, ret->data, ai->dataLen * sizeof(aibase_t)) == 0",
"AI_new.c",
0xD9u,
"AI_NewArbInt_FromCopy");
}
else
{
v5 = (__int64 *)v1;
v1 = 0LL;
AI_FreeArbInt(v5);
}
}
return v1;
}

canonical_decompiled_code:
__int64 __fastcall func8(const void **a1)
{
__int64 v1; // r12
__int64 v2; // rbp
const void *v3; // rdx
__int64 *v5; // rdi

v1 = func0();
if ( v1 )
{
v2 = AI_malloc(4LL * (_QWORD)a1[1]);
if ( v2 )
{
AI_memcpy(v2, *a1, 4LL * (_QWORD)a1[1]);
func1(v1, v2, (__int64)a1[1], *((_DWORD *)a1 + 4));
v3 = a1[1];
if ( v3 != *(const void **)(v1 + 8) )
_assert_fail("ai->dataLen == ret->dataLen", "AI_new.c", 0xD7u, "AI_NewArbInt_FromCopy");
if ( memcmp(*a1, *(const void **)v1, 4LL * (_QWORD)v3) )
_assert_fail(
"memcmp(ai->data, ret->data, ai->dataLen * sizeof(aibase_t)) == 0",
"AI_new.c",
0xD9u,
"AI_NewArbInt_FromCopy");
}
else
{
v5 = (__int64 *)v1;
v1 = 0LL;
func6(v5);
}
}
return v1;
}

original_code:
ArbInt *AI_NewArbInt_FromCopy(ArbInt const *ai)
{
  ArbInt *ret = ai_new_empty();
  if (ret == ((void *)0))
    return ((void *)0);
  aibase_t *lv = AI_malloc(ai->dataLen * sizeof(aibase_t));
  if (lv == ((void *)0)) {
    AI_FreeArbInt(ret);
    return ((void *)0);
  }
  AI_memcpy(lv, ai->data, ai->dataLen * sizeof(aibase_t));
  ai_assign_value(ret, lv, ai->dataLen, ai->sign);
  ((void) sizeof ((ai->dataLen == ret->dataLen) ? 1 : 0), __extension__ ({ if (ai->dataLen == ret->dataLen) ; else __assert_fail ("ai->dataLen == ret->dataLen", "AI_new.c", 215, __extension__ __PRETTY_FUNCTION__); }));
  ((void) sizeof ((ai->sign == ai->sign) ? 1 : 0), __extension__ ({ if (ai->sign == ai->sign) ; else __assert_fail ("ai->sign == ai->sign", "AI_new.c", 216, __extension__ __PRETTY_FUNCTION__); }));
  ((void) sizeof ((memcmp(ai->data, ret->data, ai->dataLen * sizeof(aibase_t)) == 0) ? 1 : 0), __extension__ ({ if (memcmp(ai->data, ret->data, ai->dataLen * sizeof(aibase_t)) == 0) ; else __assert_fail ("memcmp(ai->data, ret->data, ai->dataLen * sizeof(aibase_t)) == 0", "AI_new.c", 217, __extension__ __PRETTY_FUNCTION__); }));
  return ret;
}

canonical_original_code:
struct arbint *AI_NewArbInt_FromCopy(struct arbint *ai)
{
  struct arbint *ret = ai_new_empty();
  if (ret == ((void *)0))
    return ((void *)0);
  unsigned int *lv = AI_malloc(ai->dataLen * sizeof(aibase_t));
  if (lv == ((void *)0)) {
    AI_FreeArbInt(ret);
    return ((void *)0);
  }
  AI_memcpy(lv, ai->data, ai->dataLen * sizeof(aibase_t));
  ai_assign_value(ret, lv, ai->dataLen, ai->sign);
  ((void) sizeof ((ai->dataLen == ret->dataLen) ? 1 : 0), __extension__ ({ if (ai->dataLen == ret->dataLen) ; else __assert_fail ("ai->dataLen == ret->dataLen", "AI_new.c", 215, __extension__ __PRETTY_FUNCTION__); }));
  ((void) sizeof ((ai->sign == ai->sign) ? 1 : 0), __extension__ ({ if (ai->sign == ai->sign) ; else __assert_fail ("ai->sign == ai->sign", "AI_new.c", 216, __extension__ __PRETTY_FUNCTION__); }));
  ((void) sizeof ((memcmp(ai->data, ret->data, ai->dataLen * sizeof(aibase_t)) == 0) ? 1 : 0), __extension__ ({ if (memcmp(ai->data, ret->data, ai->dataLen * sizeof(aibase_t)) == 0) ; else __assert_fail ("memcmp(ai->data, ret->data, ai->dataLen * sizeof(aibase_t)) == 0", "AI_new.c", 217, __extension__ __PRETTY_FUNCTION__); }));
  return ret;
}

variable_types:
ai
struct arbint *


decompiled_code:
__int64 __fastcall ai_pow_by_power2(__int64 a1, int a2)
{
int v2; // ebx
__int64 i; // rdi

v2 = a2;
for ( i = AI_NewArbInt_FromCopy(); v2; --v2 )
i = AI_Mul(i, i);
return i;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, int a2)
{
int v2; // ebx
__int64 i; // rdi

v2 = a2;
for ( i = AI_NewArbInt_FromCopy(); v2; --v2 )
i = AI_Mul(i, i);
return i;
}

original_code:
ArbInt *ai_pow_by_power2(ArbInt const *A, aibase_t exponent)
{
  ArbInt *ans = AI_NewArbInt_FromCopy(A);
  ArbInt *val;
  while (exponent > 0) {
    val = AI_Mul(ans, ans);
    ans = val;
    exponent--;
  }
  return ans;
}

canonical_original_code:
struct arbint *ai_pow_by_power2(struct arbint *A, unsigned int exponent)
{
  struct arbint *ans = AI_NewArbInt_FromCopy(A);
  struct arbint *val;
  while (exponent > 0) {
    val = AI_Mul(ans, ans);
    ans = val;
    exponent--;
  }
  return ans;
}

variable_types:
A
struct arbint *

variable_types:
exponent
unsigned int


decompiled_code:
__int64 __fastcall ai_pow_positive(__int64 a1, __int64 a2)
{
int v2; // ebx
__int64 v3; // r12
int v4; // er13
__int64 v5; // rbp
int v6; // esi
__int64 v7; // rsi
__int64 v8; // r15

v2 = 0;
v3 = AI_NewArbInt_From32(1LL);
v4 = arbint_get_hsb_position(a2);
v5 = AI_Make_Bit_Iter(a2);
while ( v2 != v4 )
{
if ( (unsigned int)AI_Bit_Iter_Get(v5) )
{
v6 = v2++;
v7 = ai_pow_by_power2(a1, v6);
v8 = AI_Mul(v3, v7);
AI_FreeArbInt(v3);
v3 = v8;
if ( !(unsigned int)AI_Bit_Iter_Inc(v5) )
return v3;
}
else
{
++v2;
if ( !(unsigned int)AI_Bit_Iter_Inc(v5) )
return v3;
}
}
return v3;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1, __int64 a2)
{
int v2; // ebx
__int64 v3; // r12
int v4; // er13
__int64 v5; // rbp
int v6; // esi
__int64 v7; // rsi
__int64 v8; // r15

v2 = 0;
v3 = AI_NewArbInt_From32(1LL);
v4 = arbint_get_hsb_position(a2);
v5 = AI_Make_Bit_Iter(a2);
while ( v2 != v4 )
{
if ( (unsigned int)AI_Bit_Iter_Get(v5) )
{
v6 = v2++;
v7 = func0(a1, v6);
v8 = AI_Mul(v3, v7);
AI_FreeArbInt(v3);
v3 = v8;
if ( !(unsigned int)AI_Bit_Iter_Inc(v5) )
return v3;
}
else
{
++v2;
if ( !(unsigned int)AI_Bit_Iter_Inc(v5) )
return v3;
}
}
return v3;
}

original_code:
ArbInt *ai_pow_positive(ArbInt const *A, ArbInt const *B)
{
  ArbInt *ans = AI_NewArbInt_From32(1);
  ArbInt *val;
  aibase_t hsb = arbint_get_hsb_position(B);
  ArbInt_BitIterator *bi = AI_Make_Bit_Iter(B);
  aibase_t bitNum = 0;
  aibase_t exp = 1;
  while (bitNum < hsb) {
    int isSet = AI_Bit_Iter_Get(bi);
    if (isSet) {
      val = AI_Mul(ans, ai_pow_by_power2(A, bitNum));
      AI_FreeArbInt(ans);
      ans = val;
    }
    bitNum++;
    exp++;
    if (!AI_Bit_Iter_Inc(bi)) {
      break;
    }
  }
  return ans;
}

canonical_original_code:
struct arbint *ai_pow_positive(struct arbint *A, struct arbint *B)
{
  struct arbint *ans = AI_NewArbInt_From32(1);
  struct arbint *val;
  unsigned int hsb = arbint_get_hsb_position(B);
  struct arbint_bititerator *bi = AI_Make_Bit_Iter(B);
  unsigned int bitNum = 0;
  unsigned int exp = 1;
  while (bitNum < hsb) {
    int isSet = AI_Bit_Iter_Get(bi);
    if (isSet) {
      val = AI_Mul(ans, ai_pow_by_power2(A, bitNum));
      AI_FreeArbInt(ans);
      ans = val;
    }
    bitNum++;
    exp++;
    if (!AI_Bit_Iter_Inc(bi)) {
      break;
    }
  }
  return ans;
}

variable_types:
B
struct arbint *

variable_types: struct arbint { unsigned int *data; unsigned long dataLen; int sign; } *

variable_types:
hsb
unsigned int

variable_types: struct arbint_bititerator { unsigned int *begin; unsigned int *end; unsigned int *byte; unsigned int bit; } *

variable_types:
bitNum
unsigned int

variable_types:
exp
unsigned int

variable_types: isSet int


decompiled_code:
__int64 __fastcall AI_Pow(__int64 a1, __int64 a2)
{
__int64 v2; // rbp
__int64 v3; // r13
__int64 result; // rax

v2 = AI_NewArbInt_From32(0LL);
v3 = AI_NewArbInt_From32(1LL);
if ( (unsigned int)AI_Equal(a2, v2) )
{
AI_FreeArbInt(v2);
result = v3;
}
else if ( (unsigned int)AI_Equal(a2, v3) )
{
AI_FreeArbInt(v2);
AI_FreeArbInt(v3);
result = AI_NewArbInt_FromCopy(a1);
}
else if ( (unsigned int)AI_Less(a2, v2) )
{
AI_FreeArbInt(v2);
AI_FreeArbInt(v3);
result = v2;
}
else
{
AI_FreeArbInt(v2);
AI_FreeArbInt(v3);
result = ai_pow_positive(a1, a2);
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1, __int64 a2)
{
__int64 v2; // rbp
__int64 v3; // r13
__int64 result; // rax

v2 = AI_NewArbInt_From32(0LL);
v3 = AI_NewArbInt_From32(1LL);
if ( (unsigned int)AI_Equal(a2, v2) )
{
AI_FreeArbInt(v2);
result = v3;
}
else if ( (unsigned int)AI_Equal(a2, v3) )
{
AI_FreeArbInt(v2);
AI_FreeArbInt(v3);
result = AI_NewArbInt_FromCopy(a1);
}
else if ( (unsigned int)AI_Less(a2, v2) )
{
AI_FreeArbInt(v2);
AI_FreeArbInt(v3);
result = v2;
}
else
{
AI_FreeArbInt(v2);
AI_FreeArbInt(v3);
result = func1(a1, a2);
}
return result;
}

original_code:
ArbInt *AI_Pow(ArbInt const *A, ArbInt const *B)
{
  ArbInt *zero = AI_NewArbInt_From32(0);
  ArbInt *one = AI_NewArbInt_From32(1);
  if (AI_Equal(B, zero)) {
    AI_FreeArbInt(zero);
    return one;
  }
  if (AI_Equal(B, one)) {
    AI_FreeArbInt(zero);
    AI_FreeArbInt(one);
    return AI_NewArbInt_FromCopy(A);
  }
  if (AI_Less(B, zero)) {
    AI_FreeArbInt(zero);
    AI_FreeArbInt(one);
    return zero;
  }
  AI_FreeArbInt(zero);
  AI_FreeArbInt(one);
  return ai_pow_positive(A, B);
}

canonical_original_code:
struct arbint *AI_Pow(struct arbint *A, struct arbint *B)
{
  struct arbint *zero = AI_NewArbInt_From32(0);
  struct arbint *one = AI_NewArbInt_From32(1);
  if (AI_Equal(B, zero)) {
    AI_FreeArbInt(zero);
    return one;
  }
  if (AI_Equal(B, one)) {
    AI_FreeArbInt(zero);
    AI_FreeArbInt(one);
    return AI_NewArbInt_FromCopy(A);
  }
  if (AI_Less(B, zero)) {
    AI_FreeArbInt(zero);
    AI_FreeArbInt(one);
    return zero;
  }
  AI_FreeArbInt(zero);
  AI_FreeArbInt(one);
  return ai_pow_positive(A, B);
}


decompiled_code:
__int64 __fastcall ai_pow_by_val(__int64 a1, int a2)
{
__int64 v3; // r12
int v4; // ebx
__int64 v5; // rdi

if ( !a2 )
return AI_NewArbInt_From32(1LL);
if ( a2 == 1 )
return AI_NewArbInt_FromCopy(a1);
v3 = AI_Mul(a1, a1);
v4 = a2 - 2;
if ( a2 != 2 )
{
do
{
v5 = v3;
v3 = AI_Mul(v3, a1);
AI_FreeArbInt(v5);
--v4;
}
while ( v4 );
}
return v3;
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1, int a2)
{
__int64 v3; // r12
int v4; // ebx
__int64 v5; // rdi

if ( !a2 )
return AI_NewArbInt_From32(1LL);
if ( a2 == 1 )
return AI_NewArbInt_FromCopy(a1);
v3 = AI_Mul(a1, a1);
v4 = a2 - 2;
if ( a2 != 2 )
{
do
{
v5 = v3;
v3 = AI_Mul(v3, a1);
AI_FreeArbInt(v5);
--v4;
}
while ( v4 );
}
return v3;
}

original_code:
ArbInt *ai_pow_by_val(ArbInt const *A, aibase_t val)
{
  if (val == 0) {
    return AI_NewArbInt_From32(1);
  } else if (val == 1) {
    return AI_NewArbInt_FromCopy(A);
  }
  ArbInt *result = AI_Mul(A, A);
  val -= 2;
  while (val > 0) {
    ArbInt *tmp = AI_Mul(result, A);
    AI_FreeArbInt(result);
    result = tmp;
    val--;
  }
  return result;
}

canonical_original_code:
struct arbint *ai_pow_by_val(struct arbint *A, unsigned int val)
{
  if (val == 0) {
    return AI_NewArbInt_From32(1);
  } else if (val == 1) {
    return AI_NewArbInt_FromCopy(A);
  }
  struct arbint *result = AI_Mul(A, A);
  val -= 2;
  while (val > 0) {
    struct arbint *tmp = AI_Mul(result, A);
    AI_FreeArbInt(result);
    result = tmp;
    val--;
  }
  return result;
}

variable_types:
val
unsigned int


original_code:
char const *AI_ToString(ArbInt const *value)
{
  if (value == ((void *)0)) return nullstr;
  size_t i;
  int zero_crop = 1;
  int len =
    2 * value->dataLen * sizeof(aibase_t) + 1 + (value->sign == 0 ? 0 : 1);
  char *str = (char *)AI_malloc(len);
  char *p = str;
  aibase_t *vp = value->data;
  int shift = 28;
  if (p == ((void *)0)) {
    return ((void *)0);
  }
  if (value->sign == -1) {
    *p++ = '-';
  }
  while (((((*vp >> shift) & 0x0000000F) <= 9) ? (((*vp >> shift) & 0x0000000F) + '0') : (((*vp >> shift) & 0x0000000F) + 55)) == '0' && shift >= 0) {
    shift -= 4;
  }
  *p++ = '0';
  *p++ = 'x';
  for (i = 0; i < value->dataLen; i++) {
    while (shift >= 0) {
      *p++ = ((((*vp >> shift) & 0x0000000F) <= 9) ? (((*vp >> shift) & 0x0000000F) + '0') : (((*vp >> shift) & 0x0000000F) + 55));
      shift -= 4;
    }
    shift = 28;
    vp++;
  }
  *p = '\0';
  return str;
}

canonical_original_code:
char *AI_ToString(struct arbint *value)
{
  if (value == ((void *)0)) return nullstr;
  unsigned long i;
  int zero_crop = 1;
  int len = 2 * value->dataLen * sizeof(aibase_t) + 1 + (value->sign == 0 ? 0 : 1);
  char *str = (char *)AI_malloc(len);
  char *p = str;
  unsigned int *vp = value->data;
  int shift = 28;
  if (p == ((void *)0)) {
    return ((void *)0);
  }
  if (value->sign == -1) {
    *p++ = '-';
  }
  while (((((*vp >> shift) & 0x0000000F) <= 9) ? (((*vp >> shift) & 0x0000000F) + '0') : (((*vp >> shift) & 0x0000000F) + 55)) == '0' && shift >= 0) {
    shift -= 4;
  }
  *p++ = '0';
  *p++ = 'x';
  for (i = 0; i < value->dataLen; i++) {
    while (shift >= 0) {
      *p++ = ((((*vp >> shift) & 0x0000000F) <= 9) ? (((*vp >> shift) & 0x0000000F) + '0') : (((*vp >> shift) & 0x0000000F) + 55));
      shift -= 4;
    }
    shift = 28;
    vp++;
  }
  *p = '\0';
  return str;
}

variable_types:
i
unsigned long

variable_types: len int

variable_types:
str
char *

variable_types:
p
char *

variable_types:
vp
unsigned int *

variable_types: shift int

return_type: char *


decompiled_code:
const char *__fastcall ai_reverse_str(const char *a1)
{
int v2; // eax
int v3; // edi
const char *v4; // rdx
__int64 v5; // rax
char v6; // si
char v7; // cl

v2 = strlen(a1);
v3 = v2 / 2;
if ( v2 > 1 )
{
v4 = &a1[v2 - 1];
v5 = 0LL;
do
{
v6 = *v4;
v7 = a1[v5];
--v4;
a1[v5++] = v6;
*((_BYTE *)v4 + 1) = v7;
}
while ( v3 > (int)v5 );
}
return a1;
}

canonical_decompiled_code:
const char *__fastcall func1(const char *a1)
{
int v2; // eax
int v3; // edi
const char *v4; // rdx
__int64 v5; // rax
char v6; // si
char v7; // cl

v2 = strlen(a1);
v3 = v2 / 2;
if ( v2 > 1 )
{
v4 = &a1[v2 - 1];
v5 = 0LL;
do
{
v6 = *v4;
v7 = a1[v5];
--v4;
a1[v5++] = v6;
*((_BYTE *)v4 + 1) = v7;
}
while ( v3 > (int)v5 );
}
return a1;
}

original_code:
char const *ai_reverse_str(char *in_out)
{
  int len = strlen(in_out);
  char swap;
  int i;
  for (i = 0; i < len/2; i++) {
    swap = in_out[i];
    in_out[i] = in_out[len - i - 1];
    in_out[len - i - 1] = swap;
  }
  return in_out;
}

canonical_original_code:
char *ai_reverse_str(char *in_out)
{
  int len = strlen(in_out);
  char swap;
  int i;
  for (i = 0; i < len/2; i++) {
    swap = in_out[i];
    in_out[i] = in_out[len - i - 1];
    in_out[len - i - 1] = swap;
  }
  return in_out;
}

variable_types: swap char

variable_types: i int


original_code:
char const *AI_ToStringBase(ArbInt const *value, int base, int approxLen)
{
  if (base > 10 || base <= 0 || base != 1000000000 || base != 16, value == ((void *)0)) return nullstr;
  int sign = value->sign;
  char *str = AI_malloc(approxLen + 2);
  char *p = str;
  ArbInt *ai_base = AI_NewArbInt_FromLong(base);
  ArbInt *copy = AI_NewArbInt_FromCopy(value);
  copy->sign = 1;
  ArbInt *digit;
  while (AI_Greater(copy, ai_base)) {
    int i;
    ArbInt *tmp = AI_Div(copy, ai_base, &digit);
    AI_FreeArbInt(copy);
    copy = tmp;
    if (base != 1000000000) {
      *p++ = (((digit->data[0]) <= 9) ? ((digit->data[0]) + '0') : ((digit->data[0]) + 55));
      if (approxLen-- == 0) {
        return nullstr;
      }
    } else {
      {
        char s[11];
        sprintf(s, "%09u", digit->data[0]);
        for (i = 0; i < 9; i++) {
          *p++ = s[8 - i];
        }
      }
      if (approxLen-- == 0) {
        return nullstr;
      }
      if (approxLen-- == 0) {
        return nullstr;
      }
      if (approxLen-- == 0) {
        return nullstr;
      }
    }
    AI_FreeArbInt(digit);
  }
  if (base != 1000000000) {
    *p++ = (((copy->data[0]) <= 9) ? ((copy->data[0]) + '0') : ((copy->data[0]) + 55));
  } else {
    {
      int i;
      char s[11];
      int prezero = 0;
      sprintf(s, "%09u", copy->data[0]);
      for (i = 0; i < 9; i++) {
        if (s[i] != '0') break;
        prezero++;
      }
      for (i = 0; i < 9 - prezero; i++) {
          *p++ = s[8 - i];
      }
    }
  }
  if (base == 16) { *p++ = 'x'; *p++ = '0'; }
  if (sign == -1) *p++ = '-';
  *p = '\0';
  return ai_reverse_str(str);
}

canonical_original_code:
char *AI_ToStringBase(struct arbint *value, int base, int approxLen)
{
  if (base > 10 || base <= 0 || base != 1000000000 || base != 16, value == ((void *)0)) return nullstr;
  int sign = value->sign;
  char *str = AI_malloc(approxLen + 2);
  char *p = str;
  struct arbint *ai_base = AI_NewArbInt_FromLong(base);
  struct arbint *copy = AI_NewArbInt_FromCopy(value);
  copy->sign = 1;
  struct arbint *digit;
  while (AI_Greater(copy, ai_base)) {
    int i;
    struct arbint *tmp = AI_Div(copy, ai_base, &digit);
    AI_FreeArbInt(copy);
    copy = tmp;
    if (base != 1000000000) {
      *p++ = (((digit->data[0]) <= 9) ? ((digit->data[0]) + '0') : ((digit->data[0]) + 55));
      if (approxLen-- == 0) {
        return nullstr;
      }
    } else {
      {
        char s[11];
        sprintf(s, "%09u", digit->data[0]);
        for (i = 0; i < 9; i++) {
          *p++ = s[8 - i];
        }
      }
      if (approxLen-- == 0) {
        return nullstr;
      }
      if (approxLen-- == 0) {
        return nullstr;
      }
      if (approxLen-- == 0) {
        return nullstr;
      }
    }
    AI_FreeArbInt(digit);
  }
  if (base != 1000000000) {
    *p++ = (((copy->data[0]) <= 9) ? ((copy->data[0]) + '0') : ((copy->data[0]) + 55));
  } else {
    {
      int i;
      char s[11];
      int prezero = 0;
      sprintf(s, "%09u", copy->data[0]);
      for (i = 0; i < 9; i++) {
        if (s[i] != '0') break;
        prezero++;
      }
      for (i = 0; i < 9 - prezero; i++) {
          *p++ = s[8 - i];
      }
    }
  }
  if (base == 16) { *p++ = 'x'; *p++ = '0'; }
  if (sign == -1) *p++ = '-';
  *p = '\0';
  return ai_reverse_str(str);
}

variable_types: base int

variable_types: approxLen int

variable_types: sign int

variable_types:
s
char [11]

variable_types: prezero int


decompiled_code:
const char *__fastcall AI_ToStringDec(__int64 a1)
{
const char *result; // rax

if ( a1 )
result = AI_ToStringBase(a1, 0x3B9ACA00u, 10 * (unsigned int)*(_QWORD *)(a1 + 8));
else
result = "(null)";
return result;
}

canonical_decompiled_code:
const char *__fastcall func3(__int64 a1)
{
const char *result; // rax

if ( a1 )
result = func2(a1, 0x3B9ACA00u, 10 * (unsigned int)*(_QWORD *)(a1 + 8));
else
result = "(null)";
return result;
}

original_code:
char const *AI_ToStringDec(ArbInt const *value)
{
  if (value == ((void *)0)) return nullstr;
  return AI_ToStringBase(value, 1000000000, 10 * value->dataLen);
}

canonical_original_code:
char *AI_ToStringDec(struct arbint *value)
{
  if (value == ((void *)0)) return nullstr;
  return AI_ToStringBase(value, 1000000000, 10 * value->dataLen);
}

variable_types: struct arbint { unsigned int *data; unsigned long dataLen; int sign; } *


decompiled_code:
__int64 __fastcall AI_Make_Bit_Iter(__int64 *a1)
{
__int64 result; // rax
__int64 v2; // rdx
__int64 v3; // rcx
__int64 v4; // rcx

result = AI_malloc(32LL);
if ( result )
{
v2 = *a1;
v3 = a1[1];
*(_DWORD *)(result + 24) = 1;
v4 = v2 + 4 * v3 - 4;
*(_QWORD *)result = v4;
*(_QWORD *)(result + 8) = v2 - 4;
*(_QWORD *)(result + 16) = v4;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 *a1)
{
__int64 result; // rax
__int64 v2; // rdx
__int64 v3; // rcx
__int64 v4; // rcx

result = AI_malloc(32LL);
if ( result )
{
v2 = *a1;
v3 = a1[1];
*(_DWORD *)(result + 24) = 1;
v4 = v2 + 4 * v3 - 4;
*(_QWORD *)result = v4;
*(_QWORD *)(result + 8) = v2 - 4;
*(_QWORD *)(result + 16) = v4;
}
return result;
}

original_code:
ArbInt_BitIterator *AI_Make_Bit_Iter(ArbInt const *ai)
{
  ArbInt_BitIterator *bi = AI_malloc(sizeof(ArbInt_BitIterator));
  if (bi != ((void *)0)) {
    bi->begin = ai->data + ai->dataLen - 1;
    bi->end = ai->data - 1;
    bi->byte = bi->begin;
    bi->bit = 0x01;
  }
  return bi;
}

canonical_original_code:
struct arbint_bititerator *AI_Make_Bit_Iter(struct arbint *ai)
{
  struct arbint_bititerator *bi = AI_malloc(sizeof(ArbInt_BitIterator));
  if (bi != ((void *)0)) {
    bi->begin = ai->data + ai->dataLen - 1;
    bi->end = ai->data - 1;
    bi->byte = bi->begin;
    bi->bit = 0x01;
  }
  return bi;
}

variable_types: struct arbint_bititerator { unsigned int *begin; unsigned int *end; unsigned int *byte; unsigned int bit; } *


original_code:
int AI_Bit_Iter_Inc(ArbInt_BitIterator *bi)
{
  bi->bit <<= 1;
  if (bi->bit == 0) {
    bi->byte--;
    bi->bit = 0x01;
  }
  if (bi->byte > bi->end) {
    return 1;
  } else {
    bi->byte = bi->end;
    return 0;
  }
}

canonical_original_code:
int AI_Bit_Iter_Inc(struct arbint_bititerator *bi)
{
  bi->bit <<= 1;
  if (bi->bit == 0) {
    bi->byte--;
    bi->bit = 0x01;
  }
  if (bi->byte > bi->end) {
    return 1;
  } else {
    bi->byte = bi->end;
    return 0;
  }
}

user_defined_types: struct arbint_bititerator { unsigned int *begin; unsigned int *end; unsigned int *byte; unsigned int bit; }


original_code:
int AI_Bit_Iter_Get(ArbInt_BitIterator const *bi)
{
  return (*(bi->byte) & bi->bit) ? 1 : 0;
}

canonical_original_code:
int AI_Bit_Iter_Get(struct arbint_bititerator *bi)
{
  return (*(bi->byte) & bi->bit) ? 1 : 0;
}


OCLErrorMessage

repo: matthewharvey/OCLHelperFunctions

decompiled_code:
const char *__fastcall OCLErrorMessage(int a1)
{
__int64 v1; // rdi
const char *result; // rax

v1 = (unsigned int)(a1 + 63);
result = "CL:Unknown Error";
if ( (unsigned int)v1 <= 0x3F )
result = CSWTCH_31[v1];
return result;
}

canonical_decompiled_code:
const char *__fastcall func0(int a1)
{
__int64 v1; // rdi
const char *result; // rax

v1 = (unsigned int)(a1 + 63);
result = "CL:Unknown Error";
if ( (unsigned int)v1 <= 0x3F )
result = CSWTCH_31[v1];
return result;
}

original_code:
const char* OCLErrorMessage(cl_int retval)
{
    const char* message = ((void *)0);
    switch (retval)
    {
    case 0:
        break;
    case -1:
        message = "CL:Device not Found";
        break;
    case -2:
        message = "CL:Device not Available";
        break;
    case -3:
        message = "CL:Compiler not Available";
        break;
    case -4:
        message = "CL:Memory Object Allocation Failed";
        break;
    case -5:
        message = "CL:Out of Resources";
        break;
    case -6:
        message = "CL:Out of Host Memory";
        break;
    case -7:
        message = "CL:Profiling info is not available";
        break;
    case -8:
        message = "CL:Memory copy overlap";
        break;
    case -9:
        message = "CL:Image Format Mismatch";
        break;
    case -10:
        message = "CL:Image Format Not Supported";
        break;
    case -11:
        message = "CL:Build Program Failure";
        break;
    case -12:
        message = "CL:Map Failure";
        break;
    case -30:
        message = "CL:Invalid Value";
        break;
    case -31:
        message = "CL:Invalid Device Type";
        break;
    case -32:
        message = "CL:Invalid Platform";
        break;
    case -33:
        message = "CL:Invalid Device";
        break;
    case -34:
        message = "CL:Invalid Context";
        break;
    case -35:
        message = "CL:Invalid Queue Properties";
        break;
    case -36:
        message = "CL:Invalid Command Queue";
        break;
    case -37:
        message = "CL:Invalid Host Pointer";
        break;
    case -38:
        message = "CL:Invalid Memory Object";
        break;
    case -39:
        message = "CL:Invalid Image Format Descriptor";
        break;
    case -40:
        message = "CL:Invalid Image Size";
        break;
    case -41:
        message = "CL:Invalid Sampler";
        break;
    case -42:
        message = "CL:Invalid Binary";
        break;
    case -43:
        message = "CL:Invalid Build Options";
        break;
    case -44:
        message = "CL:Invalid Program";
        break;
    case -45:
        message = "CL:Invalid Program Executable";
        break;
    case -46:
        message = "CL:Invalid Kernel Name";
        break;
    case -47:
        message = "CL:Invalid Kernel Definition";
        break;
    case -48:
        message = "CL:Invalid Kernel";
        break;
    case -49:
        message = "CL:Invalid Argument Index";
        break;
    case -50:
        message = "CL:Invalid Argument Value";
        break;
    case -51:
        message = "CL:Invalid Argument Size";
        break;
    case -52:
        message = "CL:Invalid Kernel Arguments";
        break;
    case -53:
        message = "CL:Invalid Work Dimension";
        break;
    case -54:
        message = "CL:Invalid Work Group Size";
        break;
    case -55:
        message = "CL:Invalid Work Item Size";
        break;
    case -56:
        message = "CL:Invalid Global Offset";
        break;
    case -57:
        message = "CL:Invalid Event Wait List";
        break;
    case -58:
        message = "CL:Invalid Event";
        break;
    case -59:
        message = "CL:Invalid Operation";
        break;
    case -60:
        message = "CL:Invalid GL Object";
        break;
    case -61:
        message = "CL:Invalid Buffer Size";
        break;
    case -62:
        message = "CL:Invalid Mip Level";
        break;
    case -63:
        message = "CL:Invalid Global Work Size";
        break;
    default:
        message = "CL:Unknown Error";
        break;
    }
    return message;
}

canonical_original_code:
char *OCLErrorMessage(int retval)
{
    char *message = ((void *)0);
    switch (retval)
    {
    case 0:
        break;
    case -1:
        message = "CL:Device not Found";
        break;
    case -2:
        message = "CL:Device not Available";
        break;
    case -3:
        message = "CL:Compiler not Available";
        break;
    case -4:
        message = "CL:Memory Object Allocation Failed";
        break;
    case -5:
        message = "CL:Out of Resources";
        break;
    case -6:
        message = "CL:Out of Host Memory";
        break;
    case -7:
        message = "CL:Profiling info is not available";
        break;
    case -8:
        message = "CL:Memory copy overlap";
        break;
    case -9:
        message = "CL:Image Format Mismatch";
        break;
    case -10:
        message = "CL:Image Format Not Supported";
        break;
    case -11:
        message = "CL:Build Program Failure";
        break;
    case -12:
        message = "CL:Map Failure";
        break;
    case -30:
        message = "CL:Invalid Value";
        break;
    case -31:
        message = "CL:Invalid Device Type";
        break;
    case -32:
        message = "CL:Invalid Platform";
        break;
    case -33:
        message = "CL:Invalid Device";
        break;
    case -34:
        message = "CL:Invalid Context";
        break;
    case -35:
        message = "CL:Invalid Queue Properties";
        break;
    case -36:
        message = "CL:Invalid Command Queue";
        break;
    case -37:
        message = "CL:Invalid Host Pointer";
        break;
    case -38:
        message = "CL:Invalid Memory Object";
        break;
    case -39:
        message = "CL:Invalid Image Format Descriptor";
        break;
    case -40:
        message = "CL:Invalid Image Size";
        break;
    case -41:
        message = "CL:Invalid Sampler";
        break;
    case -42:
        message = "CL:Invalid Binary";
        break;
    case -43:
        message = "CL:Invalid Build Options";
        break;
    case -44:
        message = "CL:Invalid Program";
        break;
    case -45:
        message = "CL:Invalid Program Executable";
        break;
    case -46:
        message = "CL:Invalid Kernel Name";
        break;
    case -47:
        message = "CL:Invalid Kernel Definition";
        break;
    case -48:
        message = "CL:Invalid Kernel";
        break;
    case -49:
        message = "CL:Invalid Argument Index";
        break;
    case -50:
        message = "CL:Invalid Argument Value";
        break;
    case -51:
        message = "CL:Invalid Argument Size";
        break;
    case -52:
        message = "CL:Invalid Kernel Arguments";
        break;
    case -53:
        message = "CL:Invalid Work Dimension";
        break;
    case -54:
        message = "CL:Invalid Work Group Size";
        break;
    case -55:
        message = "CL:Invalid Work Item Size";
        break;
    case -56:
        message = "CL:Invalid Global Offset";
        break;
    case -57:
        message = "CL:Invalid Event Wait List";
        break;
    case -58:
        message = "CL:Invalid Event";
        break;
    case -59:
        message = "CL:Invalid Operation";
        break;
    case -60:
        message = "CL:Invalid GL Object";
        break;
    case -61:
        message = "CL:Invalid Buffer Size";
        break;
    case -62:
        message = "CL:Invalid Mip Level";
        break;
    case -63:
        message = "CL:Invalid Global Work Size";
        break;
    default:
        message = "CL:Unknown Error";
        break;
    }
    return message;
}

variable_types: retval int

variable_types:
message
char *


decompiled_code:
const char *base2_type_string_internal()
{
return "base2";
}

canonical_decompiled_code:
const char *func0()
{
return "base2";
}

original_code:
static const char *
base2_type_string_internal (base2_handle base2_h)
{
    return ("base2");
}

canonical_original_code:
static char *base2_type_string_internal(struct base2_st_ *base2_h)
{
    return ("base2");
}

variable_types: struct base2_st_ { struct base2_private_st_ { struct base2_vtable_st_ { void (*delete_fn)(struct base2_st_ *base2_h); char *(*type_string_fn)(struct base2_st_ *base2_h); enum my_rc_e_ { MY_RC_E_INVALID=0, MY_RC_E_SUCCESS=1, MY_RC_E_EINVAL=2, MY_RC_E_ENOMEM=3, MY_RC_E_MAX=4 } (*string_fn)(struct base2_st_ *base2_h, char *buffer, unsigned long buffer_size); enum my_rc_e_ { MY_RC_E_INVALID=0, MY_RC_E_SUCCESS=1, MY_RC_E_EINVAL=2, MY_RC_E_ENOMEM=3, MY_RC_E_MAX=4 } (*string_size_fn)(struct base2_st_ *base2_h, unsigned long *buffer_size); enum my_rc_e_ { MY_RC_E_INVALID=0, MY_RC_E_SUCCESS=1, MY_RC_E_EINVAL=2, MY_RC_E_ENOMEM=3, MY_RC_E_MAX=4 } (*increase_val1_fn)(struct base2_st_ *base2_h); } *vtable; } *private_h; unsigned int val1; } *

user_defined_types: struct base2_st_ { struct base2_private_st_ *private_h; unsigned int val1; }

user_defined_types: struct base2_private_st_ { struct base2_vtable_st_ *vtable; }

user_defined_types: struct base2_vtable_st_ { void (*delete_fn)(struct base2_st_ *base2_h); char *(*type_string_fn)(struct base2_st_ *base2_h); enum my_rc_e_ (*string_fn)(struct base2_st_ *base2_h, char *buffer, unsigned long buffer_size); enum my_rc_e_ (*string_size_fn)(struct base2_st_ *base2_h, unsigned long *buffer_size); enum my_rc_e_ (*increase_val1_fn)(struct base2_st_ *base2_h); }


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

if ( a1 && a2 )
{
*a2 = 64LL;
result = 1LL;
}
else
{
printf("(%s:%u) ERROR: Invalid input, base2_h(%p) buffer_size(%p)\n", "base2.c", 74LL, a1, a2);
result = 2LL;
}
return result;
}

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

if ( a1 && a2 )
{
*a2 = 64LL;
result = 1LL;
}
else
{
printf("(%s:%u) ERROR: Invalid input, base2_h(%p) buffer_size(%p)\n", "base2.c", 74LL, a1, a2);
result = 2LL;
}
return result;
}

original_code:
static my_rc_e
base2_string_size_internal (base2_handle base2_h, size_t *buffer_size)
{
    if ((((void *)0) == base2_h) || (((void *)0) == buffer_size)) {
        do { printf("(%s:%u) ERROR: " "Invalid input, base2_h(%p) buffer_size(%p)" "\n", "base2.c", 74, base2_h, buffer_size); } while (0);
        return (MY_RC_E_EINVAL);
    }
    *buffer_size = 64;
    return (MY_RC_E_SUCCESS);
}

canonical_original_code:
static enum my_rc_e_ base2_string_size_internal(struct base2_st_ *base2_h, unsigned long *buffer_size)
{
    if ((((void *)0) == base2_h) || (((void *)0) == buffer_size)) {
        do { printf("(%s:%u) ERROR: " "Invalid input, base2_h(%p) buffer_size(%p)" "\n", "base2.c", 74, base2_h, buffer_size); } while (0);
        return (MY_RC_E_EINVAL);
    }
    *buffer_size = 64;
    return (MY_RC_E_SUCCESS);
}

return_type: enum my_rc_e_ { MY_RC_E_INVALID=0, MY_RC_E_SUCCESS=1, MY_RC_E_EINVAL=2, MY_RC_E_ENOMEM=3, MY_RC_E_MAX=4 }


decompiled_code:
void __fastcall base2_delete_internal(void *ptr, char a2)
{
void *v3; // rdi

if ( ptr )
{
v3 = *(void **)ptr;
if ( v3 )
{
free(v3);
*(_QWORD *)ptr = 0LL;
}
if ( a2 )
free(ptr);
}
}

canonical_decompiled_code:
void __fastcall func2(void *ptr, char a2)
{
void *v3; // rdi

if ( ptr )
{
v3 = *(void **)ptr;
if ( v3 )
{
free(v3);
*(_QWORD *)ptr = 0LL;
}
if ( a2 )
free(ptr);
}
}

original_code:
static void
base2_delete_internal (base2_handle base2_h, _Bool free_base2_h)
{
    if (((void *)0) == base2_h) {
        return;
    }
    if (((void *)0) != base2_h->private_h) {
        free(base2_h->private_h);
        base2_h->private_h = ((void *)0);
    }
    if (free_base2_h) {
        free(base2_h);
    }
}

canonical_original_code:
static void base2_delete_internal(struct base2_st_ *base2_h, _Bool free_base2_h)
{
    if (((void *)0) == base2_h) {
        return;
    }
    if (((void *)0) != base2_h->private_h) {
        free(base2_h->private_h);
        base2_h->private_h = ((void *)0);
    }
    if (free_base2_h) {
        free(base2_h);
    }
}

user_defined_types: enum my_rc_e_ { MY_RC_E_INVALID=0, MY_RC_E_SUCCESS=1, MY_RC_E_EINVAL=2, MY_RC_E_ENOMEM=3, MY_RC_E_MAX=4 }


decompiled_code:
void __fastcall base2_private_delete(void *a1)
{
base2_delete_internal(a1, 1);
}

canonical_decompiled_code:
void __fastcall func3(void *a1)
{
func2(a1, 1);
}

original_code:
static void
base2_private_delete (base2_handle base2_h)
{
    base2_delete_internal(base2_h, 1);
}

canonical_original_code:
static void base2_private_delete(struct base2_st_ *base2_h)
{
    base2_delete_internal(base2_h, 1);
}


decompiled_code:
__int64 __fastcall base2_string_internal(unsigned int *a1, char *a2, size_t a3)
{
_QWORD *v4; // r8
_QWORD *v5; // r9
__int64 v6; // r13
__int64 result; // rax
unsigned __int64 v8[6]; // [rsp+8h] [rbp-30h] BYREF

if ( a1 && a2 )
{
v4 = *(_QWORD **)a1;
if ( *(_QWORD *)a1 )
{
v5 = (_QWORD *)*v4;
if ( *v4 )
{
LODWORD(v6) = 1;
if ( !v5[3] )
{
LODWORD(v6) = 2;
printf(
"(%s:%u) ERROR: Invalid input, base2_h(%p) private_h(%p) vtable(%p) string_size_fn(%p)\n",
"base2.c",
162LL,
a1,
v4,
v5,
0LL);
}
}
else
{
LODWORD(v6) = 2;
printf("(%s:%u) ERROR: Invalid input, base2_h(%p) private_h(%p) vtable(%p)\n", "base2.c", 162LL, a1, v4, 0LL);
}
}
else
{
LODWORD(v6) = 2;
printf("(%s:%u) ERROR: Invalid input, base2_h(%p) private_h(%p)\n", "base2.c", 162LL, a1, 0LL);
}
if ( !(unsigned __int8)my_rc_e_is_notok((unsigned int)v6) )
{
v6 = (*(unsigned int (__fastcall **)(unsigned int *, unsigned __int64 *))(**(_QWORD **)a1 + 24LL))(a1, v8);
if ( !(unsigned __int8)my_rc_e_is_notok(v6) )
{
if ( v8[0] > a3 )
{
printf("(%s:%u) ERROR: Invalid input, buffer_size(%zu)\n", "base2.c", 173LL, a3);
LODWORD(v6) = 2;
}
else
{
LODWORD(v6) = 1;
snprintf(a2, a3, "val1(%u)", a1[2]);
}
}
}
result = (unsigned int)v6;
}
else
{
printf("(%s:%u) ERROR: Invalid input, base2_h(%p) buffer(%p) buffer_size(%zu)\n", "base2.c", 157LL, a1, a2, a3);
result = 2LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func4(unsigned int *a1, char *a2, size_t a3)
{
_QWORD *v4; // r8
_QWORD *v5; // r9
__int64 v6; // r13
__int64 result; // rax
unsigned __int64 v8[6]; // [rsp+8h] [rbp-30h] BYREF

if ( a1 && a2 )
{
v4 = *(_QWORD **)a1;
if ( *(_QWORD *)a1 )
{
v5 = (_QWORD *)*v4;
if ( *v4 )
{
LODWORD(v6) = 1;
if ( !v5[3] )
{
LODWORD(v6) = 2;
printf(
"(%s:%u) ERROR: Invalid input, base2_h(%p) private_h(%p) vtable(%p) string_size_fn(%p)\n",
"base2.c",
162LL,
a1,
v4,
v5,
0LL);
}
}
else
{
LODWORD(v6) = 2;
printf("(%s:%u) ERROR: Invalid input, base2_h(%p) private_h(%p) vtable(%p)\n", "base2.c", 162LL, a1, v4, 0LL);
}
}
else
{
LODWORD(v6) = 2;
printf("(%s:%u) ERROR: Invalid input, base2_h(%p) private_h(%p)\n", "base2.c", 162LL, a1, 0LL);
}
if ( !(unsigned __int8)my_rc_e_is_notok((unsigned int)v6) )
{
v6 = (*(unsigned int (__fastcall **)(unsigned int *, unsigned __int64 *))(**(_QWORD **)a1 + 24LL))(a1, v8);
if ( !(unsigned __int8)my_rc_e_is_notok(v6) )
{
if ( v8[0] > a3 )
{
printf("(%s:%u) ERROR: Invalid input, buffer_size(%zu)\n", "base2.c", 173LL, a3);
LODWORD(v6) = 2;
}
else
{
LODWORD(v6) = 1;
snprintf(a2, a3, "val1(%u)", a1[2]);
}
}
}
result = (unsigned int)v6;
}
else
{
printf("(%s:%u) ERROR: Invalid input, base2_h(%p) buffer(%p) buffer_size(%zu)\n", "base2.c", 157LL, a1, a2, a3);
result = 2LL;
}
return result;
}

original_code:
static my_rc_e
base2_string_internal (base2_handle base2_h, char *buffer, size_t buffer_size)
{
    size_t min_size;
    my_rc_e rc = MY_RC_E_SUCCESS;
    if ((((void *)0) == base2_h) || (((void *)0) == buffer)) {
        do { printf("(%s:%u) ERROR: " "Invalid input, base2_h(%p) buffer(%p) buffer_size(%zu)" "\n", "base2.c", 157, base2_h, buffer, buffer_size); } while (0);
        return (MY_RC_E_EINVAL);
    }
    do { if (((void *)0) == base2_h) { do { printf("(%s:%u) ERROR: " "Invalid input, " "base2_h" "(%p)" "\n", "base2.c", 162,base2_h); } while (0); rc = MY_RC_E_EINVAL; break; } if (((void *)0) == base2_h->private_h) { do { printf("(%s:%u) ERROR: " "Invalid input, " "base2_h" "(%p) " "private_h" "(%p)" "\n", "base2.c", 162,base2_h, base2_h->private_h); } while (0); rc = MY_RC_E_EINVAL; break; } if (((void *)0) == base2_h->private_h->vtable) { do { printf("(%s:%u) ERROR: " "Invalid input, " "base2_h" "(%p) " "private_h" "(%p) " "vtable" "(%p)" "\n", "base2.c", 162,base2_h, base2_h->private_h, base2_h->private_h->vtable); } while (0); rc = MY_RC_E_EINVAL; break; } if (((void *)0) == base2_h->private_h->vtable->string_size_fn) { do { printf("(%s:%u) ERROR: " "Invalid input, " "base2_h" "(%p) " "private_h" "(%p) " "vtable" "(%p) " "string_size_fn" "(%p)" "\n", "base2.c", 162,base2_h, base2_h->private_h, base2_h->private_h->vtable, base2_h->private_h->vtable->string_size_fn); } while (0); rc = MY_RC_E_EINVAL; break; } } while (0);
    if (my_rc_e_is_notok(rc)) {
        return (rc);
    }
    rc = base2_h->private_h->vtable->string_size_fn(base2_h, &min_size);
    if (my_rc_e_is_notok(rc)) {
        return (rc);
    }
    if (buffer_size < min_size) {
        do { printf("(%s:%u) ERROR: " "Invalid input, buffer_size(%zu)" "\n", "base2.c", 173, buffer_size); } while (0);
        return (MY_RC_E_EINVAL);
    }
    snprintf(buffer, buffer_size, "val1(%u)", base2_h->val1);
    return (MY_RC_E_SUCCESS);
}

canonical_original_code:
static enum my_rc_e_ base2_string_internal(struct base2_st_ *base2_h, char *buffer, unsigned long buffer_size)
{
    unsigned long min_size;
    enum my_rc_e_ rc = MY_RC_E_SUCCESS;
    if ((((void *)0) == base2_h) || (((void *)0) == buffer)) {
        do { printf("(%s:%u) ERROR: " "Invalid input, base2_h(%p) buffer(%p) buffer_size(%zu)" "\n", "base2.c", 157, base2_h, buffer, buffer_size); } while (0);
        return (MY_RC_E_EINVAL);
    }
    do { if (((void *)0) == base2_h) { do { printf("(%s:%u) ERROR: " "Invalid input, " "base2_h" "(%p)" "\n", "base2.c", 162,base2_h); } while (0); rc = MY_RC_E_EINVAL; break; } if (((void *)0) == base2_h->private_h) { do { printf("(%s:%u) ERROR: " "Invalid input, " "base2_h" "(%p) " "private_h" "(%p)" "\n", "base2.c", 162,base2_h, base2_h->private_h); } while (0); rc = MY_RC_E_EINVAL; break; } if (((void *)0) == base2_h->private_h->vtable) { do { printf("(%s:%u) ERROR: " "Invalid input, " "base2_h" "(%p) " "private_h" "(%p) " "vtable" "(%p)" "\n", "base2.c", 162,base2_h, base2_h->private_h, base2_h->private_h->vtable); } while (0); rc = MY_RC_E_EINVAL; break; } if (((void *)0) == base2_h->private_h->vtable->string_size_fn) { do { printf("(%s:%u) ERROR: " "Invalid input, " "base2_h" "(%p) " "private_h" "(%p) " "vtable" "(%p) " "string_size_fn" "(%p)" "\n", "base2.c", 162,base2_h, base2_h->private_h, base2_h->private_h->vtable, base2_h->private_h->vtable->string_size_fn); } while (0); rc = MY_RC_E_EINVAL; break; } } while (0);
    if (my_rc_e_is_notok(rc)) {
        return (rc);
    }
    rc = base2_h->private_h->vtable->string_size_fn(base2_h, &min_size);
    if (my_rc_e_is_notok(rc)) {
        return (rc);
    }
    if (buffer_size < min_size) {
        do { printf("(%s:%u) ERROR: " "Invalid input, buffer_size(%zu)" "\n", "base2.c", 173, buffer_size); } while (0);
        return (MY_RC_E_EINVAL);
    }
    snprintf(buffer, buffer_size, "val1(%u)", base2_h->val1);
    return (MY_RC_E_SUCCESS);
}

variable_types:
buffer
char *

variable_types: enum my_rc_e_ { MY_RC_E_INVALID=0, MY_RC_E_SUCCESS=1, MY_RC_E_EINVAL=2, MY_RC_E_ENOMEM=3, MY_RC_E_MAX=4 }


decompiled_code:
__int64 __fastcall base2_string_size(const void *a1, __int64 a2)
{
_QWORD *v2; // r8
_QWORD *v3; // r9
unsigned int v4; // er12
__int64 result; // rax

if ( a1 )
{
v2 = *(_QWORD **)a1;
if ( *(_QWORD *)a1 )
{
v3 = (_QWORD *)*v2;
if ( *v2 )
{
v4 = 1;
if ( !v3[3] )
{
v4 = 2;
printf(
"(%s:%u) ERROR: Invalid input, base2_h(%p) private_h(%p) vtable(%p) string_size_fn(%p)\n",
"base2.c",
54LL,
a1,
v2,
v3,
0LL);
}
}
else
{
v4 = 2;
printf("(%s:%u) ERROR: Invalid input, base2_h(%p) private_h(%p) vtable(%p)\n", "base2.c", 54LL, a1, v2, 0LL);
}
}
else
{
v4 = 2;
printf("(%s:%u) ERROR: Invalid input, base2_h(%p) private_h(%p)\n", "base2.c", 54LL, a1, 0LL);
}
}
else
{
v4 = 2;
printf("(%s:%u) ERROR: Invalid input, base2_h(%p)\n", "base2.c", 54LL, 0LL);
}
if ( (unsigned __int8)my_rc_e_is_notok(v4) )
result = v4;
else
result = (*(__int64 (__fastcall **)(const void *, __int64))(**(_QWORD **)a1 + 24LL))(a1, a2);
return result;
}

canonical_decompiled_code:
__int64 __fastcall func5(const void *a1, __int64 a2)
{
_QWORD *v2; // r8
_QWORD *v3; // r9
unsigned int v4; // er12
__int64 result; // rax

if ( a1 )
{
v2 = *(_QWORD **)a1;
if ( *(_QWORD *)a1 )
{
v3 = (_QWORD *)*v2;
if ( *v2 )
{
v4 = 1;
if ( !v3[3] )
{
v4 = 2;
printf(
"(%s:%u) ERROR: Invalid input, base2_h(%p) private_h(%p) vtable(%p) string_size_fn(%p)\n",
"base2.c",
54LL,
a1,
v2,
v3,
0LL);
}
}
else
{
v4 = 2;
printf("(%s:%u) ERROR: Invalid input, base2_h(%p) private_h(%p) vtable(%p)\n", "base2.c", 54LL, a1, v2, 0LL);
}
}
else
{
v4 = 2;
printf("(%s:%u) ERROR: Invalid input, base2_h(%p) private_h(%p)\n", "base2.c", 54LL, a1, 0LL);
}
}
else
{
v4 = 2;
printf("(%s:%u) ERROR: Invalid input, base2_h(%p)\n", "base2.c", 54LL, 0LL);
}
if ( (unsigned __int8)my_rc_e_is_notok(v4) )
result = v4;
else
result = (*(__int64 (__fastcall **)(const void *, __int64))(**(_QWORD **)a1 + 24LL))(a1, a2);
return result;
}

original_code:
my_rc_e
base2_string_size (base2_handle base2_h, size_t *buffer_size)
{
    my_rc_e rc = MY_RC_E_SUCCESS;
    do { if (((void *)0) == base2_h) { do { printf("(%s:%u) ERROR: " "Invalid input, " "base2_h" "(%p)" "\n", "base2.c", 54,base2_h); } while (0); rc = MY_RC_E_EINVAL; break; } if (((void *)0) == base2_h->private_h) { do { printf("(%s:%u) ERROR: " "Invalid input, " "base2_h" "(%p) " "private_h" "(%p)" "\n", "base2.c", 54,base2_h, base2_h->private_h); } while (0); rc = MY_RC_E_EINVAL; break; } if (((void *)0) == base2_h->private_h->vtable) { do { printf("(%s:%u) ERROR: " "Invalid input, " "base2_h" "(%p) " "private_h" "(%p) " "vtable" "(%p)" "\n", "base2.c", 54,base2_h, base2_h->private_h, base2_h->private_h->vtable); } while (0); rc = MY_RC_E_EINVAL; break; } if (((void *)0) == base2_h->private_h->vtable->string_size_fn) { do { printf("(%s:%u) ERROR: " "Invalid input, " "base2_h" "(%p) " "private_h" "(%p) " "vtable" "(%p) " "string_size_fn" "(%p)" "\n", "base2.c", 54,base2_h, base2_h->private_h, base2_h->private_h->vtable, base2_h->private_h->vtable->string_size_fn); } while (0); rc = MY_RC_E_EINVAL; break; } } while (0);
    if (my_rc_e_is_notok(rc)) {
        return (rc);
    }
    return (base2_h->private_h->vtable->string_size_fn(base2_h, buffer_size));
}

canonical_original_code:
enum my_rc_e_ base2_string_size(struct base2_st_ *base2_h, unsigned long *buffer_size)
{
    enum my_rc_e_ rc = MY_RC_E_SUCCESS;
    do { if (((void *)0) == base2_h) { do { printf("(%s:%u) ERROR: " "Invalid input, " "base2_h" "(%p)" "\n", "base2.c", 54,base2_h); } while (0); rc = MY_RC_E_EINVAL; break; } if (((void *)0) == base2_h->private_h) { do { printf("(%s:%u) ERROR: " "Invalid input, " "base2_h" "(%p) " "private_h" "(%p)" "\n", "base2.c", 54,base2_h, base2_h->private_h); } while (0); rc = MY_RC_E_EINVAL; break; } if (((void *)0) == base2_h->private_h->vtable) { do { printf("(%s:%u) ERROR: " "Invalid input, " "base2_h" "(%p) " "private_h" "(%p) " "vtable" "(%p)" "\n", "base2.c", 54,base2_h, base2_h->private_h, base2_h->private_h->vtable); } while (0); rc = MY_RC_E_EINVAL; break; } if (((void *)0) == base2_h->private_h->vtable->string_size_fn) { do { printf("(%s:%u) ERROR: " "Invalid input, " "base2_h" "(%p) " "private_h" "(%p) " "vtable" "(%p) " "string_size_fn" "(%p)" "\n", "base2.c", 54,base2_h, base2_h->private_h, base2_h->private_h->vtable, base2_h->private_h->vtable->string_size_fn); } while (0); rc = MY_RC_E_EINVAL; break; } } while (0);
    if (my_rc_e_is_notok(rc)) {
        return (rc);
    }
    return (base2_h->private_h->vtable->string_size_fn(base2_h, buffer_size));
}


decompiled_code:
void *__fastcall base2_type_string(const void *a1)
{
_QWORD *v2; // r8
_QWORD *v3; // r9
__int64 v4; // rdi
void *result; // rax

if ( a1 )
{
v2 = *(_QWORD **)a1;
if ( *(_QWORD *)a1 )
{
v3 = (_QWORD *)*v2;
if ( *v2 )
{
v4 = 1LL;
if ( !v3[1] )
{
printf(
"(%s:%u) ERROR: Invalid input, base2_h(%p) private_h(%p) vtable(%p) type_string_fn(%p)\n",
"base2.c",
109LL,
a1,
v2,
v3,
0LL);
v4 = 2LL;
}
}
else
{
printf("(%s:%u) ERROR: Invalid input, base2_h(%p) private_h(%p) vtable(%p)\n", "base2.c", 109LL, a1, v2, 0LL);
v4 = 2LL;
}
}
else
{
printf("(%s:%u) ERROR: Invalid input, base2_h(%p) private_h(%p)\n", "base2.c", 109LL, a1, 0LL);
v4 = 2LL;
}
}
else
{
printf("(%s:%u) ERROR: Invalid input, base2_h(%p)\n", "base2.c", 109LL, 0LL);
v4 = 2LL;
}
if ( (unsigned __int8)my_rc_e_is_notok(v4) )
result = &unk_BA7;
else
result = (void *)(*(__int64 (__fastcall **)(const void *))(**(_QWORD **)a1 + 8LL))(a1);
return result;
}

canonical_decompiled_code:
void *__fastcall func6(const void *a1)
{
_QWORD *v2; // r8
_QWORD *v3; // r9
__int64 v4; // rdi
void *result; // rax

if ( a1 )
{
v2 = *(_QWORD **)a1;
if ( *(_QWORD *)a1 )
{
v3 = (_QWORD *)*v2;
if ( *v2 )
{
v4 = 1LL;
if ( !v3[1] )
{
printf(
"(%s:%u) ERROR: Invalid input, base2_h(%p) private_h(%p) vtable(%p) type_string_fn(%p)\n",
"base2.c",
109LL,
a1,
v2,
v3,
0LL);
v4 = 2LL;
}
}
else
{
printf("(%s:%u) ERROR: Invalid input, base2_h(%p) private_h(%p) vtable(%p)\n", "base2.c", 109LL, a1, v2, 0LL);
v4 = 2LL;
}
}
else
{
printf("(%s:%u) ERROR: Invalid input, base2_h(%p) private_h(%p)\n", "base2.c", 109LL, a1, 0LL);
v4 = 2LL;
}
}
else
{
printf("(%s:%u) ERROR: Invalid input, base2_h(%p)\n", "base2.c", 109LL, 0LL);
v4 = 2LL;
}
if ( (unsigned __int8)my_rc_e_is_notok(v4) )
result = &unk_BA7;
else
result = (void *)(*(__int64 (__fastcall **)(const void *))(**(_QWORD **)a1 + 8LL))(a1);
return result;
}

original_code:
const char *
base2_type_string (base2_handle base2_h)
{
    my_rc_e rc = MY_RC_E_SUCCESS;
    do { if (((void *)0) == base2_h) { do { printf("(%s:%u) ERROR: " "Invalid input, " "base2_h" "(%p)" "\n", "base2.c", 109,base2_h); } while (0); rc = MY_RC_E_EINVAL; break; } if (((void *)0) == base2_h->private_h) { do { printf("(%s:%u) ERROR: " "Invalid input, " "base2_h" "(%p) " "private_h" "(%p)" "\n", "base2.c", 109,base2_h, base2_h->private_h); } while (0); rc = MY_RC_E_EINVAL; break; } if (((void *)0) == base2_h->private_h->vtable) { do { printf("(%s:%u) ERROR: " "Invalid input, " "base2_h" "(%p) " "private_h" "(%p) " "vtable" "(%p)" "\n", "base2.c", 109,base2_h, base2_h->private_h, base2_h->private_h->vtable); } while (0); rc = MY_RC_E_EINVAL; break; } if (((void *)0) == base2_h->private_h->vtable->type_string_fn) { do { printf("(%s:%u) ERROR: " "Invalid input, " "base2_h" "(%p) " "private_h" "(%p) " "vtable" "(%p) " "type_string_fn" "(%p)" "\n", "base2.c", 109,base2_h, base2_h->private_h, base2_h->private_h->vtable, base2_h->private_h->vtable->type_string_fn); } while (0); rc = MY_RC_E_EINVAL; break; } } while (0);
    if (my_rc_e_is_notok(rc)) {
        return ("");
    }
    return (base2_h->private_h->vtable->type_string_fn(base2_h));
}

canonical_original_code:
char *base2_type_string(struct base2_st_ *base2_h)
{
    enum my_rc_e_ rc = MY_RC_E_SUCCESS;
    do { if (((void *)0) == base2_h) { do { printf("(%s:%u) ERROR: " "Invalid input, " "base2_h" "(%p)" "\n", "base2.c", 109,base2_h); } while (0); rc = MY_RC_E_EINVAL; break; } if (((void *)0) == base2_h->private_h) { do { printf("(%s:%u) ERROR: " "Invalid input, " "base2_h" "(%p) " "private_h" "(%p)" "\n", "base2.c", 109,base2_h, base2_h->private_h); } while (0); rc = MY_RC_E_EINVAL; break; } if (((void *)0) == base2_h->private_h->vtable) { do { printf("(%s:%u) ERROR: " "Invalid input, " "base2_h" "(%p) " "private_h" "(%p) " "vtable" "(%p)" "\n", "base2.c", 109,base2_h, base2_h->private_h, base2_h->private_h->vtable); } while (0); rc = MY_RC_E_EINVAL; break; } if (((void *)0) == base2_h->private_h->vtable->type_string_fn) { do { printf("(%s:%u) ERROR: " "Invalid input, " "base2_h" "(%p) " "private_h" "(%p) " "vtable" "(%p) " "type_string_fn" "(%p)" "\n", "base2.c", 109,base2_h, base2_h->private_h, base2_h->private_h->vtable, base2_h->private_h->vtable->type_string_fn); } while (0); rc = MY_RC_E_EINVAL; break; } } while (0);
    if (my_rc_e_is_notok(rc)) {
        return ("");
    }
    return (base2_h->private_h->vtable->type_string_fn(base2_h));
}


decompiled_code:
__int64 __fastcall base2_string(const void *a1, __int64 a2, __int64 a3)
{
_QWORD *v4; // r8
_QWORD *v5; // r9
unsigned int v6; // er14
__int64 result; // rax

if ( a1 )
{
v4 = *(_QWORD **)a1;
if ( *(_QWORD *)a1 )
{
v5 = (_QWORD *)*v4;
if ( *v4 )
{
v6 = 1;
if ( !v5[2] )
{
v6 = 2;
printf(
"(%s:%u) ERROR: Invalid input, base2_h(%p) private_h(%p) vtable(%p) string_fn(%p)\n",
"base2.c",
131LL,
a1,
v4,
v5,
0LL);
}
}
else
{
v6 = 2;
printf("(%s:%u) ERROR: Invalid input, base2_h(%p) private_h(%p) vtable(%p)\n", "base2.c", 131LL, a1, v4, 0LL);
}
}
else
{
v6 = 2;
printf("(%s:%u) ERROR: Invalid input, base2_h(%p) private_h(%p)\n", "base2.c", 131LL, a1, 0LL);
}
}
else
{
v6 = 2;
printf("(%s:%u) ERROR: Invalid input, base2_h(%p)\n", "base2.c", 131LL, 0LL);
}
if ( (unsigned __int8)my_rc_e_is_notok(v6) )
result = v6;
else
result = (*(__int64 (__fastcall **)(const void *, __int64, __int64))(**(_QWORD **)a1 + 16LL))(a1, a2, a3);
return result;
}

canonical_decompiled_code:
__int64 __fastcall func7(const void *a1, __int64 a2, __int64 a3)
{
_QWORD *v4; // r8
_QWORD *v5; // r9
unsigned int v6; // er14
__int64 result; // rax

if ( a1 )
{
v4 = *(_QWORD **)a1;
if ( *(_QWORD *)a1 )
{
v5 = (_QWORD *)*v4;
if ( *v4 )
{
v6 = 1;
if ( !v5[2] )
{
v6 = 2;
printf(
"(%s:%u) ERROR: Invalid input, base2_h(%p) private_h(%p) vtable(%p) string_fn(%p)\n",
"base2.c",
131LL,
a1,
v4,
v5,
0LL);
}
}
else
{
v6 = 2;
printf("(%s:%u) ERROR: Invalid input, base2_h(%p) private_h(%p) vtable(%p)\n", "base2.c", 131LL, a1, v4, 0LL);
}
}
else
{
v6 = 2;
printf("(%s:%u) ERROR: Invalid input, base2_h(%p) private_h(%p)\n", "base2.c", 131LL, a1, 0LL);
}
}
else
{
v6 = 2;
printf("(%s:%u) ERROR: Invalid input, base2_h(%p)\n", "base2.c", 131LL, 0LL);
}
if ( (unsigned __int8)my_rc_e_is_notok(v6) )
result = v6;
else
result = (*(__int64 (__fastcall **)(const void *, __int64, __int64))(**(_QWORD **)a1 + 16LL))(a1, a2, a3);
return result;
}

original_code:
my_rc_e
base2_string (base2_handle base2_h, char *buffer, size_t buffer_size)
{
    my_rc_e rc = MY_RC_E_SUCCESS;
    do { if (((void *)0) == base2_h) { do { printf("(%s:%u) ERROR: " "Invalid input, " "base2_h" "(%p)" "\n", "base2.c", 131,base2_h); } while (0); rc = MY_RC_E_EINVAL; break; } if (((void *)0) == base2_h->private_h) { do { printf("(%s:%u) ERROR: " "Invalid input, " "base2_h" "(%p) " "private_h" "(%p)" "\n", "base2.c", 131,base2_h, base2_h->private_h); } while (0); rc = MY_RC_E_EINVAL; break; } if (((void *)0) == base2_h->private_h->vtable) { do { printf("(%s:%u) ERROR: " "Invalid input, " "base2_h" "(%p) " "private_h" "(%p) " "vtable" "(%p)" "\n", "base2.c", 131,base2_h, base2_h->private_h, base2_h->private_h->vtable); } while (0); rc = MY_RC_E_EINVAL; break; } if (((void *)0) == base2_h->private_h->vtable->string_fn) { do { printf("(%s:%u) ERROR: " "Invalid input, " "base2_h" "(%p) " "private_h" "(%p) " "vtable" "(%p) " "string_fn" "(%p)" "\n", "base2.c", 131,base2_h, base2_h->private_h, base2_h->private_h->vtable, base2_h->private_h->vtable->string_fn); } while (0); rc = MY_RC_E_EINVAL; break; } } while (0);
    if (my_rc_e_is_notok(rc)) {
        return (rc);
    }
    return (base2_h->private_h->vtable->string_fn(base2_h, buffer,
                                                  buffer_size));
}

canonical_original_code:
enum my_rc_e_ base2_string(struct base2_st_ *base2_h, char *buffer, unsigned long buffer_size)
{
    enum my_rc_e_ rc = MY_RC_E_SUCCESS;
    do { if (((void *)0) == base2_h) { do { printf("(%s:%u) ERROR: " "Invalid input, " "base2_h" "(%p)" "\n", "base2.c", 131,base2_h); } while (0); rc = MY_RC_E_EINVAL; break; } if (((void *)0) == base2_h->private_h) { do { printf("(%s:%u) ERROR: " "Invalid input, " "base2_h" "(%p) " "private_h" "(%p)" "\n", "base2.c", 131,base2_h, base2_h->private_h); } while (0); rc = MY_RC_E_EINVAL; break; } if (((void *)0) == base2_h->private_h->vtable) { do { printf("(%s:%u) ERROR: " "Invalid input, " "base2_h" "(%p) " "private_h" "(%p) " "vtable" "(%p)" "\n", "base2.c", 131,base2_h, base2_h->private_h, base2_h->private_h->vtable); } while (0); rc = MY_RC_E_EINVAL; break; } if (((void *)0) == base2_h->private_h->vtable->string_fn) { do { printf("(%s:%u) ERROR: " "Invalid input, " "base2_h" "(%p) " "private_h" "(%p) " "vtable" "(%p) " "string_fn" "(%p)" "\n", "base2.c", 131,base2_h, base2_h->private_h, base2_h->private_h->vtable, base2_h->private_h->vtable->string_fn); } while (0); rc = MY_RC_E_EINVAL; break; } } while (0);
    if (my_rc_e_is_notok(rc)) {
        return (rc);
    }
    return (base2_h->private_h->vtable->string_fn(base2_h, buffer,
                                                  buffer_size));
}


decompiled_code:
void __fastcall base2_friend_delete(void *a1)
{
base2_delete_internal(a1, 0);
}

canonical_decompiled_code:
void __fastcall func8(void *a1)
{
func2(a1, 0);
}

original_code:
void
base2_friend_delete (base2_handle base2_h)
{
    base2_delete_internal(base2_h, 0);
}

canonical_original_code:
void base2_friend_delete(struct base2_st_ *base2_h)
{
    base2_delete_internal(base2_h, 0);
}


decompiled_code:
__int64 __fastcall base2_delete(_QWORD ***a1)
{
_QWORD **v2; // r8
_QWORD *v3; // r9
__int64 v4; // rdi
__int64 result; // rax

if ( a1 )
{
v2 = *a1;
if ( *a1 )
{
v3 = *v2;
if ( *v2 )
{
v4 = 1LL;
if ( !*v3 )
{
printf(
"(%s:%u) ERROR: Invalid input, base2_h(%p) private_h(%p) vtable(%p) delete_fn(%p)\n",
"base2.c",
250LL,
a1,
v2,
v3,
0LL);
v4 = 2LL;
}
}
else
{
printf("(%s:%u) ERROR: Invalid input, base2_h(%p) private_h(%p) vtable(%p)\n", "base2.c", 250LL, a1, v2, 0LL);
v4 = 2LL;
}
}
else
{
printf("(%s:%u) ERROR: Invalid input, base2_h(%p) private_h(%p)\n", "base2.c", 250LL, a1, 0LL);
v4 = 2LL;
}
}
else
{
printf("(%s:%u) ERROR: Invalid input, base2_h(%p)\n", "base2.c", 250LL, 0LL);
v4 = 2LL;
}
result = my_rc_e_is_notok(v4);
if ( !(_BYTE)result )
result = ((__int64 (__fastcall *)(_QWORD ***))***a1)(a1);
return result;
}

canonical_decompiled_code:
__int64 __fastcall func9(_QWORD ***a1)
{
_QWORD **v2; // r8
_QWORD *v3; // r9
__int64 v4; // rdi
__int64 result; // rax

if ( a1 )
{
v2 = *a1;
if ( *a1 )
{
v3 = *v2;
if ( *v2 )
{
v4 = 1LL;
if ( !*v3 )
{
printf(
"(%s:%u) ERROR: Invalid input, base2_h(%p) private_h(%p) vtable(%p) delete_fn(%p)\n",
"base2.c",
250LL,
a1,
v2,
v3,
0LL);
v4 = 2LL;
}
}
else
{
printf("(%s:%u) ERROR: Invalid input, base2_h(%p) private_h(%p) vtable(%p)\n", "base2.c", 250LL, a1, v2, 0LL);
v4 = 2LL;
}
}
else
{
printf("(%s:%u) ERROR: Invalid input, base2_h(%p) private_h(%p)\n", "base2.c", 250LL, a1, 0LL);
v4 = 2LL;
}
}
else
{
printf("(%s:%u) ERROR: Invalid input, base2_h(%p)\n", "base2.c", 250LL, 0LL);
v4 = 2LL;
}
result = my_rc_e_is_notok(v4);
if ( !(_BYTE)result )
result = ((__int64 (__fastcall *)(_QWORD ***))***a1)(a1);
return result;
}

original_code:
void
base2_delete (base2_handle base2_h)
{
    my_rc_e rc = MY_RC_E_SUCCESS;
    do { if (((void *)0) == base2_h) { do { printf("(%s:%u) ERROR: " "Invalid input, " "base2_h" "(%p)" "\n", "base2.c", 250,base2_h); } while (0); rc = MY_RC_E_EINVAL; break; } if (((void *)0) == base2_h->private_h) { do { printf("(%s:%u) ERROR: " "Invalid input, " "base2_h" "(%p) " "private_h" "(%p)" "\n", "base2.c", 250,base2_h, base2_h->private_h); } while (0); rc = MY_RC_E_EINVAL; break; } if (((void *)0) == base2_h->private_h->vtable) { do { printf("(%s:%u) ERROR: " "Invalid input, " "base2_h" "(%p) " "private_h" "(%p) " "vtable" "(%p)" "\n", "base2.c", 250,base2_h, base2_h->private_h, base2_h->private_h->vtable); } while (0); rc = MY_RC_E_EINVAL; break; } if (((void *)0) == base2_h->private_h->vtable->delete_fn) { do { printf("(%s:%u) ERROR: " "Invalid input, " "base2_h" "(%p) " "private_h" "(%p) " "vtable" "(%p) " "delete_fn" "(%p)" "\n", "base2.c", 250,base2_h, base2_h->private_h, base2_h->private_h->vtable, base2_h->private_h->vtable->delete_fn); } while (0); rc = MY_RC_E_EINVAL; break; } } while (0);
    if (my_rc_e_is_notok(rc)) {
        return;
    }
    return (base2_h->private_h->vtable->delete_fn(base2_h));
}

canonical_original_code:
void base2_delete(struct base2_st_ *base2_h)
{
    enum my_rc_e_ rc = MY_RC_E_SUCCESS;
    do { if (((void *)0) == base2_h) { do { printf("(%s:%u) ERROR: " "Invalid input, " "base2_h" "(%p)" "\n", "base2.c", 250,base2_h); } while (0); rc = MY_RC_E_EINVAL; break; } if (((void *)0) == base2_h->private_h) { do { printf("(%s:%u) ERROR: " "Invalid input, " "base2_h" "(%p) " "private_h" "(%p)" "\n", "base2.c", 250,base2_h, base2_h->private_h); } while (0); rc = MY_RC_E_EINVAL; break; } if (((void *)0) == base2_h->private_h->vtable) { do { printf("(%s:%u) ERROR: " "Invalid input, " "base2_h" "(%p) " "private_h" "(%p) " "vtable" "(%p)" "\n", "base2.c", 250,base2_h, base2_h->private_h, base2_h->private_h->vtable); } while (0); rc = MY_RC_E_EINVAL; break; } if (((void *)0) == base2_h->private_h->vtable->delete_fn) { do { printf("(%s:%u) ERROR: " "Invalid input, " "base2_h" "(%p) " "private_h" "(%p) " "vtable" "(%p) " "delete_fn" "(%p)" "\n", "base2.c", 250,base2_h, base2_h->private_h, base2_h->private_h->vtable, base2_h->private_h->vtable->delete_fn); } while (0); rc = MY_RC_E_EINVAL; break; } } while (0);
    if (my_rc_e_is_notok(rc)) {
        return;
    }
    return (base2_h->private_h->vtable->delete_fn(base2_h));
}


decompiled_code:
__int64 __fastcall base2_increase_val1(const void *a1)
{
_QWORD *v1; // r8
_QWORD *v2; // r9
unsigned int v3; // er12
__int64 result; // rax

if ( a1 )
{
v1 = *(_QWORD **)a1;
if ( *(_QWORD *)a1 )
{
v2 = (_QWORD *)*v1;
if ( *v1 )
{
v3 = 1;
if ( !v2[4] )
{
v3 = 2;
printf(
"(%s:%u) ERROR: Invalid input, base2_h(%p) private_h(%p) vtable(%p) increase_val1_fn(%p)\n",
"base2.c",
269LL,
a1,
v1,
v2,
0LL);
}
}
else
{
v3 = 2;
printf("(%s:%u) ERROR: Invalid input, base2_h(%p) private_h(%p) vtable(%p)\n", "base2.c", 269LL, a1, v1, 0LL);
}
}
else
{
v3 = 2;
printf("(%s:%u) ERROR: Invalid input, base2_h(%p) private_h(%p)\n", "base2.c", 269LL, a1, 0LL);
}
}
else
{
v3 = 2;
printf("(%s:%u) ERROR: Invalid input, base2_h(%p)\n", "base2.c", 269LL, 0LL);
}
if ( (unsigned __int8)my_rc_e_is_notok(v3) )
result = v3;
else
result = (*(__int64 (__fastcall **)(const void *))(**(_QWORD **)a1 + 32LL))(a1);
return result;
}

canonical_decompiled_code:
__int64 __fastcall func10(const void *a1)
{
_QWORD *v1; // r8
_QWORD *v2; // r9
unsigned int v3; // er12
__int64 result; // rax

if ( a1 )
{
v1 = *(_QWORD **)a1;
if ( *(_QWORD *)a1 )
{
v2 = (_QWORD *)*v1;
if ( *v1 )
{
v3 = 1;
if ( !v2[4] )
{
v3 = 2;
printf(
"(%s:%u) ERROR: Invalid input, base2_h(%p) private_h(%p) vtable(%p) increase_val1_fn(%p)\n",
"base2.c",
269LL,
a1,
v1,
v2,
0LL);
}
}
else
{
v3 = 2;
printf("(%s:%u) ERROR: Invalid input, base2_h(%p) private_h(%p) vtable(%p)\n", "base2.c", 269LL, a1, v1, 0LL);
}
}
else
{
v3 = 2;
printf("(%s:%u) ERROR: Invalid input, base2_h(%p) private_h(%p)\n", "base2.c", 269LL, a1, 0LL);
}
}
else
{
v3 = 2;
printf("(%s:%u) ERROR: Invalid input, base2_h(%p)\n", "base2.c", 269LL, 0LL);
}
if ( (unsigned __int8)my_rc_e_is_notok(v3) )
result = v3;
else
result = (*(__int64 (__fastcall **)(const void *))(**(_QWORD **)a1 + 32LL))(a1);
return result;
}

original_code:
my_rc_e
base2_increase_val1 (base2_handle base2_h)
{
    my_rc_e rc = MY_RC_E_SUCCESS;
    do { if (((void *)0) == base2_h) { do { printf("(%s:%u) ERROR: " "Invalid input, " "base2_h" "(%p)" "\n", "base2.c", 269,base2_h); } while (0); rc = MY_RC_E_EINVAL; break; } if (((void *)0) == base2_h->private_h) { do { printf("(%s:%u) ERROR: " "Invalid input, " "base2_h" "(%p) " "private_h" "(%p)" "\n", "base2.c", 269,base2_h, base2_h->private_h); } while (0); rc = MY_RC_E_EINVAL; break; } if (((void *)0) == base2_h->private_h->vtable) { do { printf("(%s:%u) ERROR: " "Invalid input, " "base2_h" "(%p) " "private_h" "(%p) " "vtable" "(%p)" "\n", "base2.c", 269,base2_h, base2_h->private_h, base2_h->private_h->vtable); } while (0); rc = MY_RC_E_EINVAL; break; } if (((void *)0) == base2_h->private_h->vtable->increase_val1_fn) { do { printf("(%s:%u) ERROR: " "Invalid input, " "base2_h" "(%p) " "private_h" "(%p) " "vtable" "(%p) " "increase_val1_fn" "(%p)" "\n", "base2.c", 269,base2_h, base2_h->private_h, base2_h->private_h->vtable, base2_h->private_h->vtable->increase_val1_fn); } while (0); rc = MY_RC_E_EINVAL; break; } } while (0);
    if (my_rc_e_is_notok(rc)) {
        return (rc);
    }
    return (base2_h->private_h->vtable->increase_val1_fn(base2_h));
}

canonical_original_code:
enum my_rc_e_ base2_increase_val1(struct base2_st_ *base2_h)
{
    enum my_rc_e_ rc = MY_RC_E_SUCCESS;
    do { if (((void *)0) == base2_h) { do { printf("(%s:%u) ERROR: " "Invalid input, " "base2_h" "(%p)" "\n", "base2.c", 269,base2_h); } while (0); rc = MY_RC_E_EINVAL; break; } if (((void *)0) == base2_h->private_h) { do { printf("(%s:%u) ERROR: " "Invalid input, " "base2_h" "(%p) " "private_h" "(%p)" "\n", "base2.c", 269,base2_h, base2_h->private_h); } while (0); rc = MY_RC_E_EINVAL; break; } if (((void *)0) == base2_h->private_h->vtable) { do { printf("(%s:%u) ERROR: " "Invalid input, " "base2_h" "(%p) " "private_h" "(%p) " "vtable" "(%p)" "\n", "base2.c", 269,base2_h, base2_h->private_h, base2_h->private_h->vtable); } while (0); rc = MY_RC_E_EINVAL; break; } if (((void *)0) == base2_h->private_h->vtable->increase_val1_fn) { do { printf("(%s:%u) ERROR: " "Invalid input, " "base2_h" "(%p) " "private_h" "(%p) " "vtable" "(%p) " "increase_val1_fn" "(%p)" "\n", "base2.c", 269,base2_h, base2_h->private_h, base2_h->private_h->vtable, base2_h->private_h->vtable->increase_val1_fn); } while (0); rc = MY_RC_E_EINVAL; break; } } while (0);
    if (my_rc_e_is_notok(rc)) {
        return (rc);
    }
    return (base2_h->private_h->vtable->increase_val1_fn(base2_h));
}


decompiled_code:
__int64 __fastcall base2_get_val1(_DWORD *a1, _DWORD *a2)
{
__int64 result; // rax

if ( a1 && a2 )
{
*a2 = a1[2];
result = 1LL;
}
else
{
printf("(%s:%u) ERROR: Invalid input, base2_h(%p) val1(%p)\n", "base2.c", 288LL, a1, a2);
result = 2LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func11(_DWORD *a1, _DWORD *a2)
{
__int64 result; // rax

if ( a1 && a2 )
{
*a2 = a1[2];
result = 1LL;
}
else
{
printf("(%s:%u) ERROR: Invalid input, base2_h(%p) val1(%p)\n", "base2.c", 288LL, a1, a2);
result = 2LL;
}
return result;
}

original_code:
my_rc_e
base2_get_val1 (base2_handle base2_h, uint32_t *val1)
{
    if ((((void *)0) == base2_h) || (((void *)0) == val1)) {
        do { printf("(%s:%u) ERROR: " "Invalid input, base2_h(%p) val1(%p)" "\n", "base2.c", 288, base2_h, val1); } while (0);
        return (MY_RC_E_EINVAL);
    }
    *val1 = base2_h->val1;
    return (MY_RC_E_SUCCESS);
}

canonical_original_code:
enum my_rc_e_ base2_get_val1(struct base2_st_ *base2_h, unsigned int *val1)
{
    if ((((void *)0) == base2_h) || (((void *)0) == val1)) {
        do { printf("(%s:%u) ERROR: " "Invalid input, base2_h(%p) val1(%p)" "\n", "base2.c", 288, base2_h, val1); } while (0);
        return (MY_RC_E_EINVAL);
    }
    *val1 = base2_h->val1;
    return (MY_RC_E_SUCCESS);
}