% compiler: GNU Prolog 1.4.2
% file    : dec10io.pl


file_name('/home/diaz/GP/src/src/BipsPl/dec10io.pl').


predicate('$use_dec10io'/0,42,static,private,monofile,built_in,[
    proceed]).


predicate('$find_existing_stream'/3,46,static,private,monofile,built_in,[
    pragma_arity(4),
    get_current_choice(x(3)),
    try_me_else(11),
    switch_on_term(3,1,fail,fail,fail),

label(1),
    switch_on_atom([(user,2),(user_input,6),(user_output,10)]),

label(2),
    try(4),
    trust(8),

label(3),
    try_me_else(5),

label(4),
    get_atom(user,0),
    get_structure('$stream'/1,1),
    unify_integer(0),
    get_atom(input,2),
    proceed,

label(5),
    retry_me_else(7),

label(6),
    get_atom(user_input,0),
    get_structure('$stream'/1,1),
    unify_integer(0),
    get_atom(input,2),
    proceed,

label(7),
    retry_me_else(9),

label(8),
    get_atom(user,0),
    get_structure('$stream'/1,1),
    unify_integer(1),
    get_atom(output,2),
    proceed,

label(9),
    trust_me_else_fail,

label(10),
    get_atom(user_output,0),
    get_structure('$stream'/1,1),
    unify_integer(1),
    get_atom(output,2),
    proceed,

label(11),
    retry_me_else(12),
    allocate(4),
    get_variable(y(0),0),
    get_variable(y(1),1),
    get_variable(y(2),2),
    get_variable(y(3),3),
    put_structure('$dec10_stream'/3,0),
    unify_local_value(y(0)),
    unify_local_value(y(1)),
    unify_local_value(y(2)),
    put_void(1),
    call(clause/2),
    cut(y(3)),
    put_value(y(1),0),
    put_value(y(0),1),
    put_value(y(2),2),
    deallocate,
    execute('$$find_existing_stream/3_$aux1'/3),

label(12),
    trust_me_else_fail,
    allocate(2),
    get_variable(y(0),0),
    get_value(y(0),1),
    get_variable(y(1),2),
    put_value(y(0),0),
    get_structure('$stream'/1,0),
    unify_variable(x(0)),
    call_c('Pl_Blt_Integer',[fast_call,boolean],[x(0)]),
    put_value(y(0),0),
    call(current_stream/1),
    put_value(y(0),0),
    put_value(y(1),1),
    deallocate,
    execute(stream_property/2)]).


predicate('$$find_existing_stream/3_$aux1'/3,54,static,private,monofile,local,[
    pragma_arity(4),
    get_current_choice(x(3)),
    try_me_else(1),
    allocate(4),
    get_variable(y(0),0),
    get_variable(y(1),1),
    get_variable(y(2),2),
    get_variable(y(3),3),
    put_value(y(0),0),
    call(current_stream/1),
    put_value(y(0),0),
    put_structure(file_name/1,1),
    unify_local_value(y(1)),
    call(stream_property/2),
    put_value(y(0),0),
    put_value(y(2),1),
    call(stream_property/2),
    cut(y(3)),
    deallocate,
    proceed,

label(1),
    trust_me_else_fail,
    allocate(0),
    get_variable(x(3),0),
    put_structure('$dec10_stream'/3,0),
    unify_local_value(x(1)),
    unify_local_value(x(3)),
    unify_local_value(x(2)),
    call(retract/1),
    fail]).


predicate(see/1,74,static,private,monofile,built_in,[
    pragma_arity(2),
    get_current_choice(x(1)),
    try_me_else(1),
    allocate(2),
    get_variable(y(0),1),
    call_c('Pl_Set_Bip_Name_Untagged_2',[by_value],[see,1]),
    call_c('Pl_Blt_Non_Var',[fast_call,boolean],[x(0)]),
    cut(y(0)),
    put_variable(y(1),1),
    call('$see/1_$aux1'/2),
    cut(y(0)),
    put_unsafe_value(y(1),0),
    deallocate,
    execute(set_input/1),

label(1),
    trust_me_else_fail,
    execute('$pl_err_instantiation'/0)]).


predicate('$see/1_$aux1'/2,74,static,private,monofile,local,[
    try_me_else(1),
    put_atom(input,2),
    execute('$find_existing_stream'/3),

label(1),
    trust_me_else_fail,
    allocate(2),
    get_variable(y(0),0),
    get_variable(y(1),1),
    call_c('Pl_Set_Bip_Name_Untagged_2',[by_value],[see,1]),
    put_value(y(0),0),
    put_atom(read,1),
    put_value(y(1),2),
    put_nil(3),
    call('$open'/4),
    put_structure('$dec10_stream'/3,0),
    unify_local_value(y(0)),
    unify_local_value(y(1)),
    unify_atom(input),
    deallocate,
    execute(assertz/1)]).


