// this script was compiled with wurst 1.8.1.0-jenkins-Wurst-1365 globals integer bitset_add_return_val=0 endglobals native testFail takes string msg returns nothing native testSuccess takes nothing returns nothing function initGlobals takes nothing returns nothing endfunction function bitset_containsPow takes integer this_val, integer pow returns boolean return ModuloInteger(this_val, pow * 2) >= pow endfunction function int_pow takes integer this, integer x returns integer local integer result = 1 local integer i = 1 local integer temp = x loop exitwhen i > temp set result = result * this set i = i + 1 endloop return result endfunction function bitset_add takes integer this_val, integer v returns integer local integer pow = int_pow(2, v) local integer cond_result_1 local integer tuple_temp local integer tuple_temp_1 if not bitset_containsPow(this_val, pow) then set tuple_temp = this_val + pow set cond_result_1 = tuple_temp else set tuple_temp_1 = this_val set cond_result_1 = tuple_temp_1 endif set bitset_add_return_val = cond_result_1 return bitset_add_return_val endfunction function init_Test takes nothing returns nothing local integer tuple_temp = 5 local integer a_val = tuple_temp local integer tuple_temp_1 = bitset_add(a_val, 1) local integer res_val = tuple_temp_1 if res_val == 7 then call testSuccess() else call testFail(I2S(res_val)) endif endfunction function main takes nothing returns nothing call initGlobals() call init_Test() endfunction function config takes nothing returns nothing endfunction