%% Generated by prepare_templates. DO NOT EDIT THIS FILE.
%%
%% Input files:
%%  asn1rtt_check.beam
%%  asn1rtt_ext.beam
%%  asn1rtt_per_common.beam
%%  asn1rtt_real_common.beam
%%  asn1rtt_ber.beam
%%  asn1rtt_per.beam
%%  asn1rtt_uper.beam

-module(asn1ct_rtt).
-export([assert_defined/1,dependencies/1,code/0]).

assert_defined({ber,ber_decode_erlang,1}) -> ok;
assert_defined({ber,ber_decode_nif,1}) -> ok;
assert_defined({ber,ber_encode,1}) -> ok;
assert_defined({ber,decode_BMP_string,3}) -> ok;
assert_defined({ber,decode_UTF8_string,2}) -> ok;
assert_defined({ber,decode_boolean,2}) -> ok;
assert_defined({ber,decode_compact_bit_string,3}) -> ok;
assert_defined({ber,decode_enumerated,3}) -> ok;
assert_defined({ber,decode_generalized_time,3}) -> ok;
assert_defined({ber,decode_integer,3}) -> ok;
assert_defined({ber,decode_integer,4}) -> ok;
assert_defined({ber,decode_legacy_bit_string,3}) -> ok;
assert_defined({ber,decode_named_bit_string,3}) -> ok;
assert_defined({ber,decode_native_bit_string,3}) -> ok;
assert_defined({ber,decode_null,2}) -> ok;
assert_defined({ber,decode_object_identifier,2}) -> ok;
assert_defined({ber,decode_open_type,2}) -> ok;
assert_defined({ber,decode_open_type_as_binary,2}) -> ok;
assert_defined({ber,decode_primitive_incomplete,2}) -> ok;
assert_defined({ber,decode_relative_oid,2}) -> ok;
assert_defined({ber,decode_restricted_string,2}) -> ok;
assert_defined({ber,decode_restricted_string,3}) -> ok;
assert_defined({ber,decode_selective,2}) -> ok;
assert_defined({ber,decode_universal_string,3}) -> ok;
assert_defined({ber,decode_utc_time,3}) -> ok;
assert_defined({ber,dynamicsort_SETOF,1}) -> ok;
assert_defined({ber,dynamicsort_SET_components,1}) -> ok;
assert_defined({ber,encode_BMP_string,2}) -> ok;
assert_defined({ber,encode_UTF8_string,2}) -> ok;
assert_defined({ber,encode_bit_string,4}) -> ok;
assert_defined({ber,encode_boolean,2}) -> ok;
assert_defined({ber,encode_enumerated,2}) -> ok;
assert_defined({ber,encode_generalized_time,2}) -> ok;
assert_defined({ber,encode_integer,2}) -> ok;
assert_defined({ber,encode_integer,3}) -> ok;
assert_defined({ber,encode_null,2}) -> ok;
assert_defined({ber,encode_object_identifier,2}) -> ok;
assert_defined({ber,encode_open_type,2}) -> ok;
assert_defined({ber,encode_relative_oid,2}) -> ok;
assert_defined({ber,encode_restricted_string,2}) -> ok;
assert_defined({ber,encode_tags,2}) -> ok;
assert_defined({ber,encode_tags,3}) -> ok;
assert_defined({ber,encode_universal_string,2}) -> ok;
assert_defined({ber,encode_utc_time,2}) -> ok;
assert_defined({ber,match_tags,2}) -> ok;
assert_defined({ber,skip_ExtensionAdditions,2}) -> ok;
assert_defined({check,check_bitstring,3}) -> ok;
assert_defined({check,check_bool,2}) -> ok;
assert_defined({check,check_enum,3}) -> ok;
assert_defined({check,check_int,3}) -> ok;
assert_defined({check,check_null,2}) -> ok;
assert_defined({check,check_objectdescriptor,2}) -> ok;
assert_defined({check,check_objectidentifier,2}) -> ok;
assert_defined({check,check_octetstring,2}) -> ok;
assert_defined({check,check_real,2}) -> ok;
assert_defined({check,check_restrictedstring,2}) -> ok;
assert_defined({ext,transform_to_EXTERNAL1990,1}) -> ok;
assert_defined({ext,transform_to_EXTERNAL1994,1}) -> ok;
assert_defined({per,complete,1}) -> ok;
assert_defined({per,encode_GeneralString,2}) -> ok;
assert_defined({per,encode_GraphicString,2}) -> ok;
assert_defined({per,encode_ObjectDescriptor,2}) -> ok;
assert_defined({per,encode_TeletexString,2}) -> ok;
assert_defined({per,encode_UTF8String,1}) -> ok;
assert_defined({per,encode_VideotexString,2}) -> ok;
assert_defined({per,encode_bit_string,3}) -> ok;
assert_defined({per,encode_constrained_number,2}) -> ok;
assert_defined({per,encode_integer,2}) -> ok;
assert_defined({per,encode_known_multiplier_string,4}) -> ok;
assert_defined({per,encode_length,1}) -> ok;
assert_defined({per,encode_length,2}) -> ok;
assert_defined({per,encode_object_identifier,1}) -> ok;
assert_defined({per,encode_octet_string,3}) -> ok;
assert_defined({per,encode_open_type,1}) -> ok;
assert_defined({per,encode_relative_oid,1}) -> ok;
assert_defined({per,encode_small_number,1}) -> ok;
assert_defined({per,fixextensions,2}) -> ok;
assert_defined({per,getbit,1}) -> ok;
assert_defined({per,getchoice,3}) -> ok;
assert_defined({per,octets_to_complete,2}) -> ok;
assert_defined({per,set_choice,3}) -> ok;
assert_defined({per,setext,1}) -> ok;
assert_defined({per,skipextensions,3}) -> ok;
assert_defined({per_common,decode_big_chars,2}) -> ok;
assert_defined({per_common,decode_chars,2}) -> ok;
assert_defined({per_common,decode_chars,3}) -> ok;
assert_defined({per_common,decode_chars_16bit,1}) -> ok;
assert_defined({per_common,decode_compact_bit_string,1}) -> ok;
assert_defined({per_common,decode_fragmented,3}) -> ok;
assert_defined({per_common,decode_legacy_bit_string,1}) -> ok;
assert_defined({per_common,decode_named_bit_string,2}) -> ok;
assert_defined({per_common,decode_oid,1}) -> ok;
assert_defined({per_common,decode_relative_oid,1}) -> ok;
assert_defined({real_common,ber_encode_real,1}) -> ok;
assert_defined({real_common,decode_real,1}) -> ok;
assert_defined({real_common,encode_real,1}) -> ok;
assert_defined({uper,complete,1}) -> ok;
assert_defined({uper,complete_NFP,1}) -> ok;
assert_defined({uper,encode_BMPString,2}) -> ok;
assert_defined({uper,encode_GeneralString,2}) -> ok;
assert_defined({uper,encode_GraphicString,2}) -> ok;
assert_defined({uper,encode_IA5String,2}) -> ok;
assert_defined({uper,encode_NumericString,2}) -> ok;
assert_defined({uper,encode_ObjectDescriptor,2}) -> ok;
assert_defined({uper,encode_PrintableString,2}) -> ok;
assert_defined({uper,encode_TeletexString,2}) -> ok;
assert_defined({uper,encode_UTF8String,1}) -> ok;
assert_defined({uper,encode_UniversalString,2}) -> ok;
assert_defined({uper,encode_VideotexString,2}) -> ok;
assert_defined({uper,encode_VisibleString,2}) -> ok;
assert_defined({uper,encode_bit_string,3}) -> ok;
assert_defined({uper,encode_boolean,1}) -> ok;
assert_defined({uper,encode_constrained_number,2}) -> ok;
assert_defined({uper,encode_integer,2}) -> ok;
assert_defined({uper,encode_integer,3}) -> ok;
assert_defined({uper,encode_length,1}) -> ok;
assert_defined({uper,encode_length,2}) -> ok;
assert_defined({uper,encode_object_identifier,1}) -> ok;
assert_defined({uper,encode_octet_string,1}) -> ok;
assert_defined({uper,encode_octet_string,2}) -> ok;
assert_defined({uper,encode_open_type,1}) -> ok;
assert_defined({uper,encode_relative_oid,1}) -> ok;
assert_defined({uper,encode_small_number,1}) -> ok;
assert_defined({uper,fixextensions,2}) -> ok;
assert_defined({uper,fixoptionals,3}) -> ok;
assert_defined({uper,getbit,1}) -> ok;
assert_defined({uper,getchoice,3}) -> ok;
assert_defined({uper,set_choice,3}) -> ok;
assert_defined({uper,setext,1}) -> ok;
assert_defined({uper,skipextensions,3}) -> ok.

dependencies({ber,ber_decode_erlang,1}) ->
[{ber,decode_primitive,1}];
dependencies({ber,collect_parts,1}) ->
[{ber,collect_parts,2}];
dependencies({ber,collect_parts,2}) ->
[{ber,collect_parts,1},{ber,collect_parts,2},{ber,collect_parts_bit,3}];
dependencies({ber,dec_subidentifiers,3}) ->
[{ber,dec_subidentifiers,3}];
dependencies({ber,decode_BMP_string,3}) ->
[{ber,check_restricted_string,3},
 {ber,match_and_collect,2},
 {ber,mk_BMP_string,1}];
dependencies({ber,decode_UTF8_string,2}) ->
[{ber,collect_parts,1},{ber,match_tags,2}];
dependencies({ber,decode_bitstring_NNL,2}) ->
[{ber,decode_bitstring_NNL,4}];
dependencies({ber,decode_bitstring_NNL,4}) ->
[{ber,decode_bitstring_NNL,4}];
dependencies({ber,decode_boolean,2}) ->
[{ber,match_tags,2}];
dependencies({ber,decode_compact_bit_string,3}) ->
[{ber,check_restricted_string,3},{ber,match_and_collect,2}];
dependencies({ber,decode_constr_indef_incomplete,3}) ->
[{ber,decode_constr_indef_incomplete,3},{ber,decode_primitive_incomplete,2}];
dependencies({ber,decode_constructed,1}) ->
[{ber,decode_primitive,1}];
dependencies({ber,decode_constructed_incomplete,2}) ->
[{ber,decode_constructed_incomplete,2},
 {ber,decode_parts_incomplete,1},
 {ber,decode_primitive,1},
 {ber,decode_primitive_incomplete,2},
 {ber,decode_tag_and_length,1},
 {ber,incomplete_choice_alt,2}];
dependencies({ber,decode_constructed_indefinite,2}) ->
[{ber,decode_primitive,1}];
dependencies({ber,decode_enumerated,3}) ->
[{ber,decode_enumerated_notag,3},{ber,match_tags,2}];
dependencies({ber,decode_enumerated_notag,3}) ->
[{ber,decode_enumerated1,2},{ber,decode_integer,1}];
dependencies({ber,decode_generalized_time,3}) ->
[{ber,collect_parts,1},{ber,match_tags,2}];
dependencies({ber,decode_incomplete2,5}) ->
[{ber,decode_constr_indef_incomplete,3},{ber,decode_constructed_incomplete,2}];
dependencies({ber,decode_incomplete_bin,1}) ->
[{ber,skip_length_and_value,1},{ber,skip_tag,1}];
dependencies({ber,decode_integer,3}) ->
[{ber,decode_integer,1},{ber,match_tags,2},{ber,range_check_integer,2}];
dependencies({ber,decode_integer,4}) ->
[{ber,decode_integer,1},
 {ber,match_tags,2},
 {ber,number2name,2},
 {ber,range_check_integer,2}];
dependencies({ber,decode_legacy_bit_string,3}) ->
[{ber,check_restricted_string,3},
 {ber,decode_bitstring2,3},
 {ber,match_and_collect,2}];
dependencies({ber,decode_named_bit_string,3}) ->
[{ber,decode_bitstring2,3},
 {ber,decode_bitstring_NNL,2},
 {ber,match_and_collect,2}];
dependencies({ber,decode_native_bit_string,3}) ->
[{ber,check_restricted_string,3},{ber,match_and_collect,2}];
dependencies({ber,decode_null,2}) ->
[{ber,match_tags,2}];
dependencies({ber,decode_object_identifier,2}) ->
[{ber,dec_subidentifiers,3},{ber,match_tags,2}];
dependencies({ber,decode_open_type,2}) ->
[{ber,ber_decode_nif,1},{ber,match_tags,2}];
dependencies({ber,decode_open_type_as_binary,2}) ->
[{ber,ber_encode,1},{ber,match_tags,2}];
dependencies({ber,decode_parts_incomplete,1}) ->
[{ber,skip_length_and_value,1},{ber,skip_tag,1}];
dependencies({ber,decode_primitive,1}) ->
[{ber,decode_constructed,1},
 {ber,decode_constructed_indefinite,2},
 {ber,decode_tag_and_length,1}];
dependencies({ber,decode_primitive_incomplete,2}) ->
[{ber,decode_incomplete2,5},
 {ber,decode_incomplete_bin,1},
 {ber,decode_parts_incomplete,1},
 {ber,decode_primitive,1},
 {ber,decode_primitive_incomplete,2},
 {ber,decode_tag_and_length,1}];
dependencies({ber,decode_relative_oid,2}) ->
[{ber,dec_subidentifiers,3},{ber,match_tags,2}];
dependencies({ber,decode_restricted_string,2}) ->
[{ber,match_and_collect,2}];
dependencies({ber,decode_restricted_string,3}) ->
[{ber,check_restricted_string,3},{ber,match_and_collect,2}];
dependencies({ber,decode_selective,2}) ->
[{ber,decode_selective,2},
 {ber,get_value,1},
 {ber,return_value,2},
 {ber,skip_length_and_value,1},
 {ber,skip_optional_tag,2},
 {ber,skip_tag,1}];
dependencies({ber,decode_tag_and_length,1}) ->
[{ber,decode_length,1},{ber,decode_tag,2}];
dependencies({ber,decode_universal_string,3}) ->
[{ber,check_restricted_string,3},
 {ber,match_and_collect,2},
 {ber,mk_universal_string,1}];
dependencies({ber,decode_utc_time,3}) ->
[{ber,collect_parts,1},{ber,match_tags,2}];
dependencies({ber,dynamicsort_SET_components,1}) ->
[{ber,dynsort_decode_tag,1}];
dependencies({ber,dynsort_decode_tag,1}) ->
[{ber,dynsort_decode_tag,2}];
dependencies({ber,e_object_identifier,1}) ->
[{ber,e_object_identifier,1},{ber,enc_obj_id_tail,2},{ber,mk_object_val,1}];
dependencies({ber,enc_obj_id_tail,2}) ->
[{ber,mk_object_val,1}];
dependencies({ber,enc_relative_oid,1}) ->
[{ber,mk_object_val,1}];
dependencies({ber,encode_BMP_string,2}) ->
[{ber,encode_tags,3},{ber,mk_BMP_list,1}];
dependencies({ber,encode_UTF8_string,2}) ->
[{ber,encode_tags,3}];
dependencies({ber,encode_bin_bit_string,4}) ->
[{ber,get_constraint,2},{ber,remove_unused_then_dotag,3}];
dependencies({ber,encode_bit_string,4}) ->
[{ber,encode_bin_bit_string,4},
 {ber,encode_bit_string_bits,4},
 {ber,encode_bit_string_named,4},
 {ber,encode_tags,3},
 {ber,int_to_bitlist,1}];
dependencies({ber,encode_bit_string_bits,4}) ->
[{ber,encode_bitstring,1},
 {ber,encode_constr_bit_str_bits,3},
 {ber,encode_tags,3},
 {ber,get_constraint,2},
 {ber,pad_bit_list,2}];
dependencies({ber,encode_bit_string_named,4}) ->
[{ber,encode_bitstring,1},
 {ber,encode_tags,3},
 {ber,get_all_bitposes,3},
 {ber,get_constraint,2},
 {ber,make_and_set_list,3}];
dependencies({ber,encode_bitstring,1}) ->
[{ber,encode_bitstring,3},{ber,unused_bitlist,3}];
dependencies({ber,encode_bitstring,3}) ->
[{ber,unused_bitlist,3}];
dependencies({ber,encode_boolean,2}) ->
[{ber,encode_tags,3}];
dependencies({ber,encode_constr_bit_str_bits,3}) ->
[{ber,encode_bitstring,1},{ber,encode_tags,3}];
dependencies({ber,encode_enumerated,2}) ->
[{ber,encode_integer,1},{ber,encode_tags,2}];
dependencies({ber,encode_generalized_time,2}) ->
[{ber,encode_tags,3}];
dependencies({ber,encode_integer,1}) ->
[{ber,encode_integer_neg,2},{ber,encode_integer_pos,2}];
dependencies({ber,encode_integer,2}) ->
[{ber,encode_integer,1},{ber,encode_tags,2}];
dependencies({ber,encode_integer,3}) ->
[{ber,encode_integer,1},{ber,encode_tags,2}];
dependencies({ber,encode_length,1}) ->
[{ber,minimum_octets,1}];
dependencies({ber,encode_null,2}) ->
[{ber,encode_tags,3}];
dependencies({ber,encode_object_identifier,2}) ->
[{ber,e_object_identifier,1},{ber,encode_tags,2}];
dependencies({ber,encode_open_type,2}) ->
[{ber,encode_tags,3}];
dependencies({ber,encode_relative_oid,2}) ->
[{ber,enc_relative_oid,1},{ber,encode_tags,2}];
dependencies({ber,encode_restricted_string,2}) ->
[{ber,encode_tags,3}];
dependencies({ber,encode_tags,2}) ->
[{ber,encode_tags,3}];
dependencies({ber,encode_tags,3}) ->
[{ber,encode_length,1}];
dependencies({ber,encode_universal_string,2}) ->
[{ber,encode_tags,3},{ber,mk_uni_list,1}];
dependencies({ber,encode_utc_time,2}) ->
[{ber,encode_tags,3}];
dependencies({ber,get_all_bitposes,3}) ->
[{ber,get_all_bitposes,3}];
dependencies({ber,get_indefinite_length_and_value,1}) ->
[{ber,get_indefinite_length_and_value,2}];
dependencies({ber,get_indefinite_length_and_value,2}) ->
[{ber,get_length_and_value,1},{ber,get_tag,1}];
dependencies({ber,get_indefinite_value,2}) ->
[{ber,get_length_and_value,1},{ber,get_tag,1}];
dependencies({ber,get_length_and_value,1}) ->
[{ber,get_indefinite_length_and_value,1}];
dependencies({ber,get_tag,1}) ->
[{ber,get_long_tag,2}];
dependencies({ber,get_value,1}) ->
[{ber,decode_length,1},{ber,get_indefinite_value,2}];
dependencies({ber,incomplete_choice_alt,2}) ->
[{ber,incomplete_choice_alt,2}];
dependencies({ber,make_and_set_list,3}) ->
[{ber,make_and_set_list,3}];
dependencies({ber,match_and_collect,2}) ->
[{ber,collect_parts,1},{ber,match_tags,2}];
dependencies({ber,match_tags,2}) ->
[{ber,match_tags,2}];
dependencies({ber,minimum_octets,1}) ->
[{ber,minimum_octets,2}];
dependencies({ber,mk_BMP_list,1}) ->
[{ber,mk_BMP_list,2}];
dependencies({ber,mk_BMP_list,2}) ->
[{ber,mk_BMP_list,2}];
dependencies({ber,mk_BMP_string,1}) ->
[{ber,mk_BMP_string,2}];
dependencies({ber,mk_BMP_string,2}) ->
[{ber,mk_BMP_string,2}];
dependencies({ber,mk_object_val,1}) ->
[{ber,mk_object_val,3}];
dependencies({ber,mk_uni_list,1}) ->
[{ber,mk_uni_list,2}];
dependencies({ber,mk_uni_list,2}) ->
[{ber,mk_uni_list,2}];
dependencies({ber,mk_universal_string,1}) ->
[{ber,mk_universal_string,2}];
dependencies({ber,mk_universal_string,2}) ->
[{ber,mk_universal_string,2}];
dependencies({ber,remove_unused_then_dotag,3}) ->
[{ber,encode_tags,3}];
dependencies({ber,return_value,2}) ->
[{ber,get_length_and_value,1},{ber,get_tag,1}];
dependencies({ber,skip_indefinite_value,1}) ->
[{ber,skip_length_and_value,1},{ber,skip_tag,1}];
dependencies({ber,skip_length_and_value,1}) ->
[{ber,decode_length,1},{ber,skip_indefinite_value,1}];
dependencies({ber,skip_tag,1}) ->
[{ber,skip_long_tag,1}];
dependencies({check,bit_list_to_int,2}) ->
[{check,bit_list_to_int,2}];
dependencies({check,bit_list_to_nbl,4}) ->
[{check,bit_list_to_nbl,4}];
dependencies({check,cbs_to_bit_list,1}) ->
[{check,int_to_bit_list,3}];
dependencies({check,check_bitstring,3}) ->
[{check,bit_list_to_int,2},
 {check,bit_list_to_nbl,4},
 {check,cbs_to_bit_list,1},
 {check,check_bitstring,3},
 {check,check_bitstring1,2},
 {check,int_to_bit_list,3},
 {check,remove_trailing_zeros,1}];
dependencies({check,check_objectidentifier,2}) ->
[{check,check_objectidentifier1,2}];
dependencies({check,check_objectidentifier1,2}) ->
[{check,check_objectidentifier1,3},{check,reserved_objectid,2}];
dependencies({check,check_objectidentifier1,3}) ->
[{check,check_objectidentifier1,3},{check,reserved_objectid,2}];
dependencies({check,check_octetstring,2}) ->
[{check,integer_to_octetlist,1}];
dependencies({check,check_restrictedstring,2}) ->
[{check,check_restrictedstring,2}];
dependencies({check,integer_to_octetlist,1}) ->
[{check,integer_to_octetlist,2}];
dependencies({check,remove_trailing_zeros,1}) ->
[{check,remove_trailing_zeros1,1}];
dependencies({ext,transform_to_EXTERNAL1990,1}) ->
[{ext,transform_to_EXTERNAL1990,2}];
dependencies({ext,transform_to_EXTERNAL1990,2}) ->
[{ext,transform_to_EXTERNAL1990,2}];
dependencies({per,bit_string_trailing_zeros,2}) ->
[{per,bit_string_trailing_zeros1,3}];
dependencies({per,chars_encode2,3}) ->
[{per,chars_encode2,3},{per,exit_if_false,2},{per,pre_complete_bits,2}];
dependencies({per,decode_constrained_number,2}) ->
[{per,decode_constrained_number,3}];
dependencies({per,decode_constrained_number,3}) ->
[{per,decode_length,2},
 {per,getbits,2},
 {per,getoctets,2},
 {per,getoctets_as_bin,2}];
dependencies({per,decode_length,1}) ->
[{per,align,1}];
dependencies({per,decode_length,2}) ->
[{per,decode_constrained_number,2},{per,decode_length,1}];
dependencies({per,decode_semi_constrained_number,1}) ->
[{per,decode_length,1},{per,getoctets,2}];
dependencies({per,decode_small_number,1}) ->
[{per,decode_semi_constrained_number,1},{per,getbit,1},{per,getbits,2}];
dependencies({per,e_object_element,1}) ->
[{per,e_o_e,1}];
dependencies({per,e_object_elements,2}) ->
[{per,e_object_element,1}];
dependencies({per,e_object_identifier,1}) ->
[{per,e_object_elements,2},{per,e_object_identifier,1}];
dependencies({per,efos_1,1}) ->
[{per,efos_1,1},{per,encode_length,1},{per,octets_to_complete,2}];
dependencies({per,eint_positive,1}) ->
[{per,eint,2}];
dependencies({per,encode_GeneralString,2}) ->
[{per,encode_restricted_string,1}];
dependencies({per,encode_GraphicString,2}) ->
[{per,encode_restricted_string,1}];
dependencies({per,encode_ObjectDescriptor,2}) ->
[{per,encode_restricted_string,1}];
dependencies({per,encode_TeletexString,2}) ->
[{per,encode_restricted_string,1}];
dependencies({per,encode_UTF8String,1}) ->
[{per,encode_length,1},{per,octets_to_complete,2}];
dependencies({per,encode_VideotexString,2}) ->
[{per,encode_restricted_string,1}];
dependencies({per,encode_bin_bit_string,3}) ->
[{per,encode_bin_bit_string,3},
 {per,encode_length,1},
 {per,encode_length,2},
 {per,octets_unused_to_complete,3},
 {per,range_check,2},
 {per,remove_trailing_bin,2}];
dependencies({per,encode_bit_string,3}) ->
[{per,bit_string_trailing_zeros,2},
 {per,encode_bin_bit_string,3},
 {per,encode_bit_string,3},
 {per,encode_length,1},
 {per,encode_length,2},
 {per,get_all_bitposes,3},
 {per,int_to_bitlist,1},
 {per,make_and_set_list,2}];
dependencies({per,encode_constrained_number,2}) ->
[{per,minimum_bits,1}];
dependencies({per,encode_constrained_number,4}) ->
[{per,eint_positive,1},{per,encode_length,2}];
dependencies({per,encode_fragmented_octet_string,1}) ->
[{per,efos_1,1}];
dependencies({per,encode_integer,2}) ->
[{per,encode_constrained_number,2},
 {per,encode_constrained_number,4},
 {per,encode_semi_constrained_number,2},
 {per,encode_unconstrained_number,1}];
