
uint16_t ax = 0, bx = 0, cx = 0, dx = 0, si = 0, sp = 0, tx = 0;
uint8_t *bp, cl = 0;
static uint16_t stack[1024];

int carry = 0;  

void
f0x17e()
{
	stack[sp++] =  si  ;

	tx =  ax ,  ax  =   si ,   si  = tx ;
	tx =  ax ,  ax  =   dx ,   dx  = tx ;
	if (ax) {
		ax *= bx;
	}
	if (cx) {
		tx =  ax ,  ax  =   cx ,   cx  = tx ;
		ax *= si;
		ax += cx;
	}
	tx =  ax ,  ax  =   si ,   si  = tx ;
	ax *= bx;
	dx += si;

	 si  = stack[sp--] ;
}

void
f0x262()
{
	if (cl >= 0x10) {
		cl -= 0x10;
		tx =  ax ,  ax  =   dx ,   dx  = tx ;
		ax = 0;
		dx = dx << cl;
	} else {
		bx = ax;
		ax = ax << cl;
		dx = dx << cl;
		cl = ~cl;
		cl += 0x10;
		bx = bx >> cl;
		dx |= bx;
	}
}

void
f0x283()
{
	if (cl >= 0x10) {
		cl -= 0x10;
		tx =  ax ,  ax  =   dx ,   dx  = tx ;
		dx = ( ax  & 0x7000 ? 0xffff : 0) ;
		ax >>= cl;
	} else {
		bx = dx;
		ax >>= cl;
		dx >>= cl;
		cl = ~cl;
		cl += 0x10;
		bx <<= cl;
		ax |= bx;
	}
}

