/*
** Automatically generated from `primes.m' by the
** Mercury compiler, version 0.5-beta.  Do not edit.
*/
/*
INIT mercury__primes__init
ENDINIT
*/

#include "imp.h"

Define_extern_entry(mercury__benchmark_1_0);
Declare_label(mercury__benchmark_1_0_i3);
Define_extern_entry(mercury__main_2_0);
Declare_label(mercury__main_2_0_i3);
Declare_label(mercury__main_2_0_i4);
Declare_local(mercury__data_1_0_l);
Declare_local(mercury__primes_2_0_l);
Declare_label(mercury__primes_2_0_i3);
Declare_local(mercury__integers_3_0_l);
Declare_label(mercury__integers_3_0_i5);
Declare_label(mercury__integers_3_0_i1000);
Declare_local(mercury__sift_2_0_l);
Declare_label(mercury__sift_2_0_i5);
Declare_label(mercury__sift_2_0_i6);
Declare_label(mercury__sift_2_0_i1000);
Declare_local(mercury__remove_3_0_l);
Declare_label(mercury__remove_3_0_i8);
Declare_label(mercury__remove_3_0_i10);
Declare_label(mercury__remove_3_0_i4);
Declare_label(mercury__remove_3_0_i1000);
Declare_label(mercury__remove_3_0_i1001);

BEGIN_MODULE(mercury__primes_module)
	init_entry(mercury__benchmark_1_0);
	init_label(mercury__benchmark_1_0_i3);
	init_entry(mercury__main_2_0);
	init_label(mercury__main_2_0_i3);
	init_label(mercury__main_2_0_i4);
	init_local(mercury__data_1_0_l);
	init_local(mercury__primes_2_0_l);
	init_label(mercury__primes_2_0_i3);
	init_local(mercury__integers_3_0_l);
	init_label(mercury__integers_3_0_i5);
	init_label(mercury__integers_3_0_i1000);
	init_local(mercury__sift_2_0_l);
	init_label(mercury__sift_2_0_i5);
	init_label(mercury__sift_2_0_i6);
	init_label(mercury__sift_2_0_i1000);
	init_local(mercury__remove_3_0_l);
	init_label(mercury__remove_3_0_i8);
	init_label(mercury__remove_3_0_i10);
	init_label(mercury__remove_3_0_i4);
	init_label(mercury__remove_3_0_i1000);
	init_label(mercury__remove_3_0_i1001);
BEGIN_CODE


/*-------------------------------------------------------------------------*/
/* code for predicate benchmark/1 in mode 0 */
/* Start of procedure prologue */
/* 
Stack slot assignments (if any):
 */
Define_entry(mercury__benchmark_1_0);
		/* Procedure entry point */
/* End of procedure prologue */
	{ r1 = 98; }
		/* Assigning from Data */
	incr_sp(1);
		/* late setup */
	{ detstackvar(1) = (Integer) succip; }
		/* late save */
	{ localcall(mercury__primes_2_0_l,
		LABEL(mercury__benchmark_1_0_i3),
		LABEL(mercury__benchmark_1_0)); }
/*
 * Garbage collection livevals info
 *	detstackvar(1)	succip
 *	r2	num(7)
 */
		/* branch to det procedure */
Define_label(mercury__benchmark_1_0_i3);
	update_prof_current_proc(LABEL(mercury__benchmark_1_0));
		/* Continuation label */
	{ r1 = (Integer) r2; }
		/* Assigning from HeadVar__1 */
	{ LVALUE_CAST(Word,succip) = (Integer) detstackvar(1); }
		/* restore the success ip */
	decr_sp(1);
		/* Deallocate stack frame */
/*
 * Live lvalues:
 *	r1
 */
	{ proceed(); }
		/* Return from procedure call */

/*-------------------------------------------------------------------------*/
/* code for predicate main/2 in mode 0 */
/* Start of procedure prologue */
/* 
Stack slot assignments (if any):
DCG_0	 ->	stackvar(1)
 */
Define_entry(mercury__main_2_0);
		/* Procedure entry point */
/* End of procedure prologue */
	incr_sp(2);
		/* late setup */
	{ detstackvar(2) = (Integer) succip; }
		/* late save */
	{ detstackvar(1) = (Integer) r1; }
		/* Assigning from DCG_0 */