dependencies({per,encode_known_multiplier_string,4}) ->
[{per,chars_encode2,3},{per,encode_length,1},{per,encode_length,2}];
dependencies({per,encode_length,2}) ->
[{per,encode_constrained_number,2},
 {per,encode_length,1},
 {per,encode_semi_constrained_number,2}];
dependencies({per,encode_object_identifier,1}) ->
[{per,e_object_identifier,1},{per,encode_length,1},{per,octets_to_complete,2}];
dependencies({per,encode_octet_string,3}) ->
[{per,encode_fragmented_octet_string,1},
 {per,encode_length,1},
 {per,encode_length,2},
 {per,octets_to_complete,2}];
dependencies({per,encode_open_type,1}) ->
[{per,encode_length,1}];
dependencies({per,encode_relative_oid,1}) ->
[{per,e_object_element,1},{per,encode_length,1},{per,octets_to_complete,2}];
dependencies({per,encode_restricted_string,1}) ->
[{per,encode_length,1},{per,octets_to_complete,2}];
dependencies({per,encode_semi_constrained_number,2}) ->
[{per,eint_positive,1},{per,encode_length,1}];
dependencies({per,encode_small_length,1}) ->
[{per,encode_length,1}];
dependencies({per,encode_small_number,1}) ->
[{per,encode_semi_constrained_number,2}];
dependencies({per,encode_unconstrained_number,1}) ->
[{per,eint,2},{per,encode_length,1},{per,enint,2}];
dependencies({per,fixextensions,2}) ->
[{per,encode_small_length,1},{per,fixextensions,4},{per,pre_complete_bits,2}];
dependencies({per,get_all_bitposes,3}) ->
[{per,get_all_bitposes,3}];
dependencies({per,getchoice,3}) ->
[{per,decode_constrained_number,2},{per,decode_small_number,1}];
dependencies({per,make_and_set_list,2}) ->
[{per,make_and_set_list,2}];
dependencies({per,remove_trailing_bin,2}) ->
[{per,trailingZeroesInNibble,1}];
dependencies({per,set_choice,3}) ->
[{per,encode_constrained_number,2},
 {per,encode_small_number,1},
 {per,set_choice_tag,2}];
dependencies({per,set_choice_tag,2}) ->
[{per,set_choice_tag,3}];
dependencies({per,skipextensions,3}) ->
[{per,decode_length,1},{per,skipextensions,3}];
dependencies({per_common,dec_subidentifiers,3}) ->
[{per_common,dec_subidentifiers,3}];
dependencies({per_common,decode_big_chars,2}) ->
[{per_common,decode_big_chars_1,1},{per_common,decode_chars,2}];
dependencies({per_common,decode_big_chars_1,1}) ->
[{per_common,decode_big_chars_1,1}];
dependencies({per_common,decode_chars_16bit,1}) ->
[{per_common,decode_chars_16bit_1,1}];
dependencies({per_common,decode_chars_16bit_1,1}) ->
[{per_common,decode_chars_16bit_1,1}];
dependencies({per_common,decode_fragmented,3}) ->
[{per_common,decode_fragmented_1,3}];
dependencies({per_common,decode_named_bit_string,2}) ->
[{per_common,decode_named_bit_string_1,4}];
dependencies({per_common,decode_named_bit_string_1,4}) ->
[{per_common,decode_named_bit_string_1,4}];
dependencies({per_common,decode_oid,1}) ->
[{per_common,dec_subidentifiers,3}];
dependencies({per_common,decode_relative_oid,1}) ->
[{per_common,dec_subidentifiers,3}];
dependencies({real_common,ber_encode_real,1}) ->
[{real_common,encode_real,1}];
dependencies({real_common,decode_real,1}) ->
[{real_common,decode_real2,4}];
dependencies({real_common,decode_real2,4}) ->
[{real_common,decode_integer2,3}];
dependencies({real_common,encode_real,1}) ->
[{real_common,encode_real,2}];
dependencies({real_common,encode_real,2}) ->
[{real_common,encode_neg_integer,2},
 {real_common,encode_pos_integer,2},
 {real_common,encode_real_as_string,3},
 {real_common,real_mininum_octets,1},
 {real_common,remove_trailing_zeros,1},
 {real_common,truncate_zeros,1}];
dependencies({real_common,encode_real_as_string,3}) ->
[{real_common,remove_trailing_zeros,1}];
dependencies({real_common,real_mininum_octets,1}) ->
[{real_common,real_mininum_octets,2}];
dependencies({real_common,truncate_zeros,1}) ->
[{real_common,truncate_zeros,2}];
dependencies({uper,bitstr_trailing_zeros,2}) ->
[{uper,bit_list2bitstr,2},{uper,bitstr_trailing_zeros1,3}];
dependencies({uper,bitstr_trailing_zeros1,3}) ->
[{uper,bit_list2bitstr,2}];
dependencies({uper,charbits,1}) ->
[{uper,charbits1,1}];
dependencies({uper,chars_encode,3}) ->
[{uper,chars_encode2,3},
 {uper,get_CharOutTab,2},
 {uper,get_NumBits,2},
 {uper,get_constraint,2}];
dependencies({uper,chars_encode2,3}) ->
[{uper,chars_encode2,3},{uper,exit_if_false,2}];
dependencies({uper,complete,1}) ->
[{uper,complete1,1}];
dependencies({uper,create_char_tab,2}) ->
[{uper,create_char_tab,3}];
dependencies({uper,create_char_tab,3}) ->
[{uper,create_char_tab,3}];
dependencies({uper,decode_constrained_number,2}) ->
[{uper,getbits,2},{uper,num_bits,1}];
dependencies({uper,decode_semi_constrained_number,1}) ->
[{uper,decode_length,1},{uper,getoctets,2}];
dependencies({uper,decode_small_number,1}) ->
[{uper,decode_semi_constrained_number,1},{uper,getbit,1},{uper,getbits,2}];
dependencies({uper,e_object_element,1}) ->
[{uper,e_o_e,1}];
dependencies({uper,e_object_elements,2}) ->
[{uper,e_object_element,1}];
dependencies({uper,e_object_identifier,1}) ->
[{uper,e_object_elements,2},{uper,e_object_identifier,1}];
dependencies({uper,efos_1,1}) ->
[{uper,efos_1,1},{uper,encode_length,1}];
dependencies({uper,eint_bin_2Cs,1}) ->
[{uper,eint_bin_positive,1}];
dependencies({uper,eint_bin_positive,1}) ->
[{uper,eint_bin_positive2,1}];
dependencies({uper,encode_BMPString,2}) ->
[{uper,encode_known_multiplier_string,3}];
dependencies({uper,encode_GeneralString,2}) ->
[{uper,encode_restricted_string,1}];
dependencies({uper,encode_GraphicString,2}) ->
[{uper,encode_restricted_string,1}];
dependencies({uper,encode_IA5String,2}) ->
[{uper,encode_known_multiplier_string,3}];
dependencies({uper,encode_NumericString,2}) ->
[{uper,encode_known_multiplier_string,3}];
dependencies({uper,encode_ObjectDescriptor,2}) ->
[{uper,encode_restricted_string,1}];
dependencies({uper,encode_PrintableString,2}) ->
[{uper,encode_known_multiplier_string,3}];
dependencies({uper,encode_TeletexString,2}) ->
[{uper,encode_restricted_string,1}];
dependencies({uper,encode_UTF8String,1}) ->
[{uper,encode_length,1}];
dependencies({uper,encode_UniversalString,2}) ->
[{uper,encode_known_multiplier_string,3}];
dependencies({uper,encode_VideotexString,2}) ->
[{uper,encode_restricted_string,1}];
dependencies({uper,encode_VisibleString,2}) ->
[{uper,encode_known_multiplier_string,3}];
dependencies({uper,encode_bin_bit_string,3}) ->
[{uper,adjust_trailing_zeros,2},
 {uper,encode_length,1},
 {uper,encode_length,2},
 {uper,remove_trailing_bin,2}];
dependencies({uper,encode_bit_string,3}) ->
[{uper,encode_bin_bit_string,3},{uper,encode_bit_string1,3}];
dependencies({uper,encode_bit_string1,3}) ->
[{uper,bit_list2bitstr,2},
 {uper,bitstr_trailing_zeros,2},
 {uper,encode_bit_string1,3},
 {uper,encode_length,1},
 {uper,encode_length,2},
 {uper,get_all_bitposes,3},
 {uper,int_to_bitlist,1},
 {uper,make_and_set_list,2}];
dependencies({uper,encode_constrained_number,2}) ->
[{uper,num_bits,1}];
dependencies({uper,encode_fragmented_octet_string,1}) ->
[{uper,efos_1,1}];
dependencies({uper,encode_integer,2}) ->
[{uper,encode_integer1,2},
 {uper,encode_unconstrained_number,1},
 {uper,get_constraint,2}];
dependencies({uper,encode_integer,3}) ->
[{uper,encode_integer,2}];
dependencies({uper,encode_integer1,2}) ->
[{uper,encode_constrained_number,2},
 {uper,encode_semi_constrained_number,2},
 {uper,encode_unconstrained_number,1},
 {uper,get_constraint,2}];
dependencies({uper,encode_known_multiplier_string,3}) ->
[{uper,chars_encode,3},
 {uper,encode_length,1},
 {uper,encode_length,2},
 {uper,get_NumBits,2},
 {uper,get_constraint,2}];
dependencies({uper,encode_length,2}) ->
[{uper,encode_constrained_number,2},
 {uper,encode_length,1},
 {uper,encode_semi_constrained_number,2}];
dependencies({uper,encode_object_identifier,1}) ->
[{uper,e_object_identifier,1},{uper,encode_length,1}];
dependencies({uper,encode_octet_string,1}) ->
[{uper,encode_fragmented_octet_string,1},{uper,encode_length,1}];
dependencies({uper,encode_octet_string,2}) ->
[{uper,encode_fragmented_octet_string,1},{uper,encode_length,2}];
dependencies({uper,encode_open_type,1}) ->
[{uper,encode_length,1}];
dependencies({uper,encode_relative_oid,1}) ->
[{uper,e_object_element,1},{uper,encode_length,1}];
dependencies({uper,encode_restricted_string,1}) ->
[{uper,encode_length,1}];
dependencies({uper,encode_semi_constrained_number,2}) ->
[{uper,eint_bin_positive,1},{uper,encode_length,1}];
dependencies({uper,encode_small_length,1}) ->
[{uper,encode_length,1}];
dependencies({uper,encode_small_number,1}) ->
[{uper,encode_semi_constrained_number,2}];
dependencies({uper,encode_unconstrained_number,1}) ->
[{uper,eint_bin_2Cs,1},{uper,encode_length,1},{uper,enint,2}];
dependencies({uper,fixextensions,2}) ->
[{uper,encode_small_length,1},{uper,fixextensions,4}];
dependencies({uper,fixoptionals,3}) ->
[{uper,fixoptionals,3}];
dependencies({uper,get_CharOutTab,2}) ->
[{uper,get_CharTab2,5},{uper,get_constraint,2}];
dependencies({uper,get_CharTab2,5}) ->
[{uper,create_char_tab,2},{uper,get_NumBits,2}];
dependencies({uper,get_NumBits,2}) ->
[{uper,charbits,1},{uper,get_constraint,2}];
dependencies({uper,get_all_bitposes,3}) ->
[{uper,get_all_bitposes,3}];
dependencies({uper,getchoice,3}) ->
[{uper,decode_constrained_number,2},{uper,decode_small_number,1}];
dependencies({uper,make_and_set_list,2}) ->
[{uper,make_and_set_list,2}];
dependencies({uper,num_bits,1}) ->
[{uper,num_bits,3}];
dependencies({uper,remove_trailing_bin,2}) ->
[{uper,trailingZeroesInNibble,1}];
dependencies({uper,set_choice,3}) ->
[{uper,encode_integer,2},{uper,encode_small_number,1},{uper,set_choice_tag,2}];
dependencies({uper,set_choice_tag,2}) ->
[{uper,set_choice_tag,3}];
dependencies({uper,skipextensions,3}) ->
[{uper,decode_length,1},{uper,skipextensions,3}];
dependencies(_) -> [].