void
function()
{
	 ;

	stack[sp++] =  si  ;

	ax = *((uint16_t *) (bp + 0x6));
	ax &= 0xf;
	*((uint16_t *) (bp - 0x6)) = ax;
	dx = ( ax  & 0x7000 ? 0xffff : 0) ;

	bx = *((uint16_t *) (bp + 0xc));

	stack[sp++] =  ax  ;
	stack[sp++] =  dx  ;
	stack[sp++] =  bx  ;
	 ax  = stack[sp--] ;
	 dx  = stack[sp--] ;
	 cx  = stack[sp--] ;

	bx = *((uint16_t *) (bp + 0xa));
	(carry = ( bx  +   cx  > 0xffff)),  bx  +=   cx  ;
	ax += dx + carry;
	stack[sp++] =  bx  ;
	stack[sp++] =  ax  ;

	ax = *((uint16_t *) (bp - 0x6));
	dx = ( ax  & 0x7000 ? 0xffff : 0) ;
	stack[sp++] =  ax  ;
	stack[sp++] =  dx  ;

	dx = *((uint16_t *) (bp + 0x10));
	ax = *((uint16_t *) (bp + 0xe));

	 bx  = stack[sp--] ;
	 cx  = stack[sp--] ;
	(carry = ( ax  +   cx  > 0xffff)),  ax  +=   cx  ;
	dx += bx + carry;

	 cx  = stack[sp--] ;
	 bx  = stack[sp--] ;

	f0x17e();

	 
	bx = *((uint16_t *) (bp + 0xc));
	cx = *((uint16_t *) (bp + 0xa));
	(carry = ( cx  +   *((uint16_t *) (bp + 0xe))  > 0xffff)),  cx  +=   *((uint16_t *) (bp + 0xe))  ;
	bx += *((uint16_t *) (bp + 0x10)) + carry;
	(carry = ( cx  +   *((uint16_t *) (bp + 0x12))  > 0xffff)),  cx  +=   *((uint16_t *) (bp + 0x12))  ;
	bx += *((uint16_t *) (bp + 0x14)) + carry;
	(carry = ( cx  +   *((uint16_t *) (bp + 0x6))  > 0xffff)),  cx  +=   *((uint16_t *) (bp + 0x6))  ;
	bx += *((uint16_t *) (bp + 0x8)) + carry;
	cx += ax;
	bx += dx;

	ax = *((uint16_t *) (bp - 0x6));
	dx = ( ax  & 0x7000 ? 0xffff : 0) ;

	si = *((uint16_t *) (bp + 0x14));

	stack[sp++] =  cx  ;
	stack[sp++] =  bx  ;

	bx = *((uint16_t *) (bp + 0x12));
	(carry = ( bx  +   ax  > 0xffff)),  bx  +=   ax  ;
	si += dx + carry;
	ax = *((uint16_t *) (bp - 0x6));
	dx = ( ax  & 0x7000 ? 0xffff : 0) ;

	stack[sp++] =  bx  ;
	stack[sp++] =  si  ;
	stack[sp++] =  ax  ;
	stack[sp++] =  dx  ;

	dx = *((uint16_t *) (bp + 0x8));
	ax = *((uint16_t *) (bp + 0x6));
	 bx  = stack[sp--] ;
	 cx  = stack[sp--] ;
	(carry = ( ax  +   cx  > 0xffff)),  ax  +=   cx  ;
	dx += bx + carry;
	 bx  = stack[sp--] ;
	 cx  = stack[sp--] ;
	
	f0x17e();

	 bx  = stack[sp--] ;
	 cx  = stack[sp--] ;
	(carry = ( cx  +   ax  > 0xffff)),  cx  +=   ax  ;
	bx += dx + carry;

	*((uint16_t *) (bp - 0x2)) = bx;
	*((uint16_t *) (bp - 0x4)) = cx;
	dx = *((uint16_t *) (bp - 0x2));
	ax = *((uint16_t *) (bp - 0x4));
	cl = *((uint16_t *) (bp - 0x6));  

	f0x262();  

	bx = *((uint16_t *) (bp - 0x2));
	cx = *((uint16_t *) (bp - 0x4));

	(carry = ( cx  +   ax  > 0xffff)),  cx  +=   ax  ;
	bx += dx + carry;
	dx = *((uint16_t *) (bp - 0xc));
	ax = *((uint16_t *) (bp - 0xa));

	stack[sp++] =  cx  ;
	cl = 0x7;
	stack[sp++] =  bx  ;

	f0x262();  

	 bx  = stack[sp--] ;
	 cx  = stack[sp--] ;

	(carry = ( cx  +   ax  > 0xffff)),  cx  +=   ax  ;
	bx += dx + carry;
	dx = *((uint16_t *) (bp + 0x14));
	ax = *((uint16_t *) (bp + 0x12));

	stack[sp++] =  cx  ;
	cl = 0xb;
	stack[sp++] =  bx  ;

	f0x262();  
	
	 bx  = stack[sp--] ;
	 cx  = stack[sp--] ;

	(carry = ( cx  +   ax  > 0xffff)),  cx  +=   ax  ;
	bx += dx + carry;
	dx = *((uint16_t *) (bp + 0x10));
	ax = *((uint16_t *) (bp + 0xe));

	stack[sp++] =  cx  ;
	cl = 0x11;
	stack[sp++] =  bx  ;

	f0x262();  

	 bx  = stack[sp--] ;
	 cx  = stack[sp--] ;

	(carry = ( cx  +   ax  > 0xffff)),  cx  +=   ax  ;
	bx += dx + carry;
	dx = *((uint16_t *) (bp - 0x2));
	ax = *((uint16_t *) (bp - 0x4));

	cl = 0xd;

	f0x262();  

	stack[sp++] =  ax  ;
	stack[sp++] =  dx  ;

	dx = *((uint16_t *) (bp - 0x2));
	ax = *((uint16_t *) (bp - 0x4));

	cl = 0xf;

	f0x283();  
	
	 bx  = stack[sp--] ;
	 cx  = stack[sp--] ;

	(carry = ( cx  +   ax  > 0xffff)),  cx  +=   ax  ;
	bx += dx + carry;
	*((uint16_t *) (bp - 0x4)) = cx;
	*((uint16_t *) (bp - 0x2)) = bx;
	*((uint16_t *) (bp - 0x4)) &= 0xffff;
	*((uint16_t *) (bp - 0x2)) &= 0x7fff;
	*((uint16_t *) (bp - 0x4)) |= 0x0;
	*((uint16_t *) (bp - 0x2)) |= 0x4000;

	dx = *((uint16_t *) (bp - 0x2));
	ax = *((uint16_t *) (bp - 0x4));

	goto _3528;
_3528:
	 si  = stack[sp--] ;

	 ;
}

int
main(int argc, char *argv[])
{
 


































	 

















	 








	uint8_t *bp_ = calloc(0x40, 1);

	bp = bp_ + 0x20;

	if (argc < 4) return 1;

	*((uint32_t *) (bp + 0x6)) = atol(argv[1]);  
	*((uint32_t *) (bp + 0xa)) = atol(argv[2]);  
	*((uint32_t *) (bp + 0xe)) = atol(argv[3]);  
	*((uint32_t *) (bp + 0x12)) = atol(argv[4]);  

	function();

	printf("%04x%04x\n", ax, dx);
	{
		int i;
		for (i = 0; i < 0x40; i += 0x4) {
			printf("%02x: %08x\n", i, *((uint32_t *) (bp_ + i)));
		}
	}

	return 0;
}
