%% 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,compact_bit_string_size,1}) -> ok;
assert_defined({ber,decode_BMP_string,2}) -> ok;
assert_defined({ber,decode_UTF8_string,2}) -> ok;
assert_defined({ber,decode_boolean,2}) -> ok;
assert_defined({ber,decode_compact_bit_string,2}) -> ok;
assert_defined({ber,decode_integer,2}) -> ok;
assert_defined({ber,decode_named_bit_string,3}) -> ok;
assert_defined({ber,decode_native_bit_string,2}) -> ok;
assert_defined({ber,decode_null,2}) -> ok;
assert_defined({ber,decode_object_identifier,2}) -> ok;
assert_defined({ber,decode_octet_string,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_selective,2}) -> ok;
assert_defined({ber,decode_universal_string,2}) -> 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_integer,2}) -> ok;
assert_defined({ber,encode_integer,3}) -> ok;
assert_defined({ber,encode_named_bit_string,3}) -> ok;
assert_defined({ber,encode_named_bit_string,4}) -> 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,3}) -> ok;
assert_defined({ber,encode_universal_string,2}) -> ok;
assert_defined({ber,encode_unnamed_bit_string,2}) -> ok;
assert_defined({ber,encode_unnamed_bit_string,3}) -> ok;
assert_defined({ber,match_tags,2}) -> ok;
assert_defined({ber,native_to_legacy_bit_string,1}) -> ok;
assert_defined({ber,number2name,2}) -> ok;
assert_defined({ber,skip_ExtensionAdditions,2}) -> ok;
assert_defined({check,check_fail,1}) -> ok;
assert_defined({check,check_int,3}) -> ok;
assert_defined({check,check_legacy_bitstring,2}) -> ok;
assert_defined({check,check_legacy_named_bitstring,3}) -> ok;
assert_defined({check,check_legacy_named_bitstring,4}) -> ok;
assert_defined({check,check_literal_sof,2}) -> ok;
assert_defined({check,check_named_bitstring,3}) -> ok;
assert_defined({check,check_named_bitstring,4}) -> 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,skipextensions,3}) -> ok;
assert_defined({per_common,adjust_trailing_zeroes,2}) -> ok;
assert_defined({per_common,bitstring_from_positions,1}) -> ok;
assert_defined({per_common,bitstring_from_positions,2}) -> ok;
assert_defined({per_common,bs_drop_trailing_zeroes,1}) -> 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({per_common,encode_big_chars,1}) -> ok;
assert_defined({per_common,encode_chars,2}) -> ok;
assert_defined({per_common,encode_chars,3}) -> ok;
assert_defined({per_common,encode_chars_16bit,1}) -> ok;
assert_defined({per_common,encode_chars_compact_map,3}) -> ok;
assert_defined({per_common,encode_fragmented,2}) -> ok;
assert_defined({per_common,encode_oid,1}) -> ok;
assert_defined({per_common,encode_relative_oid,1}) -> ok;
assert_defined({per_common,encode_unconstrained_number,1}) -> ok;
assert_defined({per_common,extension_bitmap,3}) -> ok;
assert_defined({per_common,is_default_bitstring,3}) -> ok;
assert_defined({per_common,is_default_bitstring,5}) -> ok;
assert_defined({per_common,legacy_open_type_to_binary,1}) -> ok;
assert_defined({per_common,open_type_to_binary,1}) -> ok;
assert_defined({per_common,to_bitstring,1}) -> ok;
assert_defined({per_common,to_bitstring,2}) -> ok;
assert_defined({per_common,to_named_bitstring,1}) -> ok;
assert_defined({per_common,to_named_bitstring,2}) -> 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,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,2}) ->
[{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,2}) ->
[{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_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,2}) ->
[{ber,match_tags,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,2}) ->
[{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_octet_string,2}) ->
[{ber,match_and_collect,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_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,2}) ->
[{ber,match_and_collect,2},{ber,mk_universal_string,1}];
dependencies({ber,do_encode_named_bit_string,3}) ->
[{ber,encode_bitstring,1},
 {ber,encode_tags,3},
 {ber,get_all_bitposes,3},
 {ber,make_and_set_list,3}];