/*
 * Live lvalues:
 *	detstackvar(1)
 *	detstackvar(2)
 */
	{ localcall(mercury__benchmark_1_0,
		LABEL(mercury__main_2_0_i3),
		LABEL(mercury__main_2_0)); }
/*
 * Garbage collection livevals info
 *	detstackvar(2)	succip
 *	r1	num(7)
 *	detstackvar(1)	num(8)
 */
		/* branch to det procedure */
Define_label(mercury__main_2_0_i3);
	update_prof_current_proc(LABEL(mercury__main_2_0));
		/* Continuation label */
	{ r2 = (Integer) detstackvar(1); }
		/* Assigning from DCG_0 */
/*
 * Live lvalues:
 *	r1
 *	r2
 *	detstackvar(2)
 */
	{ Declare_entry(mercury__print_list_3_0);
	  call(ENTRY(mercury__print_list_3_0),
		LABEL(mercury__main_2_0_i4),
		LABEL(mercury__main_2_0)); }
/*
 * Garbage collection livevals info
 *	detstackvar(2)	succip
 *	r3	num(8)
 */
		/* branch to det procedure */
Define_label(mercury__main_2_0_i4);
	update_prof_current_proc(LABEL(mercury__main_2_0));
		/* Continuation label */
	{ r2 = (Integer) r3; }
		/* Assigning from HeadVar__2 */
	{ LVALUE_CAST(Word,succip) = (Integer) detstackvar(2); }
		/* restore the success ip */
	decr_sp(2);
		/* Deallocate stack frame */
/*
 * Live lvalues:
 *	r2
 */
	{ proceed(); }
		/* Return from procedure call */

/*-------------------------------------------------------------------------*/
/* code for predicate data/1 in mode 0 */
/* Start of procedure prologue */
/* 
Stack slot assignments (if any):
 */
Define_local(mercury__data_1_0_l);
		/* Procedure entry point */
/* End of procedure prologue */
/* Start of procedure epilogue */
	{ r1 = 98; }
		/* Assigning from HeadVar__1 */
/* End of procedure epilogue */
/*
 * Live lvalues:
 *	r1
 */
	{ proceed(); }
		/* Return from procedure call */

/*-------------------------------------------------------------------------*/
/* code for predicate primes/2 in mode 0 */
/* Start of procedure prologue */
/* 
Stack slot assignments (if any):
 */
Define_local(mercury__primes_2_0_l);
		/* Procedure entry point */
/* End of procedure prologue */
	{ r2 = (Integer) r1; }
		/* shuffle lval */
	{ r1 = 2; }
		/* Assigning from variable number 6 */
	incr_sp(1);
		/* late setup */
	{ detstackvar(1) = (Integer) succip; }
		/* late save */
	{ localcall(mercury__integers_3_0_l,
		LABEL(mercury__primes_2_0_i3),
		LABEL(mercury__primes_2_0_l)); }
/*
 * Garbage collection livevals info
 *	detstackvar(1)	succip
 *	r3	num(7)
 */
		/* branch to det procedure */
Define_label(mercury__primes_2_0_i3);
	update_prof_current_proc(LABEL(mercury__primes_2_0_l));
		/* Continuation label */
	{ r1 = (Integer) r3; }
		/* Assigning from Is */
	{ LVALUE_CAST(Word,succip) = (Integer) detstackvar(1); }
		/* restore the success ip */
	decr_sp(1);
		/* Deallocate stack frame */
/*
 * Live lvalues:
 *	r1
 *	detstackvar(1)
 */
	{ localtailcall(mercury__sift_2_0_l,
		LABEL(mercury__primes_2_0_l)); }
		/* branch to det procedure (redirected return) */

/*-------------------------------------------------------------------------*/
/* code for predicate integers/3 in mode 0 */
/* Start of procedure prologue */
/* 
Stack slot assignments (if any):
Low	 ->	stackvar(1)
High	 ->	stackvar(2)
 */
Define_local(mercury__integers_3_0_l);
		/* Procedure entry point */
