Function at 0x402d20
Capabilities:
Encode data using xor

Disassembly:
sub esp, 8
mov eax, dword [0x40f53c]
push ebx
push ebp
push esi
xor esi, esi
xor ebx, ebx
mov si, word [0x40f4e4]
push edi
test eax, eax
mov eax, dword [0x40f598]
mov dword [esp + 0x14], 0
mov word [0x40f540], 0
je 0x40302f
mov edx, dword [0x40f620]
xor ecx, ecx
and esi, 0x3ff
xor edi, edi
mov cl, byte [eax + edx + 2]
mov edx, dword [0x40f610]
and ecx, 0x7fff
and eax, 0x7fff
shl esi, 5
xor esi, ecx
xor ecx, ecx
mov cx, word [edx + esi*2]
mov edx, dword [0x40f4ec]
test ecx, ecx
mov word [edx + eax*2], cx
mov edx, dword [0x40f610]
mov ax, word [0x40f598]
mov word [edx + esi*2], ax
mov di, word [0x40f540]
mov dx, bx
mov ebx, 2
mov word [0x40f588], dx
je 0x402e2b
movsx eax, word [0x40f60c]
xor ebp, ebp
mov bp, dx
cmp ebp, eax
jge 0x402e2b
mov eax, dword [0x40f598]
mov ebp, eax
sub ebp, ecx
cmp ebp, 0x7efa
ja 0x402e30
push ecx
call fcn.00402b80
mov ebx, eax
mov eax, dword [0x40f53c]
add esp, 4
cmp ebx, eax
jbe 0x402df0
mov ebx, eax
cmp ebx, 3
jne 0x402e1d
mov eax, dword [0x40f598]
xor ecx, ecx
mov cx, word [0x40f540]
mov edx, eax
sub edx, ecx
cmp edx, 0x1000
jle 0x402e14
mov ebx, 2
mov dx, word [0x40f588]
jmp 0x402e30
mov eax, dword [0x40f598]
mov dx, word [0x40f588]
jmp 0x402e30
mov eax, dword [0x40f598]
cmp dx, 3
jb 0x402f47
xor ecx, ecx
mov cx, dx
cmp ebx, ecx
ja 0x402f47
lea ecx, [esp + 0x10]
sub eax, edi
sub dx, 3
push ecx
dec eax
push edx
push eax
call fcn.00404a70
add esp, 0xc
test eax, eax
je 0x403043
mov ax, word [0x40f588]
xor edx, edx
mov dx, ax
mov ecx, 1
sub ecx, edx
mov edx, dword [0x40f53c]
add edx, ecx
add ax, 0xfffe
mov dword [0x40f53c], edx
mov word [0x40f588], ax
mov eax, dword [0x40f598]
mov ecx, dword [0x40f620]
inc eax
xor edx, edx
mov dword [0x40f598], eax
and esi, 0x3ff
mov dl, byte [eax + ecx + 2]
mov ecx, dword [0x40f610]
and edx, 0x7fff
and eax, 0x7fff
shl esi, 5
xor esi, edx
mov dx, word [ecx + esi*2]
mov ecx, dword [0x40f4ec]
mov word [ecx + eax*2], dx
mov eax, dword [0x40f610]
mov dx, word [0x40f598]
mov word [eax + esi*2], dx
dec word [0x40f588]
jne 0x402e8f
mov eax, dword [0x40f598]
mov ecx, dword [esp + 0x10]
xor edi, edi
inc eax
test ecx, ecx
mov dword [esp + 0x14], edi
mov ebx, 2
mov dword [0x40f598], eax
je 0x402fdc
mov edx, dword [0x40f538]
test edx, edx
jl 0x402f1f
mov ecx, dword [0x40f620]
add ecx, edx
jmp 0x402f21
xor ecx, ecx
sub eax, edx
push 0
push eax
push ecx
call fcn.00405910
add esp, 0xc
test ax, ax
jne 0x40306b
mov eax, dword [0x40f598]
mov dword [0x40f538], eax
jmp 0x402fdc
mov edi, dword [esp + 0x14]
test edi, edi
je 0x402fc0
mov ecx, dword [0x40f620]
lea edx, [esp + 0x10]
push edx
movzx dx, byte [eax + ecx - 1]
push edx
push 0
call fcn.00404a70
add esp, 0xc
test eax, eax
je 0x403043
mov eax, dword [esp + 0x10]
test eax, eax
je 0x402fb9
mov ecx, dword [0x40f538]
test ecx, ecx
jl 0x402f8e
mov eax, dword [0x40f620]
add eax, ecx
jmp 0x402f90
xor eax, eax
mov edx, dword [0x40f598]
push 0
sub edx, ecx
push edx
push eax
call fcn.00405910
add esp, 0xc
test ax, ax
jne 0x40306b
mov eax, dword [0x40f598]
mov dword [0x40f538], eax
jmp 0x402fc9
mov eax, dword [0x40f598]
jmp 0x402fc9
mov edi, 1
mov dword [esp + 0x14], edi
mov ecx, dword [0x40f53c]
inc eax
dec ecx
mov dword [0x40f598], eax
mov dword [0x40f53c], ecx
cmp dword [0x40f53c], 0x106
jge 0x402ffc
mov ecx, dword [0x40f558]
test ecx, ecx
jne 0x402ffc
call fcn.00402820
mov eax, dword [0x40f598]
mov ecx, dword [0x40f53c]
test ecx, ecx
jne 0x402d55
test edi, edi
je 0x40302f
mov edx, dword [0x40f620]
lea ecx, [esp + 0x10]
push ecx
movzx ax, byte [eax + edx - 1]
push eax
push 0
call fcn.00404a70
mov eax, dword [0x40f598]
add esp, 0xc
mov edx, dword [0x40f538]
test edx, edx
jl 0x40304f
mov ecx, dword [0x40f620]
add ecx, edx
jmp 0x403051
pop edi
pop esi
pop ebp
mov ax, 0xfff5
pop ebx
add esp, 8
ret
xor ecx, ecx
sub eax, edx
push 1
push eax
push ecx
call fcn.00405910
add esp, 0xc
test ax, ax
jne 0x40306b
mov word [0x40f4e4], si
pop edi
pop esi
pop ebp
pop ebx
add esp, 8
ret