dependencies({ber,do_encode_named_bit_string,4}) ->
[{ber,encode_bitstring,1},
 {ber,encode_tags,3},
 {ber,get_all_bitposes,3},
 {ber,make_and_set_list,3}];
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,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,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,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_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_named_bit_string,3}) ->
[{ber,do_encode_named_bit_string,3},{ber,encode_unnamed_bit_string,2}];
dependencies({ber,encode_named_bit_string,4}) ->
[{ber,do_encode_named_bit_string,4},{ber,encode_unnamed_bit_string,3}];
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_unnamed_bit_string,2}) ->
[{ber,encode_tags,3}];
dependencies({ber,encode_unnamed_bit_string,3}) ->
[{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,check_bitstring,2}) ->
[{check,check_bitstring_integer,2},{check,check_bitstring_list,2}];
dependencies({check,check_legacy_bitstring,2}) ->
[{check,check_bitstring,2}];
dependencies({check,check_legacy_named_bitstring,3}) ->
[{check,check_named_bitstring,3},{check,legacy_int_to_bitlist,1}];
dependencies({check,check_legacy_named_bitstring,4}) ->
[{check,check_named_bitstring,4},{check,legacy_int_to_bitlist,1}];
dependencies({check,check_objectidentifier,2}) ->
[{check,check_oid,3}];
dependencies({check,check_restrictedstring,2}) ->
[{check,check_restrictedstring,2}];
dependencies({ext,transform_to_EXTERNAL1990,1}) ->
[{ext,transform_to_EXTERNAL1990,2}];
dependencies({ext,transform_to_EXTERNAL1990,2}) ->
[{ext,transform_to_EXTERNAL1990,2}];
dependencies({per,complete,1}) ->
[{per,complete,2}];
dependencies({per,complete,2}) ->
[{per,complete,2},{per,complete,3}];
dependencies({per,complete,3}) ->
[{per,complete,2},{per,complete,3}];
dependencies({per,decode_length,1}) ->
[{per,align,1}];
dependencies({per,skipextensions,3}) ->
[{per,decode_length,1},{per,skipextensions,3}];
dependencies({per_common,adjust_trailing_zeroes,2}) ->
[{per_common,bs_drop_trailing_zeroes,1}];
dependencies({per_common,bitstring_from_positions,1}) ->
[{per_common,diff,2}];
dependencies({per_common,bitstring_from_positions,2}) ->
[{per_common,diff,3}];
dependencies({per_common,bs_drop_trailing_zeroes,1}) ->
[{per_common,bs_drop_trailing_zeroes,2}];
dependencies({per_common,bs_drop_trailing_zeroes,2}) ->
[{per_common,ntz,1}];
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({per_common,e_object_element,1}) ->
[{per_common,e_o_e,1}];
dependencies({per_common,e_object_elements,2}) ->
[{per_common,e_object_element,1}];
dependencies({per_common,e_object_identifier,1}) ->
[{per_common,e_object_elements,2}];
dependencies({per_common,enc_char,3}) ->
[{per_common,illegal_char_error,0}];
dependencies({per_common,enc_char_cm,3}) ->
[{per_common,illegal_char_error,0}];
dependencies({per_common,encode_chars,3}) ->
[{per_common,enc_char,3}];
dependencies({per_common,encode_chars_compact_map,3}) ->
[{per_common,enc_char_cm,3}];
dependencies({per_common,encode_fragmented,2}) ->
[{per_common,encode_fragmented_1,3}];
dependencies({per_common,encode_fragmented_1,3}) ->
[{per_common,encode_fragmented_1,3}];
dependencies({per_common,encode_oid,1}) ->
[{per_common,e_object_identifier,1}];
dependencies({per_common,encode_relative_oid,1}) ->
[{per_common,e_object_element,1}];
dependencies({per_common,encode_unconstrained_number,1}) ->
[{per_common,enint,2}];
dependencies({per_common,extension_bitmap,3}) ->
[{per_common,extension_bitmap,4}];
dependencies({per_common,is_default_bitstring,5}) ->
[{per_common,is_default_bitstring_list,2}];
dependencies({per_common,to_bitstring,1}) ->
[{per_common,int_to_bitlist,1}];
dependencies({per_common,to_bitstring,2}) ->
[{per_common,adjust_size,2},{per_common,int_to_bitlist,1}];
dependencies({per_common,to_named_bitstring,1}) ->
[{per_common,bs_drop_trailing_zeroes,1},{per_common,to_bitstring,1}];
dependencies({per_common,to_named_bitstring,2}) ->
[{per_common,adjust_trailing_zeroes,2},{per_common,to_bitstring,1}];
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,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, 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,2},
  <<"\ndecode_integer(Tlv, TagIn) ->\n    Bin = match_tags(Tlv, TagIn),\n    Len = byte_size(Bin),\n    <<Int:Len/signed-unit:8>> = Bin,\n    Int.\n">>},
 {{ber,number2name,2},
  <<"\nnumber2name(Int, NamedNumberList) ->\n    case lists:keyfind(Int, 2, NamedNumberList) of\n        {NamedVal,_} ->\n            NamedVal;\n        _ ->\n            Int\n    end.\n">>},
 {{ber,encode_unnamed_bit_string,2},
  <<"\nencode_unnamed_bit_string(Bits, TagIn) ->\n    Unused = (8 - bit_size(Bits) band 7) band 7,\n    Bin = <<Unused,Bits/bitstring,0:Unused>>,\n    encode_tags(TagIn, Bin, byte_size(Bin)).\n">>},
 {{ber,encode_unnamed_bit_string,3},
  <<"\nencode_unnamed_bit_string(MaxBits, Bits, TagIn) ->\n    NumBits = bit_size(Bits),\n    Unused = (8 - NumBits band 7) band 7,\n    Bin = <<Unused,Bits/bitstring,0:Unused>>,\n    if\n        NumBits > MaxBits ->\n            exit({error,\n                  {asn1,\n                   {bitstring_length,{{was,NumBits},{maximum,MaxBits}}}}});\n        true ->\n            encode_tags(TagIn, Bin, byte_size(Bin))\n    end.\n">>},
 {{ber,encode_named_bit_string,3},
  <<"\nencode_named_bit_string([H|_] = Bits, NamedBitList, TagIn)\n    when is_atom(H) ->\n    do_encode_named_bit_string(Bits, NamedBitList, TagIn);\nencode_named_bit_string([{bit,_}|_] = Bits, NamedBitList, TagIn) ->\n    do_encode_named_bit_string(Bits, NamedBitList, TagIn);\nencode_named_bit_string([], _NamedBitList, TagIn) ->\n    encode_unnamed_bit_string(<<>>, TagIn);\nencode_named_bit_string(Bits, _NamedBitList, TagIn)\n    when is_bitstring(Bits) ->\n    encode_unnamed_bit_string(Bits, TagIn).\n">>},
 {{ber,encode_named_bit_string,4},
  <<"\nencode_named_bit_string(C, [H|_] = Bits, NamedBitList, TagIn)\n    when is_atom(H) ->\n    do_encode_named_bit_string(C, Bits, NamedBitList, TagIn);\nencode_named_bit_string(C, [{bit,_}|_] = Bits, NamedBitList, TagIn) ->\n    do_encode_named_bit_string(C, Bits, NamedBitList, TagIn);\nencode_named_bit_string(C, [], _NamedBitList, TagIn) ->\n    encode_unnamed_bit_string(C, <<>>, TagIn);\nencode_named_bit_string(C, Bits, _NamedBitList, TagIn)\n    when is_bitstring(Bits) ->\n    encode_unnamed_bit_string(C, Bits, TagIn).\n">>},
 {{ber,do_encode_named_bit_string,3},
  <<"\ndo_encode_named_bit_string([FirstVal|RestVal], NamedBitList, TagIn) ->\n    ToSetPos = get_all_bitposes([FirstVal|RestVal], NamedBitList, []),\n    Size = lists:max(ToSetPos) + 1,\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,do_encode_named_bit_string,4},
  <<"\ndo_encode_named_bit_string(Size,\n                           [FirstVal|RestVal],\n                           NamedBitList,\n                           TagIn) ->\n    ToSetPos = get_all_bitposes([FirstVal|RestVal], NamedBitList, []),\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,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 C of\n        [] ->\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 C of\n            [] ->\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 C of\n        [] ->\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 when is_integer(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,2},
  <<"\ndecode_compact_bit_string(Buffer, Tags) ->\n    case match_and_collect(Buffer, Tags) of\n        <<0>> ->\n            {0,<<>>};\n        <<Unused,Bits/binary>> ->\n            {Unused,Bits}\n    end.\n">>},
 {{ber,compact_bit_string_size,1},
  <<"\ncompact_bit_string_size({Unused,Bits}) ->\n    bit_size(Bits) - Unused.\n">>},
 {{ber,decode_native_bit_string,2},
  <<"\ndecode_native_bit_string(Buffer, Tags) ->\n    case match_and_collect(Buffer, Tags) of\n        <<0>> ->\n            <<>>;\n        <<Unused,Bits/binary>> ->\n            Size = bit_size(Bits) - Unused,\n            <<Val:Size/bitstring,_:Unused/bitstring>> = Bits,\n            Val\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,native_to_legacy_bit_string,1},
  <<"\nnative_to_legacy_bit_string(Bits) ->\n    [ \n     B ||\n         <<B:1>> <= Bits\n    ].\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_octet_string,2},
  <<"\ndecode_octet_string(Tlv, TagsIn) ->\n    Bin = match_and_collect(Tlv, TagsIn),\n    binary:copy(Bin).\n">>},
 {{ber,decode_restricted_string,2},
  <<"\ndecode_restricted_string(Tlv, TagsIn) ->\n    match_and_collect(Tlv, TagsIn).\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,2},
  <<"\ndecode_universal_string(Buffer, Tags) ->\n    Bin = match_and_collect(Buffer, Tags),\n    mk_universal_string(binary_to_list(Bin)).\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,2},
  <<"\ndecode_BMP_string(Buffer, Tags) ->\n    Bin = match_and_collect(Buffer, Tags),\n    mk_BMP_string(binary_to_list(Bin)).\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_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,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_fail,1},<<"\ncheck_fail(_) ->\n    throw(false).\n">>},
 {{check,check_int,3},
  <<"\ncheck_int(Value, Value, _) when is_integer(Value) ->\n    true;\ncheck_int(Value, DefValue, NNL) when is_atom(Value) ->\n    case lists:keyfind(Value, 1, NNL) of\n        {_,DefValue} ->\n            true;\n        _ ->\n            throw(false)\n    end;\ncheck_int(_, _, _) ->\n    throw(false).\n">>},
 {{check,check_legacy_bitstring,2},
  <<"\ncheck_legacy_bitstring(Value, Default) ->\n    check_bitstring(Default, Value).\n">>},
 {{check,check_bitstring,2},
  <<"\ncheck_bitstring(DefVal, {Unused,Binary}) ->\n    Sz = bit_size(Binary) - Unused,\n    <<Val:Sz/bitstring,_:Unused>> = Binary,\n    check_bitstring(DefVal, Val);\ncheck_bitstring(DefVal, Val) when is_bitstring(Val) ->\n    case Val =:= DefVal of\n        false ->\n            throw(false);\n        true ->\n            true\n    end;\ncheck_bitstring(Def, Val) when is_list(Val) ->\n    check_bitstring_list(Def, Val);\ncheck_bitstring(Def, Val) when is_integer(Val) ->\n    check_bitstring_integer(Def, Val).\n">>},
 {{check,check_bitstring_list,2},
  <<"\ncheck_bitstring_list(<<H:1,T1/bitstring>>, [H|T2]) ->\n    check_bitstring_list(T1, T2);\ncheck_bitstring_list(<<>>, []) ->\n    true;\ncheck_bitstring_list(_, _) ->\n    throw(false).\n">>},
 {{check,check_bitstring_integer,2},
  <<"\ncheck_bitstring_integer(<<H:1,T1/bitstring>>, Int) when H =:= Int band 1 ->\n    check_bitstring_integer(T1, Int bsr 1);\ncheck_bitstring_integer(<<>>, 0) ->\n    true;\ncheck_bitstring_integer(_, _) ->\n    throw(false).\n">>},
 {{check,check_legacy_named_bitstring,3},
  <<"\ncheck_legacy_named_bitstring([Int|_] = Val, Bs, BsSize)\n    when is_integer(Int) ->\n    check_named_bitstring(<< \n                            <<B:1>> ||\n                                B <- Val\n                          >>,\n                          Bs,\n                          BsSize);\ncheck_legacy_named_bitstring({Unused,Val0}, Bs, BsSize) ->\n    Sz = bit_size(Val0) - Unused,\n    <<Val:Sz/bits,_/bits>> = Val0,\n    check_named_bitstring(Val, Bs, BsSize);\ncheck_legacy_named_bitstring(Val, Bs, BsSize) when is_integer(Val) ->\n    L = legacy_int_to_bitlist(Val),\n    check_named_bitstring(<< \n                            <<B:1>> ||\n                                B <- L\n                          >>,\n                          Bs,\n                          BsSize);\ncheck_legacy_named_bitstring(Val, Bs, BsSize) ->\n    check_named_bitstring(Val, Bs, BsSize).\n">>},
 {{check,check_legacy_named_bitstring,4},
  <<"\ncheck_legacy_named_bitstring([Int|_] = Val, Names, Bs, BsSize)\n    when is_integer(Int) ->\n    check_named_bitstring(<< \n                            <<B:1>> ||\n                                B <- Val\n                          >>,\n                          Names,\n                          Bs,\n                          BsSize);\ncheck_legacy_named_bitstring({Unused,Val0}, Names, Bs, BsSize) ->\n    Sz = bit_size(Val0) - Unused,\n    <<Val:Sz/bits,_/bits>> = Val0,\n    check_named_bitstring(Val, Names, Bs, BsSize);\ncheck_legacy_named_bitstring(Val, Names, Bs, BsSize)\n    when is_integer(Val) ->\n    L = legacy_int_to_bitlist(Val),\n    check_named_bitstring(<< \n                            <<B:1>> ||\n                                B <- L\n                          >>,\n                          Names,\n                          Bs,\n                          BsSize);\ncheck_legacy_named_bitstring(Val, Names, Bs, BsSize) ->\n    check_named_bitstring(Val, Names, Bs, BsSize).\n">>},
 {{check,legacy_int_to_bitlist,1},
  <<"\nlegacy_int_to_bitlist(0) ->\n    [];\nlegacy_int_to_bitlist(Int) ->\n    [Int band 1|legacy_int_to_bitlist(Int bsr 1)].\n">>},
 {{check,check_named_bitstring,3},
  <<"\ncheck_named_bitstring(Bs, Bs, _) ->\n    true;\ncheck_named_bitstring(Val, Bs, BsSize) ->\n    Rest = bit_size(Val) - BsSize,\n    case Val of\n        <<Bs:BsSize/bits,0:Rest>> ->\n            true;\n        _ ->\n            throw(false)\n    end.\n">>},
 {{check,check_named_bitstring,4},
  <<"\ncheck_named_bitstring([_|_] = Val, Names, _, _) ->\n    case lists:sort(Val) of\n        Names ->\n            true;\n        _ ->\n            throw(false)\n    end;\ncheck_named_bitstring(Bs, _, Bs, _) ->\n    true;\ncheck_named_bitstring(Val, _, Bs, BsSize) ->\n    Rest = bit_size(Val) - BsSize,\n    case Val of\n        <<Bs:BsSize/bits,0:Rest>> ->\n            true;\n        _ ->\n            throw(false)\n    end.\n">>},
 {{check,check_octetstring,2},
  <<"\ncheck_octetstring(V, V) ->\n    true;\ncheck_octetstring(V, Def) when is_list(V) ->\n    case list_to_binary(V) of\n        Def ->\n            true;\n        _ ->\n            throw(false)\n    end;\ncheck_octetstring(_, _) ->\n    throw(false).\n">>},
 {{check,check_objectidentifier,2},
  <<"\ncheck_objectidentifier(Value, {Prefix,Tail}) when is_tuple(Value) ->\n    check_oid(tuple_to_list(Value), Prefix, Tail);\ncheck_objectidentifier(_, _) ->\n    throw(false).\n">>},
 {{check,check_oid,3},
  <<"\ncheck_oid([H|T], [K|Ks], Tail) ->\n    case lists:member(H, K) of\n        false ->\n            throw(false);\n        true ->\n            check_oid(T, Ks, Tail)\n    end;\ncheck_oid(Tail, [], Tail) ->\n    true;\ncheck_oid(_, _, _) ->\n    throw(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_restrictedstring,2},
  <<"\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_tuple(V1) ->\n    check_restrictedstring(tuple_to_list(V1), V2);\ncheck_restrictedstring(_, _) ->\n    throw(false).\n">>},
 {{check,check_literal_sof,2},
  <<"\ncheck_literal_sof(Value, Default) ->\n    case lists:sort(Value) of\n        Default ->\n            true;\n        _ ->\n            throw(false)\n    end.\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); is_binary(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,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,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,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,complete,1},
  <<"\ncomplete(L0) ->\n    L = complete(L0, []),\n    case list_to_bitstring(L) of\n        <<>> ->\n            <<0>>;\n        Bin ->\n            Bin\n    end.\n">>},
 {{per,complete,2},
  <<"\ncomplete([], []) ->\n    [];\ncomplete([], [H|More]) ->\n    complete(H, More);\ncomplete([align|T], More) ->\n    complete(T, More);\ncomplete([[]|T], More) ->\n    complete(T, More);\ncomplete([[_|_] = H], More) ->\n    complete(H, More);\ncomplete([[_|_] = H|T], More) ->\n    complete(H, [T|More]);\ncomplete([H|T], More) when is_integer(H); is_binary(H) ->\n    [H|complete(T, More)];\ncomplete([H|T], More) ->\n    [H|complete(T, bit_size(H), More)];\ncomplete(Bin, More) when is_binary(Bin) ->\n    [Bin|complete([], More)];\ncomplete(Bin, More) ->\n    [Bin|complete([], bit_size(Bin), More)].\n">>},
 {{per,complete,3},
  <<"\ncomplete([], Bits, []) ->\n    case Bits band 7 of\n        0 ->\n            [];\n        N ->\n            [<<0:(8 - N)>>]\n    end;\ncomplete([], Bits, [H|More]) ->\n    complete(H, Bits, More);\ncomplete([align|T], Bits, More) ->\n    case Bits band 7 of\n        0 ->\n            complete(T, More);\n        1 ->\n            [<<0:7>>|complete(T, More)];\n        2 ->\n            [<<0:6>>|complete(T, More)];\n        3 ->\n            [<<0:5>>|complete(T, More)];\n        4 ->\n            [<<0:4>>|complete(T, More)];\n        5 ->\n            [<<0:3>>|complete(T, More)];\n        6 ->\n            [<<0:2>>|complete(T, More)];\n        7 ->\n            [<<0:1>>|complete(T, More)]\n    end;\ncomplete([[]|T], Bits, More) ->\n    complete(T, Bits, More);\ncomplete([[_|_] = H], Bits, More) ->\n    complete(H, Bits, More);\ncomplete([[_|_] = H|T], Bits, More) ->\n    complete(H, Bits, [T|More]);\ncomplete([H|T], Bits, More) when is_integer(H); is_binary(H) ->\n    [H|complete(T, Bits, More)];\ncomplete([H|T], Bits, More) ->\n    [H|complete(T, Bits + bit_size(H), More)];\ncomplete(Bin, Bits, More) when is_binary(Bin) ->\n    [Bin|complete([], Bits, More)];\ncomplete(Bin, Bits, More) ->\n    [Bin|complete([], Bits + bit_size(Bin), More)].\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,encode_chars,2},
  <<"\nencode_chars(Val, NumBits) ->\n    << \n      <<C:NumBits>> ||\n          C <- Val\n    >>.\n">>},
 {{per_common,encode_chars,3},
  <<"\nencode_chars(Val, NumBits, {Lb,Tab}) ->\n    << \n      <<(enc_char(C, Lb, Tab)):NumBits>> ||\n          C <- Val\n    >>.\n">>},
 {{per_common,encode_chars_compact_map,3},
  <<"\nencode_chars_compact_map(Val, NumBits, {Lb,Limit}) ->\n    << \n      <<(enc_char_cm(C, Lb, Limit)):NumBits>> ||\n          C <- Val\n    >>.\n">>},
 {{per_common,encode_chars_16bit,1},
  <<"\nencode_chars_16bit(Val) ->\n    L = [ \n         case C of\n             {0,0,A,B} ->\n                 [A,B];\n             C when is_integer(C) ->\n                 [0,C]\n         end ||\n             C <- Val\n        ],\n    iolist_to_binary(L).\n">>},
 {{per_common,encode_big_chars,1},
  <<"\nencode_big_chars(Val) ->\n    L = [ \n         case C of\n             {_,_,_,_} ->\n                 tuple_to_list(C);\n             C when is_integer(C) ->\n                 [<<0,0,0>>,C]\n         end ||\n             C <- Val\n        ],\n    iolist_to_binary(L).\n">>},
 {{per_common,encode_fragmented,2},
  <<"\nencode_fragmented(Bin, Unit) ->\n    encode_fragmented_1(Bin, Unit, 4).\n">>},
 {{per_common,encode_oid,1},
  <<"\nencode_oid(Val) when is_tuple(Val) ->\n    encode_oid(tuple_to_list(Val));\nencode_oid(Val) ->\n    iolist_to_binary(e_object_identifier(Val)).\n">>},
 {{per_common,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    list_to_binary([ \n                    e_object_element(X) ||\n                        X <- Val\n                   ]).\n">>},
 {{per_common,encode_unconstrained_number,1},
  <<"\nencode_unconstrained_number(Val) when Val >= 0 ->\n    if\n        Val < 128 ->\n            [1,Val];\n        Val < 256 ->\n            [<<2,0>>,Val];\n        true ->\n            case binary:encode_unsigned(Val) of\n                <<0:1,_/bitstring>> = Bin ->\n                    case byte_size(Bin) of\n                        Sz when Sz < 128 ->\n                            [Sz,Bin];\n                        Sz when Sz < 16384 ->\n                            [<<2:2,Sz:14>>,Bin]\n                    end;\n                <<1:1,_/bitstring>> = Bin ->\n                    case byte_size(Bin) + 1 of\n                        Sz when Sz < 128 ->\n                            [Sz,0,Bin];\n                        Sz when Sz < 16384 ->\n                            [<<2:2,Sz:14,0:8>>,Bin]\n                    end\n            end\n    end;\nencode_unconstrained_number(Val) ->\n    Oct = enint(Val, []),\n    Len = length(Oct),\n    if\n        Len < 128 ->\n            [Len|Oct];\n        Len < 16384 ->\n            [<<2:2,Len:14>>|Oct]\n    end.\n">>},
 {{per_common,bitstring_from_positions,1},
  <<"\nbitstring_from_positions([]) ->\n    <<>>;\nbitstring_from_positions([_|_] = L0) ->\n    L1 = lists:sort(L0),\n    L = diff(L1, - 1),\n    << \n      <<1:(N + 0)>> ||\n          N <- L\n    >>.\n">>},
 {{per_common,bitstring_from_positions,2},
  <<"\nbitstring_from_positions(L0, Lb) ->\n    L1 = lists:sort(L0),\n    L = diff(L1, - 1, Lb - 1),\n    << \n      <<B:(N + 0)>> ||\n          {B,N} <- L\n    >>.\n">>},
 {{per_common,to_bitstring,1},
  <<"\nto_bitstring({0,Bs}) when is_binary(Bs) ->\n    Bs;\nto_bitstring({Unused,Bs0}) when is_binary(Bs0) ->\n    Sz = bit_size(Bs0) - Unused,\n    <<Bs:Sz/bits,_/bits>> = Bs0,\n    Bs;\nto_bitstring(Bs) when is_bitstring(Bs) ->\n    Bs;\nto_bitstring(Int) when is_integer(Int), Int >= 0 ->\n    L = int_to_bitlist(Int),\n    << \n      <<B:1>> ||\n          B <- L\n    >>;\nto_bitstring(L) when is_list(L) ->\n    << \n      <<B:1>> ||\n          B <- L\n    >>.\n">>},
 {{per_common,to_bitstring,2},
  <<"\nto_bitstring({0,Bs}, Lb) when is_binary(Bs) ->\n    case bit_size(Bs) of\n        Sz when Sz < Lb ->\n            <<Bs/bits,0:(Lb - Sz)>>;\n        _ ->\n            Bs\n    end;\nto_bitstring({Unused,Bs0}, Lb) when is_binary(Bs0) ->\n    Sz = bit_size(Bs0) - Unused,\n    if\n        Sz < Lb ->\n            <<Bs0:Sz/bits,0:(Lb - Sz)>>;\n        true ->\n            <<Bs:Sz/bits,_/bits>> = Bs0,\n            Bs\n    end;\nto_bitstring(Bs, Lb) when is_bitstring(Bs) ->\n    adjust_size(Bs, Lb);\nto_bitstring(Int, Lb) when is_integer(Int), Int >= 0 ->\n    L = int_to_bitlist(Int),\n    Bs =\n        << \n          <<B:1>> ||\n              B <- L\n        >>,\n    adjust_size(Bs, Lb);\nto_bitstring(L, Lb) when is_list(L) ->\n    Bs =\n        << \n          <<B:1>> ||\n              B <- L\n        >>,\n    adjust_size(Bs, Lb).\n">>},
 {{per_common,to_named_bitstring,1},
  <<"\nto_named_bitstring(Val) ->\n    Bs = to_bitstring(Val),\n    bs_drop_trailing_zeroes(Bs).\n">>},
 {{per_common,to_named_bitstring,2},
  <<"\nto_named_bitstring({0,Bs}, Lb) when is_binary(Bs) ->\n    adjust_trailing_zeroes(Bs, Lb);\nto_named_bitstring({Unused,Bs0}, Lb) when is_binary(Bs0) ->\n    Sz = bit_size(Bs0) - Unused,\n    <<Bs:Sz/bits,_/bits>> = Bs0,\n    adjust_trailing_zeroes(Bs, Lb);\nto_named_bitstring(Bs, Lb) when is_bitstring(Bs) ->\n    adjust_trailing_zeroes(Bs, Lb);\nto_named_bitstring(Val, Lb) ->\n    adjust_trailing_zeroes(to_bitstring(Val), Lb).\n">>},
 {{per_common,is_default_bitstring,3},
  <<"\nis_default_bitstring(asn1_DEFAULT, _, _) ->\n    true;\nis_default_bitstring(Named, Named, _) ->\n    true;\nis_default_bitstring(Bs, _, Bs) ->\n    true;\nis_default_bitstring(Val, _, Def) when is_bitstring(Val) ->\n    Sz = bit_size(Def),\n    case Val of\n        <<Def:Sz/bitstring,T/bitstring>> ->\n            NumZeroes = bit_size(T),\n            case T of\n                <<0:NumZeroes>> ->\n                    true;\n                _ ->\n                    false\n            end;\n        _ ->\n            false\n    end.\n">>},
 {{per_common,is_default_bitstring,5},
  <<"\nis_default_bitstring(asn1_DEFAULT, _, _, _, _) ->\n    true;\nis_default_bitstring({Unused,Bin}, V0, V1, V2, V3)\n    when is_integer(Unused) ->\n    Sz = bit_size(Bin) - Unused,\n    <<Bs:Sz/bitstring,_:Unused>> = Bin,\n    is_default_bitstring(Bs, V0, V1, V2, V3);\nis_default_bitstring(Named, Named, _, _, _) ->\n    true;\nis_default_bitstring(Bs, _, Bs, _, _) ->\n    true;\nis_default_bitstring(List, _, _, List, _) ->\n    true;\nis_default_bitstring(Int, _, _, _, Int) ->\n    true;\nis_default_bitstring(Val, _, Def, _, _) when is_bitstring(Val) ->\n    Sz = bit_size(Def),\n    case Val of\n        <<Def:Sz/bitstring,T/bitstring>> ->\n            NumZeroes = bit_size(T),\n            case T of\n                <<0:NumZeroes>> ->\n                    true;\n                _ ->\n                    false\n            end;\n        _ ->\n            false\n    end;\nis_default_bitstring(Val, _, _, List, _) when is_list(Val) ->\n    is_default_bitstring_list(List, Val);\nis_default_bitstring(_, _, _, _, _) ->\n    false.\n">>},
 {{per_common,extension_bitmap,3},
  <<"\nextension_bitmap(Val, Pos, Limit) ->\n    extension_bitmap(Val, Pos, Limit, 0).\n">>},
 {{per_common,open_type_to_binary,1},
  <<"\nopen_type_to_binary({asn1_OPENTYPE,Bin}) when is_binary(Bin) ->\n    Bin.\n">>},
 {{per_common,legacy_open_type_to_binary,1},
  <<"\nlegacy_open_type_to_binary({asn1_OPENTYPE,Bin}) when is_binary(Bin) ->\n    Bin;\nlegacy_open_type_to_binary(Bin) when is_binary(Bin) ->\n    Bin;\nlegacy_open_type_to_binary(List) when is_list(List) ->\n    List.\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">>},
 {{per_common,enc_char,3},
  <<"\nenc_char(C0, Lb, Tab) ->\n    try element(C0 - Lb, Tab) of\n        ill ->\n            illegal_char_error();\n        C ->\n            C\n    catch\n        error:badarg ->\n            illegal_char_error()\n    end.\n">>},
 {{per_common,enc_char_cm,3},
  <<"\nenc_char_cm(C0, Lb, Limit) ->\n    C = C0 - Lb,\n    if\n        0 =< C, C < Limit ->\n            C;\n        true ->\n            illegal_char_error()\n    end.\n">>},
 {{per_common,illegal_char_error,0},
  <<"\nillegal_char_error() ->\n    error({error,{asn1,\"value forbidden by FROM constraint\"}}).\n">>},
 {{per_common,encode_fragmented_1,3},
  <<"\nencode_fragmented_1(Bin, Unit, N) ->\n    SegSz = Unit * N * 16384,\n    case Bin of\n        <<B:SegSz/bitstring,T/bitstring>> ->\n            [<<3:2,N:6>>,B|encode_fragmented_1(T, Unit, N)];\n        _ when N > 1 ->\n            encode_fragmented_1(Bin, Unit, N - 1);\n        _ ->\n            case bit_size(Bin) div Unit of\n                Len when Len < 128 ->\n                    [Len,Bin];\n                Len when Len < 16384 ->\n                    [<<2:2,Len:14>>,Bin]\n            end\n    end.\n">>},
 {{per_common,e_object_identifier,1},
  <<"\ne_object_identifier([E1,E2|Tail])\n    when E1 >= 0, E1 < 2, E2 < 40; E1 =:= 2 ->\n    Head = 40 * E1 + E2,\n    e_object_elements([Head|Tail], []);\ne_object_identifier([_,_|_Tail] = Oid) ->\n    exit({error,{asn1,{illegal_value,Oid}}}).\n">>},
 {{per_common,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_common,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_common,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_common,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_common,diff,2},
  <<"\ndiff([H|T], Prev) ->\n    [H - Prev|diff(T, H)];\ndiff([], _) ->\n    [].\n">>},
 {{per_common,diff,3},
  <<"\ndiff([H|T], Prev, Last) ->\n    [{1,H - Prev}|diff(T, H, Last)];\ndiff([], Prev, Last) when Last >= Prev ->\n    [{0,Last - Prev}];\ndiff([], _, _) ->\n    [].\n">>},
 {{per_common,int_to_bitlist,1},
  <<"\nint_to_bitlist(0) ->\n    [];\nint_to_bitlist(Int) ->\n    [Int band 1|int_to_bitlist(Int bsr 1)].\n">>},
 {{per_common,adjust_size,2},
  <<"\nadjust_size(Bs, Lb) ->\n    case bit_size(Bs) of\n        Sz when Sz < Lb ->\n            <<Bs:Sz/bits,0:(Lb - Sz)>>;\n        _ ->\n            Bs\n    end.\n">>},
 {{per_common,adjust_trailing_zeroes,2},
  <<"\nadjust_trailing_zeroes(Bs0, Lb) ->\n    case bit_size(Bs0) of\n        Sz when Sz < Lb ->\n            <<Bs0:Sz/bits,0:(Lb - Sz)>>;\n        Lb ->\n            Bs0;\n        _ ->\n            <<_:Lb/bits,Tail/bits>> = Bs0,\n            Sz = Lb + bit_size(bs_drop_trailing_zeroes(Tail)),\n            <<Bs:Sz/bits,_/bits>> = Bs0,\n            Bs\n    end.\n">>},
 {{per_common,bs_drop_trailing_zeroes,1},
  <<"\nbs_drop_trailing_zeroes(Bs) ->\n    bs_drop_trailing_zeroes(Bs, bit_size(Bs)).\n">>},
 {{per_common,bs_drop_trailing_zeroes,2},
  <<"\nbs_drop_trailing_zeroes(Bs, 0) ->\n    Bs;\nbs_drop_trailing_zeroes(Bs0, Sz0) when Sz0 < 8 ->\n    <<Byte:Sz0>> = Bs0,\n    Sz = Sz0 - ntz(Byte),\n    <<Bs:Sz/bits,_/bits>> = Bs0,\n    Bs;\nbs_drop_trailing_zeroes(Bs0, Sz0) ->\n    Sz1 = Sz0 - 8,\n    <<Bs1:Sz1/bits,Byte:8>> = Bs0,\n    case ntz(Byte) of\n        8 ->\n            bs_drop_trailing_zeroes(Bs1, Sz1);\n        Ntz ->\n            Sz = Sz0 - Ntz,\n            <<Bs:Sz/bits,_:Ntz/bits>> = Bs0,\n            Bs\n    end.\n">>},
 {{per_common,ntz,1},
  <<"\nntz(Byte) ->\n    T = {8,\n         0,\n         1,\n         0,\n         2,\n         0,\n         1,\n         0,\n         3,\n         0,\n         1,\n         0,\n         2,\n         0,\n         1,\n         0,\n         4,\n         0,\n         1,\n         0,\n         2,\n         0,\n         1,\n         0,\n         3,\n         0,\n         1,\n         0,\n         2,\n         0,\n         1,\n         0,\n         5,\n         0,\n         1,\n         0,\n         2,\n         0,\n         1,\n         0,\n         3,\n         0,\n         1,\n         0,\n         2,\n         0,\n         1,\n         0,\n         4,\n         0,\n         1,\n         0,\n         2,\n         0,\n         1,\n         0,\n         3,\n         0,\n         1,\n         0,\n         2,\n         0,\n         1,\n         0,\n         6,\n         0,\n         1,\n         0,\n         2,\n         0,\n         1,\n         0,\n         3,\n         0,\n         1,\n         0,\n         2,\n         0,\n         1,\n         0,\n         4,\n         0,\n         1,\n         0,\n         2,\n         0,\n         1,\n         0,\n         3,\n         0,\n         1,\n         0,\n         2,\n         0,\n         1,\n         0,\n         5,\n         0,\n         1,\n         0,\n         2,\n         0,\n         1,\n         0,\n         3,\n         0,\n         1,\n         0,\n         2,\n         0,\n         1,\n         0,\n         4,\n         0,\n         1,\n         0,\n         2,\n         0,\n         1,\n         0,\n         3,\n         0,\n         1,\n         0,\n         2,\n         0,\n         1,\n         0,\n         7,\n         0,\n         1,\n         0,\n         2,\n         0,\n         1,\n         0,\n         3,\n         0,\n         1,\n         0,\n         2,\n         0,\n         1,\n         0,\n         4,\n         0,\n         1,\n         0,\n         2,\n         0,\n         1,\n         0,\n         3,\n         0,\n         1,\n         0,\n         2,\n         0,\n         1,\n         0,\n         5,\n         0,\n         1,\n         0,\n         2,\n         0,\n         1,\n         0,\n         3,\n         0,\n         1,\n         0,\n         2,\n         0,\n         1,\n         0,\n         4,\n         0,\n         1,\n         0,\n         2,\n         0,\n         1,\n         0,\n         3,\n         0,\n         1,\n         0,\n         2,\n         0,\n         1,\n         0,\n         6,\n         0,\n         1,\n         0,\n         2,\n         0,\n         1,\n         0,\n         3,\n         0,\n         1,\n         0,\n         2,\n         0,\n         1,\n         0,\n         4,\n         0,\n         1,\n         0,\n         2,\n         0,\n         1,\n         0,\n         3,\n         0,\n         1,\n         0,\n         2,\n         0,\n         1,\n         0,\n         5,\n         0,\n         1,\n         0,\n         2,\n         0,\n         1,\n         0,\n         3,\n         0,\n         1,\n         0,\n         2,\n         0,\n         1,\n         0,\n         4,\n         0,\n         1,\n         0,\n         2,\n         0,\n         1,\n         0,\n         3,\n         0,\n         1,\n         0,\n         2,\n         0,\n         1,\n         0},\n    element(Byte + 1, T).\n">>},
 {{per_common,is_default_bitstring_list,2},
  <<"\nis_default_bitstring_list([H|Def], [H|Val]) ->\n    is_default_bitstring_list(Def, Val);\nis_default_bitstring_list([], []) ->\n    true;\nis_default_bitstring_list([], [_|_] = Val) ->\n    lists:all(fun(0) ->\n                     true;\n                 (_) ->\n                     false\n              end,\n              Val);\nis_default_bitstring_list(_, _) ->\n    false.\n">>},
 {{per_common,extension_bitmap,4},
  <<"\nextension_bitmap(_Val, Pos, Limit, Acc) when Pos >= Limit ->\n    Acc;\nextension_bitmap(Val, Pos, Limit, Acc) ->\n    Bit =\n        case element(Pos, Val) of\n            asn1_NOVALUE ->\n                0;\n            _ ->\n                1\n        end,\n    extension_bitmap(Val, Pos + 1, Limit, Acc bsl 1 bor Bit).\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    <<FirstOctet/binary,EOctets/binary,OctMantissa/binary>>;\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">>},
 {{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,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,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,complete,1},
  <<"\ncomplete(InList) when is_list(InList) ->\n    case list_to_bitstring(InList) of\n        <<>> ->\n            <<0>>;\n        Res ->\n            Sz = bit_size(Res),\n            case Sz band 7 of\n                0 ->\n                    Res;\n                Bits ->\n                    <<Res:Sz/bitstring,0:(8 - Bits)>>\n            end\n    end;\ncomplete(Bin) when is_binary(Bin) ->\n    case Bin of\n        <<>> ->\n            <<0>>;\n        _ ->\n            Bin\n    end;\ncomplete(InList) when is_bitstring(InList) ->\n    Sz = bit_size(InList),\n    PadLen = 8 - Sz band 7,\n    <<InList:Sz/bitstring,0:PadLen>>.\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">>}].