/* End of procedure prologue */
	{ detstackvar(0) = (Integer) succip; }
		/* late save */
	{ if (((Integer) r1 > (Integer) r2))
		GOTO_LABEL(mercury__integers_3_0_i1000); }
		/* Test for failure (teardown redirect) */
	incr_sp(3);
		/* late setup after succip */
	{ detstackvar(1) = (Integer) r1; }
		/* Assigning from Low */
	{ r3 = (Integer) r1; }
		/* shuffle lval */
	{ r1 = ((Integer) r3 + 1); }
		/* Assigning from M */
/*
 * Live lvalues:
 *	r1
 *	r2
 *	detstackvar(1)
 *	detstackvar(3)
 */
	{ localcall(mercury__integers_3_0_l,
		LABEL(mercury__integers_3_0_i5),
		LABEL(mercury__integers_3_0_l)); }
/*
 * Garbage collection livevals info
 *	detstackvar(3)	succip
 *	r3	num(7)
 *	detstackvar(1)	num(2)
 */
		/* branch to det procedure */
Define_label(mercury__integers_3_0_i5);
	update_prof_current_proc(LABEL(mercury__integers_3_0_l));
		/* Continuation label */
	{ r1 = (Integer) r3; }
		/* shuffle lval */
	{ tag_incr_hp(r3, mktag(1), 2); }
		/* Allocating heap for HeadVar__3 */
	{ field(mktag(1), (Integer) r3, 0) = (Integer) detstackvar(1); }
		/* Assigning from  */
	{ field(mktag(1), (Integer) r3, 1) = (Integer) r1; }
		/* Assigning from  */
	{ LVALUE_CAST(Word,succip) = (Integer) detstackvar(3); }
		/* restore the success ip */
	decr_sp(3);
		/* Deallocate stack frame */
/*
 * Live lvalues:
 *	r3
 */
	{ proceed(); }
		/* shortcircuit */
Define_label(mercury__integers_3_0_i1000);
		/* non-teardown parallel label */
	{ r3 = (Integer) mkword(mktag(0), mkbody(0)); }
		/* Assigning from HeadVar__3 */
/*
 * Live lvalues:
 *	r3
 */
	{ proceed(); }
		/* Return from procedure call */

/*-------------------------------------------------------------------------*/
/* code for predicate sift/2 in mode 0 */
/* Start of procedure prologue */
/* 
Stack slot assignments (if any):
I	 ->	stackvar(1)
 */
Define_local(mercury__sift_2_0_l);
	{ detstackvar(0) = (Integer) succip; }
		/* late save */
	{ if (((Integer) r1 == (Integer) mkword(mktag(0), mkbody(0))))
		GOTO_LABEL(mercury__sift_2_0_i1000); }
		/*  (teardown redirect) */
	incr_sp(2);
		/* late setup after succip */
	{ r2 = (Integer) field(mktag(1), (Integer) r1, 1); }
		/* vn flush */
	{ r1 = (Integer) field(mktag(1), (Integer) r1, 0); }
		/* vn flush */
	{ detstackvar(1) = (Integer) r1; }
		/* vn flush */
/*
 * Live lvalues:
 *	r1
 *	r2
 *	detstackvar(1)
 *	detstackvar(2)
 */
	{ localcall(mercury__remove_3_0_l,
		LABEL(mercury__sift_2_0_i5),
		LABEL(mercury__sift_2_0_l)); }
/*
 * Garbage collection livevals info
 *	detstackvar(2)	succip
 *	r3	num(7)
 *	detstackvar(1)	num(2)
 */
Define_label(mercury__sift_2_0_i5);
	update_prof_current_proc(LABEL(mercury__sift_2_0_l));
		/* Continuation label */
	{ r1 = (Integer) r3; }
		/* Assigning from New */
/*
 * Live lvalues:
 *	r1
 *	detstackvar(1)
 *	detstackvar(2)
 */
	{ localcall(mercury__sift_2_0_l,
		LABEL(mercury__sift_2_0_i6),
		LABEL(mercury__sift_2_0_l)); }
/*
 * Garbage collection livevals info
 *	detstackvar(2)	succip
 *	r2	num(7)
 *	detstackvar(1)	num(2)
 */
		/* branch to det procedure */