predicate(seeing/1,90,static,private,monofile,built_in,[
    pragma_arity(2),
    get_current_choice(x(1)),
    allocate(3),
    get_variable(y(0),0),
    get_variable(y(1),1),
    call_c('Pl_Set_Bip_Name_Untagged_2',[by_value],[seeing,1]),
    put_variable(y(2),0),
    call(current_input/1),
    put_value(y(0),0),
    put_value(y(2),1),
    put_atom(input,2),
    call('$find_existing_stream'/3),
    cut(y(1)),
    deallocate,
    proceed]).


predicate(seen/0,98,static,private,monofile,built_in,[
    pragma_arity(1),
    get_current_choice(x(0)),
    allocate(2),
    get_variable(y(0),0),
    call_c('Pl_Set_Bip_Name_Untagged_2',[by_value],[seen,0]),
    put_variable(y(1),0),
    call(current_input/1),
    put_value(y(1),0),
    call(close/1),
    put_value(y(1),0),
    call('$seen/0_$aux1'/1),
    cut(y(0)),
    deallocate,
    proceed]).


predicate('$seen/0_$aux1'/1,98,static,private,monofile,local,[
    try_me_else(1),
    put_value(x(0),1),
    put_void(0),
    put_atom(input,2),
    execute('$find_existing_stream'/3),

label(1),
    trust_me_else_fail,
    proceed]).


predicate(tell/1,108,static,private,monofile,built_in,[
    pragma_arity(2),
    get_current_choice(x(1)),
    try_me_else(1),
    allocate(2),
    get_variable(y(0),1),
    call_c('Pl_Set_Bip_Name_Untagged_2',[by_value],[tell,1]),
    call_c('Pl_Blt_Non_Var',[fast_call,boolean],[x(0)]),
    cut(y(0)),
    put_variable(y(1),1),
    call('$tell/1_$aux1'/2),
    cut(y(0)),
    put_unsafe_value(y(1),0),
    deallocate,
    execute(set_output/1),

label(1),
    trust_me_else_fail,
    execute('$pl_err_instantiation'/0)]).


predicate('$tell/1_$aux1'/2,108,static,private,monofile,local,[
    try_me_else(1),
    put_atom(output,2),
    execute('$find_existing_stream'/3),

label(1),
    trust_me_else_fail,
    allocate(2),
    get_variable(y(0),0),
    get_variable(y(1),1),
    call_c('Pl_Set_Bip_Name_Untagged_2',[by_value],[tell,1]),
    put_value(y(0),0),
    put_atom(write,1),
    put_value(y(1),2),
    put_nil(3),
    call('$open'/4),
    put_structure('$dec10_stream'/3,0),
    unify_local_value(y(0)),
    unify_local_value(y(1)),
    unify_atom(output),
    deallocate,
    execute(assertz/1)]).


predicate(telling/1,124,static,private,monofile,built_in,[
    pragma_arity(2),
    get_current_choice(x(1)),
    allocate(3),
    get_variable(y(0),0),
    get_variable(y(1),1),
    call_c('Pl_Set_Bip_Name_Untagged_2',[by_value],[telling,1]),
    put_variable(y(2),0),
    call(current_output/1),
    put_value(y(0),0),
    put_value(y(2),1),
    put_atom(output,2),
    call('$find_existing_stream'/3),
    cut(y(1)),
    deallocate,
    proceed]).


predicate(told/0,132,static,private,monofile,built_in,[
    pragma_arity(1),
    get_current_choice(x(0)),
    allocate(2),
    get_variable(y(0),0),
    call_c('Pl_Set_Bip_Name_Untagged_2',[by_value],[told,0]),
    put_variable(y(1),0),
    call(current_output/1),
    put_value(y(1),0),
    call(close/1),
    put_value(y(1),0),
    call('$told/0_$aux1'/1),
    cut(y(0)),
    deallocate,
    proceed]).


predicate('$told/0_$aux1'/1,132,static,private,monofile,local,[
    try_me_else(1),
    put_value(x(0),1),
    put_void(0),
    put_atom(output,2),
    execute('$find_existing_stream'/3),

label(1),
    trust_me_else_fail,
    proceed]).


predicate(append/1,141,static,private,monofile,built_in,[
    pragma_arity(2),
    get_current_choice(x(1)),
    try_me_else(1),
    allocate(2),
    get_variable(y(0),1),
    call_c('Pl_Set_Bip_Name_Untagged_2',[by_value],[append,1]),
    call_c('Pl_Blt_Non_Var',[fast_call,boolean],[x(0)]),
    cut(y(0)),
    put_variable(y(1),1),
    call('$append/1_$aux1'/2),
    cut(y(0)),
    put_unsafe_value(y(1),0),
    deallocate,
    execute(set_output/1),

label(1),
    trust_me_else_fail,
    execute('$pl_err_instantiation'/0)]).