code() ->
[{{ber,ber_encode,1},
  <<"\nber_encode([Tlv]) ->\n    ber_encode(Tlv);\nber_encode(Tlv) when is_binary(Tlv) ->\n    Tlv;\nber_encode(Tlv) ->\n    asn1rt_nif:encode_ber_tlv(Tlv).\n">>},
 {{ber,ber_decode_nif,1},
  <<"\nber_decode_nif(B) ->\n    asn1rt_nif:decode_ber_tlv(B).\n">>},
 {{ber,ber_decode_erlang,1},
  <<"\nber_decode_erlang(B) when is_binary(B) ->\n    decode_primitive(B);\nber_decode_erlang(Tlv) ->\n    {Tlv,<<>>}.\n">>},
 {{ber,decode_primitive,1},
  <<"\ndecode_primitive(Bin) ->\n    {Form,TagNo,V,Rest} = decode_tag_and_length(Bin),\n    case Form of\n        1 ->\n            {{TagNo,decode_constructed(V)},Rest};\n        0 ->\n            {{TagNo,V},Rest};\n        2 ->\n            {Vlist,Rest2} = decode_constructed_indefinite(V, []),\n            {{TagNo,Vlist},Rest2}\n    end.\n">>},
 {{ber,decode_constructed,1},
  <<"\ndecode_constructed(Bin) when byte_size(Bin) =:= 0 ->\n    [];\ndecode_constructed(Bin) ->\n    {Tlv,Rest} = decode_primitive(Bin),\n    [Tlv|decode_constructed(Rest)].\n">>},
 {{ber,decode_constructed_indefinite,2},
  <<"\ndecode_constructed_indefinite(<<0,0,Rest/binary>>, Acc) ->\n    {lists:reverse(Acc),Rest};\ndecode_constructed_indefinite(Bin, Acc) ->\n    {Tlv,Rest} = decode_primitive(Bin),\n    decode_constructed_indefinite(Rest, [Tlv|Acc]).\n">>},
 {{ber,decode_primitive_incomplete,2},
  <<"\ndecode_primitive_incomplete([[default,TagNo]], Bin) ->\n    case decode_tag_and_length(Bin) of\n        {Form,TagNo,V,Rest} ->\n            decode_incomplete2(Form, TagNo, V, [], Rest);\n        _ ->\n            asn1_NOVALUE\n    end;\ndecode_primitive_incomplete([[default,TagNo,Directives]], Bin) ->\n    case decode_tag_and_length(Bin) of\n        {Form,TagNo,V,Rest} ->\n            decode_incomplete2(Form, TagNo, V, Directives, Rest);\n        _ ->\n            asn1_NOVALUE\n    end;\ndecode_primitive_incomplete([[opt,TagNo]], Bin) ->\n    case decode_tag_and_length(Bin) of\n        {Form,TagNo,V,Rest} ->\n            decode_incomplete2(Form, TagNo, V, [], Rest);\n        _ ->\n            asn1_NOVALUE\n    end;\ndecode_primitive_incomplete([[opt,TagNo,Directives]], Bin) ->\n    case decode_tag_and_length(Bin) of\n        {Form,TagNo,V,Rest} ->\n            decode_incomplete2(Form, TagNo, V, Directives, Rest);\n        _ ->\n            asn1_NOVALUE\n    end;\ndecode_primitive_incomplete([[opt_undec,Tag]], Bin) ->\n    case decode_tag_and_length(Bin) of\n        {_,Tag,_,_} ->\n            decode_incomplete_bin(Bin);\n        _ ->\n            asn1_NOVALUE\n    end;\ndecode_primitive_incomplete([[alt_undec,TagNo]|RestAlts], Bin) ->\n    case decode_tag_and_length(Bin) of\n        {_,TagNo,_,_} ->\n            decode_incomplete_bin(Bin);\n        _ ->\n            decode_primitive_incomplete(RestAlts, Bin)\n    end;\ndecode_primitive_incomplete([[alt,TagNo]|RestAlts], Bin) ->\n    case decode_tag_and_length(Bin) of\n        {_Form,TagNo,V,Rest} ->\n            {{TagNo,V},Rest};\n        _ ->\n            decode_primitive_incomplete(RestAlts, Bin)\n    end;\ndecode_primitive_incomplete([[alt,TagNo,Directives]|RestAlts], Bin) ->\n    case decode_tag_and_length(Bin) of\n        {Form,TagNo,V,Rest} ->\n            decode_incomplete2(Form, TagNo, V, Directives, Rest);\n        _ ->\n            decode_primitive_incomplete(RestAlts, Bin)\n    end;\ndecode_primitive_incomplete([[alt_parts,TagNo]], Bin) ->\n    case decode_tag_and_length(Bin) of\n        {_Form,TagNo,V,Rest} ->\n            {{TagNo,V},Rest};\n        _ ->\n            asn1_NOVALUE\n    end;\ndecode_primitive_incomplete([[alt_parts,TagNo]|RestAlts], Bin) ->\n    case decode_tag_and_length(Bin) of\n        {_Form,TagNo,V,Rest} ->\n            {{TagNo,decode_parts_incomplete(V)},Rest};\n        _ ->\n            decode_primitive_incomplete(RestAlts, Bin)\n    end;\ndecode_primitive_incomplete([[undec,_TagNo]|_RestTag], Bin) ->\n    decode_incomplete_bin(Bin);\ndecode_primitive_incomplete([[parts,TagNo]|_RestTag], Bin) ->\n    case decode_tag_and_length(Bin) of\n        {_Form,TagNo,V,Rest} ->\n            {{TagNo,decode_parts_incomplete(V)},Rest};\n        Err ->\n            {error,{asn1,\"tag failure\",TagNo,Err}}\n    end;\ndecode_primitive_incomplete([mandatory|RestTag], Bin) ->\n    {Form,TagNo,V,Rest} = decode_tag_and_length(Bin),\n    decode_incomplete2(Form, TagNo, V, RestTag, Rest);\ndecode_primitive_incomplete([[mandatory|Directives]], Bin) ->\n    {Form,TagNo,V,Rest} = decode_tag_and_length(Bin),\n    decode_incomplete2(Form, TagNo, V, Directives, Rest);\ndecode_primitive_incomplete([], Bin) ->\n    decode_primitive(Bin).\n">>},
 {{ber,decode_parts_incomplete,1},
  <<"\ndecode_parts_incomplete(<<>>) ->\n    [];\ndecode_parts_incomplete(Bin) ->\n    {ok,Rest} = skip_tag(Bin),\n    {ok,Rest2} = skip_length_and_value(Rest),\n    LenPart = byte_size(Bin) - byte_size(Rest2),\n    <<Part:LenPart/binary,RestBin/binary>> = Bin,\n    [Part|decode_parts_incomplete(RestBin)].\n">>},
 {{ber,decode_incomplete2,5},
  <<"\ndecode_incomplete2(_Form = 2, TagNo, V, TagMatch, _) ->\n    {Vlist,Rest2} = decode_constr_indef_incomplete(TagMatch, V, []),\n    {{TagNo,Vlist},Rest2};\ndecode_incomplete2(1, TagNo, V, [TagMatch], Rest) when is_list(TagMatch) ->\n    {{TagNo,decode_constructed_incomplete(TagMatch, V)},Rest};\ndecode_incomplete2(1, TagNo, V, TagMatch, Rest) ->\n    {{TagNo,decode_constructed_incomplete(TagMatch, V)},Rest};\ndecode_incomplete2(0, TagNo, V, _TagMatch, Rest) ->\n    {{TagNo,V},Rest}.\n">>},
 {{ber,decode_constructed_incomplete,2},
  <<"\ndecode_constructed_incomplete([Tags = [Ts]], Bin) when is_list(Ts) ->\n    decode_constructed_incomplete(Tags, Bin);\ndecode_constructed_incomplete(_TagMatch, <<>>) ->\n    [];\ndecode_constructed_incomplete([mandatory|RestTag], Bin) ->\n    {Tlv,Rest} = decode_primitive(Bin),\n    [Tlv|decode_constructed_incomplete(RestTag, Rest)];\ndecode_constructed_incomplete(Directives = [[Alt,_]|_], Bin)\n    when Alt =:= alt_undec; Alt =:= alt; Alt =:= alt_parts ->\n    {_Form,TagNo,V,Rest} = decode_tag_and_length(Bin),\n    case incomplete_choice_alt(TagNo, Directives) of\n        {alt_undec,_} ->\n            LenA = byte_size(Bin) - byte_size(Rest),\n            <<A:LenA/binary,Rest/binary>> = Bin,\n            A;\n        {alt,InnerDirectives} ->\n            {Tlv,Rest} = decode_primitive_incomplete(InnerDirectives, V),\n            {TagNo,Tlv};\n        {alt_parts,_} ->\n            [{TagNo,decode_parts_incomplete(V)}];\n        no_match ->\n            {Tlv,_} = decode_primitive(Bin),\n            Tlv\n    end;\ndecode_constructed_incomplete([TagNo|RestTag], Bin) ->\n    case decode_primitive_incomplete([TagNo], Bin) of\n        {Tlv,Rest} ->\n            [Tlv|decode_constructed_incomplete(RestTag, Rest)];\n        asn1_NOVALUE ->\n            decode_constructed_incomplete(RestTag, Bin)\n    end;\ndecode_constructed_incomplete([], Bin) ->\n    {Tlv,Rest} = decode_primitive(Bin),\n    [Tlv|decode_constructed_incomplete([], Rest)].\n">>},
 {{ber,decode_constr_indef_incomplete,3},
  <<"\ndecode_constr_indef_incomplete(_TagMatch, <<0,0,Rest/binary>>, Acc) ->\n    {lists:reverse(Acc),Rest};\ndecode_constr_indef_incomplete([Tag|RestTags], Bin, Acc) ->\n    case decode_primitive_incomplete([Tag], Bin) of\n        {Tlv,Rest} ->\n            decode_constr_indef_incomplete(RestTags, Rest, [Tlv|Acc]);\n        asn1_NOVALUE ->\n            decode_constr_indef_incomplete(RestTags, Bin, Acc)\n    end.\n">>},
 {{ber,decode_incomplete_bin,1},
  <<"\ndecode_incomplete_bin(Bin) ->\n    {ok,Rest} = skip_tag(Bin),\n    {ok,Rest2} = skip_length_and_value(Rest),\n    IncLen = byte_size(Bin) - byte_size(Rest2),\n    <<IncBin:IncLen/binary,Ret/binary>> = Bin,\n    {IncBin,Ret}.\n">>},
 {{ber,incomplete_choice_alt,2},
  <<"\nincomplete_choice_alt(TagNo, [[Alt,TagNo]|Directives]) ->\n    {Alt,Directives};\nincomplete_choice_alt(TagNo, [D]) when is_list(D) ->\n    incomplete_choice_alt(TagNo, D);\nincomplete_choice_alt(TagNo, [_H|Directives]) ->\n    incomplete_choice_alt(TagNo, Directives);\nincomplete_choice_alt(_, []) ->\n    no_match.\n">>},
 {{ber,decode_selective,2},
  <<"\ndecode_selective([], Binary) ->\n    {ok,Binary};\ndecode_selective([skip|RestPattern], Binary) ->\n    {ok,RestBinary} = skip_tag(Binary),\n    {ok,RestBinary2} = skip_length_and_value(RestBinary),\n    decode_selective(RestPattern, RestBinary2);\ndecode_selective([[skip_optional,Tag]|RestPattern], Binary) ->\n    case skip_optional_tag(Tag, Binary) of\n        {ok,RestBinary} ->\n            {ok,RestBinary2} = skip_length_and_value(RestBinary),\n            decode_selective(RestPattern, RestBinary2);\n        missing ->\n            decode_selective(RestPattern, Binary)\n    end;\ndecode_selective([[choosen,Tag]], Binary) ->\n    return_value(Tag, Binary);\ndecode_selective([[choosen,Tag]|RestPattern], Binary) ->\n    case skip_optional_tag(Tag, Binary) of\n        {ok,RestBinary} ->\n            {ok,Value} = get_value(RestBinary),\n            decode_selective(RestPattern, Value);\n        missing ->\n            {ok,<<>>}\n    end;\ndecode_selective(P, _) ->\n    {error,{asn1,{partial_decode,\"bad pattern\",P}}}.\n">>},
 {{ber,return_value,2},
  <<"\nreturn_value(Tag, Binary) ->\n    {ok,{Tag,RestBinary}} = get_tag(Binary),\n    {ok,{LenVal,_RestBinary2}} = get_length_and_value(RestBinary),\n    {ok,<<Tag/binary,LenVal/binary>>}.\n">>},
 {{ber,skip_tag,1},
  <<"\nskip_tag(<<_:3,31:5,Rest/binary>>) ->\n    skip_long_tag(Rest);\nskip_tag(<<_:3,_Tag:5,Rest/binary>>) ->\n    {ok,Rest}.\n">>},
 {{ber,skip_long_tag,1},
  <<"\nskip_long_tag(<<1:1,_:7,Rest/binary>>) ->\n    skip_long_tag(Rest);\nskip_long_tag(<<0:1,_:7,Rest/binary>>) ->\n    {ok,Rest}.\n">>},
 {{ber,skip_optional_tag,2},
  <<"\nskip_optional_tag(<<>>, Binary) ->\n    {ok,Binary};\nskip_optional_tag(<<Tag,RestTag/binary>>, <<Tag,Rest/binary>>) ->\n    skip_optional_tag(RestTag, Rest);\nskip_optional_tag(_, _) ->\n    missing.\n">>},
 {{ber,skip_length_and_value,1},
  <<"\nskip_length_and_value(Binary) ->\n    case decode_length(Binary) of\n        {indefinite,RestBinary} ->\n            skip_indefinite_value(RestBinary);\n        {Length,RestBinary} ->\n            <<_:Length/unit:8,Rest/binary>> = RestBinary,\n            {ok,Rest}\n    end.\n">>},
 {{ber,skip_indefinite_value,1},
  <<"\nskip_indefinite_value(<<0,0,Rest/binary>>) ->\n    {ok,Rest};\nskip_indefinite_value(Binary) ->\n    {ok,RestBinary} = skip_tag(Binary),\n    {ok,RestBinary2} = skip_length_and_value(RestBinary),\n    skip_indefinite_value(RestBinary2).\n">>},
 {{ber,get_value,1},
  <<"\nget_value(Binary) ->\n    case decode_length(Binary) of\n        {indefinite,RestBinary} ->\n            get_indefinite_value(RestBinary, []);\n        {Length,RestBinary} ->\n            <<Value:Length/binary,_Rest/binary>> = RestBinary,\n            {ok,Value}\n    end.\n">>},
 {{ber,get_indefinite_value,2},
  <<"\nget_indefinite_value(<<0,0,_Rest/binary>>, Acc) ->\n    {ok,list_to_binary(lists:reverse(Acc))};\nget_indefinite_value(Binary, Acc) ->\n    {ok,{Tag,RestBinary}} = get_tag(Binary),\n    {ok,{LenVal,RestBinary2}} = get_length_and_value(RestBinary),\n    get_indefinite_value(RestBinary2, [LenVal,Tag|Acc]).\n">>},
 {{ber,get_tag,1},
  <<"\nget_tag(<<H:1/binary,Rest/binary>>) ->\n    case H of\n        <<_:3,31:5>> ->\n            get_long_tag(Rest, [H]);\n        _ ->\n            {ok,{H,Rest}}\n    end.\n">>},
 {{ber,get_long_tag,2},
  <<"\nget_long_tag(<<H:1/binary,Rest/binary>>, Acc) ->\n    case H of\n        <<0:1,_:7>> ->\n            {ok,{list_to_binary(lists:reverse([H|Acc])),Rest}};\n        _ ->\n            get_long_tag(Rest, [H|Acc])\n    end.\n">>},
 {{ber,get_length_and_value,1},
  <<"\nget_length_and_value(Bin = <<0:1,Length:7,_T/binary>>) ->\n    <<Len,Val:Length/binary,Rest/binary>> = Bin,\n    {ok,{<<Len,Val/binary>>,Rest}};\nget_length_and_value(Bin = <<1:1,0:7,_T/binary>>) ->\n    get_indefinite_length_and_value(Bin);\nget_length_and_value(<<1:1,LL:7,T/binary>>) ->\n    <<Length:LL/unit:8,Rest/binary>> = T,\n    <<Value:Length/binary,Rest2/binary>> = Rest,\n    {ok,{<<1:1,LL:7,Length:LL/unit:8,Value/binary>>,Rest2}}.\n">>},
 {{ber,get_indefinite_length_and_value,1},
  <<"\nget_indefinite_length_and_value(<<H,T/binary>>) ->\n    get_indefinite_length_and_value(T, [H]).\n">>},
 {{ber,get_indefinite_length_and_value,2},
  <<"\nget_indefinite_length_and_value(<<0,0,Rest/binary>>, Acc) ->\n    {ok,{list_to_binary(lists:reverse(Acc)),Rest}};\nget_indefinite_length_and_value(Binary, Acc) ->\n    {ok,{Tag,RestBinary}} = get_tag(Binary),\n    {ok,{LenVal,RestBinary2}} = get_length_and_value(RestBinary),\n    get_indefinite_length_and_value(RestBinary2, [LenVal,Tag|Acc]).\n">>},
 {{ber,match_tags,2},
  <<"\nmatch_tags({T,V}, [T]) ->\n    V;\nmatch_tags({T,V}, [T|Tt]) ->\n    match_tags(V, Tt);\nmatch_tags([{T,V}], [T|Tt]) ->\n    match_tags(V, Tt);\nmatch_tags([{T,_V}|_] = Vlist, [T]) ->\n    Vlist;\nmatch_tags(Tlv, []) ->\n    Tlv;\nmatch_tags({Tag,_V} = Tlv, [T|_Tt]) ->\n    exit({error,{asn1,{wrong_tag,{{expected,T},{got,Tag,Tlv}}}}}).\n">>},
 {{ber,skip_ExtensionAdditions,2},
  <<"\nskip_ExtensionAdditions([], _Tags) ->\n    [];\nskip_ExtensionAdditions([{Tag,_}|Rest] = TLV, Tags) ->\n    case\n        [ \n         X ||\n             X = T <- Tags,\n             T =:= Tag\n        ]\n    of\n        [] ->\n            skip_ExtensionAdditions(Rest, Tags);\n        _ ->\n            TLV\n    end.\n">>},
 {{ber,decode_tag_and_length,1},
  <<"\ndecode_tag_and_length(<<Class:2,\n                        Form:1,\n                        TagNo:5,\n                        0:1,\n                        Length:7,\n                        V:Length/binary,\n                        RestBuffer/binary>>)\n    when TagNo < 31 ->\n    {Form,Class bsl 16 bor TagNo,V,RestBuffer};\ndecode_tag_and_length(<<Class:2,1:1,TagNo:5,1:1,0:7,T/binary>>)\n    when TagNo < 31 ->\n    {2,Class bsl 16 + TagNo,T,<<>>};\ndecode_tag_and_length(<<Class:2,\n                        Form:1,\n                        TagNo:5,\n                        1:1,\n                        LL:7,\n                        Length:LL/unit:8,\n                        V:Length/binary,\n                        T/binary>>)\n    when TagNo < 31 ->\n    {Form,Class bsl 16 bor TagNo,V,T};\ndecode_tag_and_length(<<Class:2,\n                        Form:1,\n                        31:5,\n                        0:1,\n                        TagNo:7,\n                        0:1,\n                        Length:7,\n                        V:Length/binary,\n                        RestBuffer/binary>>) ->\n    {Form,Class bsl 16 bor TagNo,V,RestBuffer};\ndecode_tag_and_length(<<Class:2,1:1,31:5,0:1,TagNo:7,1:1,0:7,T/binary>>) ->\n    {2,Class bsl 16 bor TagNo,T,<<>>};\ndecode_tag_and_length(<<Class:2,\n                        Form:1,\n                        31:5,\n                        0:1,\n                        TagNo:7,\n                        1:1,\n                        LL:7,\n                        Length:LL/unit:8,\n                        V:Length/binary,\n                        T/binary>>) ->\n    {Form,Class bsl 16 bor TagNo,V,T};\ndecode_tag_and_length(<<Class:2,\n                        Form:1,\n                        31:5,\n                        1:1,\n                        TagPart1:7,\n                        0:1,\n                        TagPartLast,\n                        Buffer/binary>>) ->\n    TagNo = TagPart1 bsl 7 bor TagPartLast,\n    {Length,RestBuffer} = decode_length(Buffer),\n    <<V:Length/binary,RestBuffer2/binary>> = RestBuffer,\n    {Form,Class bsl 16 bor TagNo,V,RestBuffer2};\ndecode_tag_and_length(<<Class:2,Form:1,31:5,Buffer/binary>>) ->\n    {TagNo,Buffer1} = decode_tag(Buffer, 0),\n    {Length,RestBuffer} = decode_length(Buffer1),\n    <<V:Length/binary,RestBuffer2/binary>> = RestBuffer,\n    {Form,Class bsl 16 bor TagNo,V,RestBuffer2}.\n">>},
 {{ber,decode_tag,2},
  <<"\ndecode_tag(<<0:1,PartialTag:7,Buffer/binary>>, TagAck) ->\n    TagNo = TagAck bsl 7 bor PartialTag,\n    {TagNo,Buffer};\ndecode_tag(<<_:1,PartialTag:7,Buffer/binary>>, TagAck) ->\n    TagAck1 = TagAck bsl 7 bor PartialTag,\n    decode_tag(Buffer, TagAck1).\n">>},
 {{ber,encode_tags,3},
  <<"\nencode_tags([Tag|Trest], BytesSoFar, LenSoFar) ->\n    {Bytes2,L2} = encode_length(LenSoFar),\n    encode_tags(Trest,\n                [Tag,Bytes2|BytesSoFar],\n                LenSoFar + byte_size(Tag) + L2);\nencode_tags([], BytesSoFar, LenSoFar) ->\n    {BytesSoFar,LenSoFar}.\n">>},
 {{ber,encode_tags,2},
  <<"\nencode_tags(TagIn, {BytesSoFar,LenSoFar}) ->\n    encode_tags(TagIn, BytesSoFar, LenSoFar).\n">>},
 {{ber,encode_open_type,2},
  <<"\nencode_open_type(Val, T) when is_list(Val) ->\n    encode_open_type(list_to_binary(Val), T);\nencode_open_type(Val, []) ->\n    {Val,byte_size(Val)};\nencode_open_type(Val, Tag) ->\n    encode_tags(Tag, Val, byte_size(Val)).\n">>},
 {{ber,decode_open_type,2},
  <<"\ndecode_open_type(Tlv, TagIn) ->\n    case match_tags(Tlv, TagIn) of\n        Bin when is_binary(Bin) ->\n            {InnerTlv,_} = ber_decode_nif(Bin),\n            InnerTlv;\n        TlvBytes ->\n            TlvBytes\n    end.\n">>},
 {{ber,decode_open_type_as_binary,2},
  <<"\ndecode_open_type_as_binary(Tlv, TagIn) ->\n    ber_encode(match_tags(Tlv, TagIn)).\n">>},
 {{ber,encode_boolean,2},
  <<"\nencode_boolean(true, TagIn) ->\n    encode_tags(TagIn, [255], 1);\nencode_boolean(false, TagIn) ->\n    encode_tags(TagIn, [0], 1);\nencode_boolean(X, _) ->\n    exit({error,{asn1,{encode_boolean,X}}}).\n">>},
 {{ber,decode_boolean,2},
  <<"\ndecode_boolean(Tlv, TagIn) ->\n    Val = match_tags(Tlv, TagIn),\n    case Val of\n        <<0:8>> ->\n            false;\n        <<_:8>> ->\n            true;\n        _ ->\n            exit({error,{asn1,{decode_boolean,Val}}})\n    end.\n">>},
 {{ber,encode_integer,2},
  <<"\nencode_integer(Val, Tag) when is_integer(Val) ->\n    encode_tags(Tag, encode_integer(Val));\nencode_integer(Val, _Tag) ->\n    exit({error,{asn1,{encode_integer,Val}}}).\n">>},
 {{ber,encode_integer,3},
  <<"\nencode_integer(Val, NamedNumberList, Tag) when is_atom(Val) ->\n    case lists:keyfind(Val, 1, NamedNumberList) of\n        {_,NewVal} ->\n            encode_tags(Tag, encode_integer(NewVal));\n        _ ->\n            exit({error,{asn1,{encode_integer_namednumber,Val}}})\n    end;\nencode_integer(Val, _NamedNumberList, Tag) ->\n    encode_tags(Tag, encode_integer(Val)).\n">>},
 {{ber,encode_integer,1},
  <<"\nencode_integer(Val) ->\n    Bytes =\n        if\n            Val >= 0 ->\n                encode_integer_pos(Val, []);\n            true ->\n                encode_integer_neg(Val, [])\n        end,\n    {Bytes,length(Bytes)}.\n">>},
 {{ber,encode_integer_pos,2},
  <<"\nencode_integer_pos(0, [B|_Acc] = L) when B < 128 ->\n    L;\nencode_integer_pos(N, Acc) ->\n    encode_integer_pos(N bsr 8, [N band 255|Acc]).\n">>},
 {{ber,encode_integer_neg,2},
  <<"\nencode_integer_neg(- 1, [B1|_T] = L) when B1 > 127 ->\n    L;\nencode_integer_neg(N, Acc) ->\n    encode_integer_neg(N bsr 8, [N band 255|Acc]).\n">>},
 {{ber,decode_integer,4},
  <<"\ndecode_integer(Tlv, Range, NamedNumberList, TagIn) ->\n    V = match_tags(Tlv, TagIn),\n    Int = range_check_integer(decode_integer(V), Range),\n    number2name(Int, NamedNumberList).\n">>},
 {{ber,decode_integer,3},
  <<"\ndecode_integer(Tlv, Range, TagIn) ->\n    V = match_tags(Tlv, TagIn),\n    Int = decode_integer(V),\n    range_check_integer(Int, Range).\n">>},
 {{ber,decode_integer,1},
  <<"\ndecode_integer(Bin) ->\n    Len = byte_size(Bin),\n    <<Int:Len/signed-unit:8>> = Bin,\n    Int.\n">>},
 {{ber,range_check_integer,2},
  <<"\nrange_check_integer(Int, Range) ->\n    case Range of\n        [] ->\n            Int;\n        {Lb,Ub} when Int >= Lb, Ub >= Int ->\n            Int;\n        {_,_} ->\n            exit({error,{asn1,{integer_range,Range,Int}}});\n        Int ->\n            Int;\n        SingleValue when is_integer(SingleValue) ->\n            exit({error,{asn1,{integer_range,Range,Int}}});\n        _ ->\n            Int\n    end.\n">>},
 {{ber,number2name,2},
  <<"\nnumber2name(Int, []) ->\n    Int;\nnumber2name(Int, NamedNumberList) ->\n    case lists:keyfind(Int, 2, NamedNumberList) of\n        {NamedVal,_} ->\n            NamedVal;\n        _ ->\n            Int\n    end.\n">>},
 {{ber,encode_enumerated,2},
  <<"\nencode_enumerated(Val, TagIn) when is_integer(Val) ->\n    encode_tags(TagIn, encode_integer(Val)).\n">>},
 {{ber,decode_enumerated,3},
  <<"\ndecode_enumerated(Tlv, NamedNumberList, Tags) ->\n    Buffer = match_tags(Tlv, Tags),\n    decode_enumerated_notag(Buffer, NamedNumberList, Tags).\n">>},
 {{ber,decode_enumerated_notag,3},
  <<"\ndecode_enumerated_notag(Buffer, {NamedNumberList,ExtList}, _Tags) ->\n    IVal = decode_integer(Buffer),\n    case decode_enumerated1(IVal, NamedNumberList) of\n        {asn1_enum,IVal} ->\n            decode_enumerated1(IVal, ExtList);\n        EVal ->\n            EVal\n    end;\ndecode_enumerated_notag(Buffer, NNList, _Tags) ->\n    IVal = decode_integer(Buffer),\n    case decode_enumerated1(IVal, NNList) of\n        {asn1_enum,_} ->\n            exit({error,{asn1,{illegal_enumerated,IVal}}});\n        EVal ->\n            EVal\n    end.\n">>},
 {{ber,decode_enumerated1,2},
  <<"\ndecode_enumerated1(Val, NamedNumberList) ->\n    case lists:keyfind(Val, 2, NamedNumberList) of\n        {NamedVal,_} ->\n            NamedVal;\n        _ ->\n            {asn1_enum,Val}\n    end.\n">>},
 {{ber,encode_bit_string,4},
  <<"\nencode_bit_string(C, Bits, NamedBitList, TagIn) when is_bitstring(Bits) ->\n    PadLen = (8 - bit_size(Bits) band 7) band 7,\n    Compact = {PadLen,<<Bits/bitstring,0:PadLen>>},\n    encode_bin_bit_string(C, Compact, NamedBitList, TagIn);\nencode_bit_string(C, Bin = {Unused,BinBits}, NamedBitList, TagIn)\n    when is_integer(Unused), is_binary(BinBits) ->\n    encode_bin_bit_string(C, Bin, NamedBitList, TagIn);\nencode_bit_string(C, [FirstVal|RestVal], NamedBitList, TagIn)\n    when is_atom(FirstVal) ->\n    encode_bit_string_named(C, [FirstVal|RestVal], NamedBitList, TagIn);\nencode_bit_string(C, [{bit,X}|RestVal], NamedBitList, TagIn) ->\n    encode_bit_string_named(C, [{bit,X}|RestVal], NamedBitList, TagIn);\nencode_bit_string(C, [FirstVal|RestVal], NamedBitList, TagIn)\n    when is_integer(FirstVal) ->\n    encode_bit_string_bits(C, [FirstVal|RestVal], NamedBitList, TagIn);\nencode_bit_string(_C, 0, _NamedBitList, TagIn) ->\n    encode_tags(TagIn, <<0>>, 1);\nencode_bit_string(_C, [], _NamedBitList, TagIn) ->\n    encode_tags(TagIn, <<0>>, 1);\nencode_bit_string(C, IntegerVal, NamedBitList, TagIn)\n    when is_integer(IntegerVal) ->\n    BitListVal = int_to_bitlist(IntegerVal),\n    encode_bit_string_bits(C, BitListVal, NamedBitList, TagIn).\n">>},
 {{ber,int_to_bitlist,1},
  <<"\nint_to_bitlist(0) ->\n    [];\nint_to_bitlist(Int) when is_integer(Int), Int >= 0 ->\n    [Int band 1|int_to_bitlist(Int bsr 1)].\n">>},
 {{ber,encode_bin_bit_string,4},
  <<"\nencode_bin_bit_string(C, {Unused,BinBits}, _NamedBitList, TagIn) ->\n    case get_constraint(C, 'SizeConstraint') of\n        no ->\n            remove_unused_then_dotag(TagIn, Unused, BinBits);\n        {_Min,Max} ->\n            BBLen = byte_size(BinBits) * 8 - Unused,\n            if\n                BBLen > Max ->\n                    exit({error,\n                          {asn1,\n                           {bitstring_length,\n                            {{was,BBLen},{maximum,Max}}}}});\n                true ->\n                    remove_unused_then_dotag(TagIn, Unused, BinBits)\n            end;\n        Size ->\n            case byte_size(BinBits) * 8 - Unused of\n                BBSize when BBSize =< Size ->\n                    remove_unused_then_dotag(TagIn, Unused, BinBits);\n                BBSize ->\n                    exit({error,\n                          {asn1,\n                           {bitstring_length,\n                            {{was,BBSize},{should_be,Size}}}}})\n            end\n    end.\n">>},
 {{ber,remove_unused_then_dotag,3},
  <<"\nremove_unused_then_dotag(TagIn, Unused, BinBits) ->\n    case Unused of\n        0 when byte_size(BinBits) =:= 0 ->\n            encode_tags(TagIn, <<0>>, 1);\n        0 ->\n            Bin = <<Unused,BinBits/binary>>,\n            encode_tags(TagIn, Bin, byte_size(Bin));\n        Num ->\n            N = byte_size(BinBits) - 1,\n            <<BBits:N/binary,LastByte>> = BinBits,\n            encode_tags(TagIn,\n                        [Unused,\n                         binary_to_list(BBits)\n                         ++\n                         [LastByte bsr Num bsl Num]],\n                        1 + byte_size(BinBits))\n    end.\n">>},
 {{ber,encode_bit_string_named,4},
  <<"\nencode_bit_string_named(C, [FirstVal|RestVal], NamedBitList, TagIn) ->\n    ToSetPos = get_all_bitposes([FirstVal|RestVal], NamedBitList, []),\n    Size =\n        case get_constraint(C, 'SizeConstraint') of\n            no ->\n                lists:max(ToSetPos) + 1;\n            {_Min,Max} ->\n                Max;\n            TSize ->\n                TSize\n        end,\n    BitList = make_and_set_list(Size, ToSetPos, 0),\n    {Len,Unused,OctetList} = encode_bitstring(BitList),\n    encode_tags(TagIn, [Unused|OctetList], Len + 1).\n">>},
 {{ber,get_all_bitposes,3},
  <<"\nget_all_bitposes([{bit,ValPos}|Rest], NamedBitList, Ack) ->\n    get_all_bitposes(Rest, NamedBitList, [ValPos|Ack]);\nget_all_bitposes([Val|Rest], NamedBitList, Ack) when is_atom(Val) ->\n    case lists:keyfind(Val, 1, NamedBitList) of\n        {_ValName,ValPos} ->\n            get_all_bitposes(Rest, NamedBitList, [ValPos|Ack]);\n        _ ->\n            exit({error,{asn1,{bitstring_namedbit,Val}}})\n    end;\nget_all_bitposes([], _NamedBitList, Ack) ->\n    lists:sort(Ack).\n">>},
 {{ber,make_and_set_list,3},
  <<"\nmake_and_set_list(0, [], _) ->\n    [];\nmake_and_set_list(0, _, _) ->\n    exit({error,{asn1,bitstring_sizeconstraint}});\nmake_and_set_list(Len, [XPos|SetPos], XPos) ->\n    [1|make_and_set_list(Len - 1, SetPos, XPos + 1)];\nmake_and_set_list(Len, [Pos|SetPos], XPos) ->\n    [0|make_and_set_list(Len - 1, [Pos|SetPos], XPos + 1)];\nmake_and_set_list(Len, [], XPos) ->\n    [0|make_and_set_list(Len - 1, [], XPos + 1)].\n">>},
 {{ber,encode_bit_string_bits,4},
  <<"\nencode_bit_string_bits(C, BitListVal, _NamedBitList, TagIn)\n    when is_list(BitListVal) ->\n    case get_constraint(C, 'SizeConstraint') of\n        no ->\n            {Len,Unused,OctetList} = encode_bitstring(BitListVal),\n            encode_tags(TagIn, [Unused|OctetList], Len + 1);\n        Constr = {Min,_Max} when is_integer(Min) ->\n            encode_constr_bit_str_bits(Constr, BitListVal, TagIn);\n        {Constr = {_,_},[]} ->\n            encode_constr_bit_str_bits(Constr, BitListVal, TagIn);\n        Constr = {{_,_},{_,_}} ->\n            encode_constr_bit_str_bits(Constr, BitListVal, TagIn);\n        Size ->\n            case length(BitListVal) of\n                BitSize when BitSize == Size ->\n                    {Len,Unused,OctetList} =\n                        encode_bitstring(BitListVal),\n                    encode_tags(TagIn, [Unused|OctetList], Len + 1);\n                BitSize when BitSize < Size ->\n                    PaddedList =\n                        pad_bit_list(Size - BitSize, BitListVal),\n                    {Len,Unused,OctetList} =\n                        encode_bitstring(PaddedList),\n                    encode_tags(TagIn, [Unused|OctetList], Len + 1);\n                BitSize ->\n                    exit({error,\n                          {asn1,\n                           {bitstring_length,\n                            {{was,BitSize},{should_be,Size}}}}})\n            end\n    end.\n">>},
 {{ber,encode_constr_bit_str_bits,3},
  <<"\nencode_constr_bit_str_bits({{_Min1,Max1},{Min2,Max2}},\n                           BitListVal,\n                           TagIn) ->\n    BitLen = length(BitListVal),\n    case BitLen of\n        Len when Len > Max2 ->\n            exit({error,\n                  {asn1,\n                   {bitstring_length,{{was,BitLen},{maximum,Max2}}}}});\n        Len when Len > Max1, Len < Min2 ->\n            exit({error,\n                  {asn1,\n                   {bitstring_length,\n                    {{was,BitLen},{not_allowed_interval,Max1,Min2}}}}});\n        _ ->\n            {Len,Unused,OctetList} = encode_bitstring(BitListVal),\n            encode_tags(TagIn, [Unused,OctetList], Len + 1)\n    end;\nencode_constr_bit_str_bits({Min,Max}, BitListVal, TagIn) ->\n    BitLen = length(BitListVal),\n    if\n        BitLen > Max ->\n            exit({error,\n                  {asn1,{bitstring_length,{{was,BitLen},{maximum,Max}}}}});\n        BitLen < Min ->\n            exit({error,\n                  {asn1,{bitstring_length,{{was,BitLen},{minimum,Max}}}}});\n        true ->\n            {Len,Unused,OctetList} = encode_bitstring(BitListVal),\n            encode_tags(TagIn, [Unused,OctetList], Len + 1)\n    end.\n">>},
 {{ber,pad_bit_list,2},
  <<"\npad_bit_list(Size, BitListVal) ->\n    Tail = lists:duplicate(Size, 0),\n    lists:append(BitListVal, Tail).\n">>},
 {{ber,encode_bitstring,1},
  <<"\nencode_bitstring([B8,B7,B6,B5,B4,B3,B2,B1|Rest]) ->\n    Val =\n        B8 bsl 7 bor (B7 bsl 6) bor (B6 bsl 5) bor (B5 bsl 4)\n        bor\n        (B4 bsl 3)\n        bor\n        (B3 bsl 2)\n        bor\n        (B2 bsl 1)\n        bor\n        B1,\n    encode_bitstring(Rest, [Val], 1);\nencode_bitstring(Val) ->\n    {Unused,Octet} = unused_bitlist(Val, 7, 0),\n    {1,Unused,[Octet]}.\n">>},
 {{ber,encode_bitstring,3},
  <<"\nencode_bitstring([B8,B7,B6,B5,B4,B3,B2,B1|Rest], Ack, Len) ->\n    Val =\n        B8 bsl 7 bor (B7 bsl 6) bor (B6 bsl 5) bor (B5 bsl 4)\n        bor\n        (B4 bsl 3)\n        bor\n        (B3 bsl 2)\n        bor\n        (B2 bsl 1)\n        bor\n        B1,\n    encode_bitstring(Rest, [Ack,Val], Len + 1);\nencode_bitstring([], Ack, Len) ->\n    {Len,0,Ack};\nencode_bitstring(Rest, Ack, Len) ->\n    {Unused,Val} = unused_bitlist(Rest, 7, 0),\n    {Len + 1,Unused,[Ack,Val]}.\n">>},
 {{ber,unused_bitlist,3},
  <<"\nunused_bitlist([], Trail, Ack) ->\n    {Trail + 1,Ack};\nunused_bitlist([Bit|Rest], Trail, Ack) ->\n    unused_bitlist(Rest, Trail - 1, Bit bsl Trail bor Ack).\n">>},
 {{ber,decode_compact_bit_string,3},
  <<"\ndecode_compact_bit_string(Buffer, Range, Tags) ->\n    case match_and_collect(Buffer, Tags) of\n        <<0>> ->\n            check_restricted_string({0,<<>>}, 0, Range);\n        <<Unused,Bits/binary>> ->\n            Val = {Unused,Bits},\n            Len = bit_size(Bits) - Unused,\n            check_restricted_string(Val, Len, Range)\n    end.\n">>},
 {{ber,decode_legacy_bit_string,3},
  <<"\ndecode_legacy_bit_string(Buffer, Range, Tags) ->\n    Val =\n        case match_and_collect(Buffer, Tags) of\n            <<0>> ->\n                [];\n            <<Unused,Bits/binary>> ->\n                decode_bitstring2(byte_size(Bits), Unused, Bits)\n        end,\n    check_restricted_string(Val, length(Val), Range).\n">>},
 {{ber,decode_native_bit_string,3},
  <<"\ndecode_native_bit_string(Buffer, Range, Tags) ->\n    case match_and_collect(Buffer, Tags) of\n        <<0>> ->\n            check_restricted_string(<<>>, 0, Range);\n        <<Unused,Bits/binary>> ->\n            Size = bit_size(Bits) - Unused,\n            <<Val:Size/bitstring,_:Unused/bitstring>> = Bits,\n            check_restricted_string(Val, Size, Range)\n    end.\n">>},
 {{ber,decode_named_bit_string,3},
  <<"\ndecode_named_bit_string(Buffer, NamedNumberList, Tags) ->\n    case match_and_collect(Buffer, Tags) of\n        <<0>> ->\n            [];\n        <<Unused,Bits/binary>> ->\n            BitString = decode_bitstring2(byte_size(Bits), Unused, Bits),\n            decode_bitstring_NNL(BitString, NamedNumberList)\n    end.\n">>},
 {{ber,decode_bitstring2,3},
  <<"\ndecode_bitstring2(1,\n                  Unused,\n                  <<B7:1,B6:1,B5:1,B4:1,B3:1,B2:1,B1:1,B0:1,_/binary>>) ->\n    lists:sublist([B7,B6,B5,B4,B3,B2,B1,B0], 8 - Unused);\ndecode_bitstring2(Len,\n                  Unused,\n                  <<B7:1,\n                    B6:1,\n                    B5:1,\n                    B4:1,\n                    B3:1,\n                    B2:1,\n                    B1:1,\n                    B0:1,\n                    Buffer/binary>>) ->\n    [B7,B6,B5,B4,B3,B2,B1,B0|decode_bitstring2(Len - 1, Unused, Buffer)].\n">>},
 {{ber,decode_bitstring_NNL,2},
  <<"\ndecode_bitstring_NNL(BitList, NamedNumberList) ->\n    decode_bitstring_NNL(BitList, NamedNumberList, 0, []).\n">>},
 {{ber,decode_bitstring_NNL,4},
  <<"\ndecode_bitstring_NNL([], _, _No, Result) ->\n    lists:reverse(Result);\ndecode_bitstring_NNL([B|BitList],\n                     [{Name,No}|NamedNumberList],\n                     No,\n                     Result) ->\n    if\n        B =:= 0 ->\n            decode_bitstring_NNL(BitList,\n                                 NamedNumberList,\n                                 No + 1,\n                                 Result);\n        true ->\n            decode_bitstring_NNL(BitList,\n                                 NamedNumberList,\n                                 No + 1,\n                                 [Name|Result])\n    end;\ndecode_bitstring_NNL([1|BitList], NamedNumberList, No, Result) ->\n    decode_bitstring_NNL(BitList,\n                         NamedNumberList,\n                         No + 1,\n                         [{bit,No}|Result]);\ndecode_bitstring_NNL([0|BitList], NamedNumberList, No, Result) ->\n    decode_bitstring_NNL(BitList, NamedNumberList, No + 1, Result).\n">>},
 {{ber,encode_null,2},
  <<"\nencode_null(_Val, TagIn) ->\n    encode_tags(TagIn, [], 0).\n">>},
 {{ber,decode_null,2},
  <<"\ndecode_null(Tlv, Tags) ->\n    Val = match_tags(Tlv, Tags),\n    case Val of\n        <<>> ->\n            'NULL';\n        _ ->\n            exit({error,{asn1,{decode_null,Val}}})\n    end.\n">>},
 {{ber,encode_object_identifier,2},
  <<"\nencode_object_identifier(Val, TagIn) ->\n    encode_tags(TagIn, e_object_identifier(Val)).\n">>},
 {{ber,e_object_identifier,1},
  <<"\ne_object_identifier({'OBJECT IDENTIFIER',V}) ->\n    e_object_identifier(V);\ne_object_identifier(V) when is_tuple(V) ->\n    e_object_identifier(tuple_to_list(V));\ne_object_identifier([E1,E2|Tail]) ->\n    Head = 40 * E1 + E2,\n    {H,Lh} = mk_object_val(Head),\n    {R,Lr} = lists:mapfoldl(fun enc_obj_id_tail/2, 0, Tail),\n    {[H|R],Lh + Lr}.\n">>},
 {{ber,enc_obj_id_tail,2},
  <<"\nenc_obj_id_tail(H, Len) ->\n    {B,L} = mk_object_val(H),\n    {B,Len + L}.\n">>},
 {{ber,mk_object_val,1},
  <<"\nmk_object_val(Val) when Val =< 127 ->\n    {[255 band Val],1};\nmk_object_val(Val) ->\n    mk_object_val(Val bsr 7, [Val band 127], 1).\n">>},
 {{ber,mk_object_val,3},
  <<"\nmk_object_val(0, Ack, Len) ->\n    {Ack,Len};\nmk_object_val(Val, Ack, Len) ->\n    mk_object_val(Val bsr 7, [Val band 127 bor 128|Ack], Len + 1).\n">>},
 {{ber,decode_object_identifier,2},
  <<"\ndecode_object_identifier(Tlv, Tags) ->\n    Val = match_tags(Tlv, Tags),\n    [AddedObjVal|ObjVals] = dec_subidentifiers(Val, 0, []),\n    {Val1,Val2} =\n        if\n            AddedObjVal < 40 ->\n                {0,AddedObjVal};\n            AddedObjVal < 80 ->\n                {1,AddedObjVal - 40};\n            true ->\n                {2,AddedObjVal - 80}\n        end,\n    list_to_tuple([Val1,Val2|ObjVals]).\n">>},
 {{ber,dec_subidentifiers,3},
  <<"\ndec_subidentifiers(<<>>, _Av, Al) ->\n    lists:reverse(Al);\ndec_subidentifiers(<<1:1,H:7,T/binary>>, Av, Al) ->\n    dec_subidentifiers(T, Av bsl 7 + H, Al);\ndec_subidentifiers(<<H,T/binary>>, Av, Al) ->\n    dec_subidentifiers(T, 0, [Av bsl 7 + H|Al]).\n">>},
 {{ber,encode_relative_oid,2},
  <<"\nencode_relative_oid(Val, TagIn) when is_tuple(Val) ->\n    encode_relative_oid(tuple_to_list(Val), TagIn);\nencode_relative_oid(Val, TagIn) ->\n    encode_tags(TagIn, enc_relative_oid(Val)).\n">>},
 {{ber,enc_relative_oid,1},
  <<"\nenc_relative_oid(Tuple) when is_tuple(Tuple) ->\n    enc_relative_oid(tuple_to_list(Tuple));\nenc_relative_oid(Val) ->\n    lists:mapfoldl(fun(X, AccIn) ->\n                          {SO,L} = mk_object_val(X),\n                          {SO,L + AccIn}\n                   end,\n                   0,\n                   Val).\n">>},
 {{ber,decode_relative_oid,2},
  <<"\ndecode_relative_oid(Tlv, Tags) ->\n    Val = match_tags(Tlv, Tags),\n    ObjVals = dec_subidentifiers(Val, 0, []),\n    list_to_tuple(ObjVals).\n">>},
 {{ber,encode_restricted_string,2},
  <<"\nencode_restricted_string(OctetList, TagIn) when is_binary(OctetList) ->\n    encode_tags(TagIn, OctetList, byte_size(OctetList));\nencode_restricted_string(OctetList, TagIn) when is_list(OctetList) ->\n    encode_tags(TagIn, OctetList, length(OctetList)).\n">>},
 {{ber,decode_restricted_string,2},
  <<"\ndecode_restricted_string(Tlv, TagsIn) ->\n    Bin = match_and_collect(Tlv, TagsIn),\n    binary_to_list(Bin).\n">>},
 {{ber,decode_restricted_string,3},
  <<"\ndecode_restricted_string(Tlv, Range, TagsIn) ->\n    Bin = match_and_collect(Tlv, TagsIn),\n    check_restricted_string(binary_to_list(Bin), byte_size(Bin), Range).\n">>},
 {{ber,check_restricted_string,3},
  <<"\ncheck_restricted_string(Val, StrLen, Range) ->\n    case Range of\n        {Lb,Ub} when StrLen >= Lb, Ub >= StrLen ->\n            Val;\n        {{Lb,_Ub},[]} when StrLen >= Lb ->\n            Val;\n        {{Lb,_Ub},_Ext = [Min|_]} when StrLen >= Lb; StrLen >= Min ->\n            Val;\n        {{Lb1,Ub1},{Lb2,Ub2}}\n            when\n                StrLen >= Lb1, StrLen =< Ub1;\n                StrLen =< Ub2, StrLen >= Lb2 ->\n            Val;\n        StrLen ->\n            Val;\n        {_,_} ->\n            exit({error,{asn1,{length,Range,Val}}});\n        _Len when is_integer(_Len) ->\n            exit({error,{asn1,{length,Range,Val}}});\n        _ ->\n            Val\n    end.\n">>},
 {{ber,encode_universal_string,2},
  <<"\nencode_universal_string(Universal, TagIn) ->\n    OctetList = mk_uni_list(Universal),\n    encode_tags(TagIn, OctetList, length(OctetList)).\n">>},
 {{ber,mk_uni_list,1},<<"\nmk_uni_list(In) ->\n    mk_uni_list(In, []).\n">>},
 {{ber,mk_uni_list,2},
  <<"\nmk_uni_list([], List) ->\n    lists:reverse(List);\nmk_uni_list([{A,B,C,D}|T], List) ->\n    mk_uni_list(T, [D,C,B,A|List]);\nmk_uni_list([H|T], List) ->\n    mk_uni_list(T, [H,0,0,0|List]).\n">>},
 {{ber,decode_universal_string,3},
  <<"\ndecode_universal_string(Buffer, Range, Tags) ->\n    Bin = match_and_collect(Buffer, Tags),\n    Val = mk_universal_string(binary_to_list(Bin)),\n    check_restricted_string(Val, length(Val), Range).\n">>},
 {{ber,mk_universal_string,1},
  <<"\nmk_universal_string(In) ->\n    mk_universal_string(In, []).\n">>},
 {{ber,mk_universal_string,2},
  <<"\nmk_universal_string([], Acc) ->\n    lists:reverse(Acc);\nmk_universal_string([0,0,0,D|T], Acc) ->\n    mk_universal_string(T, [D|Acc]);\nmk_universal_string([A,B,C,D|T], Acc) ->\n    mk_universal_string(T, [{A,B,C,D}|Acc]).\n">>},
 {{ber,encode_UTF8_string,2},
  <<"\nencode_UTF8_string(UTF8String, TagIn) when is_binary(UTF8String) ->\n    encode_tags(TagIn, UTF8String, byte_size(UTF8String));\nencode_UTF8_string(UTF8String, TagIn) ->\n    encode_tags(TagIn, UTF8String, length(UTF8String)).\n">>},
 {{ber,decode_UTF8_string,2},
  <<"\ndecode_UTF8_string(Tlv, TagsIn) ->\n    Val = match_tags(Tlv, TagsIn),\n    case Val of\n        [_|_] = PartList ->\n            collect_parts(PartList);\n        Bin ->\n            Bin\n    end.\n">>},
 {{ber,encode_BMP_string,2},
  <<"\nencode_BMP_string(BMPString, TagIn) ->\n    OctetList = mk_BMP_list(BMPString),\n    encode_tags(TagIn, OctetList, length(OctetList)).\n">>},
 {{ber,mk_BMP_list,1},<<"\nmk_BMP_list(In) ->\n    mk_BMP_list(In, []).\n">>},
 {{ber,mk_BMP_list,2},
  <<"\nmk_BMP_list([], List) ->\n    lists:reverse(List);\nmk_BMP_list([{0,0,C,D}|T], List) ->\n    mk_BMP_list(T, [D,C|List]);\nmk_BMP_list([H|T], List) ->\n    mk_BMP_list(T, [H,0|List]).\n">>},
 {{ber,decode_BMP_string,3},
  <<"\ndecode_BMP_string(Buffer, Range, Tags) ->\n    Bin = match_and_collect(Buffer, Tags),\n    Val = mk_BMP_string(binary_to_list(Bin)),\n    check_restricted_string(Val, length(Val), Range).\n">>},
 {{ber,mk_BMP_string,1},
  <<"\nmk_BMP_string(In) ->\n    mk_BMP_string(In, []).\n">>},
 {{ber,mk_BMP_string,2},
  <<"\nmk_BMP_string([], US) ->\n    lists:reverse(US);\nmk_BMP_string([0,B|T], US) ->\n    mk_BMP_string(T, [B|US]);\nmk_BMP_string([C,D|T], US) ->\n    mk_BMP_string(T, [{0,0,C,D}|US]).\n">>},
 {{ber,encode_generalized_time,2},
  <<"\nencode_generalized_time(OctetList, TagIn) ->\n    encode_tags(TagIn, OctetList, length(OctetList)).\n">>},
 {{ber,decode_generalized_time,3},
  <<"\ndecode_generalized_time(Tlv, _Range, Tags) ->\n    Val = match_tags(Tlv, Tags),\n    NewVal =\n        case Val of\n            [_H|_T] = PartList ->\n                collect_parts(PartList);\n            Bin ->\n                Bin\n        end,\n    binary_to_list(NewVal).\n">>},
 {{ber,encode_utc_time,2},
  <<"\nencode_utc_time(OctetList, TagIn) ->\n    encode_tags(TagIn, OctetList, length(OctetList)).\n">>},
 {{ber,decode_utc_time,3},
  <<"\ndecode_utc_time(Tlv, _Range, Tags) ->\n    Val = match_tags(Tlv, Tags),\n    NewVal =\n        case Val of\n            [_|_] = PartList ->\n                collect_parts(PartList);\n            Bin ->\n                Bin\n        end,\n    binary_to_list(NewVal).\n">>},
 {{ber,encode_length,1},
  <<"\nencode_length(L) when L =< 127 ->\n    {[L],1};\nencode_length(L) ->\n    Oct = minimum_octets(L),\n    Len = length(Oct),\n    if\n        Len =< 126 ->\n            {[128 bor Len|Oct],Len + 1};\n        true ->\n            exit({error,{asn1,too_long_length_oct,Len}})\n    end.\n">>},
 {{ber,minimum_octets,1},
  <<"\nminimum_octets(Val) ->\n    minimum_octets(Val, []).\n">>},
 {{ber,minimum_octets,2},
  <<"\nminimum_octets(0, Acc) ->\n    Acc;\nminimum_octets(Val, Acc) ->\n    minimum_octets(Val bsr 8, [Val band 255|Acc]).\n">>},
 {{ber,decode_length,1},
  <<"\ndecode_length(<<1:1,0:7,T/binary>>) ->\n    {indefinite,T};\ndecode_length(<<0:1,Length:7,T/binary>>) ->\n    {Length,T};\ndecode_length(<<1:1,LL:7,Length:LL/unit:8,T/binary>>) ->\n    {Length,T}.\n">>},
 {{ber,dynamicsort_SET_components,1},
  <<"\ndynamicsort_SET_components(ListOfEncCs) ->\n    TagBinL =\n        [ \n         begin\n             Bin = list_to_binary(L),\n             {dynsort_decode_tag(Bin),Bin}\n         end ||\n             L <- ListOfEncCs\n        ],\n    [ \n     E ||\n         {_,E} <- lists:keysort(1, TagBinL)\n    ].\n">>},
 {{ber,dynamicsort_SETOF,1},
  <<"\ndynamicsort_SETOF(ListOfEncVal) ->\n    BinL =\n        lists:map(fun(L) when is_list(L) ->\n                         list_to_binary(L);\n                     (B) ->\n                         B\n                  end,\n                  ListOfEncVal),\n    lists:sort(BinL).\n">>},
 {{ber,dynsort_decode_tag,1},
  <<"\ndynsort_decode_tag(<<Class:2,_Form:1,31:5,Buffer/binary>>) ->\n    TagNum = dynsort_decode_tag(Buffer, 0),\n    {Class,TagNum};\ndynsort_decode_tag(<<Class:2,_Form:1,TagNum:5,_/binary>>) ->\n    {Class,TagNum}.\n">>},
 {{ber,dynsort_decode_tag,2},
  <<"\ndynsort_decode_tag(<<0:1,PartialTag:7,_/binary>>, TagAcc) ->\n    TagAcc bsl 7 bor PartialTag;\ndynsort_decode_tag(<<_:1,PartialTag:7,Buffer/binary>>, TagAcc0) ->\n    TagAcc = TagAcc0 bsl 7 bor PartialTag,\n    dynsort_decode_tag(Buffer, TagAcc).\n">>},
 {{ber,match_and_collect,2},
  <<"\nmatch_and_collect(Tlv, TagsIn) ->\n    Val = match_tags(Tlv, TagsIn),\n    case Val of\n        [_|_] = PartList ->\n            collect_parts(PartList);\n        Bin when is_binary(Bin) ->\n            Bin\n    end.\n">>},
 {{ber,get_constraint,2},
  <<"\nget_constraint(C, Key) ->\n    case lists:keyfind(Key, 1, C) of\n        false ->\n            no;\n        {_,V} ->\n            V\n    end.\n">>},
 {{ber,collect_parts,1},
  <<"\ncollect_parts(TlvList) ->\n    collect_parts(TlvList, []).\n">>},
 {{ber,collect_parts,2},
  <<"\ncollect_parts([{_,L}|Rest], Acc) when is_list(L) ->\n    collect_parts(Rest, [collect_parts(L)|Acc]);\ncollect_parts([{3,<<Unused,Bits/binary>>}|Rest], _Acc) ->\n    collect_parts_bit(Rest, [Bits], Unused);\ncollect_parts([{_T,V}|Rest], Acc) ->\n    collect_parts(Rest, [V|Acc]);\ncollect_parts([], Acc) ->\n    list_to_binary(lists:reverse(Acc)).\n">>},
 {{ber,collect_parts_bit,3},
  <<"\ncollect_parts_bit([{3,<<Unused,Bits/binary>>}|Rest], Acc, Uacc) ->\n    collect_parts_bit(Rest, [Bits|Acc], Unused + Uacc);\ncollect_parts_bit([], Acc, Uacc) ->\n    list_to_binary([Uacc|lists:reverse(Acc)]).\n">>},
 {{check,check_bool,2},
  <<"\ncheck_bool(_Bool, asn1_DEFAULT) ->\n    true;\ncheck_bool(Bool, Bool) when is_boolean(Bool) ->\n    true;\ncheck_bool(_Bool1, Bool2) ->\n    throw({error,Bool2}).\n">>},
 {{check,check_int,3},
  <<"\ncheck_int(_, asn1_DEFAULT, _) ->\n    true;\ncheck_int(Value, Value, _) when is_integer(Value) ->\n    true;\ncheck_int(DefValue, Value, NNL) when is_atom(Value) ->\n    case lists:keyfind(Value, 1, NNL) of\n        {_,DefValue} ->\n            true;\n        _ ->\n            throw({error,DefValue})\n    end;\ncheck_int(DefaultValue, _Value, _) ->\n    throw({error,DefaultValue}).\n">>},
 {{check,check_bitstring,3},
  <<"\ncheck_bitstring(_, asn1_DEFAULT, _) ->\n    true;\ncheck_bitstring(V, V, _) ->\n    true;\ncheck_bitstring(L = [H|T], Int, _) when is_integer(Int), is_integer(H) ->\n    case bit_list_to_int(L, length(T)) of\n        Int ->\n            true;\n        _ ->\n            throw({error,L,Int})\n    end;\ncheck_bitstring(Int, Val, NBL) when is_integer(Int), is_list(Val) ->\n    BL = int_to_bit_list(Int, [], length(Val)),\n    check_bitstring(BL, Val, NBL);\ncheck_bitstring(L1 = [H1|_T1], L2 = [H2|_T2], NBL = [_H|_T])\n    when is_integer(H1), is_integer(H2) ->\n    L2new = remove_trailing_zeros(L2),\n    check_bitstring(L1, L2new, NBL);\ncheck_bitstring(L1 = [H1|_T1], L2 = [H2|_T2], NBL)\n    when is_integer(H1), is_atom(H2) ->\n    L3 = bit_list_to_nbl(L1, NBL, 0, []),\n    check_bitstring(L3, L2, NBL);\ncheck_bitstring(L1 = [H1|T1], L2 = [H2|_T2], _)\n    when is_atom(H1), is_atom(H2), length(L1) =:= length(L2) ->\n    case lists:member(H1, L2) of\n        true ->\n            check_bitstring1(T1, L2);\n        false ->\n            throw({error,L2})\n    end;\ncheck_bitstring(L1 = [H1|_T1], L2 = [H2|_T2], NBL)\n    when is_atom(H1), is_integer(H2) ->\n    L3 = bit_list_to_nbl(L2, NBL, 0, []),\n    check_bitstring(L1, L3, NBL);\ncheck_bitstring(DefVal, CBS = {_,_}, NBL) ->\n    NewVal = cbs_to_bit_list(CBS),\n    check_bitstring(DefVal, NewVal, NBL);\ncheck_bitstring(DV, V, _) ->\n    throw({error,DV,V}).\n">>},
 {{check,bit_list_to_int,2},
  <<"\nbit_list_to_int([0|Bs], ShL) ->\n    bit_list_to_int(Bs, ShL - 1) + 0;\nbit_list_to_int([1|Bs], ShL) ->\n    bit_list_to_int(Bs, ShL - 1) + (1 bsl ShL);\nbit_list_to_int([], _) ->\n    0.\n">>},
 {{check,int_to_bit_list,3},
  <<"\nint_to_bit_list(0, Acc, 0) ->\n    Acc;\nint_to_bit_list(Int, Acc, Len) ->\n    int_to_bit_list(Int bsr 1, [Int band 1|Acc], Len - 1).\n">>},
 {{check,bit_list_to_nbl,4},
  <<"\nbit_list_to_nbl([0|T], NBL, Pos, Acc) ->\n    bit_list_to_nbl(T, NBL, Pos + 1, Acc);\nbit_list_to_nbl([1|T], NBL, Pos, Acc) ->\n    case lists:keyfind(Pos, 2, NBL) of\n        {N,_} ->\n            bit_list_to_nbl(T, NBL, Pos + 1, [N|Acc]);\n        _ ->\n            throw({error,{no,named,element,at,pos,Pos}})\n    end;\nbit_list_to_nbl([], _, _, Acc) ->\n    Acc.\n">>},
 {{check,remove_trailing_zeros,1},
  <<"\nremove_trailing_zeros(L2) ->\n    remove_trailing_zeros1(lists:reverse(L2)).\n">>},
 {{check,remove_trailing_zeros1,1},
  <<"\nremove_trailing_zeros1(L) ->\n    lists:reverse(lists:dropwhile(fun(0) ->\n                                         true;\n                                     (_) ->\n                                         false\n                                  end,\n                                  L)).\n">>},
 {{check,check_bitstring1,2},
  <<"\ncheck_bitstring1([H|T], NBL) ->\n    case lists:member(H, NBL) of\n        true ->\n            check_bitstring1(T, NBL);\n        V ->\n            throw({error,V})\n    end;\ncheck_bitstring1([], _) ->\n    true.\n">>},
 {{check,cbs_to_bit_list,1},
  <<"\ncbs_to_bit_list({Unused,\n                 <<B7:1,B6:1,B5:1,B4:1,B3:1,B2:1,B1:1,B0:1,Rest/binary>>})\n    when byte_size(Rest) >= 1 ->\n    [B7,B6,B5,B4,B3,B2,B1,B0|cbs_to_bit_list({Unused,Rest})];\ncbs_to_bit_list({0,<<B7:1,B6:1,B5:1,B4:1,B3:1,B2:1,B1:1,B0:1>>}) ->\n    [B7,B6,B5,B4,B3,B2,B1,B0];\ncbs_to_bit_list({Unused,Bin}) when byte_size(Bin) =:= 1 ->\n    Used = 8 - Unused,\n    <<Int:Used,_:Unused>> = Bin,\n    int_to_bit_list(Int, [], Used).\n">>},
 {{check,check_octetstring,2},
  <<"\ncheck_octetstring(_, asn1_DEFAULT) ->\n    true;\ncheck_octetstring(L, L) ->\n    true;\ncheck_octetstring(L, Int) when is_list(L), is_integer(Int) ->\n    case integer_to_octetlist(Int) of\n        L ->\n            true;\n        V ->\n            throw({error,V})\n    end;\ncheck_octetstring(_, V) ->\n    throw({error,V}).\n">>},
 {{check,integer_to_octetlist,1},
  <<"\ninteger_to_octetlist(Int) ->\n    integer_to_octetlist(Int, []).\n">>},
 {{check,integer_to_octetlist,2},
  <<"\ninteger_to_octetlist(0, Acc) ->\n    Acc;\ninteger_to_octetlist(Int, Acc) ->\n    integer_to_octetlist(Int bsr 8, [Int band 255|Acc]).\n">>},
 {{check,check_null,2},
  <<"\ncheck_null(_, asn1_DEFAULT) ->\n    true;\ncheck_null('NULL', 'NULL') ->\n    true;\ncheck_null(_, V) ->\n    throw({error,V}).\n">>},
 {{check,check_objectidentifier,2},
  <<"\ncheck_objectidentifier(_, asn1_DEFAULT) ->\n    true;\ncheck_objectidentifier(OI, OI) ->\n    true;\ncheck_objectidentifier(DOI, OI) when is_tuple(DOI), is_tuple(OI) ->\n    check_objectidentifier1(tuple_to_list(DOI), tuple_to_list(OI));\ncheck_objectidentifier(_, OI) ->\n    throw({error,OI}).\n">>},
 {{check,check_objectidentifier1,2},
  <<"\ncheck_objectidentifier1([V|Rest1], [V|Rest2]) ->\n    check_objectidentifier1(Rest1, Rest2, V);\ncheck_objectidentifier1([V1|Rest1], [V2|Rest2]) ->\n    case reserved_objectid(V2, []) of\n        V1 ->\n            check_objectidentifier1(Rest1, Rest2, [V1]);\n        V ->\n            throw({error,V})\n    end.\n">>},
 {{check,check_objectidentifier1,3},
  <<"\ncheck_objectidentifier1([V|Rest1], [V|Rest2], Above) ->\n    check_objectidentifier1(Rest1, Rest2, [V|Above]);\ncheck_objectidentifier1([V1|Rest1], [V2|Rest2], Above) ->\n    case reserved_objectid(V2, Above) of\n        V1 ->\n            check_objectidentifier1(Rest1, Rest2, [V1|Above]);\n        V ->\n            throw({error,V})\n    end;\ncheck_objectidentifier1([], [], _) ->\n    true;\ncheck_objectidentifier1(_, V, _) ->\n    throw({error,object,identifier,V}).\n">>},
 {{check,reserved_objectid,2},
  <<"\nreserved_objectid('itu-t', []) ->\n    0;\nreserved_objectid(ccitt, []) ->\n    0;\nreserved_objectid(recommendation, [0]) ->\n    0;\nreserved_objectid(question, [0]) ->\n    1;\nreserved_objectid(administration, [0]) ->\n    2;\nreserved_objectid('network-operator', [0]) ->\n    3;\nreserved_objectid('identified-organization', [0]) ->\n    4;\nreserved_objectid(iso, []) ->\n    1;\nreserved_objectid(standard, [1]) ->\n    0;\nreserved_objectid('member-body', [1]) ->\n    2;\nreserved_objectid('identified-organization', [1]) ->\n    3;\nreserved_objectid('joint-iso-itu-t', []) ->\n    2;\nreserved_objectid('joint-iso-ccitt', []) ->\n    2;\nreserved_objectid(_, _) ->\n    false.\n">>},
 {{check,check_objectdescriptor,2},
  <<"\ncheck_objectdescriptor(_, asn1_DEFAULT) ->\n    true;\ncheck_objectdescriptor(OD, OD) ->\n    true;\ncheck_objectdescriptor(OD, OD) ->\n    throw({error,{not_implemented_yet,check_objectdescriptor}}).\n">>},
 {{check,check_real,2},
  <<"\ncheck_real(_, asn1_DEFAULT) ->\n    true;\ncheck_real(R, R) ->\n    true;\ncheck_real(_, _) ->\n    throw({error,{not_implemented_yet,check_real}}).\n">>},
 {{check,check_enum,3},
  <<"\ncheck_enum(_, asn1_DEFAULT, _) ->\n    true;\ncheck_enum(Val, Val, _) ->\n    true;\ncheck_enum(Int, Atom, Enumerations) when is_integer(Int), is_atom(Atom) ->\n    case lists:keyfind(Atom, 1, Enumerations) of\n        {_,Int} ->\n            true;\n        _ ->\n            throw({error,{enumerated,Int,Atom}})\n    end;\ncheck_enum(DefVal, Val, _) ->\n    throw({error,{enumerated,DefVal,Val}}).\n">>},
 {{check,check_restrictedstring,2},
  <<"\ncheck_restrictedstring(_, asn1_DEFAULT) ->\n    true;\ncheck_restrictedstring(Val, Val) ->\n    true;\ncheck_restrictedstring([V|Rest1], [V|Rest2]) ->\n    check_restrictedstring(Rest1, Rest2);\ncheck_restrictedstring([V1|Rest1], [V2|Rest2]) ->\n    check_restrictedstring(V1, V2),\n    check_restrictedstring(Rest1, Rest2);\ncheck_restrictedstring({V1,V2}, [V1,V2]) ->\n    true;\ncheck_restrictedstring([V1,V2], {V1,V2}) ->\n    true;\ncheck_restrictedstring({V1,V2,V3,V4}, [V1,V2,V3,V4]) ->\n    true;\ncheck_restrictedstring([V1,V2,V3,V4], {V1,V2,V3,V4}) ->\n    true;\ncheck_restrictedstring(V1, V2) when is_list(V1), is_tuple(V2) ->\n    check_restrictedstring(V1, tuple_to_list(V2));\ncheck_restrictedstring(V1, V2) ->\n    throw({error,{restricted,string,V1,V2}}).\n">>},
 {{ext,transform_to_EXTERNAL1990,1},
  <<"\ntransform_to_EXTERNAL1990({_,_,_,_} = Val) ->\n    transform_to_EXTERNAL1990(tuple_to_list(Val), []);\ntransform_to_EXTERNAL1990(Val) when is_tuple(Val) ->\n    Val.\n">>},
 {{ext,transform_to_EXTERNAL1990,2},
  <<"\ntransform_to_EXTERNAL1990(['EXTERNAL'|Rest], Acc) ->\n    transform_to_EXTERNAL1990(Rest, ['EXTERNAL'|Acc]);\ntransform_to_EXTERNAL1990([{syntax,Syntax}|Rest], Acc) ->\n    transform_to_EXTERNAL1990(Rest, [asn1_NOVALUE,Syntax|Acc]);\ntransform_to_EXTERNAL1990([{'presentation-context-id',PCid}|Rest], Acc) ->\n    transform_to_EXTERNAL1990(Rest, [PCid,asn1_NOVALUE|Acc]);\ntransform_to_EXTERNAL1990([{'context-negotiation',Context_negot}|Rest],\n                          Acc) ->\n    {_,Presentation_Cid,Transfer_syntax} = Context_negot,\n    transform_to_EXTERNAL1990(Rest,\n                              [Presentation_Cid,Transfer_syntax|Acc]);\ntransform_to_EXTERNAL1990([asn1_NOVALUE|Rest], Acc) ->\n    transform_to_EXTERNAL1990(Rest, [asn1_NOVALUE|Acc]);\ntransform_to_EXTERNAL1990([Data_val_desc,Data_value], Acc)\n    when is_list(Data_value) ->\n    list_to_tuple(lists:reverse([{'octet-aligned',Data_value},\n                                 Data_val_desc|\n                                 Acc]));\ntransform_to_EXTERNAL1990([Data_val_desc,Data_value], Acc)\n    when is_binary(Data_value) ->\n    list_to_tuple(lists:reverse([{'single-ASN1-type',Data_value},\n                                 Data_val_desc|\n                                 Acc]));\ntransform_to_EXTERNAL1990([Data_value], Acc)\n    when is_list(Data_value); is_binary(Data_value) ->\n    list_to_tuple(lists:reverse([{'octet-aligned',Data_value}|Acc])).\n">>},
 {{ext,transform_to_EXTERNAL1994,1},
  <<"\ntransform_to_EXTERNAL1994({'EXTERNAL',DRef,IndRef,Data_v_desc,Encoding} =\n                              V) ->\n    Identification =\n        case {DRef,IndRef} of\n            {DRef,asn1_NOVALUE} ->\n                {syntax,DRef};\n            {asn1_NOVALUE,IndRef} ->\n                {'presentation-context-id',IndRef};\n            _ ->\n                {'context-negotiation',\n                 {'EXTERNAL_identification_context-negotiation',\n                  IndRef,\n                  DRef}}\n        end,\n    case Encoding of\n        {'octet-aligned',Val} when is_list(Val); is_binary(Val) ->\n            {'EXTERNAL',Identification,Data_v_desc,Val};\n        _ ->\n            V\n    end.\n">>},
 {{per,setext,1},
  <<"\nsetext(false) ->\n    [0];\nsetext(true) ->\n    [1].\n">>},
 {{per,fixextensions,2},
  <<"\nfixextensions({ext,ExtPos,ExtNum}, Val) ->\n    case fixextensions(ExtPos, ExtNum + ExtPos, Val, 0) of\n        0 ->\n            [];\n        ExtBits ->\n            [encode_small_length(ExtNum)|\n             pre_complete_bits(ExtNum, ExtBits)]\n    end.\n">>},
 {{per,fixextensions,4},
  <<"\nfixextensions(Pos, MaxPos, _, Acc) when Pos >= MaxPos ->\n    Acc;\nfixextensions(Pos, ExtPos, Val, Acc) ->\n    Bit =\n        case catch element(Pos + 1, Val) of\n            asn1_NOVALUE ->\n                0;\n            asn1_NOEXTVALUE ->\n                0;\n            {'EXIT',_} ->\n                0;\n            _ ->\n                1\n        end,\n    fixextensions(Pos + 1, ExtPos, Val, Acc bsl 1 + Bit).\n">>},
 {{per,skipextensions,3},
  <<"\nskipextensions(Bytes0, Nr, ExtensionBitstr)\n    when is_bitstring(ExtensionBitstr) ->\n    Prev = Nr - 1,\n    case ExtensionBitstr of\n        <<_:Prev,1:1,_/bitstring>> ->\n            {Len,Bytes1} = decode_length(Bytes0),\n            <<_:Len/binary,Bytes2/bitstring>> = Bytes1,\n            skipextensions(Bytes2, Nr + 1, ExtensionBitstr);\n        <<_:Prev,0:1,_/bitstring>> ->\n            skipextensions(Bytes0, Nr + 1, ExtensionBitstr);\n        _ ->\n            Bytes0\n    end.\n">>},
 {{per,getchoice,3},
  <<"\ngetchoice(Bytes, 1, 0) ->\n    {0,Bytes};\ngetchoice(Bytes, _, 1) ->\n    decode_small_number(Bytes);\ngetchoice(Bytes, NumChoices, 0) ->\n    decode_constrained_number(Bytes, {0,NumChoices - 1}).\n">>},
 {{per,getbit,1},
  <<"\ngetbit(Buffer) ->\n    <<B:1,Rest/bitstring>> = Buffer,\n    {B,Rest}.\n">>},
 {{per,getbits,2},
  <<"\ngetbits(Buffer, Num) when is_bitstring(Buffer) ->\n    <<Bs:Num,Rest/bitstring>> = Buffer,\n    {Bs,Rest}.\n">>},
 {{per,align,1},
  <<"\nalign(Bin) when is_binary(Bin) ->\n    Bin;\nalign(BitStr) when is_bitstring(BitStr) ->\n    AlignBits = bit_size(BitStr) rem 8,\n    <<_:AlignBits,Rest/binary>> = BitStr,\n    Rest.\n">>},
 {{per,getoctets,2},
  <<"\ngetoctets(Buffer, Num) when is_binary(Buffer) ->\n    <<Val:Num/integer-unit:8,RestBin/binary>> = Buffer,\n    {Val,RestBin};\ngetoctets(Buffer, Num) when is_bitstring(Buffer) ->\n    AlignBits = bit_size(Buffer) rem 8,\n    <<_:AlignBits,Val:Num/integer-unit:8,RestBin/binary>> = Buffer,\n    {Val,RestBin}.\n">>},
 {{per,getoctets_as_bin,2},
  <<"\ngetoctets_as_bin(Bin, Num) when is_binary(Bin) ->\n    <<Octets:Num/binary,RestBin/binary>> = Bin,\n    {Octets,RestBin};\ngetoctets_as_bin(Bin, Num) when is_bitstring(Bin) ->\n    AlignBits = bit_size(Bin) rem 8,\n    <<_:AlignBits,Val:Num/binary,RestBin/binary>> = Bin,\n    {Val,RestBin}.\n">>},
 {{per,set_choice,3},
  <<"\nset_choice(Alt, {L1,L2}, {Len1,_Len2}) ->\n    case set_choice_tag(Alt, L1) of\n        N when is_integer(N), Len1 > 1 ->\n            [0,encode_constrained_number({0,Len1 - 1}, N)];\n        N when is_integer(N) ->\n            [0];\n        false ->\n            [1,\n             case set_choice_tag(Alt, L2) of\n                 N2 when is_integer(N2) ->\n                     encode_small_number(N2);\n                 false ->\n                     unknown_choice_alt\n             end]\n    end;\nset_choice(Alt, L, Len) ->\n    case set_choice_tag(Alt, L) of\n        N when is_integer(N), Len > 1 ->\n            encode_constrained_number({0,Len - 1}, N);\n        N when is_integer(N) ->\n            [];\n        false ->\n            [unknown_choice_alt]\n    end.\n">>},
 {{per,set_choice_tag,2},
  <<"\nset_choice_tag(Alt, Choices) ->\n    set_choice_tag(Alt, Choices, 0).\n">>},
 {{per,set_choice_tag,3},
  <<"\nset_choice_tag(Alt, [Alt|_Rest], Tag) ->\n    Tag;\nset_choice_tag(Alt, [_H|Rest], Tag) ->\n    set_choice_tag(Alt, Rest, Tag + 1);\nset_choice_tag(_Alt, [], _Tag) ->\n    false.\n">>},
 {{per,encode_open_type,1},
  <<"\nencode_open_type(Val) when is_list(Val) ->\n    Bin = list_to_binary(Val),\n    case byte_size(Bin) of\n        Size when Size > 255 ->\n            [encode_length(Size),21,<<Size:16>>,Bin];\n        Size ->\n            [encode_length(Size),20,Size,Bin]\n    end;\nencode_open_type(Val) when is_binary(Val) ->\n    case byte_size(Val) of\n        Size when Size > 255 ->\n            [encode_length(Size),21,<<Size:16>>,Val];\n        Size ->\n            [encode_length(Size),20,Size,Val]\n    end.\n">>},
 {{per,encode_integer,2},
  <<"\nencode_integer([{Rc,_Ec}], Val) when is_tuple(Rc) ->\n    try\n        [0|encode_integer([Rc], Val)]\n    catch\n        _:{error,{asn1,_}} ->\n            [1|encode_unconstrained_number(Val)]\n    end;\nencode_integer([], Val) ->\n    encode_unconstrained_number(Val);\nencode_integer([{'SingleValue',V}], V) ->\n    [];\nencode_integer([{'ValueRange',{Lb,Ub} = VR,Range,PreEnc}], Val)\n    when Val >= Lb, Ub >= Val ->\n    encode_constrained_number(VR, Range, PreEnc, Val);\nencode_integer([{'ValueRange',{Lb,'MAX'}}], Val) ->\n    encode_semi_constrained_number(Lb, Val);\nencode_integer([{'ValueRange',{'MIN',_}}], Val) ->\n    encode_unconstrained_number(Val);\nencode_integer([{'ValueRange',VR = {_Lb,_Ub}}], Val) ->\n    encode_constrained_number(VR, Val);\nencode_integer(_, Val) ->\n    exit({error,{asn1,{illegal_value,Val}}}).\n">>},
 {{per,encode_small_number,1},
  <<"\nencode_small_number(Val) when Val < 64 ->\n    [10,7,Val];\nencode_small_number(Val) ->\n    [1|encode_semi_constrained_number(0, Val)].\n">>},
 {{per,decode_small_number,1},
  <<"\ndecode_small_number(Bytes) ->\n    {Bit,Bytes2} = getbit(Bytes),\n    case Bit of\n        0 ->\n            getbits(Bytes2, 6);\n        1 ->\n            decode_semi_constrained_number(Bytes2)\n    end.\n">>},
 {{per,encode_semi_constrained_number,2},
  <<"\nencode_semi_constrained_number(Lb, Val) ->\n    Val2 = Val - Lb,\n    Oct = eint_positive(Val2),\n    Len = length(Oct),\n    if\n        Len < 128 ->\n            [20,Len + 1,Len|Oct];\n        Len < 256 ->\n            [encode_length(Len),20,Len|Oct];\n        true ->\n            [encode_length(Len),21,<<Len:16>>|Oct]\n    end.\n">>},
 {{per,decode_semi_constrained_number,1},
  <<"\ndecode_semi_constrained_number(Bytes) ->\n    {Len,Bytes2} = decode_length(Bytes),\n    getoctets(Bytes2, Len).\n">>},
 {{per,encode_constrained_number,4},
  <<"\nencode_constrained_number({Lb,_Ub}, _Range, {bits,N}, Val) ->\n    Val2 = Val - Lb,\n    [10,N,Val2];\nencode_constrained_number({Lb,_Ub}, _Range, {octets,N}, Val)\n    when N < 256 ->\n    Val2 = Val - Lb,\n    [20,N,Val2];\nencode_constrained_number({Lb,_Ub}, _Range, {octets,N}, Val) ->\n    Val2 = Val - Lb,\n    [21,<<N:16>>,Val2];\nencode_constrained_number({Lb,_Ub}, Range, _, Val) ->\n    Val2 = Val - Lb,\n    if\n        Range =< 16777216 ->\n            Octs = eint_positive(Val2),\n            L = length(Octs),\n            [encode_length({1,3}, L),[20,L,Octs]];\n        Range =< 4294967296 ->\n            Octs = eint_positive(Val2),\n            L = length(Octs),\n            [encode_length({1,4}, L),[20,L,Octs]];\n        Range =< 1099511627776 ->\n            Octs = eint_positive(Val2),\n            L = length(Octs),\n            [encode_length({1,5}, L),[20,L,Octs]];\n        true ->\n            exit({not_supported,{integer_range,Range}})\n    end.\n">>},
 {{per,encode_constrained_number,2},
  <<"\nencode_constrained_number({Lb,Ub}, Val) when Val >= Lb, Ub >= Val ->\n    Range = Ub - Lb + 1,\n    Val2 = Val - Lb,\n    if\n        Range == 1 ->\n            [];\n        Range == 2 ->\n            [Val2];\n        Range =< 4 ->\n            [10,2,Val2];\n        Range =< 8 ->\n            [10,3,Val2];\n        Range =< 16 ->\n            [10,4,Val2];\n        Range =< 32 ->\n            [10,5,Val2];\n        Range =< 64 ->\n            [10,6,Val2];\n        Range =< 128 ->\n            [10,7,Val2];\n        Range =< 255 ->\n            [10,8,Val2];\n        Range =< 256 ->\n            [20,1,Val2];\n        Range =< 65536 ->\n            [20,2,<<Val2:16>>];\n        Range =< 1 bsl 255 * 8 ->\n            Octs = binary:encode_unsigned(Val2),\n            RangeOcts = binary:encode_unsigned(Range - 1),\n            OctsLen = byte_size(Octs),\n            RangeOctsLen = byte_size(RangeOcts),\n            LengthBitsNeeded = minimum_bits(RangeOctsLen - 1),\n            [10,LengthBitsNeeded,OctsLen - 1,20,OctsLen,Octs];\n        true ->\n            exit({not_supported,{integer_range,Range}})\n    end;\nencode_constrained_number({_,_}, Val) ->\n    exit({error,{asn1,{illegal_value,Val}}}).\n">>},
 {{per,decode_constrained_number,2},
  <<"\ndecode_constrained_number(Buffer, VR = {Lb,Ub}) ->\n    Range = Ub - Lb + 1,\n    decode_constrained_number(Buffer, VR, Range).\n">>},
 {{per,decode_constrained_number,3},
  <<"\ndecode_constrained_number(Buffer, {Lb,_Ub}, Range) ->\n    {Val,Remain} =\n        if\n            Range == 1 ->\n                {0,Buffer};\n            Range == 2 ->\n                getbits(Buffer, 1);\n            Range =< 4 ->\n                getbits(Buffer, 2);\n            Range =< 8 ->\n                getbits(Buffer, 3);\n            Range =< 16 ->\n                getbits(Buffer, 4);\n            Range =< 32 ->\n                getbits(Buffer, 5);\n            Range =< 64 ->\n                getbits(Buffer, 6);\n            Range =< 128 ->\n                getbits(Buffer, 7);\n            Range =< 255 ->\n                getbits(Buffer, 8);\n            Range =< 256 ->\n                getoctets(Buffer, 1);\n            Range =< 65536 ->\n                getoctets(Buffer, 2);\n            Range =< 1 bsl 255 * 8 ->\n                OList =\n                    binary:bin_to_list(binary:encode_unsigned(Range - 1)),\n                RangeOctLen = length(OList),\n                {Len,Bytes} = decode_length(Buffer, {1,RangeOctLen}),\n                {Octs,RestBytes} = getoctets_as_bin(Bytes, Len),\n                {binary:decode_unsigned(Octs),RestBytes};\n            true ->\n                exit({not_supported,{integer_range,Range}})\n        end,\n    {Val + Lb,Remain}.\n">>},
 {{per,minimum_bits,1},
  <<"\nminimum_bits(N) when N < 4 ->\n    2;\nminimum_bits(N) when N < 8 ->\n    3;\nminimum_bits(N) when N < 16 ->\n    4;\nminimum_bits(N) when N < 32 ->\n    5;\nminimum_bits(N) when N < 64 ->\n    6;\nminimum_bits(N) when N < 128 ->\n    7;\nminimum_bits(_N) ->\n    8.\n">>},
 {{per,encode_unconstrained_number,1},
  <<"\nencode_unconstrained_number(Val) ->\n    Oct =\n        if\n            Val >= 0 ->\n                eint(Val, []);\n            true ->\n                enint(Val, [])\n        end,\n    Len = length(Oct),\n    if\n        Len < 128 ->\n            [20,Len + 1,Len|Oct];\n        Len < 256 ->\n            [20,Len + 2,<<2:2,Len:14>>|Oct];\n        true ->\n            [encode_length(Len),21,<<Len:16>>|Oct]\n    end.\n">>},
 {{per,eint_positive,1},
  <<"\neint_positive(Val) ->\n    case eint(Val, []) of\n        [0,B1|T] ->\n            [B1|T];\n        T ->\n            T\n    end.\n">>},
 {{per,eint,2},
  <<"\neint(0, [B|Acc]) when B < 128 ->\n    [B|Acc];\neint(N, Acc) ->\n    eint(N bsr 8, [N band 255|Acc]).\n">>},
 {{per,enint,2},
  <<"\nenint(- 1, [B1|T]) when B1 > 127 ->\n    [B1|T];\nenint(N, Acc) ->\n    enint(N bsr 8, [N band 255|Acc]).\n">>},
 {{per,encode_length,1},
  <<"\nencode_length(Len) ->\n    if\n        Len < 128 ->\n            [20,1,Len];\n        Len < 16384 ->\n            <<20,2,2:2,Len:14>>;\n        true ->\n            exit({error,{asn1,{encode_length,{nyi,above_16k}}}})\n    end.\n">>},
 {{per,encode_length,2},
  <<"\nencode_length(undefined, Len) ->\n    encode_length(Len);\nencode_length({0,'MAX'}, Len) ->\n    encode_length(undefined, Len);\nencode_length({Lb,Ub} = Vr, Len) when Ub =< 65535, Lb >= 0 ->\n    encode_constrained_number(Vr, Len);\nencode_length({Lb,_Ub}, Len) when is_integer(Lb), Lb >= 0 ->\n    encode_length(Len);\nencode_length({{Lb,Ub} = Vr,Ext}, Len)\n    when Ub =< 65535, Lb >= 0, Len =< Ub, is_list(Ext) ->\n    [0|encode_constrained_number(Vr, Len)];\nencode_length({{Lb,_},Ext}, Len) when is_list(Ext) ->\n    [1|encode_semi_constrained_number(Lb, Len)];\nencode_length(SingleValue, _Len) when is_integer(SingleValue) ->\n    [].\n">>},
 {{per,encode_small_length,1},
  <<"\nencode_small_length(Len) when Len =< 64 ->\n    [10,7,Len - 1];\nencode_small_length(Len) ->\n    [1,encode_length(Len)].\n">>},
 {{per,decode_length,1},
  <<"\ndecode_length(Buffer) ->\n    case align(Buffer) of\n        <<0:1,Oct:7,Rest/binary>> ->\n            {Oct,Rest};\n        <<2:2,Val:14,Rest/binary>> ->\n            {Val,Rest};\n        <<3:2,_Val:14,_Rest/binary>> ->\n            exit({error,{asn1,{decode_length,{nyi,above_16k}}}})\n    end.\n">>},
 {{per,decode_length,2},
  <<"\ndecode_length(Buffer, {Lb,Ub}) when Ub =< 65535, Lb >= 0 ->\n    decode_constrained_number(Buffer, {Lb,Ub});\ndecode_length(Buffer, {Lb,_Ub}) when is_integer(Lb), Lb >= 0 ->\n    decode_length(Buffer).\n">>},
 {{per,encode_bit_string,3},
  <<"\nencode_bit_string(C, Bits, NamedBitList) when is_bitstring(Bits) ->\n    PadLen = (8 - bit_size(Bits) band 7) band 7,\n    Compact = {PadLen,<<Bits/bitstring,0:PadLen>>},\n    encode_bin_bit_string(C, Compact, NamedBitList);\nencode_bit_string(C, {Unused,BinBits} = Bin, NamedBitList)\n    when is_integer(Unused), is_binary(BinBits) ->\n    encode_bin_bit_string(C, Bin, NamedBitList);\nencode_bit_string(C, LoNB = [FirstVal|_RestVal], NamedBitList)\n    when is_atom(FirstVal) ->\n    ToSetPos = get_all_bitposes(LoNB, NamedBitList, []),\n    BitList = make_and_set_list(ToSetPos, 0),\n    encode_bit_string(C, BitList, NamedBitList);\nencode_bit_string(C, BL = [{bit,_}|_RestVal], NamedBitList) ->\n    ToSetPos = get_all_bitposes(BL, NamedBitList, []),\n    BitList = make_and_set_list(ToSetPos, 0),\n    encode_bit_string(C, BitList, NamedBitList);\nencode_bit_string(Int, BitListValue, _)\n    when is_list(BitListValue), is_integer(Int), Int =< 16 ->\n    [40,Int,length(BitListValue),BitListValue];\nencode_bit_string(Int, BitListValue, _)\n    when is_list(BitListValue), is_integer(Int), Int =< 255 ->\n    [2,40,Int,length(BitListValue),BitListValue];\nencode_bit_string(Int, BitListValue, _)\n    when is_list(BitListValue), is_integer(Int), Int < 65536 ->\n    {Code,DesiredLength,Length} =\n        case length(BitListValue) of\n            B1 when B1 > Int ->\n                exit({error,\n                      {'BIT_STRING_length_greater_than_SIZE',\n                       Int,\n                       BitListValue}});\n            B1 when B1 =< 255, Int =< 255 ->\n                {40,Int,B1};\n            B1 when B1 =< 255 ->\n                {42,<<Int:16>>,B1};\n            B1 ->\n                {43,<<Int:16>>,<<B1:16>>}\n        end,\n    [2,Code,DesiredLength,Length,BitListValue];\nencode_bit_string(no, BitListValue, []) when is_list(BitListValue) ->\n    [encode_length(length(BitListValue)),2|BitListValue];\nencode_bit_string({{Fix,Fix},Ext}, BitListValue, [])\n    when is_integer(Fix), is_list(Ext) ->\n    case length(BitListValue) of\n        Len when Len =< Fix ->\n            [0|encode_bit_string(Fix, BitListValue, [])];\n        _ ->\n            [1|encode_bit_string(no, BitListValue, [])]\n    end;\nencode_bit_string(C, BitListValue, []) when is_list(BitListValue) ->\n    [encode_length(C, length(BitListValue)),2|BitListValue];\nencode_bit_string(no, BitListValue, _NamedBitList)\n    when is_list(BitListValue) ->\n    NewBitLVal =\n        lists:reverse(lists:dropwhile(fun(0) ->\n                                             true;\n                                         (1) ->\n                                             false\n                                      end,\n                                      lists:reverse(BitListValue))),\n    [encode_length(length(NewBitLVal)),2|NewBitLVal];\nencode_bit_string({{Fix,Fix},Ext}, BitListValue, NamedBitList)\n    when is_integer(Fix), is_list(Ext) ->\n    case length(BitListValue) of\n        Len when Len =< Fix ->\n            [0|encode_bit_string(Fix, BitListValue, NamedBitList)];\n        _ ->\n            [1|encode_bit_string(no, BitListValue, NamedBitList)]\n    end;\nencode_bit_string(C, BitListValue, _NamedBitList)\n    when is_list(BitListValue) ->\n    NewBitLVal = bit_string_trailing_zeros(BitListValue, C),\n    [encode_length(C, length(NewBitLVal)),2|NewBitLVal];\nencode_bit_string(C, IntegerVal, NamedBitList)\n    when is_integer(IntegerVal) ->\n    BitList = int_to_bitlist(IntegerVal),\n    encode_bit_string(C, BitList, NamedBitList).\n">>},
 {{per,bit_string_trailing_zeros,2},
  <<"\nbit_string_trailing_zeros(BitList, C) when is_integer(C) ->\n    bit_string_trailing_zeros1(BitList, C, C);\nbit_string_trailing_zeros(BitList, {Lb,Ub}) when is_integer(Lb) ->\n    bit_string_trailing_zeros1(BitList, Lb, Ub);\nbit_string_trailing_zeros(BitList, {{Lb,Ub},_}) when is_integer(Lb) ->\n    bit_string_trailing_zeros1(BitList, Lb, Ub);\nbit_string_trailing_zeros(BitList, _) ->\n    BitList.\n">>},
 {{per,bit_string_trailing_zeros1,3},
  <<"\nbit_string_trailing_zeros1(BitList, Lb, Ub) ->\n    case length(BitList) of\n        Lb ->\n            BitList;\n        B when B < Lb ->\n            BitList ++ lists:duplicate(Lb - B, 0);\n        D ->\n            F = fun(L, LB, LB, _, _) ->\n                       lists:reverse(L);\n                   ([0|R], L1, LB, UB, Fun) ->\n                       Fun(R, L1 - 1, LB, UB, Fun);\n                   (L, L1, _, UB, _) when L1 =< UB ->\n                       lists:reverse(L);\n                   (_, _L1, _, _, _) ->\n                       exit({error,{list_length_BIT_STRING,BitList}})\n                end,\n            F(lists:reverse(BitList), D, Lb, Ub, F)\n    end.\n">>},
 {{per,encode_bin_bit_string,3},
  <<"\nencode_bin_bit_string(C, {Unused,BinBits}, _NamedBitList)\n    when is_integer(C), C =< 16 ->\n    range_check(C, bit_size(BinBits) - Unused),\n    [45,C,byte_size(BinBits),BinBits];\nencode_bin_bit_string(C, {Unused,BinBits}, _NamedBitList)\n    when is_integer(C), C =< 255 ->\n    range_check(C, bit_size(BinBits) - Unused),\n    [2,45,C,byte_size(BinBits),BinBits];\nencode_bin_bit_string(C, {Unused,BinBits}, _NamedBitList)\n    when is_integer(C), C =< 65535 ->\n    range_check(C, bit_size(BinBits) - Unused),\n    case byte_size(BinBits) of\n        Size when Size =< 255 ->\n            [2,46,<<C:16>>,Size,BinBits];\n        Size ->\n            [2,47,<<C:16>>,<<Size:16>>,BinBits]\n    end;\nencode_bin_bit_string(C, UnusedAndBin = {_,_}, NamedBitList) ->\n    {Unused1,Bin1} = remove_trailing_bin(NamedBitList, UnusedAndBin),\n    case C of\n        {Lb,Ub} when is_integer(Lb), is_integer(Ub) ->\n            Size = byte_size(Bin1),\n            [encode_length({Lb,Ub}, Size * 8 - Unused1),\n             2,\n             octets_unused_to_complete(Unused1, Size, Bin1)];\n        no ->\n            Size = byte_size(Bin1),\n            [encode_length(Size * 8 - Unused1),\n             2|\n             octets_unused_to_complete(Unused1, Size, Bin1)];\n        {{Fix,Fix},Ext} when is_integer(Fix), is_list(Ext) ->\n            case byte_size(Bin1) * 8 - Unused1 of\n                Size when Size =< Fix ->\n                    [0|\n                     encode_bin_bit_string(Fix,\n                                           UnusedAndBin,\n                                           NamedBitList)];\n                _Size ->\n                    [1|\n                     encode_bin_bit_string(no,\n                                           UnusedAndBin,\n                                           NamedBitList)]\n            end;\n        Sc ->\n            Size = byte_size(Bin1),\n            [encode_length(Sc, Size * 8 - Unused1),\n             2|\n             octets_unused_to_complete(Unused1, Size, Bin1)]\n    end.\n">>},
 {{per,range_check,2},
  <<"\nrange_check(C, C) when is_integer(C) ->\n    ok;\nrange_check(C1, C2) when is_integer(C1) ->\n    exit({error,{asn1,{bit_string_out_of_range,{C1,C2}}}}).\n">>},
 {{per,remove_trailing_bin,2},
  <<"\nremove_trailing_bin([], {Unused,Bin}) ->\n    {Unused,Bin};\nremove_trailing_bin(_NamedNumberList, {_Unused,<<>>}) ->\n    {0,<<>>};\nremove_trailing_bin(NamedNumberList, {_Unused,Bin}) ->\n    Size = byte_size(Bin) - 1,\n    <<Bfront:Size/binary,LastByte:8>> = Bin,\n    Unused1 = trailingZeroesInNibble(LastByte band 15),\n    Unused2 =\n        case Unused1 of\n            4 ->\n                4 + trailingZeroesInNibble(LastByte bsr 4);\n            _ ->\n                Unused1\n        end,\n    case Unused2 of\n        8 ->\n            remove_trailing_bin(NamedNumberList, {0,Bfront});\n        _ ->\n            {Unused2,Bin}\n    end.\n">>},
 {{per,trailingZeroesInNibble,1},
  <<"\ntrailingZeroesInNibble(0) ->\n    4;\ntrailingZeroesInNibble(1) ->\n    0;\ntrailingZeroesInNibble(2) ->\n    1;\ntrailingZeroesInNibble(3) ->\n    0;\ntrailingZeroesInNibble(4) ->\n    2;\ntrailingZeroesInNibble(5) ->\n    0;\ntrailingZeroesInNibble(6) ->\n    1;\ntrailingZeroesInNibble(7) ->\n    0;\ntrailingZeroesInNibble(8) ->\n    3;\ntrailingZeroesInNibble(9) ->\n    0;\ntrailingZeroesInNibble(10) ->\n    1;\ntrailingZeroesInNibble(11) ->\n    0;\ntrailingZeroesInNibble(12) ->\n    2;\ntrailingZeroesInNibble(13) ->\n    0;\ntrailingZeroesInNibble(14) ->\n    1;\ntrailingZeroesInNibble(15) ->\n    0.\n">>},
 {{per,int_to_bitlist,1},
  <<"\nint_to_bitlist(Int) when is_integer(Int), Int > 0 ->\n    [Int band 1|int_to_bitlist(Int bsr 1)];\nint_to_bitlist(0) ->\n    [].\n">>},
 {{per,get_all_bitposes,3},
  <<"\nget_all_bitposes([{bit,ValPos}|Rest], NamedBitList, Ack) ->\n    get_all_bitposes(Rest, NamedBitList, [ValPos|Ack]);\nget_all_bitposes([Val|Rest], NamedBitList, Ack) ->\n    case lists:keyfind(Val, 1, NamedBitList) of\n        {_ValName,ValPos} ->\n            get_all_bitposes(Rest, NamedBitList, [ValPos|Ack]);\n        false ->\n            exit({error,{asn1,{bitstring_namedbit,Val}}})\n    end;\nget_all_bitposes([], _NamedBitList, Ack) ->\n    lists:sort(Ack).\n">>},
 {{per,make_and_set_list,2},
  <<"\nmake_and_set_list([XPos|SetPos], XPos) ->\n    [1|make_and_set_list(SetPos, XPos + 1)];\nmake_and_set_list([Pos|SetPos], XPos) ->\n    [0|make_and_set_list([Pos|SetPos], XPos + 1)];\nmake_and_set_list([], _) ->\n    [].\n">>},
 {{per,encode_octet_string,3},
  <<"\nencode_octet_string(_C, true, _Val) ->\n    exit({error,{asn1,{not_supported,extensionmarker}}});\nencode_octet_string({_,_} = SZ, false, Val) ->\n    Len = length(Val),\n    try\n        [encode_length(SZ, Len),2|octets_to_complete(Len, Val)]\n    catch\n        exit:{error,{asn1,{encode_length,_}}} ->\n            encode_fragmented_octet_string(Val)\n    end;\nencode_octet_string(SZ, false, Val) when is_list(SZ) ->\n    Len = length(Val),\n    try\n        [encode_length({hd(SZ),lists:max(SZ)}, Len),\n         2|\n         octets_to_complete(Len, Val)]\n    catch\n        exit:{error,{asn1,{encode_length,_}}} ->\n            encode_fragmented_octet_string(Val)\n    end;\nencode_octet_string(Sv, false, Val) when is_integer(Sv) ->\n    encode_fragmented_octet_string(Val);\nencode_octet_string(no, false, Val) ->\n    Len = length(Val),\n    try\n        [encode_length(Len),2|octets_to_complete(Len, Val)]\n    catch\n        exit:{error,{asn1,{encode_length,_}}} ->\n            encode_fragmented_octet_string(Val)\n    end;\nencode_octet_string(C, _, _) ->\n    exit({error,{not_implemented,C}}).\n">>},
 {{per,encode_fragmented_octet_string,1},
  <<"\nencode_fragmented_octet_string(Val) ->\n    Bin = iolist_to_binary(Val),\n    efos_1(Bin).\n">>},
 {{per,efos_1,1},
  <<"\nefos_1(<<B1:49152/binary,B2:16384/binary,T/binary>>) ->\n    [20,\n     1,\n     <<3:2,4:6>>,\n     octets_to_complete(49152, B1),\n     octets_to_complete(16384, B2)|\n     efos_1(T)];\nefos_1(<<B:49152/binary,T/binary>>) ->\n    [20,1,<<3:2,3:6>>,octets_to_complete(49152, B)|efos_1(T)];\nefos_1(<<B:32768/binary,T/binary>>) ->\n    [20,1,<<3:2,2:6>>,octets_to_complete(32768, B)|efos_1(T)];\nefos_1(<<B:16384/binary,T/binary>>) ->\n    [20,1,<<3:2,1:6>>,octets_to_complete(16384, B)|efos_1(T)];\nefos_1(<<>>) ->\n    [20,1,0];\nefos_1(<<B/bitstring>>) ->\n    Len = byte_size(B),\n    [encode_length(Len)|octets_to_complete(Len, B)].\n">>},
 {{per,encode_restricted_string,1},
  <<"\nencode_restricted_string(Val) when is_list(Val) ->\n    Len = length(Val),\n    [encode_length(Len)|octets_to_complete(Len, Val)].\n">>},
 {{per,encode_known_multiplier_string,4},
  <<"\nencode_known_multiplier_string(SizeC, NumBits, CharOutTab, Val) ->\n    Result = chars_encode2(Val, NumBits, CharOutTab),\n    case SizeC of\n        Ub when is_integer(Ub), Ub * NumBits =< 16 ->\n            Result;\n        Ub when is_integer(Ub), Ub =< 65535 ->\n            [2,Result];\n        {Ub,Lb} ->\n            [encode_length({Ub,Lb}, length(Val)),2,Result];\n        no ->\n            [encode_length(length(Val)),2,Result]\n    end.\n">>},
 {{per,encode_GeneralString,2},
  <<"\nencode_GeneralString(_C, Val) ->\n    encode_restricted_string(Val).\n">>},
 {{per,encode_GraphicString,2},
  <<"\nencode_GraphicString(_C, Val) ->\n    encode_restricted_string(Val).\n">>},
 {{per,encode_ObjectDescriptor,2},
  <<"\nencode_ObjectDescriptor(_C, Val) ->\n    encode_restricted_string(Val).\n">>},
 {{per,encode_TeletexString,2},
  <<"\nencode_TeletexString(_C, Val) ->\n    encode_restricted_string(Val).\n">>},
 {{per,encode_VideotexString,2},
  <<"\nencode_VideotexString(_C, Val) ->\n    encode_restricted_string(Val).\n">>},
 {{per,chars_encode2,3},
  <<"\nchars_encode2([H|T], NumBits, T1 = {Min,Max,notab})\n    when H =< Max, H >= Min ->\n    [pre_complete_bits(NumBits, H - Min)|chars_encode2(T, NumBits, T1)];\nchars_encode2([H|T], NumBits, T1 = {Min,Max,Tab})\n    when H =< Max, H >= Min ->\n    [pre_complete_bits(NumBits,\n                       exit_if_false(H, element(H - Min + 1, Tab)))|\n     chars_encode2(T, NumBits, T1)];\nchars_encode2([{A,B,C,D}|T], NumBits, T1 = {Min,_Max,notab}) ->\n    [pre_complete_bits(NumBits, A bsl 8 + B bsl 8 + C bsl 8 + D - Min)|\n     chars_encode2(T, NumBits, T1)];\nchars_encode2([H = {A,B,C,D}|T], NumBits, {Min,Max,Tab}) ->\n    [pre_complete_bits(NumBits,\n                       exit_if_false(H,\n                                     element(A bsl 8 + B bsl 8 + C bsl 8\n                                             +\n                                             D\n                                             -\n                                             Min,\n                                             Tab)))|\n     chars_encode2(T, NumBits, {Min,Max,notab})];\nchars_encode2([H|_T], _NumBits, {_Min,_Max,_Tab}) ->\n    exit({error,{asn1,{illegal_char_value,H}}});\nchars_encode2([], _, _) ->\n    [].\n">>},
 {{per,exit_if_false,2},
  <<"\nexit_if_false(V, false) ->\n    exit({error,\n          {asn1,\n           {\"illegal value according to Permitted alphabet constraint\",\n            V}}});\nexit_if_false(_, V) ->\n    V.\n">>},
 {{per,pre_complete_bits,2},
  <<"\npre_complete_bits(NumBits, Val) when NumBits =< 8 ->\n    [10,NumBits,Val];\npre_complete_bits(NumBits, Val) when NumBits =< 16 ->\n    [10,NumBits - 8,Val bsr 8,10,8,Val band 255];\npre_complete_bits(NumBits, Val) when NumBits =< 2040 ->\n    Unused = (8 - NumBits rem 8) rem 8,\n    Len = NumBits + Unused,\n    [30,Unused,Len div 8,<<(Val bsl Unused):Len>>].\n">>},
 {{per,encode_UTF8String,1},
  <<"\nencode_UTF8String(Val) when is_binary(Val) ->\n    Sz = byte_size(Val),\n    [encode_length(Sz),octets_to_complete(Sz, Val)];\nencode_UTF8String(Val) ->\n    encode_UTF8String(list_to_binary(Val)).\n">>},
 {{per,encode_object_identifier,1},
  <<"\nencode_object_identifier(Val) ->\n    OctetList = e_object_identifier(Val),\n    Octets = list_to_binary(OctetList),\n    Sz = byte_size(Octets),\n    [encode_length(Sz),octets_to_complete(Sz, Octets)].\n">>},
 {{per,e_object_identifier,1},
  <<"\ne_object_identifier({'OBJECT IDENTIFIER',V}) ->\n    e_object_identifier(V);\ne_object_identifier(V) when is_tuple(V) ->\n    e_object_identifier(tuple_to_list(V));\ne_object_identifier([E1,E2|Tail]) when E1 >= 0, E1 < 2, E2 < 40; E1 == 2 ->\n    Head = 40 * E1 + E2,\n    e_object_elements([Head|Tail], []);\ne_object_identifier(Oid = [_,_|_Tail]) ->\n    exit({error,{asn1,{illegal_value,Oid}}}).\n">>},
 {{per,e_object_elements,2},
  <<"\ne_object_elements([], Acc) ->\n    lists:reverse(Acc);\ne_object_elements([H|T], Acc) ->\n    e_object_elements(T, [e_object_element(H)|Acc]).\n">>},
 {{per,e_object_element,1},
  <<"\ne_object_element(Num) when Num < 128 ->\n    [Num];\ne_object_element(Num) ->\n    [e_o_e(Num bsr 7),Num band 127].\n">>},
 {{per,e_o_e,1},
  <<"\ne_o_e(Num) when Num < 128 ->\n    Num bor 128;\ne_o_e(Num) ->\n    [e_o_e(Num bsr 7),Num band 127 bor 128].\n">>},
 {{per,encode_relative_oid,1},
  <<"\nencode_relative_oid(Val) when is_tuple(Val) ->\n    encode_relative_oid(tuple_to_list(Val));\nencode_relative_oid(Val) when is_list(Val) ->\n    Octets =\n        list_to_binary([ \n                        e_object_element(X) ||\n                            X <- Val\n                       ]),\n    Sz = byte_size(Octets),\n    [encode_length(Sz)|octets_to_complete(Sz, Octets)].\n">>},
 {{per,complete,1},
  <<"\ncomplete(L) ->\n    asn1rt_nif:encode_per_complete(L).\n">>},
 {{per,octets_to_complete,2},
  <<"\noctets_to_complete(Len, Val) when Len < 256 ->\n    [20,Len,Val];\noctets_to_complete(Len, Val) ->\n    [21,<<Len:16>>,Val].\n">>},
 {{per,octets_unused_to_complete,3},
  <<"\noctets_unused_to_complete(Unused, Len, Val) when Len < 256 ->\n    [30,Unused,Len,Val];\noctets_unused_to_complete(Unused, Len, Val) ->\n    [31,Unused,<<Len:16>>,Val].\n">>},
 {{per_common,decode_fragmented,3},
  <<"\ndecode_fragmented(SegSz0, Buf0, Unit) ->\n    SegSz = SegSz0 * Unit * 16384,\n    <<Res:SegSz/bitstring,Buf/bitstring>> = Buf0,\n    decode_fragmented_1(Buf, Unit, Res).\n">>},
 {{per_common,decode_fragmented_1,3},
  <<"\ndecode_fragmented_1(<<0:1,N:7,Buf0/bitstring>>, Unit, Res) ->\n    Sz = N * Unit,\n    <<S:Sz/bitstring,Buf/bitstring>> = Buf0,\n    {<<Res/bitstring,S/bitstring>>,Buf};\ndecode_fragmented_1(<<1:1,0:1,N:14,Buf0/bitstring>>, Unit, Res) ->\n    Sz = N * Unit,\n    <<S:Sz/bitstring,Buf/bitstring>> = Buf0,\n    {<<Res/bitstring,S/bitstring>>,Buf};\ndecode_fragmented_1(<<1:1,1:1,SegSz0:6,Buf0/bitstring>>, Unit, Res0) ->\n    SegSz = SegSz0 * Unit * 16384,\n    <<Frag:SegSz/bitstring,Buf/bitstring>> = Buf0,\n    Res = <<Res0/bitstring,Frag/bitstring>>,\n    decode_fragmented_1(Buf, Unit, Res).\n">>},
 {{per_common,decode_named_bit_string,2},
  <<"\ndecode_named_bit_string(Val, NNL) ->\n    Bits =\n        [ \n         B ||\n             <<B:1>> <= Val\n        ],\n    decode_named_bit_string_1(0, Bits, NNL, []).\n">>},
 {{per_common,decode_legacy_bit_string,1},
  <<"\ndecode_legacy_bit_string(Val) ->\n    [ \n     B ||\n         <<B:1>> <= Val\n    ].\n">>},
 {{per_common,decode_compact_bit_string,1},
  <<"\ndecode_compact_bit_string(Val) ->\n    PadLen = (8 - bit_size(Val) band 7) band 7,\n    {PadLen,<<Val/bitstring,0:PadLen>>}.\n">>},
 {{per_common,decode_chars,2},
  <<"\ndecode_chars(Val, N) ->\n    [ \n     C ||\n         <<C:N>> <= Val\n    ].\n">>},
 {{per_common,decode_chars,3},
  <<"\ndecode_chars(Val, N, Chars) ->\n    [ \n     element(C + 1, Chars) ||\n         <<C:N>> <= Val\n    ].\n">>},
 {{per_common,decode_chars_16bit,1},
  <<"\ndecode_chars_16bit(Val) ->\n    Cs =\n        [ \n         C ||\n             <<C:16>> <= Val\n        ],\n    decode_chars_16bit_1(Cs).\n">>},
 {{per_common,decode_big_chars,2},
  <<"\ndecode_big_chars(Val, N) ->\n    decode_big_chars_1(decode_chars(Val, N)).\n">>},
 {{per_common,decode_oid,1},
  <<"\ndecode_oid(Octets) ->\n    [First|Rest] = dec_subidentifiers(Octets, 0, []),\n    Idlist =\n        if\n            First < 40 ->\n                [0,First|Rest];\n            First < 80 ->\n                [1,First - 40|Rest];\n            true ->\n                [2,First - 80|Rest]\n        end,\n    list_to_tuple(Idlist).\n">>},
 {{per_common,decode_relative_oid,1},
  <<"\ndecode_relative_oid(Octets) ->\n    list_to_tuple(dec_subidentifiers(Octets, 0, [])).\n">>},
 {{per_common,decode_named_bit_string_1,4},
  <<"\ndecode_named_bit_string_1(Pos, [0|Bt], Names, Acc) ->\n    decode_named_bit_string_1(Pos + 1, Bt, Names, Acc);\ndecode_named_bit_string_1(Pos, [1|Bt], Names, Acc) ->\n    case lists:keyfind(Pos, 2, Names) of\n        {Name,_} ->\n            decode_named_bit_string_1(Pos + 1, Bt, Names, [Name|Acc]);\n        false ->\n            decode_named_bit_string_1(Pos + 1,\n                                      Bt,\n                                      Names,\n                                      [{bit,Pos}|Acc])\n    end;\ndecode_named_bit_string_1(_Pos, [], _Names, Acc) ->\n    lists:reverse(Acc).\n">>},
 {{per_common,decode_chars_16bit_1,1},
  <<"\ndecode_chars_16bit_1([H|T]) when H < 256 ->\n    [H|decode_chars_16bit_1(T)];\ndecode_chars_16bit_1([H|T]) ->\n    [{0,0,H bsr 8,H band 255}|decode_chars_16bit_1(T)];\ndecode_chars_16bit_1([]) ->\n    [].\n">>},
 {{per_common,decode_big_chars_1,1},
  <<"\ndecode_big_chars_1([H|T]) when H < 256 ->\n    [H|decode_big_chars_1(T)];\ndecode_big_chars_1([H|T]) ->\n    [list_to_tuple(binary_to_list(<<H:32>>))|decode_big_chars_1(T)];\ndecode_big_chars_1([]) ->\n    [].\n">>},
 {{per_common,dec_subidentifiers,3},
  <<"\ndec_subidentifiers([H|T], Av, Al) when H >= 128 ->\n    dec_subidentifiers(T, Av bsl 7 bor H band 127, Al);\ndec_subidentifiers([H|T], Av, Al) ->\n    dec_subidentifiers(T, 0, [Av bsl 7 bor H|Al]);\ndec_subidentifiers([], _Av, Al) ->\n    lists:reverse(Al).\n">>},
 {{real_common,ber_encode_real,1},
  <<"\nber_encode_real(0) ->\n    {[],0};\nber_encode_real('PLUS-INFINITY') ->\n    {[64],1};\nber_encode_real('MINUS-INFINITY') ->\n    {[65],1};\nber_encode_real(Val) when is_tuple(Val); is_list(Val) ->\n    encode_real(Val).\n">>},
 {{real_common,encode_real,1},
  <<"\nencode_real(Real) ->\n    encode_real([], Real).\n">>},
 {{real_common,encode_real,2},
  <<"\nencode_real(_C, {Mantissa,Base,Exponent}) when Base =:= 2 ->\n    {Man,ExpAdd} = truncate_zeros(Mantissa),\n    Exp = Exponent + ExpAdd,\n    OctExp =\n        if\n            Exp >= 0 ->\n                list_to_binary(encode_pos_integer(Exp, []));\n            true ->\n                list_to_binary(encode_neg_integer(Exp, []))\n        end,\n    SignBit =\n        if\n            Man > 0 ->\n                0;\n            true ->\n                1\n        end,\n    SFactor = 0,\n    OctExpLen = byte_size(OctExp),\n    if\n        OctExpLen > 255 ->\n            exit({error,{asn1,{to_big_exp_in_encode_real,OctExpLen}}});\n        true ->\n            true\n    end,\n    {LenCode,EOctets} =\n        case OctExpLen of\n            1 ->\n                {0,OctExp};\n            2 ->\n                {1,OctExp};\n            3 ->\n                {2,OctExp};\n            _ ->\n                {3,<<OctExpLen,OctExp/binary>>}\n        end,\n    BB = 0,\n    FirstOctet = <<1:1,SignBit:1,BB:2,SFactor:2,LenCode:2>>,\n    OctMantissa =\n        if\n            Man > 0 ->\n                list_to_binary(real_mininum_octets(Man));\n            true ->\n                list_to_binary(real_mininum_octets(- Man))\n        end,\n    Bin = <<FirstOctet/binary,EOctets/binary,OctMantissa/binary>>,\n    {Bin,size(Bin)};\nencode_real(C, {Mantissa,Base,Exponent})\n    when Base =:= 10, is_integer(Mantissa), is_integer(Exponent) ->\n    ManStr = integer_to_list(Mantissa),\n    encode_real_as_string(C, ManStr, Exponent);\nencode_real(_C, {_,Base,_}) ->\n    exit({error,{asn1,{encode_real_non_supported_encoding,Base}}});\nencode_real(C, Real) when is_list(Real) ->\n    {Mantissa,Exponent} =\n        case string:tokens(Real, \"Ee\") of\n            [NR2] ->\n                {NR2,0};\n            [NR3MB,NR3E] ->\n                {NR3MB,list_to_integer(NR3E)}\n        end,\n    ZeroDecimal =\n        fun(\"0\") ->\n               \"\";\n           (L) ->\n               L\n        end,\n    {NewMantissa,LenDecimal} =\n        case Mantissa of\n            [$.|Dec] ->\n                NewMan = remove_trailing_zeros(Dec),\n                {NewMan,length(ZeroDecimal(NewMan))};\n            _ ->\n                case string:tokens(Mantissa, \",.\") of\n                    [Num] ->\n                        {integer_to_list(list_to_integer(Num)),0};\n                    [Num,Dec] ->\n                        NewDec = ZeroDecimal(remove_trailing_zeros(Dec)),\n                        NewMan =\n                            integer_to_list(list_to_integer(Num))\n                            ++\n                            NewDec,\n                        {integer_to_list(list_to_integer(NewMan)),\n                         length(NewDec)}\n                end\n        end,\n    encode_real_as_string(C, NewMantissa, Exponent - LenDecimal).\n">>},
 {{real_common,encode_real_as_string,3},
  <<"\nencode_real_as_string(_C, Mantissa, Exponent)\n    when is_list(Mantissa), is_integer(Exponent) ->\n    TruncMant = remove_trailing_zeros(Mantissa),\n    ExpIncr = length(Mantissa) - length(TruncMant),\n    ExpStr = integer_to_list(Exponent + ExpIncr),\n    ExpBin =\n        case ExpStr of\n            \"0\" ->\n                <<\"E+0\">>;\n            _ ->\n                ExpB = list_to_binary(ExpStr),\n                <<$E,ExpB/binary>>\n        end,\n    ManBin = list_to_binary(TruncMant),\n    NR3 = 3,\n    {<<NR3,ManBin/binary,$.,ExpBin/binary>>,\n     2 + byte_size(ManBin) + byte_size(ExpBin)}.\n">>},
 {{real_common,remove_trailing_zeros,1},
  <<"\nremove_trailing_zeros(IntStr) ->\n    case\n        lists:dropwhile(fun($0) ->\n                               true;\n                           (_) ->\n                               false\n                        end,\n                        lists:reverse(IntStr))\n    of\n        [] ->\n            \"0\";\n        ReversedIntStr ->\n            lists:reverse(ReversedIntStr)\n    end.\n">>},
 {{real_common,truncate_zeros,1},
  <<"\ntruncate_zeros(Num) ->\n    truncate_zeros(Num, 0).\n">>},
 {{real_common,truncate_zeros,2},
  <<"\ntruncate_zeros(0, Sum) ->\n    {0,Sum};\ntruncate_zeros(M, Sum) ->\n    case M band 15 =:= M band 14 of\n        true ->\n            truncate_zeros(M bsr 1, Sum + 1);\n        _ ->\n            {M,Sum}\n    end.\n">>},
 {{real_common,decode_real,1},
  <<"\ndecode_real(Buffer) ->\n    Sz = byte_size(Buffer),\n    {RealVal,<<>>,Sz} = decode_real2(Buffer, [], Sz, 0),\n    RealVal.\n">>},
 {{real_common,decode_real2,4},
  <<"\ndecode_real2(Buffer, _C, 0, _RemBytes) ->\n    {0,Buffer};\ndecode_real2(Buffer0, _C, Len, RemBytes1) ->\n    <<First,Buffer2/binary>> = Buffer0,\n    if\n        First =:= 64 ->\n            {'PLUS-INFINITY',Buffer2};\n        First =:= 65 ->\n            {'MINUS-INFINITY',Buffer2};\n        First =:= 1\n        orelse\n        First =:= 2\n        orelse\n        First =:= 3 ->\n            {NRx,Rest} = split_binary(Buffer2, Len - 1),\n            {binary_to_list(NRx),Rest,Len};\n        true ->\n            <<_B7:1,Sign:1,BB:2,_FF:2,EE:2>> = <<First>>,\n            Base =\n                case BB of\n                    0 ->\n                        2;\n                    _ ->\n                        exit({error,{asn1,{non_supported_base,BB}}})\n                end,\n            {FirstLen,{Exp,Buffer3,_Rb2},RemBytes2} =\n                case EE of\n                    0 ->\n                        {2,\n                         decode_integer2(1, Buffer2, RemBytes1),\n                         RemBytes1 + 1};\n                    1 ->\n                        {3,\n                         decode_integer2(2, Buffer2, RemBytes1),\n                         RemBytes1 + 2};\n                    2 ->\n                        {4,\n                         decode_integer2(3, Buffer2, RemBytes1),\n                         RemBytes1 + 3};\n                    3 ->\n                        <<ExpLen1,RestBuffer/binary>> = Buffer2,\n                        {ExpLen1 + 2,\n                         decode_integer2(ExpLen1, RestBuffer, RemBytes1),\n                         RemBytes1 + ExpLen1}\n                end,\n            Length = Len - FirstLen,\n            <<LongInt:Length/unit:8,RestBuff/binary>> = Buffer3,\n            {{Mantissa,Buffer4},RemBytes3} =\n                if\n                    Sign =:= 0 ->\n                        {{LongInt,RestBuff},1 + Length};\n                    true ->\n                        {{- LongInt,RestBuff},1 + Length}\n                end,\n            {{Mantissa,Base,Exp},Buffer4,RemBytes2 + RemBytes3}\n    end.\n">>},
 {{real_common,encode_pos_integer,2},
  <<"\nencode_pos_integer(0, [B|_Acc] = L) when B < 128 ->\n    L;\nencode_pos_integer(N, Acc) ->\n    encode_pos_integer(N bsr 8, [N band 255|Acc]).\n">>},
 {{real_common,encode_neg_integer,2},
  <<"\nencode_neg_integer(- 1, [B1|_T] = L) when B1 > 127 ->\n    L;\nencode_neg_integer(N, Acc) ->\n    encode_neg_integer(N bsr 8, [N band 255|Acc]).\n">>},
 {{real_common,real_mininum_octets,1},
  <<"\nreal_mininum_octets(Val) ->\n    real_mininum_octets(Val, []).\n">>},
 {{real_common,real_mininum_octets,2},
  <<"\nreal_mininum_octets(0, Acc) ->\n    Acc;\nreal_mininum_octets(Val, Acc) ->\n    real_mininum_octets(Val bsr 8, [Val band 255|Acc]).\n">>},
 {{real_common,decode_integer2,3},
  <<"\ndecode_integer2(Len, <<0:1,_:7,_Bs/binary>> = Bin, RemovedBytes) ->\n    <<Int:Len/unit:8,Buffer2/binary>> = Bin,\n    {Int,Buffer2,RemovedBytes};\ndecode_integer2(Len, <<1:1,B2:7,Bs/binary>>, RemovedBytes) ->\n    <<N:Len/unit:8,Buffer2/binary>> = <<B2,Bs/binary>>,\n    Int = N - (1 bsl (8 * Len - 1)),\n    {Int,Buffer2,RemovedBytes}.\n">>},
 {{uper,setext,1},
  <<"\nsetext(false) ->\n    <<0:1>>;\nsetext(true) ->\n    <<1:1>>.\n">>},
 {{uper,fixoptionals,3},
  <<"\nfixoptionals(OptList, OptLength, Val) when is_tuple(Val) ->\n    Bits = fixoptionals(OptList, Val, 0),\n    {Val,<<Bits:OptLength>>};\nfixoptionals([], _Val, Acc) ->\n    Acc;\nfixoptionals([{Pos,DefVal}|Ot], Val, Acc) ->\n    case element(Pos, Val) of\n        asn1_DEFAULT ->\n            fixoptionals(Ot, Val, Acc bsl 1);\n        DefVal ->\n            fixoptionals(Ot, Val, Acc bsl 1);\n        _ ->\n            fixoptionals(Ot, Val, Acc bsl 1 + 1)\n    end;\nfixoptionals([Pos|Ot], Val, Acc) ->\n    case element(Pos, Val) of\n        asn1_NOVALUE ->\n            fixoptionals(Ot, Val, Acc bsl 1);\n        asn1_DEFAULT ->\n            fixoptionals(Ot, Val, Acc bsl 1);\n        _ ->\n            fixoptionals(Ot, Val, Acc bsl 1 + 1)\n    end.\n">>},
 {{uper,fixextensions,2},
  <<"\nfixextensions({ext,ExtPos,ExtNum}, Val) ->\n    case fixextensions(ExtPos, ExtNum + ExtPos, Val, 0) of\n        0 ->\n            [];\n        ExtBits ->\n            [encode_small_length(ExtNum),<<ExtBits:ExtNum>>]\n    end.\n">>},
 {{uper,fixextensions,4},
  <<"\nfixextensions(Pos, MaxPos, _, Acc) when Pos >= MaxPos ->\n    Acc;\nfixextensions(Pos, ExtPos, Val, Acc) ->\n    Bit =\n        case catch element(Pos + 1, Val) of\n            asn1_NOVALUE ->\n                0;\n            asn1_NOEXTVALUE ->\n                0;\n            {'EXIT',_} ->\n                0;\n            _ ->\n                1\n        end,\n    fixextensions(Pos + 1, ExtPos, Val, Acc bsl 1 + Bit).\n">>},
 {{uper,skipextensions,3},
  <<"\nskipextensions(Bytes0, Nr, ExtensionBitstr)\n    when is_bitstring(ExtensionBitstr) ->\n    Prev = Nr - 1,\n    case ExtensionBitstr of\n        <<_:Prev,1:1,_/bitstring>> ->\n            {Len,Bytes1} = decode_length(Bytes0),\n            <<_:Len/binary,Bytes2/bitstring>> = Bytes1,\n            skipextensions(Bytes2, Nr + 1, ExtensionBitstr);\n        <<_:Prev,0:1,_/bitstring>> ->\n            skipextensions(Bytes0, Nr + 1, ExtensionBitstr);\n        _ ->\n            Bytes0\n    end.\n">>},
 {{uper,getchoice,3},
  <<"\ngetchoice(Bytes, 1, 0) ->\n    {0,Bytes};\ngetchoice(Bytes, _, 1) ->\n    decode_small_number(Bytes);\ngetchoice(Bytes, NumChoices, 0) ->\n    decode_constrained_number(Bytes, {0,NumChoices - 1}).\n">>},
 {{uper,getbit,1},
  <<"\ngetbit(Buffer) ->\n    <<B:1,Rest/bitstring>> = Buffer,\n    {B,Rest}.\n">>},
 {{uper,getbits,2},
  <<"\ngetbits(Buffer, Num) when is_bitstring(Buffer) ->\n    <<Bs:Num,Rest/bitstring>> = Buffer,\n    {Bs,Rest}.\n">>},
 {{uper,getoctets,2},
  <<"\ngetoctets(Buffer, Num) when is_bitstring(Buffer) ->\n    <<Val:Num/integer-unit:8,RestBitStr/bitstring>> = Buffer,\n    {Val,RestBitStr}.\n">>},
 {{uper,set_choice,3},
  <<"\nset_choice(Alt, {L1,L2}, {Len1,_Len2}) ->\n    case set_choice_tag(Alt, L1) of\n        N when is_integer(N), Len1 > 1 ->\n            [<<0:1>>,encode_integer([{'ValueRange',{0,Len1 - 1}}], N)];\n        N when is_integer(N) ->\n            <<0:1>>;\n        false ->\n            [<<1:1>>,\n             case set_choice_tag(Alt, L2) of\n                 N2 when is_integer(N2) ->\n                     encode_small_number(N2);\n                 false ->\n                     unknown_choice_alt\n             end]\n    end;\nset_choice(Alt, L, Len) ->\n    case set_choice_tag(Alt, L) of\n        N when is_integer(N), Len > 1 ->\n            encode_integer([{'ValueRange',{0,Len - 1}}], N);\n        N when is_integer(N) ->\n            [];\n        false ->\n            [unknown_choice_alt]\n    end.\n">>},
 {{uper,set_choice_tag,2},
  <<"\nset_choice_tag(Alt, Choices) ->\n    set_choice_tag(Alt, Choices, 0).\n">>},
 {{uper,set_choice_tag,3},
  <<"\nset_choice_tag(Alt, [Alt|_Rest], Tag) ->\n    Tag;\nset_choice_tag(Alt, [_H|Rest], Tag) ->\n    set_choice_tag(Alt, Rest, Tag + 1);\nset_choice_tag(_Alt, [], _Tag) ->\n    false.\n">>},
 {{uper,encode_open_type,1},
  <<"\nencode_open_type(Val) when is_list(Val) ->\n    encode_open_type(list_to_binary(Val));\nencode_open_type(Val) when is_binary(Val) ->\n    [encode_length(byte_size(Val)),Val].\n">>},
 {{uper,encode_integer,3},
  <<"\nencode_integer(C, V, NamedNumberList) when is_atom(V) ->\n    case lists:keyfind(V, 1, NamedNumberList) of\n        {_,NewV} ->\n            encode_integer(C, NewV);\n        false ->\n            exit({error,{asn1,{namednumber,V}}})\n    end;\nencode_integer(C, V, _NamedNumberList) when is_integer(V) ->\n    encode_integer(C, V).\n">>},
 {{uper,encode_integer,2},
  <<"\nencode_integer([{Rc,_Ec}], Val) when is_tuple(Rc) ->\n    try\n        [<<0:1>>,encode_integer([Rc], Val)]\n    catch\n        _:{error,{asn1,_}} ->\n            [<<1:1>>,encode_unconstrained_number(Val)]\n    end;\nencode_integer(C, Val) when is_list(C) ->\n    case get_constraint(C, 'SingleValue') of\n        no ->\n            encode_integer1(C, Val);\n        V when is_integer(V), V =:= Val ->\n            [];\n        V when is_list(V) ->\n            case lists:member(Val, V) of\n                true ->\n                    encode_integer1(C, Val);\n                _ ->\n                    exit({error,{asn1,{illegal_value,Val}}})\n            end;\n        _ ->\n            exit({error,{asn1,{illegal_value,Val}}})\n    end.\n">>},
 {{uper,encode_integer1,2},
  <<"\nencode_integer1(C, Val) ->\n    case VR = get_constraint(C, 'ValueRange') of\n        no ->\n            encode_unconstrained_number(Val);\n        {Lb,'MAX'} ->\n            encode_semi_constrained_number(Lb, Val);\n        {Lb,Ub} when Val >= Lb, Ub >= Val ->\n            encode_constrained_number(VR, Val);\n        _ ->\n            exit({error,{asn1,{illegal_value,VR,Val}}})\n    end.\n">>},
 {{uper,encode_small_number,1},
  <<"\nencode_small_number(Val) when Val < 64 ->\n    <<Val:7>>;\nencode_small_number(Val) ->\n    [<<1:1>>|encode_semi_constrained_number(0, Val)].\n">>},
 {{uper,decode_small_number,1},
  <<"\ndecode_small_number(Bytes) ->\n    {Bit,Bytes2} = getbit(Bytes),\n    case Bit of\n        0 ->\n            getbits(Bytes2, 6);\n        1 ->\n            decode_semi_constrained_number(Bytes2)\n    end.\n">>},
 {{uper,encode_semi_constrained_number,2},
  <<"\nencode_semi_constrained_number(Lb, Val) ->\n    Val2 = Val - Lb,\n    Bin = eint_bin_positive(Val2),\n    Size = byte_size(Bin),\n    if\n        Size < 128 ->\n            [<<Size>>,Bin];\n        Size < 16384 ->\n            [<<2:2,Size:14>>,Bin];\n        true ->\n            [encode_length(Size),Bin]\n    end.\n">>},
 {{uper,decode_semi_constrained_number,1},
  <<"\ndecode_semi_constrained_number(Bytes) ->\n    {Len,Bytes2} = decode_length(Bytes),\n    {V,Bytes3} = getoctets(Bytes2, Len),\n    {V,Bytes3}.\n">>},
 {{uper,encode_constrained_number,2},
  <<"\nencode_constrained_number({Lb,Ub}, Val) when Val >= Lb, Ub >= Val ->\n    Range = Ub - Lb + 1,\n    Val2 = Val - Lb,\n    NumBits = num_bits(Range),\n    <<Val2:NumBits>>;\nencode_constrained_number(Range, Val) ->\n    exit({error,{asn1,{integer_range,Range,value,Val}}}).\n">>},
 {{uper,decode_constrained_number,2},
  <<"\ndecode_constrained_number(Buffer, {Lb,Ub}) ->\n    Range = Ub - Lb + 1,\n    NumBits = num_bits(Range),\n    {Val,Remain} = getbits(Buffer, NumBits),\n    {Val + Lb,Remain}.\n">>},
 {{uper,encode_unconstrained_number,1},
  <<"\nencode_unconstrained_number(Val) when Val >= 0 ->\n    Oct = eint_bin_2Cs(Val),\n    Len = byte_size(Oct),\n    if\n        Len < 128 ->\n            [<<Len>>,Oct];\n        Len < 16384 ->\n            [<<2:2,Len:14>>,Oct];\n        true ->\n            [encode_length(Len),<<Len:16>>,Oct]\n    end;\nencode_unconstrained_number(Val) ->\n    Oct = enint(Val, []),\n    Len = byte_size(Oct),\n    if\n        Len < 128 ->\n            [<<Len>>,Oct];\n        Len < 16384 ->\n            [<<2:2,Len:14>>,Oct];\n        true ->\n            [encode_length(Len),Oct]\n    end.\n">>},
 {{uper,eint_bin_2Cs,1},
  <<"\neint_bin_2Cs(Int) ->\n    case eint_bin_positive(Int) of\n        <<B,_/binary>> = Bin when B > 127 ->\n            <<0,Bin/binary>>;\n        Bin ->\n            Bin\n    end.\n">>},
 {{uper,eint_bin_positive,1},
  <<"\neint_bin_positive(Val) when Val < 256 ->\n    <<Val>>;\neint_bin_positive(Val) when Val < 65536 ->\n    <<Val:16>>;\neint_bin_positive(Val) when Val < 16777216 ->\n    <<Val:24>>;\neint_bin_positive(Val) when Val < 4294967296 ->\n    <<Val:32>>;\neint_bin_positive(Val) ->\n    list_to_binary([eint_bin_positive2(Val bsr 32),<<Val:32>>]).\n">>},
 {{uper,eint_bin_positive2,1},
  <<"\neint_bin_positive2(Val) when Val < 256 ->\n    <<Val>>;\neint_bin_positive2(Val) when Val < 65536 ->\n    <<Val:16>>;\neint_bin_positive2(Val) when Val < 16777216 ->\n    <<Val:24>>;\neint_bin_positive2(Val) when Val < 4294967296 ->\n    <<Val:32>>;\neint_bin_positive2(Val) ->\n    [eint_bin_positive2(Val bsr 32),<<Val:32>>].\n">>},
 {{uper,enint,2},
  <<"\nenint(- 1, [B1|T]) when B1 > 127 ->\n    list_to_binary([B1|T]);\nenint(N, Acc) ->\n    enint(N bsr 8, [N band 255|Acc]).\n">>},
 {{uper,encode_length,1},
  <<"\nencode_length(Len) ->\n    if\n        Len < 128 ->\n            <<Len>>;\n        Len < 16384 ->\n            <<2:2,Len:14>>;\n        true ->\n            error({error,{asn1,{encode_length,{nyi,above_16k}}}})\n    end.\n">>},
 {{uper,encode_length,2},
  <<"\nencode_length(undefined, Len) ->\n    encode_length(Len);\nencode_length({0,'MAX'}, Len) ->\n    encode_length(undefined, Len);\nencode_length({Lb,Ub} = Vr, Len) when Ub =< 65535, Lb >= 0 ->\n    encode_constrained_number(Vr, Len);\nencode_length({Lb,_Ub}, Len) when is_integer(Lb), Lb >= 0 ->\n    encode_length(Len);\nencode_length({{Lb,Ub} = Vr,Ext}, Len)\n    when Ub =< 65535, Lb >= 0, Len =< Ub, is_list(Ext) ->\n    [<<0:1>>,encode_constrained_number(Vr, Len)];\nencode_length({{Lb,_Ub},Ext}, Len) when is_list(Ext) ->\n    [<<1:1>>,encode_semi_constrained_number(Lb, Len)];\nencode_length(SingleValue, _Len) when is_integer(SingleValue) ->\n    [].\n">>},
 {{uper,encode_small_length,1},
  <<"\nencode_small_length(Len) when Len =< 64 ->\n    <<(Len - 1):7>>;\nencode_small_length(Len) ->\n    [<<1:1>>,encode_length(Len)].\n">>},
 {{uper,decode_length,1},
  <<"\ndecode_length(<<0:1,Oct:7,Rest/bitstring>>) ->\n    {Oct,Rest};\ndecode_length(<<2:2,Val:14,Rest/bitstring>>) ->\n    {Val,Rest};\ndecode_length(<<3:2,_:14,_Rest/bitstring>>) ->\n    exit({error,{asn1,{decode_length,{nyi,above_16k}}}}).\n">>},
 {{uper,encode_boolean,1},
  <<"\nencode_boolean(true) ->\n    <<1:1>>;\nencode_boolean(false) ->\n    <<0:1>>;\nencode_boolean(Val) ->\n    exit({error,{asn1,{encode_boolean,Val}}}).\n">>},
 {{uper,encode_bit_string,3},
  <<"\nencode_bit_string(C, Bits, NamedBitList) when is_bitstring(Bits) ->\n    PadLen = (8 - bit_size(Bits) band 7) band 7,\n    Compact = {PadLen,<<Bits/bitstring,0:PadLen>>},\n    encode_bit_string(C, Compact, NamedBitList);\nencode_bit_string(C, {Unused,BinBits} = Bin, NamedBitList)\n    when is_integer(Unused), is_binary(BinBits) ->\n    encode_bin_bit_string(C, Bin, NamedBitList);\nencode_bit_string(C, BitListVal, NamedBitList) ->\n    encode_bit_string1(C, BitListVal, NamedBitList).\n">>},
 {{uper,encode_bit_string1,3},
  <<"\nencode_bit_string1(C, [FirstVal|_RestVal] = LoNB, NamedBitList)\n    when is_atom(FirstVal) ->\n    ToSetPos = get_all_bitposes(LoNB, NamedBitList, []),\n    BitList = make_and_set_list(ToSetPos, 0),\n    encode_bit_string1(C, BitList, NamedBitList);\nencode_bit_string1(C, [{bit,_No}|_RestVal] = BL, NamedBitList) ->\n    ToSetPos = get_all_bitposes(BL, NamedBitList, []),\n    BitList = make_and_set_list(ToSetPos, 0),\n    encode_bit_string1(C, BitList, NamedBitList);\nencode_bit_string1(Int, BitListValue, _)\n    when is_list(BitListValue), is_integer(Int) ->\n    bit_list2bitstr(Int, BitListValue);\nencode_bit_string1(no, BitListValue, []) when is_list(BitListValue) ->\n    Len = length(BitListValue),\n    [encode_length(Len),bit_list2bitstr(Len, BitListValue)];\nencode_bit_string1(C, BitListValue, []) when is_list(BitListValue) ->\n    Len = length(BitListValue),\n    [encode_length(C, Len),bit_list2bitstr(Len, BitListValue)];\nencode_bit_string1(no, BitListValue, _NamedBitList)\n    when is_list(BitListValue) ->\n    NewBitLVal =\n        lists:reverse(lists:dropwhile(fun(0) ->\n                                             true;\n                                         (1) ->\n                                             false\n                                      end,\n                                      lists:reverse(BitListValue))),\n    Len = length(NewBitLVal),\n    [encode_length(Len),bit_list2bitstr(Len, NewBitLVal)];\nencode_bit_string1(C, BitListValue, _NamedBitList)\n    when is_list(BitListValue) ->\n    NewBitStr = bitstr_trailing_zeros(BitListValue, C),\n    [encode_length(C, bit_size(NewBitStr)),NewBitStr];\nencode_bit_string1(C, IntegerVal, NamedBitList)\n    when is_integer(IntegerVal) ->\n    BitList = int_to_bitlist(IntegerVal),\n    encode_bit_string1(C, BitList, NamedBitList).\n">>},
 {{uper,bit_list2bitstr,2},
  <<"\nbit_list2bitstr(Len, BitListValue) ->\n    case length(BitListValue) of\n        Len ->\n            << \n              <<B:1>> ||\n                  B <- BitListValue\n            >>;\n        L when L > Len ->\n            <<<< \n                <<B:1>> ||\n                    B <- BitListValue\n              >>:Len/bitstring>>;\n        L ->\n            <<<< \n                <<B:1>> ||\n                    B <- BitListValue\n              >>/bitstring,\n              0:(Len - L)>>\n    end.\n">>},
 {{uper,adjust_trailing_zeros,2},
  <<"\nadjust_trailing_zeros(Len, Bin) when Len =:= bit_size(Bin) ->\n    Bin;\nadjust_trailing_zeros(Len, Bin) when Len > bit_size(Bin) ->\n    <<Bin/bitstring,0:(Len - bit_size(Bin))>>;\nadjust_trailing_zeros(Len, Bin) ->\n    <<Bin:Len/bitstring>>.\n">>},
 {{uper,bitstr_trailing_zeros,2},
  <<"\nbitstr_trailing_zeros(BitList, C) when is_integer(C) ->\n    bitstr_trailing_zeros1(BitList, C, C);\nbitstr_trailing_zeros(BitList, {Lb,Ub}) when is_integer(Lb) ->\n    bitstr_trailing_zeros1(BitList, Lb, Ub);\nbitstr_trailing_zeros(BitList, {{Lb,Ub},_}) when is_integer(Lb) ->\n    bitstr_trailing_zeros1(BitList, Lb, Ub);\nbitstr_trailing_zeros(BitList, _) ->\n    bit_list2bitstr(length(BitList), BitList).\n">>},
 {{uper,bitstr_trailing_zeros1,3},
  <<"\nbitstr_trailing_zeros1(BitList, Lb, Ub) ->\n    case length(BitList) of\n        Lb ->\n            bit_list2bitstr(Lb, BitList);\n        B when B < Lb ->\n            bit_list2bitstr(Lb, BitList);\n        D ->\n            F = fun(L, LB, LB, _, _) ->\n                       bit_list2bitstr(LB, lists:reverse(L));\n                   ([0|R], L1, LB, UB, Fun) ->\n                       Fun(R, L1 - 1, LB, UB, Fun);\n                   (L, L1, _, UB, _) when L1 =< UB ->\n                       bit_list2bitstr(L1, lists:reverse(L));\n                   (_, _L1, _, _, _) ->\n                       exit({error,{list_length_BIT_STRING,BitList}})\n                end,\n            F(lists:reverse(BitList), D, Lb, Ub, F)\n    end.\n">>},
 {{uper,encode_bin_bit_string,3},
  <<"\nencode_bin_bit_string(C, {_,BinBits}, _NamedBitList)\n    when is_integer(C), C =< 16 ->\n    adjust_trailing_zeros(C, BinBits);\nencode_bin_bit_string(C, {_Unused,BinBits}, _NamedBitList)\n    when is_integer(C) ->\n    adjust_trailing_zeros(C, BinBits);\nencode_bin_bit_string(C, {_,_} = UnusedAndBin, NamedBitList) ->\n    BitStr = remove_trailing_bin(NamedBitList, UnusedAndBin),\n    case C of\n        {Lb,Ub} when is_integer(Lb), is_integer(Ub) ->\n            [encode_length({Lb,Ub}, bit_size(BitStr)),BitStr];\n        no ->\n            [encode_length(bit_size(BitStr)),BitStr];\n        Sc ->\n            [encode_length(Sc, bit_size(BitStr)),BitStr]\n    end.\n">>},
 {{uper,remove_trailing_bin,2},
  <<"\nremove_trailing_bin([], {Unused,Bin}) ->\n    BS = bit_size(Bin) - Unused,\n    <<BitStr:BS/bitstring,_:Unused>> = Bin,\n    BitStr;\nremove_trailing_bin(_NamedNumberList, {_Unused,<<>>}) ->\n    <<>>;\nremove_trailing_bin(NamedNumberList, {_Unused,Bin}) ->\n    Size = byte_size(Bin) - 1,\n    <<Bfront:Size/binary,LastByte:8>> = Bin,\n    Unused1 = trailingZeroesInNibble(LastByte band 15),\n    Unused2 =\n        case Unused1 of\n            4 ->\n                4 + trailingZeroesInNibble(LastByte bsr 4);\n            _ ->\n                Unused1\n        end,\n    case Unused2 of\n        8 ->\n            remove_trailing_bin(NamedNumberList, {0,Bfront});\n        _ ->\n            BS = bit_size(Bin) - Unused2,\n            <<BitStr:BS/bitstring,_:Unused2>> = Bin,\n            BitStr\n    end.\n">>},
 {{uper,trailingZeroesInNibble,1},
  <<"\ntrailingZeroesInNibble(0) ->\n    4;\ntrailingZeroesInNibble(1) ->\n    0;\ntrailingZeroesInNibble(2) ->\n    1;\ntrailingZeroesInNibble(3) ->\n    0;\ntrailingZeroesInNibble(4) ->\n    2;\ntrailingZeroesInNibble(5) ->\n    0;\ntrailingZeroesInNibble(6) ->\n    1;\ntrailingZeroesInNibble(7) ->\n    0;\ntrailingZeroesInNibble(8) ->\n    3;\ntrailingZeroesInNibble(9) ->\n    0;\ntrailingZeroesInNibble(10) ->\n    1;\ntrailingZeroesInNibble(11) ->\n    0;\ntrailingZeroesInNibble(12) ->\n    2;\ntrailingZeroesInNibble(13) ->\n    0;\ntrailingZeroesInNibble(14) ->\n    1;\ntrailingZeroesInNibble(15) ->\n    0.\n">>},
 {{uper,int_to_bitlist,1},
  <<"\nint_to_bitlist(Int) when is_integer(Int), Int > 0 ->\n    [Int band 1|int_to_bitlist(Int bsr 1)];\nint_to_bitlist(0) ->\n    [].\n">>},
 {{uper,get_all_bitposes,3},
  <<"\nget_all_bitposes([{bit,ValPos}|Rest], NamedBitList, Ack) ->\n    get_all_bitposes(Rest, NamedBitList, [ValPos|Ack]);\nget_all_bitposes([Val|Rest], NamedBitList, Ack) ->\n    case lists:keyfind(Val, 1, NamedBitList) of\n        {_ValName,ValPos} ->\n            get_all_bitposes(Rest, NamedBitList, [ValPos|Ack]);\n        false ->\n            exit({error,{asn1,{bitstring_namedbit,Val}}})\n    end;\nget_all_bitposes([], _NamedBitList, Ack) ->\n    lists:sort(Ack).\n">>},
 {{uper,make_and_set_list,2},
  <<"\nmake_and_set_list([XPos|SetPos], XPos) ->\n    [1|make_and_set_list(SetPos, XPos + 1)];\nmake_and_set_list([Pos|SetPos], XPos) ->\n    [0|make_and_set_list([Pos|SetPos], XPos + 1)];\nmake_and_set_list([], _) ->\n    [].\n">>},
 {{uper,encode_octet_string,1},
  <<"\nencode_octet_string(Val) ->\n    try\n        [encode_length(length(Val)),list_to_binary(Val)]\n    catch\n        error:{error,{asn1,{encode_length,_}}} ->\n            encode_fragmented_octet_string(Val)\n    end.\n">>},
 {{uper,encode_octet_string,2},
  <<"\nencode_octet_string(C, Val) ->\n    case C of\n        1 ->\n            list_to_binary(Val);\n        2 ->\n            list_to_binary(Val);\n        {_,_} = VR ->\n            try\n                [encode_length(VR, length(Val)),list_to_binary(Val)]\n            catch\n                error:{error,{asn1,{encode_length,_}}} ->\n                    encode_fragmented_octet_string(Val)\n            end;\n        Sv when is_integer(Sv), Sv =:= length(Val) ->\n            if\n                Sv =< 65535 ->\n                    list_to_binary(Val);\n                true ->\n                    encode_fragmented_octet_string(Val)\n            end;\n        Sv when is_list(Sv) ->\n            try\n                [encode_length({hd(Sv),lists:max(Sv)}, length(Val)),\n                 list_to_binary(Val)]\n            catch\n                error:{error,{asn1,{encode_length,_}}} ->\n                    encode_fragmented_octet_string(Val)\n            end\n    end.\n">>},
 {{uper,encode_fragmented_octet_string,1},
  <<"\nencode_fragmented_octet_string(Val) ->\n    Bin = list_to_binary(Val),\n    efos_1(Bin).\n">>},
 {{uper,efos_1,1},
  <<"\nefos_1(<<B:65536/binary,T/binary>>) ->\n    [<<3:2,4:6>>,B|efos_1(T)];\nefos_1(<<B:49152/binary,T/binary>>) ->\n    [<<3:2,3:6>>,B|efos_1(T)];\nefos_1(<<B:32768/binary,T/binary>>) ->\n    [<<3:2,2:6>>,B|efos_1(T)];\nefos_1(<<B:16384/binary,T/binary>>) ->\n    [<<3:2,1:6>>,B|efos_1(T)];\nefos_1(<<B/bitstring>>) ->\n    Len = byte_size(B),\n    [encode_length(Len),B].\n">>},
 {{uper,encode_restricted_string,1},
  <<"\nencode_restricted_string(Val) when is_list(Val) ->\n    [encode_length(length(Val)),list_to_binary(Val)].\n">>},
 {{uper,encode_known_multiplier_string,3},
  <<"\nencode_known_multiplier_string(StringType, C, Val) ->\n    Result = chars_encode(C, StringType, Val),\n    NumBits = get_NumBits(C, StringType),\n    case get_constraint(C, 'SizeConstraint') of\n        Ub when is_integer(Ub), Ub * NumBits =< 16 ->\n            Result;\n        0 ->\n            [];\n        Ub when is_integer(Ub), Ub =< 65535 ->\n            Result;\n        {Ub,Lb} ->\n            [encode_length({Ub,Lb}, length(Val)),Result];\n        Vl when is_list(Vl) ->\n            [encode_length({lists:min(Vl),lists:max(Vl)}, length(Val)),\n             Result];\n        no ->\n            [encode_length(length(Val)),Result]\n    end.\n">>},
 {{uper,encode_NumericString,2},
  <<"\nencode_NumericString(C, Val) ->\n    encode_known_multiplier_string('NumericString', C, Val).\n">>},
 {{uper,encode_PrintableString,2},
  <<"\nencode_PrintableString(C, Val) ->\n    encode_known_multiplier_string('PrintableString', C, Val).\n">>},
 {{uper,encode_VisibleString,2},
  <<"\nencode_VisibleString(C, Val) ->\n    encode_known_multiplier_string('VisibleString', C, Val).\n">>},
 {{uper,encode_IA5String,2},
  <<"\nencode_IA5String(C, Val) ->\n    encode_known_multiplier_string('IA5String', C, Val).\n">>},
 {{uper,encode_BMPString,2},
  <<"\nencode_BMPString(C, Val) ->\n    encode_known_multiplier_string('BMPString', C, Val).\n">>},
 {{uper,encode_UniversalString,2},
  <<"\nencode_UniversalString(C, Val) ->\n    encode_known_multiplier_string('UniversalString', C, Val).\n">>},
 {{uper,encode_GeneralString,2},
  <<"\nencode_GeneralString(_C, Val) ->\n    encode_restricted_string(Val).\n">>},
 {{uper,encode_GraphicString,2},
  <<"\nencode_GraphicString(_C, Val) ->\n    encode_restricted_string(Val).\n">>},
 {{uper,encode_ObjectDescriptor,2},
  <<"\nencode_ObjectDescriptor(_C, Val) ->\n    encode_restricted_string(Val).\n">>},
 {{uper,encode_TeletexString,2},
  <<"\nencode_TeletexString(_C, Val) ->\n    encode_restricted_string(Val).\n">>},
 {{uper,encode_VideotexString,2},
  <<"\nencode_VideotexString(_C, Val) ->\n    encode_restricted_string(Val).\n">>},
 {{uper,chars_encode,3},
  <<"\nchars_encode(C, StringType, Value) ->\n    case {StringType,get_constraint(C, 'PermittedAlphabet')} of\n        {'UniversalString',{_,_Sv}} ->\n            exit({error,\n                  {asn1,\n                   {'not implemented',\n                    \"UniversalString with PermittedAlphabet constraint\"}}});\n        {'BMPString',{_,_Sv}} ->\n            exit({error,\n                  {asn1,\n                   {'not implemented',\n                    \"BMPString with PermittedAlphabet constraint\"}}});\n        _ ->\n            {NumBits,CharOutTab} =\n                {get_NumBits(C, StringType),\n                 get_CharOutTab(C, StringType)},\n            chars_encode2(Value, NumBits, CharOutTab)\n    end.\n">>},
 {{uper,chars_encode2,3},
  <<"\nchars_encode2([H|T], NumBits, {Min,Max,notab}) when H =< Max, H >= Min ->\n    [<<(H - Min):NumBits>>|chars_encode2(T, NumBits, {Min,Max,notab})];\nchars_encode2([H|T], NumBits, {Min,Max,Tab}) when H =< Max, H >= Min ->\n    Ch = exit_if_false(H, element(H - Min + 1, Tab)),\n    [<<Ch:NumBits>>|chars_encode2(T, NumBits, {Min,Max,Tab})];\nchars_encode2([{A,B,C,D}|T], NumBits, {Min,Max,notab}) ->\n    Ch = A bsl 8 + B bsl 8 + C bsl 8 + D - Min,\n    [<<Ch:NumBits>>|chars_encode2(T, NumBits, {Min,Max,notab})];\nchars_encode2([{A,B,C,D}|T], NumBits, {Min,Max,Tab}) ->\n    Ch =\n        exit_if_false({A,B,C,D},\n                      element(A bsl 8 + B bsl 8 + C bsl 8 + D - Min,\n                              Tab)),\n    [<<Ch:NumBits>>|chars_encode2(T, NumBits, {Min,Max,notab})];\nchars_encode2([H|_T], _, {_,_,_}) ->\n    exit({error,{asn1,{illegal_char_value,H}}});\nchars_encode2([], _, _) ->\n    [].\n">>},
 {{uper,exit_if_false,2},
  <<"\nexit_if_false(V, false) ->\n    exit({error,\n          {asn1,\n           {\"illegal value according to Permitted alphabet constraint\",\n            V}}});\nexit_if_false(_, V) ->\n    V.\n">>},
 {{uper,get_NumBits,2},
  <<"\nget_NumBits(C, StringType) ->\n    case get_constraint(C, 'PermittedAlphabet') of\n        {'SingleValue',Sv} ->\n            charbits(length(Sv));\n        no ->\n            case StringType of\n                'IA5String' ->\n                    charbits(128);\n                'VisibleString' ->\n                    charbits(95);\n                'PrintableString' ->\n                    charbits(74);\n                'NumericString' ->\n                    charbits(11);\n                'UniversalString' ->\n                    32;\n                'BMPString' ->\n                    16\n            end\n    end.\n">>},
 {{uper,get_CharOutTab,2},
  <<"\nget_CharOutTab(C, StringType) ->\n    case get_constraint(C, 'PermittedAlphabet') of\n        {'SingleValue',Sv} ->\n            get_CharTab2(C, StringType, hd(Sv), lists:max(Sv), Sv);\n        no ->\n            case StringType of\n                'IA5String' ->\n                    {0,127,notab};\n                'VisibleString' ->\n                    get_CharTab2(C, StringType, 32, 127, notab);\n                'PrintableString' ->\n                    Chars =\n                        lists:sort(\" '()+,-./0123456789:=?ABCDEFGHIJKLM\"\n                                   \"NOPQRSTUVWXYZabcdefghijklmnopqrstuv\"\n                                   \"wxyz\"),\n                    get_CharTab2(C,\n                                 StringType,\n                                 hd(Chars),\n                                 lists:max(Chars),\n                                 Chars);\n                'NumericString' ->\n                    get_CharTab2(C, StringType, 32, $9, \" 0123456789\");\n                'UniversalString' ->\n                    {0,4294967295,notab};\n                'BMPString' ->\n                    {0,65535,notab}\n            end\n    end.\n">>},
 {{uper,get_CharTab2,5},
  <<"\nget_CharTab2(C, StringType, Min, Max, Chars) ->\n    BitValMax = 1 bsl get_NumBits(C, StringType) - 1,\n    if\n        Max =< BitValMax ->\n            {0,Max,notab};\n        true ->\n            {Min,Max,create_char_tab(Min, Chars)}\n    end.\n">>},
 {{uper,create_char_tab,2},
  <<"\ncreate_char_tab(Min, L) ->\n    list_to_tuple(create_char_tab(Min, L, 0)).\n">>},
 {{uper,create_char_tab,3},
  <<"\ncreate_char_tab(Min, [Min|T], V) ->\n    [V|create_char_tab(Min + 1, T, V + 1)];\ncreate_char_tab(_Min, [], _V) ->\n    [];\ncreate_char_tab(Min, L, V) ->\n    [false|create_char_tab(Min + 1, L, V)].\n">>},
 {{uper,charbits,1},
  <<"\ncharbits(NumOfChars) when NumOfChars =< 2 ->\n    1;\ncharbits(NumOfChars) when NumOfChars =< 4 ->\n    2;\ncharbits(NumOfChars) when NumOfChars =< 8 ->\n    3;\ncharbits(NumOfChars) when NumOfChars =< 16 ->\n    4;\ncharbits(NumOfChars) when NumOfChars =< 32 ->\n    5;\ncharbits(NumOfChars) when NumOfChars =< 64 ->\n    6;\ncharbits(NumOfChars) when NumOfChars =< 128 ->\n    7;\ncharbits(NumOfChars) when NumOfChars =< 256 ->\n    8;\ncharbits(NumOfChars) when NumOfChars =< 512 ->\n    9;\ncharbits(NumOfChars) when NumOfChars =< 1024 ->\n    10;\ncharbits(NumOfChars) when NumOfChars =< 2048 ->\n    11;\ncharbits(NumOfChars) when NumOfChars =< 4096 ->\n    12;\ncharbits(NumOfChars) when NumOfChars =< 8192 ->\n    13;\ncharbits(NumOfChars) when NumOfChars =< 16384 ->\n    14;\ncharbits(NumOfChars) when NumOfChars =< 32768 ->\n    15;\ncharbits(NumOfChars) when NumOfChars =< 65536 ->\n    16;\ncharbits(NumOfChars) when is_integer(NumOfChars) ->\n    16 + charbits1(NumOfChars bsr 16).\n">>},
 {{uper,charbits1,1},
  <<"\ncharbits1(0) ->\n    0;\ncharbits1(NumOfChars) ->\n    1 + charbits1(NumOfChars bsr 1).\n">>},
 {{uper,encode_UTF8String,1},
  <<"\nencode_UTF8String(Val) when is_binary(Val) ->\n    [encode_length(byte_size(Val)),Val];\nencode_UTF8String(Val) ->\n    Bin = list_to_binary(Val),\n    encode_UTF8String(Bin).\n">>},
 {{uper,encode_object_identifier,1},
  <<"\nencode_object_identifier(Val) ->\n    OctetList = e_object_identifier(Val),\n    Octets = list_to_binary(OctetList),\n    [encode_length(byte_size(Octets)),Octets].\n">>},
 {{uper,e_object_identifier,1},
  <<"\ne_object_identifier({'OBJECT IDENTIFIER',V}) ->\n    e_object_identifier(V);\ne_object_identifier(V) when is_tuple(V) ->\n    e_object_identifier(tuple_to_list(V));\ne_object_identifier([E1,E2|Tail]) when E1 >= 0, E1 < 2, E2 < 40; E1 == 2 ->\n    Head = 40 * E1 + E2,\n    e_object_elements([Head|Tail], []);\ne_object_identifier(Oid = [_,_|_Tail]) ->\n    exit({error,{asn1,{illegal_value,Oid}}}).\n">>},
 {{uper,e_object_elements,2},
  <<"\ne_object_elements([], Acc) ->\n    lists:reverse(Acc);\ne_object_elements([H|T], Acc) ->\n    e_object_elements(T, [e_object_element(H)|Acc]).\n">>},
 {{uper,e_object_element,1},
  <<"\ne_object_element(Num) when Num < 128 ->\n    [Num];\ne_object_element(Num) ->\n    [e_o_e(Num bsr 7),Num band 127].\n">>},
 {{uper,e_o_e,1},
  <<"\ne_o_e(Num) when Num < 128 ->\n    Num bor 128;\ne_o_e(Num) ->\n    [e_o_e(Num bsr 7),Num band 127 bor 128].\n">>},
 {{uper,encode_relative_oid,1},
  <<"\nencode_relative_oid(Val) when is_tuple(Val) ->\n    encode_relative_oid(tuple_to_list(Val));\nencode_relative_oid(Val) when is_list(Val) ->\n    Octets =\n        list_to_binary([ \n                        e_object_element(X) ||\n                            X <- Val\n                       ]),\n    [encode_length(byte_size(Octets)),Octets].\n">>},
 {{uper,get_constraint,2},
  <<"\nget_constraint([{Key,V}], Key) ->\n    V;\nget_constraint([], _Key) ->\n    no;\nget_constraint(C, Key) ->\n    case lists:keyfind(Key, 1, C) of\n        false ->\n            no;\n        {_,V} ->\n            V\n    end.\n">>},
 {{uper,complete,1},
  <<"\ncomplete(InList) when is_list(InList) ->\n    case complete1(InList) of\n        <<>> ->\n            <<0>>;\n        Res ->\n            case bit_size(Res) band 7 of\n                0 ->\n                    Res;\n                Bits ->\n                    <<Res/bitstring,0:(8 - Bits)>>\n            end\n    end;\ncomplete(InList) when is_binary(InList) ->\n    InList;\ncomplete(InList) when is_bitstring(InList) ->\n    PadLen = 8 - bit_size(InList) band 7,\n    <<InList/bitstring,0:PadLen>>.\n">>},
 {{uper,complete1,1},
  <<"\ncomplete1(L) when is_list(L) ->\n    list_to_bitstring(L).\n">>},
 {{uper,complete_NFP,1},
  <<"\ncomplete_NFP(InList) when is_list(InList) ->\n    list_to_bitstring(InList);\ncomplete_NFP(InList) when is_bitstring(InList) ->\n    InList.\n">>},
 {{uper,num_bits,1},<<"\nnum_bits(N) ->\n    num_bits(N, 1, 0).\n">>},
 {{uper,num_bits,3},
  <<"\nnum_bits(N, T, B) when N =< T ->\n    B;\nnum_bits(N, T, B) ->\n    num_bits(N, T bsl 1, B + 1).\n">>}].

