% compiler: GNU Prolog 1.1.1 (Oct 18 1999)
% file    : wam_emit.pl
% date    : 10 22 1999
% time    : 14:54:28


file_name('/home/lima/diaz/GNU-Prolog/src/Pl2Wam/wam_emit.pl').


predicate(emit_code_init/2,82,static,private,user,[
    allocate(13),
    get_variable(y(0),0),
    put_value(x(1),0),
    put_variable(y(1),1),
    call(prolog_file_name/2),
    put_value(y(0),0),
    put_value(y(1),1),
    put_variable(y(2),2),
    call(emit_code_files/3),
    put_value(y(2),0),
    put_variable(y(3),1),
    call('$emit_code_init/2_$aux1'/2),
    put_atom(streamwamfile,0),
    put_value(y(3),1),
    call_c_test('Blt_G_Assign',[0,1]),
    put_atom(cur_pl_file,0),
    put_atom('',1),
    call_c_test('Blt_G_Assign',[0,1]),
    put_atom(prolog_name,0),
    put_variable(y(4),1),
    call(current_prolog_flag/2),
    put_atom(prolog_version,0),
    put_variable(y(5),1),
    call(current_prolog_flag/2),
    put_atom(prolog_date,0),
    put_variable(y(6),1),
    call(current_prolog_flag/2),
    put_structure(dt/6,0),
    unify_variable(y(7)),
    unify_variable(y(8)),
    unify_variable(y(9)),
    unify_variable(y(10)),
    unify_variable(y(11)),
    unify_variable(y(12)),
    call(date_time/1),
    put_value(y(3),0),
    put_atom('%% compiler: ~a ~a (~a)~n',1),
    put_list(2),
    unify_local_value(y(4)),
    unify_list,
    unify_local_value(y(5)),
    unify_list,
    unify_local_value(y(6)),
    unify_nil,
    call(format/3),
    put_value(y(3),0),
    put_atom('%% file    : ~a~n',1),
    put_list(2),
    unify_local_value(y(1)),
    unify_nil,
    call(format/3),
    put_value(y(3),0),
    put_atom('%% date    : ~d ~d ~d~n',1),
    put_list(2),
    unify_value(y(8)),
    unify_list,
    unify_value(y(9)),
    unify_list,
    unify_value(y(7)),
    unify_nil,
    call(format/3),
    put_unsafe_value(y(3),0),
    put_atom('%% time    : ~d:~d:~d~n',1),
    put_list(2),
    unify_value(y(10)),
    unify_list,
    unify_value(y(11)),
    unify_list,
    unify_value(y(12)),
    unify_nil,
    deallocate,
    execute(format/3)]).


predicate('$emit_code_init/2_$aux1'/2,82,static,private,user,[
    load_cut_level(2),
    try_me_else(2),
    switch_on_term(1,1,fail,fail,fail),

label(1),
    get_atom(user,0),
    cut(x(2)),
    put_value(x(1),0),
    execute(current_output/1),

label(2),
    trust_me_else_fail,
    put_value(x(1),2),
    put_atom(write,1),
    execute(open/3)]).


