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


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


predicate('$term_to_goal'/3,43,static,private,monofile,built_in,[
    pragma_arity(4),
    get_current_choice(x(3)),
    try_me_else(1),
    allocate(1),
    get_variable(y(0),3),
    put_atom('$call_call_info',3),
    call_c('Pl_Blt_G_Assign',[fast_call],[x(3),x(1)]),
    put_atom('$new_term',1),
    put_atom(f,3),
    call_c('Pl_Blt_G_Assign',[fast_call],[x(1),x(3)]),
    put_value(x(2),1),
    call('$term_to_goal1'/2),
    put_atom('$new_term',0),
    put_atom(t,1),
    call_c('Pl_Blt_G_Read',[fast_call,boolean],[x(0),x(1)]),
    cut(y(0)),
    deallocate,
    proceed,

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


predicate('$term_to_goal1'/2,53,static,private,monofile,built_in,[
    pragma_arity(3),
    get_current_choice(x(2)),
    try_me_else(1),
    allocate(1),
    get_variable(y(0),2),
    call('$term_to_goal2'/2),
    cut(y(0)),
    deallocate,
    proceed,

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


predicate('$term_to_goal2'/2,60,static,private,monofile,built_in,[
    pragma_arity(3),
    get_current_choice(x(2)),
    try_me_else(1),
    get_variable(x(3),0),
    call_c('Pl_Blt_Var',[fast_call,boolean],[x(3)]),
    cut(x(2)),
    put_atom('$call_call_info',2),
    put_variable(x(0),4),
    call_c('Pl_Blt_G_Read',[fast_call,boolean],[x(2),x(4)]),
    put_atom('$new_term',2),
    put_atom(t,4),
    call_c('Pl_Blt_G_Assign',[fast_call],[x(2),x(4)]),
    put_value(x(3),2),
    execute('$$term_to_goal2/2_$aux1'/3),

label(1),
    retry_me_else(9),
    switch_on_term(3,fail,fail,fail,2),

label(2),
    switch_on_structure([((->)/2,4),((',')/2,6),((;)/2,8)]),

label(3),
    try_me_else(5),

label(4),
    allocate(2),
    get_structure((->)/2,0),
    unify_variable(x(0)),
    unify_variable(y(0)),
    get_structure((->)/2,1),
    unify_variable(x(1)),
    unify_variable(y(1)),
    cut(x(2)),
    call('$term_to_goal2'/2),
    put_value(y(0),0),
    put_value(y(1),1),
    deallocate,
    execute('$term_to_goal2'/2),

label(5),
    retry_me_else(7),

label(6),
    allocate(2),
    get_structure((',')/2,0),
    unify_variable(x(0)),
    unify_variable(y(0)),
    get_structure((',')/2,1),
    unify_variable(x(1)),
    unify_variable(y(1)),
    cut(x(2)),
    call('$term_to_goal2'/2),
    put_value(y(0),0),
    put_value(y(1),1),
    deallocate,
    execute('$term_to_goal2'/2),

label(7),
    trust_me_else_fail,

label(8),
    allocate(2),
    get_structure((;)/2,0),
    unify_variable(x(0)),
    unify_variable(y(0)),
    get_structure((;)/2,1),
    unify_variable(x(1)),
    unify_variable(y(1)),
    cut(x(2)),
    call('$term_to_goal2'/2),
    put_value(y(0),0),
    put_value(y(1),1),
    deallocate,
    execute('$term_to_goal2'/2),

label(9),
    trust_me_else_fail,
    get_value(x(1),0),
    call_c('Pl_Blt_Callable',[fast_call,boolean],[x(1)]),
    proceed]).


predicate('$$term_to_goal2/2_$aux1'/3,60,static,private,monofile,local,[
    pragma_arity(4),
    get_current_choice(x(3)),
    try_me_else(1),
    get_atom(none,0),
    cut(x(3)),
    get_structure(call/1,1),
    unify_local_value(x(2)),
    proceed,

label(1),
    trust_me_else_fail,
    get_structure('$call_internal'/2,1),
    unify_local_value(x(2)),
    unify_local_value(x(0)),
    proceed]).


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

label(1),
    retry_me_else(2),
    call_c('Pl_Blt_List_Or_Partial_List',[fast_call,boolean],[x(0)]),
    cut(x(1)),
    execute('$pl_err_instantiation'/0),

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


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

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


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

label(1),
    trust_me_else_fail,
    allocate(1),
    get_variable(y(0),1),
    call('$check_atom_or_atom_list1'/1),
    cut(y(0)),
    deallocate,
    proceed]).


predicate('$check_atom_or_atom_list1'/1,123,static,private,monofile,built_in,[
    try_me_else(1),
    call_c('Pl_Blt_Var',[fast_call,boolean],[x(0)]),
    execute('$pl_err_instantiation'/0),

label(1),
    retry_me_else(6),
    switch_on_term(2,3,fail,5,fail),

label(2),
    try_me_else(4),

label(3),
    get_nil(0),
    proceed,

label(4),
    trust_me_else_fail,

label(5),
    allocate(1),
    get_list(0),
    unify_variable(x(0)),
    unify_variable(y(0)),
    call('$check_atom_or_atom_list2'/1),
    put_value(y(0),0),
    deallocate,
    execute('$check_atom_or_atom_list1'/1),

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


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

label(1),
    retry_me_else(2),
    call_c('Pl_Blt_Var',[fast_call,boolean],[x(0)]),
    cut(x(1)),
    execute('$pl_err_instantiation'/0),

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


predicate('$get_head_and_body'/3,150,static,private,monofile,built_in,[
    pragma_arity(4),
    get_current_choice(x(3)),
    try_me_else(1),
    get_structure((:-)/2,0),
    unify_local_value(x(1)),
    unify_local_value(x(2)),
    cut(x(3)),
    put_value(x(1),0),
    execute('$check_head'/1),

label(1),
    trust_me_else_fail,
    get_atom(true,2),
    get_value(x(1),0),
    put_value(x(1),0),
    execute('$check_head'/1)]).


predicate('$check_head'/1,160,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)),
    execute('$pl_err_instantiation'/0),

label(1),
    trust_me_else_fail,
    execute('$$check_head/1_$aux1'/1)]).


predicate('$$check_head/1_$aux1'/1,164,static,private,monofile,local,[
    pragma_arity(2),
    get_current_choice(x(1)),
    try_me_else(1),
    call_c('Pl_Blt_Callable',[fast_call,boolean],[x(0)]),
    cut(x(1)),
    proceed,

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


predicate('$get_pred_indic'/3,173,static,private,monofile,built_in,[
    call_c('Pl_Get_Pred_Indic_3',[boolean],[x(0),x(1),x(2)]),
    proceed]).
