array<integer> C_nextFree115
integer C_firstFree705
integer C_maxIndex100
array<integer> C_typeId121


integer C_firstFree705 = 0
integer C_maxIndex100 = 0


function initGlobals848() { 
    C_firstFree_705 = 0;
    C_maxIndex_100 = 0;
}


function main546() { 
    initGlobals848();
    init_test391();
}


function config100() { 
}


function init_test391() { 
    local integer c118
    local integer d204
    c_118 = new_C148();
    d_204 = new_D319();
    if (((dispatch_C_test_C_foo_2160(c_118, 1, 2) == 3) and (dispatch_C_test_C_foo_2160(d_204, 1, 2) == 2)) and (dispatch_C_test_C_foo_4140(d_204, 1, 2, 3, 4) == 24)) {
        testSuccess748();
    } else {
    };
}


IS_NATIVE function testSuccess748() { 
}


function C_init149(integer this191) { 
}


function new_C148() returns integer { 
    local integer this128
    this_128 = alloc_C136();
    construct_C133(this_128);
    return this_128;
}


function construct_C133(integer this101) { 
    C_init149(this_101);
}


function D_init559(integer this172) { 
}


function new_D319() returns integer { 
    local integer this386
    this_386 = alloc_D301();
    construct_D136(this_386);
    return this_386;
}


function construct_D136(integer this166) { 
    construct_C133(this_166);
    D_init559(this_166);
}


function alloc_C136() returns integer { 
    local integer this412
    if (C_firstFree_705 == 0) {
        if (C_maxIndex_100 < 32768) {
            C_maxIndex_100 = (C_maxIndex_100 + 1);
            this_412 = C_maxIndex_100;
            C_typeId_121[this_412] = 1;
        } else {
            error383("Out of memory: Could not create C.");
            this_412 = 0;
        };
    } else {
        C_firstFree_705 = (C_firstFree_705 - 1);
        this_412 = C_nextFree_115[C_firstFree_705];
        C_typeId_121[this_412] = 1;
    };
    return this_412;
}


function error383(string msg176) { 
    $debugPrint195((msg_176 + ("
" + #getStackTrace())));
}


function alloc_D301() returns integer { 
    local integer this615
    if (C_firstFree_705 == 0) {
        if (C_maxIndex_100 < 32768) {
            C_maxIndex_100 = (C_maxIndex_100 + 1);
            this_615 = C_maxIndex_100;
            C_typeId_121[this_615] = 2;
        } else {
            error383("Out of memory: Could not create D.");
            this_615 = 0;
        };
    } else {
        C_firstFree_705 = (C_firstFree_705 - 1);
        this_615 = C_nextFree_115[C_firstFree_705];
        C_typeId_121[this_615] = 2;
    };
    return this_615;
}


function C_foo_2618(integer this214, integer xs_0100, integer xs_1181) returns integer { 
    local integer sum527
    sum_527 = 0;
    sum_527 = (sum_527 + xs_0_100);
    sum_527 = (sum_527 + xs_1_181);
    return sum_527;
}


function D_foo_2102(integer this168, integer xs_0113, integer xs_1528) returns integer { 
    local integer prod180
    prod_180 = 1;
    prod_180 = (prod_180 * xs_0_113);
    prod_180 = (prod_180 * xs_1_528);
    return prod_180;
}


function dispatch_C_test_C_foo_2160(integer this156, integer xs_0170, integer xs_1737) returns integer { 
    local integer test_C_foo_result452
    if (C_typeId_121[this_156] == 0) {
        if (this_156 == 0) {
            error383("Nullpointer exception when calling C.foo");
        } else {
            error383("Called C.foo on invalid object.");
        };
    } else {
    };
    if (C_typeId_121[this_156] <= 1) {
        test_C_foo_result_452 = C_foo_2618(this_156, xs_0_170, xs_1_737);
    } else {
        test_C_foo_result_452 = D_foo_2102(this_156, xs_0_170, xs_1_737);
    };
    return test_C_foo_result_452;
}


function C_foo_4199(integer this197, integer xs_0777, integer xs_1199, integer xs_2690, integer xs_3121) returns integer { 
    local integer sum690
    sum_690 = 0;
    sum_690 = (sum_690 + xs_0_777);
    sum_690 = (sum_690 + xs_1_199);
    sum_690 = (sum_690 + xs_2_690);
    sum_690 = (sum_690 + xs_3_121);
    return sum_690;
}


function D_foo_4696(integer this159, integer xs_0118, integer xs_1123, integer xs_2214, integer xs_3368) returns integer { 
    local integer prod714
    prod_714 = 1;
    prod_714 = (prod_714 * xs_0_118);
    prod_714 = (prod_714 * xs_1_123);
    prod_714 = (prod_714 * xs_2_214);
    prod_714 = (prod_714 * xs_3_368);
    return prod_714;
}


function dispatch_C_test_C_foo_4140(integer this152, integer xs_0188, integer xs_1170, integer xs_2596, integer xs_3418) returns integer { 
    local integer test_C_foo_result154
    if (C_typeId_121[this_152] == 0) {
        if (this_152 == 0) {
            error383("Nullpointer exception when calling C.foo");
        } else {
            error383("Called C.foo on invalid object.");
        };
    } else {
    };
    if (C_typeId_121[this_152] <= 1) {
        test_C_foo_result_154 = C_foo_4199(this_152, xs_0_188, xs_1_170, xs_2_596, xs_3_418);
    } else {
        test_C_foo_result_154 = D_foo_4696(this_152, xs_0_188, xs_1_170, xs_2_596, xs_3_418);
    };
    return test_C_foo_result_154;
}