array<integer> C_nextFree154
integer C_firstFree596
integer C_maxIndex418
array<integer> C_typeId193


integer C_firstFree596 = 0
integer C_maxIndex418 = 0


function initGlobals112() { 
    C_firstFree_596 = 0;
    C_maxIndex_418 = 0;
}


function main100() { 
    initGlobals112();
    init_test114();
}


function config527() { 
}


function init_test114() { 
    local integer c184
    local integer d102
    c_184 = new_C515();
    d_102 = new_D360();
    if (((dispatch_C_test_C_foo_2782(c_184, 1, 2) == 3) and (dispatch_C_test_C_foo_2782(d_102, 1, 2) == 2)) and (dispatch_C_test_C_foo_4882(d_102, 1, 2, 3, 4) == 24)) {
        testSuccess123();
    } else {
    };
}


IS_NATIVE function testSuccess123() { 
}


function C_init841(integer this197) { 
}


function new_C515() returns integer { 
    local integer this777
    this_777 = alloc_C153();
    construct_C186(this_777);
    return this_777;
}


function construct_C186(integer this199) { 
    C_init841(this_199);
}


function D_init214(integer this109) { 
}


function new_D360() returns integer { 
    local integer this152
    this_152 = alloc_D124();
    construct_D618(this_152);
    return this_152;
}


function construct_D618(integer this188) { 
    construct_C186(this_188);
    D_init214(this_188);
}


function alloc_C153() returns integer { 
    local integer this241
    if (C_firstFree_596 == 0) {
        if (C_maxIndex_418 < 32768) {
            C_maxIndex_418 = (C_maxIndex_418 + 1);
            this_241 = C_maxIndex_418;
            C_typeId_193[this_241] = 1;
        } else {
            error138("Out of memory: Could not create C.");
            this_241 = 0;
        };
    } else {
        C_firstFree_596 = (C_firstFree_596 - 1);
        this_241 = C_nextFree_154[C_firstFree_596];
        C_typeId_193[this_241] = 1;
    };
    return this_241;
}


function error138(string msg683) { 
    $debugPrint155((msg_683 + ("
" + #getStackTrace())));
}


function alloc_D124() returns integer { 
    local integer this189
    if (C_firstFree_596 == 0) {
        if (C_maxIndex_418 < 32768) {
            C_maxIndex_418 = (C_maxIndex_418 + 1);
            this_189 = C_maxIndex_418;
            C_typeId_193[this_189] = 2;
        } else {
            error138("Out of memory: Could not create D.");
            this_189 = 0;
        };
    } else {
        C_firstFree_596 = (C_firstFree_596 - 1);
        this_189 = C_nextFree_154[C_firstFree_596];
        C_typeId_193[this_189] = 2;
    };
    return this_189;
}


function C_foo_2135(integer this128, integer xs_0119, integer xs_1326) returns integer { 
    local integer sum497
    sum_497 = 0;
    sum_497 = (sum_497 + xs_0_119);
    sum_497 = (sum_497 + xs_1_326);
    return sum_497;
}


function D_foo_2521(integer this194, integer xs_0697, integer xs_1401) returns integer { 
    local integer prod152
    prod_152 = 1;
    prod_152 = (prod_152 * xs_0_697);
    prod_152 = (prod_152 * xs_1_401);
    return prod_152;
}


function dispatch_C_test_C_foo_2782(integer this610, integer xs_0686, integer xs_1157) returns integer { 
    local integer test_C_foo_result128
    if (C_typeId_193[this_610] == 0) {
        if (this_610 == 0) {
            error138("Nullpointer exception when calling C.foo");
        } else {
            error138("Called C.foo on invalid object.");
        };
    } else {
    };
    if (C_typeId_193[this_610] <= 1) {
        test_C_foo_result_128 = C_foo_2135(this_610, xs_0_686, xs_1_157);
    } else {
        test_C_foo_result_128 = D_foo_2521(this_610, xs_0_686, xs_1_157);
    };
    return test_C_foo_result_128;
}


function C_foo_4198(integer this133, integer xs_0244, integer xs_1121, integer xs_2158, integer xs_3985) returns integer { 
    local integer sum110
    sum_110 = 0;
    sum_110 = (sum_110 + xs_0_244);
    sum_110 = (sum_110 + xs_1_121);
    sum_110 = (sum_110 + xs_2_158);
    sum_110 = (sum_110 + xs_3_985);
    return sum_110;
}


function D_foo_4767(integer this419, integer xs_0150, integer xs_1198, integer xs_2213, integer xs_3194) returns integer { 
    local integer prod182
    prod_182 = 1;
    prod_182 = (prod_182 * xs_0_150);
    prod_182 = (prod_182 * xs_1_198);
    prod_182 = (prod_182 * xs_2_213);
    prod_182 = (prod_182 * xs_3_194);
    return prod_182;
}


function dispatch_C_test_C_foo_4882(integer this171, integer xs_0107, integer xs_1167, integer xs_2199, integer xs_3851) returns integer { 
    local integer test_C_foo_result286
    if (C_typeId_193[this_171] == 0) {
        if (this_171 == 0) {
            error138("Nullpointer exception when calling C.foo");
        } else {
            error138("Called C.foo on invalid object.");
        };
    } else {
    };
    if (C_typeId_193[this_171] <= 1) {
        test_C_foo_result_286 = C_foo_4198(this_171, xs_0_107, xs_1_167, xs_2_199, xs_3_851);
    } else {
        test_C_foo_result_286 = D_foo_4767(this_171, xs_0_107, xs_1_167, xs_2_199, xs_3_851);
    };
    return test_C_foo_result_286;
}