Unless I'm missing some logic here - 
Because NUM_ITEM_TYPES, NUM_ILLEGAL_ITEM_TYPES, and illegal_item_types are global variables, get_flag_by_number(...) should not have these variables passed to it.