// this script was compiled with wurst 1.8.1.0-jenkins-Wurst-1367
globals
integer array Func_nextFree
integer Func_firstFree=0
integer Func_maxIndex=0
integer array Func_typeId
integer array C_nextFree
integer C_firstFree=0
integer C_maxIndex=0
integer array C_typeId
integer array C_x
endglobals
native testSuccess takes nothing returns nothing
function initGlobals takes nothing returns nothing
endfunction

function error takes string msg returns nothing
	call BJDebugMsg(msg + "\n" + "")
endfunction

function new_C takes integer x returns integer
	local integer this
	local integer this_1
	local integer this_2
	local integer x_1
	if C_firstFree == 0 then
		if C_maxIndex < 32768 then
			set C_maxIndex = C_maxIndex + 1
			set this_1 = C_maxIndex
			set C_typeId[this_1] = 1
		else
			call error("Out of memory: Could not create C.")
			set this_1 = 0
		endif
	else
		set C_firstFree = C_firstFree - 1
		set this_1 = C_nextFree[C_firstFree]
		set C_typeId[this_1] = 1
	endif
	set this = this_1
	set this_2 = this
	set x_1 = x
	set C_x[this_2] = x_1
	return this
endfunction

function C_map takes integer this, integer f returns integer
	local integer this_1 = f
	local integer x = C_x[this]
	local integer A_Func_apply_result
	local integer x_1
	if Func_typeId[this_1] == 0 then
		if this_1 == 0 then
			call error("Nullpointer exception when calling Func.apply")
		else
			call error("Called Func.apply on invalid object.")
		endif
	endif
	set x_1 = x
	set A_Func_apply_result = 2 * x_1
	return new_C(A_Func_apply_result)
endfunction

function init_A takes nothing returns nothing
	local integer x = 5
	local integer a
	local integer b
	local integer clVar
	local integer temp
	local integer this
	local integer this_1
	local integer this_2
	local integer x_1
	local integer this_3
	local integer this_4
	local integer f
	local integer A_C_map_result
	if C_firstFree == 0 then
		if C_maxIndex < 32768 then
			set C_maxIndex = C_maxIndex + 1
			set this_1 = C_maxIndex
			set C_typeId[this_1] = 1
		else
			call error("Out of memory: Could not create C.")
			set this_1 = 0
		endif
	else
		set C_firstFree = C_firstFree - 1
		set this_1 = C_nextFree[C_firstFree]
		set C_typeId[this_1] = 1
	endif
	set this = this_1
	set this_2 = this
	set x_1 = x
	set C_x[this_2] = x_1
	set a = this
	set temp = a
	if Func_firstFree == 0 then
		if Func_maxIndex < 32768 then
			set Func_maxIndex = Func_maxIndex + 1
			set this_3 = Func_maxIndex
			set Func_typeId[this_3] = 3
		else
			call error("Out of memory: Could not create Func_map_A.")
			set this_3 = 0
		endif
	else
		set Func_firstFree = Func_firstFree - 1
		set this_3 = Func_nextFree[Func_firstFree]
		set Func_typeId[this_3] = 3
	endif
	set clVar = this_3
	set this_4 = temp
	set f = clVar
	if C_typeId[this_4] == 0 then
		if this_4 == 0 then
			call error("Nullpointer exception when calling C.map")
		else
			call error("Called C.map on invalid object.")
		endif
	endif
	set A_C_map_result = C_map(this_4, f)
	set b = A_C_map_result
	if C_x[b] == 10 then
		call testSuccess()
	endif
endfunction

function main takes nothing returns nothing
	call initGlobals()
	call init_A()
endfunction

function config takes nothing returns nothing
endfunction