	; 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>
	; 
	TITLE	rc4-586.asm
        .386
.model FLAT
_TEXT	SEGMENT
PUBLIC	_RC4

_RC4 PROC NEAR
	mov	edx,		DWORD PTR 8[esp]
	cmp	edx,		0
	jne	$L000proceed
	ret
$L000proceed:
	; 
	push	ebp
	push	ebx
	push	esi
	xor	eax,		eax
	push	edi
	xor	ebx,		ebx
	mov	ebp,		DWORD PTR 20[esp]
	mov	esi,		DWORD PTR 28[esp]
	mov	al,		BYTE PTR [ebp]
	mov	bl,		BYTE PTR 4[ebp]
	mov	edi,		DWORD PTR 32[esp]
	inc	al
	sub	esp,		12
	add	ebp,		8
	cmp	DWORD PTR 256[ebp],-1
	je	$L001RC4_CHAR
	lea	edx,		DWORD PTR [esi+edx-8]
	mov	DWORD PTR 8[esp],edx
	mov	ecx,		DWORD PTR [eax*4+ebp]
	cmp	edx,		esi
	jb	$L002end
$L003start:
	add	esi,		8
	; Round 0
	add	bl,		cl
	mov	edx,		DWORD PTR [ebx*4+ebp]
	mov	DWORD PTR [eax*4+ebp],edx
	add	edx,		ecx
	mov	DWORD PTR [ebx*4+ebp],ecx
	and	edx,		255
	inc	al
	mov	ecx,		DWORD PTR [eax*4+ebp]
	mov	edx,		DWORD PTR [edx*4+ebp]
	mov	BYTE PTR [esp],	dl
	; Round 1
	add	bl,		cl
	mov	edx,		DWORD PTR [ebx*4+ebp]
	mov	DWORD PTR [eax*4+ebp],edx
	add	edx,		ecx
	mov	DWORD PTR [ebx*4+ebp],ecx
	and	edx,		255
	inc	al
	mov	ecx,		DWORD PTR [eax*4+ebp]
	mov	edx,		DWORD PTR [edx*4+ebp]
	mov	BYTE PTR 1[esp],dl
	; Round 2
	add	bl,		cl
	mov	edx,		DWORD PTR [ebx*4+ebp]
	mov	DWORD PTR [eax*4+ebp],edx
	add	edx,		ecx
	mov	DWORD PTR [ebx*4+ebp],ecx
	and	edx,		255
	inc	al
	mov	ecx,		DWORD PTR [eax*4+ebp]
	mov	edx,		DWORD PTR [edx*4+ebp]
	mov	BYTE PTR 2[esp],dl
	; Round 3
	add	bl,		cl
	mov	edx,		DWORD PTR [ebx*4+ebp]
	mov	DWORD PTR [eax*4+ebp],edx
	add	edx,		ecx
	mov	DWORD PTR [ebx*4+ebp],ecx
	and	edx,		255
	inc	al
	mov	ecx,		DWORD PTR [eax*4+ebp]
	mov	edx,		DWORD PTR [edx*4+ebp]
	mov	BYTE PTR 3[esp],dl
	; Round 4
	add	bl,		cl
	mov	edx,		DWORD PTR [ebx*4+ebp]
	mov	DWORD PTR [eax*4+ebp],edx
	add	edx,		ecx
	mov	DWORD PTR [ebx*4+ebp],ecx
	and	edx,		255
	inc	al
	mov	ecx,		DWORD PTR [eax*4+ebp]
	mov	edx,		DWORD PTR [edx*4+ebp]
	mov	BYTE PTR 4[esp],dl
	; Round 5
	add	bl,		cl
	mov	edx,		DWORD PTR [ebx*4+ebp]
	mov	DWORD PTR [eax*4+ebp],edx
	add	edx,		ecx
	mov	DWORD PTR [ebx*4+ebp],ecx
	and	edx,		255
	inc	al
	mov	ecx,		DWORD PTR [eax*4+ebp]
	mov	edx,		DWORD PTR [edx*4+ebp]
	mov	BYTE PTR 5[esp],dl
	; Round 6
	add	bl,		cl
	mov	edx,		DWORD PTR [ebx*4+ebp]
	mov	DWORD PTR [eax*4+ebp],edx
	add	edx,		ecx
	mov	DWORD PTR [ebx*4+ebp],ecx
	and	edx,		255
	inc	al
	mov	ecx,		DWORD PTR [eax*4+ebp]
	mov	edx,		DWORD PTR [edx*4+ebp]
	mov	BYTE PTR 6[esp],dl
	; Round 7
	add	bl,		cl
	mov	edx,		DWORD PTR [ebx*4+ebp]
	mov	DWORD PTR [eax*4+ebp],edx
	add	edx,		ecx
	mov	DWORD PTR [ebx*4+ebp],ecx
	and	edx,		255
	inc	al
	mov	edx,		DWORD PTR [edx*4+ebp]
	add	edi,		8
	mov	BYTE PTR 7[esp],dl
	; apply the cipher text
	mov	ecx,		DWORD PTR [esp]
	mov	edx,		DWORD PTR [esi-8]
	xor	ecx,		edx
	mov	edx,		DWORD PTR [esi-4]
	mov	DWORD PTR [edi-8],ecx
	mov	ecx,		DWORD PTR 4[esp]
	xor	ecx,		edx
	mov	edx,		DWORD PTR 8[esp]
	mov	DWORD PTR [edi-4],ecx
	mov	ecx,		DWORD PTR [eax*4+ebp]
	cmp	esi,		edx
	jbe	$L003start