Define_label(mercury__sift_2_0_i6);
	update_prof_current_proc(LABEL(mercury__sift_2_0_l));
		/* Continuation label */
	{ r1 = (Integer) r2; }
		/* shuffle lval */
	{ tag_incr_hp(r2, mktag(1), 2); }
		/* Allocating heap for HeadVar__2 */
	{ field(mktag(1), (Integer) r2, 0) = (Integer) detstackvar(1); }
		/* Assigning from  */
	{ field(mktag(1), (Integer) r2, 1) = (Integer) r1; }
		/* Assigning from  */
	{ LVALUE_CAST(Word,succip) = (Integer) detstackvar(2); }
		/* restore the success ip */
	decr_sp(2);
		/* Deallocate stack frame */
/*
 * Live lvalues:
 *	r2
 */
	{ proceed(); }
		/* shortcircuit */
Define_label(mercury__sift_2_0_i1000);
		/* non-teardown parallel label */
	{ r2 = (Integer) mkword(mktag(0), mkbody(0)); }
		/* Assigning from HeadVar__2 */
/*
 * Live lvalues:
 *	r2
 */
	{ proceed(); }
		/* Return from procedure call */

/*-------------------------------------------------------------------------*/
/* code for predicate remove/3 in mode 0 */
/* Start of procedure prologue */
/* 
Stack slot assignments (if any):
I	 ->	stackvar(1)
M	 ->	stackvar(2)
P	 ->	stackvar(3)
Is	 ->	stackvar(4)
 */
Define_local(mercury__remove_3_0_l);
		/* Procedure entry point */
/* End of procedure prologue */
/* checking that HeadVar__2 has functor '[]'/0 */
	{ detstackvar(0) = (Integer) succip; }
		/* late save */
	{ if (((Integer) r2 == (Integer) mkword(mktag(0), mkbody(0))))
		GOTO_LABEL(mercury__remove_3_0_i1001); }
		/* tag test (teardown redirect) */
	{ r3 = (Integer) field(mktag(1), (Integer) r2, 1); }
		/* Assigning from Is */
	{ r4 = (Integer) field(mktag(1), (Integer) r2, 0); }
		/* Assigning from I */
	{ r5 = ((Integer) r4 % (Integer) r1); }
		/* Assigning from M */
/* checking that M has functor 0 */
	{ if (((Integer) r5 == 0))
		GOTO_LABEL(mercury__remove_3_0_i1000); }
		/* branch over failure (teardown redirect) */
	incr_sp(5);
		/* late setup after succip */
	{ detstackvar(1) = (Integer) r4; }
		/* Assigning from I */
	{ r2 = (Integer) r3; }
		/* Assigning from Is */
/*
 * Live lvalues:
 *	r1
 *	r2
 *	detstackvar(1)
 *	detstackvar(5)
 */
	{ localcall(mercury__remove_3_0_l,
		LABEL(mercury__remove_3_0_i10),
		LABEL(mercury__remove_3_0_l)); }
/*
 * Garbage collection livevals info
 *	detstackvar(5)	succip
 *	r3	num(7)
 *	detstackvar(1)	num(2)
 */
		/* branch to det procedure */
Define_label(mercury__remove_3_0_i8);
	while (1) {
	{ r2 = (Integer) r3; }
		/* vn flush */
	{ LVALUE_CAST(Word,succip) = (Integer) detstackvar(5); }
		/* vn flush */
	{ if (((Integer) r2 == (Integer) mkword(mktag(0), mkbody(0))))
		GOTO_LABEL(mercury__remove_3_0_i4); }
		/* tag test (teardown redirect) (original) */
	{ r3 = (Integer) field(mktag(1), (Integer) r2, 1); }
		/* Assigning from Is */
	{ r4 = (Integer) field(mktag(1), (Integer) r2, 0); }
		/* Assigning from I */
	{ r5 = ((Integer) r4 % (Integer) r1); }
		/* Assigning from M */
	{ if (((Integer) r5 == 0))
		continue; }
		/* branch over failure (teardown redirect) (original) */
	{ detstackvar(1) = (Integer) r4; }
		/* Assigning from I */
	{ r2 = (Integer) r3; }
		/* Assigning from Is */
/*
 * Live lvalues:
 *	r1
 *	r2
 *	detstackvar(1)
 *	detstackvar(5)
 */
	{ localcall(mercury__remove_3_0_l,
		LABEL(mercury__remove_3_0_i10),
		LABEL(mercury__remove_3_0_l)); }
/*
 * Garbage collection livevals info
 *	detstackvar(5)	succip
 *	r3	num(7)
 *	detstackvar(1)	num(2)
 */
		/* branch to det procedure */
	break; } /* end while */