predicate('$append/1_$aux1'/2,141,static,private,monofile,local,[
    try_me_else(1),
    put_atom(output,2),
    execute('$find_existing_stream'/3),

label(1),
    trust_me_else_fail,
    allocate(2),
    get_variable(y(0),0),
    get_variable(y(1),1),
    call_c('Pl_Set_Bip_Name_Untagged_2',[by_value],[append,1]),
    put_value(y(0),0),
    put_atom(append,1),
    put_value(y(1),2),
    put_nil(3),
    call('$open'/4),
    put_structure('$dec10_stream'/3,0),
    unify_local_value(y(0)),
    unify_local_value(y(1)),
    unify_atom(output),
    deallocate,
    execute(assertz/1)]).


predicate(get0/1,157,static,private,monofile,built_in,[
    call_c('Pl_Set_Bip_Name_Untagged_2',[by_value],[get0,1]),
    call_c('Pl_Get_Code_1',[boolean],[x(0)]),
    proceed]).


predicate(get/1,163,static,private,monofile,built_in,[
    allocate(1),
    get_variable(y(0),0),
    call_c('Pl_Set_Bip_Name_Untagged_2',[by_value],[get,1]),
    put_value(y(0),0),
    call('$check_in_character_code'/1),
    put_variable(x(0),1),
    call_c('Pl_Get_Code_1',[boolean],[x(1)]),
    put_value(y(0),1),
    deallocate,
    execute('$get/1_$aux1'/2)]).


predicate('$get/1_$aux1'/2,163,static,private,monofile,local,[
    pragma_arity(3),
    get_current_choice(x(2)),
    try_me_else(1),
    call_c('Pl_Set_Bip_Name_Untagged_2',[by_value],[=<,2]),
    math_load_value(x(0),0),
    put_integer(32,3),
    call_c('Pl_Blt_Lte',[fast_call,boolean],[x(0),x(3)]),
    cut(x(2)),
    put_value(x(1),0),
    execute(get/1),

label(1),
    trust_me_else_fail,
    get_value(x(0),1),
    proceed]).


predicate(put/1,172,static,private,monofile,built_in,[
    call_c('Pl_Set_Bip_Name_Untagged_2',[by_value],[put,1]),
    call_c('Pl_Put_Code_1',[],[x(0)]),
    proceed]).


predicate(skip/1,177,static,private,monofile,built_in,[
    pragma_arity(2),
    get_current_choice(x(1)),
    allocate(2),
    get_variable(y(0),0),
    get_variable(y(1),1),
    call_c('Pl_Set_Bip_Name_Untagged_2',[by_value],[skip,1]),
    put_value(y(0),0),
    call('$check_in_character_code'/1),
    call(repeat/0),
    put_variable(x(0),1),
    call_c('Pl_Get_Code_1',[boolean],[x(1)]),
    get_value(y(0),0),
    cut(y(1)),
    deallocate,
    proceed]).


predicate('$check_in_character_code'/1,187,static,private,monofile,built_in,[
    pragma_arity(2),
    get_current_choice(x(1)),
    try_me_else(1),
    call_c('Pl_Blt_Var',[fast_call,boolean],[x(0)]),
    cut(x(1)),
    proceed,

label(1),
    retry_me_else(2),
    call_c('Pl_Blt_Integer',[fast_call,boolean],[x(0)]),
    cut(x(1)),
    execute('$$check_in_character_code/1_$aux1'/1),

label(2),
    trust_me_else_fail,
    put_value(x(0),1),
    put_atom(integer,0),
    execute('$pl_err_type'/2)]).


predicate('$$check_in_character_code/1_$aux1'/1,190,static,private,monofile,local,[
    pragma_arity(2),
    get_current_choice(x(1)),
    try_me_else(1),
    call_c('Pl_Set_Bip_Name_Untagged_2',[by_value],[>=,2]),
    math_load_value(x(0),2),
    put_integer(-1,3),
    call_c('Pl_Blt_Gte',[fast_call,boolean],[x(2),x(3)]),
    call_c('Pl_Set_Bip_Name_Untagged_2',[by_value],[=<,2]),
    math_load_value(x(0),0),
    put_integer(255,2),
    call_c('Pl_Blt_Lte',[fast_call,boolean],[x(0),x(2)]),
    cut(x(1)),
    proceed,

label(1),
    trust_me_else_fail,
    put_atom(in_character_code,0),
    execute('$pl_err_representation'/1)]).


predicate(tab/1,202,static,private,monofile,built_in,[
    try_me_else(1),
    allocate(1),
    call_c('Pl_Set_Bip_Name_Untagged_2',[by_value],[tab,1]),
    put_variable(y(0),1),
    call('$arith_eval'/2),
    put_void(0),
    put_integer(1,1),
    put_value(y(0),2),
    call(for/3),
    put_atom(' ',0),
    call(put_char/1),
    fail,

label(1),
    trust_me_else_fail,
    proceed]).