$L002end:
	; Round 0
	add	edx,		8
	inc	esi
	cmp	edx,		esi
	jb	$L004finished
	mov	DWORD PTR 8[esp],edx
	add	bl,		cl
	mov	edx,		DWORD PTR [ebx*4+ebp]
	mov	DWORD PTR [eax*4+ebp],edx
	add	edx,		ecx
	mov	DWORD PTR [ebx*4+ebp],ecx
	and	edx,		255
	inc	al
	mov	ecx,		DWORD PTR [eax*4+ebp]
	mov	edx,		DWORD PTR [edx*4+ebp]
	mov	dh,		BYTE PTR [esi-1]
	xor	dl,		dh
	mov	BYTE PTR [edi],	dl
	; Round 1
	mov	edx,		DWORD PTR 8[esp]
	cmp	edx,		esi
	jbe	$L004finished
	inc	esi
	add	bl,		cl
	mov	edx,		DWORD PTR [ebx*4+ebp]
	mov	DWORD PTR [eax*4+ebp],edx
	add	edx,		ecx
	mov	DWORD PTR [ebx*4+ebp],ecx
	and	edx,		255
	inc	al
	mov	ecx,		DWORD PTR [eax*4+ebp]
	mov	edx,		DWORD PTR [edx*4+ebp]
	mov	dh,		BYTE PTR [esi-1]
	xor	dl,		dh
	mov	BYTE PTR 1[edi],dl
	; Round 2
	mov	edx,		DWORD PTR 8[esp]
	cmp	edx,		esi
	jbe	$L004finished
	inc	esi
	add	bl,		cl
	mov	edx,		DWORD PTR [ebx*4+ebp]
	mov	DWORD PTR [eax*4+ebp],edx
	add	edx,		ecx
	mov	DWORD PTR [ebx*4+ebp],ecx
	and	edx,		255
	inc	al
	mov	ecx,		DWORD PTR [eax*4+ebp]
	mov	edx,		DWORD PTR [edx*4+ebp]
	mov	dh,		BYTE PTR [esi-1]
	xor	dl,		dh
	mov	BYTE PTR 2[edi],dl
	; Round 3
	mov	edx,		DWORD PTR 8[esp]
	cmp	edx,		esi
	jbe	$L004finished
	inc	esi
	add	bl,		cl
	mov	edx,		DWORD PTR [ebx*4+ebp]
	mov	DWORD PTR [eax*4+ebp],edx
	add	edx,		ecx
	mov	DWORD PTR [ebx*4+ebp],ecx
	and	edx,		255
	inc	al
	mov	ecx,		DWORD PTR [eax*4+ebp]
	mov	edx,		DWORD PTR [edx*4+ebp]
	mov	dh,		BYTE PTR [esi-1]
	xor	dl,		dh
	mov	BYTE PTR 3[edi],dl
	; Round 4
	mov	edx,		DWORD PTR 8[esp]
	cmp	edx,		esi
	jbe	$L004finished
	inc	esi
	add	bl,		cl
	mov	edx,		DWORD PTR [ebx*4+ebp]
	mov	DWORD PTR [eax*4+ebp],edx
	add	edx,		ecx
	mov	DWORD PTR [ebx*4+ebp],ecx
	and	edx,		255
	inc	al
	mov	ecx,		DWORD PTR [eax*4+ebp]
	mov	edx,		DWORD PTR [edx*4+ebp]
	mov	dh,		BYTE PTR [esi-1]
	xor	dl,		dh
	mov	BYTE PTR 4[edi],dl
	; Round 5
	mov	edx,		DWORD PTR 8[esp]
	cmp	edx,		esi
	jbe	$L004finished
	inc	esi
	add	bl,		cl
	mov	edx,		DWORD PTR [ebx*4+ebp]
	mov	DWORD PTR [eax*4+ebp],edx
	add	edx,		ecx
	mov	DWORD PTR [ebx*4+ebp],ecx
	and	edx,		255
	inc	al
	mov	ecx,		DWORD PTR [eax*4+ebp]
	mov	edx,		DWORD PTR [edx*4+ebp]
	mov	dh,		BYTE PTR [esi-1]
	xor	dl,		dh
	mov	BYTE PTR 5[edi],dl
	; Round 6
	mov	edx,		DWORD PTR 8[esp]
	cmp	edx,		esi
	jbe	$L004finished
	inc	esi
	add	bl,		cl
	mov	edx,		DWORD PTR [ebx*4+ebp]
	mov	DWORD PTR [eax*4+ebp],edx
	add	edx,		ecx
	mov	DWORD PTR [ebx*4+ebp],ecx
	and	edx,		255
	inc	al
	mov	edx,		DWORD PTR [edx*4+ebp]
	mov	dh,		BYTE PTR [esi-1]
	xor	dl,		dh
	mov	BYTE PTR 6[edi],dl
	jmp	$L004finished
$L001RC4_CHAR:
	lea	edx,		DWORD PTR [edx+esi]
	mov	DWORD PTR 8[esp],edx
$L005RC4_CHAR_loop:
	movzx	ecx,		BYTE PTR [eax+ebp]
	add	bl,		cl
	movzx	edx,		BYTE PTR [ebx+ebp]
	mov	BYTE PTR [ebx+ebp],cl
	mov	BYTE PTR [eax+ebp],dl
	add	dl,		cl
	movzx	edx,		BYTE PTR [edx+ebp]
	xor	dl,		BYTE PTR [esi]
	mov	BYTE PTR [edi],	dl
	inc	al
	inc	esi
	inc	edi
	cmp	esi,		DWORD PTR 8[esp]
	jb	$L005RC4_CHAR_loop
$L004finished:
	dec	eax
	add	esp,		12
	mov	BYTE PTR [ebp-4],bl
	mov	BYTE PTR [ebp-8],al
	pop	edi
	pop	esi
	pop	ebx
	pop	ebp
	ret
_RC4 ENDP
_TEXT	ENDS
END