predicate(emit_code_files/3,101,static,private,user,[
    load_cut_level(3),
    try_me_else(7),
    switch_on_term(3,1,fail,fail,fail),

label(1),
    switch_on_atom([('',2)]),

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

label(3),
    try_me_else(5),

label(4),
    get_atom('',0),
    get_atom(user,1),
    get_atom(user,2),
    cut(x(3)),
    proceed,

label(5),
    trust_me_else_fail,

label(6),
    allocate(4),
    get_atom('',0),
    get_variable(y(0),2),
    cut(x(3)),
    put_value(x(1),0),
    put_void(1),
    put_variable(y(1),2),
    put_variable(y(2),3),
    call(decompose_file_name/4),
    put_variable(y(3),0),
    call('$emit_code_files/3_$aux1'/1),
    put_unsafe_value(y(2),0),
    put_unsafe_value(y(1),1),
    put_unsafe_value(y(3),2),
    put_value(y(0),3),
    deallocate,
    execute('$emit_code_files/3_$aux2'/4),

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


predicate('$emit_code_files/3_$aux2'/4,104,static,private,user,[
    load_cut_level(4),
    try_me_else(2),
    switch_on_term(1,1,fail,fail,fail),

label(1),
    get_atom('.pl',0),
    cut(x(4)),
    put_value(x(1),0),
    put_value(x(2),1),
    put_value(x(3),2),
    execute(atom_concat/3),

label(2),
    trust_me_else_fail,
    allocate(3),
    get_variable(y(0),2),
    get_variable(y(1),3),
    get_variable(x(2),1),
    get_variable(x(1),0),
    put_value(x(2),0),
    put_variable(y(2),2),
    call(atom_concat/3),
    put_unsafe_value(y(2),0),
    put_value(y(0),1),
    put_value(y(1),2),
    deallocate,
    execute(atom_concat/3)]).


predicate('$emit_code_files/3_$aux1'/1,104,static,private,user,[
    load_cut_level(1),
    try_me_else(1),
    put_atom(native_code,2),
    put_atom(t,3),
    call_c_test('Blt_G_Read',[2,3]),
    cut(x(1)),
    get_atom('.wam',0),
    proceed,

label(1),
    trust_me_else_fail,
    switch_on_term(2,2,fail,fail,fail),

label(2),
    get_atom('.wbc',0),
    proceed]).


predicate(emit_code_term/2,120,static,private,user,[
    allocate(2),
    get_variable(y(0),1),
    put_atom(streamwamfile,1),
    put_variable(y(1),2),
    call_c_test('Blt_G_Read',[1,2]),
    put_value(x(0),1),
    put_value(y(1),0),
    call(character_count/2),
    put_value(y(1),0),
    put_value(y(0),1),
    call(line_count/2),
    put_unsafe_value(y(1),0),
    deallocate,
    execute(close/1)]).


predicate(emit_code/5,129,static,private,user,[
    allocate(2),
    get_variable(y(0),4),
    put_atom(streamwamfile,4),
    put_variable(y(1),5),
    call_c_test('Blt_G_Read',[4,5]),
    put_value(y(1),4),
    put_void(5),
    call(emit_pred_start/6),
    put_value(y(0),0),
    put_void(1),
    put_value(y(1),2),
    call(emit_wam_code/3),
    put_value(y(1),0),
    put_atom(']).',1),
    call(write/2),
    put_unsafe_value(y(1),0),
    deallocate,
    execute(nl/1)]).


predicate(emit_pred_start/6,138,static,private,user,[
    load_cut_level(6),
    try_me_else(1),
    allocate(5),
    get_integer(0,1),
    get_variable(y(0),2),
    get_variable(y(1),3),
    get_variable(y(2),4),
    get_variable(y(3),5),
    get_variable(y(4),6),
    put_value(y(3),1),
    call('$emit_pred_start/6_$aux1'/2),
    cut(y(4)),
    put_value(y(0),0),
    put_value(y(2),1),
    call(emit_file_name_if_needed/2),
    put_value(y(2),0),
    put_atom('~n~ndirective(~d,~a,',1),
    put_list(2),
    unify_local_value(y(1)),
    unify_list,
    unify_local_value(y(3)),
    unify_nil,
    deallocate,
    execute(format/3),

label(1),
    trust_me_else_fail,
    allocate(7),
    get_variable(y(0),0),
    get_variable(y(1),1),
    get_variable(y(2),3),
    get_variable(y(3),4),
    put_value(x(2),0),
    put_value(y(3),1),
    call(emit_file_name_if_needed/2),
    put_value(y(0),0),
    put_value(y(1),1),
    put_variable(y(4),2),
    call('$emit_pred_start/6_$aux2'/3),
    put_value(y(0),0),
    put_value(y(1),1),
    put_variable(y(5),2),
    call('$emit_pred_start/6_$aux3'/3),
    put_value(y(0),0),
    put_value(y(1),1),
    put_variable(y(6),2),
    call('$emit_pred_start/6_$aux4'/3),
    put_value(y(3),0),
    put_atom('~n~npredicate(~q,~d,~a,~a,~a,',1),
    put_structure((/)/2,3),
    unify_local_value(y(0)),
    unify_local_value(y(1)),
    put_list(2),
    unify_value(x(3)),
    unify_list,
    unify_local_value(y(2)),
    unify_list,
    unify_local_value(y(4)),
    unify_list,
    unify_local_value(y(5)),
    unify_list,
    unify_local_value(y(6)),
    unify_nil,
    deallocate,
    execute(format/3)]).


predicate('$emit_pred_start/6_$aux4'/3,146,static,private,user,[
    load_cut_level(3),
    try_me_else(1),
    allocate(2),
    get_variable(y(0),2),
    get_variable(x(2),1),
    get_variable(y(1),3),
    put_value(x(0),1),
    put_atom(bpl,0),
    call(test_pred_info/3),
    cut(y(1)),
    put_value(y(0),0),
    get_atom(built_in,0),
    deallocate,
    proceed,

label(1),
    retry_me_else(2),
    allocate(2),
    get_variable(y(0),2),
    get_variable(x(2),1),
    get_variable(y(1),3),
    put_value(x(0),1),
    put_atom(bfd,0),
    call(test_pred_info/3),
    cut(y(1)),
    put_value(y(0),0),
    get_atom(built_in_fd,0),
    deallocate,
    proceed,

label(2),
    trust_me_else_fail,
    get_atom(user,2),
    proceed]).


predicate('$emit_pred_start/6_$aux3'/3,146,static,private,user,[
    load_cut_level(3),
    try_me_else(1),
    allocate(2),
    get_variable(y(0),2),
    get_variable(x(2),1),
    get_variable(y(1),3),
    put_value(x(0),1),
    put_atom(pub,0),
    call(test_pred_info/3),
    cut(y(1)),
    put_value(y(0),0),
    get_atom(public,0),
    deallocate,
    proceed,

label(1),
    trust_me_else_fail,
    get_atom(private,2),
    proceed]).


predicate('$emit_pred_start/6_$aux2'/3,146,static,private,user,[
    load_cut_level(3),
    try_me_else(1),
    allocate(2),
    get_variable(y(0),2),
    get_variable(x(2),1),
    get_variable(y(1),3),
    put_value(x(0),1),
    put_atom(dyn,0),
    call(test_pred_info/3),
    cut(y(1)),
    put_value(y(0),0),
    get_atom(dynamic,0),
    deallocate,
    proceed,

label(1),
    trust_me_else_fail,
    get_atom(static,2),
    proceed]).


predicate('$emit_pred_start/6_$aux1'/2,138,static,private,user,[
    switch_on_term(2,1,fail,fail,fail),

label(1),
    switch_on_atom([('$exe_user',3),('$exe_system',5)]),

label(2),
    try_me_else(4),

label(3),
    get_atom('$exe_user',0),
    get_atom(user,1),
    proceed,

label(4),
    trust_me_else_fail,

label(5),
    get_atom('$exe_system',0),
    get_atom(system,1),
    proceed]).


predicate(emit_file_name_if_needed/2,165,static,private,user,[
    load_cut_level(2),
    try_me_else(1),
    put_atom(cur_pl_file,1),
    call_c_test('Blt_G_Read',[1,0]),
    cut(x(2)),
    proceed,

label(1),
    trust_me_else_fail,
    allocate(1),
    get_variable(y(0),0),
    put_value(x(1),0),
    put_atom('~n~nfile_name(~q).~n',1),
    put_list(2),
    unify_local_value(y(0)),
    unify_nil,
    call(format/3),
    put_atom(cur_pl_file,0),
    put_value(y(0),1),
    call_c_test('Blt_G_Assign',[0,1]),
    deallocate,
    proceed]).


predicate(emit_wam_code/3,176,static,private,user,[
    load_cut_level(3),
    try_me_else(5),
    switch_on_term(1,2,fail,4,fail),

label(1),
    try_me_else(3),

label(2),
    get_nil(0),
    proceed,

label(3),
    trust_me_else_fail,

label(4),
    allocate(4),
    get_variable(y(1),1),
    get_variable(y(2),2),
    get_list(0),
    unify_variable(x(0)),
    unify_variable(y(0)),
    get_variable(y(3),3),
    put_value(y(1),1),
    put_value(y(2),2),
    call(emit_wam_code/3),
    put_value(y(0),0),
    put_value(y(1),1),
    put_value(y(2),2),
    call(emit_wam_code/3),
    cut(y(3)),
    deallocate,
    proceed,

label(5),
    retry_me_else(6),
    allocate(3),
    get_variable(y(0),1),
    get_variable(y(1),2),
    put_variable(y(2),1),
    call(special_form/2),
    put_unsafe_value(y(2),0),
    put_value(y(0),1),
    put_value(y(1),2),
    deallocate,
    execute(emit_wam_code/3),

label(6),
    retry_me_else(7),
    allocate(1),
    get_variable(y(0),3),
    put_atom(keep_void_inst,1),
    put_atom(f,2),
    call_c_test('Blt_G_Read',[1,2]),
    call(dummy_instruction/1),
    cut(y(0)),
    deallocate,
    proceed,

label(7),
    retry_me_else(8),
    allocate(3),
    get_variable(y(0),0),
    get_variable(y(1),2),
    put_value(y(0),0),
    get_structure(label/1,0),
    unify_void(1),
    cut(x(3)),
    put_value(x(1),0),
    put_variable(y(2),1),
    call('$emit_wam_code/3_$aux1'/2),
    put_value(y(1),0),
    put_atom('~a~n~n',1),
    put_list(2),
    unify_local_value(y(2)),
    unify_nil,
    call(format/3),
    put_value(y(0),0),
    put_value(y(1),1),
    deallocate,
    execute(emit_one_inst/2),

label(8),
    trust_me_else_fail,
    allocate(3),
    get_variable(y(0),0),
    get_variable(y(1),2),
    put_value(x(1),0),
    put_variable(y(2),1),
    call('$emit_wam_code/3_$aux2'/2),
    put_value(y(1),0),
    put_atom('~a~n    ',1),
    put_list(2),
    unify_local_value(y(2)),
    unify_nil,
    call(format/3),
    put_value(y(0),0),
    put_value(y(1),1),
    deallocate,
    execute(emit_one_inst/2)]).


predicate('$emit_wam_code/3_$aux2'/2,199,static,private,user,[
    load_cut_level(2),
    try_me_else(1),
    call_c_test('Blt_Var',[0]),
    cut(x(2)),
    get_atom('[',1),
    get_atom(f,0),
    proceed,

label(1),
    trust_me_else_fail,
    get_atom(',',1),
    proceed]).


predicate('$emit_wam_code/3_$aux1'/2,192,static,private,user,[
    load_cut_level(2),
    try_me_else(1),
    call_c_test('Blt_Var',[0]),
    cut(x(2)),
    get_atom('[',1),
    get_atom(f,0),
    proceed,

label(1),
    trust_me_else_fail,
    get_atom(',',1),
    proceed]).


predicate(emit_one_inst/2,207,static,private,user,[
    load_cut_level(2),
    try_me_else(1),
    get_variable(x(3),1),
    get_variable(x(1),0),
    call_c_test('Blt_Atom',[1]),
    cut(x(2)),
    put_value(x(3),0),
    execute(writeq/2),

label(1),
    trust_me_else_fail,
    allocate(3),
    get_variable(y(0),0),
    get_variable(y(1),1),
    put_value(y(0),0),
    put_variable(x(1),2),
    put_variable(y(2),3),
    call_c_test('Blt_Functor',[0,2,3]),
    put_value(y(1),0),
    call(writeq/2),
    put_integer(0,0),
    put_value(y(2),1),
    put_value(y(0),2),
    put_value(y(1),3),
    call(emit_args/4),
    put_value(y(1),0),
    put_atom(')',1),
    deallocate,
    execute(write/2)]).


predicate(emit_args/4,218,static,private,user,[
    load_cut_level(4),
    try_me_else(1),
    get_value(x(1),0),
    cut(x(4)),
    proceed,

label(1),
    trust_me_else_fail,
    allocate(5),
    get_variable(y(0),1),
    get_variable(y(1),2),
    get_variable(y(2),3),
    math_fast_load_value(x(0),0),
    function('Fct_Fast_Inc',0,[0]),
    get_variable(y(3),0),
    put_value(y(3),0),
    put_variable(y(4),1),
    call('$emit_args/4_$aux1'/2),
    put_value(y(3),1),
    put_value(y(1),2),
    put_variable(x(0),3),
    call_c_test('Blt_Arg',[1,2,3]),
    put_list(2),
    unify_local_value(y(4)),
    unify_list,
    unify_value(x(0)),
    unify_nil,
    put_value(y(2),0),
    put_atom('~a~q',1),
    call(format/3),
    put_value(y(3),0),
    put_value(y(0),1),
    put_value(y(1),2),
    put_value(y(2),3),
    deallocate,
    execute(emit_args/4)]).


predicate('$emit_args/4_$aux1'/2,221,static,private,user,[
    load_cut_level(2),
    try_me_else(2),
    switch_on_term(1,fail,1,fail,fail),

label(1),
    get_integer(1,0),
    cut(x(2)),
    get_atom('(',1),
    proceed,

label(2),
    trust_me_else_fail,
    get_atom(',',1),
    proceed]).


predicate(emit_ensure_linked/0,232,static,private,user,[
    load_cut_level(0),
    try_me_else(1),
    allocate(4),
    get_variable(y(0),0),
    put_atom(streamwamfile,0),
    put_variable(y(1),1),
    call_c_test('Blt_G_Read',[0,1]),
    put_structure(ensure_linked/2,0),
    unify_variable(y(2)),
    unify_variable(y(3)),
    call(retract/1),
    cut(y(0)),
    put_value(y(1),0),
    put_atom('~n~nensure_linked([~q',1),
    put_structure((/)/2,3),
    unify_value(y(2)),
    unify_value(y(3)),
    put_list(2),
    unify_value(x(3)),
    unify_nil,
    call(format/3),
    put_value(y(1),0),
    call('$emit_ensure_linked/0_$aux1'/1),
    put_value(y(1),0),
    put_atom(']).',1),
    call(write/2),
    put_unsafe_value(y(1),0),
    deallocate,
    execute(nl/1),

label(1),
    trust_me_else_fail,
    proceed]).


predicate('$emit_ensure_linked/0_$aux1'/1,232,static,private,user,[
    try_me_else(1),
    allocate(3),
    get_variable(y(0),0),
    put_structure(ensure_linked/2,0),
    unify_variable(y(1)),
    unify_variable(y(2)),
    put_void(1),
    call(clause/2),
    put_value(y(0),0),
    put_atom(',~q',1),
    put_structure((/)/2,3),
    unify_value(y(1)),
    unify_value(y(2)),
    put_list(2),
    unify_value(x(3)),
    unify_nil,
    call(format/3),
    fail,

label(1),
    trust_me_else_fail,
    proceed]).


predicate(bc_emit_code/5,249,static,private,user,[
    allocate(3),
    get_variable(y(0),4),
    put_atom(streamwamfile,4),
    put_variable(y(1),5),
    call_c_test('Blt_G_Read',[4,5]),
    put_value(y(1),4),
    put_variable(y(2),5),
    call(emit_pred_start/6),
    put_unsafe_value(y(2),0),
    put_value(y(0),1),
    put_unsafe_value(y(1),2),
    deallocate,
    execute('$bc_emit_code/5_$aux1'/3)]).


predicate('$bc_emit_code/5_$aux1'/3,249,static,private,user,[
    load_cut_level(3),
    try_me_else(1),
    allocate(1),
    get_variable(y(0),2),
    call_c_test('Blt_Non_Var',[0]),
    cut(x(3)),
    get_list(1),
    unify_variable(x(0)),
    unify_nil,
    get_structure(bc/2,0),
    unify_variable(x(0)),
    unify_void(1),
    get_structure((:-)/2,0),
    unify_void(1),
    unify_variable(x(1)),
    put_value(y(0),0),
    call(bc_emit_prolog_term/2),
    put_value(y(0),0),
    put_atom(').~n',1),
    put_nil(2),
    deallocate,
    execute(format/3),

label(1),
    trust_me_else_fail,
    allocate(5),
    get_variable(y(0),1),
    get_variable(y(1),2),
    put_value(y(0),0),
    put_variable(y(2),1),
    call(length/2),
    put_value(y(0),0),
    put_variable(y(3),1),
    put_variable(y(4),2),
    put_value(y(2),3),
    call('$bc_emit_code/5_$aux2'/4),
    put_value(y(1),0),
    put_atom('~d).~n',1),
    put_list(2),
    unify_local_value(y(3)),
    unify_nil,
    call(format/3),
    put_unsafe_value(y(4),0),
    put_value(y(1),1),
    deallocate,
    execute(bc_emit_lst_clause/2)]).


predicate('$bc_emit_code/5_$aux2'/4,249,static,private,user,[
    load_cut_level(4),
    try_me_else(2),
    switch_on_term(1,fail,fail,1,fail),

label(1),
    get_list(0),
    unify_variable(x(0)),
    unify_nil,
    get_structure(bc/2,0),
    unify_atom('$$empty$$predicate$$clause$$'),
    unify_list,
    unify_atom(proceed),
    unify_nil,
    cut(x(4)),
    get_integer(0,1),
    get_nil(2),
    proceed,

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


predicate(bc_emit_lst_clause/2,267,static,private,user,[
    switch_on_term(1,2,fail,4,fail),

label(1),
    try_me_else(3),

label(2),
    get_nil(0),
    proceed,

label(3),
    trust_me_else_fail,

label(4),
    allocate(4),
    get_list(0),
    unify_variable(x(0)),
    unify_variable(y(2)),
    get_structure(bc/2,0),
    unify_variable(y(0)),
    unify_variable(y(1)),
    get_variable(y(3),1),
    put_value(y(3),0),
    put_atom('~n~nclause(',1),
    put_nil(2),
    call(format/3),
    put_value(y(3),0),
    put_value(y(0),1),
    call(bc_emit_prolog_term/2),
    put_value(y(3),0),
    put_atom(',',1),
    call(write/2),
    put_value(y(1),0),
    put_void(1),
    put_value(y(3),2),
    call(emit_wam_code/3),
    put_value(y(3),0),
    put_atom(']).~n',1),
    put_nil(2),
    call(format/3),
    put_value(y(2),0),
    put_value(y(3),1),
    deallocate,
    execute(bc_emit_lst_clause/2)]).


predicate(bc_emit_prolog_term/2,280,static,private,user,[
    allocate(2),
    get_variable(y(0),0),
    get_variable(y(1),1),
    put_value(y(1),0),
    put_integer(0,1),
    put_void(2),
    call(numbervars/3),
    put_value(y(0),0),
    put_value(y(1),1),
    put_structure(numbervars/1,5),
    unify_atom(true),
    put_structure(ignore_ops/1,4),
    unify_atom(true),
    put_structure(quoted/1,3),
    unify_atom(true),
    put_list(2),
    unify_value(x(5)),
    unify_list,
    unify_value(x(4)),
    unify_list,
    unify_value(x(3)),
    unify_nil,
    deallocate,
    execute(write_term/3)]).
