	; Don't even think of reading this code
	; It was automatically generated by rc4-586.pl
	; Which is a perl program used to generate the x86 assember for
	; any of elf, a.out, BSDI, Win32, gaswin (for GNU as on Win32) or Solaris
	; eric <eay@cryptsoft.com>
	; 
segment .text
global	_RC4
_RC4:
	; 
	push	ebp
	push	ebx
	mov	ebp,		[12+esp]
	mov	ebx,		[16+esp]
	push	esi
	push	edi
	mov	ecx,		[ebp]
	mov	edx,		[4+ebp]
	mov	esi,		[28+esp]
	inc	ecx
	sub	esp,		12
	add	ebp,		8
	and	ecx,		255
	lea	ebx,		[esi+ebx-8]
	mov	edi,		[44+esp]
	mov	[8+esp],	ebx
	mov	eax,		[ecx*4+ebp]
	cmp	ebx,		esi
	jl NEAR	$L000end
L001start:
	add	esi,		8
	; Round 0
	add	edx,		eax
	and	edx,		255
	inc	ecx
	mov	ebx,		[edx*4+ebp]
	mov	[ecx*4+ebp-4],	ebx
	add	ebx,		eax
	and	ecx,		255
	and	ebx,		255
	mov	[edx*4+ebp],	eax
	nop
	mov	ebx,		[ebx*4+ebp]
	mov	eax,		[ecx*4+ebp]
	mov	[esp],		bl
	; Round 1
	add	edx,		eax
	and	edx,		255
	inc	ecx
	mov	ebx,		[edx*4+ebp]
	mov	[ecx*4+ebp-4],	ebx
	add	ebx,		eax
	and	ecx,		255
	and	ebx,		255
	mov	[edx*4+ebp],	eax
	nop
	mov	ebx,		[ebx*4+ebp]
	mov	eax,		[ecx*4+ebp]
	mov	[1+esp],	bl
	; Round 2
	add	edx,		eax
	and	edx,		255
	inc	ecx
	mov	ebx,		[edx*4+ebp]
	mov	[ecx*4+ebp-4],	ebx
	add	ebx,		eax
	and	ecx,		255
	and	ebx,		255
	mov	[edx*4+ebp],	eax
	nop
	mov	ebx,		[ebx*4+ebp]
	mov	eax,		[ecx*4+ebp]
	mov	[2+esp],	bl
	; Round 3
	add	edx,		eax
	and	edx,		255
	inc	ecx
	mov	ebx,		[edx*4+ebp]
	mov	[ecx*4+ebp-4],	ebx
	add	ebx,		eax
	and	ecx,		255
	and	ebx,		255
	mov	[edx*4+ebp],	eax
	nop
	mov	ebx,		[ebx*4+ebp]
	mov	eax,		[ecx*4+ebp]
	mov	[3+esp],	bl
	; Round 4
	add	edx,		eax
	and	edx,		255
	inc	ecx
	mov	ebx,		[edx*4+ebp]
	mov	[ecx*4+ebp-4],	ebx
	add	ebx,		eax
	and	ecx,		255
	and	ebx,		255
	mov	[edx*4+ebp],	eax
	nop
	mov	ebx,		[ebx*4+ebp]
	mov	eax,		[ecx*4+ebp]
	mov	[4+esp],	bl
	; Round 5
	add	edx,		eax
	and	edx,		255
	inc	ecx
	mov	ebx,		[edx*4+ebp]
	mov	[ecx*4+ebp-4],	ebx
	add	ebx,		eax
	and	ecx,		255
	and	ebx,		255
	mov	[edx*4+ebp],	eax
	nop
	mov	ebx,		[ebx*4+ebp]
	mov	eax,		[ecx*4+ebp]
	mov	[5+esp],	bl
	; Round 6
	add	edx,		eax
	and	edx,		255
	inc	ecx
	mov	ebx,		[edx*4+ebp]
	mov	[ecx*4+ebp-4],	ebx
	add	ebx,		eax
	and	ecx,		255
	and	ebx,		255
	mov	[edx*4+ebp],	eax
	nop
	mov	ebx,		[ebx*4+ebp]
	mov	eax,		[ecx*4+ebp]
	mov	[6+esp],	bl
	; Round 7
	add	edx,		eax
	and	edx,		255
	inc	ecx
	mov	ebx,		[edx*4+ebp]
	mov	[ecx*4+ebp-4],	ebx
	add	ebx,		eax
	and	ecx,		255
	and	ebx,		255
	mov	[edx*4+ebp],	eax
	nop
	mov	ebx,		[ebx*4+ebp]
	add	edi,		8
	mov	[7+esp],	bl
	; apply the cipher text
	mov	eax,		[esp]
	mov	ebx,		[esi-8]
	xor	eax,		ebx
	mov	ebx,		[esi-4]
	mov	[edi-8],	eax
	mov	eax,		[4+esp]
	xor	eax,		ebx
	mov	ebx,		[8+esp]
	mov	[edi-4],	eax
	mov	eax,		[ecx*4+ebp]
	cmp	esi,		ebx
	jle NEAR	L001start