Define_label(mercury__remove_3_0_i10);
	update_prof_current_proc(LABEL(mercury__remove_3_0_l));
		/* Continuation label */
	{ r1 = (Integer) r3; }
		/* shuffle lval */
	{ tag_incr_hp(r3, mktag(1), 2); }
		/* Allocating heap for HeadVar__3 */
	{ field(mktag(1), (Integer) r3, 0) = (Integer) detstackvar(1); }
		/* Assigning from  */
	{ field(mktag(1), (Integer) r3, 1) = (Integer) r1; }
		/* Assigning from  */
	{ LVALUE_CAST(Word,succip) = (Integer) detstackvar(5); }
		/* restore the success ip */
	decr_sp(5);
		/* Deallocate stack frame */
/*
 * Live lvalues:
 *	r3
 */
	{ proceed(); }
		/* shortcircuit */
Define_label(mercury__remove_3_0_i4);
		/* next case */
	{ r3 = (Integer) mkword(mktag(0), mkbody(0)); }
		/* Assigning from HeadVar__3 */
	{ LVALUE_CAST(Word,succip) = (Integer) detstackvar(5); }
		/* restore the success ip */
	decr_sp(5);
		/* Deallocate stack frame */
/*
 * Live lvalues:
 *	r3
 */
	{ proceed(); }
		/* Return from procedure call */
Define_label(mercury__remove_3_0_i1000);
		/* non-teardown parallel label */
	while (1) {
	{ r2 = (Integer) r3; }
		/* vn flush */
	{ detstackvar(0) = (Integer) succip; }
		/* late save */
	{ if (((Integer) r2 == (Integer) mkword(mktag(0), mkbody(0))))
		GOTO_LABEL(mercury__remove_3_0_i1001); }
		/* tag test (teardown redirect) */
	{ r3 = (Integer) field(mktag(1), (Integer) r2, 1); }
		/* Assigning from Is */
	{ r4 = (Integer) field(mktag(1), (Integer) r2, 0); }
		/* Assigning from I */
	{ r5 = ((Integer) r4 % (Integer) r1); }
		/* Assigning from M */
/* checking that M has functor 0 */
	{ if (((Integer) r5 == 0))
		continue; }
		/* branch over failure (teardown redirect) */
	incr_sp(5);
		/* late setup after succip */
	{ detstackvar(1) = (Integer) r4; }
		/* Assigning from I */
	{ r2 = (Integer) r3; }
		/* Assigning from Is */
/*
 * Live lvalues:
 *	r1
 *	r2
 *	detstackvar(1)
 *	detstackvar(5)
 */
	{ localcall(mercury__remove_3_0_l,
		LABEL(mercury__remove_3_0_i10),
		LABEL(mercury__remove_3_0_l)); }
/*
 * Garbage collection livevals info
 *	detstackvar(5)	succip
 *	r3	num(7)
 *	detstackvar(1)	num(2)
 */
		/* branch to det procedure */
	break; } /* end while */
Define_label(mercury__remove_3_0_i1001);
		/* non-teardown parallel label */
	{ r3 = (Integer) mkword(mktag(0), mkbody(0)); }
		/* Assigning from HeadVar__3 */
/*
 * Live lvalues:
 *	r3
 */
	{ proceed(); }
		/* Return from procedure call */
END_MODULE

#if (defined(USE_GCC_NONLOCAL_GOTOS) && !defined(USE_ASM_LABELS)) \
	|| defined(PROFILE_CALLS) || defined(DEBUG_GOTOS) \
	|| defined(DEBUG_LABELS) || !defined(SPEED)

static void mercury__primes_bunch_0(void)
{
	mercury__primes_module();
}

#endif

void mercury__primes__init(void); /* suppress gcc warning */
void mercury__primes__init(void)
{
#if (defined(USE_GCC_NONLOCAL_GOTOS) && !defined(USE_ASM_LABELS)) \
	|| defined(PROFILE_CALLS) || defined(DEBUG_GOTOS) \
	|| defined(DEBUG_LABELS) || !defined(SPEED)

	mercury__primes_bunch_0();
#endif
}