$L000end:
	; Round 0
	add	ebx,		8
	inc	esi
	cmp	ebx,		esi
	jl NEAR	$L002finished
	mov	[8+esp],	ebx
	add	edx,		eax
	and	edx,		255
	inc	ecx
	mov	ebx,		[edx*4+ebp]
	mov	[ecx*4+ebp-4],	ebx
	add	ebx,		eax
	and	ecx,		255
	and	ebx,		255
	mov	[edx*4+ebp],	eax
	nop
	mov	ebx,		[ebx*4+ebp]
	mov	eax,		[ecx*4+ebp]
	mov	bh,		[esi-1]
	xor	bl,		bh
	mov	[edi],		bl
	; Round 1
	mov	ebx,		[8+esp]
	cmp	ebx,		esi
	jle NEAR	$L002finished
	inc	esi
	add	edx,		eax
	and	edx,		255
	inc	ecx
	mov	ebx,		[edx*4+ebp]
	mov	[ecx*4+ebp-4],	ebx
	add	ebx,		eax
	and	ecx,		255
	and	ebx,		255
	mov	[edx*4+ebp],	eax
	nop
	mov	ebx,		[ebx*4+ebp]
	mov	eax,		[ecx*4+ebp]
	mov	bh,		[esi-1]
	xor	bl,		bh
	mov	[1+edi],	bl
	; Round 2
	mov	ebx,		[8+esp]
	cmp	ebx,		esi
	jle NEAR	$L002finished
	inc	esi
	add	edx,		eax
	and	edx,		255
	inc	ecx
	mov	ebx,		[edx*4+ebp]
	mov	[ecx*4+ebp-4],	ebx
	add	ebx,		eax
	and	ecx,		255
	and	ebx,		255
	mov	[edx*4+ebp],	eax
	nop
	mov	ebx,		[ebx*4+ebp]
	mov	eax,		[ecx*4+ebp]
	mov	bh,		[esi-1]
	xor	bl,		bh
	mov	[2+edi],	bl
	; Round 3
	mov	ebx,		[8+esp]
	cmp	ebx,		esi
	jle NEAR	$L002finished
	inc	esi
	add	edx,		eax
	and	edx,		255
	inc	ecx
	mov	ebx,		[edx*4+ebp]
	mov	[ecx*4+ebp-4],	ebx
	add	ebx,		eax
	and	ecx,		255
	and	ebx,		255
	mov	[edx*4+ebp],	eax
	nop
	mov	ebx,		[ebx*4+ebp]
	mov	eax,		[ecx*4+ebp]
	mov	bh,		[esi-1]
	xor	bl,		bh
	mov	[3+edi],	bl
	; Round 4
	mov	ebx,		[8+esp]
	cmp	ebx,		esi
	jle NEAR	$L002finished
	inc	esi
	add	edx,		eax
	and	edx,		255
	inc	ecx
	mov	ebx,		[edx*4+ebp]
	mov	[ecx*4+ebp-4],	ebx
	add	ebx,		eax
	and	ecx,		255
	and	ebx,		255
	mov	[edx*4+ebp],	eax
	nop
	mov	ebx,		[ebx*4+ebp]
	mov	eax,		[ecx*4+ebp]
	mov	bh,		[esi-1]
	xor	bl,		bh
	mov	[4+edi],	bl
	; Round 5
	mov	ebx,		[8+esp]
	cmp	ebx,		esi
	jle NEAR	$L002finished
	inc	esi
	add	edx,		eax
	and	edx,		255
	inc	ecx
	mov	ebx,		[edx*4+ebp]
	mov	[ecx*4+ebp-4],	ebx
	add	ebx,		eax
	and	ecx,		255
	and	ebx,		255
	mov	[edx*4+ebp],	eax
	nop
	mov	ebx,		[ebx*4+ebp]
	mov	eax,		[ecx*4+ebp]
	mov	bh,		[esi-1]
	xor	bl,		bh
	mov	[5+edi],	bl
	; Round 6
	mov	ebx,		[8+esp]
	cmp	ebx,		esi
	jle NEAR	$L002finished
	inc	esi
	add	edx,		eax
	and	edx,		255
	inc	ecx
	mov	ebx,		[edx*4+ebp]
	mov	[ecx*4+ebp-4],	ebx
	add	ebx,		eax
	and	ecx,		255
	and	ebx,		255
	mov	[edx*4+ebp],	eax
	nop
	mov	ebx,		[ebx*4+ebp]
	mov	bh,		[esi-1]
	xor	bl,		bh
	mov	[6+edi],	bl
$L002finished:
	dec	ecx
	add	esp,		12
	mov	[ebp-4],	edx
	mov	[ebp-8],	cl
	pop	edi
	pop	esi
	pop	ebx
	pop	ebp
	ret
